Browse Source

sympa le 24

feat/year-wrapped
Elias Sebbar 1 day ago
parent
commit
808c4076a4
1 changed files with 62 additions and 36 deletions
  1. 62
    36
      vite-wrapped/src/steps/welcome.tsx

+ 62
- 36
vite-wrapped/src/steps/welcome.tsx View File

@@ -8,8 +8,9 @@ type VariantProps = {
8 8
 };
9 9
 
10 10
 type NudgedVariantProps = VariantProps & {
11
-    nudge: number;
12
-    };
11
+  nudge: number;
12
+  id: number;
13
+};
13 14
 
14 15
 const starVariants: Variants = {
15 16
   "1": (props: VariantProps) => ({
@@ -43,35 +44,38 @@ const starVariants: Variants = {
43 44
   }),
44 45
 };
45 46
 
47
+
46 48
 const letterVariants: Variants = {
47 49
   "1": (props: NudgedVariantProps) => ({
48
-    rotate: (360 - 45) * props.nudge,
49
-    scale: 4,
50
+    rotate: 360 * props.nudge + props.id * 5,
51
+    x: -props.nudge * props.id * 15,
52
+    scale: 9 - props.id / 2,
50 53
     transition: {
51 54
       duration: 2,
52
-      ease: 'easeOut',
53
-      delay: 1.5 + props.delay,
55
+      ease: "easeInOut",
56
+      //delay: 1.5 + props.delay + props.id / 10,
57
+      delay: 1.5 + props.id/50,
54 58
     },
55 59
   }),
56 60
   "2": (props: NudgedVariantProps) => ({
57
-    rotate: 360 * props.nudge,
58
-    x: -props.nudge * 19,
59
-    z:0.1,
60
-    scale: 4,
61
+    rotate: 360 * props.nudge + props.id * 5,
62
+    x: -props.nudge * props.id * 15,
63
+    z: 0.1,
64
+    scale: 9 - props.id / 2,
61 65
     transition: {
62 66
       duration: 2,
63
-      ease: 'easeInOut',
64
-      delay: props.delay,
67
+      ease: "linear",
68
+      //delay: props.delay + props.id / 10,
65 69
     },
66 70
   }),
67 71
   "3": (props: NudgedVariantProps) => ({
68 72
     rotate: 361 * props.nudge,
69
-    x: -props.nudge * 20,
73
+    x: -props.nudge * 30,
70 74
     scale: 4,
71
-    z:0.2,
75
+    z: 0.2,
72 76
     transition: {
73
-      duration: 6,
74
-      ease: 'easeInOut',
77
+      duration: 1,
78
+      ease: "easeInOut",
75 79
       delay: props.delay,
76 80
     },
77 81
   }),
@@ -132,25 +136,41 @@ function Welcome({ progress }: StepProps) {
132 136
       <motion.div
133 137
         style={{
134 138
           display: "flex",
135
-          position: "absolute",
139
+          position: "relative",
136 140
         }}
137 141
       >
138
-        <motion.div
139
-          variants={letterVariants}
140
-          animate={starVariant}
141
-          custom={{ delay: 0, nudge: 1 }}
142
-          style={letterStyle}
143
-        >
144
-          2
145
-        </motion.div>
146
-        <motion.div
147
-          variants={letterVariants}
148
-          animate={starVariant}
149
-          custom={{ delay: 0.1, nudge: -1 }}
150
-          style={letterStyle}
151
-        >
152
-          4
153
-        </motion.div>
142
+        {Array.from({ length: 10 }).map((_, i) => (
143
+          <motion.div
144
+            variants={letterVariants}
145
+            animate={starVariant}
146
+            custom={{ delay: 0, nudge: 1, id: 9-i }}
147
+            style={
148
+              letterStyle({
149
+                delay: 0.1,
150
+                nudge: -1,
151
+                id: 9-i,
152
+              }) as React.CSSProperties
153
+            }
154
+          >
155
+            2
156
+          </motion.div>
157
+        ))}
158
+        {Array.from({ length: 10 }).map((_, i) => (
159
+          <motion.div
160
+            variants={letterVariants}
161
+            animate={starVariant}
162
+            custom={{ delay: 0.1, nudge: -1, id: 9-i }}
163
+            style={
164
+              letterStyle({
165
+                delay: 0.1,
166
+                nudge: -1,
167
+                id: 9-i,
168
+              }) as React.CSSProperties
169
+            }
170
+          >
171
+            4
172
+          </motion.div>
173
+        ))}
154 174
       </motion.div>
155 175
     </div>
156 176
   );
@@ -182,9 +202,15 @@ const starStyle = {
182 202
     "radial-gradient(circle at center center,rgb(95, 247, 68),rgb(247, 255, 19)), repeating-radial-gradient(circle at center center,rgb(0, 255, 140),rgb(77, 247, 68), 10px, transparent 90px, transparent 10px)",
183 203
 };
184 204
 
185
-const letterStyle = {
205
+const letterStyle = (props: NudgedVariantProps) => ({
206
+  transform: `translateX(${Math.floor(props.nudge * props.id * 100)}px)`,
186 207
   scale: 0,
187
-  fontSize: "3em"
188
-};
208
+  fontSize: "3em",
209
+  position: "absolute",
210
+  color: "transparent",
211
+  backgroundClip: "text",
212
+  backgroundImage: "linear-gradient(90deg, rgb(95, 247, 68),rgb(247, 255, 19))",
213
+  //webkitTextStroke: "1px white",
214
+});
189 215
 
190 216
 export default Welcome;

Loading…
Cancel
Save