@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.
Files changed (87) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +101 -0
  3. package/package.json +49 -0
  4. package/scripts/postinstall.js +105 -0
  5. package/template/app/ClientNav.tsx +310 -0
  6. package/template/app/globals.css +167 -0
  7. package/template/app/layout.tsx +128 -0
  8. package/template/app/themes/dark-mc.css +51 -0
  9. package/template/app/themes/dark.css +51 -0
  10. package/template/app/themes/light-mc.css +51 -0
  11. package/template/app/themes/light.css +51 -0
  12. package/template/app/themes/theme.css +82 -0
  13. package/template/components/layout/Lightbox/LightboxCard.tsx +100 -0
  14. package/template/components/layout/Lightbox/LightboxGallery.module.css +249 -0
  15. package/template/components/layout/Lightbox/LightboxGallery.tsx +72 -0
  16. package/template/components/layout/Lightbox/LightboxGrid.tsx +186 -0
  17. package/template/components/layout/Lightbox/LightboxModal.module.css +395 -0
  18. package/template/components/layout/Lightbox/LightboxModal.tsx +500 -0
  19. package/template/components/layout/Lightbox/demo.tsx +412 -0
  20. package/template/components/layout/Lightbox/index.ts +30 -0
  21. package/template/components/layout/Lightbox/types.ts +113 -0
  22. package/template/components/layout/Lightbox/useLightboxFilters.ts +140 -0
  23. package/template/components/layout/accordion/Accordion.module.css +149 -0
  24. package/template/components/layout/accordion/Accordion.tsx +114 -0
  25. package/template/components/layout/button/Button.module.css +305 -0
  26. package/template/components/layout/button/ButtonGroup.tsx +503 -0
  27. package/template/components/layout/button/FAB.tsx +118 -0
  28. package/template/components/layout/button/button.tsx +128 -0
  29. package/template/components/layout/button/drop.module.css +229 -0
  30. package/template/components/layout/button/drop.tsx +516 -0
  31. package/template/components/layout/hero/v1/heroSlideshow.module.css +107 -0
  32. package/template/components/layout/hero/v1/heroSlideshow.tsx +233 -0
  33. package/template/components/layout/modals/accessibilityModal/AccessibilityModal.module.css +126 -0
  34. package/template/components/layout/modals/accessibilityModal/AccessibilityModal.tsx +290 -0
  35. package/template/components/layout/modals/alert/Alert.tsx +188 -0
  36. package/template/components/layout/navigation/MioCard.module.css +88 -0
  37. package/template/components/layout/navigation/MioCard.tsx +266 -0
  38. package/template/components/layout/navigation/Wrap.tsx +41 -0
  39. package/template/components/layout/navigation/nav/Nav.module.css +508 -0
  40. package/template/components/layout/navigation/nav/Nav.tsx +167 -0
  41. package/template/components/layout/navigation/nav/NavBar.tsx +419 -0
  42. package/template/components/layout/navigation/nav/NavContext.tsx +259 -0
  43. package/template/components/layout/navigation/nav/NavItem.tsx +173 -0
  44. package/template/components/layout/navigation/nav/NavNew.module.css +373 -0
  45. package/template/components/layout/navigation/nav/NavRail.tsx +315 -0
  46. package/template/components/layout/navigation/nav/NavSection.tsx +102 -0
  47. package/template/components/layout/navigation/nav/NavTab.tsx +25 -0
  48. package/template/components/layout/navigation/nav/navftb/NavFTB.module.css +252 -0
  49. package/template/components/layout/navigation/nav/navftb/NavFTB.tsx +399 -0
  50. package/template/components/layout/navigation/nav/navftb/useTabIndicator.ts +484 -0
  51. package/template/components/layout/navigation/nav/navheader/NavHeader.module.css +59 -0
  52. package/template/components/layout/navigation/nav/navheader/NavHeader.tsx +478 -0
  53. package/template/components/layout/pages/loadingScreen.tsx +102 -0
  54. package/template/components/layout/pages/maintenance/Maintenance.tsx +53 -0
  55. package/template/components/layout/pages/maintenance/maintenance.module.css +163 -0
  56. package/template/components/layout/switch/Switch.module.css +102 -0
  57. package/template/components/layout/switch/Switch.tsx +48 -0
  58. package/template/components/tools/Divider.tsx +11 -0
  59. package/template/components/tools/ProgressiveBlur.tsx +73 -0
  60. package/template/components/tools/ReduceMotionContext.tsx +5 -0
  61. package/template/components/tools/Sinewave.tsx +199 -0
  62. package/template/components/tools/SinewaveProgress.tsx +135 -0
  63. package/template/components/tools/badge/Badge.tsx +28 -0
  64. package/template/components/tools/flubber.d.ts +7 -0
  65. package/template/components/tools/icon/SocialIcons.tsx +88 -0
  66. package/template/components/tools/icon/icon.module.css +0 -0
  67. package/template/components/tools/icon/icon.tsx +125 -0
  68. package/template/components/tools/mobileViewProvider.tsx +58 -0
  69. package/template/components/tools/react-bits/ClickSpark.tsx +177 -0
  70. package/template/components/tools/react-bits/FadeContent.tsx +90 -0
  71. package/template/components/tools/react-bits/GlareHover.tsx +73 -0
  72. package/template/components/tools/react-bits/GradientText/GradientText.css +70 -0
  73. package/template/components/tools/react-bits/GradientText/GradientText.tsx +44 -0
  74. package/template/components/tools/react-bits/Magnet.tsx +118 -0
  75. package/template/components/tools/react-bits/Stepper/Stepper.css +134 -0
  76. package/template/components/tools/react-bits/Stepper/Stepper.tsx +412 -0
  77. package/template/components/tools/ripple/ripple.css +41 -0
  78. package/template/components/tools/ripple/ripple.tsx +53 -0
  79. package/template/components/tools/shape/ShapeLoader.tsx +101 -0
  80. package/template/components/tools/shape/ShapeMorph.tsx +190 -0
  81. package/template/components/tools/shape/ShapePaths.ts +116 -0
  82. package/template/components/tools/switch/Switch.module.css +102 -0
  83. package/template/components/tools/switch/Switch.tsx +48 -0
  84. package/template/components/tools/useBodyScrollLock.tsx +27 -0
  85. package/template/components/tools/useImageColor.ts +47 -0
  86. package/template/components/tools/useNavSheetDrag.tsx +196 -0
  87. package/template/public/fonts/material-symbols/MaterialSymbolsRounded-VariableFont_FILL,GRAD,opsz,wght.woff2 +0 -0
@@ -0,0 +1,508 @@
1
+ .navRail {
2
+ --navRailWidth: 72px;
3
+ display: flex;
4
+ flex-direction: column;
5
+ align-items: flex-start;
6
+ justify-content: space-between;
7
+ z-index: 1001;
8
+ position: fixed;
9
+ top: 0;
10
+ overflow: hidden;
11
+ padding: 12px 0;
12
+ height: 100dvh;
13
+ border: 1px solid red;
14
+ color: var(--md-sys-color-secondary);
15
+ border-radius: 36px;
16
+ width: var(--navRailWidth);
17
+ min-width: var(--navRailWidth);
18
+ background-color: var(--sys-background);
19
+ max-width: var(--navRailWidth);
20
+ box-shadow: none;
21
+ margin: 0;
22
+ transition:
23
+ margin var(--transition-expressive-slow),
24
+ width var(--transition-expressive-slow),
25
+ height var(--transition-expressive-slow),
26
+ max-width var(--transition-expressive-slow),
27
+ box-shadow var(--transition-expressive-color),
28
+ background-color var(--transition-expressive-color),
29
+ border var(--transition-expressive-color),
30
+ min-width var(--transition-expressive-slow);
31
+ }
32
+ .navRail.navRailExpanded {
33
+ width: 234px;
34
+ min-width: 234px;
35
+ max-width: 234px;
36
+ height: calc(100dvh - 24px);
37
+ border: 1px solid var(--globalUIBorderCard);
38
+ margin: 12px;
39
+ background-color: var(--md-sys-color-surface-container-low);
40
+ box-shadow:
41
+ 0 2px 1px rgba(0, 0, 0, 0.1),
42
+ 0 2px 4px rgba(0, 0, 0, 0.05),
43
+ 0 4px 8px rgba(0, 0, 0, 0.05);
44
+ }
45
+ .navRailBottomButtons {
46
+ position: relative;
47
+ display: flex;
48
+ flex-direction: column;
49
+ justify-content: flex-end;
50
+ gap: 4px;
51
+ }
52
+
53
+ .iconStyleNavRail {
54
+ position: relative;
55
+ width: 48px;
56
+ flex-shrink: 0;
57
+ display: flex;
58
+ align-items: center;
59
+ justify-content: center;
60
+ cursor: pointer;
61
+ transition: filter var(--transition-expressive-color);
62
+ }
63
+
64
+ .iconStyleNavRail::after {
65
+ touch-action: manipulation;
66
+ -webkit-tap-highlight-color: transparent;
67
+
68
+ z-index: -1;
69
+ left: -5px;
70
+ transform: translateY(-14px);
71
+ content: "";
72
+ width: 0px;
73
+ height: 32px;
74
+ border-radius: 36px;
75
+ background-color: var(--globalUIBorderCard);
76
+ opacity: 0;
77
+ position: absolute;
78
+ transition:
79
+ opacity 0.1s ease,
80
+ height var(--transition-expressive-slow),
81
+ width var(--transition-expressive-slow),
82
+ box-shadow var(--transition-expressive-color),
83
+ background-color var(--transition-expressive-color);
84
+ }
85
+
86
+ .iconStyleNavRail::before {
87
+ touch-action: manipulation;
88
+ -webkit-tap-highlight-color: transparent;
89
+
90
+ z-index: -1;
91
+ left: -5px;
92
+ transform: translateY(-14px);
93
+ content: "";
94
+ width: 58px;
95
+ height: 32px;
96
+ border-radius: 36px;
97
+ background-color: var(--globalUIBorderCard);
98
+ opacity: 0;
99
+ position: absolute;
100
+ transition:
101
+ opacity 0.1s ease,
102
+ left var(--transition-expressive-slow),
103
+ background-color var(--transition-expressive-color);
104
+ }
105
+
106
+ .navItem:hover .iconStyleNavRail::before {
107
+ opacity: 1;
108
+ transition: opacity 0.2s ease;
109
+ }
110
+
111
+ .iconStyleNavRail.active::after {
112
+ background-color: var(--md-sys-color-primary-container);
113
+ opacity: 1;
114
+ height: 32px;
115
+ width: 58px;
116
+ border: 1px solid var(--globalUIBorder);
117
+ transition:
118
+ opacity 0.1s ease,
119
+ left var(--transition-expressive-slow),
120
+ width var(--transition-expressive-slow),
121
+ height var(--transition-expressive-slow),
122
+ box-shadow var(--transition-expressive-color),
123
+ background-color var(--transition-expressive-color);
124
+ }
125
+
126
+ .iconStyleNavRail.expanded::after {
127
+ width: 112px;
128
+ height: 56px;
129
+ transition:
130
+ opacity var(--transition-expressive-color),
131
+ width var(--transition-expressive-slow),
132
+ height var(--transition-expressive-slow),
133
+ background-color var(--transition-expressive-color);
134
+ }
135
+ .iconStyleNavRail.active.expanded::after {
136
+ height: 56px;
137
+ width: 206px;
138
+ box-shadow:
139
+ 0 1px 2px rgba(0, 0, 0, 0.2),
140
+ 0 2px 4px rgba(0, 0, 0, 0.1);
141
+ transition:
142
+ height var(--transition-expressive-slow),
143
+ width var(--transition-expressive-slow);
144
+ }
145
+ .iconStyleNavRail.expanded::before {
146
+ background-color: var(--md-sys-color-surface-container-highest);
147
+ width: 206px;
148
+ height: 56px;
149
+ transition: opacity 0.2s ease;
150
+ }
151
+ /*--------------Navigations and sections-------------*/
152
+ .mainNavContent {
153
+ position: relative;
154
+ width: 100%;
155
+ min-width: 0;
156
+ height: fit-content;
157
+ min-height: 100dvh;
158
+ gap: 12px;
159
+ overflow: visible;
160
+ display: flex;
161
+ flex-direction: column;
162
+ }
163
+
164
+ .navSection {
165
+ position: relative;
166
+ width: 100%;
167
+ height: fit-content;
168
+ display: flex;
169
+ flex-direction: column;
170
+ align-items: center;
171
+ justify-content: flex-start;
172
+ border-radius: 36px;
173
+ transition:
174
+ background-color var(--transition-expressive-color),
175
+ border var(--transition-expressive-color);
176
+ }
177
+
178
+ :global([data-show-borders="true"]) .navSection {
179
+ border: var(--a11y-border) !important;
180
+ }
181
+
182
+ :global([data-show-borders="true"]) .iconStyleNavRail.active::after {
183
+ border: var(--a11y-border) !important;
184
+ }
185
+
186
+ /* Top section: menu button + logo */
187
+ .navRailTopSection {
188
+ display: flex;
189
+ flex-direction: column;
190
+ align-items: flex-start;
191
+ gap: 12px;
192
+ width: 100%;
193
+ margin-bottom: 20px;
194
+ }
195
+
196
+ /* Menu button shifts right when expanded */
197
+ .navRailMenuButtonWrapper {
198
+ display: flex;
199
+ justify-content: flex-end;
200
+ width: 100%;
201
+ padding: 0 14px;
202
+ position: relative;
203
+ transition: transform var(--transition-expressive-slow);
204
+ }
205
+
206
+ .navRailCTAWrapper {
207
+ display: flex;
208
+ justify-content: flex-start;
209
+ width: 100%;
210
+ padding: 0 20px;
211
+ position: relative;
212
+ }
213
+
214
+ /* Scrollable middle area */
215
+ .navRailScrollContainer {
216
+ display: flex;
217
+ flex-direction: column;
218
+ align-items: flex-start;
219
+ justify-content: space-between;
220
+ overflow-x: hidden;
221
+ overflow-y: auto;
222
+ max-width: var(--navRailWidth);
223
+ min-width: var(--navRailWidth);
224
+ height: 100%;
225
+ gap: 12px;
226
+ transition:
227
+ max-width var(--transition-expressive-slow),
228
+ min-width var(--transition-expressive-slow);
229
+ }
230
+
231
+ .navRailScrollContainer.navRailExpanded {
232
+ max-width: 228px;
233
+ min-width: 228px;
234
+ }
235
+
236
+ /* Items list: gap + margin change on expand */
237
+ .navItemsContainer {
238
+ display: flex;
239
+ justify-content: flex-start;
240
+ align-items: flex-start;
241
+ flex-direction: column;
242
+ gap: 12px;
243
+ width: 100%;
244
+ padding-top: 4px;
245
+ transition:
246
+ gap var(--transition-expressive-slow),
247
+ margin-top var(--transition-expressive-slow);
248
+ }
249
+
250
+ .navItemsContainer.navRailExpanded {
251
+ gap: 6px;
252
+ margin-top: 12px;
253
+ }
254
+
255
+ /* Nav item row */
256
+ .navItem {
257
+ cursor: pointer;
258
+ display: flex;
259
+ flex-direction: row;
260
+ align-items: flex-start;
261
+ justify-content: flex-start;
262
+ flex-wrap: nowrap;
263
+ flex-shrink: 0;
264
+ flex-grow: 0;
265
+ width: 100%;
266
+ position: relative;
267
+ margin-left: 18px;
268
+ filter: brightness(1);
269
+ transition: filter var(--transition-expressive-color);
270
+ }
271
+
272
+ .navItemMobile {
273
+ margin-left: 0;
274
+ }
275
+
276
+ /* ── Nav item side label (always in DOM, CSS-animated) ───────────────────── */
277
+ .navItemLabel {
278
+ display: flex;
279
+ align-items: center;
280
+ justify-content: flex-start;
281
+ overflow: hidden;
282
+ opacity: 0;
283
+ transform: translateX(-8px);
284
+ pointer-events: none;
285
+ flex-shrink: 0;
286
+ max-width: 0;
287
+ transition:
288
+ opacity var(--transition-expressive-color),
289
+ transform var(--transition-expressive-slow),
290
+ max-width var(--transition-expressive-slow);
291
+ }
292
+
293
+ .navItemLabel.navRailExpanded {
294
+ max-width: 160px;
295
+ opacity: 1;
296
+ transform: translateX(0);
297
+ pointer-events: auto;
298
+ }
299
+
300
+ .navItemLabel p {
301
+ overflow: hidden;
302
+ font-weight: 400;
303
+ width: max-content;
304
+ white-space: nowrap;
305
+ }
306
+
307
+ .navItemLabel.active p {
308
+ color: var(--md-sys-color-on-secondary-container);
309
+ }
310
+
311
+ .navRailMenu {
312
+ position: fixed;
313
+ gap: 12px;
314
+ border-radius: 0 36px 36px 0;
315
+
316
+ overflow: hidden;
317
+ opacity: 0;
318
+ display: flex;
319
+ flex-direction: column;
320
+ align-items: flex-end;
321
+ justify-content: flex-start;
322
+
323
+ z-index: 1001;
324
+ margin: 12px;
325
+ width: 278px;
326
+ height: calc(100dvh - 24px);
327
+
328
+ background-color: var(--md-sys-color-surface-container-lowest);
329
+ box-shadow: none;
330
+ border: 1px solid var(--md-sys-color-surface-container-low);
331
+
332
+ transform: translateX(-290px);
333
+ pointer-events: none;
334
+ transition:
335
+ transform var(--transition-expressive-slow),
336
+ box-shadow var(--transition-expressive-color),
337
+ background-color var(--transition-expressive-color),
338
+ opacity var(--transition-expressive-color),
339
+ border var(--transition-expressive-color);
340
+ }
341
+ .navRailMenu.navRailExpanded {
342
+ opacity: 1;
343
+ transform: translateX(194px);
344
+ pointer-events: auto;
345
+ box-shadow:
346
+ 0 1px 2px rgba(0, 0, 0, 0.05),
347
+ 0 2px 4px rgba(0, 0, 0, 0.05),
348
+ 0 4px 8px rgba(0, 0, 0, 0.05);
349
+ }
350
+
351
+ :global(html.dark) .navRailMenu,
352
+ :global(html.dark-medium-contrast) .navRailMenu {
353
+ background-color: var(--md-sys-color-surface);
354
+ }
355
+
356
+ .navRailMenu ul {
357
+ display: flex;
358
+ flex-direction: column;
359
+ justify-content: flex-start;
360
+ padding: 12px;
361
+ margin: 0;
362
+ width: 100%;
363
+ max-width: 230px;
364
+ max-height: calc(100dvh - 48px);
365
+ overflow-x: hidden;
366
+ overflow-y: auto;
367
+ }
368
+
369
+ .navRailMenu ul li {
370
+ position: relative;
371
+ list-style: none;
372
+ height: 48px;
373
+ width: 100%;
374
+ padding: 12px 16px;
375
+ border-radius: 36px;
376
+ cursor: pointer;
377
+ transition: background-color var(--transition-expressive-color);
378
+ }
379
+
380
+ .navRailMenu ul li:hover {
381
+ background-color: var(--md-sys-color-surface-container);
382
+ }
383
+
384
+ .navTabActive {
385
+ background-color: var(--md-sys-color-secondary-container) !important;
386
+ color: var(--md-sys-color-on-secondary-container);
387
+ }
388
+
389
+ /* ── Mobile Bar: two-panel animated layout ──────────────────────────────── */
390
+
391
+ .navBarPanelContainer {
392
+ position: relative;
393
+ flex: 1;
394
+ min-height: 0;
395
+ overflow: hidden;
396
+ width: 100%;
397
+ }
398
+ .navBarPanel {
399
+ position: absolute;
400
+ top: 0;
401
+ left: 0;
402
+ right: 0;
403
+ bottom: 0;
404
+ display: flex;
405
+ flex-direction: column;
406
+ padding-top: 12px;
407
+ transition:
408
+ transform var(--transition-expressive-slow),
409
+ opacity var(--transition-expressive-color);
410
+ }
411
+
412
+ .navBarPanelItems {
413
+ transform: translateX(0);
414
+ opacity: 1;
415
+ pointer-events: auto;
416
+ }
417
+
418
+ .navBarPanelItems.navBarPanelHidden {
419
+ transform: translateX(-60px);
420
+ opacity: 0;
421
+ pointer-events: none;
422
+ }
423
+
424
+ .navBarPanelTabs {
425
+ transform: translateX(60px);
426
+ opacity: 0;
427
+ pointer-events: none;
428
+ }
429
+ .navBarPanelTabs.navBarPanelVisible {
430
+ transform: translateX(0);
431
+ opacity: 1;
432
+ pointer-events: auto;
433
+ }
434
+
435
+ .navBarMenu {
436
+ display: flex;
437
+ flex-direction: column;
438
+ list-style: none;
439
+ padding: 0 12px;
440
+ margin: 0;
441
+ width: 100%;
442
+ overflow-x: hidden;
443
+ overflow-y: auto;
444
+ }
445
+ .navBarMenu li {
446
+ display: flex;
447
+ align-items: center;
448
+ list-style: none;
449
+ height: 48px;
450
+ width: 100%;
451
+ padding: 0 16px;
452
+ border-radius: 36px;
453
+ cursor: pointer;
454
+ transition: background-color var(--transition-expressive-color);
455
+ }
456
+ .navBarMenu li:hover {
457
+ background-color: var(--md-sys-color-surface-container);
458
+ }
459
+
460
+ /* ── Nav.BarPull: pull-down sheet ───────────────────────────────────────── */
461
+ .pullTrackViewport {
462
+ overflow: hidden;
463
+ width: 100%;
464
+ }
465
+ .pullTrack {
466
+ display: flex;
467
+ width: 200%;
468
+ transition: transform var(--transition-expressive-slow);
469
+ }
470
+ .pullTrackPanel {
471
+ width: 50%;
472
+ flex-shrink: 0;
473
+ }
474
+
475
+ .pullHandle {
476
+ display: flex;
477
+ justify-content: center;
478
+ align-items: center;
479
+ height: 36px;
480
+ flex-shrink: 0;
481
+ cursor: grab;
482
+ }
483
+ .pullHandle span {
484
+ width: 32px;
485
+ height: 4px;
486
+ border-radius: 2px;
487
+ background: var(--md-sys-color-outline-variant);
488
+ }
489
+
490
+ /* Pull panel: pill highlights and label fill the full item row */
491
+ .pullTrackPanel .iconStyleNavRail {
492
+ position: static;
493
+ }
494
+ .pullTrackPanel .iconStyleNavRail.expanded::before,
495
+ .pullTrackPanel .navItem:hover .iconStyleNavRail::before {
496
+ width: calc(100% + 6px);
497
+ }
498
+ .pullTrackPanel .iconStyleNavRail.expanded::after,
499
+ .pullTrackPanel .iconStyleNavRail.active.expanded::after {
500
+ width: calc(100% + 6px);
501
+ }
502
+ .pullTrackPanel .navItemLabel.navRailExpanded {
503
+ width: calc(100% + 6px);
504
+ flex: 1;
505
+ }
506
+ .pullHandle:active {
507
+ cursor: grabbing;
508
+ }
@@ -0,0 +1,167 @@
1
+ "use client";
2
+
3
+ import React, {
4
+ useCallback,
5
+ useMemo,
6
+ useState,
7
+ useEffect,
8
+ useContext,
9
+ } from "react";
10
+ import { useRouter, usePathname } from "next/navigation";
11
+ import styles from "./Nav.module.css";
12
+ import {
13
+ BREAKPOINTS,
14
+ useBreakpoints,
15
+ useMediaQuery,
16
+ } from "@/components/tools/mobileViewProvider";
17
+ import {
18
+ NavProps,
19
+ NavRailProps,
20
+ NavItemProps,
21
+ NavTabProps,
22
+ NavSectionProps,
23
+ NavContext,
24
+ NavRailContext,
25
+ NavRailContextValue,
26
+ NavFTBStickyContext,
27
+ useNavRail,
28
+ useHasHeader,
29
+ } from "./NavContext";
30
+ import NavRailComponent from "./NavRail";
31
+ import NavBarComponent from "./NavBar";
32
+ import NavItemComponent from "./NavItem";
33
+ import NavTabComponent from "./NavTab";
34
+ import NavSectionComponent from "./NavSection";
35
+ import NavFTBComponent from "./navftb/NavFTB";
36
+ import type { NavFTBProps, FTBRefProps } from "./NavContext";
37
+ import NavHeaderComponent from "./navheader/NavHeader";
38
+ import { NavHeaderOverlayContext } from "./NavContext";
39
+ import type { NavHeaderOverlayState } from "./NavContext";
40
+
41
+ type NavComponent = React.FC<NavProps> & {
42
+ Rail: React.FC<NavRailProps>;
43
+ Item: React.FC<NavItemProps>;
44
+ Tab: React.FC<NavTabProps>;
45
+ Content: React.FC<{ children?: React.ReactNode }>;
46
+ Section: React.FC<NavSectionProps>;
47
+ Bar: React.FC<NavRailProps>;
48
+ FTB: React.FC<NavFTBProps> & { Ref: React.FC<FTBRefProps> };
49
+ Header: typeof NavHeaderComponent;
50
+ };
51
+
52
+ const Nav: NavComponent = Object.assign(
53
+ function Nav({ children, isExpanded, onCollapse }: NavProps) {
54
+ const router = useRouter();
55
+ const pathname = usePathname();
56
+ const { isMobile, isTablet } = useBreakpoints();
57
+
58
+ // Optimistic path: set immediately on click so items never flash back to
59
+ // the previous active state while the router is still resolving.
60
+ // Cleared as soon as pathname catches up.
61
+ const [optimisticPath, setOptimisticPath] = useState<string | null>(null);
62
+ useEffect(() => {
63
+ if (optimisticPath && pathname === optimisticPath) {
64
+ setOptimisticPath(null);
65
+ }
66
+ }, [pathname, optimisticPath]);
67
+
68
+ const activePath = optimisticPath ?? pathname;
69
+
70
+ const navigate = useCallback(
71
+ (path: string) => {
72
+ setOptimisticPath(path);
73
+ router.push(path);
74
+ },
75
+ [router],
76
+ );
77
+
78
+ const railContextValue = useMemo<NavRailContextValue>(
79
+ () => ({
80
+ activePath,
81
+ navigate,
82
+ isExpanded,
83
+ isMobile,
84
+ isTablet,
85
+ onCollapse,
86
+ }),
87
+ [activePath, navigate, isExpanded, isMobile, isTablet, onCollapse],
88
+ );
89
+
90
+ const [headerOverlay, setHeaderOverlay] =
91
+ useState<NavHeaderOverlayState | null>(null);
92
+ const headerOverlayValue = useMemo(
93
+ () => ({ overlay: headerOverlay, setOverlay: setHeaderOverlay }),
94
+ [headerOverlay],
95
+ );
96
+
97
+ const [ftbStickyProps, setFtbStickyProps] = useState<NavFTBProps | null>(
98
+ null,
99
+ );
100
+ const ftbStickyContextValue = useMemo(
101
+ () => ({ ftbProps: ftbStickyProps, setFtbProps: setFtbStickyProps }),
102
+ [ftbStickyProps],
103
+ );
104
+
105
+ return (
106
+ <NavContext.Provider value={{ inNav: true }}>
107
+ <NavRailContext.Provider value={railContextValue}>
108
+ <NavHeaderOverlayContext.Provider value={headerOverlayValue}>
109
+ <NavFTBStickyContext.Provider value={ftbStickyContextValue}>
110
+ {children}
111
+ </NavFTBStickyContext.Provider>
112
+ </NavHeaderOverlayContext.Provider>
113
+ </NavRailContext.Provider>
114
+ </NavContext.Provider>
115
+ );
116
+ },
117
+ {
118
+ Content({ children }: { children?: React.ReactNode }) {
119
+ const { isExpanded, isTablet, onCollapse } = useNavRail();
120
+ const overlay = useContext(NavHeaderOverlayContext)?.overlay ?? null;
121
+ const dimmed = isExpanded || overlay?.isOpen || false;
122
+ const isHeader = useHasHeader();
123
+ return (
124
+ <main
125
+ className={styles.mainNavContent}
126
+ style={{
127
+ position: "relative",
128
+ display: "flex",
129
+ flexDirection: "column",
130
+ minHeight: "100dvh",
131
+ overflow: "clip",
132
+ padding: isHeader || isTablet ? 0 : "12px 12px 12px 78px",
133
+ transition: "border-radius var(--transition-expressive-color)",
134
+ }}
135
+ >
136
+ <div
137
+ onClick={() => {
138
+ onCollapse?.();
139
+ overlay?.close?.();
140
+ }}
141
+ style={{
142
+ position: "fixed",
143
+ inset: 0,
144
+ zIndex: 999,
145
+ backgroundColor: "rgba(0, 0, 0, 0.4)",
146
+ backdropFilter: "blur(12px)",
147
+ opacity: dimmed ? 1 : 0,
148
+ pointerEvents: dimmed ? "auto" : "none",
149
+
150
+ transition: "opacity var(--transition-expressive-color)",
151
+ }}
152
+ />
153
+ {children}
154
+ </main>
155
+ );
156
+ },
157
+ Rail: NavRailComponent,
158
+ Bar: NavBarComponent,
159
+ Item: NavItemComponent,
160
+ Tab: NavTabComponent,
161
+ Section: NavSectionComponent,
162
+ FTB: NavFTBComponent,
163
+ Header: NavHeaderComponent,
164
+ },
165
+ );
166
+
167
+ export default Nav;