@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,233 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import Image from "next/image";
|
|
3
|
+
import styles from "./heroSlideshow.module.css";
|
|
4
|
+
import { useState, useRef } from "react";
|
|
5
|
+
import { getColorSync } from "colorthief";
|
|
6
|
+
import Icon from "@/components/tools/icon/icon";
|
|
7
|
+
import {
|
|
8
|
+
BREAKPOINTS,
|
|
9
|
+
useBreakpoints,
|
|
10
|
+
useMediaQuery,
|
|
11
|
+
} from "@/components/tools/mobileViewProvider";
|
|
12
|
+
import Button from "../../button/button";
|
|
13
|
+
import Link from "next/link";
|
|
14
|
+
|
|
15
|
+
interface HeroSlideshowProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
16
|
+
tabs: {
|
|
17
|
+
alt?: string;
|
|
18
|
+
src: string;
|
|
19
|
+
style?: React.CSSProperties;
|
|
20
|
+
cta?: {
|
|
21
|
+
title: string;
|
|
22
|
+
text: string;
|
|
23
|
+
href: string;
|
|
24
|
+
btn: string;
|
|
25
|
+
icon: string;
|
|
26
|
+
};
|
|
27
|
+
}[];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export default function HeroSlideshow({ tabs, ...rest }: HeroSlideshowProps) {
|
|
31
|
+
const [activeTab, setActiveTab] = useState(0);
|
|
32
|
+
const [colors, setColors] = useState<(string | null)[]>(() =>
|
|
33
|
+
Array(tabs.length).fill(null),
|
|
34
|
+
);
|
|
35
|
+
const [hues, setHues] = useState<(number | null)[]>(() =>
|
|
36
|
+
Array(tabs.length).fill(null),
|
|
37
|
+
);
|
|
38
|
+
const { isMobile, isTablet } = useBreakpoints();
|
|
39
|
+
useMediaQuery("(max-width: 767px)");
|
|
40
|
+
const touchStartX = useRef<number | null>(null);
|
|
41
|
+
const prevActiveRef = useRef<number>(0);
|
|
42
|
+
|
|
43
|
+
// Records the current slide before switching so only the entering and leaving slides animate.
|
|
44
|
+
const navigate = (next: number) => {
|
|
45
|
+
prevActiveRef.current = activeTab;
|
|
46
|
+
setActiveTab(next);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
// Extracts the dominant hue from a loaded image via colorthief and stores it as an HSL color string.
|
|
50
|
+
const extractColor = (img: HTMLImageElement, index: number) => {
|
|
51
|
+
try {
|
|
52
|
+
const result = getColorSync(img);
|
|
53
|
+
if (result) {
|
|
54
|
+
const { h } = result.hsl();
|
|
55
|
+
setColors((prev) => {
|
|
56
|
+
const next = [...prev];
|
|
57
|
+
next[index] = `hsl(${h}, 40%, 40%)`;
|
|
58
|
+
return next;
|
|
59
|
+
});
|
|
60
|
+
setHues((prev) => {
|
|
61
|
+
const next = [...prev];
|
|
62
|
+
next[index] = h;
|
|
63
|
+
return next;
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
} catch {
|
|
67
|
+
// CORS or extraction failure — skip
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
// Returns the shortest-path offset (in slide widths) from the active slide to slide i,
|
|
72
|
+
// wrapping around the ends so navigation always travels the shortest visual direction.
|
|
73
|
+
const slideOffset = (i: number) => {
|
|
74
|
+
let offset = i - activeTab;
|
|
75
|
+
if (offset > tabs.length / 2) offset -= tabs.length;
|
|
76
|
+
if (offset < -tabs.length / 2) offset += tabs.length;
|
|
77
|
+
return offset;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
// Records the X position where a touch begins.
|
|
81
|
+
const handleTouchStart = (e: React.TouchEvent) => {
|
|
82
|
+
touchStartX.current = e.touches[0].clientX;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
// Navigates to the next or previous slide if the horizontal swipe distance exceeds 50px.
|
|
86
|
+
const handleTouchEnd = (e: React.TouchEvent) => {
|
|
87
|
+
if (touchStartX.current === null) return;
|
|
88
|
+
const diff = touchStartX.current - e.changedTouches[0].clientX;
|
|
89
|
+
if (Math.abs(diff) > 50) {
|
|
90
|
+
navigate(
|
|
91
|
+
diff > 0
|
|
92
|
+
? (activeTab + 1) % tabs.length
|
|
93
|
+
: (activeTab - 1 + tabs.length) % tabs.length,
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
touchStartX.current = null;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
return (
|
|
100
|
+
<div
|
|
101
|
+
className={styles.heroWrap}
|
|
102
|
+
onTouchStart={handleTouchStart}
|
|
103
|
+
onTouchEnd={handleTouchEnd}
|
|
104
|
+
{...rest}
|
|
105
|
+
>
|
|
106
|
+
<div className={styles.slideshow}>
|
|
107
|
+
{tabs.map((tab, i) => (
|
|
108
|
+
<div
|
|
109
|
+
key={i}
|
|
110
|
+
className={styles.slide}
|
|
111
|
+
style={
|
|
112
|
+
isMobile
|
|
113
|
+
? {
|
|
114
|
+
position: "absolute",
|
|
115
|
+
inset: 0,
|
|
116
|
+
width: "100%",
|
|
117
|
+
height: "100%",
|
|
118
|
+
transform: `translateX(${slideOffset(i) * 100}%)`,
|
|
119
|
+
transition:
|
|
120
|
+
i === activeTab || i === prevActiveRef.current
|
|
121
|
+
? "transform 0.6s ease"
|
|
122
|
+
: "none",
|
|
123
|
+
}
|
|
124
|
+
: {
|
|
125
|
+
position: "absolute",
|
|
126
|
+
inset: 0,
|
|
127
|
+
width: "100%",
|
|
128
|
+
height: "100%",
|
|
129
|
+
opacity: i === activeTab ? 1 : 0,
|
|
130
|
+
transition: "opacity 0.6s ease",
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
>
|
|
134
|
+
<Image
|
|
135
|
+
src={tab.src}
|
|
136
|
+
alt={tab.alt ?? ""}
|
|
137
|
+
fill
|
|
138
|
+
style={{ objectFit: "cover" }}
|
|
139
|
+
priority={i === 0}
|
|
140
|
+
crossOrigin="anonymous"
|
|
141
|
+
onLoad={(e) =>
|
|
142
|
+
extractColor(e.currentTarget as HTMLImageElement, i)
|
|
143
|
+
}
|
|
144
|
+
/>
|
|
145
|
+
</div>
|
|
146
|
+
))}
|
|
147
|
+
</div>
|
|
148
|
+
|
|
149
|
+
{tabs.map((_, i) => (
|
|
150
|
+
<div
|
|
151
|
+
key={i}
|
|
152
|
+
className={styles.gradient}
|
|
153
|
+
style={{
|
|
154
|
+
background: `linear-gradient(to top, ${colors[i] ?? "transparent"} 0%, transparent 100%)`,
|
|
155
|
+
opacity: i === activeTab ? 1 : 0,
|
|
156
|
+
transition: "opacity 0.6s ease",
|
|
157
|
+
}}
|
|
158
|
+
/>
|
|
159
|
+
))}
|
|
160
|
+
|
|
161
|
+
{tabs.map((tab, i) =>
|
|
162
|
+
tab.cta ? (
|
|
163
|
+
<div
|
|
164
|
+
key={i}
|
|
165
|
+
className={styles.contentCTA}
|
|
166
|
+
style={{
|
|
167
|
+
opacity: i === activeTab ? 1 : 0,
|
|
168
|
+
pointerEvents: i === activeTab ? "auto" : "none",
|
|
169
|
+
transition: "opacity 0.6s ease",
|
|
170
|
+
}}
|
|
171
|
+
>
|
|
172
|
+
<h1>{tab.cta.title}</h1>
|
|
173
|
+
<h4 className={styles.ctaText}>{tab.cta.text}</h4>
|
|
174
|
+
<Link href={tab.cta.href} style={{ textDecoration: "none" }}>
|
|
175
|
+
<Button
|
|
176
|
+
text
|
|
177
|
+
rippleColor={
|
|
178
|
+
hues[i] !== null ? `hsl(${hues[i]}, 90%, 20%)` : undefined
|
|
179
|
+
}
|
|
180
|
+
style={
|
|
181
|
+
{
|
|
182
|
+
background:
|
|
183
|
+
hues[i] !== null
|
|
184
|
+
? `linear-gradient(135deg, hsl(${hues[i]}, 80%, 80%), color-mix(in srgb, hsl(${hues[i]}, 80%, 80%) 50%, white))`
|
|
185
|
+
: undefined,
|
|
186
|
+
color:
|
|
187
|
+
hues[i] !== null
|
|
188
|
+
? `hsl(${hues[i]}, 90%, 20%)`
|
|
189
|
+
: undefined,
|
|
190
|
+
boxShadow: "0 2px 4px rgba(0,0,0,0.2)",
|
|
191
|
+
} as React.CSSProperties
|
|
192
|
+
}
|
|
193
|
+
>
|
|
194
|
+
<Icon systemName={tab.cta.icon} label={tab.cta.btn} />
|
|
195
|
+
</Button>
|
|
196
|
+
</Link>
|
|
197
|
+
</div>
|
|
198
|
+
) : null,
|
|
199
|
+
)}
|
|
200
|
+
|
|
201
|
+
<div className={styles.indicators}>
|
|
202
|
+
<button
|
|
203
|
+
className={styles.arrowBtn}
|
|
204
|
+
onClick={() => navigate((activeTab - 1 + tabs.length) % tabs.length)}
|
|
205
|
+
aria-label="Previous slide"
|
|
206
|
+
>
|
|
207
|
+
<Icon
|
|
208
|
+
iconStyle={{ color: "white" }}
|
|
209
|
+
systemName="keyboard_arrow_left"
|
|
210
|
+
/>
|
|
211
|
+
</button>
|
|
212
|
+
{tabs.map((_, i) => (
|
|
213
|
+
<button
|
|
214
|
+
key={i}
|
|
215
|
+
className={`${styles.dot} ${i === activeTab ? styles.dotActive : ""}`}
|
|
216
|
+
onClick={() => navigate(i)}
|
|
217
|
+
aria-label={`Slide ${i + 1}`}
|
|
218
|
+
/>
|
|
219
|
+
))}
|
|
220
|
+
<button
|
|
221
|
+
className={styles.arrowBtn}
|
|
222
|
+
onClick={() => navigate((activeTab + 1) % tabs.length)}
|
|
223
|
+
aria-label="Next slide"
|
|
224
|
+
>
|
|
225
|
+
<Icon
|
|
226
|
+
iconStyle={{ color: "white" }}
|
|
227
|
+
systemName="keyboard_arrow_right"
|
|
228
|
+
/>
|
|
229
|
+
</button>
|
|
230
|
+
</div>
|
|
231
|
+
</div>
|
|
232
|
+
);
|
|
233
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/* ── Accessibility: Show Borders ──────────────────────────────────────── */
|
|
2
|
+
:global([data-show-borders="true"]) .accModLi {
|
|
3
|
+
border: var(--a11y-border) !important;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.accModLi {
|
|
7
|
+
display: flex;
|
|
8
|
+
justify-content: space-between;
|
|
9
|
+
align-items: center;
|
|
10
|
+
padding: 12px 0 12px 10px;
|
|
11
|
+
overflow: hidden;
|
|
12
|
+
transition: padding var(--transition-expressive-fast);
|
|
13
|
+
&:not(:last-child) {
|
|
14
|
+
border-bottom: 1px solid var(--globalUIBorder);
|
|
15
|
+
}
|
|
16
|
+
&.hidden {
|
|
17
|
+
padding: 0;
|
|
18
|
+
transition: padding var(--transition-expressive-fast);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.accModSettings {
|
|
23
|
+
list-style: none;
|
|
24
|
+
padding: 0 12px;
|
|
25
|
+
margin: 0;
|
|
26
|
+
display: flex;
|
|
27
|
+
border-radius: 24px;
|
|
28
|
+
flex-direction: column;
|
|
29
|
+
background-color: var(--md-sys-color-surface-container-lowest);
|
|
30
|
+
overflow: hidden;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/* ── Font-size slider row ────────────────────────────── */
|
|
34
|
+
.fontSizeSliderRow {
|
|
35
|
+
display: flex;
|
|
36
|
+
flex-direction: row;
|
|
37
|
+
align-items: center;
|
|
38
|
+
justify-content: flex-start;
|
|
39
|
+
gap: 16px;
|
|
40
|
+
width: 100%;
|
|
41
|
+
max-height: 74px;
|
|
42
|
+
opacity: 1;
|
|
43
|
+
pointer-events: auto;
|
|
44
|
+
transition:
|
|
45
|
+
opacity var(--transition-expressive-fast),
|
|
46
|
+
max-height var(--transition-expressive-fast);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.hidden .fontSizeSliderRow {
|
|
50
|
+
max-height: 0;
|
|
51
|
+
opacity: 0;
|
|
52
|
+
pointer-events: none;
|
|
53
|
+
transition:
|
|
54
|
+
opacity var(--transition-expressive-fast),
|
|
55
|
+
max-height var(--transition-expressive-fast);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.hidden {
|
|
59
|
+
border-bottom: 1px solid transparent;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.fontSizeALg {
|
|
63
|
+
font-size: 1.25rem;
|
|
64
|
+
font-weight: 600;
|
|
65
|
+
color: var(--md-sys-color-outline);
|
|
66
|
+
line-height: 1;
|
|
67
|
+
flex-shrink: 0;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.fontSizeSliderWrap {
|
|
71
|
+
flex: 1;
|
|
72
|
+
display: flex;
|
|
73
|
+
flex-direction: column;
|
|
74
|
+
gap: 4px;
|
|
75
|
+
padding-top: 24px;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.fontSizeSlider {
|
|
79
|
+
-webkit-appearance: none;
|
|
80
|
+
appearance: none;
|
|
81
|
+
width: 100%;
|
|
82
|
+
height: 4px;
|
|
83
|
+
border-radius: 99px;
|
|
84
|
+
background: var(--md-sys-color-surface-container-highest);
|
|
85
|
+
outline: none;
|
|
86
|
+
cursor: pointer;
|
|
87
|
+
accent-color: var(--md-sys-color-primary);
|
|
88
|
+
}
|
|
89
|
+
.fontSizeSlider::-webkit-slider-thumb {
|
|
90
|
+
-webkit-appearance: none;
|
|
91
|
+
appearance: none;
|
|
92
|
+
width: 24px;
|
|
93
|
+
transform-origin: center;
|
|
94
|
+
height: 16px;
|
|
95
|
+
border-radius: 50px;
|
|
96
|
+
background: var(--md-sys-color-primary);
|
|
97
|
+
cursor: pointer;
|
|
98
|
+
transition: transform var(--transition-expressive-fast);
|
|
99
|
+
}
|
|
100
|
+
.fontSizeSlider::-webkit-slider-thumb:hover,
|
|
101
|
+
.fontSizeSlider::-webkit-slider-thumb:active {
|
|
102
|
+
transform: scale(1.5);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.fontSizeSlider::-moz-range-thumb {
|
|
106
|
+
width: 20px;
|
|
107
|
+
height: 20px;
|
|
108
|
+
border: none;
|
|
109
|
+
border-radius: 50%;
|
|
110
|
+
background: var(--md-sys-color-primary);
|
|
111
|
+
cursor: pointer;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.fontSizeLabels {
|
|
115
|
+
display: flex;
|
|
116
|
+
justify-content: space-between;
|
|
117
|
+
font-size: 0.65rem;
|
|
118
|
+
color: var(--md-sys-color-outline);
|
|
119
|
+
padding: 0 0.2rem 0 0.4rem;
|
|
120
|
+
user-select: none;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.fontSizeLabelActive {
|
|
124
|
+
color: var(--md-sys-color-primary);
|
|
125
|
+
font-weight: 600;
|
|
126
|
+
}
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import React, { useState, useEffect, useCallback } from "react";
|
|
3
|
+
import Alert from "../alert/Alert";
|
|
4
|
+
import Icon from "@/components/tools/icon/icon";
|
|
5
|
+
import styles from "./AccessibilityModal.module.css";
|
|
6
|
+
import Switch from "../../../tools/switch/Switch";
|
|
7
|
+
|
|
8
|
+
// Defined outside the component — same array reference across all renders.
|
|
9
|
+
const STOPS = [16, 18, 20, 24] as const;
|
|
10
|
+
type FontSize = (typeof STOPS)[number];
|
|
11
|
+
|
|
12
|
+
interface AccModProps {
|
|
13
|
+
isOpen: boolean;
|
|
14
|
+
onSave?: (data: {
|
|
15
|
+
contrast: "none" | "medium";
|
|
16
|
+
largerText: boolean;
|
|
17
|
+
fontSize: FontSize;
|
|
18
|
+
reduceMotion: boolean;
|
|
19
|
+
showBorders: boolean;
|
|
20
|
+
disableBrightness: boolean;
|
|
21
|
+
}) => void;
|
|
22
|
+
onCancel?: () => void;
|
|
23
|
+
contrast?: "none" | "medium";
|
|
24
|
+
largerText?: boolean;
|
|
25
|
+
fontSize?: FontSize;
|
|
26
|
+
reduceMotion?: boolean;
|
|
27
|
+
showBorders?: boolean;
|
|
28
|
+
disableBrightness?: boolean;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export default function AccessibilityModal({
|
|
32
|
+
isOpen,
|
|
33
|
+
onSave,
|
|
34
|
+
onCancel,
|
|
35
|
+
contrast = "none",
|
|
36
|
+
largerText = false,
|
|
37
|
+
fontSize = 16,
|
|
38
|
+
reduceMotion = false,
|
|
39
|
+
showBorders = false,
|
|
40
|
+
disableBrightness = false,
|
|
41
|
+
}: AccModProps) {
|
|
42
|
+
const [draftContrast, setDraftContrast] = useState<"none" | "medium">(
|
|
43
|
+
contrast,
|
|
44
|
+
);
|
|
45
|
+
const [draftLargerText, setDraftLargerText] = useState(largerText);
|
|
46
|
+
const [draftReduceMotion, setDraftReduceMotion] = useState(reduceMotion);
|
|
47
|
+
const [draftShowBorders, setDraftShowBorders] = useState(showBorders);
|
|
48
|
+
const [draftDisableBrightness, setDraftDisableBrightness] =
|
|
49
|
+
useState(disableBrightness);
|
|
50
|
+
const [localIndex, setLocalIndex] = useState<number>(
|
|
51
|
+
Math.max(0, STOPS.indexOf(fontSize)),
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
// Re-sync draft state from committed props every time the modal opens.
|
|
55
|
+
// All prop values are included in the dependency array — no eslint suppression needed.
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
if (!isOpen) return;
|
|
58
|
+
setDraftContrast(contrast);
|
|
59
|
+
setDraftLargerText(largerText);
|
|
60
|
+
setDraftReduceMotion(reduceMotion);
|
|
61
|
+
setDraftShowBorders(showBorders);
|
|
62
|
+
setDraftDisableBrightness(disableBrightness);
|
|
63
|
+
setLocalIndex(Math.max(0, STOPS.indexOf(fontSize)));
|
|
64
|
+
document.documentElement.style.setProperty(
|
|
65
|
+
"--font-size-base",
|
|
66
|
+
`${fontSize}px`,
|
|
67
|
+
);
|
|
68
|
+
}, [
|
|
69
|
+
isOpen,
|
|
70
|
+
contrast,
|
|
71
|
+
largerText,
|
|
72
|
+
reduceMotion,
|
|
73
|
+
showBorders,
|
|
74
|
+
disableBrightness,
|
|
75
|
+
fontSize,
|
|
76
|
+
]);
|
|
77
|
+
|
|
78
|
+
const handleSliderChange = useCallback(
|
|
79
|
+
(e: React.ChangeEvent<HTMLInputElement>) => {
|
|
80
|
+
const idx = Number(e.target.value);
|
|
81
|
+
setLocalIndex(idx);
|
|
82
|
+
document.documentElement.style.setProperty(
|
|
83
|
+
"--font-size-base",
|
|
84
|
+
`${STOPS[idx]}px`,
|
|
85
|
+
);
|
|
86
|
+
},
|
|
87
|
+
[],
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
const handleLargerTextChange = useCallback(
|
|
91
|
+
(on: boolean) => {
|
|
92
|
+
setDraftLargerText(on);
|
|
93
|
+
document.documentElement.style.setProperty(
|
|
94
|
+
"--font-size-base",
|
|
95
|
+
on ? `${STOPS[localIndex]}px` : `${fontSize}px`,
|
|
96
|
+
);
|
|
97
|
+
},
|
|
98
|
+
[localIndex, fontSize],
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
const handleContrastChange = useCallback((on: boolean) => {
|
|
102
|
+
setDraftContrast(on ? "medium" : "none");
|
|
103
|
+
}, []);
|
|
104
|
+
|
|
105
|
+
const handleSave = useCallback(() => {
|
|
106
|
+
onSave?.({
|
|
107
|
+
contrast: draftContrast,
|
|
108
|
+
largerText: draftLargerText,
|
|
109
|
+
fontSize: draftLargerText ? STOPS[localIndex] : 16,
|
|
110
|
+
reduceMotion: draftReduceMotion,
|
|
111
|
+
showBorders: draftShowBorders,
|
|
112
|
+
disableBrightness: draftDisableBrightness,
|
|
113
|
+
});
|
|
114
|
+
}, [
|
|
115
|
+
onSave,
|
|
116
|
+
draftContrast,
|
|
117
|
+
draftLargerText,
|
|
118
|
+
localIndex,
|
|
119
|
+
draftReduceMotion,
|
|
120
|
+
draftShowBorders,
|
|
121
|
+
draftDisableBrightness,
|
|
122
|
+
]);
|
|
123
|
+
|
|
124
|
+
const handleCancel = useCallback(() => {
|
|
125
|
+
document.documentElement.style.setProperty(
|
|
126
|
+
"--font-size-base",
|
|
127
|
+
`${fontSize}px`,
|
|
128
|
+
);
|
|
129
|
+
onCancel?.();
|
|
130
|
+
}, [onCancel, fontSize]);
|
|
131
|
+
|
|
132
|
+
return (
|
|
133
|
+
<Alert
|
|
134
|
+
title=""
|
|
135
|
+
submit={{ label: "Save settings" }}
|
|
136
|
+
cancel={{ label: "Cancel" }}
|
|
137
|
+
onSubmit={handleSave}
|
|
138
|
+
onCancel={handleCancel}
|
|
139
|
+
isPresented={isOpen}
|
|
140
|
+
padding={4}
|
|
141
|
+
style={{
|
|
142
|
+
background:
|
|
143
|
+
"linear-gradient(to bottom, color-mix(var(--md-sys-color-secondary-container) 50%, var(--md-sys-color-surface-container-lowest) 50%) 0%, var(--md-sys-color-surface-container-low) 100%)",
|
|
144
|
+
}}
|
|
145
|
+
>
|
|
146
|
+
<div style={{ display: "flex", flexDirection: "column", gap: "12px" }}>
|
|
147
|
+
<span
|
|
148
|
+
style={{
|
|
149
|
+
borderRadius: "24px",
|
|
150
|
+
padding: "14px 18px",
|
|
151
|
+
backgroundColor: "var(--md-sys-color-secondary-container)",
|
|
152
|
+
border: "1px solid var(--globalUIBorderCard)",
|
|
153
|
+
color: "var(--md-sys-color-on-surface-variant)",
|
|
154
|
+
}}
|
|
155
|
+
>
|
|
156
|
+
<span
|
|
157
|
+
style={{
|
|
158
|
+
backgroundColor: "var(--md-sys-color-surface-container-lowest)",
|
|
159
|
+
color: "var(--md-sys-color-secondary)",
|
|
160
|
+
display: "flex",
|
|
161
|
+
alignItems: "center",
|
|
162
|
+
justifyContent: "center",
|
|
163
|
+
width: "60px",
|
|
164
|
+
height: "60px",
|
|
165
|
+
margin: "4px 0 12px 0",
|
|
166
|
+
borderRadius: "50%",
|
|
167
|
+
}}
|
|
168
|
+
>
|
|
169
|
+
<Icon
|
|
170
|
+
systemName="accessibility_new"
|
|
171
|
+
iconStyle={{ fontSize: "36px" }}
|
|
172
|
+
/>
|
|
173
|
+
</span>
|
|
174
|
+
<h3
|
|
175
|
+
style={{
|
|
176
|
+
fontWeight: 600,
|
|
177
|
+
color: "var(--md-sys-color-on-surface)",
|
|
178
|
+
}}
|
|
179
|
+
>
|
|
180
|
+
Accessibility
|
|
181
|
+
</h3>
|
|
182
|
+
Personalise your experience in ways that work best for you with
|
|
183
|
+
accessibility settings for vision and motion.
|
|
184
|
+
</span>
|
|
185
|
+
<div>
|
|
186
|
+
<p
|
|
187
|
+
style={{
|
|
188
|
+
fontWeight: 500,
|
|
189
|
+
padding: "8px 0 0 20px",
|
|
190
|
+
color: "var(--md-sys-color-outline)",
|
|
191
|
+
}}
|
|
192
|
+
>
|
|
193
|
+
Vision
|
|
194
|
+
</p>
|
|
195
|
+
<ul className={styles.accModSettings}>
|
|
196
|
+
<li className={styles.accModLi}>
|
|
197
|
+
Increase contrast
|
|
198
|
+
<Switch
|
|
199
|
+
checked={draftContrast === "medium"}
|
|
200
|
+
onChange={handleContrastChange}
|
|
201
|
+
/>
|
|
202
|
+
</li>
|
|
203
|
+
<li className={styles.accModLi}>
|
|
204
|
+
Show borders
|
|
205
|
+
<Switch
|
|
206
|
+
checked={draftShowBorders}
|
|
207
|
+
onChange={setDraftShowBorders}
|
|
208
|
+
/>
|
|
209
|
+
</li>
|
|
210
|
+
<li className={styles.accModLi}>
|
|
211
|
+
Disable brightness effect
|
|
212
|
+
<Switch
|
|
213
|
+
checked={draftDisableBrightness}
|
|
214
|
+
onChange={setDraftDisableBrightness}
|
|
215
|
+
/>
|
|
216
|
+
</li>
|
|
217
|
+
</ul>
|
|
218
|
+
</div>
|
|
219
|
+
<ul className={styles.accModSettings}>
|
|
220
|
+
<li
|
|
221
|
+
style={{
|
|
222
|
+
borderBottom: !draftLargerText
|
|
223
|
+
? "1px solid transparent"
|
|
224
|
+
: undefined,
|
|
225
|
+
}}
|
|
226
|
+
className={styles.accModLi}
|
|
227
|
+
>
|
|
228
|
+
Larger text
|
|
229
|
+
<Switch
|
|
230
|
+
checked={draftLargerText}
|
|
231
|
+
onChange={handleLargerTextChange}
|
|
232
|
+
/>
|
|
233
|
+
</li>
|
|
234
|
+
<li
|
|
235
|
+
className={`${styles.accModLi} ${!draftLargerText ? styles.hidden : ""}`}
|
|
236
|
+
>
|
|
237
|
+
<div className={styles.fontSizeSliderRow}>
|
|
238
|
+
<Icon className="textIcon" systemName="text_decrease" />
|
|
239
|
+
<div className={styles.fontSizeSliderWrap}>
|
|
240
|
+
<input
|
|
241
|
+
type="range"
|
|
242
|
+
min={0}
|
|
243
|
+
max={4}
|
|
244
|
+
step={1}
|
|
245
|
+
value={localIndex}
|
|
246
|
+
onChange={handleSliderChange}
|
|
247
|
+
className={styles.fontSizeSlider}
|
|
248
|
+
aria-label="Font size"
|
|
249
|
+
/>
|
|
250
|
+
<div className={styles.fontSizeLabels}>
|
|
251
|
+
{STOPS.map((s, i) => (
|
|
252
|
+
<span
|
|
253
|
+
key={s}
|
|
254
|
+
className={
|
|
255
|
+
localIndex === i ? styles.fontSizeLabelActive : ""
|
|
256
|
+
}
|
|
257
|
+
>
|
|
258
|
+
{s}
|
|
259
|
+
</span>
|
|
260
|
+
))}
|
|
261
|
+
</div>
|
|
262
|
+
</div>
|
|
263
|
+
<Icon className="textIcon" systemName="text_increase" />
|
|
264
|
+
</div>
|
|
265
|
+
</li>
|
|
266
|
+
</ul>
|
|
267
|
+
<div>
|
|
268
|
+
<p
|
|
269
|
+
style={{
|
|
270
|
+
fontWeight: 500,
|
|
271
|
+
padding: "8px 0 0 20px",
|
|
272
|
+
color: "var(--md-sys-color-outline)",
|
|
273
|
+
}}
|
|
274
|
+
>
|
|
275
|
+
Motion
|
|
276
|
+
</p>
|
|
277
|
+
<ul className={styles.accModSettings}>
|
|
278
|
+
<li className={styles.accModLi}>
|
|
279
|
+
Reduce motion
|
|
280
|
+
<Switch
|
|
281
|
+
checked={draftReduceMotion}
|
|
282
|
+
onChange={setDraftReduceMotion}
|
|
283
|
+
/>
|
|
284
|
+
</li>
|
|
285
|
+
</ul>
|
|
286
|
+
</div>
|
|
287
|
+
</div>
|
|
288
|
+
</Alert>
|
|
289
|
+
);
|
|
290
|
+
}
|