Skip to content

Commit 6cb1ad8

Browse files
committed
stagger center section
1 parent d5a8fdf commit 6cb1ad8

File tree

1 file changed

+34
-20
lines changed

1 file changed

+34
-20
lines changed

src/break.jsx

+34-20
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,19 @@ import { maps } from "./utils"
1919
import { forwardRef, useEffect, useState } from "react"
2020

2121
const animateContainer = {
22-
hidden: { x: -20, opacity: 0 },
22+
hidden: {
23+
x: -20,
24+
opacity: 0,
25+
transition: {
26+
staggerChildren: 0.2,
27+
},
28+
},
2329
show: {
2430
x: 0,
2531
opacity: 1,
32+
transition: {
33+
staggerChildren: 0.1,
34+
},
2635
},
2736
}
2837

@@ -89,11 +98,11 @@ const Main = () => {
8998
/>
9099
{screen === "brb" ? (
91100
<motion.div
92-
key="brb"
93-
layout="position"
94-
initial={{ translateX: -20, opacity: 0 }}
95-
animate={{ translateX: 0, opacity: 1 }}
96-
exit={{ translateX: 20, opacity: 0 }}
101+
variants={animateContainer}
102+
key={screen}
103+
initial="hidden"
104+
animate="show"
105+
exit="hidden"
97106
className="flex flex-col gap-8 w-full items-center"
98107
>
99108
<BreakSections
@@ -104,6 +113,7 @@ const Main = () => {
104113
) : (
105114
<motion.div
106115
variants={animateContainer}
116+
key={screen}
107117
initial="hidden"
108118
animate="show"
109119
exit="hidden"
@@ -131,9 +141,7 @@ const Main = () => {
131141
)}
132142
{mapWinners?.[i] && (
133143
<div className="absolute inset-0 flex items-center justify-center p-8 text-center text-4xl font-medium">
134-
<AnimatedText key={mapWinners[i]}>
135-
{mapWinners[i]}
136-
</AnimatedText>
144+
<FadeText key={mapWinners[i]}>{mapWinners[i]}</FadeText>
137145
</div>
138146
)}
139147
</div>
@@ -213,11 +221,17 @@ const BottomSection = ({ comms }) => (
213221
const BottomComms = ({ block }) =>
214222
block.value.map((comm) => (
215223
<div className="flex items-center gap-4">
216-
<div className="text-4xl font-medium">{comm.name}</div>
224+
<div className="text-4xl font-medium">
225+
<FadeText>{comm.name}</FadeText>
226+
</div>
217227
<div className="self-stretch shrink-0 rounded-full w-1 bg-fabl-indigo-light"></div>
218-
<div className="text-fabl-pink font-semibold">{comm.pronouns}</div>
228+
<div className="text-fabl-pink font-semibold">
229+
<FadeText>{comm.pronouns}</FadeText>
230+
</div>
219231
<div className="self-stretch shrink-0 rounded-full w-1 bg-fabl-indigo-light"></div>
220-
<div>{comm.twitter}</div>
232+
<div>
233+
<FadeText>{comm.twitter}</FadeText>
234+
</div>
221235
</div>
222236
))
223237

@@ -279,15 +293,15 @@ const Score = ({ name, score, reverse }) => (
279293
)}
280294
>
281295
<div className="text-5xl font-semibold">
282-
<AnimatedText>{name}</AnimatedText>
296+
<FadeText>{name}</FadeText>
283297
</div>
284298
<div className="text-5xl font-bold w-8 flex justify-center">
285-
<AnimatedText>{score}</AnimatedText>
299+
<FadeText>{score}</FadeText>
286300
</div>
287301
</motion.div>
288302
)
289303

290-
const AnimatedText = ({ children }) => (
304+
const FadeText = ({ children }) => (
291305
<AnimatePresence mode="wait">
292306
<motion.span
293307
key={children}
@@ -321,7 +335,7 @@ const FlavorText = ({ text }) => {
321335
exit={{ opacity: 0 }}
322336
className="text-5xl font-semibold"
323337
>
324-
<AnimatedText>{main}</AnimatedText>
338+
<FadeText>{main}</FadeText>
325339
</motion.div>
326340
)}
327341
{sub && (
@@ -333,7 +347,7 @@ const FlavorText = ({ text }) => {
333347
exit={{ opacity: 0 }}
334348
className="text-3xl"
335349
>
336-
<AnimatedText>{sub}</AnimatedText>
350+
<FadeText>{sub}</FadeText>
337351
</motion.div>
338352
)}
339353
</AnimatePresence>
@@ -469,7 +483,7 @@ const Commentator = ({ left, right, comm }) => (
469483
)}
470484
>
471485
<div className="text-4xl font-medium">
472-
<AnimatedText>{comm.name}</AnimatedText>
486+
<FadeText>{comm.name}</FadeText>
473487
</div>
474488
<div
475489
className={clsx(
@@ -478,11 +492,11 @@ const Commentator = ({ left, right, comm }) => (
478492
)}
479493
>
480494
<div>
481-
<AnimatedText>{comm.twitter}</AnimatedText>
495+
<FadeText>{comm.twitter}</FadeText>
482496
</div>
483497
<div className="self-stretch shrink-0 rounded-full w-1 bg-fabl-indigo-light"></div>
484498
<div className="text-fabl-pink font-semibold">
485-
<AnimatedText>{comm.pronouns}</AnimatedText>
499+
<FadeText>{comm.pronouns}</FadeText>
486500
</div>
487501
</div>
488502
</div>

0 commit comments

Comments
 (0)