@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,196 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useEffect, useRef, useState } from "react";
|
|
4
|
+
import { animate, useMotionValue } from "framer-motion";
|
|
5
|
+
|
|
6
|
+
type PullSheetOptions = {
|
|
7
|
+
/** Controlled open state (menu button / programmatic). */
|
|
8
|
+
open: boolean;
|
|
9
|
+
setOpen: (open: boolean) => void;
|
|
10
|
+
/** Wrapper that catches the touches (the whole bar container). */
|
|
11
|
+
surfaceRef: React.RefObject<HTMLElement | null>;
|
|
12
|
+
/** Inner scroller — touches starting here scroll natively, never drag. */
|
|
13
|
+
scrollRef?: React.RefObject<HTMLElement | null>;
|
|
14
|
+
/** Returns the panel's open height in px (e.g. 98dvh minus the button row). */
|
|
15
|
+
getMaxHeight: () => number;
|
|
16
|
+
/**
|
|
17
|
+
* Gate + mount signal. Pass `!!isMobile`. The variant mounts late
|
|
18
|
+
* (useMediaQuery resolves false→true on the client); flipping this re-runs
|
|
19
|
+
* the effects so they bind once the elements exist, instead of running while
|
|
20
|
+
* the refs are still null and bailing.
|
|
21
|
+
*/
|
|
22
|
+
enabled?: boolean;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const TAP_THRESHOLD = 8; // px before a touch counts as a drag
|
|
26
|
+
const AXIS_LOCK_RATIO = 1.2; // |dy| must beat |dx| by this to claim vertical
|
|
27
|
+
const OPEN_FRACTION = 0.4; // released past this fraction of open → snap open
|
|
28
|
+
const FLICK_VELOCITY = 0.5; // px/ms; a flick this fast forces open/close
|
|
29
|
+
const RUBBER_BAND = 0.2; // resistance past the open limit
|
|
30
|
+
// Bouncy spring tuned to feel like cubic-bezier(0.01, 1.25, 0.23, 1.01):
|
|
31
|
+
// ~25% overshoot, ~500ms settle. Tune stiffness/damping to taste.
|
|
32
|
+
const SNAP_SPRING = {
|
|
33
|
+
type: "spring",
|
|
34
|
+
stiffness: 720,
|
|
35
|
+
damping: 64,
|
|
36
|
+
mass: 2,
|
|
37
|
+
} as const;
|
|
38
|
+
|
|
39
|
+
export function useNavSheetDrag({
|
|
40
|
+
open,
|
|
41
|
+
setOpen,
|
|
42
|
+
surfaceRef,
|
|
43
|
+
scrollRef,
|
|
44
|
+
getMaxHeight,
|
|
45
|
+
enabled = true,
|
|
46
|
+
}: PullSheetOptions) {
|
|
47
|
+
// Height is a motion value → Framer writes it to the DOM off the React render
|
|
48
|
+
// loop, so the per-frame drag never triggers a React re-render.
|
|
49
|
+
const height = useMotionValue(0);
|
|
50
|
+
const [isDragging, setIsDragging] = useState(false);
|
|
51
|
+
const [direction, setDirection] = useState<1 | -1>(1); // 1 = down/open, -1 = up/close
|
|
52
|
+
|
|
53
|
+
const dragging = useRef(false);
|
|
54
|
+
const abandoned = useRef(false);
|
|
55
|
+
const startX = useRef(0);
|
|
56
|
+
const startY = useRef(0);
|
|
57
|
+
const startH = useRef(0);
|
|
58
|
+
const maxH = useRef(0);
|
|
59
|
+
const lastY = useRef(0);
|
|
60
|
+
const lastT = useRef(0);
|
|
61
|
+
const velocity = useRef(0);
|
|
62
|
+
const dirRef = useRef<1 | -1>(1);
|
|
63
|
+
const animRef = useRef<ReturnType<typeof animate> | null>(null);
|
|
64
|
+
|
|
65
|
+
const stopAnim = () => {
|
|
66
|
+
animRef.current?.stop();
|
|
67
|
+
animRef.current = null;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const springTo = (px: number) => {
|
|
71
|
+
stopAnim();
|
|
72
|
+
animRef.current = animate(height, px, SNAP_SPRING);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
// Controlled open (menu button / route change) — skip while a drag owns it.
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
if (!enabled || dragging.current) return;
|
|
78
|
+
springTo(open ? getMaxHeight() : 0);
|
|
79
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
80
|
+
}, [open, enabled]);
|
|
81
|
+
|
|
82
|
+
// Set the initial height once enabled, without animating.
|
|
83
|
+
useEffect(() => {
|
|
84
|
+
if (!enabled) return;
|
|
85
|
+
height.set(open ? getMaxHeight() : 0);
|
|
86
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
87
|
+
}, [enabled]);
|
|
88
|
+
|
|
89
|
+
useEffect(() => {
|
|
90
|
+
if (!enabled) return;
|
|
91
|
+
const surface = surfaceRef.current;
|
|
92
|
+
if (!surface) return;
|
|
93
|
+
|
|
94
|
+
const onStart = (e: TouchEvent) => {
|
|
95
|
+
const t = e.touches[0];
|
|
96
|
+
dragging.current = false;
|
|
97
|
+
abandoned.current = false;
|
|
98
|
+
velocity.current = 0;
|
|
99
|
+
startX.current = t.clientX;
|
|
100
|
+
startY.current = lastY.current = t.clientY;
|
|
101
|
+
lastT.current = e.timeStamp;
|
|
102
|
+
startH.current = height.get(); // interruptible mid-spring
|
|
103
|
+
maxH.current = getMaxHeight();
|
|
104
|
+
|
|
105
|
+
// Open + finger in the scroll list → native scroll owns it.
|
|
106
|
+
// Only hand off to native scroll when the list is actually scrolled —
|
|
107
|
+
// otherwise (items fit, scrollTop 0) the drag hook keeps the gesture so
|
|
108
|
+
// an up-swipe can close the sheet.
|
|
109
|
+
const list = scrollRef?.current;
|
|
110
|
+
if (
|
|
111
|
+
open &&
|
|
112
|
+
list &&
|
|
113
|
+
list.contains(t.target as Node) &&
|
|
114
|
+
list.scrollTop > 0
|
|
115
|
+
) {
|
|
116
|
+
abandoned.current = true;
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
const onMove = (e: TouchEvent) => {
|
|
121
|
+
if (abandoned.current) return;
|
|
122
|
+
const t = e.touches[0];
|
|
123
|
+
const dx = t.clientX - startX.current;
|
|
124
|
+
const dy = t.clientY - startY.current;
|
|
125
|
+
|
|
126
|
+
if (!dragging.current) {
|
|
127
|
+
if (Math.abs(dx) < TAP_THRESHOLD && Math.abs(dy) < TAP_THRESHOLD)
|
|
128
|
+
return;
|
|
129
|
+
if (Math.abs(dy) <= Math.abs(dx) * AXIS_LOCK_RATIO) {
|
|
130
|
+
abandoned.current = true;
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
dragging.current = true;
|
|
134
|
+
setIsDragging(true);
|
|
135
|
+
stopAnim();
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
e.preventDefault(); // we own it → kill page scroll / pull-to-refresh
|
|
139
|
+
|
|
140
|
+
const now = e.timeStamp;
|
|
141
|
+
const dt = now - lastT.current;
|
|
142
|
+
const stepY = t.clientY - lastY.current;
|
|
143
|
+
if (dt > 0) velocity.current = stepY / dt;
|
|
144
|
+
|
|
145
|
+
// Arrow direction follows the finger; only re-render on a real flip.
|
|
146
|
+
if (stepY > 0.5 && dirRef.current !== 1) {
|
|
147
|
+
dirRef.current = 1;
|
|
148
|
+
setDirection(1);
|
|
149
|
+
} else if (stepY < -0.5 && dirRef.current !== -1) {
|
|
150
|
+
dirRef.current = -1;
|
|
151
|
+
setDirection(-1);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
lastY.current = t.clientY;
|
|
155
|
+
lastT.current = now;
|
|
156
|
+
|
|
157
|
+
const M = maxH.current;
|
|
158
|
+
let h = startH.current + dy;
|
|
159
|
+
if (h < 0) h = 0;
|
|
160
|
+
else if (h > M) h = M + (h - M) * RUBBER_BAND; // clamp → no infinite pull
|
|
161
|
+
height.set(h);
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
const settle = () => {
|
|
165
|
+
if (!dragging.current) return;
|
|
166
|
+
dragging.current = false;
|
|
167
|
+
setIsDragging(false);
|
|
168
|
+
const M = maxH.current || getMaxHeight();
|
|
169
|
+
const h = height.get();
|
|
170
|
+
const v = velocity.current;
|
|
171
|
+
|
|
172
|
+
let toOpen: boolean;
|
|
173
|
+
if (v > FLICK_VELOCITY) toOpen = true;
|
|
174
|
+
else if (v < -FLICK_VELOCITY) toOpen = false;
|
|
175
|
+
else toOpen = h > M * OPEN_FRACTION;
|
|
176
|
+
|
|
177
|
+
springTo(toOpen ? M : 0);
|
|
178
|
+
setOpen(toOpen);
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
surface.addEventListener("touchstart", onStart, { passive: true });
|
|
182
|
+
surface.addEventListener("touchmove", onMove, { passive: false });
|
|
183
|
+
surface.addEventListener("touchend", settle, { passive: true });
|
|
184
|
+
surface.addEventListener("touchcancel", settle, { passive: true });
|
|
185
|
+
|
|
186
|
+
return () => {
|
|
187
|
+
surface.removeEventListener("touchstart", onStart);
|
|
188
|
+
surface.removeEventListener("touchmove", onMove);
|
|
189
|
+
surface.removeEventListener("touchend", settle);
|
|
190
|
+
surface.removeEventListener("touchcancel", settle);
|
|
191
|
+
};
|
|
192
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
193
|
+
}, [enabled, open, setOpen, surfaceRef, scrollRef, getMaxHeight]);
|
|
194
|
+
|
|
195
|
+
return { height, isDragging, direction };
|
|
196
|
+
}
|