react-zoom-pan-pinch 4.0.0 → 4.0.1
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/package.json +3 -2
- package/src/stories/assets/big-image.jpeg +0 -0
- package/src/stories/assets/map.jpg +0 -0
- package/src/stories/assets/medium-image.jpg +0 -0
- package/src/stories/assets/pin.svg +0 -1
- package/src/stories/assets/small-image.jpg +0 -0
- package/src/stories/assets/svg-example.svg +0 -14
- package/src/stories/docs/DocTable.tsx +0 -59
- package/src/stories/docs/HandlerCards.tsx +0 -102
- package/src/stories/docs/Introduction.stories.mdx +0 -135
- package/src/stories/docs/PropTable.tsx +0 -116
- package/src/stories/docs/docs.module.css +0 -370
- package/src/stories/docs/handlers.stories.mdx +0 -7
- package/src/stories/docs/handlers.tsx +0 -111
- package/src/stories/docs/props.stories.mdx +0 -11
- package/src/stories/docs/props.tsx +0 -571
- package/src/stories/examples/axis-lock/axis-lock.stories.mdx +0 -35
- package/src/stories/examples/axis-lock/example.tsx +0 -114
- package/src/stories/examples/bounds/bounds.data.tsx +0 -191
- package/src/stories/examples/bounds/bounds.stories.mdx +0 -99
- package/src/stories/examples/center-zoomed-out/center-zoomed-out.stories.mdx +0 -206
- package/src/stories/examples/cinema/cinema-data.tsx +0 -578
- package/src/stories/examples/cinema/cinema.stories.mdx +0 -30
- package/src/stories/examples/cinema/example.tsx +0 -378
- package/src/stories/examples/cinema/image.png +0 -0
- package/src/stories/examples/content/content.stories.mdx +0 -172
- package/src/stories/examples/content/mixed-content.data.tsx +0 -624
- package/src/stories/examples/content-rerendering/content-updating.stories.mdx +0 -34
- package/src/stories/examples/content-rerendering/example.tsx +0 -631
- package/src/stories/examples/controls/controls.stories.mdx +0 -120
- package/src/stories/examples/image/example.tsx +0 -149
- package/src/stories/examples/image/image.stories.mdx +0 -46
- package/src/stories/examples/image-annotations/example.tsx +0 -1442
- package/src/stories/examples/image-annotations/image-annotations.stories.mdx +0 -39
- package/src/stories/examples/image-responsive/example.tsx +0 -152
- package/src/stories/examples/image-responsive/image-responsive.stories.mdx +0 -51
- package/src/stories/examples/image-zoomed-out/image-zoomed-out.stories.mdx +0 -107
- package/src/stories/examples/initial-transform/example.tsx +0 -233
- package/src/stories/examples/initial-transform/initial-transform.stories.mdx +0 -37
- package/src/stories/examples/keep-scale/example.tsx +0 -882
- package/src/stories/examples/keep-scale/keep-scale.stories.mdx +0 -30
- package/src/stories/examples/keep-scale/map.stories.mdx +0 -28
- package/src/stories/examples/medical-viewer/chest-xray.tsx +0 -246
- package/src/stories/examples/medical-viewer/example.tsx +0 -690
- package/src/stories/examples/medical-viewer/medical-viewer.stories.mdx +0 -49
- package/src/stories/examples/mini-map/example.tsx +0 -122
- package/src/stories/examples/mini-map/mini-map.stories.mdx +0 -26
- package/src/stories/examples/miro/example.tsx +0 -1573
- package/src/stories/examples/miro/miro.stories.mdx +0 -31
- package/src/stories/examples/padding/example.tsx +0 -147
- package/src/stories/examples/padding/padding.stories.mdx +0 -35
- package/src/stories/examples/product-card/example.tsx +0 -594
- package/src/stories/examples/product-card/product-card.stories.mdx +0 -29
- package/src/stories/examples/stadium/example.tsx +0 -1040
- package/src/stories/examples/stadium/stadium-data.ts +0 -224
- package/src/stories/examples/stadium/stadium.stories.mdx +0 -32
- package/src/stories/examples/stress/example.tsx +0 -59
- package/src/stories/examples/stress/stress-test.stories.mdx +0 -28
- package/src/stories/examples/svg-zoom-to-element/creativity.svg +0 -143
- package/src/stories/examples/svg-zoom-to-element/example.tsx +0 -95
- package/src/stories/examples/svg-zoom-to-element/svg-zoom-to-element.stories.mdx +0 -28
- package/src/stories/examples/text-selection/example.tsx +0 -221
- package/src/stories/examples/text-selection/text-selection.stories.mdx +0 -31
- package/src/stories/examples/velocity/example.tsx +0 -908
- package/src/stories/examples/velocity/velocity.stories.mdx +0 -35
- package/src/stories/examples/virtualize/example.tsx +0 -239
- package/src/stories/examples/virtualize/virtualize.stories.mdx +0 -84
- package/src/stories/examples/zoom-to-element/example.tsx +0 -219
- package/src/stories/examples/zoom-to-element/zoom-to-element.stories.mdx +0 -31
- package/src/stories/hooks/use-controls.stories.mdx +0 -86
- package/src/stories/hooks/use-transform-component.stories.mdx +0 -108
- package/src/stories/hooks/use-transform-context.stories.mdx +0 -92
- package/src/stories/hooks/use-transform-effect.stories.mdx +0 -114
- package/src/stories/hooks/use-transform-init.stories.mdx +0 -105
- package/src/stories/types/args.types.ts +0 -192
- package/src/stories/utils/args.utils.ts +0 -35
- package/src/stories/utils/bounds-overlay.tsx +0 -168
- package/src/stories/utils/code.utils.tsx +0 -22
- package/src/stories/utils/controls.utils.tsx +0 -347
- package/src/stories/utils/index.ts +0 -5
- package/src/stories/utils/styles.module.css +0 -223
- package/src/stories/utils/viewer.styles.ts +0 -34
|
@@ -1,594 +0,0 @@
|
|
|
1
|
-
import React, { useState } from "react";
|
|
2
|
-
|
|
3
|
-
import { TransformWrapper, TransformComponent } from "../../../components";
|
|
4
|
-
import { normalizeArgs } from "../../utils";
|
|
5
|
-
|
|
6
|
-
const productImg =
|
|
7
|
-
"https://images.pexels.com/photos/29306504/pexels-photo-29306504.jpeg";
|
|
8
|
-
|
|
9
|
-
const font = 'Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif';
|
|
10
|
-
|
|
11
|
-
/* ── Data ──────────────────────────────────────────────────── */
|
|
12
|
-
|
|
13
|
-
const SAUCES = [
|
|
14
|
-
{ name: "Garlic", value: "#fefce8" },
|
|
15
|
-
{ name: "Spicy", value: "#dc2626" },
|
|
16
|
-
{ name: "Yogurt", value: "#e2e8f0" },
|
|
17
|
-
{ name: "BBQ", value: "#78350f" },
|
|
18
|
-
];
|
|
19
|
-
|
|
20
|
-
const PORTIONS = ["S", "M", "L", "XL"] as const;
|
|
21
|
-
|
|
22
|
-
/* ── Icons ─────────────────────────────────────────────────── */
|
|
23
|
-
|
|
24
|
-
const ZoomInIcon = () => (
|
|
25
|
-
<svg width="18" height="18" viewBox="0 0 18 18" fill="none">
|
|
26
|
-
<circle cx="8" cy="8" r="5.5" stroke="currentColor" strokeWidth="1.5" />
|
|
27
|
-
<path
|
|
28
|
-
d="M12 12L16 16"
|
|
29
|
-
stroke="currentColor"
|
|
30
|
-
strokeWidth="1.5"
|
|
31
|
-
strokeLinecap="round"
|
|
32
|
-
/>
|
|
33
|
-
<path
|
|
34
|
-
d="M8 6V10M6 8H10"
|
|
35
|
-
stroke="currentColor"
|
|
36
|
-
strokeWidth="1.5"
|
|
37
|
-
strokeLinecap="round"
|
|
38
|
-
/>
|
|
39
|
-
</svg>
|
|
40
|
-
);
|
|
41
|
-
|
|
42
|
-
const ZoomOutIcon = () => (
|
|
43
|
-
<svg width="18" height="18" viewBox="0 0 18 18" fill="none">
|
|
44
|
-
<circle cx="8" cy="8" r="5.5" stroke="currentColor" strokeWidth="1.5" />
|
|
45
|
-
<path
|
|
46
|
-
d="M12 12L16 16"
|
|
47
|
-
stroke="currentColor"
|
|
48
|
-
strokeWidth="1.5"
|
|
49
|
-
strokeLinecap="round"
|
|
50
|
-
/>
|
|
51
|
-
<path
|
|
52
|
-
d="M6 8H10"
|
|
53
|
-
stroke="currentColor"
|
|
54
|
-
strokeWidth="1.5"
|
|
55
|
-
strokeLinecap="round"
|
|
56
|
-
/>
|
|
57
|
-
</svg>
|
|
58
|
-
);
|
|
59
|
-
|
|
60
|
-
const ResetIcon = () => (
|
|
61
|
-
<svg width="18" height="18" viewBox="0 0 18 18" fill="none">
|
|
62
|
-
<path
|
|
63
|
-
d="M3 3V7H7"
|
|
64
|
-
stroke="currentColor"
|
|
65
|
-
strokeWidth="1.5"
|
|
66
|
-
strokeLinecap="round"
|
|
67
|
-
strokeLinejoin="round"
|
|
68
|
-
/>
|
|
69
|
-
<path
|
|
70
|
-
d="M3.5 11A6 6 0 1 0 5 5L3 7"
|
|
71
|
-
stroke="currentColor"
|
|
72
|
-
strokeWidth="1.5"
|
|
73
|
-
strokeLinecap="round"
|
|
74
|
-
strokeLinejoin="round"
|
|
75
|
-
/>
|
|
76
|
-
</svg>
|
|
77
|
-
);
|
|
78
|
-
|
|
79
|
-
const HeartIcon = ({ filled }: { filled: boolean }) => (
|
|
80
|
-
<svg
|
|
81
|
-
width="18"
|
|
82
|
-
height="18"
|
|
83
|
-
viewBox="0 0 18 18"
|
|
84
|
-
fill={filled ? "currentColor" : "none"}
|
|
85
|
-
>
|
|
86
|
-
<path
|
|
87
|
-
d="M9 15.5S2 11 2 6.5C2 4 4 2.5 6 2.5C7.5 2.5 8.5 3.5 9 4.5C9.5 3.5 10.5 2.5 12 2.5C14 2.5 16 4 16 6.5C16 11 9 15.5 9 15.5Z"
|
|
88
|
-
stroke="currentColor"
|
|
89
|
-
strokeWidth="1.5"
|
|
90
|
-
strokeLinejoin="round"
|
|
91
|
-
/>
|
|
92
|
-
</svg>
|
|
93
|
-
);
|
|
94
|
-
|
|
95
|
-
const StarIcon = ({ full }: { full: boolean }) => (
|
|
96
|
-
<svg width="14" height="14" viewBox="0 0 14 14">
|
|
97
|
-
<path
|
|
98
|
-
d="M7 1L8.8 5.1L13.2 5.6L9.9 8.5L10.8 12.9L7 10.7L3.2 12.9L4.1 8.5L0.8 5.6L5.2 5.1L7 1Z"
|
|
99
|
-
fill={full ? "#f59e0b" : "rgba(255,255,255,0.1)"}
|
|
100
|
-
stroke={full ? "#f59e0b" : "rgba(255,255,255,0.15)"}
|
|
101
|
-
strokeWidth="0.8"
|
|
102
|
-
/>
|
|
103
|
-
</svg>
|
|
104
|
-
);
|
|
105
|
-
|
|
106
|
-
/* ── Product image viewer ──────────────────────────────────── */
|
|
107
|
-
|
|
108
|
-
const zoomBtnStyle: React.CSSProperties = {
|
|
109
|
-
width: 36,
|
|
110
|
-
height: 36,
|
|
111
|
-
borderRadius: 9,
|
|
112
|
-
border: "none",
|
|
113
|
-
background: "transparent",
|
|
114
|
-
color: "rgba(255,255,255,0.75)",
|
|
115
|
-
cursor: "pointer",
|
|
116
|
-
display: "flex",
|
|
117
|
-
alignItems: "center",
|
|
118
|
-
justifyContent: "center",
|
|
119
|
-
padding: 0,
|
|
120
|
-
transition: "background 0.15s",
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
function ImageViewer({ args }: { args: Record<string, unknown> }) {
|
|
124
|
-
const normalized = normalizeArgs(args);
|
|
125
|
-
|
|
126
|
-
return (
|
|
127
|
-
<TransformWrapper
|
|
128
|
-
{...normalized}
|
|
129
|
-
initialScale={1}
|
|
130
|
-
minScale={0.5}
|
|
131
|
-
maxScale={6}
|
|
132
|
-
centerOnInit
|
|
133
|
-
centerZoomedOut
|
|
134
|
-
doubleClick={{ step: 0.5 }}
|
|
135
|
-
wheel={{ step: 0.08 }}
|
|
136
|
-
>
|
|
137
|
-
{({ zoomIn, zoomOut, resetTransform, instance }) => {
|
|
138
|
-
const { scale } = instance.state;
|
|
139
|
-
const isZoomed = scale > 1.05;
|
|
140
|
-
|
|
141
|
-
return (
|
|
142
|
-
<div style={{ position: "relative" }}>
|
|
143
|
-
<TransformComponent
|
|
144
|
-
wrapperStyle={{
|
|
145
|
-
width: "100%",
|
|
146
|
-
aspectRatio: "1",
|
|
147
|
-
borderRadius: 16,
|
|
148
|
-
overflow: "hidden",
|
|
149
|
-
background: "#0c0c14",
|
|
150
|
-
cursor: isZoomed ? "grab" : "zoom-in",
|
|
151
|
-
}}
|
|
152
|
-
>
|
|
153
|
-
<img
|
|
154
|
-
src={productImg}
|
|
155
|
-
alt="Döner Kebab"
|
|
156
|
-
draggable={false}
|
|
157
|
-
style={{
|
|
158
|
-
width: "100%",
|
|
159
|
-
height: "100%",
|
|
160
|
-
objectFit: "cover",
|
|
161
|
-
display: "block",
|
|
162
|
-
pointerEvents: "none",
|
|
163
|
-
}}
|
|
164
|
-
/>
|
|
165
|
-
</TransformComponent>
|
|
166
|
-
|
|
167
|
-
{/* Zoom controls */}
|
|
168
|
-
<div
|
|
169
|
-
style={{
|
|
170
|
-
position: "absolute",
|
|
171
|
-
bottom: 12,
|
|
172
|
-
right: 12,
|
|
173
|
-
display: "flex",
|
|
174
|
-
gap: 4,
|
|
175
|
-
padding: 4,
|
|
176
|
-
borderRadius: 12,
|
|
177
|
-
background: "rgba(0, 0, 0, 0.55)",
|
|
178
|
-
backdropFilter: "blur(12px)",
|
|
179
|
-
border: "1px solid rgba(255,255,255,0.08)",
|
|
180
|
-
}}
|
|
181
|
-
>
|
|
182
|
-
<button
|
|
183
|
-
type="button"
|
|
184
|
-
onClick={() => zoomIn()}
|
|
185
|
-
style={zoomBtnStyle}
|
|
186
|
-
title="Zoom in"
|
|
187
|
-
aria-label="Zoom in"
|
|
188
|
-
>
|
|
189
|
-
<ZoomInIcon />
|
|
190
|
-
</button>
|
|
191
|
-
<button
|
|
192
|
-
type="button"
|
|
193
|
-
onClick={() => zoomOut()}
|
|
194
|
-
style={zoomBtnStyle}
|
|
195
|
-
title="Zoom out"
|
|
196
|
-
aria-label="Zoom out"
|
|
197
|
-
>
|
|
198
|
-
<ZoomOutIcon />
|
|
199
|
-
</button>
|
|
200
|
-
{isZoomed && (
|
|
201
|
-
<button
|
|
202
|
-
type="button"
|
|
203
|
-
onClick={() => resetTransform()}
|
|
204
|
-
style={zoomBtnStyle}
|
|
205
|
-
title="Reset zoom"
|
|
206
|
-
aria-label="Reset zoom"
|
|
207
|
-
>
|
|
208
|
-
<ResetIcon />
|
|
209
|
-
</button>
|
|
210
|
-
)}
|
|
211
|
-
</div>
|
|
212
|
-
|
|
213
|
-
{/* Zoom hint */}
|
|
214
|
-
{!isZoomed && (
|
|
215
|
-
<div
|
|
216
|
-
style={{
|
|
217
|
-
position: "absolute",
|
|
218
|
-
top: 12,
|
|
219
|
-
left: 12,
|
|
220
|
-
padding: "5px 10px",
|
|
221
|
-
borderRadius: 8,
|
|
222
|
-
background: "rgba(0, 0, 0, 0.5)",
|
|
223
|
-
backdropFilter: "blur(8px)",
|
|
224
|
-
fontSize: 10,
|
|
225
|
-
fontWeight: 600,
|
|
226
|
-
color: "rgba(255,255,255,0.6)",
|
|
227
|
-
fontFamily: font,
|
|
228
|
-
pointerEvents: "none",
|
|
229
|
-
display: "flex",
|
|
230
|
-
alignItems: "center",
|
|
231
|
-
gap: 5,
|
|
232
|
-
}}
|
|
233
|
-
>
|
|
234
|
-
<ZoomInIcon />
|
|
235
|
-
Scroll or pinch to zoom
|
|
236
|
-
</div>
|
|
237
|
-
)}
|
|
238
|
-
|
|
239
|
-
{/* Zoom level badge */}
|
|
240
|
-
{isZoomed && (
|
|
241
|
-
<div
|
|
242
|
-
style={{
|
|
243
|
-
position: "absolute",
|
|
244
|
-
top: 12,
|
|
245
|
-
right: 12,
|
|
246
|
-
padding: "4px 10px",
|
|
247
|
-
borderRadius: 8,
|
|
248
|
-
background: "rgba(0, 0, 0, 0.55)",
|
|
249
|
-
backdropFilter: "blur(8px)",
|
|
250
|
-
fontSize: 11,
|
|
251
|
-
fontWeight: 700,
|
|
252
|
-
color: "rgba(255,255,255,0.7)",
|
|
253
|
-
fontFamily: font,
|
|
254
|
-
fontVariantNumeric: "tabular-nums",
|
|
255
|
-
pointerEvents: "none",
|
|
256
|
-
}}
|
|
257
|
-
>
|
|
258
|
-
{scale.toFixed(1)}×
|
|
259
|
-
</div>
|
|
260
|
-
)}
|
|
261
|
-
</div>
|
|
262
|
-
);
|
|
263
|
-
}}
|
|
264
|
-
</TransformWrapper>
|
|
265
|
-
);
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
/* ── Main product card ─────────────────────────────────────── */
|
|
269
|
-
|
|
270
|
-
export const Example: React.FC<Record<string, unknown>> = (args) => {
|
|
271
|
-
const [selectedSauce, setSelectedSauce] = useState(0);
|
|
272
|
-
const [selectedPortion, setSelectedPortion] = useState(1);
|
|
273
|
-
const [wishlisted, setWishlisted] = useState(false);
|
|
274
|
-
|
|
275
|
-
return (
|
|
276
|
-
<div
|
|
277
|
-
style={{
|
|
278
|
-
fontFamily: font,
|
|
279
|
-
maxWidth: 880,
|
|
280
|
-
margin: "0 auto",
|
|
281
|
-
}}
|
|
282
|
-
>
|
|
283
|
-
<div
|
|
284
|
-
style={{
|
|
285
|
-
display: "grid",
|
|
286
|
-
gridTemplateColumns: "1fr 1fr",
|
|
287
|
-
gap: 32,
|
|
288
|
-
alignItems: "start",
|
|
289
|
-
borderRadius: 20,
|
|
290
|
-
background:
|
|
291
|
-
"linear-gradient(145deg, rgba(15, 23, 42, 0.6), rgba(10, 10, 20, 0.8))",
|
|
292
|
-
border: "1px solid rgba(255,255,255,0.06)",
|
|
293
|
-
padding: 24,
|
|
294
|
-
boxShadow:
|
|
295
|
-
"0 24px 48px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255,255,255,0.03)",
|
|
296
|
-
}}
|
|
297
|
-
>
|
|
298
|
-
{/* Left: image viewer */}
|
|
299
|
-
<ImageViewer args={args} />
|
|
300
|
-
|
|
301
|
-
{/* Right: product info */}
|
|
302
|
-
<div style={{ padding: "8px 0" }}>
|
|
303
|
-
{/* Badge */}
|
|
304
|
-
<span
|
|
305
|
-
style={{
|
|
306
|
-
display: "inline-block",
|
|
307
|
-
padding: "4px 10px",
|
|
308
|
-
borderRadius: 6,
|
|
309
|
-
background: "rgba(16, 185, 129, 0.15)",
|
|
310
|
-
border: "1px solid rgba(16, 185, 129, 0.25)",
|
|
311
|
-
fontSize: 10,
|
|
312
|
-
fontWeight: 700,
|
|
313
|
-
color: "rgba(52, 211, 153, 0.9)",
|
|
314
|
-
letterSpacing: "0.04em",
|
|
315
|
-
textTransform: "uppercase",
|
|
316
|
-
marginBottom: 12,
|
|
317
|
-
}}
|
|
318
|
-
>
|
|
319
|
-
Best Seller
|
|
320
|
-
</span>
|
|
321
|
-
|
|
322
|
-
{/* Title */}
|
|
323
|
-
<h2
|
|
324
|
-
style={{
|
|
325
|
-
margin: "0 0 6px",
|
|
326
|
-
fontSize: 26,
|
|
327
|
-
fontWeight: 800,
|
|
328
|
-
color: "rgba(255,255,255,0.95)",
|
|
329
|
-
letterSpacing: "-0.02em",
|
|
330
|
-
lineHeight: 1.2,
|
|
331
|
-
}}
|
|
332
|
-
>
|
|
333
|
-
Signature Döner Kebab
|
|
334
|
-
</h2>
|
|
335
|
-
|
|
336
|
-
{/* Rating */}
|
|
337
|
-
<div
|
|
338
|
-
style={{
|
|
339
|
-
display: "flex",
|
|
340
|
-
alignItems: "center",
|
|
341
|
-
gap: 6,
|
|
342
|
-
marginBottom: 16,
|
|
343
|
-
}}
|
|
344
|
-
>
|
|
345
|
-
<div style={{ display: "flex", gap: 2 }}>
|
|
346
|
-
{[1, 2, 3, 4, 5].map((n) => (
|
|
347
|
-
<StarIcon key={n} full={n <= 5} />
|
|
348
|
-
))}
|
|
349
|
-
</div>
|
|
350
|
-
<span
|
|
351
|
-
style={{
|
|
352
|
-
fontSize: 12,
|
|
353
|
-
color: "rgba(255,255,255,0.4)",
|
|
354
|
-
fontWeight: 500,
|
|
355
|
-
}}
|
|
356
|
-
>
|
|
357
|
-
4.8 · 342 reviews
|
|
358
|
-
</span>
|
|
359
|
-
</div>
|
|
360
|
-
|
|
361
|
-
{/* Price */}
|
|
362
|
-
<div
|
|
363
|
-
style={{
|
|
364
|
-
display: "flex",
|
|
365
|
-
alignItems: "baseline",
|
|
366
|
-
gap: 10,
|
|
367
|
-
marginBottom: 20,
|
|
368
|
-
}}
|
|
369
|
-
>
|
|
370
|
-
<span
|
|
371
|
-
style={{
|
|
372
|
-
fontSize: 28,
|
|
373
|
-
fontWeight: 800,
|
|
374
|
-
color: "rgba(255,255,255,0.95)",
|
|
375
|
-
letterSpacing: "-0.02em",
|
|
376
|
-
}}
|
|
377
|
-
>
|
|
378
|
-
$12.99
|
|
379
|
-
</span>
|
|
380
|
-
<span
|
|
381
|
-
style={{
|
|
382
|
-
fontSize: 16,
|
|
383
|
-
color: "rgba(255,255,255,0.3)",
|
|
384
|
-
textDecoration: "line-through",
|
|
385
|
-
fontWeight: 500,
|
|
386
|
-
}}
|
|
387
|
-
>
|
|
388
|
-
$15.99
|
|
389
|
-
</span>
|
|
390
|
-
<span
|
|
391
|
-
style={{
|
|
392
|
-
padding: "3px 8px",
|
|
393
|
-
borderRadius: 6,
|
|
394
|
-
background: "rgba(239, 68, 68, 0.15)",
|
|
395
|
-
fontSize: 11,
|
|
396
|
-
fontWeight: 700,
|
|
397
|
-
color: "rgba(248, 113, 113, 0.9)",
|
|
398
|
-
}}
|
|
399
|
-
>
|
|
400
|
-
-19%
|
|
401
|
-
</span>
|
|
402
|
-
</div>
|
|
403
|
-
|
|
404
|
-
{/* Description */}
|
|
405
|
-
<p
|
|
406
|
-
style={{
|
|
407
|
-
margin: "0 0 20px",
|
|
408
|
-
fontSize: 13,
|
|
409
|
-
lineHeight: 1.65,
|
|
410
|
-
color: "rgba(255,255,255,0.45)",
|
|
411
|
-
}}
|
|
412
|
-
>
|
|
413
|
-
Tender slices of seasoned lamb and chicken, slow-roasted on a
|
|
414
|
-
vertical spit, wrapped in warm handmade flatbread with crisp
|
|
415
|
-
lettuce, tomatoes, onions, and your choice of sauce. Zoom into the
|
|
416
|
-
image to see every juicy detail up close.
|
|
417
|
-
</p>
|
|
418
|
-
|
|
419
|
-
{/* Sauce selector */}
|
|
420
|
-
<div style={{ marginBottom: 18 }}>
|
|
421
|
-
<div
|
|
422
|
-
style={{
|
|
423
|
-
fontSize: 12,
|
|
424
|
-
fontWeight: 600,
|
|
425
|
-
color: "rgba(255,255,255,0.5)",
|
|
426
|
-
marginBottom: 8,
|
|
427
|
-
}}
|
|
428
|
-
>
|
|
429
|
-
Sauce ·{" "}
|
|
430
|
-
<span style={{ color: "rgba(255,255,255,0.8)" }}>
|
|
431
|
-
{SAUCES[selectedSauce].name}
|
|
432
|
-
</span>
|
|
433
|
-
</div>
|
|
434
|
-
<div style={{ display: "flex", gap: 8 }}>
|
|
435
|
-
{SAUCES.map((s, i) => (
|
|
436
|
-
<button
|
|
437
|
-
key={s.name}
|
|
438
|
-
type="button"
|
|
439
|
-
onClick={() => setSelectedSauce(i)}
|
|
440
|
-
title={s.name}
|
|
441
|
-
aria-label={`Select sauce ${s.name}`}
|
|
442
|
-
style={{
|
|
443
|
-
width: 32,
|
|
444
|
-
height: 32,
|
|
445
|
-
borderRadius: "50%",
|
|
446
|
-
border:
|
|
447
|
-
selectedSauce === i
|
|
448
|
-
? "2px solid rgba(255,255,255,0.7)"
|
|
449
|
-
: "2px solid rgba(255,255,255,0.1)",
|
|
450
|
-
background: s.value,
|
|
451
|
-
cursor: "pointer",
|
|
452
|
-
padding: 0,
|
|
453
|
-
boxShadow:
|
|
454
|
-
selectedSauce === i
|
|
455
|
-
? "0 0 0 3px rgba(99, 102, 241, 0.35)"
|
|
456
|
-
: "none",
|
|
457
|
-
transition: "border-color 0.15s, box-shadow 0.15s",
|
|
458
|
-
}}
|
|
459
|
-
/>
|
|
460
|
-
))}
|
|
461
|
-
</div>
|
|
462
|
-
</div>
|
|
463
|
-
|
|
464
|
-
{/* Portion selector */}
|
|
465
|
-
<div style={{ marginBottom: 24 }}>
|
|
466
|
-
<div
|
|
467
|
-
style={{
|
|
468
|
-
fontSize: 12,
|
|
469
|
-
fontWeight: 600,
|
|
470
|
-
color: "rgba(255,255,255,0.5)",
|
|
471
|
-
marginBottom: 8,
|
|
472
|
-
}}
|
|
473
|
-
>
|
|
474
|
-
Portion ·{" "}
|
|
475
|
-
<span style={{ color: "rgba(255,255,255,0.8)" }}>
|
|
476
|
-
{PORTIONS[selectedPortion]}
|
|
477
|
-
</span>
|
|
478
|
-
</div>
|
|
479
|
-
<div style={{ display: "flex", gap: 6 }}>
|
|
480
|
-
{PORTIONS.map((p, i) => (
|
|
481
|
-
<button
|
|
482
|
-
key={p}
|
|
483
|
-
type="button"
|
|
484
|
-
onClick={() => setSelectedPortion(i)}
|
|
485
|
-
style={{
|
|
486
|
-
width: 42,
|
|
487
|
-
height: 42,
|
|
488
|
-
borderRadius: 10,
|
|
489
|
-
border:
|
|
490
|
-
selectedPortion === i
|
|
491
|
-
? "1.5px solid rgba(99, 102, 241, 0.6)"
|
|
492
|
-
: "1.5px solid rgba(255,255,255,0.08)",
|
|
493
|
-
background:
|
|
494
|
-
selectedPortion === i
|
|
495
|
-
? "rgba(99, 102, 241, 0.15)"
|
|
496
|
-
: "rgba(255,255,255,0.03)",
|
|
497
|
-
color:
|
|
498
|
-
selectedPortion === i
|
|
499
|
-
? "rgba(165, 180, 252, 0.95)"
|
|
500
|
-
: "rgba(255,255,255,0.5)",
|
|
501
|
-
fontSize: 13,
|
|
502
|
-
fontWeight: 700,
|
|
503
|
-
fontFamily: font,
|
|
504
|
-
cursor: "pointer",
|
|
505
|
-
padding: 0,
|
|
506
|
-
transition:
|
|
507
|
-
"border-color 0.15s, background 0.15s, color 0.15s",
|
|
508
|
-
}}
|
|
509
|
-
>
|
|
510
|
-
{p}
|
|
511
|
-
</button>
|
|
512
|
-
))}
|
|
513
|
-
</div>
|
|
514
|
-
</div>
|
|
515
|
-
|
|
516
|
-
{/* Action buttons */}
|
|
517
|
-
<div style={{ display: "flex", gap: 10 }}>
|
|
518
|
-
<button
|
|
519
|
-
type="button"
|
|
520
|
-
style={{
|
|
521
|
-
flex: 1,
|
|
522
|
-
padding: "14px 24px",
|
|
523
|
-
borderRadius: 12,
|
|
524
|
-
border: "none",
|
|
525
|
-
background: "linear-gradient(135deg, #6366f1, #8b5cf6)",
|
|
526
|
-
color: "#fff",
|
|
527
|
-
fontSize: 14,
|
|
528
|
-
fontWeight: 700,
|
|
529
|
-
fontFamily: font,
|
|
530
|
-
cursor: "pointer",
|
|
531
|
-
boxShadow:
|
|
532
|
-
"0 4px 16px rgba(99, 102, 241, 0.3), 0 1px 3px rgba(0,0,0,0.2)",
|
|
533
|
-
letterSpacing: "-0.01em",
|
|
534
|
-
}}
|
|
535
|
-
>
|
|
536
|
-
Add to Order
|
|
537
|
-
</button>
|
|
538
|
-
<button
|
|
539
|
-
type="button"
|
|
540
|
-
onClick={() => setWishlisted(!wishlisted)}
|
|
541
|
-
aria-label={
|
|
542
|
-
wishlisted ? "Remove from favorites" : "Add to favorites"
|
|
543
|
-
}
|
|
544
|
-
style={{
|
|
545
|
-
width: 48,
|
|
546
|
-
height: 48,
|
|
547
|
-
borderRadius: 12,
|
|
548
|
-
border: "1.5px solid rgba(255,255,255,0.08)",
|
|
549
|
-
background: wishlisted
|
|
550
|
-
? "rgba(239, 68, 68, 0.12)"
|
|
551
|
-
: "rgba(255,255,255,0.03)",
|
|
552
|
-
color: wishlisted
|
|
553
|
-
? "rgba(248, 113, 113, 0.9)"
|
|
554
|
-
: "rgba(255,255,255,0.45)",
|
|
555
|
-
cursor: "pointer",
|
|
556
|
-
padding: 0,
|
|
557
|
-
display: "flex",
|
|
558
|
-
alignItems: "center",
|
|
559
|
-
justifyContent: "center",
|
|
560
|
-
transition: "background 0.15s, color 0.15s, border-color 0.15s",
|
|
561
|
-
borderColor: wishlisted
|
|
562
|
-
? "rgba(248, 113, 113, 0.25)"
|
|
563
|
-
: "rgba(255,255,255,0.08)",
|
|
564
|
-
flexShrink: 0,
|
|
565
|
-
}}
|
|
566
|
-
>
|
|
567
|
-
<HeartIcon filled={wishlisted} />
|
|
568
|
-
</button>
|
|
569
|
-
</div>
|
|
570
|
-
|
|
571
|
-
{/* Delivery info */}
|
|
572
|
-
<div
|
|
573
|
-
style={{
|
|
574
|
-
marginTop: 18,
|
|
575
|
-
padding: "10px 14px",
|
|
576
|
-
borderRadius: 10,
|
|
577
|
-
background: "rgba(255,255,255,0.02)",
|
|
578
|
-
border: "1px solid rgba(255,255,255,0.04)",
|
|
579
|
-
display: "flex",
|
|
580
|
-
gap: 16,
|
|
581
|
-
fontSize: 11,
|
|
582
|
-
color: "rgba(255,255,255,0.35)",
|
|
583
|
-
fontWeight: 500,
|
|
584
|
-
}}
|
|
585
|
-
>
|
|
586
|
-
<span>🕐 25-35 min delivery</span>
|
|
587
|
-
<span>🔥 Made fresh to order</span>
|
|
588
|
-
<span>✓ Available now</span>
|
|
589
|
-
</div>
|
|
590
|
-
</div>
|
|
591
|
-
</div>
|
|
592
|
-
</div>
|
|
593
|
-
);
|
|
594
|
-
};
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { Meta, Story, ArgsTable, Canvas } from "@storybook/blocks";
|
|
2
|
-
|
|
3
|
-
import { TransformWrapper } from "../../../components";
|
|
4
|
-
import { argsTypes } from "../../types/args.types.ts";
|
|
5
|
-
import { Example } from "./example";
|
|
6
|
-
|
|
7
|
-
export const Template = (args) => <Example {...args} />;
|
|
8
|
-
|
|
9
|
-
<Meta
|
|
10
|
-
title="Examples/Product card"
|
|
11
|
-
component={TransformWrapper}
|
|
12
|
-
argTypes={argsTypes}
|
|
13
|
-
/>
|
|
14
|
-
|
|
15
|
-
# Product Card
|
|
16
|
-
|
|
17
|
-
A realistic **food delivery product card** with an interactive image zoom viewer.
|
|
18
|
-
Scroll, pinch, or double-click the product image to zoom in and see
|
|
19
|
-
the juicy meat, fresh vegetables, and sauce details up close. The card includes
|
|
20
|
-
sauce/portion selectors, pricing, and an order flow — a common real-world
|
|
21
|
-
use case for `react-zoom-pan-pinch`.
|
|
22
|
-
|
|
23
|
-
<Canvas>
|
|
24
|
-
<Story name="Product card">{(args) => <Template {...args} />}</Story>
|
|
25
|
-
</Canvas>
|
|
26
|
-
|
|
27
|
-
## Component API
|
|
28
|
-
|
|
29
|
-
<ArgsTable story="Product card" />
|