Skip to content

Commit

Permalink
Fixing errors
Browse files Browse the repository at this point in the history
  • Loading branch information
AB10110F committed Aug 13, 2023
1 parent 5c56990 commit c8e8188
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ export default function RootLayout({
}) {
return (
<html lang="en">
<Dots/>
<body>
<Dots/>
{children}
</body>
</html>
Expand Down
2 changes: 1 addition & 1 deletion src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default function Home() {
<main className={bright}>
<span className={scanner}></span>
<Image src="/scanlines.jpg" width={500} height={500} className={scanlines} alt="image" />
<Typewriter text={'F ront-End Developer'}/> {/* TODO What is wrong with the position 1? */}
<Typewriter text={'Front-End Developer'}/>
<div className={styles.grid}>
<Terminal/>
<section className={styles.column}>
Expand Down
17 changes: 11 additions & 6 deletions src/components/Typewriter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,18 @@ import { dotFont } from '../fonts/fonts'
const Typewriter = ({ text }: { text:string }) => {
const index = useRef(0);
const [currentText, setCurrentText] = useState('');

useEffect(()=>{
setTimeout(()=>{
setCurrentText((value) => value + text.charAt(index.current));

useEffect(() => {
if (index.current < text.length) {
const nextChar: string = text.charAt(index.current);
const timer = setTimeout(() => {
setCurrentText(val => val + nextChar);
index.current++;
}, 80);
}, [currentText]);
}, 80);

return () => clearTimeout(timer);
}
}, [currentText, text]);

return <h1 style={dotFont.style} >&gt;{currentText}</h1>
};
Expand Down

0 comments on commit c8e8188

Please sign in to comment.