@katajere/recap 1.0.13 → 2.0.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.
- package/dist/App.css +32 -12
- package/dist/LoginScreen.css +22 -21
- package/dist/OtpScreen.css +20 -17
- package/dist/RecapStory.css +148 -0
- package/dist/RecapStory.d.ts +2 -2
- package/dist/RecapStory.d.ts.map +1 -1
- package/dist/RecapStory.js +169 -81
- package/dist/StoryProgress.css +3 -3
- package/dist/StoryProgress.d.ts +3 -2
- package/dist/StoryProgress.d.ts.map +1 -1
- package/dist/StoryProgress.js +66 -12
- package/dist/assets/huxxle-login-blue-logo.svg +14 -0
- package/dist/assets/noisy-background.png +0 -0
- package/dist/assets/noisy-background.svg +23 -0
- package/dist/assets/search-icon.svg +4 -0
- package/dist/assets/share-button.svg +5 -0
- package/dist/assets/web-icon.png +0 -0
- package/dist/assets/web-icon.svg +14 -0
- package/dist/components/Header.css +12 -1
- package/dist/components/Header.js +2 -2
- package/dist/data/mock.d.ts +1 -1
- package/dist/data/mock.d.ts.map +1 -1
- package/dist/data/mock.js +36 -23
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/slides/Slide10Final.css +73 -35
- package/dist/slides/Slide1Intro.css +204 -56
- package/dist/slides/Slide1Intro.d.ts +2 -1
- package/dist/slides/Slide1Intro.d.ts.map +1 -1
- package/dist/slides/Slide1Intro.js +41 -47
- package/dist/slides/Slide2Days.css +121 -34
- package/dist/slides/Slide2Days.d.ts +2 -1
- package/dist/slides/Slide2Days.d.ts.map +1 -1
- package/dist/slides/Slide2Days.js +45 -4
- package/dist/slides/Slide3Revenue.css +80 -38
- package/dist/slides/Slide3Revenue.d.ts.map +1 -1
- package/dist/slides/Slide3Revenue.js +31 -3
- package/dist/slides/Slide4Orders.css +93 -34
- package/dist/slides/Slide4Orders.d.ts +2 -1
- package/dist/slides/Slide4Orders.d.ts.map +1 -1
- package/dist/slides/Slide4Orders.js +45 -3
- package/dist/slides/Slide5Buyers.css +124 -67
- package/dist/slides/Slide5Buyers.d.ts +2 -1
- package/dist/slides/Slide5Buyers.d.ts.map +1 -1
- package/dist/slides/Slide5Buyers.js +43 -3
- package/dist/slides/Slide6Customer.css +294 -52
- package/dist/slides/Slide6Customer.d.ts +6 -3
- package/dist/slides/Slide6Customer.d.ts.map +1 -1
- package/dist/slides/Slide6Customer.js +25 -4
- package/dist/slides/Slide7Products.css +8 -7
- package/dist/slides/Slide7Products.js +3 -3
- package/dist/slides/Slide8Months.css +6 -6
- package/dist/slides/Slide9Year.css +4 -2
- package/dist/slides/Slide9Year.d.ts +2 -1
- package/dist/slides/Slide9Year.d.ts.map +1 -1
- package/dist/slides/Slide9Year.js +23 -2
- package/dist/types.d.ts +7 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/slideScreenshot.d.ts +27 -0
- package/dist/utils/slideScreenshot.d.ts.map +1 -0
- package/dist/utils/slideScreenshot.js +274 -0
- package/package.json +2 -1
- package/src/App.css +32 -12
- package/src/LoginScreen.css +22 -21
- package/src/LoginScreen.tsx +1 -1
- package/src/OtpScreen.css +20 -17
- package/src/OtpScreen.tsx +1 -1
- package/src/RecapStory.css +148 -0
- package/src/RecapStory.tsx +249 -118
- package/src/StoryProgress.css +3 -3
- package/src/StoryProgress.tsx +96 -21
- package/src/components/Header.css +12 -1
- package/src/components/Header.tsx +2 -2
- package/src/data/mock.ts +44 -24
- package/src/index.ts +0 -1
- package/src/slides/Slide10Final.css +73 -35
- package/src/slides/Slide1Intro.css +204 -56
- package/src/slides/Slide1Intro.tsx +89 -81
- package/src/slides/Slide2Days.css +121 -34
- package/src/slides/Slide2Days.tsx +67 -19
- package/src/slides/Slide3Revenue.css +80 -38
- package/src/slides/Slide3Revenue.tsx +43 -6
- package/src/slides/Slide4Orders.css +93 -34
- package/src/slides/Slide4Orders.tsx +71 -10
- package/src/slides/Slide5Buyers.css +124 -67
- package/src/slides/Slide5Buyers.tsx +97 -38
- package/src/slides/Slide6Customer.css +294 -52
- package/src/slides/Slide6Customer.tsx +68 -10
- package/src/slides/Slide7Products.css +8 -7
- package/src/slides/Slide7Products.tsx +3 -3
- package/src/slides/Slide8Months.css +6 -6
- package/src/slides/Slide9Year.css +4 -2
- package/src/slides/Slide9Year.tsx +35 -7
- package/src/types.ts +7 -0
- package/src/utils/slideScreenshot.ts +324 -0
- package/dist/FloatingFrames.css +0 -55
- package/dist/FloatingFrames.d.ts +0 -11
- package/dist/FloatingFrames.d.ts.map +0 -1
- package/dist/FloatingFrames.js +0 -12
- package/src/FloatingFrames.css +0 -55
- package/src/FloatingFrames.tsx +0 -27
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
|
|
15
15
|
.slide7-products__lead {
|
|
16
16
|
font-family: 'Lora', serif;
|
|
17
|
-
font-size:
|
|
17
|
+
font-size: clamp(14px, 4.1vw, 16px);
|
|
18
18
|
font-weight: 400;
|
|
19
19
|
text-align: center;
|
|
20
|
-
background:
|
|
20
|
+
background: var(--bg-gradient);
|
|
21
21
|
-webkit-background-clip: text;
|
|
22
22
|
background-clip: text;
|
|
23
23
|
-webkit-text-fill-color: transparent;
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
font-size: clamp(18px, 6.15vw, 24px);
|
|
50
50
|
font-weight: 700;
|
|
51
51
|
line-height: 1.3;
|
|
52
|
-
background:
|
|
52
|
+
background: var(--bg-gradient);
|
|
53
53
|
-webkit-background-clip: text;
|
|
54
54
|
-webkit-text-fill-color: transparent;
|
|
55
55
|
background-clip: text;
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
width: 22.31%;
|
|
73
73
|
height: 100%;
|
|
74
74
|
box-sizing: border-box;
|
|
75
|
-
border: 1px solid
|
|
75
|
+
border: 1px solid var(--border-line);
|
|
76
76
|
display: flex;
|
|
77
77
|
align-items: center;
|
|
78
78
|
justify-content: center;
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
.slide7-products__image {
|
|
82
82
|
width: 87%;
|
|
83
83
|
height: 88.5%;
|
|
84
|
-
border: 1px solid
|
|
84
|
+
border: 1px solid var(--border-line);
|
|
85
85
|
object-fit: cover;
|
|
86
86
|
display: block;
|
|
87
87
|
}
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
.slide7-products__title,
|
|
96
96
|
.slide7-products__subtitle {
|
|
97
97
|
font-family: 'Lora', serif;
|
|
98
|
-
background:
|
|
98
|
+
background: var(--bg-gradient);
|
|
99
99
|
-webkit-background-clip: text;
|
|
100
100
|
-webkit-text-fill-color: transparent;
|
|
101
101
|
background-clip: text;
|
|
@@ -117,6 +117,7 @@
|
|
|
117
117
|
.slide7-products__subtitle {
|
|
118
118
|
font-size: clamp(14px, 4.1vw, 16px);
|
|
119
119
|
font-weight: 400;
|
|
120
|
+
color: var(--text-primary);
|
|
120
121
|
/* line-height: 72px; */
|
|
121
122
|
}
|
|
122
123
|
|
|
@@ -138,7 +139,7 @@
|
|
|
138
139
|
box-sizing: border-box;
|
|
139
140
|
width: 46.15%;
|
|
140
141
|
aspect-ratio: 180 / 240;
|
|
141
|
-
border: 1px solid
|
|
142
|
+
border: 1px solid var(--rect-border);
|
|
142
143
|
flex: none;
|
|
143
144
|
flex-grow: 0;
|
|
144
145
|
}
|
|
@@ -12,8 +12,8 @@ const listVariant: Variants = {
|
|
|
12
12
|
animate: {
|
|
13
13
|
opacity: 1,
|
|
14
14
|
transition: {
|
|
15
|
-
staggerChildren: 0.
|
|
16
|
-
delayChildren: 0.
|
|
15
|
+
staggerChildren: 0.18, // 5 items * 0.18s stagger = 0.72s total stagger
|
|
16
|
+
delayChildren: 0.1,
|
|
17
17
|
when: 'beforeChildren'
|
|
18
18
|
}
|
|
19
19
|
}
|
|
@@ -24,7 +24,7 @@ const rowVariant: Variants = {
|
|
|
24
24
|
animate: {
|
|
25
25
|
opacity: 1,
|
|
26
26
|
y: 0,
|
|
27
|
-
transition: { duration:
|
|
27
|
+
transition: { duration: 0.8, ease: [0.33, 0.1, 0.33, 1] } // 0.1 + 0.72 + 0.8 = 1.62s total
|
|
28
28
|
}
|
|
29
29
|
};
|
|
30
30
|
|
|
@@ -26,11 +26,11 @@
|
|
|
26
26
|
font-size: clamp(14px, 4.1vw, 16px);
|
|
27
27
|
font-weight: 400;
|
|
28
28
|
text-align: center;
|
|
29
|
-
background: linear-gradient(90deg, #FFFFFF 0%, #FFCC80 100%);
|
|
29
|
+
/* background: linear-gradient(90deg, #FFFFFF 0%, #FFCC80 100%);
|
|
30
30
|
-webkit-background-clip: text;
|
|
31
31
|
-webkit-text-fill-color: transparent;
|
|
32
|
-
background-clip: text;
|
|
33
|
-
color:
|
|
32
|
+
background-clip: text; */
|
|
33
|
+
color: var(--primary-purple);
|
|
34
34
|
margin-bottom: 1.9%;
|
|
35
35
|
z-index: 2;
|
|
36
36
|
}
|
|
@@ -57,11 +57,11 @@
|
|
|
57
57
|
font-size: clamp(16px, 5.13vw, 20px);
|
|
58
58
|
line-height: 1.3;
|
|
59
59
|
text-align: center;
|
|
60
|
-
background:
|
|
60
|
+
background: var(--bg-gradient);
|
|
61
61
|
-webkit-background-clip: text;
|
|
62
62
|
-webkit-text-fill-color: transparent;
|
|
63
63
|
background-clip: text;
|
|
64
|
-
color:
|
|
64
|
+
/* color: var(--primary-blue); */
|
|
65
65
|
opacity: 0.6;
|
|
66
66
|
transition: opacity 0.1s ease, transform 0.1s ease;
|
|
67
67
|
}
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
position: absolute;
|
|
96
96
|
width: 46.15%;
|
|
97
97
|
aspect-ratio: 180 / 240;
|
|
98
|
-
border: 1px solid
|
|
98
|
+
border: 1px solid var(--rect-border);
|
|
99
99
|
box-sizing: border-box;
|
|
100
100
|
transform-origin: 0 0;
|
|
101
101
|
transform: rotate(28.86deg);
|
|
@@ -17,8 +17,9 @@
|
|
|
17
17
|
font-size: clamp(14px, 4.1vw, 16px);
|
|
18
18
|
font-weight: 400;
|
|
19
19
|
margin-bottom: 2.84%;
|
|
20
|
+
/* color: var(--primary-blue); */
|
|
20
21
|
/* width: 320px; */
|
|
21
|
-
background:
|
|
22
|
+
background: var(--bg-gradient);
|
|
22
23
|
-webkit-background-clip: text;
|
|
23
24
|
-webkit-text-fill-color: transparent;
|
|
24
25
|
background-clip: text;
|
|
@@ -32,7 +33,8 @@
|
|
|
32
33
|
margin-bottom: 1.9%;
|
|
33
34
|
width: 92.31%;
|
|
34
35
|
text-transform: capitalize;
|
|
35
|
-
|
|
36
|
+
/* color: var(--primary-blue); */
|
|
37
|
+
background: var(--bg-gradient);
|
|
36
38
|
-webkit-background-clip: text;
|
|
37
39
|
-webkit-text-fill-color: transparent;
|
|
38
40
|
background-clip: text;
|
|
@@ -7,13 +7,41 @@ import type { BusinessCategory } from '../types';
|
|
|
7
7
|
interface Slide9YearProps {
|
|
8
8
|
businessCategory: BusinessCategory;
|
|
9
9
|
year?: number;
|
|
10
|
+
frameImages?: string[];
|
|
10
11
|
}
|
|
11
12
|
|
|
12
|
-
function Slide9Year({ businessCategory, year }: Slide9YearProps) {
|
|
13
|
+
function Slide9Year({ businessCategory, year, frameImages }: Slide9YearProps) {
|
|
13
14
|
const copy = recapCopy[businessCategory] ?? recapCopy[BUSINESS_CATEGORIES.THRIVING];
|
|
14
15
|
const baseYear = year ?? 2025;
|
|
15
16
|
const nextYear = baseYear + 1;
|
|
16
17
|
|
|
18
|
+
const frameImagePool = React.useMemo(() => {
|
|
19
|
+
return frameImages && frameImages.length > 0 ? frameImages : [];
|
|
20
|
+
}, [frameImages]);
|
|
21
|
+
|
|
22
|
+
const rectSources = React.useMemo(() => {
|
|
23
|
+
if (!frameImagePool.length) {
|
|
24
|
+
return [];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return Array.from({ length: 6 }, () =>
|
|
28
|
+
frameImagePool[Math.floor(Math.random() * frameImagePool.length)]
|
|
29
|
+
);
|
|
30
|
+
}, [frameImagePool]);
|
|
31
|
+
|
|
32
|
+
const getRectStyle = (index: number) => {
|
|
33
|
+
const image = rectSources[index];
|
|
34
|
+
if (!image) {
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return {
|
|
39
|
+
backgroundImage: `url('${image}')`,
|
|
40
|
+
backgroundSize: 'cover',
|
|
41
|
+
backgroundPosition: 'center',
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
|
|
17
45
|
return (
|
|
18
46
|
<div className="slide9-year">
|
|
19
47
|
<div className="slide9-year__message">{copy.yearHeadline}</div>
|
|
@@ -21,15 +49,15 @@ function Slide9Year({ businessCategory, year }: Slide9YearProps) {
|
|
|
21
49
|
<div className="slide9-year__crown">👑</div>
|
|
22
50
|
|
|
23
51
|
<div className="slide9-year__rect-layer slide9-year__rect-layer--top">
|
|
24
|
-
<span className="slide9-year__rect slide9-year__rect--top-1 top-group" />
|
|
25
|
-
<span className="slide9-year__rect slide9-year__rect--top-2 top-group" />
|
|
26
|
-
<span className="slide9-year__rect slide9-year__rect--top-3 top-group" />
|
|
52
|
+
<span className="slide9-year__rect slide9-year__rect--top-1 top-group" style={getRectStyle(0)} />
|
|
53
|
+
<span className="slide9-year__rect slide9-year__rect--top-2 top-group" style={getRectStyle(1)} />
|
|
54
|
+
<span className="slide9-year__rect slide9-year__rect--top-3 top-group" style={getRectStyle(2)} />
|
|
27
55
|
</div>
|
|
28
56
|
|
|
29
57
|
<div className="slide9-year__rect-layer slide9-year__rect-layer--bottom">
|
|
30
|
-
<span className="slide9-year__rect slide9-year__rect--bottom-1 bottom-group" />
|
|
31
|
-
<span className="slide9-year__rect slide9-year__rect--bottom-2 bottom-group" />
|
|
32
|
-
<span className="slide9-year__rect slide9-year__rect--bottom-3 bottom-group" />
|
|
58
|
+
<span className="slide9-year__rect slide9-year__rect--bottom-1 bottom-group" style={getRectStyle(3)} />
|
|
59
|
+
<span className="slide9-year__rect slide9-year__rect--bottom-2 bottom-group" style={getRectStyle(4)} />
|
|
60
|
+
<span className="slide9-year__rect slide9-year__rect--bottom-3 bottom-group" style={getRectStyle(5)} />
|
|
33
61
|
</div>
|
|
34
62
|
</div>
|
|
35
63
|
);
|
package/src/types.ts
CHANGED
|
@@ -22,6 +22,13 @@ 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)
|
|
27
|
+
productImages?: string[]; // Optional image pool for background frames
|
|
28
|
+
websiteLink?: string;
|
|
29
|
+
websiteVisits?: number;
|
|
30
|
+
mostViewedProduct?: string;
|
|
31
|
+
mostViewedProductCount?: number;
|
|
25
32
|
}
|
|
26
33
|
|
|
27
34
|
export interface ProductSummary {
|
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
import html2canvas from 'html2canvas';
|
|
2
|
+
|
|
3
|
+
export interface ScreenshotOptions {
|
|
4
|
+
slideId: string;
|
|
5
|
+
businessName: string;
|
|
6
|
+
year: number;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
// Cache for pre-captured screenshots
|
|
10
|
+
const screenshotCache = new Map<string, File>();
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Detects if the device is mobile
|
|
14
|
+
*/
|
|
15
|
+
function isMobileDevice(): boolean {
|
|
16
|
+
return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ||
|
|
17
|
+
(navigator.maxTouchPoints > 0 && window.innerWidth < 768);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Pre-captures a screenshot of the slide and caches it.
|
|
22
|
+
* Call this when a slide becomes active so the image is ready for instant sharing.
|
|
23
|
+
*/
|
|
24
|
+
export async function preCaptureSlide(
|
|
25
|
+
containerRef: HTMLElement | null,
|
|
26
|
+
options: ScreenshotOptions
|
|
27
|
+
): Promise<void> {
|
|
28
|
+
if (!containerRef) return;
|
|
29
|
+
|
|
30
|
+
const { slideId, businessName, year } = options;
|
|
31
|
+
const cacheKey = `${businessName}-${year}-${slideId}`;
|
|
32
|
+
|
|
33
|
+
// Skip if already cached
|
|
34
|
+
if (screenshotCache.has(cacheKey)) {
|
|
35
|
+
console.log('[Screenshot] Using cached screenshot for:', cacheKey);
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const storyContainer = containerRef.closest('.recap-story') as HTMLElement;
|
|
40
|
+
if (!storyContainer) return;
|
|
41
|
+
|
|
42
|
+
try {
|
|
43
|
+
console.log('[Screenshot] Pre-capturing slide:', slideId);
|
|
44
|
+
|
|
45
|
+
const canvas = await html2canvas(storyContainer, {
|
|
46
|
+
scale: 3, // Higher scale for better image quality
|
|
47
|
+
useCORS: true,
|
|
48
|
+
allowTaint: true,
|
|
49
|
+
backgroundColor: '#FCFCFC',
|
|
50
|
+
logging: false,
|
|
51
|
+
windowWidth: storyContainer.scrollWidth,
|
|
52
|
+
windowHeight: storyContainer.scrollHeight,
|
|
53
|
+
ignoreElements: (element) => {
|
|
54
|
+
// Ignore buttons and progress bar - they're excluded from screenshot
|
|
55
|
+
return element.classList.contains('recap-story__sound-btn') ||
|
|
56
|
+
element.classList.contains('recap-story__share-btn') ||
|
|
57
|
+
element.classList.contains('recap-story__progress-wrap');
|
|
58
|
+
},
|
|
59
|
+
// Apply screenshot-mode to cloned DOM only (not visible to user)
|
|
60
|
+
onclone: (clonedDoc) => {
|
|
61
|
+
const clonedContainer = clonedDoc.querySelector('.recap-story');
|
|
62
|
+
if (clonedContainer) {
|
|
63
|
+
clonedContainer.classList.add('screenshot-mode');
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
const blob = await new Promise<Blob>((resolve, reject) => {
|
|
69
|
+
canvas.toBlob(
|
|
70
|
+
(b) => {
|
|
71
|
+
if (b) resolve(b);
|
|
72
|
+
else reject(new Error('Failed to create blob'));
|
|
73
|
+
},
|
|
74
|
+
'image/png',
|
|
75
|
+
1.0
|
|
76
|
+
);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
const mimeType = 'image/png';
|
|
80
|
+
const fileName = `${businessName.replace(/\s+/g, '-')}-recap-${year}-${slideId}.png`;
|
|
81
|
+
const file = new File([blob], fileName, {
|
|
82
|
+
type: mimeType,
|
|
83
|
+
lastModified: Date.now()
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
screenshotCache.set(cacheKey, file);
|
|
87
|
+
console.log('[Screenshot] Pre-capture complete:', cacheKey, file.size, 'bytes');
|
|
88
|
+
|
|
89
|
+
} catch (error) {
|
|
90
|
+
console.error('[Screenshot] Pre-capture failed:', error);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Clears the screenshot cache (call when leaving recap)
|
|
96
|
+
*/
|
|
97
|
+
export function clearScreenshotCache(): void {
|
|
98
|
+
screenshotCache.clear();
|
|
99
|
+
console.log('[Screenshot] Cache cleared');
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Check if a screenshot is cached for a specific slide
|
|
104
|
+
*/
|
|
105
|
+
export function isScreenshotCached(options: ScreenshotOptions): boolean {
|
|
106
|
+
const { slideId, businessName, year } = options;
|
|
107
|
+
const cacheKey = `${businessName}-${year}-${slideId}`;
|
|
108
|
+
return screenshotCache.has(cacheKey);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Shares or downloads a slide screenshot.
|
|
113
|
+
* Uses cached screenshot if available (instant share), otherwise captures fresh.
|
|
114
|
+
*
|
|
115
|
+
* - Desktop: Downloads the image directly
|
|
116
|
+
* - Mobile: Uses Web Share API with file (same as Slide10Final)
|
|
117
|
+
*/
|
|
118
|
+
export async function captureAndShareSlide(
|
|
119
|
+
containerRef: HTMLElement | null,
|
|
120
|
+
options: ScreenshotOptions
|
|
121
|
+
): Promise<void> {
|
|
122
|
+
if (!containerRef) {
|
|
123
|
+
console.error('[Screenshot] No container element provided');
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const { slideId, businessName, year } = options;
|
|
128
|
+
const cacheKey = `${businessName}-${year}-${slideId}`;
|
|
129
|
+
const isMobile = isMobileDevice();
|
|
130
|
+
|
|
131
|
+
console.log('[Screenshot] Device type:', isMobile ? 'mobile' : 'desktop');
|
|
132
|
+
console.log('[Screenshot] Cache key:', cacheKey);
|
|
133
|
+
|
|
134
|
+
// Check for cached screenshot (enables instant sharing on mobile)
|
|
135
|
+
const cachedFile = screenshotCache.get(cacheKey);
|
|
136
|
+
console.log('[Screenshot] Cache available:', !!cachedFile);
|
|
137
|
+
|
|
138
|
+
// MOBILE: Must use cached file for instant share (user gesture chain)
|
|
139
|
+
if (isMobile) {
|
|
140
|
+
if (cachedFile) {
|
|
141
|
+
console.log('[Screenshot] Using cached file for instant share');
|
|
142
|
+
// CRITICAL: Call navigator.share() directly without any await before it
|
|
143
|
+
// to maintain the user gesture chain on mobile browsers (especially Edge)
|
|
144
|
+
const canShareFiles = navigator.canShare && navigator.canShare({ files: [cachedFile] });
|
|
145
|
+
console.log('[Screenshot] Can share files:', canShareFiles);
|
|
146
|
+
|
|
147
|
+
if (canShareFiles) {
|
|
148
|
+
// Call share synchronously - no try/catch wrapper that could break gesture chain
|
|
149
|
+
navigator.share({
|
|
150
|
+
files: [cachedFile],
|
|
151
|
+
title: 'My Huxxle Recap',
|
|
152
|
+
text: `Check out ${businessName}'s Wrapped ${year} highlights! 🎉`
|
|
153
|
+
}).then(() => {
|
|
154
|
+
console.log('[Screenshot] Share successful!');
|
|
155
|
+
}).catch((err) => {
|
|
156
|
+
console.error('[Screenshot] Share failed:', err);
|
|
157
|
+
// If user cancelled (AbortError), don't download
|
|
158
|
+
if (err.name !== 'AbortError') {
|
|
159
|
+
// Fallback to download on share failure
|
|
160
|
+
const blob = new Blob([cachedFile], { type: cachedFile.type });
|
|
161
|
+
downloadImage(blob, cachedFile.name);
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// Mobile browser doesn't support file sharing - download instead
|
|
168
|
+
console.log('[Screenshot] File sharing not supported, downloading...');
|
|
169
|
+
const blob = new Blob([cachedFile], { type: cachedFile.type });
|
|
170
|
+
downloadImage(blob, cachedFile.name);
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// No cache on mobile - this shouldn't happen if timing is correct
|
|
175
|
+
// Fall back to capturing and downloading (share won't work due to gesture chain)
|
|
176
|
+
console.warn('[Screenshot] No cache on mobile - falling back to capture + download');
|
|
177
|
+
// Continue to fresh capture below, but it will download instead of share
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// DESKTOP or MOBILE-FALLBACK: Capture fresh screenshot
|
|
181
|
+
const storyContainer = containerRef.closest('.recap-story') as HTMLElement;
|
|
182
|
+
if (!storyContainer) {
|
|
183
|
+
console.error('[Screenshot] Could not find .recap-story container');
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
try {
|
|
188
|
+
console.log('[Screenshot] Starting capture...');
|
|
189
|
+
|
|
190
|
+
const canvas = await html2canvas(storyContainer, {
|
|
191
|
+
scale: 3, // Higher scale for better image quality
|
|
192
|
+
useCORS: true,
|
|
193
|
+
allowTaint: true,
|
|
194
|
+
backgroundColor: '#FCFCFC',
|
|
195
|
+
logging: false,
|
|
196
|
+
windowWidth: storyContainer.scrollWidth,
|
|
197
|
+
windowHeight: storyContainer.scrollHeight,
|
|
198
|
+
ignoreElements: (element) => {
|
|
199
|
+
// Ignore buttons and progress bar - they're excluded from screenshot
|
|
200
|
+
return element.classList.contains('recap-story__sound-btn') ||
|
|
201
|
+
element.classList.contains('recap-story__share-btn') ||
|
|
202
|
+
element.classList.contains('recap-story__progress-wrap');
|
|
203
|
+
},
|
|
204
|
+
// Apply screenshot-mode to cloned DOM only (not visible to user)
|
|
205
|
+
onclone: (clonedDoc) => {
|
|
206
|
+
const clonedContainer = clonedDoc.querySelector('.recap-story');
|
|
207
|
+
if (clonedContainer) {
|
|
208
|
+
clonedContainer.classList.add('screenshot-mode');
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
console.log('[Screenshot] Canvas created:', canvas.width, 'x', canvas.height);
|
|
214
|
+
|
|
215
|
+
const blob = await new Promise<Blob>((resolve, reject) => {
|
|
216
|
+
canvas.toBlob(
|
|
217
|
+
(b) => {
|
|
218
|
+
if (b) resolve(b);
|
|
219
|
+
else reject(new Error('Failed to create blob'));
|
|
220
|
+
},
|
|
221
|
+
'image/png',
|
|
222
|
+
1.0
|
|
223
|
+
);
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
console.log('[Screenshot] Blob created:', blob.size, 'bytes');
|
|
227
|
+
|
|
228
|
+
const mimeType = 'image/png';
|
|
229
|
+
const fileName = `${businessName.replace(/\s+/g, '-')}-recap-${year}-${slideId}.png`;
|
|
230
|
+
|
|
231
|
+
// DESKTOP: Always download
|
|
232
|
+
if (!isMobile) {
|
|
233
|
+
console.log('[Screenshot] Desktop - downloading...');
|
|
234
|
+
downloadImage(blob, fileName);
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// MOBILE (no cache): Try to share, likely will fail due to user gesture timing
|
|
239
|
+
const file = new File([blob], fileName, {
|
|
240
|
+
type: mimeType,
|
|
241
|
+
lastModified: Date.now()
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
// Cache for next time
|
|
245
|
+
screenshotCache.set(cacheKey, file);
|
|
246
|
+
|
|
247
|
+
await shareFile(file, businessName, year);
|
|
248
|
+
|
|
249
|
+
} catch (error) {
|
|
250
|
+
console.error('[Screenshot] Capture failed:', error);
|
|
251
|
+
} finally {
|
|
252
|
+
storyContainer.classList.remove('screenshot-mode');
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Shares a file using Web Share API with fallbacks
|
|
258
|
+
*/
|
|
259
|
+
async function shareFile(file: File, businessName: string, year: number): Promise<void> {
|
|
260
|
+
console.log('[Screenshot] File to share:', file.name, file.type, file.size, 'bytes');
|
|
261
|
+
|
|
262
|
+
// Validate file size (WhatsApp limit: 5MB for images)
|
|
263
|
+
const maxSize = 5 * 1024 * 1024;
|
|
264
|
+
if (file.size > maxSize) {
|
|
265
|
+
alert('File is too large. Maximum size is 5MB');
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
// Check if Web Share API with files is supported
|
|
270
|
+
const canShareFiles = navigator.canShare && navigator.canShare({ files: [file] });
|
|
271
|
+
console.log('[Screenshot] Can share files:', canShareFiles);
|
|
272
|
+
|
|
273
|
+
// Try sharing with file
|
|
274
|
+
if (canShareFiles) {
|
|
275
|
+
console.log('[Screenshot] Sharing file...');
|
|
276
|
+
try {
|
|
277
|
+
await navigator.share({
|
|
278
|
+
files: [file],
|
|
279
|
+
title: 'My Huxxle Recap',
|
|
280
|
+
text: `Check out ${businessName}'s Wrapped ${year} highlights! 🎉`
|
|
281
|
+
});
|
|
282
|
+
console.log('[Screenshot] Share successful!');
|
|
283
|
+
return;
|
|
284
|
+
} catch (shareError) {
|
|
285
|
+
console.error('[Screenshot] File share failed:', shareError);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
// Fallback: share URL only
|
|
290
|
+
if (navigator.share) {
|
|
291
|
+
console.log('[Screenshot] Sharing URL fallback...');
|
|
292
|
+
try {
|
|
293
|
+
await navigator.share({
|
|
294
|
+
title: 'My Huxxle Recap',
|
|
295
|
+
text: `Check out ${businessName}'s Wrapped ${year} highlights! 🎉`,
|
|
296
|
+
url: window.location.href
|
|
297
|
+
});
|
|
298
|
+
return;
|
|
299
|
+
} catch (urlShareError) {
|
|
300
|
+
console.error('[Screenshot] URL share failed:', urlShareError);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
// Final fallback: download
|
|
305
|
+
console.log('[Screenshot] Download fallback...');
|
|
306
|
+
const blob = new Blob([await file.arrayBuffer()], { type: file.type });
|
|
307
|
+
downloadImage(blob, file.name);
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Downloads an image blob
|
|
312
|
+
*/
|
|
313
|
+
function downloadImage(blob: Blob, fileName: string): void {
|
|
314
|
+
console.log('[Screenshot] Downloading:', fileName);
|
|
315
|
+
const url = URL.createObjectURL(blob);
|
|
316
|
+
const a = document.createElement('a');
|
|
317
|
+
a.href = url;
|
|
318
|
+
a.download = fileName;
|
|
319
|
+
document.body.appendChild(a);
|
|
320
|
+
a.click();
|
|
321
|
+
document.body.removeChild(a);
|
|
322
|
+
URL.revokeObjectURL(url);
|
|
323
|
+
console.log('[Screenshot] Download complete');
|
|
324
|
+
}
|
package/dist/FloatingFrames.css
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
.floating-frames {
|
|
2
|
-
position: absolute;
|
|
3
|
-
display: flex;
|
|
4
|
-
gap: clamp(6px, 2vw, 8px);
|
|
5
|
-
left: 50%;
|
|
6
|
-
transform: translateX(-50%);
|
|
7
|
-
z-index: 1;
|
|
8
|
-
pointer-events: none;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
.floating-frames--top {
|
|
12
|
-
top: clamp(80px, 16.5dvh, 140px);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
.floating-frames--bottom {
|
|
16
|
-
bottom: clamp(100px, 21.3dvh, 180px);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
.floating-frame {
|
|
20
|
-
width: clamp(70px, 28.2vw, 110px);
|
|
21
|
-
height: clamp(280px, 52.1dvh, 440px);
|
|
22
|
-
border: 1px solid rgba(255, 255, 255, 0.2);
|
|
23
|
-
border-radius: 4px;
|
|
24
|
-
background: transparent;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
@media (max-width: 420px) {
|
|
28
|
-
.floating-frame {
|
|
29
|
-
width: clamp(70px, 23vw, 90px);
|
|
30
|
-
height: clamp(280px, 45dvh, 380px);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
.floating-frames--top {
|
|
34
|
-
top: clamp(80px, 14.2dvh, 120px);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
.floating-frames--bottom {
|
|
38
|
-
bottom: clamp(100px, 18.9dvh, 160px);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
@media (max-height: 720px), (orientation: landscape) {
|
|
43
|
-
.floating-frames--top {
|
|
44
|
-
top: clamp(60px, 10dvh, 100px);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
.floating-frames--bottom {
|
|
48
|
-
bottom: clamp(80px, 12dvh, 120px);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
.floating-frame {
|
|
52
|
-
width: clamp(60px, 20vw, 90px);
|
|
53
|
-
height: clamp(200px, 35dvh, 320px);
|
|
54
|
-
}
|
|
55
|
-
}
|
package/dist/FloatingFrames.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import './FloatingFrames.css';
|
|
2
|
-
interface FloatingFramesProps {
|
|
3
|
-
variant?: 'top' | 'bottom';
|
|
4
|
-
}
|
|
5
|
-
/**
|
|
6
|
-
* FloatingFrames - Decorative animated rectangles
|
|
7
|
-
* Displays 3 vertical rectangles with gentle horizontal motion
|
|
8
|
-
*/
|
|
9
|
-
declare function FloatingFrames({ variant }: FloatingFramesProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
-
export default FloatingFrames;
|
|
11
|
-
//# sourceMappingURL=FloatingFrames.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FloatingFrames.d.ts","sourceRoot":"","sources":["../src/FloatingFrames.tsx"],"names":[],"mappings":"AAGA,OAAO,sBAAsB,CAAC;AAE9B,UAAU,mBAAmB;IAC3B,OAAO,CAAC,EAAE,KAAK,GAAG,QAAQ,CAAC;CAC5B;AAED;;;GAGG;AACH,iBAAS,cAAc,CAAC,EAAE,OAAe,EAAE,EAAE,mBAAmB,2CAW/D;AAED,eAAe,cAAc,CAAC"}
|
package/dist/FloatingFrames.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { motion } from 'framer-motion';
|
|
3
|
-
import { floatingAnimation } from './utils';
|
|
4
|
-
import './FloatingFrames.css';
|
|
5
|
-
/**
|
|
6
|
-
* FloatingFrames - Decorative animated rectangles
|
|
7
|
-
* Displays 3 vertical rectangles with gentle horizontal motion
|
|
8
|
-
*/
|
|
9
|
-
function FloatingFrames({ variant = 'top' }) {
|
|
10
|
-
return (_jsxs(motion.div, { className: `floating-frames floating-frames--${variant}`, animate: floatingAnimation, children: [_jsx("div", { className: "floating-frame" }), _jsx("div", { className: "floating-frame" }), _jsx("div", { className: "floating-frame" })] }));
|
|
11
|
-
}
|
|
12
|
-
export default FloatingFrames;
|
package/src/FloatingFrames.css
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
.floating-frames {
|
|
2
|
-
position: absolute;
|
|
3
|
-
display: flex;
|
|
4
|
-
gap: clamp(6px, 2vw, 8px);
|
|
5
|
-
left: 50%;
|
|
6
|
-
transform: translateX(-50%);
|
|
7
|
-
z-index: 1;
|
|
8
|
-
pointer-events: none;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
.floating-frames--top {
|
|
12
|
-
top: clamp(80px, 16.5dvh, 140px);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
.floating-frames--bottom {
|
|
16
|
-
bottom: clamp(100px, 21.3dvh, 180px);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
.floating-frame {
|
|
20
|
-
width: clamp(70px, 28.2vw, 110px);
|
|
21
|
-
height: clamp(280px, 52.1dvh, 440px);
|
|
22
|
-
border: 1px solid rgba(255, 255, 255, 0.2);
|
|
23
|
-
border-radius: 4px;
|
|
24
|
-
background: transparent;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
@media (max-width: 420px) {
|
|
28
|
-
.floating-frame {
|
|
29
|
-
width: clamp(70px, 23vw, 90px);
|
|
30
|
-
height: clamp(280px, 45dvh, 380px);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
.floating-frames--top {
|
|
34
|
-
top: clamp(80px, 14.2dvh, 120px);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
.floating-frames--bottom {
|
|
38
|
-
bottom: clamp(100px, 18.9dvh, 160px);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
@media (max-height: 720px), (orientation: landscape) {
|
|
43
|
-
.floating-frames--top {
|
|
44
|
-
top: clamp(60px, 10dvh, 100px);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
.floating-frames--bottom {
|
|
48
|
-
bottom: clamp(80px, 12dvh, 120px);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
.floating-frame {
|
|
52
|
-
width: clamp(60px, 20vw, 90px);
|
|
53
|
-
height: clamp(200px, 35dvh, 320px);
|
|
54
|
-
}
|
|
55
|
-
}
|