|
| 1 | +import CodeBlock from '../components/CodeBlock' |
| 2 | + |
| 3 | +const introAnimCSS = `@keyframes appear { |
| 4 | + to { |
| 5 | + width: auto; |
| 6 | + } |
| 7 | +} |
| 8 | +
|
| 9 | +.animate-appear { |
| 10 | + animation: appear 0s linear forwards; |
| 11 | +}` |
| 12 | + |
| 13 | +const introAnimTSX = `{text.map((letter, index) => ( |
| 14 | + <span |
| 15 | + className="inline-block w-0 animate-appear overflow-hidden timeline" |
| 16 | + style={{ |
| 17 | + animationRangeEnd: (index * 64 + 128).toString() + 'px', |
| 18 | + }} |
| 19 | + key={index} |
| 20 | + > |
| 21 | + {letter === ' ' ? '\\u00A0' : letter} |
| 22 | + </span> |
| 23 | +))}` |
| 24 | + |
1 | 25 | const HomeIntroAnimation = () => { |
2 | 26 | const text = Array.from('Scroll. Your next superpower.') |
3 | 27 | return ( |
4 | 28 | <div className="h-[1920px] w-full"> |
5 | | - <div className="flex w-full font-bold text-3xl sm:text-7xl sticky top-32"> |
6 | | - {text.map((letter, index) => ( |
7 | | - <span |
8 | | - className="inline-block w-0 animate-appear overflow-hidden timeline" |
9 | | - style={{ |
10 | | - animationRangeEnd: (index * 64 + 128).toString() + 'px', |
11 | | - }} |
12 | | - key={index} |
13 | | - > |
14 | | - {letter === ' ' ? '\u00A0' : letter} |
15 | | - </span> |
16 | | - ))} |
| 29 | + <div className="sticky top-32"> |
| 30 | + <div className="flex w-full font-bold text-3xl sm:text-7xl"> |
| 31 | + {text.map((letter, index) => ( |
| 32 | + <span |
| 33 | + className="inline-block w-0 animate-appear overflow-hidden timeline" |
| 34 | + style={{ |
| 35 | + animationRangeEnd: (index * 64 + 128).toString() + 'px', |
| 36 | + }} |
| 37 | + key={index} |
| 38 | + > |
| 39 | + {letter === ' ' ? '\u00A0' : letter} |
| 40 | + </span> |
| 41 | + ))} |
| 42 | + </div> |
| 43 | + <CodeBlock language="css">{introAnimCSS}</CodeBlock> |
| 44 | + <CodeBlock language="tsx">{introAnimTSX}</CodeBlock> |
17 | 45 | </div> |
18 | 46 | </div> |
19 | 47 | ) |
|
0 commit comments