@katajere/recap 1.0.13 → 1.0.14
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.
- package/dist/App.css +10 -10
- package/dist/RecapStory.d.ts +2 -2
- package/dist/RecapStory.d.ts.map +1 -1
- package/dist/RecapStory.js +117 -62
- package/dist/StoryProgress.d.ts +3 -2
- package/dist/StoryProgress.d.ts.map +1 -1
- package/dist/StoryProgress.js +66 -12
- package/dist/data/mock.d.ts +1 -1
- package/dist/data/mock.d.ts.map +1 -1
- package/dist/data/mock.js +23 -22
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/App.css +10 -10
- package/src/RecapStory.tsx +147 -90
- package/src/StoryProgress.tsx +96 -21
- package/src/data/mock.ts +31 -23
- package/src/types.ts +2 -0
package/dist/App.css
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
:root {
|
|
4
4
|
--frame-ar-num: 9;
|
|
5
|
-
--frame-ar-den:
|
|
6
|
-
--frame-ar: 9 /
|
|
5
|
+
--frame-ar-den: 16;
|
|
6
|
+
--frame-ar: 9 / 16;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
* {
|
|
@@ -60,8 +60,8 @@ body {
|
|
|
60
60
|
aspect-ratio: var(--frame-ar);
|
|
61
61
|
width: min(100%, calc(100dvh * var(--frame-ar-num) / var(--frame-ar-den)));
|
|
62
62
|
height: min(100dvh, calc(100vw * var(--frame-ar-den) / var(--frame-ar-num)));
|
|
63
|
-
max-width:
|
|
64
|
-
max-height:
|
|
63
|
+
max-width: 1080px;
|
|
64
|
+
max-height: 1920px;
|
|
65
65
|
background: linear-gradient(180deg, #3F3DAD 0%, #CC6240 100%);
|
|
66
66
|
/* border-radius: clamp(0px, 2vw, 24px); */
|
|
67
67
|
overflow: hidden;
|
|
@@ -72,14 +72,14 @@ body {
|
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
/* Fallback for browsers without aspect-ratio support */
|
|
75
|
-
@supports not (aspect-ratio: 9 /
|
|
75
|
+
@supports not (aspect-ratio: 9 / 16) {
|
|
76
76
|
.app__shell {
|
|
77
77
|
width: 100vw;
|
|
78
78
|
height: calc(100vw * var(--frame-ar-den) / var(--frame-ar-num));
|
|
79
79
|
max-height: 100dvh;
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
@media (min-aspect-ratio: 9/
|
|
82
|
+
@media (min-aspect-ratio: 9/16) {
|
|
83
83
|
.app__shell {
|
|
84
84
|
width: calc(100dvh * var(--frame-ar-num) / var(--frame-ar-den));
|
|
85
85
|
height: 100dvh;
|
|
@@ -88,7 +88,7 @@ body {
|
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
/* Mobile - remove border radius and shadow */
|
|
91
|
-
@media (max-width:
|
|
91
|
+
@media (max-width: 600px) {
|
|
92
92
|
.app {
|
|
93
93
|
background: linear-gradient(180deg, #3F3DAD 0%, #CC6240 100%);
|
|
94
94
|
padding: 0;
|
|
@@ -101,10 +101,10 @@ body {
|
|
|
101
101
|
.app__shell {
|
|
102
102
|
/* border-radius: 0; */
|
|
103
103
|
box-shadow: none;
|
|
104
|
-
width:
|
|
104
|
+
width: 100vw;
|
|
105
105
|
height: 100dvh;
|
|
106
|
-
max-width:
|
|
107
|
-
max-height:
|
|
106
|
+
max-width: 100vw;
|
|
107
|
+
max-height: 100dvh;
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
|
package/dist/RecapStory.d.ts
CHANGED
package/dist/RecapStory.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RecapStory.d.ts","sourceRoot":"","sources":["../src/RecapStory.tsx"],"names":[],"mappings":"AAgBA,OAAO,EAAuB,SAAS,EAAE,MAAM,SAAS,CAAC;AAKzD,OAAO,kBAAkB,CAAC;AAE1B,UAAU,eAAe;IACvB,SAAS,EAAE,SAAS,CAAC;CACtB;AAED;;GAEG;AACH,iBAAS,UAAU,CAAC,EAAE,SAAS,EAAE,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"RecapStory.d.ts","sourceRoot":"","sources":["../src/RecapStory.tsx"],"names":[],"mappings":"AAgBA,OAAO,EAAuB,SAAS,EAAE,MAAM,SAAS,CAAC;AAKzD,OAAO,kBAAkB,CAAC;AAE1B,UAAU,eAAe;IACvB,SAAS,EAAE,SAAS,CAAC;CACtB;AAED;;GAEG;AACH,iBAAS,UAAU,CAAC,EAAE,SAAS,EAAE,EAAE,eAAe,2CAgTjD;AAED,eAAe,UAAU,CAAC"}
|
package/dist/RecapStory.js
CHANGED
|
@@ -1,38 +1,50 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import React, { useState } from
|
|
3
|
-
import { AnimatePresence, motion } from
|
|
4
|
-
import StoryProgress from
|
|
5
|
-
import Header from
|
|
6
|
-
import Slide1Intro from
|
|
7
|
-
import Slide2Days from
|
|
8
|
-
import Slide3Revenue from
|
|
9
|
-
import Slide4Orders from
|
|
10
|
-
import Slide5Buyers from
|
|
11
|
-
import Slide6Customer from
|
|
12
|
-
import Slide7Products from
|
|
13
|
-
import Slide8Months from
|
|
14
|
-
import Slide9Year from
|
|
15
|
-
import Slide10Final from
|
|
16
|
-
import { slideVariants } from
|
|
17
|
-
import { slideDurations } from
|
|
18
|
-
import { BUSINESS_CATEGORIES } from
|
|
19
|
-
import { useBackgroundMusic } from
|
|
20
|
-
import soundOnIcon from
|
|
21
|
-
import soundOffIcon from
|
|
22
|
-
import recapMusic from
|
|
23
|
-
import
|
|
2
|
+
import React, { useState, useRef } from "react";
|
|
3
|
+
import { AnimatePresence, motion } from "framer-motion";
|
|
4
|
+
import StoryProgress from "./StoryProgress";
|
|
5
|
+
import Header from "./components/Header";
|
|
6
|
+
import Slide1Intro from "./slides/Slide1Intro";
|
|
7
|
+
import Slide2Days from "./slides/Slide2Days";
|
|
8
|
+
import Slide3Revenue from "./slides/Slide3Revenue";
|
|
9
|
+
import Slide4Orders from "./slides/Slide4Orders";
|
|
10
|
+
import Slide5Buyers from "./slides/Slide5Buyers";
|
|
11
|
+
import Slide6Customer from "./slides/Slide6Customer";
|
|
12
|
+
import Slide7Products from "./slides/Slide7Products";
|
|
13
|
+
import Slide8Months from "./slides/Slide8Months";
|
|
14
|
+
import Slide9Year from "./slides/Slide9Year";
|
|
15
|
+
import Slide10Final from "./slides/Slide10Final";
|
|
16
|
+
import { slideVariants } from "./utils";
|
|
17
|
+
import { slideDurations as defaultDurations } from "./data/mock";
|
|
18
|
+
import { BUSINESS_CATEGORIES } from "./types";
|
|
19
|
+
import { useBackgroundMusic } from "./hooks/useBackgroundMusic";
|
|
20
|
+
import soundOnIcon from "./assets/sound-on.svg";
|
|
21
|
+
import soundOffIcon from "./assets/sound-off.svg";
|
|
22
|
+
import recapMusic from "./assets/recap-music.mp3";
|
|
23
|
+
import "./RecapStory.css";
|
|
24
24
|
/**
|
|
25
25
|
* RecapStory - Story container with header, progress bars, and slide transitions
|
|
26
26
|
*/
|
|
27
27
|
function RecapStory({ recapData }) {
|
|
28
28
|
const [activeIndex, setActiveIndex] = useState(0);
|
|
29
|
-
const
|
|
29
|
+
const durations = recapData.slideDurations || defaultDurations;
|
|
30
|
+
const [introDuration, setIntroDuration] = useState(durations.intro);
|
|
30
31
|
const [isIntroDurationReady, setIsIntroDurationReady] = useState(false);
|
|
32
|
+
const [isPaused, setIsPaused] = useState(false);
|
|
33
|
+
const holdTimerRef = useRef(null);
|
|
34
|
+
const isHoldingRef = useRef(false);
|
|
35
|
+
// Cleanup on unmount to prevent memory leaks
|
|
36
|
+
React.useEffect(() => {
|
|
37
|
+
return () => {
|
|
38
|
+
if (holdTimerRef.current) {
|
|
39
|
+
clearTimeout(holdTimerRef.current);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
}, []);
|
|
31
43
|
const { isMuted, isPlaying, toggleMute, play, stop } = useBackgroundMusic({
|
|
32
44
|
src: recapMusic,
|
|
33
45
|
volume: 0.6,
|
|
34
46
|
autoPlay: true,
|
|
35
|
-
loop: false
|
|
47
|
+
loop: false,
|
|
36
48
|
});
|
|
37
49
|
// Handle intro duration updates
|
|
38
50
|
const handleIntroDurationCalculated = (duration) => {
|
|
@@ -48,20 +60,22 @@ function RecapStory({ recapData }) {
|
|
|
48
60
|
const isNewUser = recapData.businessCategory === BUSINESS_CATEGORIES.NEW_USER;
|
|
49
61
|
// Define slides with their durations (new-user only sees the intro)
|
|
50
62
|
const fullSlideSet = [
|
|
51
|
-
{ id:
|
|
52
|
-
{ id:
|
|
53
|
-
{ id:
|
|
54
|
-
{ id:
|
|
55
|
-
{ id:
|
|
56
|
-
{ id:
|
|
57
|
-
{ id:
|
|
58
|
-
{ id:
|
|
59
|
-
{ id:
|
|
60
|
-
{ id:
|
|
63
|
+
{ id: "intro", duration: introDuration },
|
|
64
|
+
{ id: "days", duration: durations.days },
|
|
65
|
+
{ id: "revenue", duration: durations.revenue },
|
|
66
|
+
{ id: "orders", duration: durations.orders },
|
|
67
|
+
{ id: "buyers", duration: durations.buyers },
|
|
68
|
+
{ id: "customer", duration: durations.customer },
|
|
69
|
+
{ id: "products", duration: durations.products },
|
|
70
|
+
{ id: "months", duration: durations.months },
|
|
71
|
+
{ id: "year", duration: durations.year },
|
|
72
|
+
{ id: "final", duration: durations.final },
|
|
61
73
|
];
|
|
62
|
-
const slides = isNewUser
|
|
74
|
+
const slides = isNewUser
|
|
75
|
+
? [{ id: "intro", duration: introDuration }]
|
|
76
|
+
: fullSlideSet;
|
|
63
77
|
const currentSlide = slides[activeIndex];
|
|
64
|
-
const isFinalSlide = currentSlide.id ===
|
|
78
|
+
const isFinalSlide = currentSlide.id === "final";
|
|
65
79
|
// Ensure music plays only on slides 1-9 and stops immediately on the final slide
|
|
66
80
|
React.useEffect(() => {
|
|
67
81
|
if (isFinalSlide) {
|
|
@@ -83,68 +97,109 @@ function RecapStory({ recapData }) {
|
|
|
83
97
|
return;
|
|
84
98
|
}
|
|
85
99
|
if (activeIndex < slides.length - 1) {
|
|
86
|
-
setActiveIndex(prev => prev + 1);
|
|
100
|
+
setActiveIndex((prev) => prev + 1);
|
|
101
|
+
setIsPaused(false);
|
|
87
102
|
}
|
|
88
103
|
};
|
|
89
104
|
const handleReplay = () => {
|
|
90
105
|
setActiveIndex(0);
|
|
91
106
|
setIsIntroDurationReady(false);
|
|
107
|
+
setIsPaused(false);
|
|
92
108
|
};
|
|
93
109
|
// Jump to specific slide when bar is clicked
|
|
94
110
|
const handleBarClick = (index) => {
|
|
95
111
|
setActiveIndex(index);
|
|
112
|
+
setIsPaused(false);
|
|
113
|
+
};
|
|
114
|
+
// Handle hold to pause
|
|
115
|
+
const handlePointerDown = (event) => {
|
|
116
|
+
// Ignore if on interactive elements
|
|
117
|
+
const target = event.target;
|
|
118
|
+
if (target.tagName === "BUTTON" || target.closest("button")) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
isHoldingRef.current = false;
|
|
122
|
+
// Start hold timer - pause after 150ms of holding
|
|
123
|
+
holdTimerRef.current = setTimeout(() => {
|
|
124
|
+
isHoldingRef.current = true;
|
|
125
|
+
setIsPaused(true);
|
|
126
|
+
}, 150);
|
|
96
127
|
};
|
|
97
|
-
|
|
98
|
-
|
|
128
|
+
const handlePointerUp = (event) => {
|
|
129
|
+
// Clear hold timer
|
|
130
|
+
if (holdTimerRef.current) {
|
|
131
|
+
clearTimeout(holdTimerRef.current);
|
|
132
|
+
holdTimerRef.current = null;
|
|
133
|
+
}
|
|
134
|
+
// If was holding, just unpause and don't navigate
|
|
135
|
+
if (isHoldingRef.current) {
|
|
136
|
+
isHoldingRef.current = false;
|
|
137
|
+
setIsPaused(false);
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
99
140
|
// Ignore clicks on interactive elements
|
|
100
141
|
const target = event.target;
|
|
101
|
-
if (target.tagName ===
|
|
142
|
+
if (target.tagName === "BUTTON" || target.closest("button")) {
|
|
102
143
|
return;
|
|
103
144
|
}
|
|
104
145
|
const container = event.currentTarget;
|
|
105
146
|
const rect = container.getBoundingClientRect();
|
|
106
147
|
const tapX = event.clientX - rect.left;
|
|
107
148
|
const screenWidth = rect.width;
|
|
108
|
-
// Left
|
|
109
|
-
if (tapX < screenWidth
|
|
149
|
+
// Left 20% of screen = previous slide
|
|
150
|
+
if (tapX < screenWidth * 0.2) {
|
|
110
151
|
if (activeIndex > 0) {
|
|
111
|
-
setActiveIndex(prev => prev - 1);
|
|
152
|
+
setActiveIndex((prev) => prev - 1);
|
|
153
|
+
setIsPaused(false);
|
|
112
154
|
}
|
|
113
155
|
}
|
|
114
|
-
// Right
|
|
115
|
-
else {
|
|
156
|
+
// Right 20% of screen = next slide
|
|
157
|
+
else if (tapX > screenWidth * 0.8) {
|
|
116
158
|
if (!isFinalSlide && activeIndex < slides.length - 1) {
|
|
117
|
-
setActiveIndex(prev => prev + 1);
|
|
159
|
+
setActiveIndex((prev) => prev + 1);
|
|
160
|
+
setIsPaused(false);
|
|
118
161
|
}
|
|
119
162
|
}
|
|
163
|
+
// Middle 60% = no navigation, just tap (already handled by hold logic)
|
|
164
|
+
};
|
|
165
|
+
const handlePointerLeave = () => {
|
|
166
|
+
// Clear hold timer and unpause if leaving
|
|
167
|
+
if (holdTimerRef.current) {
|
|
168
|
+
clearTimeout(holdTimerRef.current);
|
|
169
|
+
holdTimerRef.current = null;
|
|
170
|
+
}
|
|
171
|
+
if (isHoldingRef.current) {
|
|
172
|
+
isHoldingRef.current = false;
|
|
173
|
+
setIsPaused(false);
|
|
174
|
+
}
|
|
120
175
|
};
|
|
121
176
|
// Render current slide content
|
|
122
177
|
const renderSlide = () => {
|
|
123
178
|
switch (currentSlide.id) {
|
|
124
|
-
case
|
|
179
|
+
case "intro":
|
|
125
180
|
return (_jsx(Slide1Intro, { businessName: recapData.businessName, businessCategory: recapData.businessCategory, introHeadline: recapData.introHeadline, introSubtitle: recapData.introSubtitle, onDurationCalculated: handleIntroDurationCalculated }));
|
|
126
|
-
case
|
|
127
|
-
return
|
|
128
|
-
case
|
|
181
|
+
case "days":
|
|
182
|
+
return _jsx(Slide2Days, { days: recapData.days, streak: recapData.streak });
|
|
183
|
+
case "revenue":
|
|
129
184
|
return (_jsx(Slide3Revenue, { revenue: recapData.revenue, currency: recapData.currency, businessCategory: recapData.businessCategory }));
|
|
130
|
-
case
|
|
131
|
-
return
|
|
132
|
-
case
|
|
185
|
+
case "orders":
|
|
186
|
+
return _jsx(Slide4Orders, { orders: recapData.orders });
|
|
187
|
+
case "buyers":
|
|
133
188
|
return (_jsx(Slide5Buyers, { firstTimeBuyers: recapData.firstTimeBuyers, repeatBuyers: recapData.repeatBuyers }));
|
|
134
|
-
case
|
|
135
|
-
return
|
|
136
|
-
case
|
|
137
|
-
return
|
|
138
|
-
case
|
|
139
|
-
return
|
|
140
|
-
case
|
|
189
|
+
case "customer":
|
|
190
|
+
return _jsx(Slide6Customer, { customerName: recapData.topCustomerName });
|
|
191
|
+
case "products":
|
|
192
|
+
return _jsx(Slide7Products, { products: recapData.topProducts });
|
|
193
|
+
case "months":
|
|
194
|
+
return _jsx(Slide8Months, { busiestMonth: recapData.busiestMonth });
|
|
195
|
+
case "year":
|
|
141
196
|
return (_jsx(Slide9Year, { businessCategory: recapData.businessCategory, year: recapData.year }));
|
|
142
|
-
case
|
|
197
|
+
case "final":
|
|
143
198
|
return (_jsx(Slide10Final, { videoUrl: recapData.videoUrl, downloadUrl: recapData.downloadUrl, year: recapData.year, onReplay: handleReplay }));
|
|
144
199
|
default:
|
|
145
200
|
return null;
|
|
146
201
|
}
|
|
147
202
|
};
|
|
148
|
-
return (_jsxs("div", { className: "recap-story", children: [_jsxs("div", { className: "recap-story__top-group", children: [_jsx("div", { className: "recap-story__header-wrapper", children: _jsx(Header, { showRecapBadge: true, badgeVariant: isNewUser ?
|
|
203
|
+
return (_jsxs("div", { className: "recap-story", children: [_jsxs("div", { className: "recap-story__top-group", children: [_jsx("div", { className: "recap-story__header-wrapper", children: _jsx(Header, { showRecapBadge: true, badgeVariant: isNewUser ? "new-user" : "default", year: recapData.year }) }), _jsxs("div", { className: "recap-story__progress-wrap", children: [_jsx("div", { className: "recap-story__progress", children: (activeIndex !== 0 || isIntroDurationReady) && (_jsx(StoryProgress, { total: slides.length, active: activeIndex, duration: currentSlide.duration, onComplete: handleProgressComplete, onBarClick: handleBarClick, hideBorder: isFinalSlide, isPaused: isPaused })) }), !isFinalSlide && recapData.isVideo !== true && (_jsx("button", { type: "button", className: "recap-story__sound-toggle", onClick: toggleMute, "aria-label": isMuted ? "Unmute sound" : "Mute sound", children: _jsx("img", { src: isMuted ? soundOffIcon : soundOnIcon, alt: isMuted ? "Unmute sound" : "Mute sound", className: "recap-story__sound-icon", draggable: false }) }))] })] }), _jsx("div", { className: "recap-story__slides", onPointerDown: handlePointerDown, onPointerUp: handlePointerUp, onPointerLeave: handlePointerLeave, onPointerCancel: handlePointerLeave, children: _jsx(AnimatePresence, { mode: "wait", children: _jsx(motion.div, { variants: slideVariants, initial: "initial", animate: "animate", exit: "exit", className: "recap-story__slide", children: renderSlide() }, currentSlide.id) }) })] }));
|
|
149
204
|
}
|
|
150
205
|
export default RecapStory;
|
package/dist/StoryProgress.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "./StoryProgress.css";
|
|
2
2
|
interface StoryProgressProps {
|
|
3
3
|
total: number;
|
|
4
4
|
active: number;
|
|
@@ -6,10 +6,11 @@ interface StoryProgressProps {
|
|
|
6
6
|
onComplete: () => void;
|
|
7
7
|
onBarClick: (index: number) => void;
|
|
8
8
|
hideBorder?: boolean;
|
|
9
|
+
isPaused?: boolean;
|
|
9
10
|
}
|
|
10
11
|
/**
|
|
11
12
|
* StoryProgress - Story-style progress bars at the top
|
|
12
13
|
*/
|
|
13
|
-
declare function StoryProgress({ total, active, duration, onComplete, onBarClick, hideBorder }: StoryProgressProps): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
declare function StoryProgress({ total, active, duration, onComplete, onBarClick, hideBorder, isPaused, }: StoryProgressProps): import("react/jsx-runtime").JSX.Element;
|
|
14
15
|
export default StoryProgress;
|
|
15
16
|
//# sourceMappingURL=StoryProgress.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StoryProgress.d.ts","sourceRoot":"","sources":["../src/StoryProgress.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"StoryProgress.d.ts","sourceRoot":"","sources":["../src/StoryProgress.tsx"],"names":[],"mappings":"AACA,OAAO,qBAAqB,CAAC;AAE7B,UAAU,kBAAkB;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;GAEG;AACH,iBAAS,aAAa,CAAC,EACrB,KAAK,EACL,MAAM,EACN,QAAQ,EACR,UAAU,EACV,UAAU,EACV,UAAU,EACV,QAAQ,GACT,EAAE,kBAAkB,2CA4GpB;AAED,eAAe,aAAa,CAAC"}
|
package/dist/StoryProgress.js
CHANGED
|
@@ -1,23 +1,77 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useEffect, useState } from
|
|
3
|
-
import
|
|
4
|
-
import './StoryProgress.css';
|
|
2
|
+
import { useEffect, useState, useRef } from "react";
|
|
3
|
+
import "./StoryProgress.css";
|
|
5
4
|
/**
|
|
6
5
|
* StoryProgress - Story-style progress bars at the top
|
|
7
6
|
*/
|
|
8
|
-
function StoryProgress({ total, active, duration, onComplete, onBarClick, hideBorder }) {
|
|
9
|
-
const [
|
|
10
|
-
|
|
7
|
+
function StoryProgress({ total, active, duration, onComplete, onBarClick, hideBorder, isPaused, }) {
|
|
8
|
+
const [progress, setProgress] = useState(0);
|
|
9
|
+
const progressRef = useRef(0);
|
|
10
|
+
const startTimeRef = useRef(0);
|
|
11
|
+
const pausedProgressRef = useRef(0);
|
|
12
|
+
const animationFrameRef = useRef(null);
|
|
13
|
+
const onCompleteRef = useRef(onComplete);
|
|
14
|
+
// Keep onComplete ref up to date
|
|
11
15
|
useEffect(() => {
|
|
12
|
-
|
|
16
|
+
onCompleteRef.current = onComplete;
|
|
17
|
+
}, [onComplete]);
|
|
18
|
+
// Reset progress when active slide changes
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
setProgress(0);
|
|
21
|
+
progressRef.current = 0;
|
|
22
|
+
pausedProgressRef.current = 0;
|
|
23
|
+
startTimeRef.current = performance.now();
|
|
13
24
|
}, [active]);
|
|
14
|
-
|
|
25
|
+
// Animation loop with pause support
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
if (isPaused) {
|
|
28
|
+
// Save current progress when pausing
|
|
29
|
+
pausedProgressRef.current = progressRef.current;
|
|
30
|
+
if (animationFrameRef.current) {
|
|
31
|
+
cancelAnimationFrame(animationFrameRef.current);
|
|
32
|
+
animationFrameRef.current = null;
|
|
33
|
+
}
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
// Resume from paused progress
|
|
37
|
+
startTimeRef.current = performance.now();
|
|
38
|
+
const startProgress = pausedProgressRef.current;
|
|
39
|
+
if (startProgress >= 1) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
if (startProgress >= 1) {
|
|
43
|
+
setProgress(1);
|
|
44
|
+
onCompleteRef.current();
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const remainingDuration = duration * (1 - startProgress) * 1000;
|
|
48
|
+
const animate = (currentTime) => {
|
|
49
|
+
const elapsed = currentTime - startTimeRef.current;
|
|
50
|
+
const newProgress = startProgress + (elapsed / remainingDuration) * (1 - startProgress);
|
|
51
|
+
if (newProgress >= 1) {
|
|
52
|
+
progressRef.current = 1;
|
|
53
|
+
setProgress(1);
|
|
54
|
+
onCompleteRef.current();
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
progressRef.current = newProgress;
|
|
58
|
+
setProgress(newProgress);
|
|
59
|
+
animationFrameRef.current = requestAnimationFrame(animate);
|
|
60
|
+
};
|
|
61
|
+
animationFrameRef.current = requestAnimationFrame(animate);
|
|
62
|
+
return () => {
|
|
63
|
+
if (animationFrameRef.current) {
|
|
64
|
+
cancelAnimationFrame(animationFrameRef.current);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
}, [isPaused, duration, active]);
|
|
68
|
+
return (_jsx("div", { className: `story-progress${hideBorder ? " story-progress--no-border" : ""}`, children: Array.from({ length: total }).map((_, index) => {
|
|
15
69
|
const isActive = index === active;
|
|
16
70
|
const isCompleted = index < active;
|
|
17
|
-
return (_jsx("div", { className: "story-progress__bar-container", onClick: () => onBarClick(index), children: _jsx("div", { className: `story-progress__bar ${isCompleted ?
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
71
|
+
return (_jsx("div", { className: "story-progress__bar-container", onClick: () => onBarClick(index), children: _jsx("div", { className: `story-progress__bar ${isCompleted ? "completed" : ""}`, children: isActive && (_jsx("div", { className: "story-progress__bar-fill", style: {
|
|
72
|
+
transform: `scaleX(${progress})`,
|
|
73
|
+
transformOrigin: "left",
|
|
74
|
+
} })) }) }, index));
|
|
21
75
|
}) }));
|
|
22
76
|
}
|
|
23
77
|
export default StoryProgress;
|
package/dist/data/mock.d.ts
CHANGED
package/dist/data/mock.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mock.d.ts","sourceRoot":"","sources":["../../src/data/mock.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C;;;GAGG;AACH,eAAO,MAAM,aAAa,EAAE,
|
|
1
|
+
{"version":3,"file":"mock.d.ts","sourceRoot":"","sources":["../../src/data/mock.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C;;;GAGG;AACH,eAAO,MAAM,aAAa,EAAE,SAoD3B,CAAC;AAGF,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAWjD,CAAC"}
|
package/dist/data/mock.js
CHANGED
|
@@ -1,52 +1,53 @@
|
|
|
1
|
-
import { BUSINESS_CATEGORIES } from
|
|
1
|
+
import { BUSINESS_CATEGORIES } from "../types";
|
|
2
2
|
/**
|
|
3
3
|
* Mock data for the recap experience
|
|
4
4
|
* This will be replaced with real API data later
|
|
5
5
|
*/
|
|
6
6
|
export const mockRecapData = {
|
|
7
|
-
businessName:
|
|
7
|
+
businessName: "RICHYO ENTERPRISES",
|
|
8
8
|
days: 259,
|
|
9
9
|
streak: 47,
|
|
10
10
|
revenue: 22594,
|
|
11
11
|
orders: 487,
|
|
12
12
|
firstTimeBuyers: 234,
|
|
13
13
|
repeatBuyers: 65,
|
|
14
|
-
topCustomerName:
|
|
15
|
-
currency:
|
|
14
|
+
topCustomerName: "Micheal Scoffy",
|
|
15
|
+
currency: "GBP",
|
|
16
16
|
year: 2025,
|
|
17
|
-
introHeadline:
|
|
18
|
-
introSubtitle:
|
|
17
|
+
introHeadline: "You Be New Face OOO....",
|
|
18
|
+
introSubtitle: "Come back for 6 days time, we dey for you 😉",
|
|
19
19
|
topProducts: [
|
|
20
20
|
{
|
|
21
|
-
name:
|
|
21
|
+
name: "Vanilla Yoghurt",
|
|
22
22
|
units: 45,
|
|
23
|
-
productImage:
|
|
23
|
+
productImage: "https://images.unsplash.com/photo-1447078806655-40579c2520d6?auto=format&fit=crop&w=400&q=80",
|
|
24
24
|
},
|
|
25
25
|
{
|
|
26
|
-
name:
|
|
26
|
+
name: "Cocoa Milkshake",
|
|
27
27
|
units: 38,
|
|
28
|
-
productImage:
|
|
28
|
+
productImage: "https://images.unsplash.com/photo-1504674900247-0877df9cc836?auto=format&fit=crop&w=400&q=80",
|
|
29
29
|
},
|
|
30
30
|
{
|
|
31
|
-
name:
|
|
31
|
+
name: "Spicy Crunch",
|
|
32
32
|
units: 33,
|
|
33
|
-
productImage:
|
|
33
|
+
productImage: "https://images.unsplash.com/photo-1447078806655-40579c2520d6?auto=format&fit=crop&w=400&q=80",
|
|
34
34
|
},
|
|
35
35
|
{
|
|
36
|
-
name:
|
|
36
|
+
name: "Fresh Plantain Chips",
|
|
37
37
|
units: 29,
|
|
38
|
-
productImage:
|
|
38
|
+
productImage: "https://images.unsplash.com/photo-1506084868230-bb9d95c24759?auto=format&fit=crop&w=400&q=80",
|
|
39
39
|
},
|
|
40
40
|
{
|
|
41
|
-
name:
|
|
41
|
+
name: "Mango Juice",
|
|
42
42
|
units: 27,
|
|
43
|
-
productImage:
|
|
44
|
-
}
|
|
43
|
+
productImage: "https://images.unsplash.com/photo-1447078806655-40579c2520d6?auto=format&fit=crop&w=400&q=80",
|
|
44
|
+
},
|
|
45
45
|
],
|
|
46
|
-
businessCategory: BUSINESS_CATEGORIES.
|
|
47
|
-
busiestMonth:
|
|
48
|
-
videoUrl:
|
|
49
|
-
downloadUrl:
|
|
46
|
+
businessCategory: BUSINESS_CATEGORIES.THRIVING,
|
|
47
|
+
busiestMonth: "Oct",
|
|
48
|
+
videoUrl: "https://katajereassets.blob.core.windows.net/sp-list-assets/mocksite_walkthrough_a75c98dd-47ef-4f2c-a97c-ab2b3c3c97a5_2315a6b2d671d142f34e08cad43929c5.mp4",
|
|
49
|
+
downloadUrl: "https://api.huxxle.com/api/download?fileUrl=https://katajereassets.blob.core.windows.net/sp-list-assets/mocksite_walkthrough_a75c98dd-47ef-4f2c-a97c-ab2b3c3c97a5_2315a6b2d671d142f34e08cad43929c5.mp4",
|
|
50
|
+
isVideo: true
|
|
50
51
|
};
|
|
51
52
|
// Slide durations in seconds - each slide can have its own timing
|
|
52
53
|
export const slideDurations = {
|
|
@@ -59,5 +60,5 @@ export const slideDurations = {
|
|
|
59
60
|
products: 8,
|
|
60
61
|
months: 8,
|
|
61
62
|
year: 8,
|
|
62
|
-
final: 8
|
|
63
|
+
final: 8,
|
|
63
64
|
};
|
package/dist/types.d.ts
CHANGED
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,KAAK,GAAG,OAAO,CAAC;AAEjD,MAAM,MAAM,gBAAgB,GAAG,UAAU,GAAG,cAAc,GAAG,UAAU,CAAC;AAExE,MAAM,WAAW,SAAS;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,WAAW,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC;IACnC,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,KAAK,GAAG,OAAO,CAAC;AAEjD,MAAM,MAAM,gBAAgB,GAAG,UAAU,GAAG,cAAc,GAAG,UAAU,CAAC;AAExE,MAAM,WAAW,SAAS;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,WAAW,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC;IACnC,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxC,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,eAAO,MAAM,UAAU;WACH,QAAQ;SACZ,QAAQ;WACJ,QAAQ;CAC3B,CAAC;AAEF,eAAO,MAAM,mBAAmB;cACN,gBAAgB;kBACR,gBAAgB;cACxB,gBAAgB;CACzC,CAAC"}
|
package/package.json
CHANGED
package/src/App.css
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
:root {
|
|
4
4
|
--frame-ar-num: 9;
|
|
5
|
-
--frame-ar-den:
|
|
6
|
-
--frame-ar: 9 /
|
|
5
|
+
--frame-ar-den: 16;
|
|
6
|
+
--frame-ar: 9 / 16;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
* {
|
|
@@ -60,8 +60,8 @@ body {
|
|
|
60
60
|
aspect-ratio: var(--frame-ar);
|
|
61
61
|
width: min(100%, calc(100dvh * var(--frame-ar-num) / var(--frame-ar-den)));
|
|
62
62
|
height: min(100dvh, calc(100vw * var(--frame-ar-den) / var(--frame-ar-num)));
|
|
63
|
-
max-width:
|
|
64
|
-
max-height:
|
|
63
|
+
max-width: 1080px;
|
|
64
|
+
max-height: 1920px;
|
|
65
65
|
background: linear-gradient(180deg, #3F3DAD 0%, #CC6240 100%);
|
|
66
66
|
/* border-radius: clamp(0px, 2vw, 24px); */
|
|
67
67
|
overflow: hidden;
|
|
@@ -72,14 +72,14 @@ body {
|
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
/* Fallback for browsers without aspect-ratio support */
|
|
75
|
-
@supports not (aspect-ratio: 9 /
|
|
75
|
+
@supports not (aspect-ratio: 9 / 16) {
|
|
76
76
|
.app__shell {
|
|
77
77
|
width: 100vw;
|
|
78
78
|
height: calc(100vw * var(--frame-ar-den) / var(--frame-ar-num));
|
|
79
79
|
max-height: 100dvh;
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
@media (min-aspect-ratio: 9/
|
|
82
|
+
@media (min-aspect-ratio: 9/16) {
|
|
83
83
|
.app__shell {
|
|
84
84
|
width: calc(100dvh * var(--frame-ar-num) / var(--frame-ar-den));
|
|
85
85
|
height: 100dvh;
|
|
@@ -88,7 +88,7 @@ body {
|
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
/* Mobile - remove border radius and shadow */
|
|
91
|
-
@media (max-width:
|
|
91
|
+
@media (max-width: 600px) {
|
|
92
92
|
.app {
|
|
93
93
|
background: linear-gradient(180deg, #3F3DAD 0%, #CC6240 100%);
|
|
94
94
|
padding: 0;
|
|
@@ -101,10 +101,10 @@ body {
|
|
|
101
101
|
.app__shell {
|
|
102
102
|
/* border-radius: 0; */
|
|
103
103
|
box-shadow: none;
|
|
104
|
-
width:
|
|
104
|
+
width: 100vw;
|
|
105
105
|
height: 100dvh;
|
|
106
|
-
max-width:
|
|
107
|
-
max-height:
|
|
106
|
+
max-width: 100vw;
|
|
107
|
+
max-height: 100dvh;
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
|
package/src/RecapStory.tsx
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import React, { useState } from
|
|
2
|
-
import { AnimatePresence, motion } from
|
|
3
|
-
import StoryProgress from
|
|
4
|
-
import Header from
|
|
5
|
-
import Slide1Intro from
|
|
6
|
-
import Slide2Days from
|
|
7
|
-
import Slide3Revenue from
|
|
8
|
-
import Slide4Orders from
|
|
9
|
-
import Slide5Buyers from
|
|
10
|
-
import Slide6Customer from
|
|
11
|
-
import Slide7Products from
|
|
12
|
-
import Slide8Months from
|
|
13
|
-
import Slide9Year from
|
|
14
|
-
import Slide10Final from
|
|
15
|
-
import { slideVariants } from
|
|
16
|
-
import { slideDurations } from
|
|
17
|
-
import { BUSINESS_CATEGORIES, RecapData } from
|
|
18
|
-
import { useBackgroundMusic } from
|
|
19
|
-
import soundOnIcon from
|
|
20
|
-
import soundOffIcon from
|
|
21
|
-
import recapMusic from
|
|
22
|
-
import
|
|
1
|
+
import React, { useState, useRef } from "react";
|
|
2
|
+
import { AnimatePresence, motion } from "framer-motion";
|
|
3
|
+
import StoryProgress from "./StoryProgress";
|
|
4
|
+
import Header from "./components/Header";
|
|
5
|
+
import Slide1Intro from "./slides/Slide1Intro";
|
|
6
|
+
import Slide2Days from "./slides/Slide2Days";
|
|
7
|
+
import Slide3Revenue from "./slides/Slide3Revenue";
|
|
8
|
+
import Slide4Orders from "./slides/Slide4Orders";
|
|
9
|
+
import Slide5Buyers from "./slides/Slide5Buyers";
|
|
10
|
+
import Slide6Customer from "./slides/Slide6Customer";
|
|
11
|
+
import Slide7Products from "./slides/Slide7Products";
|
|
12
|
+
import Slide8Months from "./slides/Slide8Months";
|
|
13
|
+
import Slide9Year from "./slides/Slide9Year";
|
|
14
|
+
import Slide10Final from "./slides/Slide10Final";
|
|
15
|
+
import { slideVariants } from "./utils";
|
|
16
|
+
import { slideDurations as defaultDurations } from "./data/mock";
|
|
17
|
+
import { BUSINESS_CATEGORIES, RecapData } from "./types";
|
|
18
|
+
import { useBackgroundMusic } from "./hooks/useBackgroundMusic";
|
|
19
|
+
import soundOnIcon from "./assets/sound-on.svg";
|
|
20
|
+
import soundOffIcon from "./assets/sound-off.svg";
|
|
21
|
+
import recapMusic from "./assets/recap-music.mp3";
|
|
22
|
+
import "./RecapStory.css";
|
|
23
23
|
|
|
24
24
|
interface RecapStoryProps {
|
|
25
25
|
recapData: RecapData;
|
|
@@ -30,15 +30,31 @@ interface RecapStoryProps {
|
|
|
30
30
|
*/
|
|
31
31
|
function RecapStory({ recapData }: RecapStoryProps) {
|
|
32
32
|
const [activeIndex, setActiveIndex] = useState<number>(0);
|
|
33
|
-
const
|
|
34
|
-
const [
|
|
33
|
+
const durations = recapData.slideDurations || defaultDurations;
|
|
34
|
+
const [introDuration, setIntroDuration] = useState<number>(
|
|
35
|
+
durations.intro
|
|
36
|
+
);
|
|
37
|
+
const [isIntroDurationReady, setIsIntroDurationReady] =
|
|
38
|
+
useState<boolean>(false);
|
|
39
|
+
const [isPaused, setIsPaused] = useState<boolean>(false);
|
|
40
|
+
const holdTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
41
|
+
const isHoldingRef = useRef<boolean>(false);
|
|
42
|
+
|
|
43
|
+
// Cleanup on unmount to prevent memory leaks
|
|
44
|
+
React.useEffect(() => {
|
|
45
|
+
return () => {
|
|
46
|
+
if (holdTimerRef.current) {
|
|
47
|
+
clearTimeout(holdTimerRef.current);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
}, []);
|
|
35
51
|
const { isMuted, isPlaying, toggleMute, play, stop } = useBackgroundMusic({
|
|
36
52
|
src: recapMusic,
|
|
37
53
|
volume: 0.6,
|
|
38
54
|
autoPlay: true,
|
|
39
|
-
loop: false
|
|
55
|
+
loop: false,
|
|
40
56
|
});
|
|
41
|
-
|
|
57
|
+
|
|
42
58
|
// Handle intro duration updates
|
|
43
59
|
const handleIntroDurationCalculated = (duration: number) => {
|
|
44
60
|
setIntroDuration(duration);
|
|
@@ -56,21 +72,23 @@ function RecapStory({ recapData }: RecapStoryProps) {
|
|
|
56
72
|
|
|
57
73
|
// Define slides with their durations (new-user only sees the intro)
|
|
58
74
|
const fullSlideSet = [
|
|
59
|
-
{ id:
|
|
60
|
-
{ id:
|
|
61
|
-
{ id:
|
|
62
|
-
{ id:
|
|
63
|
-
{ id:
|
|
64
|
-
{ id:
|
|
65
|
-
{ id:
|
|
66
|
-
{ id:
|
|
67
|
-
{ id:
|
|
68
|
-
{ id:
|
|
75
|
+
{ id: "intro", duration: introDuration },
|
|
76
|
+
{ id: "days", duration: durations.days },
|
|
77
|
+
{ id: "revenue", duration: durations.revenue },
|
|
78
|
+
{ id: "orders", duration: durations.orders },
|
|
79
|
+
{ id: "buyers", duration: durations.buyers },
|
|
80
|
+
{ id: "customer", duration: durations.customer },
|
|
81
|
+
{ id: "products", duration: durations.products },
|
|
82
|
+
{ id: "months", duration: durations.months },
|
|
83
|
+
{ id: "year", duration: durations.year },
|
|
84
|
+
{ id: "final", duration: durations.final },
|
|
69
85
|
];
|
|
70
|
-
const slides = isNewUser
|
|
86
|
+
const slides = isNewUser
|
|
87
|
+
? [{ id: "intro", duration: introDuration }]
|
|
88
|
+
: fullSlideSet;
|
|
71
89
|
|
|
72
90
|
const currentSlide = slides[activeIndex];
|
|
73
|
-
const isFinalSlide = currentSlide.id ===
|
|
91
|
+
const isFinalSlide = currentSlide.id === "final";
|
|
74
92
|
|
|
75
93
|
// Ensure music plays only on slides 1-9 and stops immediately on the final slide
|
|
76
94
|
React.useEffect(() => {
|
|
@@ -97,25 +115,57 @@ function RecapStory({ recapData }: RecapStoryProps) {
|
|
|
97
115
|
}
|
|
98
116
|
|
|
99
117
|
if (activeIndex < slides.length - 1) {
|
|
100
|
-
setActiveIndex(prev => prev + 1);
|
|
118
|
+
setActiveIndex((prev) => prev + 1);
|
|
119
|
+
setIsPaused(false);
|
|
101
120
|
}
|
|
102
121
|
};
|
|
103
122
|
|
|
104
123
|
const handleReplay = () => {
|
|
105
124
|
setActiveIndex(0);
|
|
106
125
|
setIsIntroDurationReady(false);
|
|
126
|
+
setIsPaused(false);
|
|
107
127
|
};
|
|
108
128
|
|
|
109
129
|
// Jump to specific slide when bar is clicked
|
|
110
130
|
const handleBarClick = (index: number) => {
|
|
111
131
|
setActiveIndex(index);
|
|
132
|
+
setIsPaused(false);
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
// Handle hold to pause
|
|
136
|
+
const handlePointerDown = (event: React.PointerEvent<HTMLDivElement>) => {
|
|
137
|
+
// Ignore if on interactive elements
|
|
138
|
+
const target = event.target as HTMLElement;
|
|
139
|
+
if (target.tagName === "BUTTON" || target.closest("button")) {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
isHoldingRef.current = false;
|
|
144
|
+
|
|
145
|
+
// Start hold timer - pause after 150ms of holding
|
|
146
|
+
holdTimerRef.current = setTimeout(() => {
|
|
147
|
+
isHoldingRef.current = true;
|
|
148
|
+
setIsPaused(true);
|
|
149
|
+
}, 150);
|
|
112
150
|
};
|
|
113
151
|
|
|
114
|
-
|
|
115
|
-
|
|
152
|
+
const handlePointerUp = (event: React.PointerEvent<HTMLDivElement>) => {
|
|
153
|
+
// Clear hold timer
|
|
154
|
+
if (holdTimerRef.current) {
|
|
155
|
+
clearTimeout(holdTimerRef.current);
|
|
156
|
+
holdTimerRef.current = null;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// If was holding, just unpause and don't navigate
|
|
160
|
+
if (isHoldingRef.current) {
|
|
161
|
+
isHoldingRef.current = false;
|
|
162
|
+
setIsPaused(false);
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
|
|
116
166
|
// Ignore clicks on interactive elements
|
|
117
167
|
const target = event.target as HTMLElement;
|
|
118
|
-
if (target.tagName ===
|
|
168
|
+
if (target.tagName === "BUTTON" || target.closest("button")) {
|
|
119
169
|
return;
|
|
120
170
|
}
|
|
121
171
|
|
|
@@ -123,27 +173,42 @@ function RecapStory({ recapData }: RecapStoryProps) {
|
|
|
123
173
|
const rect = container.getBoundingClientRect();
|
|
124
174
|
const tapX = event.clientX - rect.left;
|
|
125
175
|
const screenWidth = rect.width;
|
|
126
|
-
|
|
127
|
-
// Left
|
|
128
|
-
if (tapX < screenWidth
|
|
176
|
+
|
|
177
|
+
// Left 20% of screen = previous slide
|
|
178
|
+
if (tapX < screenWidth * 0.2) {
|
|
129
179
|
if (activeIndex > 0) {
|
|
130
|
-
setActiveIndex(prev => prev - 1);
|
|
180
|
+
setActiveIndex((prev) => prev - 1);
|
|
181
|
+
setIsPaused(false);
|
|
131
182
|
}
|
|
132
|
-
}
|
|
133
|
-
// Right
|
|
134
|
-
else {
|
|
183
|
+
}
|
|
184
|
+
// Right 20% of screen = next slide
|
|
185
|
+
else if (tapX > screenWidth * 0.8) {
|
|
135
186
|
if (!isFinalSlide && activeIndex < slides.length - 1) {
|
|
136
|
-
setActiveIndex(prev => prev + 1);
|
|
187
|
+
setActiveIndex((prev) => prev + 1);
|
|
188
|
+
setIsPaused(false);
|
|
137
189
|
}
|
|
138
190
|
}
|
|
191
|
+
// Middle 60% = no navigation, just tap (already handled by hold logic)
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
const handlePointerLeave = () => {
|
|
195
|
+
// Clear hold timer and unpause if leaving
|
|
196
|
+
if (holdTimerRef.current) {
|
|
197
|
+
clearTimeout(holdTimerRef.current);
|
|
198
|
+
holdTimerRef.current = null;
|
|
199
|
+
}
|
|
200
|
+
if (isHoldingRef.current) {
|
|
201
|
+
isHoldingRef.current = false;
|
|
202
|
+
setIsPaused(false);
|
|
203
|
+
}
|
|
139
204
|
};
|
|
140
205
|
|
|
141
206
|
// Render current slide content
|
|
142
207
|
const renderSlide = () => {
|
|
143
208
|
switch (currentSlide.id) {
|
|
144
|
-
case
|
|
209
|
+
case "intro":
|
|
145
210
|
return (
|
|
146
|
-
<Slide1Intro
|
|
211
|
+
<Slide1Intro
|
|
147
212
|
businessName={recapData.businessName}
|
|
148
213
|
businessCategory={recapData.businessCategory}
|
|
149
214
|
introHeadline={recapData.introHeadline}
|
|
@@ -151,54 +216,39 @@ function RecapStory({ recapData }: RecapStoryProps) {
|
|
|
151
216
|
onDurationCalculated={handleIntroDurationCalculated}
|
|
152
217
|
/>
|
|
153
218
|
);
|
|
154
|
-
case
|
|
219
|
+
case "days":
|
|
220
|
+
return <Slide2Days days={recapData.days} streak={recapData.streak} />;
|
|
221
|
+
case "revenue":
|
|
155
222
|
return (
|
|
156
|
-
<
|
|
157
|
-
days={recapData.days}
|
|
158
|
-
streak={recapData.streak}
|
|
159
|
-
/>
|
|
160
|
-
);
|
|
161
|
-
case 'revenue':
|
|
162
|
-
return (
|
|
163
|
-
<Slide3Revenue
|
|
223
|
+
<Slide3Revenue
|
|
164
224
|
revenue={recapData.revenue}
|
|
165
225
|
currency={recapData.currency}
|
|
166
226
|
businessCategory={recapData.businessCategory}
|
|
167
227
|
/>
|
|
168
228
|
);
|
|
169
|
-
case
|
|
170
|
-
return
|
|
171
|
-
|
|
172
|
-
orders={recapData.orders}
|
|
173
|
-
/>
|
|
174
|
-
);
|
|
175
|
-
case 'buyers':
|
|
229
|
+
case "orders":
|
|
230
|
+
return <Slide4Orders orders={recapData.orders} />;
|
|
231
|
+
case "buyers":
|
|
176
232
|
return (
|
|
177
233
|
<Slide5Buyers
|
|
178
234
|
firstTimeBuyers={recapData.firstTimeBuyers}
|
|
179
235
|
repeatBuyers={recapData.repeatBuyers}
|
|
180
236
|
/>
|
|
181
237
|
);
|
|
182
|
-
case
|
|
183
|
-
return
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
case
|
|
187
|
-
return
|
|
188
|
-
|
|
189
|
-
);
|
|
190
|
-
case 'months':
|
|
191
|
-
return (
|
|
192
|
-
<Slide8Months busiestMonth={recapData.busiestMonth} />
|
|
193
|
-
);
|
|
194
|
-
case 'year':
|
|
238
|
+
case "customer":
|
|
239
|
+
return <Slide6Customer customerName={recapData.topCustomerName} />;
|
|
240
|
+
case "products":
|
|
241
|
+
return <Slide7Products products={recapData.topProducts} />;
|
|
242
|
+
case "months":
|
|
243
|
+
return <Slide8Months busiestMonth={recapData.busiestMonth} />;
|
|
244
|
+
case "year":
|
|
195
245
|
return (
|
|
196
|
-
<Slide9Year
|
|
246
|
+
<Slide9Year
|
|
197
247
|
businessCategory={recapData.businessCategory}
|
|
198
248
|
year={recapData.year}
|
|
199
249
|
/>
|
|
200
250
|
);
|
|
201
|
-
case
|
|
251
|
+
case "final":
|
|
202
252
|
return (
|
|
203
253
|
<Slide10Final
|
|
204
254
|
videoUrl={recapData.videoUrl}
|
|
@@ -218,9 +268,9 @@ function RecapStory({ recapData }: RecapStoryProps) {
|
|
|
218
268
|
<div className="recap-story__top-group">
|
|
219
269
|
{/* Header with Huxxle logo and Recap badge */}
|
|
220
270
|
<div className="recap-story__header-wrapper">
|
|
221
|
-
<Header
|
|
222
|
-
showRecapBadge={true}
|
|
223
|
-
badgeVariant={isNewUser ?
|
|
271
|
+
<Header
|
|
272
|
+
showRecapBadge={true}
|
|
273
|
+
badgeVariant={isNewUser ? "new-user" : "default"}
|
|
224
274
|
year={recapData.year}
|
|
225
275
|
/>
|
|
226
276
|
</div>
|
|
@@ -236,20 +286,21 @@ function RecapStory({ recapData }: RecapStoryProps) {
|
|
|
236
286
|
onComplete={handleProgressComplete}
|
|
237
287
|
onBarClick={handleBarClick}
|
|
238
288
|
hideBorder={isFinalSlide}
|
|
289
|
+
isPaused={isPaused}
|
|
239
290
|
/>
|
|
240
291
|
)}
|
|
241
292
|
</div>
|
|
242
293
|
|
|
243
|
-
{!isFinalSlide && (
|
|
294
|
+
{!isFinalSlide && recapData.isVideo !== true && (
|
|
244
295
|
<button
|
|
245
296
|
type="button"
|
|
246
297
|
className="recap-story__sound-toggle"
|
|
247
298
|
onClick={toggleMute}
|
|
248
|
-
aria-label={isMuted ?
|
|
299
|
+
aria-label={isMuted ? "Unmute sound" : "Mute sound"}
|
|
249
300
|
>
|
|
250
301
|
<img
|
|
251
302
|
src={isMuted ? soundOffIcon : soundOnIcon}
|
|
252
|
-
alt={isMuted ?
|
|
303
|
+
alt={isMuted ? "Unmute sound" : "Mute sound"}
|
|
253
304
|
className="recap-story__sound-icon"
|
|
254
305
|
draggable={false}
|
|
255
306
|
/>
|
|
@@ -259,7 +310,13 @@ function RecapStory({ recapData }: RecapStoryProps) {
|
|
|
259
310
|
</div>
|
|
260
311
|
|
|
261
312
|
{/* Slide content with transitions */}
|
|
262
|
-
<div
|
|
313
|
+
<div
|
|
314
|
+
className="recap-story__slides"
|
|
315
|
+
onPointerDown={handlePointerDown}
|
|
316
|
+
onPointerUp={handlePointerUp}
|
|
317
|
+
onPointerLeave={handlePointerLeave}
|
|
318
|
+
onPointerCancel={handlePointerLeave}
|
|
319
|
+
>
|
|
263
320
|
<AnimatePresence mode="wait">
|
|
264
321
|
<motion.div
|
|
265
322
|
key={currentSlide.id}
|
package/src/StoryProgress.tsx
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import React, { useEffect, useState } from
|
|
2
|
-
import
|
|
3
|
-
import './StoryProgress.css';
|
|
1
|
+
import React, { useEffect, useState, useRef } from "react";
|
|
2
|
+
import "./StoryProgress.css";
|
|
4
3
|
|
|
5
4
|
interface StoryProgressProps {
|
|
6
5
|
total: number;
|
|
@@ -9,44 +8,120 @@ interface StoryProgressProps {
|
|
|
9
8
|
onComplete: () => void;
|
|
10
9
|
onBarClick: (index: number) => void;
|
|
11
10
|
hideBorder?: boolean;
|
|
11
|
+
isPaused?: boolean;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* StoryProgress - Story-style progress bars at the top
|
|
16
16
|
*/
|
|
17
|
-
function StoryProgress({
|
|
18
|
-
|
|
17
|
+
function StoryProgress({
|
|
18
|
+
total,
|
|
19
|
+
active,
|
|
20
|
+
duration,
|
|
21
|
+
onComplete,
|
|
22
|
+
onBarClick,
|
|
23
|
+
hideBorder,
|
|
24
|
+
isPaused,
|
|
25
|
+
}: StoryProgressProps) {
|
|
26
|
+
const [progress, setProgress] = useState(0);
|
|
27
|
+
const progressRef = useRef(0);
|
|
28
|
+
const startTimeRef = useRef<number>(0);
|
|
29
|
+
const pausedProgressRef = useRef<number>(0);
|
|
30
|
+
const animationFrameRef = useRef<number | null>(null);
|
|
31
|
+
const onCompleteRef = useRef(onComplete);
|
|
19
32
|
|
|
20
|
-
//
|
|
33
|
+
// Keep onComplete ref up to date
|
|
21
34
|
useEffect(() => {
|
|
22
|
-
|
|
35
|
+
onCompleteRef.current = onComplete;
|
|
36
|
+
}, [onComplete]);
|
|
37
|
+
|
|
38
|
+
// Reset progress when active slide changes
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
setProgress(0);
|
|
41
|
+
progressRef.current = 0;
|
|
42
|
+
pausedProgressRef.current = 0;
|
|
43
|
+
startTimeRef.current = performance.now();
|
|
23
44
|
}, [active]);
|
|
24
45
|
|
|
46
|
+
// Animation loop with pause support
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
if (isPaused) {
|
|
49
|
+
// Save current progress when pausing
|
|
50
|
+
pausedProgressRef.current = progressRef.current;
|
|
51
|
+
if (animationFrameRef.current) {
|
|
52
|
+
cancelAnimationFrame(animationFrameRef.current);
|
|
53
|
+
animationFrameRef.current = null;
|
|
54
|
+
}
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Resume from paused progress
|
|
59
|
+
startTimeRef.current = performance.now();
|
|
60
|
+
const startProgress = pausedProgressRef.current;
|
|
61
|
+
if (startProgress >= 1) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
if (startProgress >= 1) {
|
|
65
|
+
setProgress(1);
|
|
66
|
+
onCompleteRef.current();
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
const remainingDuration = duration * (1 - startProgress) * 1000;
|
|
70
|
+
|
|
71
|
+
const animate = (currentTime: number) => {
|
|
72
|
+
const elapsed = currentTime - startTimeRef.current;
|
|
73
|
+
const newProgress =
|
|
74
|
+
startProgress + (elapsed / remainingDuration) * (1 - startProgress);
|
|
75
|
+
|
|
76
|
+
if (newProgress >= 1) {
|
|
77
|
+
progressRef.current = 1;
|
|
78
|
+
setProgress(1);
|
|
79
|
+
onCompleteRef.current();
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
progressRef.current = newProgress;
|
|
84
|
+
setProgress(newProgress);
|
|
85
|
+
animationFrameRef.current = requestAnimationFrame(animate);
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
animationFrameRef.current = requestAnimationFrame(animate);
|
|
89
|
+
|
|
90
|
+
return () => {
|
|
91
|
+
if (animationFrameRef.current) {
|
|
92
|
+
cancelAnimationFrame(animationFrameRef.current);
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
}, [isPaused, duration, active]);
|
|
96
|
+
|
|
25
97
|
return (
|
|
26
|
-
<div
|
|
98
|
+
<div
|
|
99
|
+
className={`story-progress${
|
|
100
|
+
hideBorder ? " story-progress--no-border" : ""
|
|
101
|
+
}`}
|
|
102
|
+
>
|
|
27
103
|
{Array.from({ length: total }).map((_, index) => {
|
|
28
104
|
const isActive = index === active;
|
|
29
105
|
const isCompleted = index < active;
|
|
30
|
-
|
|
106
|
+
|
|
31
107
|
return (
|
|
32
|
-
<div
|
|
33
|
-
key={index}
|
|
108
|
+
<div
|
|
109
|
+
key={index}
|
|
34
110
|
className="story-progress__bar-container"
|
|
35
111
|
onClick={() => onBarClick(index)}
|
|
36
112
|
>
|
|
37
|
-
<div
|
|
113
|
+
<div
|
|
114
|
+
className={`story-progress__bar ${
|
|
115
|
+
isCompleted ? "completed" : ""
|
|
116
|
+
}`}
|
|
117
|
+
>
|
|
38
118
|
{isActive && (
|
|
39
|
-
<
|
|
40
|
-
key={key}
|
|
119
|
+
<div
|
|
41
120
|
className="story-progress__bar-fill"
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
duration: duration,
|
|
46
|
-
ease: 'linear'
|
|
121
|
+
style={{
|
|
122
|
+
transform: `scaleX(${progress})`,
|
|
123
|
+
transformOrigin: "left",
|
|
47
124
|
}}
|
|
48
|
-
onAnimationComplete={onComplete}
|
|
49
|
-
style={{ transformOrigin: 'left' }}
|
|
50
125
|
/>
|
|
51
126
|
)}
|
|
52
127
|
</div>
|
package/src/data/mock.ts
CHANGED
|
@@ -1,54 +1,62 @@
|
|
|
1
|
-
import { BUSINESS_CATEGORIES } from
|
|
2
|
-
import type { RecapData } from
|
|
1
|
+
import { BUSINESS_CATEGORIES } from "../types";
|
|
2
|
+
import type { RecapData } from "../types";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Mock data for the recap experience
|
|
6
6
|
* This will be replaced with real API data later
|
|
7
7
|
*/
|
|
8
8
|
export const mockRecapData: RecapData = {
|
|
9
|
-
businessName:
|
|
9
|
+
businessName: "RICHYO ENTERPRISES",
|
|
10
10
|
days: 259,
|
|
11
11
|
streak: 47,
|
|
12
12
|
revenue: 22594,
|
|
13
13
|
orders: 487,
|
|
14
14
|
firstTimeBuyers: 234,
|
|
15
15
|
repeatBuyers: 65,
|
|
16
|
-
topCustomerName:
|
|
17
|
-
currency:
|
|
16
|
+
topCustomerName: "Micheal Scoffy",
|
|
17
|
+
currency: "GBP",
|
|
18
18
|
year: 2025,
|
|
19
|
-
introHeadline:
|
|
20
|
-
introSubtitle:
|
|
19
|
+
introHeadline: "You Be New Face OOO....",
|
|
20
|
+
introSubtitle: "Come back for 6 days time, we dey for you 😉",
|
|
21
21
|
topProducts: [
|
|
22
22
|
{
|
|
23
|
-
name:
|
|
23
|
+
name: "Vanilla Yoghurt",
|
|
24
24
|
units: 45,
|
|
25
|
-
productImage:
|
|
25
|
+
productImage:
|
|
26
|
+
"https://images.unsplash.com/photo-1447078806655-40579c2520d6?auto=format&fit=crop&w=400&q=80",
|
|
26
27
|
},
|
|
27
28
|
{
|
|
28
|
-
name:
|
|
29
|
+
name: "Cocoa Milkshake",
|
|
29
30
|
units: 38,
|
|
30
|
-
productImage:
|
|
31
|
+
productImage:
|
|
32
|
+
"https://images.unsplash.com/photo-1504674900247-0877df9cc836?auto=format&fit=crop&w=400&q=80",
|
|
31
33
|
},
|
|
32
34
|
{
|
|
33
|
-
name:
|
|
35
|
+
name: "Spicy Crunch",
|
|
34
36
|
units: 33,
|
|
35
|
-
productImage:
|
|
37
|
+
productImage:
|
|
38
|
+
"https://images.unsplash.com/photo-1447078806655-40579c2520d6?auto=format&fit=crop&w=400&q=80",
|
|
36
39
|
},
|
|
37
40
|
{
|
|
38
|
-
name:
|
|
41
|
+
name: "Fresh Plantain Chips",
|
|
39
42
|
units: 29,
|
|
40
|
-
productImage:
|
|
43
|
+
productImage:
|
|
44
|
+
"https://images.unsplash.com/photo-1506084868230-bb9d95c24759?auto=format&fit=crop&w=400&q=80",
|
|
41
45
|
},
|
|
42
46
|
{
|
|
43
|
-
name:
|
|
47
|
+
name: "Mango Juice",
|
|
44
48
|
units: 27,
|
|
45
|
-
productImage:
|
|
46
|
-
|
|
49
|
+
productImage:
|
|
50
|
+
"https://images.unsplash.com/photo-1447078806655-40579c2520d6?auto=format&fit=crop&w=400&q=80",
|
|
51
|
+
},
|
|
47
52
|
],
|
|
48
|
-
businessCategory: BUSINESS_CATEGORIES.
|
|
49
|
-
busiestMonth:
|
|
50
|
-
videoUrl:
|
|
51
|
-
|
|
53
|
+
businessCategory: BUSINESS_CATEGORIES.THRIVING,
|
|
54
|
+
busiestMonth: "Oct",
|
|
55
|
+
videoUrl:
|
|
56
|
+
"https://katajereassets.blob.core.windows.net/sp-list-assets/mocksite_walkthrough_a75c98dd-47ef-4f2c-a97c-ab2b3c3c97a5_2315a6b2d671d142f34e08cad43929c5.mp4",
|
|
57
|
+
downloadUrl:
|
|
58
|
+
"https://api.huxxle.com/api/download?fileUrl=https://katajereassets.blob.core.windows.net/sp-list-assets/mocksite_walkthrough_a75c98dd-47ef-4f2c-a97c-ab2b3c3c97a5_2315a6b2d671d142f34e08cad43929c5.mp4",
|
|
59
|
+
isVideo: true
|
|
52
60
|
};
|
|
53
61
|
|
|
54
62
|
// Slide durations in seconds - each slide can have its own timing
|
|
@@ -62,5 +70,5 @@ export const slideDurations: Record<string, number> = {
|
|
|
62
70
|
products: 8,
|
|
63
71
|
months: 8,
|
|
64
72
|
year: 8,
|
|
65
|
-
final: 8
|
|
73
|
+
final: 8,
|
|
66
74
|
};
|
package/src/types.ts
CHANGED
|
@@ -22,6 +22,8 @@ export interface RecapData {
|
|
|
22
22
|
year?: number; // e.g., 2025
|
|
23
23
|
introHeadline?: string; // Custom intro headline from backend
|
|
24
24
|
introSubtitle?: string; // Custom intro subtitle from backend
|
|
25
|
+
slideDurations?: Record<string, number>; // Optional per-slide durations
|
|
26
|
+
isVideo?: boolean; // If true, hide sound icon (video has own audio)
|
|
25
27
|
}
|
|
26
28
|
|
|
27
29
|
export interface ProductSummary {
|