@yamatozhen/design_system 1.0.1 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -201
- package/README.md +101 -101
- package/package.json +50 -50
- package/scripts/postinstall.js +91 -91
- package/template/app/ClientNav.tsx +258 -310
- package/template/app/globals.css +2 -167
- package/template/app/layout.tsx +94 -82
- package/template/app/themes/dark-mc.css +51 -51
- package/template/app/themes/dark.css +51 -51
- package/template/app/themes/light-mc.css +51 -51
- package/template/app/themes/light.css +51 -51
- package/template/app/themes/theme.css +272 -82
- package/template/components/{layout/button → (buttons)}/Button.module.css +351 -305
- package/template/components/{layout/button → (buttons)}/ButtonGroup.tsx +414 -503
- package/template/components/{layout/button → (buttons)}/FAB.tsx +119 -118
- package/template/components/(buttons)/button.tsx +164 -0
- package/template/components/(controls)/slider/Slider.module.css +250 -0
- package/template/components/(controls)/slider/Slider.tsx +386 -0
- package/template/components/{layout → (controls)}/switch/Switch.module.css +108 -102
- package/template/components/{layout → (controls)}/switch/Switch.tsx +69 -48
- package/template/components/(date & time)/calendar/Calendar.module.css +125 -0
- package/template/components/(date & time)/calendar/Calendar.tsx +206 -0
- package/template/components/(date & time)/dateField/DateField.module.css +25 -0
- package/template/components/(date & time)/dateField/DateField.tsx +193 -0
- package/template/components/(date & time)/datePicker/DatePicker.tsx +118 -0
- package/template/components/(date & time)/dateRangePicker/DateRangePicker.tsx +144 -0
- package/template/components/(date & time)/rangeCalendar/RangeCalendar.module.css +203 -0
- package/template/components/(date & time)/rangeCalendar/RangeCalendar.tsx +263 -0
- package/template/components/(date & time)/shared/dateUtils.ts +107 -0
- package/template/components/(date & time)/timeField/TimeField.module.css +39 -0
- package/template/components/(date & time)/timeField/TimeField.tsx +158 -0
- package/template/components/(feedback)/circularProgress/CircularProgress.tsx +646 -0
- package/template/components/(feedback)/linearProgress/LinearProgress.tsx +337 -0
- package/template/components/(feedback)/meter/Meter.tsx +111 -0
- package/template/components/(feedback)/skeleton/Skeleton.module.css +49 -0
- package/template/components/(feedback)/skeleton/Skeleton.tsx +32 -0
- package/template/components/(feedback)/spinner/Spinner.module.css +27 -0
- package/template/components/(feedback)/spinner/Spinner.tsx +60 -0
- package/template/components/(forms)/checkbox/Checkbox.tsx +121 -0
- package/template/components/(forms)/checkboxGroup/CheckboxGroup.tsx +83 -0
- package/template/components/(forms)/description/Description.tsx +34 -0
- package/template/components/(forms)/errorMessage/ErrorMessage.tsx +31 -0
- package/template/components/(forms)/fieldError/FieldError.tsx +39 -0
- package/template/components/(forms)/fieldset/Fieldset.tsx +51 -0
- package/template/components/(forms)/form/Form.tsx +54 -0
- package/template/components/(forms)/input/Input.tsx +50 -0
- package/template/components/(forms)/inputGroup/InputGroup.tsx +65 -0
- package/template/components/(forms)/inputOtp/InputOtp.tsx +139 -0
- package/template/components/(forms)/label/Label.tsx +46 -0
- package/template/components/(forms)/numberField/NumberField.tsx +292 -0
- package/template/components/(forms)/radioGroup/RadioGroup.tsx +175 -0
- package/template/components/(forms)/searchField/SearchField.tsx +139 -0
- package/template/components/(forms)/shared/field.module.css +75 -0
- package/template/components/(forms)/shared/fieldContext.ts +28 -0
- package/template/components/(forms)/textArea/TextArea.tsx +55 -0
- package/template/components/(forms)/textField/TextField.tsx +91 -0
- package/template/components/{layout → (layout)}/Lightbox/LightboxCard.tsx +100 -100
- package/template/components/{layout → (layout)}/Lightbox/LightboxGallery.module.css +249 -249
- package/template/components/{layout → (layout)}/Lightbox/LightboxGallery.tsx +72 -72
- package/template/components/{layout → (layout)}/Lightbox/LightboxGrid.tsx +185 -186
- package/template/components/{layout → (layout)}/Lightbox/LightboxModal.module.css +395 -395
- package/template/components/{layout → (layout)}/Lightbox/LightboxModal.tsx +498 -500
- package/template/components/{layout → (layout)}/Lightbox/demo.tsx +396 -412
- package/template/components/{layout → (layout)}/Lightbox/index.ts +30 -30
- package/template/components/{layout → (layout)}/Lightbox/types.ts +101 -113
- package/template/components/{layout → (layout)}/Lightbox/useLightboxFilters.ts +140 -140
- package/template/components/(layout)/accordion/Accordion.module.css +108 -0
- package/template/components/(layout)/accordion/Accordion.tsx +251 -0
- package/template/components/(layout)/card/Card.module.css +136 -0
- package/template/components/(layout)/card/Card.tsx +371 -0
- package/template/components/(layout)/list/List.module.css +83 -0
- package/template/components/(layout)/list/List.tsx +332 -0
- package/template/components/{layout → (layout)}/navigation/Wrap.tsx +41 -41
- package/template/components/(layout)/navigation/breadcrumbs/Breadcrumbs.tsx +145 -0
- package/template/components/{layout/navigation/nav/Nav.module.css → (layout)/navigation/nav/Nav.module.css.old} +474 -508
- package/template/components/{layout → (layout)}/navigation/nav/Nav.tsx +186 -167
- package/template/components/{layout → (layout)}/navigation/nav/NavBar.tsx +396 -419
- package/template/components/{layout → (layout)}/navigation/nav/NavContext.tsx +259 -259
- package/template/components/{layout → (layout)}/navigation/nav/NavItem.tsx +195 -173
- package/template/components/{layout → (layout)}/navigation/nav/NavNew.module.css +406 -373
- package/template/components/{layout → (layout)}/navigation/nav/NavRail.tsx +317 -315
- package/template/components/{layout → (layout)}/navigation/nav/NavSection.tsx +101 -102
- package/template/components/{layout → (layout)}/navigation/nav/NavTab.tsx +25 -25
- package/template/components/{layout → (layout)}/navigation/nav/navftb/NavFTB.module.css +253 -252
- package/template/components/{layout → (layout)}/navigation/nav/navftb/NavFTB.tsx +448 -399
- package/template/components/{layout → (layout)}/navigation/nav/navftb/useTabIndicator.ts +498 -484
- package/template/components/{layout → (layout)}/navigation/nav/navheader/NavHeader.module.css +59 -59
- package/template/components/{layout → (layout)}/navigation/nav/navheader/NavHeader.tsx +465 -473
- package/template/components/(layout)/navigation/pagination/Pagination.tsx +261 -0
- package/template/components/{layout → (layout)}/pages/loadingScreen.tsx +117 -102
- package/template/components/{layout → (layout)}/pages/maintenance/Maintenance.tsx +52 -52
- package/template/components/{layout → (layout)}/pages/maintenance/maintenance.module.css +162 -162
- package/template/components/(layout)/scrollShadow/ScrollShadow.module.css +81 -0
- package/template/components/(layout)/scrollShadow/ScrollShadow.tsx +161 -0
- package/template/components/(layout)/scrollShadow/useScrollShadow.ts +130 -0
- package/template/components/(layout)/separator/Separator.tsx +112 -0
- package/template/components/(overlays)/accessibilityModal/AccessibilityModal.tsx +307 -0
- package/template/components/(overlays)/drawer/Drawer.tsx +953 -0
- package/template/components/(overlays)/modal/Modal.tsx +654 -0
- package/template/components/(overlays)/popover/Popover.tsx +420 -0
- package/template/components/(overlays)/toast/Toast.tsx +692 -0
- package/template/components/(pickers)/autocomplete/Autocomplete.tsx +24 -0
- package/template/components/(pickers)/comboBox/ComboBox.tsx +21 -0
- package/template/components/(pickers)/select/Select.tsx +188 -0
- package/template/components/(pickers)/shared/FilterableField.tsx +223 -0
- package/template/components/(pickers)/shared/PickerItem.ts +13 -0
- package/template/components/tools/CustomScrollbar.tsx +107 -0
- package/template/components/tools/Divider.tsx +11 -11
- package/template/components/tools/ReduceMotionContext.tsx +5 -5
- package/template/components/tools/Sinewave.tsx +396 -199
- package/template/components/tools/SinewaveProgress.tsx +140 -135
- package/template/components/tools/badge/Badge.tsx +28 -28
- package/template/components/tools/dropdown/drop.module.css +196 -0
- package/template/components/tools/dropdown/drop.tsx +568 -0
- package/template/components/tools/easing.ts +118 -0
- package/template/components/tools/flubber.d.ts +6 -6
- package/template/components/tools/footer/Footer.tsx +20 -0
- package/template/components/tools/input/Input.module.css +45 -0
- package/template/components/tools/input/Input.tsx +99 -0
- package/template/components/tools/label/Icon.tsx +39 -0
- package/template/components/tools/label/Label.tsx +156 -0
- package/template/components/tools/mobileViewProvider.tsx +53 -58
- package/template/components/tools/ripple/ripple.css +38 -41
- package/template/components/tools/ripple/ripple.tsx +78 -53
- package/template/components/tools/shape/Shape.module.css +25 -0
- package/template/components/tools/shape/{ShapeMorph.tsx → Shape.tsx} +316 -190
- package/template/components/tools/shape/ShapeLoader.tsx +104 -101
- package/template/components/tools/shape/ShapePaths.ts +116 -116
- package/template/components/tools/switch/Switch.module.css +102 -102
- package/template/components/tools/switch/Switch.tsx +48 -48
- package/template/components/tools/useBodyScrollLock.tsx +27 -27
- package/template/components/tools/useImageColor.ts +47 -47
- package/template/components/tools/useNavSheetDrag.tsx +196 -196
- package/template/components/layout/accordion/Accordion.module.css +0 -149
- package/template/components/layout/accordion/Accordion.tsx +0 -114
- package/template/components/layout/button/button.tsx +0 -128
- package/template/components/layout/button/drop.module.css +0 -229
- package/template/components/layout/button/drop.tsx +0 -516
- package/template/components/layout/hero/v1/heroSlideshow.module.css +0 -107
- package/template/components/layout/hero/v1/heroSlideshow.tsx +0 -233
- package/template/components/layout/modals/accessibilityModal/AccessibilityModal.module.css +0 -126
- package/template/components/layout/modals/accessibilityModal/AccessibilityModal.tsx +0 -290
- package/template/components/layout/modals/alert/Alert.tsx +0 -188
- package/template/components/layout/navigation/MioCard.module.css +0 -88
- package/template/components/layout/navigation/MioCard.tsx +0 -266
- package/template/components/tools/ProgressiveBlur.tsx +0 -73
- package/template/components/tools/icon/icon.module.css +0 -0
- package/template/components/tools/icon/icon.tsx +0 -125
- package/template/components/tools/react-bits/ClickSpark.tsx +0 -177
- package/template/components/tools/react-bits/FadeContent.tsx +0 -90
- package/template/components/tools/react-bits/GlareHover.tsx +0 -73
- package/template/components/tools/react-bits/GradientText/GradientText.css +0 -70
- package/template/components/tools/react-bits/GradientText/GradientText.tsx +0 -44
- package/template/components/tools/react-bits/Magnet.tsx +0 -118
- package/template/components/tools/react-bits/Stepper/Stepper.css +0 -134
- package/template/components/tools/react-bits/Stepper/Stepper.tsx +0 -412
|
@@ -1,310 +1,258 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import React, { useCallback, useEffect, useState } from "react";
|
|
3
|
-
import { usePathname } from "next/navigation";
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
} from "@/components/tools/
|
|
11
|
-
import
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
);
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
applyThemeClass
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
const handleCancelAccessibility = useCallback(
|
|
261
|
-
() => setIsAccessibilityOpen(false),
|
|
262
|
-
[],
|
|
263
|
-
);
|
|
264
|
-
|
|
265
|
-
// Shared props for both nav variants
|
|
266
|
-
const sharedNavProps = {
|
|
267
|
-
logoUrl: "/favicon.png",
|
|
268
|
-
accessibilityAriaLabel: "Open accessibility settings",
|
|
269
|
-
accessibilityOnClick: handleAccessibility,
|
|
270
|
-
themeOnClick: handleThemeOnClick,
|
|
271
|
-
theme,
|
|
272
|
-
isExpanded,
|
|
273
|
-
onToggleExpanded: handleToggleExpanded,
|
|
274
|
-
};
|
|
275
|
-
|
|
276
|
-
return (
|
|
277
|
-
<ReduceMotionContext.Provider value={reduceMotion}>
|
|
278
|
-
<Nav isExpanded={isExpanded} onCollapse={handleCollapse}>
|
|
279
|
-
<AccessibilityModal
|
|
280
|
-
isOpen={isAccessibilityOpen}
|
|
281
|
-
contrast={contrast}
|
|
282
|
-
largerText={largerText}
|
|
283
|
-
fontSize={fontSize}
|
|
284
|
-
reduceMotion={reduceMotion}
|
|
285
|
-
showBorders={showBorders}
|
|
286
|
-
disableBrightness={disableBrightness}
|
|
287
|
-
onSave={handleSave}
|
|
288
|
-
onCancel={handleCancelAccessibility}
|
|
289
|
-
/>
|
|
290
|
-
<Nav.Bar
|
|
291
|
-
{...sharedNavProps}
|
|
292
|
-
style={{ display: isMobile || isTablet ? undefined : "none" }}
|
|
293
|
-
>
|
|
294
|
-
{NAV_ITEMS}
|
|
295
|
-
</Nav.Bar>
|
|
296
|
-
<Nav.Rail
|
|
297
|
-
{...sharedNavProps}
|
|
298
|
-
logoUrl=""
|
|
299
|
-
style={{ display: isMobile || isTablet ? "none" : undefined }}
|
|
300
|
-
>
|
|
301
|
-
{NAV_ITEMS}
|
|
302
|
-
</Nav.Rail>
|
|
303
|
-
|
|
304
|
-
<Nav.Content>
|
|
305
|
-
<PageTransition>{children}</PageTransition>
|
|
306
|
-
</Nav.Content>
|
|
307
|
-
</Nav>
|
|
308
|
-
</ReduceMotionContext.Provider>
|
|
309
|
-
);
|
|
310
|
-
}
|
|
1
|
+
"use client";
|
|
2
|
+
import React, { useCallback, useEffect, useState } from "react";
|
|
3
|
+
import { usePathname } from "next/navigation";
|
|
4
|
+
import { motion } from "framer-motion";
|
|
5
|
+
import Nav from "../components/(layout)/navigation/nav/Nav";
|
|
6
|
+
import AccessibilityModal from "../components/(overlays)/accessibilityModal/AccessibilityModal";
|
|
7
|
+
import {
|
|
8
|
+
ReduceMotionContext,
|
|
9
|
+
useReduceMotion,
|
|
10
|
+
} from "@/components/tools/ReduceMotionContext";
|
|
11
|
+
import {
|
|
12
|
+
useBreakpoints,
|
|
13
|
+
useMediaQuery,
|
|
14
|
+
} from "@/components/tools/mobileViewProvider";
|
|
15
|
+
import Footer from "@/components/tools/footer/Footer";
|
|
16
|
+
|
|
17
|
+
const PAGE_TRANSITION_EASE = [0.01, 1.25, 0.23, 1.01] as const;
|
|
18
|
+
|
|
19
|
+
function PageTransition({ children }: { children: React.ReactNode }) {
|
|
20
|
+
const pathname = usePathname();
|
|
21
|
+
const rm = useReduceMotion();
|
|
22
|
+
return (
|
|
23
|
+
<motion.div
|
|
24
|
+
key={pathname}
|
|
25
|
+
initial={{ opacity: 0, y: rm ? 0 : 40 }}
|
|
26
|
+
animate={{ opacity: 1, y: 0 }}
|
|
27
|
+
transition={{ duration: rm ? 0 : 0.4, ease: PAGE_TRANSITION_EASE }}
|
|
28
|
+
style={{
|
|
29
|
+
display: "flex",
|
|
30
|
+
flexDirection: "column",
|
|
31
|
+
alignItems: "center",
|
|
32
|
+
width: "100%",
|
|
33
|
+
gap: 12,
|
|
34
|
+
}}
|
|
35
|
+
>
|
|
36
|
+
{children}
|
|
37
|
+
</motion.div>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Shared nav items — defined once, passed to Bar so it stays in sync.
|
|
42
|
+
const NAV_ITEMS = (
|
|
43
|
+
<>
|
|
44
|
+
<Nav.Item default={true} path="/" systemName="home" label="Home" />
|
|
45
|
+
<Nav.Item systemName="widgets" label="Library">
|
|
46
|
+
<Nav.Tab path="/library" label="Overview" />
|
|
47
|
+
<Nav.Tab path="/library/components" label="Components" />
|
|
48
|
+
<Nav.Tab path="/library/icons" label="Icons" />
|
|
49
|
+
<Nav.Tab path="/library/themes" label="Themes" />
|
|
50
|
+
</Nav.Item>
|
|
51
|
+
<Nav.Item path="/settings" systemName="settings" label="Settings" />
|
|
52
|
+
<Nav.Item path="/profile" systemName="person" label="Profile" />
|
|
53
|
+
</>
|
|
54
|
+
);
|
|
55
|
+
export default function ClientNav({
|
|
56
|
+
children,
|
|
57
|
+
}: {
|
|
58
|
+
children?: React.ReactNode;
|
|
59
|
+
}) {
|
|
60
|
+
const [theme, setTheme] = useState<"light" | "dark">("light");
|
|
61
|
+
const [contrast, setContrast] = useState<"none" | "medium">("none");
|
|
62
|
+
const [isExpanded, setIsExpanded] = useState(false);
|
|
63
|
+
const [isAccessibilityOpen, setIsAccessibilityOpen] = useState(false);
|
|
64
|
+
const [largerText, setLargerText] = useState(false);
|
|
65
|
+
const [fontSize, setFontSize] = useState<16 | 18 | 20 | 24>(16);
|
|
66
|
+
const [reduceMotion, setReduceMotion] = useState(false);
|
|
67
|
+
const [showBorders, setShowBorders] = useState(false);
|
|
68
|
+
const [disableBrightness, setDisableBrightness] = useState(false);
|
|
69
|
+
const { isMobile, isTablet } = useBreakpoints();
|
|
70
|
+
useMediaQuery("(max-width: 812px)");
|
|
71
|
+
|
|
72
|
+
const applyThemeClass = useCallback(
|
|
73
|
+
(t: "light" | "dark", c: "none" | "medium") => {
|
|
74
|
+
const next = t + (c === "medium" ? "-medium-contrast" : "");
|
|
75
|
+
const el = document.documentElement;
|
|
76
|
+
el.classList.remove(
|
|
77
|
+
"light",
|
|
78
|
+
"dark",
|
|
79
|
+
"light-medium-contrast",
|
|
80
|
+
"dark-medium-contrast",
|
|
81
|
+
);
|
|
82
|
+
el.classList.add(next);
|
|
83
|
+
el.setAttribute("data-theme", t);
|
|
84
|
+
},
|
|
85
|
+
[],
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
// Hydrates theme/contrast/font-size/motion/etc. from localStorage and
|
|
89
|
+
// prefers-color-scheme, both client-only APIs unavailable during SSR —
|
|
90
|
+
// this can only run post-mount, so the state syncs necessarily happen here.
|
|
91
|
+
/* eslint-disable react-hooks/set-state-in-effect */
|
|
92
|
+
useEffect(() => {
|
|
93
|
+
const savedTheme = localStorage.getItem("theme") as "light" | "dark" | null;
|
|
94
|
+
const savedContrast = (localStorage.getItem("contrast") ?? "none") as
|
|
95
|
+
| "none"
|
|
96
|
+
| "medium";
|
|
97
|
+
const savedFontSize = localStorage.getItem("font-size");
|
|
98
|
+
if (savedFontSize) {
|
|
99
|
+
const parsed = parseInt(savedFontSize, 10) as 16 | 18 | 20 | 24;
|
|
100
|
+
setLargerText(parsed > 16);
|
|
101
|
+
setFontSize(parsed);
|
|
102
|
+
}
|
|
103
|
+
const savedReduceMotion = localStorage.getItem("reduce-motion") === "true";
|
|
104
|
+
setReduceMotion(savedReduceMotion);
|
|
105
|
+
const savedShowBorders = localStorage.getItem("show-borders") === "true";
|
|
106
|
+
setShowBorders(savedShowBorders);
|
|
107
|
+
if (savedShowBorders) {
|
|
108
|
+
document.documentElement.setAttribute("data-show-borders", "true");
|
|
109
|
+
}
|
|
110
|
+
const savedDisableBrightness =
|
|
111
|
+
localStorage.getItem("disable-brightness") === "true";
|
|
112
|
+
setDisableBrightness(savedDisableBrightness);
|
|
113
|
+
if (savedDisableBrightness) {
|
|
114
|
+
document.documentElement.setAttribute("data-disable-brightness", "true");
|
|
115
|
+
}
|
|
116
|
+
const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
|
|
117
|
+
|
|
118
|
+
const handleChange = () => {
|
|
119
|
+
if (!localStorage.getItem("theme")) {
|
|
120
|
+
const newTheme = mediaQuery.matches ? "dark" : "light";
|
|
121
|
+
setTheme(newTheme);
|
|
122
|
+
applyThemeClass(newTheme, savedContrast);
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
const initialTheme = savedTheme || (mediaQuery.matches ? "dark" : "light");
|
|
127
|
+
setTheme(initialTheme);
|
|
128
|
+
setContrast(savedContrast);
|
|
129
|
+
applyThemeClass(initialTheme, savedContrast);
|
|
130
|
+
|
|
131
|
+
mediaQuery.addEventListener("change", handleChange);
|
|
132
|
+
return () => mediaQuery.removeEventListener("change", handleChange);
|
|
133
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
134
|
+
}, []);
|
|
135
|
+
/* eslint-enable react-hooks/set-state-in-effect */
|
|
136
|
+
|
|
137
|
+
const handleAccessibility = useCallback(() => {
|
|
138
|
+
setIsAccessibilityOpen(true);
|
|
139
|
+
}, []);
|
|
140
|
+
|
|
141
|
+
const handleThemeOnClick = useCallback(() => {
|
|
142
|
+
const newTheme = theme === "light" ? "dark" : "light";
|
|
143
|
+
localStorage.setItem("theme", newTheme);
|
|
144
|
+
applyThemeClass(newTheme, contrast);
|
|
145
|
+
setTheme(newTheme);
|
|
146
|
+
}, [theme, contrast, applyThemeClass]);
|
|
147
|
+
|
|
148
|
+
const handleSave = useCallback(
|
|
149
|
+
({
|
|
150
|
+
contrast: c,
|
|
151
|
+
largerText: lt,
|
|
152
|
+
fontSize: fs,
|
|
153
|
+
reduceMotion: rm,
|
|
154
|
+
showBorders: sb,
|
|
155
|
+
disableBrightness: db,
|
|
156
|
+
}: {
|
|
157
|
+
contrast: "none" | "medium";
|
|
158
|
+
largerText: boolean;
|
|
159
|
+
fontSize: 16 | 18 | 20 | 24;
|
|
160
|
+
reduceMotion: boolean;
|
|
161
|
+
showBorders: boolean;
|
|
162
|
+
disableBrightness: boolean;
|
|
163
|
+
}) => {
|
|
164
|
+
setContrast(c);
|
|
165
|
+
localStorage.setItem("contrast", c);
|
|
166
|
+
applyThemeClass(theme, c);
|
|
167
|
+
setLargerText(lt);
|
|
168
|
+
setFontSize(fs);
|
|
169
|
+
localStorage.setItem("font-size", String(fs));
|
|
170
|
+
document.documentElement.style.setProperty("--font-size-base", `${fs}px`);
|
|
171
|
+
setReduceMotion(rm);
|
|
172
|
+
localStorage.setItem("reduce-motion", String(rm));
|
|
173
|
+
if (rm) {
|
|
174
|
+
document.documentElement.setAttribute("data-reduce-motion", "true");
|
|
175
|
+
} else {
|
|
176
|
+
document.documentElement.removeAttribute("data-reduce-motion");
|
|
177
|
+
}
|
|
178
|
+
setShowBorders(sb);
|
|
179
|
+
localStorage.setItem("show-borders", String(sb));
|
|
180
|
+
if (sb) {
|
|
181
|
+
document.documentElement.setAttribute("data-show-borders", "true");
|
|
182
|
+
} else {
|
|
183
|
+
document.documentElement.removeAttribute("data-show-borders");
|
|
184
|
+
}
|
|
185
|
+
setDisableBrightness(db);
|
|
186
|
+
localStorage.setItem("disable-brightness", String(db));
|
|
187
|
+
if (db) {
|
|
188
|
+
document.documentElement.setAttribute(
|
|
189
|
+
"data-disable-brightness",
|
|
190
|
+
"true",
|
|
191
|
+
);
|
|
192
|
+
} else {
|
|
193
|
+
document.documentElement.removeAttribute("data-disable-brightness");
|
|
194
|
+
}
|
|
195
|
+
setIsAccessibilityOpen(false);
|
|
196
|
+
},
|
|
197
|
+
[theme, applyThemeClass],
|
|
198
|
+
);
|
|
199
|
+
|
|
200
|
+
const handleToggleExpanded = useCallback(
|
|
201
|
+
() => setIsExpanded((prev) => !prev),
|
|
202
|
+
[],
|
|
203
|
+
);
|
|
204
|
+
|
|
205
|
+
const handleCollapse = useCallback(() => setIsExpanded(false), []);
|
|
206
|
+
|
|
207
|
+
const handleCancelAccessibility = useCallback(
|
|
208
|
+
() => setIsAccessibilityOpen(false),
|
|
209
|
+
[],
|
|
210
|
+
);
|
|
211
|
+
|
|
212
|
+
// Shared props for both nav variants
|
|
213
|
+
const sharedNavProps = {
|
|
214
|
+
logoUrl: "/favicon.png",
|
|
215
|
+
accessibilityAriaLabel: "Open accessibility settings",
|
|
216
|
+
accessibilityOnClick: handleAccessibility,
|
|
217
|
+
themeOnClick: handleThemeOnClick,
|
|
218
|
+
theme,
|
|
219
|
+
isExpanded,
|
|
220
|
+
onToggleExpanded: handleToggleExpanded,
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
return (
|
|
224
|
+
<ReduceMotionContext.Provider value={reduceMotion}>
|
|
225
|
+
<Nav isExpanded={isExpanded} onCollapse={handleCollapse}>
|
|
226
|
+
<AccessibilityModal
|
|
227
|
+
isOpen={isAccessibilityOpen}
|
|
228
|
+
contrast={contrast}
|
|
229
|
+
largerText={largerText}
|
|
230
|
+
fontSize={fontSize}
|
|
231
|
+
reduceMotion={reduceMotion}
|
|
232
|
+
showBorders={showBorders}
|
|
233
|
+
disableBrightness={disableBrightness}
|
|
234
|
+
onSave={handleSave}
|
|
235
|
+
onCancel={handleCancelAccessibility}
|
|
236
|
+
/>
|
|
237
|
+
<Nav.Bar
|
|
238
|
+
{...sharedNavProps}
|
|
239
|
+
style={{ display: isMobile || isTablet ? undefined : "none" }}
|
|
240
|
+
>
|
|
241
|
+
{NAV_ITEMS}
|
|
242
|
+
</Nav.Bar>
|
|
243
|
+
<Nav.Rail
|
|
244
|
+
{...sharedNavProps}
|
|
245
|
+
logoUrl=""
|
|
246
|
+
style={{ display: isMobile || isTablet ? "none" : undefined }}
|
|
247
|
+
>
|
|
248
|
+
{NAV_ITEMS}
|
|
249
|
+
</Nav.Rail>
|
|
250
|
+
|
|
251
|
+
<Nav.Content>
|
|
252
|
+
<PageTransition>{children}</PageTransition>
|
|
253
|
+
<Footer />
|
|
254
|
+
</Nav.Content>
|
|
255
|
+
</Nav>
|
|
256
|
+
</ReduceMotionContext.Provider>
|
|
257
|
+
);
|
|
258
|
+
}
|