Skip to content

Commit

Permalink
animation css dynamic step
Browse files Browse the repository at this point in the history
  • Loading branch information
ridhozhr10 committed May 14, 2024
1 parent 3cc3fe6 commit 6048261
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
12 changes: 11 additions & 1 deletion src/app/_components/layout/Header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,17 @@ const Logo = ({ text }: { text?: string }) => (
<div>
<span>&gt;</span>
<span>$</span>
{text ? <span>{text}</span> : <span>echo &quot;Hi&quot;</span>}
{text ? (
<span
style={{ animationTimingFunction: `steps(${text.length + 3}, end)` }}
>
{text}
</span>
) : (
<span style={{ animationTimingFunction: `steps(12, end)` }}>
echo &quot;Hi&quot;
</span>
)}
<span className="animate-cursor"></span>
</div>
</Link>
Expand Down
2 changes: 1 addition & 1 deletion src/app/_components/layout/Header/style.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
@apply mr-[5px];
}
& span:nth-child(3) {
@apply animate-typing overflow-hidden whitespace-nowrap tracking-widest w-0;
@apply animate-typing overflow-hidden whitespace-nowrap w-0;
}
& span:nth-child(4) {
@apply inline-block w-2 h-4 bg-red-400 ml-[5px] rounded-[1px];
Expand Down
2 changes: 1 addition & 1 deletion tailwind.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const config: Config = {
},
animation: {
'cursor': 'cursor 1s infinite',
'typing': 'typing 15s steps(25, end) infinite'
'typing': 'typing 15s infinite'
},
keyframes: {
cursor: {
Expand Down

0 comments on commit 6048261

Please sign in to comment.