Skip to content

Commit db6c8ed

Browse files
committed
refactor: simplify props to just word list
Uses first word in list as initial text; fixes bug where initial text would never render again
1 parent d270af2 commit db6c8ed

File tree

3 files changed

+5
-11
lines changed

3 files changed

+5
-11
lines changed

app/[locale]/10years/_components/TenYearHero.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import Morpher from "@/components/Morpher"
77
import TenYearBackgroundImage from "@/public/images/10-year-anniversary/10-year-background.png"
88
import TenYearGraphicImage from "@/public/images/10-year-anniversary/10-year-graphic.png"
99

10-
const [initialText, ...initialWords] = [
10+
const WORDS = [
1111
"censorship resistance",
1212
"100% uptime",
1313
"decentralization",
@@ -44,14 +44,10 @@ const TenYearHero = () => (
4444
className="select-none opacity-0 max-md:hidden"
4545
data-label="space-holder"
4646
>
47-
{initialText}
47+
{words[0]}
4848
</span>
4949
<span className="text-3xl font-bold text-accent-b md:absolute md:start-0 md:text-nowrap">
50-
<Morpher
51-
text={initialText}
52-
words={initialWords}
53-
charSet="abcdfgijklnopqsvwxyz"
54-
/>
50+
<Morpher words={WORDS} charSet="abcdfgijklnopqsvwxyz" />
5551
</span>
5652
</span>
5753
</p>

src/components/Homepage/LanguageMorpher.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ const LanguageMorpher = () => {
4141
variant="ghost"
4242
>
4343
<Morpher
44-
text="Ethereum"
4544
words={[
45+
"Ethereum",
4646
"以太坊",
4747
"イーサリアム",
4848
"Etérium",

src/components/Morpher.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,15 @@
33
import { useEffect, useState } from "react"
44

55
type MorpherProps = {
6-
text: string
76
words: string[]
87
charSet?: string
98
}
109

1110
const Morpher = ({
12-
text,
1311
words,
1412
charSet = "abcdefghijklmnopqrstuvwxyz",
1513
}: MorpherProps) => {
16-
const [state, setState] = useState({ text, words })
14+
const [state, setState] = useState({ text: words[0], words })
1715

1816
// loops over chars to morph a text to another
1917
const morpher = (start: string, end: string): void => {

0 commit comments

Comments
 (0)