Browse Source

Making progress

feat/year-wrapped
Elias Sebbar 3 days ago
parent
commit
61186f1770

+ 12
- 0
vite-wrapped/public/square.svg View File

1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<svg
3
+    id="Calque_1"
4
+    data-name="Calque 1"
5
+    xmlns="http://www.w3.org/2000/svg"
6
+    viewBox="0 0 400 400"
7
+>
8
+    <polygon stroke="white" fill="#00000000"
9
+    stroke-width="1em"
10
+    points="0 0 400 0 400 400 0 400"
11
+    />
12
+</svg>

+ 31
- 2
vite-wrapped/src/App.tsx View File

2
 // @deno-types="@types/react"
2
 // @deno-types="@types/react"
3
 import React, { useEffect, useState } from "react";
3
 import React, { useEffect, useState } from "react";
4
 
4
 
5
-import { motion, useMotionValue, useMotionValueEvent } from "framer-motion";
5
+import {
6
+  AnimatePresence,
7
+  motion,
8
+  useMotionValue,
9
+} from "framer-motion";
6
 import { useAnimationFrame } from "framer-motion";
10
 import { useAnimationFrame } from "framer-motion";
7
 import Welcome from "./steps/welcome.tsx";
11
 import Welcome from "./steps/welcome.tsx";
8
 import GlobalTop from "./steps/GlobalTop.tsx";
12
 import GlobalTop from "./steps/GlobalTop.tsx";
22
   },
26
   },
23
 ];
27
 ];
24
 
28
 
29
+const enterAnimation = {
30
+  opacity: 0,
31
+  scale: 0,
32
+  transition: {
33
+    duration: 0.25,
34
+  },
35
+};
36
+
37
+const exitAnimation = {
38
+  opacity: 0,
39
+  scale: 0,
40
+  transition: {
41
+    duration: 0.25,
42
+  },
43
+};
44
+
25
 function App() {
45
 function App() {
26
   const [currentStep, setCurrentStep] = useState(0);
46
   const [currentStep, setCurrentStep] = useState(0);
27
   const animationDuration = 10_000;
47
   const animationDuration = 10_000;
56
             right: "0",
76
             right: "0",
57
           }}
77
           }}
58
         >
78
         >
59
-          <CurrentStepContent key={`${currentStep}`} progress={animationProgress} />
79
+          <AnimatePresence>
80
+            <motion.span
81
+              key={`${currentStep}`}
82
+              initial={enterAnimation}
83
+              exit={exitAnimation}
84
+              animate={{ opacity: 1, scale: 1 }}
85
+            >
86
+              <CurrentStepContent progress={animationProgress} />
87
+            </motion.span>
88
+          </AnimatePresence>
60
           {/*  <Welcome progress={animationProgress} /> */}
89
           {/*  <Welcome progress={animationProgress} /> */}
61
         </div>
90
         </div>
62
         <div style={{ zIndex: 100, fontSize: "5px" }}>
91
         <div style={{ zIndex: 100, fontSize: "5px" }}>

+ 4
- 1
vite-wrapped/src/components/mask/Masked.tsx View File

1
 import React from "react";
1
 import React from "react";
2
 
2
 
3
-type Mask = "Star";
3
+type Mask = "Star" | "Square";
4
 
4
 
5
 function Masked({
5
 function Masked({
6
   children,
6
   children,
17
     if (mask === "Star") {
17
     if (mask === "Star") {
18
       setMaskUrl("/star.svg");
18
       setMaskUrl("/star.svg");
19
     }
19
     }
20
+    if (mask === "Square") {
21
+      setMaskUrl("/square.svg");
22
+    }
20
   }, [mask]);
23
   }, [mask]);
21
 
24
 
22
   return (
25
   return (

+ 1
- 1
vite-wrapped/src/steps/GlobalTop.tsx View File

15
       repeat: 0,
15
       repeat: 0,
16
       type: "spring",
16
       type: "spring",
17
       ease: "easeInOut",
17
       ease: "easeInOut",
18
-      delay: 0.5 + props.delay,
18
+      delay: 1.5 + props.delay,
19
     },
19
     },
20
   }),
20
   }),
21
   "2": (props: VariantProps) => ({
21
   "2": (props: VariantProps) => ({

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

7
   delay: number;
7
   delay: number;
8
 };
8
 };
9
 
9
 
10
+type NudgedVariantProps = VariantProps & {
11
+    nudge: number;
12
+    };
13
+
10
 const starVariants: Variants = {
14
 const starVariants: Variants = {
11
   "1": (props: VariantProps) => ({
15
   "1": (props: VariantProps) => ({
12
     rotate: 360,
16
     rotate: 360,
14
     transition: {
18
     transition: {
15
       duration: 2,
19
       duration: 2,
16
       repeat: 0,
20
       repeat: 0,
17
-      delay: props.delay,
21
+      delay: 1.5 + props.delay,
18
     },
22
     },
19
   }),
23
   }),
20
   "2": (props: VariantProps) => ({
24
   "2": (props: VariantProps) => ({
21
-    scale: 3,
25
+    scale: 10,
22
     x: props.delay,
26
     x: props.delay,
23
     rotate: props.delay + 365 * 2,
27
     rotate: props.delay + 365 * 2,
24
     transition: {
28
     transition: {
25
-      duration: 1,
29
+      duration: 1.5,
26
       repeat: 0,
30
       repeat: 0,
27
       delay: props.delay,
31
       delay: props.delay,
28
     },
32
     },
29
   }),
33
   }),
30
   "3": (props: VariantProps) => ({
34
   "3": (props: VariantProps) => ({
31
-    scale: 3,
35
+    scale: 10,
32
     rotate: props.delay + 365 * 3,
36
     rotate: props.delay + 365 * 3,
33
     transition: {
37
     transition: {
34
       duration: 6,
38
       duration: 6,
39
   }),
43
   }),
40
 };
44
 };
41
 
45
 
42
-const textAreaVariants: Variants = {
43
-  "1": {
44
-    opacity: 1,
45
-    width: "80%",
46
-    height: "80%",
46
+const letterVariants: Variants = {
47
+  "1": (props: NudgedVariantProps) => ({
48
+    rotate: (360 - 45) * props.nudge,
49
+    scale: 4,
47
     transition: {
50
     transition: {
48
-      duration: 0.5,
51
+      duration: 2,
52
+      ease: 'easeOut',
53
+      delay: 1.5 + props.delay,
49
     },
54
     },
50
-  },
51
-  "2": {
52
-    opacity: 1,
53
-    width: "80%",
54
-    height: "80%",
55
+  }),
56
+  "2": (props: NudgedVariantProps) => ({
57
+    rotate: 360 * props.nudge,
58
+    x: -props.nudge * 19,
59
+    z:0.1,
60
+    scale: 4,
55
     transition: {
61
     transition: {
56
-      duration: 1.5,
62
+      duration: 2,
63
+      ease: 'easeInOut',
64
+      delay: props.delay,
57
     },
65
     },
58
-  },
59
-  "3": {
60
-    opacity: 1,
61
-    width: "80%",
62
-    height: "80%",
66
+  }),
67
+  "3": (props: NudgedVariantProps) => ({
68
+    rotate: 361 * props.nudge,
69
+    x: -props.nudge * 20,
70
+    scale: 4,
71
+    z:0.2,
63
     transition: {
72
     transition: {
64
-      duration: 1,
73
+      duration: 6,
74
+      ease: 'easeInOut',
75
+      delay: props.delay,
65
     },
76
     },
66
-  },
77
+  }),
67
 };
78
 };
68
 
79
 
69
 type RunningAnimations = {
80
 type RunningAnimations = {
113
           onAnimationComplete={() => animationComplete(starVariant)}
124
           onAnimationComplete={() => animationComplete(starVariant)}
114
         >
125
         >
115
           <div style={{ width: "800px", height: "800px" }}>
126
           <div style={{ width: "800px", height: "800px" }}>
116
-            <Masked mask="Star" style={starStyle} />
127
+            <Masked mask="Square" style={starStyle} />
117
           </div>
128
           </div>
118
         </motion.div>
129
         </motion.div>
119
       ))}
130
       ))}
120
 
131
 
132
+      <motion.div
133
+        style={{
134
+          display: "flex",
135
+          position: "absolute",
136
+        }}
137
+      >
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>
154
+      </motion.div>
121
     </div>
155
     </div>
122
   );
156
   );
123
 }
157
 }
148
     "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)",
182
     "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)",
149
 };
183
 };
150
 
184
 
185
+const letterStyle = {
186
+  scale: 0,
187
+  fontSize: "3em"
188
+};
151
 
189
 
152
 export default Welcome;
190
 export default Welcome;

Loading…
Cancel
Save