-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove Attention after first render, jump to def cursor, etc
- Loading branch information
1 parent
1a680ed
commit 12f7c75
Showing
5 changed files
with
49 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,32 @@ | ||
import React from "react"; | ||
import React, { useEffect, useRef } from "react"; | ||
|
||
import "./Attention.css"; | ||
|
||
const DURATION = 1_000; | ||
const CN = "Attention"; | ||
|
||
const Attn = ({ | ||
children, | ||
className = CN | ||
}: React.PropsWithChildren<{ className?: string }>) => { | ||
const ref = useRef<HTMLSpanElement>(null); | ||
useEffect(() => { | ||
setTimeout(() => ref.current?.classList.remove(className), DURATION); | ||
}, []); | ||
|
||
return ( | ||
<span ref={ref} className={className}> | ||
{children} | ||
</span> | ||
); | ||
}; | ||
|
||
export const TextEmphasis = ({ children }: React.PropsWithChildren) => ( | ||
<span className="AttentionText">{children}</span> | ||
<Attn className="AttentionText">{children}</Attn> | ||
); | ||
|
||
const Attention = ({ children }: React.PropsWithChildren) => ( | ||
<span className="Attention">{children}</span> | ||
<Attn>{children}</Attn> | ||
); | ||
|
||
export default Attention; |