@yamatozhen/design_system 1.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/LICENSE +201 -0
- package/README.md +101 -0
- package/package.json +49 -0
- package/scripts/postinstall.js +105 -0
- package/template/app/ClientNav.tsx +310 -0
- package/template/app/globals.css +167 -0
- package/template/app/layout.tsx +128 -0
- package/template/app/themes/dark-mc.css +51 -0
- package/template/app/themes/dark.css +51 -0
- package/template/app/themes/light-mc.css +51 -0
- package/template/app/themes/light.css +51 -0
- package/template/app/themes/theme.css +82 -0
- package/template/components/layout/Lightbox/LightboxCard.tsx +100 -0
- package/template/components/layout/Lightbox/LightboxGallery.module.css +249 -0
- package/template/components/layout/Lightbox/LightboxGallery.tsx +72 -0
- package/template/components/layout/Lightbox/LightboxGrid.tsx +186 -0
- package/template/components/layout/Lightbox/LightboxModal.module.css +395 -0
- package/template/components/layout/Lightbox/LightboxModal.tsx +500 -0
- package/template/components/layout/Lightbox/demo.tsx +412 -0
- package/template/components/layout/Lightbox/index.ts +30 -0
- package/template/components/layout/Lightbox/types.ts +113 -0
- package/template/components/layout/Lightbox/useLightboxFilters.ts +140 -0
- package/template/components/layout/accordion/Accordion.module.css +149 -0
- package/template/components/layout/accordion/Accordion.tsx +114 -0
- package/template/components/layout/button/Button.module.css +305 -0
- package/template/components/layout/button/ButtonGroup.tsx +503 -0
- package/template/components/layout/button/FAB.tsx +118 -0
- package/template/components/layout/button/button.tsx +128 -0
- package/template/components/layout/button/drop.module.css +229 -0
- package/template/components/layout/button/drop.tsx +516 -0
- package/template/components/layout/hero/v1/heroSlideshow.module.css +107 -0
- package/template/components/layout/hero/v1/heroSlideshow.tsx +233 -0
- package/template/components/layout/modals/accessibilityModal/AccessibilityModal.module.css +126 -0
- package/template/components/layout/modals/accessibilityModal/AccessibilityModal.tsx +290 -0
- package/template/components/layout/modals/alert/Alert.tsx +188 -0
- package/template/components/layout/navigation/MioCard.module.css +88 -0
- package/template/components/layout/navigation/MioCard.tsx +266 -0
- package/template/components/layout/navigation/Wrap.tsx +41 -0
- package/template/components/layout/navigation/nav/Nav.module.css +508 -0
- package/template/components/layout/navigation/nav/Nav.tsx +167 -0
- package/template/components/layout/navigation/nav/NavBar.tsx +419 -0
- package/template/components/layout/navigation/nav/NavContext.tsx +259 -0
- package/template/components/layout/navigation/nav/NavItem.tsx +173 -0
- package/template/components/layout/navigation/nav/NavNew.module.css +373 -0
- package/template/components/layout/navigation/nav/NavRail.tsx +315 -0
- package/template/components/layout/navigation/nav/NavSection.tsx +102 -0
- package/template/components/layout/navigation/nav/NavTab.tsx +25 -0
- package/template/components/layout/navigation/nav/navftb/NavFTB.module.css +252 -0
- package/template/components/layout/navigation/nav/navftb/NavFTB.tsx +399 -0
- package/template/components/layout/navigation/nav/navftb/useTabIndicator.ts +484 -0
- package/template/components/layout/navigation/nav/navheader/NavHeader.module.css +59 -0
- package/template/components/layout/navigation/nav/navheader/NavHeader.tsx +478 -0
- package/template/components/layout/pages/loadingScreen.tsx +102 -0
- package/template/components/layout/pages/maintenance/Maintenance.tsx +53 -0
- package/template/components/layout/pages/maintenance/maintenance.module.css +163 -0
- package/template/components/layout/switch/Switch.module.css +102 -0
- package/template/components/layout/switch/Switch.tsx +48 -0
- package/template/components/tools/Divider.tsx +11 -0
- package/template/components/tools/ProgressiveBlur.tsx +73 -0
- package/template/components/tools/ReduceMotionContext.tsx +5 -0
- package/template/components/tools/Sinewave.tsx +199 -0
- package/template/components/tools/SinewaveProgress.tsx +135 -0
- package/template/components/tools/badge/Badge.tsx +28 -0
- package/template/components/tools/flubber.d.ts +7 -0
- package/template/components/tools/icon/SocialIcons.tsx +88 -0
- package/template/components/tools/icon/icon.module.css +0 -0
- package/template/components/tools/icon/icon.tsx +125 -0
- package/template/components/tools/mobileViewProvider.tsx +58 -0
- package/template/components/tools/react-bits/ClickSpark.tsx +177 -0
- package/template/components/tools/react-bits/FadeContent.tsx +90 -0
- package/template/components/tools/react-bits/GlareHover.tsx +73 -0
- package/template/components/tools/react-bits/GradientText/GradientText.css +70 -0
- package/template/components/tools/react-bits/GradientText/GradientText.tsx +44 -0
- package/template/components/tools/react-bits/Magnet.tsx +118 -0
- package/template/components/tools/react-bits/Stepper/Stepper.css +134 -0
- package/template/components/tools/react-bits/Stepper/Stepper.tsx +412 -0
- package/template/components/tools/ripple/ripple.css +41 -0
- package/template/components/tools/ripple/ripple.tsx +53 -0
- package/template/components/tools/shape/ShapeLoader.tsx +101 -0
- package/template/components/tools/shape/ShapeMorph.tsx +190 -0
- package/template/components/tools/shape/ShapePaths.ts +116 -0
- package/template/components/tools/switch/Switch.module.css +102 -0
- package/template/components/tools/switch/Switch.tsx +48 -0
- package/template/components/tools/useBodyScrollLock.tsx +27 -0
- package/template/components/tools/useImageColor.ts +47 -0
- package/template/components/tools/useNavSheetDrag.tsx +196 -0
- package/template/public/fonts/material-symbols/MaterialSymbolsRounded-VariableFont_FILL,GRAD,opsz,wght.woff2 +0 -0
|
@@ -0,0 +1,500 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
useCallback,
|
|
5
|
+
useEffect,
|
|
6
|
+
useRef,
|
|
7
|
+
useState,
|
|
8
|
+
type AnimationEvent as ReactAnimationEvent,
|
|
9
|
+
type MouseEvent as ReactMouseEvent,
|
|
10
|
+
} from "react";
|
|
11
|
+
import { createPortal } from "react-dom";
|
|
12
|
+
import Image from "next/image";
|
|
13
|
+
import type { LightboxItem } from "./types";
|
|
14
|
+
import styles from "./LightboxModal.module.css";
|
|
15
|
+
import Button from "../button/button";
|
|
16
|
+
import Icon from "@/components/tools/icon/icon";
|
|
17
|
+
import {
|
|
18
|
+
BREAKPOINTS,
|
|
19
|
+
useBreakpoints,
|
|
20
|
+
useMediaQuery,
|
|
21
|
+
} from "@/components/tools/mobileViewProvider";
|
|
22
|
+
import Sinewave from "@/components/tools/Sinewave";
|
|
23
|
+
|
|
24
|
+
export interface LightboxModalProps {
|
|
25
|
+
/** The item to display. Pass `null` to close. */
|
|
26
|
+
item: LightboxItem | null;
|
|
27
|
+
/** Called when the user requests close (X, backdrop click, Esc). */
|
|
28
|
+
onClose: () => void;
|
|
29
|
+
/** Called when the user toggles favorite on the open item. */
|
|
30
|
+
onToggleFavorite?: (item: LightboxItem) => void;
|
|
31
|
+
/** Called when the user clicks Share. Defaults to a console.log stub. */
|
|
32
|
+
onShare?: (item: LightboxItem, slideIndex: number) => void;
|
|
33
|
+
/**
|
|
34
|
+
* Builds the URL written to clipboard by the Copy button.
|
|
35
|
+
* Defaults to `${origin}${pathname}?id=${id}&slide=${i}`.
|
|
36
|
+
*/
|
|
37
|
+
buildShareUrl?: (item: LightboxItem, slideIndex: number) => string;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Modal that renders an artwork item as a vertical scroll of slides plus a
|
|
42
|
+
* sticky side panel. Mounts via a portal to `document.body`. Plays an open
|
|
43
|
+
* animation when `item` becomes non-null, a close animation when it returns
|
|
44
|
+
* to `null`, and unmounts after the close animation completes.
|
|
45
|
+
*
|
|
46
|
+
* Keyboard:
|
|
47
|
+
* Esc → close
|
|
48
|
+
* ArrowDown / ArrowRight → scroll to next slide
|
|
49
|
+
* ArrowUp / ArrowLeft → scroll to previous slide
|
|
50
|
+
*
|
|
51
|
+
* Theming exposed via CSS variables on the backdrop element — see the
|
|
52
|
+
* accompanying `.module.css` for the full list.
|
|
53
|
+
*/
|
|
54
|
+
export function LightboxModal({
|
|
55
|
+
item,
|
|
56
|
+
onClose,
|
|
57
|
+
onToggleFavorite,
|
|
58
|
+
onShare,
|
|
59
|
+
buildShareUrl,
|
|
60
|
+
}: LightboxModalProps) {
|
|
61
|
+
const [internalItem, setInternalItem] = useState<LightboxItem | null>(null);
|
|
62
|
+
const [isClosing, setIsClosing] = useState(false);
|
|
63
|
+
const [activeIdx, setActiveIdx] = useState(0);
|
|
64
|
+
const [, setCopied] = useState(false);
|
|
65
|
+
|
|
66
|
+
const backdropRef = useRef<HTMLDivElement>(null);
|
|
67
|
+
const modalRef = useRef<HTMLDivElement>(null);
|
|
68
|
+
const slideRefs = useRef<Array<HTMLDivElement | null>>([]);
|
|
69
|
+
|
|
70
|
+
// Sync prop → internal mount state, triggering close animation on prop null
|
|
71
|
+
useEffect(() => {
|
|
72
|
+
if (item) {
|
|
73
|
+
setInternalItem(item);
|
|
74
|
+
setIsClosing(false);
|
|
75
|
+
setActiveIdx(0);
|
|
76
|
+
} else if (internalItem && !isClosing) {
|
|
77
|
+
setIsClosing(true);
|
|
78
|
+
}
|
|
79
|
+
}, [item, internalItem, isClosing]);
|
|
80
|
+
|
|
81
|
+
// Reset scroll position when a new item opens
|
|
82
|
+
useEffect(() => {
|
|
83
|
+
if (internalItem && !isClosing && backdropRef.current) {
|
|
84
|
+
backdropRef.current.scrollTop = 0;
|
|
85
|
+
}
|
|
86
|
+
}, [internalItem, isClosing]);
|
|
87
|
+
|
|
88
|
+
// Lock body scroll while modal is mounted
|
|
89
|
+
useEffect(() => {
|
|
90
|
+
if (!internalItem) return;
|
|
91
|
+
const prev = document.body.style.overflow;
|
|
92
|
+
document.body.style.overflow = "hidden";
|
|
93
|
+
return () => {
|
|
94
|
+
document.body.style.overflow = prev;
|
|
95
|
+
};
|
|
96
|
+
}, [internalItem]);
|
|
97
|
+
|
|
98
|
+
const { isMobile, isTablet } = useBreakpoints();
|
|
99
|
+
// Matches the bottom-sheet layout's own breakpoint (900px in the module
|
|
100
|
+
// CSS) rather than the 767px `isMobile` flag, so the gesture handlers only
|
|
101
|
+
// arm exactly when the sheet layout is actually in effect.
|
|
102
|
+
const isBottomSheet = useMediaQuery("(max-width: 900px)");
|
|
103
|
+
|
|
104
|
+
// Guaranteed unmount after close animation. animationend is the fast path;
|
|
105
|
+
// this timeout fires if it never arrives (e.g. reduced-motion 1ms race).
|
|
106
|
+
useEffect(() => {
|
|
107
|
+
if (!isClosing) return;
|
|
108
|
+
const backdrop = backdropRef.current;
|
|
109
|
+
let ms = 400;
|
|
110
|
+
if (backdrop) {
|
|
111
|
+
const raw = getComputedStyle(backdrop)
|
|
112
|
+
.getPropertyValue("--lb-modal-duration")
|
|
113
|
+
.trim();
|
|
114
|
+
const parsed = parseFloat(raw);
|
|
115
|
+
if (!isNaN(parsed) && parsed > 0)
|
|
116
|
+
ms = (raw.endsWith("ms") ? parsed : parsed * 1000) + 50;
|
|
117
|
+
}
|
|
118
|
+
const id = window.setTimeout(() => {
|
|
119
|
+
setInternalItem(null);
|
|
120
|
+
setIsClosing(false);
|
|
121
|
+
}, ms);
|
|
122
|
+
return () => window.clearTimeout(id);
|
|
123
|
+
}, [isClosing]);
|
|
124
|
+
|
|
125
|
+
const scrollToSlide = useCallback((idx: number) => {
|
|
126
|
+
const ref = slideRefs.current[idx];
|
|
127
|
+
if (ref) ref.scrollIntoView({ behavior: "smooth", block: "center" });
|
|
128
|
+
}, []);
|
|
129
|
+
|
|
130
|
+
// Keyboard handling
|
|
131
|
+
useEffect(() => {
|
|
132
|
+
if (!internalItem || isClosing) return;
|
|
133
|
+
const slidesLen = internalItem.slides?.length ?? 0;
|
|
134
|
+
|
|
135
|
+
const handleKey = (e: KeyboardEvent) => {
|
|
136
|
+
if (e.key === "Escape") {
|
|
137
|
+
e.preventDefault();
|
|
138
|
+
onClose();
|
|
139
|
+
} else if (e.key === "ArrowDown" || e.key === "ArrowRight") {
|
|
140
|
+
e.preventDefault();
|
|
141
|
+
scrollToSlide(Math.min(activeIdx + 1, slidesLen - 1));
|
|
142
|
+
} else if (e.key === "ArrowUp" || e.key === "ArrowLeft") {
|
|
143
|
+
e.preventDefault();
|
|
144
|
+
scrollToSlide(Math.max(activeIdx - 1, 0));
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
window.addEventListener("keydown", handleKey);
|
|
148
|
+
return () => window.removeEventListener("keydown", handleKey);
|
|
149
|
+
}, [internalItem, isClosing, activeIdx, onClose, scrollToSlide]);
|
|
150
|
+
|
|
151
|
+
// Track which slide is most centered in the viewport
|
|
152
|
+
useEffect(() => {
|
|
153
|
+
const scrollEl = backdropRef.current;
|
|
154
|
+
if (!scrollEl || !internalItem) return;
|
|
155
|
+
|
|
156
|
+
const update = () => {
|
|
157
|
+
const center = scrollEl.scrollTop + scrollEl.clientHeight / 2;
|
|
158
|
+
let bestIdx = 0;
|
|
159
|
+
let bestDist = Infinity;
|
|
160
|
+
slideRefs.current.forEach((ref, idx) => {
|
|
161
|
+
if (!ref) return;
|
|
162
|
+
const c = ref.offsetTop + ref.offsetHeight / 2;
|
|
163
|
+
const d = Math.abs(c - center);
|
|
164
|
+
if (d < bestDist) {
|
|
165
|
+
bestDist = d;
|
|
166
|
+
bestIdx = idx;
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
setActiveIdx(bestIdx);
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
scrollEl.addEventListener("scroll", update, { passive: true });
|
|
173
|
+
update();
|
|
174
|
+
return () => scrollEl.removeEventListener("scroll", update);
|
|
175
|
+
}, [internalItem]);
|
|
176
|
+
|
|
177
|
+
// ── Bottom-sheet gestures (mobile only) ───────────────────────────────────
|
|
178
|
+
// Pulling down past the top of the scroll closes the sheet; pulling up past
|
|
179
|
+
// the bottom stretches a filler panel over the reveal instead of letting
|
|
180
|
+
// the native rubber-band bounce show the backdrop underneath.
|
|
181
|
+
const stretchFillerRef = useRef<HTMLDivElement>(null);
|
|
182
|
+
const dragStateRef = useRef<{
|
|
183
|
+
startY: number;
|
|
184
|
+
atTop: boolean;
|
|
185
|
+
atBottom: boolean;
|
|
186
|
+
mode: "close" | "stretch" | null;
|
|
187
|
+
lastDeltaY: number;
|
|
188
|
+
} | null>(null);
|
|
189
|
+
|
|
190
|
+
useEffect(() => {
|
|
191
|
+
if (!isBottomSheet || !internalItem || isClosing) return;
|
|
192
|
+
const scrollEl = backdropRef.current;
|
|
193
|
+
const modalEl = modalRef.current;
|
|
194
|
+
const fillerEl = stretchFillerRef.current;
|
|
195
|
+
if (!scrollEl || !modalEl) return;
|
|
196
|
+
|
|
197
|
+
const CLOSE_THRESHOLD = 90;
|
|
198
|
+
const CLOSE_DAMPING = 0.5;
|
|
199
|
+
const STRETCH_DAMPING = 0.4;
|
|
200
|
+
const STRETCH_MAX = 120;
|
|
201
|
+
|
|
202
|
+
const settle = (animate: boolean) => {
|
|
203
|
+
modalEl.style.transition = animate
|
|
204
|
+
? `transform var(--lb-modal-duration) var(--lb-modal-easing)`
|
|
205
|
+
: "none";
|
|
206
|
+
modalEl.style.transform = "";
|
|
207
|
+
if (fillerEl) {
|
|
208
|
+
fillerEl.style.transition = animate
|
|
209
|
+
? `height var(--lb-modal-duration) var(--lb-modal-easing)`
|
|
210
|
+
: "none";
|
|
211
|
+
fillerEl.style.height = "0px";
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
const handleTouchStart = (e: TouchEvent) => {
|
|
216
|
+
dragStateRef.current = {
|
|
217
|
+
startY: e.touches[0].clientY,
|
|
218
|
+
atTop: scrollEl.scrollTop <= 0,
|
|
219
|
+
atBottom:
|
|
220
|
+
scrollEl.scrollTop + scrollEl.clientHeight >=
|
|
221
|
+
scrollEl.scrollHeight - 1,
|
|
222
|
+
mode: null,
|
|
223
|
+
lastDeltaY: 0,
|
|
224
|
+
};
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
const handleTouchMove = (e: TouchEvent) => {
|
|
228
|
+
const st = dragStateRef.current;
|
|
229
|
+
if (!st) return;
|
|
230
|
+
const deltaY = e.touches[0].clientY - st.startY;
|
|
231
|
+
st.lastDeltaY = deltaY;
|
|
232
|
+
|
|
233
|
+
if (!st.mode) {
|
|
234
|
+
if (st.atTop && deltaY > 4) st.mode = "close";
|
|
235
|
+
else if (st.atBottom && deltaY < -4) st.mode = "stretch";
|
|
236
|
+
else return;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
if (st.mode === "close" && deltaY > 0) {
|
|
240
|
+
e.preventDefault();
|
|
241
|
+
modalEl.style.transition = "none";
|
|
242
|
+
modalEl.style.transform = `translateY(${deltaY * CLOSE_DAMPING}px)`;
|
|
243
|
+
} else if (st.mode === "stretch" && deltaY < 0 && fillerEl) {
|
|
244
|
+
e.preventDefault();
|
|
245
|
+
const h = Math.min(-deltaY * STRETCH_DAMPING, STRETCH_MAX);
|
|
246
|
+
fillerEl.style.transition = "none";
|
|
247
|
+
fillerEl.style.height = `${h}px`;
|
|
248
|
+
}
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
const handleTouchEnd = () => {
|
|
252
|
+
const st = dragStateRef.current;
|
|
253
|
+
dragStateRef.current = null;
|
|
254
|
+
if (!st) return;
|
|
255
|
+
|
|
256
|
+
if (st.mode === "close" && st.lastDeltaY * CLOSE_DAMPING > CLOSE_THRESHOLD) {
|
|
257
|
+
settle(false);
|
|
258
|
+
onClose();
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
settle(true);
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
scrollEl.addEventListener("touchstart", handleTouchStart, {
|
|
265
|
+
passive: true,
|
|
266
|
+
});
|
|
267
|
+
scrollEl.addEventListener("touchmove", handleTouchMove, {
|
|
268
|
+
passive: false,
|
|
269
|
+
});
|
|
270
|
+
scrollEl.addEventListener("touchend", handleTouchEnd);
|
|
271
|
+
scrollEl.addEventListener("touchcancel", handleTouchEnd);
|
|
272
|
+
return () => {
|
|
273
|
+
scrollEl.removeEventListener("touchstart", handleTouchStart);
|
|
274
|
+
scrollEl.removeEventListener("touchmove", handleTouchMove);
|
|
275
|
+
scrollEl.removeEventListener("touchend", handleTouchEnd);
|
|
276
|
+
scrollEl.removeEventListener("touchcancel", handleTouchEnd);
|
|
277
|
+
};
|
|
278
|
+
}, [isBottomSheet, internalItem, isClosing, onClose]);
|
|
279
|
+
|
|
280
|
+
const handleAnimationEnd = (e: ReactAnimationEvent<HTMLDivElement>) => {
|
|
281
|
+
// Only react to the modal's own animation, not anything bubbling up
|
|
282
|
+
if (e.target !== e.currentTarget) return;
|
|
283
|
+
if (isClosing) {
|
|
284
|
+
setInternalItem(null);
|
|
285
|
+
setIsClosing(false);
|
|
286
|
+
}
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
const handleBackdropClick = (e: ReactMouseEvent<HTMLDivElement>) => {
|
|
290
|
+
if (e.target === e.currentTarget) onClose();
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
const handleDownload = (src: string | undefined, e: ReactMouseEvent) => {
|
|
294
|
+
e.stopPropagation();
|
|
295
|
+
if (!src) return;
|
|
296
|
+
const a = document.createElement("a");
|
|
297
|
+
a.href = src;
|
|
298
|
+
a.download = "";
|
|
299
|
+
a.target = "_blank";
|
|
300
|
+
a.rel = "noopener noreferrer";
|
|
301
|
+
document.body.appendChild(a);
|
|
302
|
+
a.click();
|
|
303
|
+
document.body.removeChild(a);
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
const handleCopy = () => {
|
|
307
|
+
if (!internalItem) return;
|
|
308
|
+
const url = buildShareUrl
|
|
309
|
+
? buildShareUrl(internalItem, activeIdx)
|
|
310
|
+
: `${window.location.origin}${window.location.pathname}?id=${encodeURIComponent(
|
|
311
|
+
internalItem.id,
|
|
312
|
+
)}&slide=${activeIdx}`;
|
|
313
|
+
navigator.clipboard?.writeText(url).catch(() => {});
|
|
314
|
+
setCopied(true);
|
|
315
|
+
window.setTimeout(() => setCopied(false), 1500);
|
|
316
|
+
};
|
|
317
|
+
|
|
318
|
+
const handleShare = () => {
|
|
319
|
+
if (!internalItem) return;
|
|
320
|
+
if (onShare) onShare(internalItem, activeIdx);
|
|
321
|
+
// eslint-disable-next-line no-console
|
|
322
|
+
else
|
|
323
|
+
console.log(
|
|
324
|
+
"[LightboxModal] Share:",
|
|
325
|
+
internalItem.id,
|
|
326
|
+
"slide",
|
|
327
|
+
activeIdx,
|
|
328
|
+
);
|
|
329
|
+
};
|
|
330
|
+
|
|
331
|
+
const handleFavorite = () => {
|
|
332
|
+
if (!internalItem || !onToggleFavorite) return;
|
|
333
|
+
onToggleFavorite(internalItem);
|
|
334
|
+
};
|
|
335
|
+
|
|
336
|
+
if (typeof document === "undefined") return null;
|
|
337
|
+
if (!internalItem) return null;
|
|
338
|
+
|
|
339
|
+
const slides = internalItem.slides ?? [];
|
|
340
|
+
const activeSlide = slides[activeIdx];
|
|
341
|
+
const stateClass = isClosing ? styles.isClosing : styles.isOpen;
|
|
342
|
+
|
|
343
|
+
return createPortal(
|
|
344
|
+
<>
|
|
345
|
+
<div
|
|
346
|
+
ref={backdropRef}
|
|
347
|
+
className={`${styles.backdrop} ${stateClass}`}
|
|
348
|
+
onClick={handleBackdropClick}
|
|
349
|
+
role="dialog"
|
|
350
|
+
aria-modal="true"
|
|
351
|
+
aria-label={internalItem.title ?? "Artwork"}
|
|
352
|
+
>
|
|
353
|
+
<div
|
|
354
|
+
ref={modalRef}
|
|
355
|
+
className={styles.modal}
|
|
356
|
+
onAnimationEnd={handleAnimationEnd}
|
|
357
|
+
>
|
|
358
|
+
{/* Images column */}
|
|
359
|
+
<div className={styles.imagesColumn}>
|
|
360
|
+
{slides.length === 0 ? (
|
|
361
|
+
<div className={styles.empty}>No images for this artwork.</div>
|
|
362
|
+
) : (
|
|
363
|
+
slides.map((slide, idx) => (
|
|
364
|
+
<div
|
|
365
|
+
key={idx}
|
|
366
|
+
ref={(el) => {
|
|
367
|
+
slideRefs.current[idx] = el;
|
|
368
|
+
}}
|
|
369
|
+
className={styles.slideEntry}
|
|
370
|
+
data-active={idx === activeIdx ? "true" : "false"}
|
|
371
|
+
>
|
|
372
|
+
<div className={styles.slideImageWrap}>
|
|
373
|
+
{slide.src ? (
|
|
374
|
+
<Image
|
|
375
|
+
className={styles.slideImage}
|
|
376
|
+
src={slide.src}
|
|
377
|
+
alt={slide.alt ?? slide.title ?? ""}
|
|
378
|
+
draggable={false}
|
|
379
|
+
fill
|
|
380
|
+
/>
|
|
381
|
+
) : (
|
|
382
|
+
<div
|
|
383
|
+
className={styles.slideImagePlaceholder}
|
|
384
|
+
aria-hidden
|
|
385
|
+
/>
|
|
386
|
+
)}
|
|
387
|
+
<div className={styles.slideDownloadBtn}>
|
|
388
|
+
<Button
|
|
389
|
+
type="button"
|
|
390
|
+
onClick={(e) => handleDownload(slide.src, e)}
|
|
391
|
+
aria-label="Download image"
|
|
392
|
+
text
|
|
393
|
+
>
|
|
394
|
+
<Icon systemName="download" />
|
|
395
|
+
</Button>
|
|
396
|
+
</div>
|
|
397
|
+
</div>
|
|
398
|
+
{(slide.title || slide.comment) && (
|
|
399
|
+
<div className={styles.slideMeta}>
|
|
400
|
+
{slide.title && (
|
|
401
|
+
<h3 className={styles.slideTitle}>{slide.title}</h3>
|
|
402
|
+
)}
|
|
403
|
+
{slide.comment && (
|
|
404
|
+
<p className={styles.slideComment}>{slide.comment}</p>
|
|
405
|
+
)}
|
|
406
|
+
</div>
|
|
407
|
+
)}
|
|
408
|
+
</div>
|
|
409
|
+
))
|
|
410
|
+
)}
|
|
411
|
+
</div>
|
|
412
|
+
|
|
413
|
+
{/* Sticky info panel */}
|
|
414
|
+
<aside className={styles.infoPanel}>
|
|
415
|
+
<div className={styles.closeBtn}>
|
|
416
|
+
<Button
|
|
417
|
+
type="button"
|
|
418
|
+
onClick={onClose}
|
|
419
|
+
aria-label="Close"
|
|
420
|
+
text={!isMobile}
|
|
421
|
+
secondary={!!isMobile}
|
|
422
|
+
>
|
|
423
|
+
<Icon systemName="close" />
|
|
424
|
+
</Button>
|
|
425
|
+
</div>
|
|
426
|
+
<div className={styles.infoHeader}>
|
|
427
|
+
{internalItem.author && (
|
|
428
|
+
<div className={styles.author}>{internalItem.author}</div>
|
|
429
|
+
)}
|
|
430
|
+
{internalItem.title && (
|
|
431
|
+
<h2 className={styles.itemTitle}>{internalItem.title}</h2>
|
|
432
|
+
)}
|
|
433
|
+
{internalItem.description && (
|
|
434
|
+
<p className={styles.itemDescription}>
|
|
435
|
+
{internalItem.description}
|
|
436
|
+
</p>
|
|
437
|
+
)}
|
|
438
|
+
</div>
|
|
439
|
+
<div className={styles.fl_actions}>
|
|
440
|
+
<Button.group
|
|
441
|
+
multiSelect
|
|
442
|
+
primary
|
|
443
|
+
width={"fullWidth"}
|
|
444
|
+
cta={{
|
|
445
|
+
systemName: "favorite",
|
|
446
|
+
onClick: handleFavorite,
|
|
447
|
+
toggle: true,
|
|
448
|
+
tertiary: true,
|
|
449
|
+
circle: true,
|
|
450
|
+
}}
|
|
451
|
+
>
|
|
452
|
+
<Button.group.Tab
|
|
453
|
+
systemName="ios_share"
|
|
454
|
+
label="Share"
|
|
455
|
+
circle
|
|
456
|
+
onClick={handleShare}
|
|
457
|
+
/>
|
|
458
|
+
<Button.group.Tab
|
|
459
|
+
systemName="link"
|
|
460
|
+
circle
|
|
461
|
+
label="Copy link"
|
|
462
|
+
toggle
|
|
463
|
+
onClick={handleCopy}
|
|
464
|
+
/>
|
|
465
|
+
</Button.group>
|
|
466
|
+
</div>
|
|
467
|
+
{slides.length > 0 && (
|
|
468
|
+
<>
|
|
469
|
+
<Sinewave width={200} height={10} frequency={8} />
|
|
470
|
+
<div className={styles.currentSlide}>
|
|
471
|
+
<div className={styles.currentSlideLabel}>
|
|
472
|
+
Slide {activeIdx + 1} of {slides.length}
|
|
473
|
+
</div>
|
|
474
|
+
{activeSlide?.title && (
|
|
475
|
+
<h3 className={styles.currentSlideTitle}>
|
|
476
|
+
{activeSlide.title}
|
|
477
|
+
</h3>
|
|
478
|
+
)}
|
|
479
|
+
{activeSlide?.comment && (
|
|
480
|
+
<p className={styles.currentSlideComment}>
|
|
481
|
+
{activeSlide.comment}
|
|
482
|
+
</p>
|
|
483
|
+
)}
|
|
484
|
+
</div>
|
|
485
|
+
</>
|
|
486
|
+
)}
|
|
487
|
+
</aside>
|
|
488
|
+
</div>
|
|
489
|
+
{isBottomSheet && (
|
|
490
|
+
<div
|
|
491
|
+
ref={stretchFillerRef}
|
|
492
|
+
className={styles.stretchFiller}
|
|
493
|
+
aria-hidden
|
|
494
|
+
/>
|
|
495
|
+
)}
|
|
496
|
+
</div>
|
|
497
|
+
</>,
|
|
498
|
+
document.body,
|
|
499
|
+
);
|
|
500
|
+
}
|