@katajere/recap 1.0.14 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/dist/App.css +22 -2
  2. package/dist/LoginScreen.css +22 -21
  3. package/dist/OtpScreen.css +20 -17
  4. package/dist/RecapStory.css +148 -0
  5. package/dist/RecapStory.d.ts.map +1 -1
  6. package/dist/RecapStory.js +63 -29
  7. package/dist/StoryProgress.css +3 -3
  8. package/dist/assets/huxxle-login-blue-logo.svg +14 -0
  9. package/dist/assets/noisy-background.svg +23 -0
  10. package/dist/assets/search-icon.svg +4 -0
  11. package/dist/assets/share-button.svg +5 -0
  12. package/dist/assets/web-icon.png +0 -0
  13. package/dist/assets/web-icon.svg +14 -0
  14. package/dist/components/Header.css +12 -1
  15. package/dist/components/Header.js +2 -2
  16. package/dist/data/mock.d.ts.map +1 -1
  17. package/dist/data/mock.js +19 -7
  18. package/dist/index.d.ts +0 -1
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js +0 -1
  21. package/dist/slides/Slide10Final.css +73 -35
  22. package/dist/slides/Slide1Intro.css +204 -56
  23. package/dist/slides/Slide1Intro.d.ts +2 -1
  24. package/dist/slides/Slide1Intro.d.ts.map +1 -1
  25. package/dist/slides/Slide1Intro.js +41 -47
  26. package/dist/slides/Slide2Days.css +121 -34
  27. package/dist/slides/Slide2Days.d.ts +2 -1
  28. package/dist/slides/Slide2Days.d.ts.map +1 -1
  29. package/dist/slides/Slide2Days.js +45 -4
  30. package/dist/slides/Slide3Revenue.css +80 -38
  31. package/dist/slides/Slide3Revenue.d.ts.map +1 -1
  32. package/dist/slides/Slide3Revenue.js +33 -4
  33. package/dist/slides/Slide4Orders.css +93 -34
  34. package/dist/slides/Slide4Orders.d.ts +2 -1
  35. package/dist/slides/Slide4Orders.d.ts.map +1 -1
  36. package/dist/slides/Slide4Orders.js +45 -3
  37. package/dist/slides/Slide5Buyers.css +124 -67
  38. package/dist/slides/Slide5Buyers.d.ts +2 -1
  39. package/dist/slides/Slide5Buyers.d.ts.map +1 -1
  40. package/dist/slides/Slide5Buyers.js +43 -3
  41. package/dist/slides/Slide6Customer.css +294 -52
  42. package/dist/slides/Slide6Customer.d.ts +6 -3
  43. package/dist/slides/Slide6Customer.d.ts.map +1 -1
  44. package/dist/slides/Slide6Customer.js +25 -4
  45. package/dist/slides/Slide7Products.css +8 -7
  46. package/dist/slides/Slide7Products.js +3 -3
  47. package/dist/slides/Slide8Months.css +6 -6
  48. package/dist/slides/Slide9Year.css +4 -2
  49. package/dist/slides/Slide9Year.d.ts +2 -1
  50. package/dist/slides/Slide9Year.d.ts.map +1 -1
  51. package/dist/slides/Slide9Year.js +23 -2
  52. package/dist/types.d.ts +5 -0
  53. package/dist/types.d.ts.map +1 -1
  54. package/dist/utils/slideScreenshot.d.ts +27 -0
  55. package/dist/utils/slideScreenshot.d.ts.map +1 -0
  56. package/dist/utils/slideScreenshot.js +274 -0
  57. package/package.json +2 -1
  58. package/src/App.css +22 -2
  59. package/src/LoginScreen.css +22 -21
  60. package/src/LoginScreen.tsx +1 -1
  61. package/src/OtpScreen.css +20 -17
  62. package/src/OtpScreen.tsx +1 -1
  63. package/src/RecapStory.css +148 -0
  64. package/src/RecapStory.tsx +134 -58
  65. package/src/StoryProgress.css +3 -3
  66. package/src/components/Header.css +12 -1
  67. package/src/components/Header.tsx +2 -2
  68. package/src/data/mock.ts +19 -7
  69. package/src/index.ts +0 -1
  70. package/src/slides/Slide10Final.css +73 -35
  71. package/src/slides/Slide1Intro.css +204 -56
  72. package/src/slides/Slide1Intro.tsx +89 -81
  73. package/src/slides/Slide2Days.css +121 -34
  74. package/src/slides/Slide2Days.tsx +67 -19
  75. package/src/slides/Slide3Revenue.css +80 -38
  76. package/src/slides/Slide3Revenue.tsx +45 -7
  77. package/src/slides/Slide4Orders.css +93 -34
  78. package/src/slides/Slide4Orders.tsx +71 -10
  79. package/src/slides/Slide5Buyers.css +124 -67
  80. package/src/slides/Slide5Buyers.tsx +97 -38
  81. package/src/slides/Slide6Customer.css +294 -52
  82. package/src/slides/Slide6Customer.tsx +68 -10
  83. package/src/slides/Slide7Products.css +8 -7
  84. package/src/slides/Slide7Products.tsx +3 -3
  85. package/src/slides/Slide8Months.css +6 -6
  86. package/src/slides/Slide9Year.css +4 -2
  87. package/src/slides/Slide9Year.tsx +35 -7
  88. package/src/types.ts +5 -0
  89. package/src/utils/slideScreenshot.ts +324 -0
  90. package/dist/FloatingFrames.css +0 -55
  91. package/dist/FloatingFrames.d.ts +0 -11
  92. package/dist/FloatingFrames.d.ts.map +0 -1
  93. package/dist/FloatingFrames.js +0 -12
  94. package/dist/assets/money-rain.png +0 -0
  95. package/dist/assets/raining-money.gif +0 -0
  96. package/dist/assets/recap-music.mp3 +0 -0
  97. package/src/FloatingFrames.css +0 -55
  98. package/src/FloatingFrames.tsx +0 -27
@@ -1,4 +1,4 @@
1
- import React, { useLayoutEffect, useRef, useState } from 'react';
1
+ import React from 'react';
2
2
  import { motion } from 'framer-motion';
3
3
  import { delayedFadeIn } from '../utils';
4
4
  import { BUSINESS_CATEGORIES, BusinessCategory } from '../types';
@@ -11,74 +11,19 @@ interface Slide1IntroProps {
11
11
  introHeadline?: string;
12
12
  introSubtitle?: string;
13
13
  onDurationCalculated?: (duration: number) => void;
14
+ frameImages?: string[];
14
15
  }
15
16
 
16
17
  /**
17
18
  * Slide1Intro - Identity slide with business name and category-based messaging
18
19
  */
19
- function Slide1Intro({ businessName, businessCategory, introHeadline, introSubtitle, onDurationCalculated }: Slide1IntroProps) {
20
+ function Slide1Intro({ businessName, businessCategory, introHeadline, introSubtitle, onDurationCalculated, frameImages }: Slide1IntroProps) {
20
21
  // Dynamic messaging: use props if provided, otherwise fall back to recapCopy
21
22
  const copy = recapCopy[businessCategory] ?? recapCopy[BUSINESS_CATEGORIES.THRIVING];
22
23
  const headline = introHeadline ?? copy.introHeadline;
23
24
  const subtitle = introSubtitle ?? copy.introSubtitle;
24
- const [brandWidth, setBrandWidth] = useState(0);
25
- const [headlineWidth, setHeadlineWidth] = useState(0);
26
- const brandRef = useRef<HTMLDivElement | null>(null);
27
- const headlineRef = useRef<HTMLHeadingElement | null>(null);
28
-
29
- useLayoutEffect(() => {
30
- if (brandRef.current) {
31
- // Add extra buffer to account for hidden characters (approximately 3 character widths)
32
- const extraBuffer = brandRef.current.scrollWidth * 0.25; // ~25% extra space
33
- setBrandWidth(brandRef.current.scrollWidth + extraBuffer);
34
- }
35
- }, [businessName]);
36
-
37
- useLayoutEffect(() => {
38
- if (headlineRef.current) {
39
- setHeadlineWidth(headlineRef.current.scrollWidth);
40
- }
41
- }, [headline]);
42
-
43
- // Get actual viewport width for calculation
44
- const viewportWidth = typeof window !== 'undefined' ? window.innerWidth : 390;
45
- const containerWidth = Math.min(viewportWidth, 430); // max-width from App.css
46
- const sidePadding = Math.max(16, containerWidth * 0.041); // clamp(16px, 4.1vw, 20px)
47
- const availableWidth = containerWidth - (sidePadding * 2);
48
-
49
- const brandShift = Math.max(brandWidth - availableWidth, 0);
50
- const headlineShift = Math.max(headlineWidth - availableWidth, 0);
51
-
52
- // Calculate dynamic slide duration based on brand name length
53
- // Tested with real data: 26-75 character business names
54
- const baseAnimationDuration = 6; // seconds minimum for short names
55
- const pixelsPerSecond = 65; // animation speed (constant across all names)
56
-
57
- // Calculate animation duration for brand name
58
- const brandAnimationDuration =
59
- brandShift > 0
60
- ? Math.max(baseAnimationDuration, brandShift / pixelsPerSecond)
61
- : baseAnimationDuration;
62
-
63
- // Calculate animation duration for headline
64
- const headlineAnimationDuration = headlineShift > 0
65
- ? Math.max(baseAnimationDuration, headlineShift / pixelsPerSecond)
66
- : baseAnimationDuration;
67
-
68
- // Use the longer of the two animations, plus buffer time
69
- const dynamicSlideDuration = Math.max(
70
- brandAnimationDuration,
71
- headlineAnimationDuration
72
- ) + 2; // +2 second buffer for user to read the final position
73
-
74
- // Notify parent of calculated duration
75
- React.useEffect(() => {
76
- if (onDurationCalculated && brandWidth > 0 && headlineWidth > 0) {
77
- onDurationCalculated(dynamicSlideDuration);
78
- }
79
- }, [dynamicSlideDuration, brandWidth, headlineWidth, onDurationCalculated]);
80
25
 
81
- const slideClass = `slide1-intro slide1-intro--${copy.introVariant}`;
26
+ const slideClass = `slide1-intro slide1-intro--${copy.introVariant} slide1-intro--words-${Math.min(businessName.split(' ').length, 3)}`;
82
27
  const isNewUser = businessCategory === BUSINESS_CATEGORIES.NEW_USER;
83
28
 
84
29
  const handleContinue = () => {
@@ -87,6 +32,37 @@ function Slide1Intro({ businessName, businessCategory, introHeadline, introSubti
87
32
  }
88
33
  };
89
34
 
35
+ const frameImagePool = React.useMemo(() => {
36
+ return frameImages && frameImages.length > 0 ? frameImages : [];
37
+ }, [frameImages]);
38
+
39
+ const frameSources = React.useMemo(() => {
40
+ if (!frameImagePool.length) {
41
+ return [];
42
+ }
43
+
44
+ return Array.from({ length: 6 }, () =>
45
+ frameImagePool[Math.floor(Math.random() * frameImagePool.length)]
46
+ );
47
+ }, [frameImagePool]);
48
+
49
+ const getFrameStyle = (index: number) => {
50
+ if (!frameSources.length) {
51
+ return undefined;
52
+ }
53
+
54
+ const image = frameSources[index % frameSources.length];
55
+ if (!image) {
56
+ return undefined;
57
+ }
58
+
59
+ return {
60
+ backgroundImage: `url('${image}')`,
61
+ backgroundSize: 'cover',
62
+ backgroundPosition: 'center',
63
+ };
64
+ };
65
+
90
66
  return (
91
67
  <div className={slideClass}>
92
68
  {/* Brand name container with HEY text and business name */}
@@ -94,15 +70,52 @@ function Slide1Intro({ businessName, businessCategory, introHeadline, introSubti
94
70
  {/* Background "HEY" text */}
95
71
  <div className="slide1-intro__bg-text">HEY</div>
96
72
 
97
- {/* Business name (animated scroll left) */}
98
- <motion.div
99
- className="slide1-intro__brand"
100
- ref={brandRef}
101
- animate={{ x: [0, -brandShift] }}
102
- transition={{ duration: brandAnimationDuration, repeat: 0, ease: 'linear' }}
103
- >
104
- {businessName}
105
- </motion.div>
73
+ {/* Business name (character animation with natural word flow) */}
74
+ <div className={`slide1-intro__brand slide1-intro__brand--words-${Math.min(businessName.split(' ').length, 3)}`}>
75
+ {businessName.split(' ').map((word, wordIndex, wordsArray) => {
76
+ // Calculate character offset for stagger delay (include space characters)
77
+ const charOffset = wordsArray
78
+ .slice(0, wordIndex)
79
+ .reduce((acc, w, i) => acc + w.length + (i < wordIndex ? 1 : 0), 0);
80
+
81
+ return (
82
+ <React.Fragment key={wordIndex}>
83
+ <span className="slide1-intro__word">
84
+ {word.split('').map((char, charIndex) => (
85
+ <motion.span
86
+ key={charIndex}
87
+ initial={{ opacity: 0, y: 20, rotateX: -90 }}
88
+ animate={{
89
+ opacity: 1,
90
+ y: 0,
91
+ rotateX: 0,
92
+ }}
93
+ transition={{
94
+ duration: 0.5,
95
+ delay: (charOffset + charIndex) * 0.03,
96
+ ease: [0.34, 1.56, 0.64, 1],
97
+ }}
98
+ style={{ display: 'inline-block' }}
99
+ >
100
+ {char}
101
+ </motion.span>
102
+ ))}
103
+ </span>
104
+ {/* Add space between words (except after last word) */}
105
+ {wordIndex < wordsArray.length - 1 && (
106
+ <motion.span
107
+ initial={{ opacity: 0 }}
108
+ animate={{ opacity: 1 }}
109
+ transition={{ duration: 0.3, delay: (charOffset + word.length) * 0.03 }}
110
+ style={{ display: 'inline-block', width: '0.3em' }}
111
+ >
112
+ {' '}
113
+ </motion.span>
114
+ )}
115
+ </React.Fragment>
116
+ );
117
+ })}
118
+ </div>
106
119
  </div>
107
120
 
108
121
  {/* Top floating frames (slow horizontal drift) */}
@@ -111,9 +124,9 @@ function Slide1Intro({ businessName, businessCategory, introHeadline, introSubti
111
124
  animate={{ x: [-30, 30] }}
112
125
  transition={{ duration: 15, repeat: Infinity, repeatType: 'reverse', ease: 'linear' }}
113
126
  >
114
- <div className="frame-rect" />
115
- <div className="frame-rect" />
116
- <div className="frame-rect" />
127
+ {Array.from({ length: 3 }).map((_, index) => (
128
+ <div key={`top-rect-${index}`} className="frame-rect" style={getFrameStyle(index)} />
129
+ ))}
117
130
  </motion.div>
118
131
 
119
132
  {/* Headline and subtitle */}
@@ -123,14 +136,9 @@ function Slide1Intro({ businessName, businessCategory, introHeadline, introSubti
123
136
  initial="initial"
124
137
  animate="animate"
125
138
  >
126
- <motion.h2
127
- className="slide1-intro__headline"
128
- ref={headlineRef}
129
- animate={{ x: [0, -headlineShift] }}
130
- transition={{ duration: headlineAnimationDuration, repeat: 1, repeatType: 'reverse', ease: 'linear' }}
131
- >
139
+ <h2 className="slide1-intro__headline">
132
140
  {headline}
133
- </motion.h2>
141
+ </h2>
134
142
  <p className="slide1-intro__subtitle">{subtitle}</p>
135
143
  </motion.div>
136
144
 
@@ -140,9 +148,9 @@ function Slide1Intro({ businessName, businessCategory, introHeadline, introSubti
140
148
  animate={{ x: [-30, 30] }}
141
149
  transition={{ duration: 15, repeat: Infinity, repeatType: 'reverse', ease: 'linear' }}
142
150
  >
143
- <div className="frame-rect" />
144
- <div className="frame-rect" />
145
- <div className="frame-rect" />
151
+ {Array.from({ length: 3 }).map((_, index) => (
152
+ <div key={`bottom-rect-${index}`} className="frame-rect" style={getFrameStyle(index + 3)} />
153
+ ))}
146
154
  </motion.div>
147
155
 
148
156
  {/* New User CTA Button - Animated from bottom */}
@@ -11,14 +11,12 @@
11
11
  .slide2-days__heading {
12
12
  position: absolute;
13
13
  width: 91.79%;
14
- /* left: 4.1%;
15
- top: 10.66%; */
16
14
  font-family: 'Lora', serif;
17
15
  font-style: normal;
18
16
  font-weight: 400;
19
- color: white;
20
- /* margin: 0 0 4.74% 0; */
21
- margin: calc(108px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-left)) 0 calc(16px + env(safe-area-inset-right));
17
+ font-size: clamp(14px, 4.1vw, 16px);
18
+ color: #3734D3;
19
+ margin: calc(128px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-left)) 0 calc(16px + env(safe-area-inset-right));
22
20
  text-align: left;
23
21
  z-index: 3;
24
22
  }
@@ -33,10 +31,8 @@
33
31
  gap: clamp(8px, 3.08vw, 12px);
34
32
  position: absolute;
35
33
  width: 100%;
36
- /* height: 28.4vh; */
37
34
  left: 0;
38
- top: 21.68vh;
39
- /* margin: calc(183px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-left)) 0 calc(16px + env(safe-area-inset-right)); */
35
+ top: calc(50% - 240px/2 - 143px);
40
36
  z-index: 2;
41
37
  }
42
38
 
@@ -69,13 +65,9 @@
69
65
  width: 100%;
70
66
  font-family: 'Lora', serif;
71
67
  font-style: normal;
72
- font-weight: 500;
73
- font-size: 2.8vh;
74
- /* line-height: 72px; */
75
- background: linear-gradient(90deg, #FFFFFF 0%, #FFCC80 100%);
76
- -webkit-background-clip: text;
77
- -webkit-text-fill-color: transparent;
78
- background-clip: text;
68
+ font-weight: 600;
69
+ font-size: clamp(14px, 4.1vw, 16px);
70
+ color: #3734D3;
79
71
  margin: 0;
80
72
  flex: none;
81
73
  order: 0;
@@ -102,8 +94,8 @@
102
94
  font-style: normal;
103
95
  font-weight: 700;
104
96
  font-size: 10.37vh;
105
- /* line-height: 115px; */
106
- background: linear-gradient(90deg, #FFFFFF 0%, #FFCC80 100%);
97
+ /* color: var(--primary-blue); */
98
+ background: var(--bg-gradient);
107
99
  -webkit-background-clip: text;
108
100
  -webkit-text-fill-color: transparent;
109
101
  background-clip: text;
@@ -120,11 +112,7 @@
120
112
  font-style: normal;
121
113
  font-weight: 400;
122
114
  font-size: clamp(14px, 4.1vw, 16px);
123
- /* line-height: 72px; */
124
- background: linear-gradient(90deg, #FFFFFF 0%, #FFCC80 100%);
125
- -webkit-background-clip: text;
126
- -webkit-text-fill-color: transparent;
127
- background-clip: text;
115
+ color: #3734D3;
128
116
  margin: 0;
129
117
  flex: none;
130
118
  order: 1;
@@ -138,9 +126,8 @@
138
126
  width: 74.1%;
139
127
  height: 0;
140
128
  left: 25.9%;
141
- top: 79.86vh;
142
- opacity: 0.4;
143
- border: 0.24vh solid #FFFFFF;
129
+ top: 77vh;
130
+ border: 2px solid #E6E5F9;
144
131
  transform-origin: left;
145
132
  z-index: 3;
146
133
  }
@@ -158,11 +145,12 @@
158
145
  flex-direction: column;
159
146
  align-items: flex-end;
160
147
  padding: 0;
148
+ /* padding-right: 70px; Avoid floating Share button */
161
149
  /* gap: 40px; */
162
150
  position: absolute;
163
151
  width: 91.79%;
164
152
  left: 4.1%;
165
- top: 82.23vh;
153
+ top: 79.5vh;
166
154
  z-index: 3;
167
155
  }
168
156
 
@@ -179,12 +167,10 @@
179
167
  font-style: normal;
180
168
  font-weight: 700;
181
169
  font-size: 6.64vh;
182
- /* line-height: 115px; */
183
170
  text-align: right;
184
- background: linear-gradient(90deg, #FFFFFF 0%, #FFCC80 100%);
185
- -webkit-background-clip: text;
186
- -webkit-text-fill-color: transparent;
187
- background-clip: text;
171
+ color: #FFFFFF;
172
+ -webkit-text-stroke: 1.5px var(--primary-blue);
173
+ paint-order: stroke fill;
188
174
  margin: 0;
189
175
  flex: none;
190
176
  order: 0;
@@ -198,12 +184,113 @@
198
184
  font-style: normal;
199
185
  font-weight: 400;
200
186
  font-size: clamp(14px, 4.1vw, 16px);
201
- /* line-height: 72px; */
202
187
  text-align: right;
203
188
  flex: none;
204
189
  order: 1;
205
190
  align-self: stretch;
206
191
  flex-grow: 0;
207
- color: white;
208
- margin: 0 0 4.74% 0;
192
+ color: #3734D3;
193
+ margin: 0;
194
+ }
195
+
196
+ /* Media queries for landscape and short screens */
197
+ @media (max-height: 720px), (orientation: landscape) {
198
+ .slide2-days__heading {
199
+ margin-top: calc(100px + env(safe-area-inset-top));
200
+ font-size: clamp(12px, 3.5vw, 14px);
201
+ }
202
+
203
+ .slide2-days__frames .frame-rect {
204
+ height: 24dvh;
205
+ }
206
+
207
+ .stats-number {
208
+ font-size: 8dvh;
209
+ }
210
+
211
+ .streak-number {
212
+ font-size: 5.5dvh;
213
+ }
214
+ }
215
+
216
+ /* Small/Short screens - handles browser chrome taking space */
217
+ @media (max-height: 700px) {
218
+ .slide2-days__heading {
219
+ margin-top: calc(84px + env(safe-area-inset-top));
220
+ }
221
+
222
+ .slide2-days__frames {
223
+ top: calc(50% - 180px/2 - 110px);
224
+ }
225
+
226
+ .slide2-days__frames .frame-rect {
227
+ height: 22dvh;
228
+ width: clamp(120px, 40vw, 160px);
229
+ }
230
+
231
+ .slide2-days__stats-section {
232
+ margin-top: calc(50dvh + env(safe-area-inset-top));
233
+ }
234
+
235
+ .stats-number {
236
+ font-size: 7dvh;
237
+ }
238
+
239
+ .slide2-days__divider {
240
+ top: 70dvh;
241
+ }
242
+
243
+ .slide2-days__streak-section {
244
+ top: 72.5dvh;
245
+ }
246
+
247
+ .streak-number {
248
+ font-size: 5dvh;
249
+ }
250
+ }
251
+
252
+ /* Extra short screens (under 600px) - more aggressive adjustments */
253
+ @media (max-height: 600px) {
254
+ .slide2-days__heading {
255
+ margin-top: calc(68px + env(safe-area-inset-top));
256
+ font-size: clamp(11px, 3vw, 13px);
257
+ }
258
+
259
+ .slide2-days__frames {
260
+ top: calc(50% - 160px/2 - 90px);
261
+ }
262
+
263
+ .slide2-days__frames .frame-rect {
264
+ height: 18dvh;
265
+ width: clamp(100px, 35vw, 140px);
266
+ }
267
+
268
+ .slide2-days__stats-section {
269
+ margin-top: calc(46dvh + env(safe-area-inset-top));
270
+ }
271
+
272
+ .stats-number {
273
+ font-size: 6dvh;
274
+ }
275
+
276
+ .stats-label,
277
+ .stats-sublabel {
278
+ font-size: clamp(11px, 3vw, 13px);
279
+ }
280
+
281
+ .slide2-days__divider {
282
+ top: 66dvh;
283
+ }
284
+
285
+ .slide2-days__streak-section {
286
+ top: 68.5dvh;
287
+ }
288
+
289
+ .streak-number {
290
+ font-size: 4.5dvh;
291
+ }
292
+
293
+ .streak-label {
294
+ font-size: clamp(11px, 3vw, 13px);
295
+ }
209
296
  }
@@ -1,17 +1,71 @@
1
1
  import React from 'react';
2
- import { motion } from 'framer-motion';
2
+ import { motion, useMotionValue, useTransform, animate } from 'framer-motion';
3
3
  import { formatNumber } from '../utils';
4
4
  import './Slide2Days.css';
5
5
 
6
6
  interface Slide2DaysProps {
7
7
  days: number;
8
8
  streak: number;
9
+ frameImages?: string[];
10
+ }
11
+
12
+ /**
13
+ * Custom hook for number counter animation
14
+ */
15
+ function useCountAnimation(target: number, duration: number = 2, delay: number = 0) {
16
+ const count = useMotionValue(0);
17
+ const rounded = useTransform(count, (latest) => Math.round(latest));
18
+
19
+ React.useEffect(() => {
20
+ const controls = animate(count, target, {
21
+ duration,
22
+ delay,
23
+ ease: 'easeOut',
24
+ });
25
+
26
+ return controls.stop;
27
+ }, [count, target, duration, delay]);
28
+
29
+ return rounded;
9
30
  }
10
31
 
11
32
  /**
12
33
  * Slide2Days - Days active and streak statistics
13
34
  */
14
- function Slide2Days({ days, streak }: Slide2DaysProps) {
35
+ function Slide2Days({ days, streak, frameImages }: Slide2DaysProps) {
36
+ const daysCount = useCountAnimation(days, 1.6, 0.4); // 1.6s + 0.4s delay = 2s total
37
+ const streakCount = useCountAnimation(streak, 1.2, 0.8); // 1.2s + 0.8s delay = 2s total
38
+ const frameImagePool = React.useMemo(() => {
39
+ return frameImages && frameImages.length > 0 ? frameImages : [];
40
+ }, [frameImages]);
41
+
42
+ const frameSources = React.useMemo(() => {
43
+ if (!frameImagePool.length) {
44
+ return [];
45
+ }
46
+
47
+ return Array.from({ length: 3 }, () =>
48
+ frameImagePool[Math.floor(Math.random() * frameImagePool.length)]
49
+ );
50
+ }, [frameImagePool]);
51
+
52
+ const getFrameStyle = (index: number) => {
53
+ if (!frameSources.length) {
54
+ return undefined;
55
+ }
56
+
57
+ const image = frameSources[index % frameSources.length];
58
+ if (!image) {
59
+ return undefined;
60
+ }
61
+
62
+ return {
63
+ backgroundImage: `url('${image}')`,
64
+ backgroundSize: 'cover',
65
+ backgroundPosition: 'center',
66
+ };
67
+ };
68
+
15
69
  return (
16
70
  <div className="slide2-days">
17
71
  {/* Top heading - positioned at top like Figma */}
@@ -31,21 +85,15 @@ function Slide2Days({ days, streak }: Slide2DaysProps) {
31
85
  animate={{ opacity: 1, x: 0 }}
32
86
  transition={{ duration: 0.8, delay: 0.2 }}
33
87
  >
34
- <motion.div
35
- className="frame-rect"
36
- animate={{ x: [-20, 20] }}
37
- transition={{ duration: 4, repeat: Infinity, repeatType: 'reverse', ease: 'linear' }}
38
- />
39
- <motion.div
40
- className="frame-rect"
41
- animate={{ x: [-20, 20] }}
42
- transition={{ duration: 4, repeat: Infinity, repeatType: 'reverse', ease: 'linear' }}
43
- />
44
- <motion.div
45
- className="frame-rect"
46
- animate={{ x: [-20, 20] }}
47
- transition={{ duration: 4, repeat: Infinity, repeatType: 'reverse', ease: 'linear' }}
48
- />
88
+ {Array.from({ length: 3 }).map((_, index) => (
89
+ <motion.div
90
+ key={`frame-${index}-${frameSources[index] ?? 'no-image'}`}
91
+ className="frame-rect"
92
+ style={getFrameStyle(index)}
93
+ animate={{ x: [-20, 20] }}
94
+ transition={{ duration: 4, repeat: Infinity, repeatType: 'reverse', ease: 'linear' }}
95
+ />
96
+ ))}
49
97
  </motion.div>
50
98
 
51
99
  {/* Days stats block */}
@@ -62,7 +110,7 @@ function Slide2Days({ days, streak }: Slide2DaysProps) {
62
110
  animate={{ opacity: 1, scale: 1 }}
63
111
  transition={{ duration: 0.6, delay: 0.6 }}
64
112
  >
65
- <div className="stats-number">{formatNumber(days)}</div>
113
+ <motion.div className="stats-number">{daysCount}</motion.div>
66
114
  <p className="stats-sublabel">days dey hustle with Huxxle</p>
67
115
  </motion.div>
68
116
  </motion.div>
@@ -82,7 +130,7 @@ function Slide2Days({ days, streak }: Slide2DaysProps) {
82
130
  animate={{ opacity: 1, y: 0 }}
83
131
  transition={{ duration: 0.6, delay: 1.1 }}
84
132
  >
85
- <div className="streak-number">{formatNumber(streak)}</div>
133
+ <motion.div className="streak-number">{streakCount}</motion.div>
86
134
  <p className="streak-label">day streak, You no dey play oh 🤯</p>
87
135
  </motion.div>
88
136
  </div>