@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,419 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import React, {
|
|
4
|
+
memo,
|
|
5
|
+
useState,
|
|
6
|
+
useRef,
|
|
7
|
+
useEffect,
|
|
8
|
+
useCallback,
|
|
9
|
+
useContext,
|
|
10
|
+
} from "react";
|
|
11
|
+
import { useRouter, usePathname } from "next/navigation";
|
|
12
|
+
import styles from "./NavNew.module.css";
|
|
13
|
+
import Icon from "@/components/tools/icon/icon";
|
|
14
|
+
import Button from "../../button/button";
|
|
15
|
+
import {
|
|
16
|
+
NavRailProps,
|
|
17
|
+
NavTabInfo,
|
|
18
|
+
NavRailMenuContext,
|
|
19
|
+
NavRailMenuContextValue,
|
|
20
|
+
NavFTBStickyContext,
|
|
21
|
+
NavFTBEmbeddedContext,
|
|
22
|
+
useNavRail,
|
|
23
|
+
useCollapseOnOutsideInteraction,
|
|
24
|
+
} from "./NavContext";
|
|
25
|
+
import NavFTBComponent from "./navftb/NavFTB";
|
|
26
|
+
import type { NavFTBProps } from "./NavContext";
|
|
27
|
+
import { motion } from "framer-motion";
|
|
28
|
+
import FAB from "../../button/FAB";
|
|
29
|
+
import ProgressiveBlur from "@/components/tools/ProgressiveBlur";
|
|
30
|
+
|
|
31
|
+
const NavBar = memo(function NavBar({
|
|
32
|
+
logoUrl,
|
|
33
|
+
accessibilityAriaLabel,
|
|
34
|
+
accessibilityOnClick,
|
|
35
|
+
themeOnClick,
|
|
36
|
+
theme,
|
|
37
|
+
children,
|
|
38
|
+
isExpanded,
|
|
39
|
+
onToggleExpanded,
|
|
40
|
+
style,
|
|
41
|
+
}: NavRailProps) {
|
|
42
|
+
const { isTablet, onCollapse } = useNavRail();
|
|
43
|
+
const pathname = usePathname();
|
|
44
|
+
const router = useRouter();
|
|
45
|
+
|
|
46
|
+
const [isScrolled, setIsScrolled] = useState(false);
|
|
47
|
+
const barRef = useRef<HTMLElement>(null);
|
|
48
|
+
|
|
49
|
+
// ── Mobile sub-tab panel state ─────────────────────────────────────────
|
|
50
|
+
const [menuState, setMenuState] = useState<{
|
|
51
|
+
activeItemPath: string | null;
|
|
52
|
+
activeMenuItemId: string | null;
|
|
53
|
+
tabs: NavTabInfo[];
|
|
54
|
+
expanded: boolean;
|
|
55
|
+
}>({
|
|
56
|
+
activeItemPath: null,
|
|
57
|
+
activeMenuItemId: null,
|
|
58
|
+
tabs: [],
|
|
59
|
+
expanded: false,
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
// Reset tab panel whenever the whole drawer closes
|
|
63
|
+
useEffect(() => {
|
|
64
|
+
if (!isExpanded) {
|
|
65
|
+
setMenuState({
|
|
66
|
+
activeItemPath: null,
|
|
67
|
+
activeMenuItemId: null,
|
|
68
|
+
tabs: [],
|
|
69
|
+
expanded: false,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}, [isExpanded]);
|
|
73
|
+
|
|
74
|
+
const onItemActivated = useCallback(
|
|
75
|
+
(itemId: string, itemPath: string | null, tabs: NavTabInfo[]) => {
|
|
76
|
+
if (tabs.length > 0) {
|
|
77
|
+
setMenuState({
|
|
78
|
+
activeItemPath: itemPath,
|
|
79
|
+
activeMenuItemId: itemId,
|
|
80
|
+
tabs,
|
|
81
|
+
expanded: true,
|
|
82
|
+
});
|
|
83
|
+
} else {
|
|
84
|
+
setMenuState({
|
|
85
|
+
activeItemPath: null,
|
|
86
|
+
activeMenuItemId: null,
|
|
87
|
+
tabs: [],
|
|
88
|
+
expanded: false,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
[],
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
const handleCloseTabPanel = useCallback(() => {
|
|
96
|
+
setMenuState({
|
|
97
|
+
activeItemPath: null,
|
|
98
|
+
activeMenuItemId: null,
|
|
99
|
+
tabs: [],
|
|
100
|
+
expanded: false,
|
|
101
|
+
});
|
|
102
|
+
}, []);
|
|
103
|
+
|
|
104
|
+
const barMenuContextValue: NavRailMenuContextValue = {
|
|
105
|
+
onItemActivated,
|
|
106
|
+
activeMenuItemId: menuState.activeMenuItemId,
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
useEffect(() => {
|
|
110
|
+
const handleScroll = () => {
|
|
111
|
+
setIsScrolled(window.scrollY > 0);
|
|
112
|
+
};
|
|
113
|
+
window.addEventListener("scroll", handleScroll, {
|
|
114
|
+
passive: true,
|
|
115
|
+
capture: true,
|
|
116
|
+
});
|
|
117
|
+
return () =>
|
|
118
|
+
window.removeEventListener("scroll", handleScroll, { capture: true });
|
|
119
|
+
}, []);
|
|
120
|
+
|
|
121
|
+
useCollapseOnOutsideInteraction(
|
|
122
|
+
isExpanded,
|
|
123
|
+
onCollapse ?? (() => {}),
|
|
124
|
+
barRef,
|
|
125
|
+
!!isTablet,
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
const stickyFtbProps = useContext(NavFTBStickyContext)?.ftbProps ?? null;
|
|
129
|
+
const [ftbSlotProps, setFtbSlotProps] = useState<NavFTBProps | null>(null);
|
|
130
|
+
const [ftbSlotVisible, setFtbSlotVisible] = useState(false);
|
|
131
|
+
const ftbExitTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
132
|
+
|
|
133
|
+
useEffect(() => {
|
|
134
|
+
if (stickyFtbProps) {
|
|
135
|
+
if (ftbExitTimerRef.current !== null) {
|
|
136
|
+
clearTimeout(ftbExitTimerRef.current);
|
|
137
|
+
ftbExitTimerRef.current = null;
|
|
138
|
+
}
|
|
139
|
+
setFtbSlotProps(stickyFtbProps);
|
|
140
|
+
const raf = requestAnimationFrame(() => setFtbSlotVisible(true));
|
|
141
|
+
return () => cancelAnimationFrame(raf);
|
|
142
|
+
} else {
|
|
143
|
+
setFtbSlotVisible(false);
|
|
144
|
+
ftbExitTimerRef.current = setTimeout(() => {
|
|
145
|
+
setFtbSlotProps(null);
|
|
146
|
+
ftbExitTimerRef.current = null;
|
|
147
|
+
}, 400);
|
|
148
|
+
}
|
|
149
|
+
}, [stickyFtbProps]);
|
|
150
|
+
|
|
151
|
+
useEffect(
|
|
152
|
+
() => () => {
|
|
153
|
+
if (ftbExitTimerRef.current !== null)
|
|
154
|
+
clearTimeout(ftbExitTimerRef.current);
|
|
155
|
+
},
|
|
156
|
+
[],
|
|
157
|
+
);
|
|
158
|
+
|
|
159
|
+
{
|
|
160
|
+
/*MARK: Tob Bar*/
|
|
161
|
+
}
|
|
162
|
+
const topBar = (
|
|
163
|
+
<motion.div
|
|
164
|
+
initial={false}
|
|
165
|
+
animate={{
|
|
166
|
+
borderRadius:
|
|
167
|
+
ftbSlotVisible || isExpanded
|
|
168
|
+
? "0px 0px 36px 36px"
|
|
169
|
+
: "0px 0px 0px 0px",
|
|
170
|
+
boxShadow:
|
|
171
|
+
ftbSlotVisible || isExpanded
|
|
172
|
+
? "0 1px 1px rgba(0,0,0,0.1), 0 2px 2px rgba(0,0,0,0.1), 0 4px 4px rgba(0,0,0,0.1)"
|
|
173
|
+
: "0 0 0 rgba(0,0,0,0)",
|
|
174
|
+
}}
|
|
175
|
+
transition={{ type: "spring", stiffness: 400, damping: 30 }}
|
|
176
|
+
style={{
|
|
177
|
+
display: "flex",
|
|
178
|
+
flexDirection: "column",
|
|
179
|
+
position: "fixed",
|
|
180
|
+
zIndex: 1001,
|
|
181
|
+
justifyContent: "flex-start",
|
|
182
|
+
alignItems: "flex-start",
|
|
183
|
+
|
|
184
|
+
top: 0,
|
|
185
|
+
overflow: "hidden",
|
|
186
|
+
left: 0,
|
|
187
|
+
|
|
188
|
+
width: "100dvw",
|
|
189
|
+
minHeight: "68px",
|
|
190
|
+
height: "auto",
|
|
191
|
+
maxHeight: "max-content",
|
|
192
|
+
}}
|
|
193
|
+
>
|
|
194
|
+
<ProgressiveBlur
|
|
195
|
+
snapTo="top"
|
|
196
|
+
blur={14}
|
|
197
|
+
definition={7}
|
|
198
|
+
style={{ zIndex: -3 }}
|
|
199
|
+
/>
|
|
200
|
+
|
|
201
|
+
<div
|
|
202
|
+
aria-hidden
|
|
203
|
+
style={{
|
|
204
|
+
position: "absolute",
|
|
205
|
+
inset: 0,
|
|
206
|
+
zIndex: -2,
|
|
207
|
+
pointerEvents: "none",
|
|
208
|
+
background:
|
|
209
|
+
"linear-gradient(to bottom, var(--sys-background) 0%, transparent 100%)",
|
|
210
|
+
}}
|
|
211
|
+
/>
|
|
212
|
+
|
|
213
|
+
<motion.div
|
|
214
|
+
key="navbar-surface-bg"
|
|
215
|
+
aria-hidden
|
|
216
|
+
initial={false}
|
|
217
|
+
animate={{ opacity: ftbSlotVisible || isExpanded ? 1 : 0 }}
|
|
218
|
+
transition={{ duration: 0.3, ease: [0.4, 0, 0.2, 1] }}
|
|
219
|
+
style={{
|
|
220
|
+
position: "absolute",
|
|
221
|
+
inset: 0,
|
|
222
|
+
zIndex: -1,
|
|
223
|
+
borderRadius: "inherit",
|
|
224
|
+
pointerEvents: "none",
|
|
225
|
+
background: "var(--md-sys-color-surface-container-low)",
|
|
226
|
+
borderBottom: "1px solid var(--globalUIBorderCard)",
|
|
227
|
+
}}
|
|
228
|
+
/>
|
|
229
|
+
|
|
230
|
+
{/*MARK: Menu toggle + Logo*/}
|
|
231
|
+
<div
|
|
232
|
+
style={{
|
|
233
|
+
display: "flex",
|
|
234
|
+
alignItems: "center",
|
|
235
|
+
justifyContent: "space-between",
|
|
236
|
+
width: "100%",
|
|
237
|
+
padding: 12,
|
|
238
|
+
}}
|
|
239
|
+
>
|
|
240
|
+
{logoUrl && (
|
|
241
|
+
// eslint-disable-next-line @next/next/no-img-element
|
|
242
|
+
<img alt="Company Logo" src={logoUrl} height={24} width={154} />
|
|
243
|
+
)}
|
|
244
|
+
<Button
|
|
245
|
+
onClick={menuState.expanded ? handleCloseTabPanel : onToggleExpanded}
|
|
246
|
+
type="button"
|
|
247
|
+
outlined
|
|
248
|
+
aria-label={
|
|
249
|
+
menuState.expanded
|
|
250
|
+
? "Back to navigation"
|
|
251
|
+
: isExpanded
|
|
252
|
+
? "Collapse navigation"
|
|
253
|
+
: "Expand navigation"
|
|
254
|
+
}
|
|
255
|
+
style={{ width: 44 }}
|
|
256
|
+
>
|
|
257
|
+
<Icon
|
|
258
|
+
systemName={
|
|
259
|
+
menuState.expanded
|
|
260
|
+
? "arrow_left_alt"
|
|
261
|
+
: isExpanded
|
|
262
|
+
? "menu_open"
|
|
263
|
+
: "menu"
|
|
264
|
+
}
|
|
265
|
+
/>
|
|
266
|
+
</Button>
|
|
267
|
+
</div>
|
|
268
|
+
{/*MARK:NavRail Tabs*/}
|
|
269
|
+
<motion.div
|
|
270
|
+
key="navbar-tabs-panel"
|
|
271
|
+
initial={false}
|
|
272
|
+
animate={{
|
|
273
|
+
height: isExpanded && isTablet ? "calc(90dvh - 94px)" : 0,
|
|
274
|
+
scale: isExpanded && isTablet ? 1 : 0.9,
|
|
275
|
+
opacity: isExpanded && isTablet ? 1 : 0,
|
|
276
|
+
}}
|
|
277
|
+
transition={{ type: "spring", stiffness: 260, damping: 24, mass: 1 }}
|
|
278
|
+
style={{
|
|
279
|
+
width: "100%",
|
|
280
|
+
overflow: "hidden",
|
|
281
|
+
display: "flex",
|
|
282
|
+
flexDirection: "column",
|
|
283
|
+
justifyContent: "flex-start",
|
|
284
|
+
padding: 0,
|
|
285
|
+
}}
|
|
286
|
+
>
|
|
287
|
+
<FAB
|
|
288
|
+
scaleOff
|
|
289
|
+
systemName="search"
|
|
290
|
+
label={"Search"}
|
|
291
|
+
sm
|
|
292
|
+
primary-bold
|
|
293
|
+
style={{
|
|
294
|
+
cursor: "text",
|
|
295
|
+
marginInline: 12,
|
|
296
|
+
marginBottom: 12,
|
|
297
|
+
minHeight: 56,
|
|
298
|
+
}}
|
|
299
|
+
/>
|
|
300
|
+
<div className={styles.navBarPanel}>
|
|
301
|
+
<div
|
|
302
|
+
className={`${styles.navBarPanelItems} ${
|
|
303
|
+
menuState.expanded ? styles.navBarPanelHidden : ""
|
|
304
|
+
}`}
|
|
305
|
+
style={{ padding: 12 }}
|
|
306
|
+
>
|
|
307
|
+
<nav className={styles.navItemsContainer} style={{ gap: "6px" }}>
|
|
308
|
+
{children}
|
|
309
|
+
</nav>
|
|
310
|
+
</div>
|
|
311
|
+
|
|
312
|
+
<div
|
|
313
|
+
className={`${styles.navBarPanelTabs} ${
|
|
314
|
+
menuState.expanded ? styles.navBarPanelVisible : ""
|
|
315
|
+
}`}
|
|
316
|
+
>
|
|
317
|
+
<ul className={styles.navBarMenu}>
|
|
318
|
+
{menuState.tabs.map((tab) => (
|
|
319
|
+
<li
|
|
320
|
+
key={tab.path}
|
|
321
|
+
className={
|
|
322
|
+
pathname === tab.path ? styles.navTabActive : undefined
|
|
323
|
+
}
|
|
324
|
+
onClick={() => {
|
|
325
|
+
router.push(tab.path);
|
|
326
|
+
onCollapse?.();
|
|
327
|
+
}}
|
|
328
|
+
onKeyDown={(e) => {
|
|
329
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
330
|
+
e.preventDefault();
|
|
331
|
+
router.push(tab.path);
|
|
332
|
+
onCollapse?.();
|
|
333
|
+
}
|
|
334
|
+
}}
|
|
335
|
+
role="button"
|
|
336
|
+
tabIndex={0}
|
|
337
|
+
>
|
|
338
|
+
{tab.label}
|
|
339
|
+
</li>
|
|
340
|
+
))}
|
|
341
|
+
</ul>
|
|
342
|
+
</div>
|
|
343
|
+
</div>
|
|
344
|
+
<div
|
|
345
|
+
style={{
|
|
346
|
+
display: "flex",
|
|
347
|
+
justifyContent: "flex-end",
|
|
348
|
+
marginTop: "auto",
|
|
349
|
+
padding: 24,
|
|
350
|
+
gap: 12,
|
|
351
|
+
}}
|
|
352
|
+
>
|
|
353
|
+
{accessibilityAriaLabel && accessibilityOnClick && (
|
|
354
|
+
<Button
|
|
355
|
+
outlined
|
|
356
|
+
aria-label={accessibilityAriaLabel}
|
|
357
|
+
onClick={accessibilityOnClick}
|
|
358
|
+
style={{ width: 56, height: 56, maxHeight: 56 }}
|
|
359
|
+
>
|
|
360
|
+
<Icon systemName="settings_accessibility" />
|
|
361
|
+
</Button>
|
|
362
|
+
)}
|
|
363
|
+
|
|
364
|
+
<Button
|
|
365
|
+
outlined
|
|
366
|
+
aria-label="Light / Dark mode toggle"
|
|
367
|
+
onClick={themeOnClick}
|
|
368
|
+
style={{ width: 56, height: 56, maxHeight: 56 }}
|
|
369
|
+
>
|
|
370
|
+
<Icon systemName={theme === "dark" ? "light_mode" : "dark_mode"} />
|
|
371
|
+
</Button>
|
|
372
|
+
</div>
|
|
373
|
+
</motion.div>
|
|
374
|
+
{/*MARK:FTB Slot*/}
|
|
375
|
+
{ftbSlotProps !== null && (
|
|
376
|
+
<div
|
|
377
|
+
style={{
|
|
378
|
+
display: "grid",
|
|
379
|
+
gridTemplateRows:
|
|
380
|
+
isTablet && ftbSlotVisible && !isExpanded ? "1fr" : "0fr",
|
|
381
|
+
overflowX: "scroll",
|
|
382
|
+
overflowY: "hidden",
|
|
383
|
+
maxHeight: 70,
|
|
384
|
+
width: "100%",
|
|
385
|
+
paddingBottom: isTablet && ftbSlotVisible && !isExpanded ? 14 : 0,
|
|
386
|
+
paddingInline: 2,
|
|
387
|
+
transition:
|
|
388
|
+
"grid-template-rows 360ms cubic-bezier(0.4, 0, 0.2, 1), padding 360ms cubic-bezier(0.4, 0, 0.2, 1)",
|
|
389
|
+
}}
|
|
390
|
+
>
|
|
391
|
+
<div style={{ minHeight: 0 }}>
|
|
392
|
+
<div
|
|
393
|
+
style={{
|
|
394
|
+
opacity: isTablet && ftbSlotVisible ? 1 : 0,
|
|
395
|
+
marginTop: -14,
|
|
396
|
+
filter: `blur(${isTablet && ftbSlotVisible ? 0 : 12}px)`,
|
|
397
|
+
WebkitFilter: `blur(${isTablet && ftbSlotVisible ? 0 : 12}px)`,
|
|
398
|
+
transformOrigin: "top center",
|
|
399
|
+
transition:
|
|
400
|
+
"opacity var(--transition-expressive-color), filter var(--transition-expressive-color), transform 400ms cubic-bezier(0.34, 1.2, 0.64, 1)",
|
|
401
|
+
}}
|
|
402
|
+
>
|
|
403
|
+
<NavFTBEmbeddedContext.Provider value={true}>
|
|
404
|
+
<NavFTBComponent {...ftbSlotProps} />
|
|
405
|
+
</NavFTBEmbeddedContext.Provider>
|
|
406
|
+
</div>
|
|
407
|
+
</div>
|
|
408
|
+
</div>
|
|
409
|
+
)}
|
|
410
|
+
</motion.div>
|
|
411
|
+
);
|
|
412
|
+
return (
|
|
413
|
+
<NavRailMenuContext.Provider value={barMenuContextValue}>
|
|
414
|
+
<div style={style}>{topBar}</div>
|
|
415
|
+
</NavRailMenuContext.Provider>
|
|
416
|
+
);
|
|
417
|
+
});
|
|
418
|
+
|
|
419
|
+
export default NavBar;
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import React, { createContext, useContext, useEffect } from "react";
|
|
4
|
+
|
|
5
|
+
// ── Types ─────────────────────────────────────────────────────────────────────
|
|
6
|
+
export type NavProps = {
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
isExpanded: boolean;
|
|
9
|
+
onCollapse?: () => void;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export type NavRailProps = {
|
|
13
|
+
logoUrl: string;
|
|
14
|
+
accessibilityAriaLabel?: string;
|
|
15
|
+
accessibilityOnClick?: () => void;
|
|
16
|
+
themeOnClick: () => void;
|
|
17
|
+
theme?: "light" | "dark";
|
|
18
|
+
children?: React.ReactNode;
|
|
19
|
+
isExpanded: boolean;
|
|
20
|
+
onToggleExpanded: () => void;
|
|
21
|
+
style?: React.CSSProperties;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export type NavItemProps = {
|
|
25
|
+
label?: string;
|
|
26
|
+
systemName: string;
|
|
27
|
+
path?: string;
|
|
28
|
+
default?: boolean;
|
|
29
|
+
children?: React.ReactNode;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export type NavTabProps = {
|
|
33
|
+
path: string;
|
|
34
|
+
label: string;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
// Internal data-transfer type — communicates between Nav.Item and Nav.Rail's sub-menu.
|
|
38
|
+
export type NavTabInfo = {
|
|
39
|
+
path: string;
|
|
40
|
+
label: string;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export type NavSectionProps = {
|
|
44
|
+
children?: React.ReactNode;
|
|
45
|
+
paddingInline?: number;
|
|
46
|
+
direction?: "row" | "column";
|
|
47
|
+
title?: string;
|
|
48
|
+
comment?: string;
|
|
49
|
+
fullWidth?: boolean;
|
|
50
|
+
variant?: "transparent" | "bordered" | "opaque" | "gradient";
|
|
51
|
+
style?: React.CSSProperties;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// ── FTB (Floating Tab Bar) ────────────────────────────────────────────────────
|
|
55
|
+
|
|
56
|
+
export type FTBTab = {
|
|
57
|
+
label: string;
|
|
58
|
+
systemName: string;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export type NavFTBProps = {
|
|
62
|
+
id: string;
|
|
63
|
+
tabs: FTBTab[];
|
|
64
|
+
onTabChange?: (index: number) => void;
|
|
65
|
+
activeTabId?: string;
|
|
66
|
+
inSection?: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Controlled selected index. Used internally when NavFTB is rendered as an
|
|
69
|
+
* embedded copy inside NavBar — the root instance drives selection via this
|
|
70
|
+
* prop so there is a single source of truth and no drift can occur.
|
|
71
|
+
* External callers should use activeTabId instead.
|
|
72
|
+
*/
|
|
73
|
+
selectedIndex?: number;
|
|
74
|
+
children?: React.ReactNode;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export type FTBRefProps = {
|
|
78
|
+
forLabel: string;
|
|
79
|
+
/** Mark this Ref as the initially selected tab. Exactly one Ref should have this. */
|
|
80
|
+
defaultTab?: boolean;
|
|
81
|
+
children?: React.ReactNode;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
// ── NavFTB Sticky Context ─────────────────────────────────────────────────────
|
|
85
|
+
// Shared between NavFTB (producer) and NavBar (consumer) so that when the FTB
|
|
86
|
+
// enters sticky/elevated mode on mobile it can be mirrored inside the top bar.
|
|
87
|
+
|
|
88
|
+
export type NavFTBStickyContextValue = {
|
|
89
|
+
ftbProps: NavFTBProps | null;
|
|
90
|
+
setFtbProps: (props: NavFTBProps | null) => void;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export const NavFTBStickyContext =
|
|
94
|
+
createContext<NavFTBStickyContextValue | null>(null);
|
|
95
|
+
|
|
96
|
+
// ── NavFTB Group Context ──────────────────────────────────────────────────────
|
|
97
|
+
// Provided by NavFTB and consumed by FTBRef to show/hide content panels.
|
|
98
|
+
|
|
99
|
+
export type NavFTBGroupContextValue = {
|
|
100
|
+
selectedLabel: string;
|
|
101
|
+
selectedIndex: number;
|
|
102
|
+
tabs: FTBTab[];
|
|
103
|
+
/** Switch the active tab by index or by label (case-insensitive). */
|
|
104
|
+
selectTab: (target: number | string) => void;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export const NavFTBGroupContext = createContext<NavFTBGroupContextValue | null>(
|
|
108
|
+
null,
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
// Consume inside any component rendered within <Nav.FTB> (e.g. an FTB.Ref child)
|
|
112
|
+
// to programmatically switch tabs — handy for "next/previous" navigation cards.
|
|
113
|
+
export function useFTBNav() {
|
|
114
|
+
const ctx = useContext(NavFTBGroupContext);
|
|
115
|
+
if (!ctx && process.env.NODE_ENV !== "production") {
|
|
116
|
+
console.error("useFTBNav() must be used within <Nav.FTB>");
|
|
117
|
+
}
|
|
118
|
+
return ctx;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Set to `true` when NavFTB is rendered embedded inside NavBar.
|
|
123
|
+
* Prevents the embedded instance from re-registering into the sticky context
|
|
124
|
+
* and causing an infinite update loop.
|
|
125
|
+
*/
|
|
126
|
+
export const NavFTBEmbeddedContext = createContext<boolean>(false);
|
|
127
|
+
|
|
128
|
+
// ── NavContext ────────────────────────────────────────────────────────────────
|
|
129
|
+
|
|
130
|
+
type NavContextValue = { inNav: true };
|
|
131
|
+
export const NavContext = createContext<NavContextValue | null>(null);
|
|
132
|
+
|
|
133
|
+
export function useNav() {
|
|
134
|
+
const ctx = useContext(NavContext);
|
|
135
|
+
if (!ctx && process.env.NODE_ENV !== "production") {
|
|
136
|
+
console.error("<Nav.* /> components must be used within <Nav />");
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// ── NavRailContext ────────────────────────────────────────────────────────────
|
|
141
|
+
|
|
142
|
+
export type NavRailContextValue = {
|
|
143
|
+
activePath: string;
|
|
144
|
+
navigate: (path: string) => void;
|
|
145
|
+
isExpanded: boolean;
|
|
146
|
+
isMobile?: boolean;
|
|
147
|
+
isTablet?: boolean;
|
|
148
|
+
onCollapse?: () => void;
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
export const NavRailContext = createContext<NavRailContextValue | null>(null);
|
|
152
|
+
|
|
153
|
+
// ── NavHeader overlay ─────────────────────────────────────────────────────────
|
|
154
|
+
// Published by Nav.Header, read by Nav.Content's dim so the mega menu shares the
|
|
155
|
+
// existing backdrop without touching the rail/drawer isExpanded flag.
|
|
156
|
+
export type NavHeaderOverlayState = { isOpen: boolean; close: () => void };
|
|
157
|
+
export type NavHeaderOverlayContextValue = {
|
|
158
|
+
overlay: NavHeaderOverlayState | null;
|
|
159
|
+
setOverlay: (s: NavHeaderOverlayState | null) => void;
|
|
160
|
+
};
|
|
161
|
+
export const NavHeaderOverlayContext =
|
|
162
|
+
createContext<NavHeaderOverlayContextValue | null>(null);
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* True as soon as a <Nav.Header> is mounted anywhere in the tree, false once
|
|
166
|
+
* it unmounts. Nav.Header publishes a non-null `overlay` the instant it
|
|
167
|
+
* mounts (before any mega menu ever opens) and clears it back to null on
|
|
168
|
+
* unmount — so `overlay !== null` doubles as "is Nav.Header present", with
|
|
169
|
+
* no extra plumbing needed beyond the existing overlay/dim context.
|
|
170
|
+
*/
|
|
171
|
+
export function useHasHeader() {
|
|
172
|
+
const ctx = useContext(NavHeaderOverlayContext);
|
|
173
|
+
return ctx?.overlay != null;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// Fallback used only during Fast Refresh re-evaluation.
|
|
177
|
+
export const FALLBACK_NAV_RAIL_CTX: NavRailContextValue = {
|
|
178
|
+
activePath: "",
|
|
179
|
+
navigate: () => {},
|
|
180
|
+
isExpanded: false,
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
export function useNavRail(): NavRailContextValue {
|
|
184
|
+
const ctx = useContext(NavRailContext);
|
|
185
|
+
if (!ctx) {
|
|
186
|
+
if (process.env.NODE_ENV !== "production") {
|
|
187
|
+
console.error("<Nav.Item /> must be used within <Nav.Rail />");
|
|
188
|
+
}
|
|
189
|
+
return FALLBACK_NAV_RAIL_CTX;
|
|
190
|
+
}
|
|
191
|
+
return ctx;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// ── NavItemContext ────────────────────────────────────────────────────────────
|
|
195
|
+
|
|
196
|
+
export type NavItemContextValue = { inNavItem: true; itemPath: string | null };
|
|
197
|
+
export const NavItemContext = createContext<NavItemContextValue | null>(null);
|
|
198
|
+
|
|
199
|
+
// ── NavRailMenuContext ────────────────────────────────────────────────────────
|
|
200
|
+
|
|
201
|
+
export type NavRailMenuContextValue = {
|
|
202
|
+
onItemActivated: (
|
|
203
|
+
itemId: string,
|
|
204
|
+
path: string | null,
|
|
205
|
+
tabs: NavTabInfo[],
|
|
206
|
+
) => void;
|
|
207
|
+
/** The useId() of the Nav.Item whose tabs are currently displayed in the open panel, or null. */
|
|
208
|
+
activeMenuItemId: string | null;
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
export const NavRailMenuContext = createContext<NavRailMenuContextValue | null>(
|
|
212
|
+
null,
|
|
213
|
+
);
|
|
214
|
+
|
|
215
|
+
// ── useCollapseOnOutsideInteraction ───────────────────────────────────────────
|
|
216
|
+
|
|
217
|
+
// Collapses the nav on scroll (always) and, when a ref is provided,
|
|
218
|
+
// on any pointerdown outside that element. Used by both Nav.Bar and Nav.Rail.
|
|
219
|
+
export function useCollapseOnOutsideInteraction(
|
|
220
|
+
isExpanded: boolean,
|
|
221
|
+
collapse: () => void,
|
|
222
|
+
ref?: React.RefObject<HTMLElement | null>,
|
|
223
|
+
// Only the currently-visible nav variant should register listeners.
|
|
224
|
+
// Both Nav.Bar and Nav.Rail are always in the DOM (CSS-hidden), so without
|
|
225
|
+
// this guard both hooks fire simultaneously — two toggles cancel each other
|
|
226
|
+
// out and the nav never closes.
|
|
227
|
+
enabled: boolean = true,
|
|
228
|
+
) {
|
|
229
|
+
useEffect(() => {
|
|
230
|
+
if (!isExpanded || !enabled) return;
|
|
231
|
+
|
|
232
|
+
const onScroll = (e: Event) => {
|
|
233
|
+
// Don't collapse when the scroll originates inside the nav element itself
|
|
234
|
+
if (ref?.current && ref.current.contains(e.target as Node)) return;
|
|
235
|
+
collapse();
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
// capture: true is required because DOM scroll events do NOT bubble.
|
|
239
|
+
window.addEventListener("scroll", onScroll, {
|
|
240
|
+
passive: true,
|
|
241
|
+
capture: true,
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
const onPointerDown = ref
|
|
245
|
+
? (e: PointerEvent) => {
|
|
246
|
+
if (ref.current && !ref.current.contains(e.target as Node))
|
|
247
|
+
collapse();
|
|
248
|
+
}
|
|
249
|
+
: undefined;
|
|
250
|
+
if (onPointerDown)
|
|
251
|
+
window.addEventListener("pointerdown", onPointerDown, { passive: true });
|
|
252
|
+
|
|
253
|
+
return () => {
|
|
254
|
+
window.removeEventListener("scroll", onScroll, { capture: true });
|
|
255
|
+
if (onPointerDown)
|
|
256
|
+
window.removeEventListener("pointerdown", onPointerDown);
|
|
257
|
+
};
|
|
258
|
+
}, [isExpanded, collapse, ref, enabled]);
|
|
259
|
+
}
|