@yamatozhen/design_system 1.0.0 → 1.1.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 -201
- package/README.md +101 -101
- package/package.json +50 -49
- package/scripts/postinstall.js +91 -105
- package/template/app/ClientNav.tsx +258 -310
- package/template/app/globals.css +2 -167
- package/template/app/layout.tsx +94 -128
- package/template/app/themes/dark-mc 2.css +51 -0
- package/template/app/themes/dark-mc.css +51 -51
- package/template/app/themes/dark.css +51 -51
- package/template/app/themes/light 2.css +51 -0
- package/template/app/themes/light-mc 2.css +51 -0
- package/template/app/themes/light-mc.css +51 -51
- package/template/app/themes/light.css +51 -51
- package/template/app/themes/theme 2.css +272 -0
- 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/(controls)/switch/Switch.module.css +108 -0
- package/template/components/(controls)/switch/Switch.tsx +69 -0
- 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 -478
- 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 2.tsx +107 -0
- package/template/components/tools/CustomScrollbar.tsx +107 -0
- package/template/components/tools/Divider 2.tsx +11 -0
- package/template/components/tools/Divider.tsx +11 -11
- package/template/components/tools/ReduceMotionContext 2.tsx +5 -0
- package/template/components/tools/ReduceMotionContext.tsx +5 -5
- package/template/components/tools/Sinewave 2.tsx +206 -0
- package/template/components/tools/Sinewave.tsx +396 -199
- package/template/components/tools/SinewaveProgress 2.tsx +140 -0
- package/template/components/tools/SinewaveProgress.tsx +140 -135
- package/template/components/tools/badge/Badge 2.tsx +28 -0
- 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 2.ts +7 -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 2.tsx +99 -0
- package/template/components/tools/input/Input.module 2.css +45 -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 2.tsx +39 -0
- package/template/components/tools/label/Icon.tsx +39 -0
- package/template/components/tools/label/Label 2.tsx +150 -0
- package/template/components/tools/label/Label.tsx +156 -0
- package/template/components/tools/mobileViewProvider 2.tsx +53 -0
- package/template/components/tools/mobileViewProvider.tsx +53 -58
- package/template/components/tools/ripple/ripple 2.css +38 -0
- package/template/components/tools/ripple/ripple 2.tsx +78 -0
- package/template/components/tools/ripple/ripple.css +38 -41
- package/template/components/tools/ripple/ripple.tsx +78 -53
- package/template/components/tools/shape/{ShapeMorph.tsx → Shape 2.tsx } +313 -190
- package/template/components/tools/shape/Shape.module 2.css +21 -0
- package/template/components/tools/shape/Shape.module.css +25 -0
- package/template/components/tools/shape/Shape.tsx +316 -0
- package/template/components/tools/shape/ShapeLoader 2.tsx +104 -0
- package/template/components/tools/shape/ShapeLoader.tsx +104 -101
- package/template/components/tools/shape/ShapePaths 2.ts +116 -0
- package/template/components/tools/shape/ShapePaths.ts +116 -116
- package/template/components/{layout/switch/Switch.tsx → tools/switch/Switch 2.tsx } +48 -48
- package/template/components/{layout/switch/Switch.module.css → tools/switch/Switch.module 2.css } +102 -102
- package/template/components/tools/switch/Switch.module.css +102 -102
- package/template/components/tools/switch/Switch.tsx +48 -48
- package/template/components/tools/useBodyScrollLock 2.tsx +27 -0
- package/template/components/tools/useBodyScrollLock.tsx +27 -27
- package/template/components/tools/useImageColor 2.ts +47 -0
- package/template/components/tools/useImageColor.ts +47 -47
- package/template/components/tools/useNavSheetDrag 2.tsx +196 -0
- package/template/components/tools/useNavSheetDrag.tsx +196 -196
- package/template/public/fonts/material-symbols/MaterialSymbolsRounded-VariableFont_FILL,GRAD,opsz,wght 2.woff2 +0 -0
- 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/SocialIcons.tsx +0 -88
- 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
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useCallback, useEffect, useRef, type RefObject } from "react";
|
|
3
|
+
import type { ScrollShadowVisibility, ScrollShadowOrientation } from "./ScrollShadow";
|
|
4
|
+
|
|
5
|
+
export interface UseScrollShadowProps {
|
|
6
|
+
containerRef: RefObject<HTMLElement | null>;
|
|
7
|
+
orientation: ScrollShadowOrientation;
|
|
8
|
+
offset: number;
|
|
9
|
+
visibility: ScrollShadowVisibility;
|
|
10
|
+
isEnabled: boolean;
|
|
11
|
+
onVisibilityChange?: (visibility: ScrollShadowVisibility) => void;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// Ported from HeroUI's useScrollShadow (packages/react/src/components/
|
|
15
|
+
// scroll-shadow/use-scroll-shadow.ts) — same detection algorithm, same RAF
|
|
16
|
+
// batching, same data-attribute contract the CSS masks key off of.
|
|
17
|
+
export function useScrollShadow(props: UseScrollShadowProps) {
|
|
18
|
+
const {
|
|
19
|
+
containerRef,
|
|
20
|
+
isEnabled,
|
|
21
|
+
offset,
|
|
22
|
+
onVisibilityChange,
|
|
23
|
+
orientation,
|
|
24
|
+
visibility,
|
|
25
|
+
} = props;
|
|
26
|
+
|
|
27
|
+
// Cache previous state to avoid unnecessary DOM updates.
|
|
28
|
+
const prevStateRef = useRef<{
|
|
29
|
+
hasScrollBefore: boolean;
|
|
30
|
+
hasScrollAfter: boolean;
|
|
31
|
+
} | null>(null);
|
|
32
|
+
|
|
33
|
+
// Track pending RAF to avoid multiple scheduled updates.
|
|
34
|
+
const rafIdRef = useRef<number | null>(null);
|
|
35
|
+
|
|
36
|
+
const checkOverflow = useCallback(() => {
|
|
37
|
+
const el = containerRef.current;
|
|
38
|
+
if (!el) return;
|
|
39
|
+
|
|
40
|
+
const isVertical = orientation === "vertical";
|
|
41
|
+
const scrollStart = isVertical ? el.scrollTop : Math.abs(el.scrollLeft);
|
|
42
|
+
const scrollSize = isVertical ? el.scrollHeight : el.scrollWidth;
|
|
43
|
+
const clientSize = isVertical ? el.clientHeight : el.clientWidth;
|
|
44
|
+
|
|
45
|
+
const hasScrollBefore = scrollStart > offset;
|
|
46
|
+
const hasScrollAfter = scrollStart + clientSize + offset < scrollSize - 1;
|
|
47
|
+
|
|
48
|
+
// Skip DOM updates if state hasn't changed.
|
|
49
|
+
const prevState = prevStateRef.current;
|
|
50
|
+
if (
|
|
51
|
+
prevState &&
|
|
52
|
+
prevState.hasScrollBefore === hasScrollBefore &&
|
|
53
|
+
prevState.hasScrollAfter === hasScrollAfter
|
|
54
|
+
) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
prevStateRef.current = { hasScrollBefore, hasScrollAfter };
|
|
58
|
+
|
|
59
|
+
// Cancel previous pending update.
|
|
60
|
+
if (rafIdRef.current !== null) {
|
|
61
|
+
cancelAnimationFrame(rafIdRef.current);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Batch DOM updates with RAF for better performance.
|
|
65
|
+
rafIdRef.current = requestAnimationFrame(() => {
|
|
66
|
+
rafIdRef.current = null;
|
|
67
|
+
|
|
68
|
+
if (isVertical) {
|
|
69
|
+
if (hasScrollBefore && hasScrollAfter) {
|
|
70
|
+
el.dataset.topBottomScroll = "true";
|
|
71
|
+
delete el.dataset.topScroll;
|
|
72
|
+
delete el.dataset.bottomScroll;
|
|
73
|
+
onVisibilityChange?.("both");
|
|
74
|
+
} else {
|
|
75
|
+
el.dataset.topScroll = String(hasScrollBefore);
|
|
76
|
+
el.dataset.bottomScroll = String(hasScrollAfter);
|
|
77
|
+
delete el.dataset.topBottomScroll;
|
|
78
|
+
if (onVisibilityChange) {
|
|
79
|
+
if (hasScrollBefore) onVisibilityChange("top");
|
|
80
|
+
else if (hasScrollAfter) onVisibilityChange("bottom");
|
|
81
|
+
else onVisibilityChange("none");
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
} else {
|
|
85
|
+
if (hasScrollBefore && hasScrollAfter) {
|
|
86
|
+
el.dataset.leftRightScroll = "true";
|
|
87
|
+
delete el.dataset.leftScroll;
|
|
88
|
+
delete el.dataset.rightScroll;
|
|
89
|
+
onVisibilityChange?.("both");
|
|
90
|
+
} else {
|
|
91
|
+
el.dataset.leftScroll = String(hasScrollBefore);
|
|
92
|
+
el.dataset.rightScroll = String(hasScrollAfter);
|
|
93
|
+
delete el.dataset.leftRightScroll;
|
|
94
|
+
if (onVisibilityChange) {
|
|
95
|
+
if (hasScrollBefore) onVisibilityChange("left");
|
|
96
|
+
else if (hasScrollAfter) onVisibilityChange("right");
|
|
97
|
+
else onVisibilityChange("none");
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
}, [containerRef, orientation, offset, onVisibilityChange]);
|
|
103
|
+
|
|
104
|
+
useEffect(() => {
|
|
105
|
+
const el = containerRef.current;
|
|
106
|
+
if (!el || !isEnabled || visibility !== "auto") return;
|
|
107
|
+
|
|
108
|
+
// Initial check.
|
|
109
|
+
checkOverflow();
|
|
110
|
+
|
|
111
|
+
// Use passive listener for better scroll performance.
|
|
112
|
+
el.addEventListener("scroll", checkOverflow, { passive: true });
|
|
113
|
+
|
|
114
|
+
// Monitor size changes.
|
|
115
|
+
const resizeObserver = new ResizeObserver(checkOverflow);
|
|
116
|
+
resizeObserver.observe(el);
|
|
117
|
+
|
|
118
|
+
return () => {
|
|
119
|
+
el.removeEventListener("scroll", checkOverflow);
|
|
120
|
+
resizeObserver.disconnect();
|
|
121
|
+
|
|
122
|
+
// Cancel pending RAF and cleanup cache.
|
|
123
|
+
if (rafIdRef.current !== null) {
|
|
124
|
+
cancelAnimationFrame(rafIdRef.current);
|
|
125
|
+
rafIdRef.current = null;
|
|
126
|
+
}
|
|
127
|
+
prevStateRef.current = null;
|
|
128
|
+
};
|
|
129
|
+
}, [containerRef, visibility, isEnabled, checkOverflow]);
|
|
130
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
export type SeparatorOrientation = "horizontal" | "vertical";
|
|
4
|
+
export type SeparatorVariant = "default" | "secondary" | "tertiary";
|
|
5
|
+
|
|
6
|
+
export interface SeparatorProps {
|
|
7
|
+
orientation?: SeparatorOrientation;
|
|
8
|
+
variant?: SeparatorVariant;
|
|
9
|
+
/** Marks it as a plain visual divider (aria-hidden, no `separator` role)
|
|
10
|
+
* — the correct choice whenever the grouping is already conveyed by
|
|
11
|
+
* something else nearby (a heading, a layout gap). A separator with
|
|
12
|
+
* `children` (a label) is never decorative, regardless of this prop —
|
|
13
|
+
* labeled dividers are always meaningful content. @default false */
|
|
14
|
+
decorative?: boolean;
|
|
15
|
+
/** Length along the separator's own axis, in pixels. Horizontal ignores
|
|
16
|
+
* this and fills 100% of its container instead; vertical has no
|
|
17
|
+
* container-relative axis to fill, so it needs an explicit number.
|
|
18
|
+
* @default 64 */
|
|
19
|
+
length?: number;
|
|
20
|
+
/** Optional centered label — e.g. "OR" between two form sections. */
|
|
21
|
+
children?: React.ReactNode;
|
|
22
|
+
style?: React.CSSProperties;
|
|
23
|
+
className?: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// A plain 1px line — the sinewave version this originally shipped with
|
|
27
|
+
// didn't read well as a divider, so this is back to the same visual
|
|
28
|
+
// language as tools/Divider.tsx (that one's untouched, still available
|
|
29
|
+
// for anywhere that wants a bare line with no variant/label options).
|
|
30
|
+
const VARIANT_COLOR: Record<SeparatorVariant, string> = {
|
|
31
|
+
default: "var(--globalUIBorderCard)",
|
|
32
|
+
secondary: "var(--md-sys-color-secondary)",
|
|
33
|
+
tertiary: "var(--md-sys-color-tertiary)",
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export default function Separator({
|
|
37
|
+
orientation = "horizontal",
|
|
38
|
+
variant = "default",
|
|
39
|
+
decorative = false,
|
|
40
|
+
length = 64,
|
|
41
|
+
children,
|
|
42
|
+
style,
|
|
43
|
+
className,
|
|
44
|
+
}: SeparatorProps) {
|
|
45
|
+
const color = VARIANT_COLOR[variant];
|
|
46
|
+
const isVertical = orientation === "vertical";
|
|
47
|
+
const isDecorative = decorative && !children;
|
|
48
|
+
|
|
49
|
+
const lineStyle: React.CSSProperties = isVertical
|
|
50
|
+
? { width: 1, flex: children ? undefined : "1 1 auto", background: color }
|
|
51
|
+
: {
|
|
52
|
+
height: 1,
|
|
53
|
+
flex: children ? "1 1 auto" : undefined,
|
|
54
|
+
background: color,
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const rootStyle: React.CSSProperties = isVertical
|
|
58
|
+
? {
|
|
59
|
+
display: "inline-flex",
|
|
60
|
+
flexDirection: "column",
|
|
61
|
+
alignItems: "center",
|
|
62
|
+
width: 1,
|
|
63
|
+
height: length,
|
|
64
|
+
...style,
|
|
65
|
+
}
|
|
66
|
+
: {
|
|
67
|
+
display: "flex",
|
|
68
|
+
alignItems: "center",
|
|
69
|
+
width: "100%",
|
|
70
|
+
gap: 12,
|
|
71
|
+
...style,
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
if (!children) {
|
|
75
|
+
return (
|
|
76
|
+
<div
|
|
77
|
+
role={isDecorative ? undefined : "separator"}
|
|
78
|
+
aria-hidden={isDecorative || undefined}
|
|
79
|
+
aria-orientation={isDecorative ? undefined : orientation}
|
|
80
|
+
className={className}
|
|
81
|
+
style={rootStyle}
|
|
82
|
+
>
|
|
83
|
+
<div style={{ ...lineStyle, width: isVertical ? 1 : "100%", height: isVertical ? "100%" : 1 }} />
|
|
84
|
+
</div>
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Labeled: split into two line segments either side of the label —
|
|
89
|
+
// vertical + a label is an unusual combination, but the split still
|
|
90
|
+
// degrades reasonably (two short segments above/below the label).
|
|
91
|
+
return (
|
|
92
|
+
<div
|
|
93
|
+
role="separator"
|
|
94
|
+
aria-orientation={orientation}
|
|
95
|
+
className={className}
|
|
96
|
+
style={rootStyle}
|
|
97
|
+
>
|
|
98
|
+
<div style={lineStyle} />
|
|
99
|
+
<span
|
|
100
|
+
style={{
|
|
101
|
+
flexShrink: 0,
|
|
102
|
+
fontSize: 12,
|
|
103
|
+
fontWeight: 600,
|
|
104
|
+
color: "var(--md-sys-color-on-surface-variant)",
|
|
105
|
+
}}
|
|
106
|
+
>
|
|
107
|
+
{children}
|
|
108
|
+
</span>
|
|
109
|
+
<div style={lineStyle} />
|
|
110
|
+
</div>
|
|
111
|
+
);
|
|
112
|
+
}
|
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import React, { useState, useEffect, useCallback } from "react";
|
|
3
|
+
import Modal from "@/components/(overlays)/modal/Modal";
|
|
4
|
+
import Button from "@/components/(buttons)/button";
|
|
5
|
+
import Icon from "@/components/tools/label/Icon";
|
|
6
|
+
import Label from "@/components/tools/label/Label";
|
|
7
|
+
import List from "@/components/(layout)/list/List";
|
|
8
|
+
import Slider from "@/components/(controls)/slider/Slider";
|
|
9
|
+
import Card from "@/components/(layout)/card/Card";
|
|
10
|
+
|
|
11
|
+
// Defined outside the component — same array reference across all renders.
|
|
12
|
+
const STOPS = [16, 18, 20, 24] as const;
|
|
13
|
+
type FontSize = (typeof STOPS)[number];
|
|
14
|
+
|
|
15
|
+
interface AccModProps {
|
|
16
|
+
isOpen: boolean;
|
|
17
|
+
onSave?: (data: {
|
|
18
|
+
contrast: "none" | "medium";
|
|
19
|
+
largerText: boolean;
|
|
20
|
+
fontSize: FontSize;
|
|
21
|
+
reduceMotion: boolean;
|
|
22
|
+
showBorders: boolean;
|
|
23
|
+
disableBrightness: boolean;
|
|
24
|
+
}) => void;
|
|
25
|
+
onCancel?: () => void;
|
|
26
|
+
contrast?: "none" | "medium";
|
|
27
|
+
largerText?: boolean;
|
|
28
|
+
fontSize?: FontSize;
|
|
29
|
+
reduceMotion?: boolean;
|
|
30
|
+
showBorders?: boolean;
|
|
31
|
+
disableBrightness?: boolean;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export default function AccessibilityModal({
|
|
35
|
+
isOpen,
|
|
36
|
+
onSave,
|
|
37
|
+
onCancel,
|
|
38
|
+
contrast = "none",
|
|
39
|
+
largerText = false,
|
|
40
|
+
fontSize = 16,
|
|
41
|
+
reduceMotion = false,
|
|
42
|
+
showBorders = false,
|
|
43
|
+
disableBrightness = false,
|
|
44
|
+
}: AccModProps) {
|
|
45
|
+
const [draftContrast, setDraftContrast] = useState<"none" | "medium">(
|
|
46
|
+
contrast,
|
|
47
|
+
);
|
|
48
|
+
const [draftLargerText, setDraftLargerText] = useState(largerText);
|
|
49
|
+
const [draftReduceMotion, setDraftReduceMotion] = useState(reduceMotion);
|
|
50
|
+
const [draftShowBorders, setDraftShowBorders] = useState(showBorders);
|
|
51
|
+
const [draftDisableBrightness, setDraftDisableBrightness] =
|
|
52
|
+
useState(disableBrightness);
|
|
53
|
+
const [localIndex, setLocalIndex] = useState<number>(
|
|
54
|
+
Math.max(0, STOPS.indexOf(fontSize)),
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
// Re-sync draft state from committed props every time the modal opens.
|
|
58
|
+
// All prop values are included in the dependency array. Coupled with a
|
|
59
|
+
// genuine external DOM write (the --font-size-base custom property), so
|
|
60
|
+
// this can't be split into a render-time state adjustment.
|
|
61
|
+
/* eslint-disable react-hooks/set-state-in-effect */
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
if (!isOpen) return;
|
|
64
|
+
setDraftContrast(contrast);
|
|
65
|
+
setDraftLargerText(largerText);
|
|
66
|
+
setDraftReduceMotion(reduceMotion);
|
|
67
|
+
setDraftShowBorders(showBorders);
|
|
68
|
+
setDraftDisableBrightness(disableBrightness);
|
|
69
|
+
setLocalIndex(Math.max(0, STOPS.indexOf(fontSize)));
|
|
70
|
+
document.documentElement.style.setProperty(
|
|
71
|
+
"--font-size-base",
|
|
72
|
+
`${fontSize}px`,
|
|
73
|
+
);
|
|
74
|
+
}, [
|
|
75
|
+
isOpen,
|
|
76
|
+
contrast,
|
|
77
|
+
largerText,
|
|
78
|
+
reduceMotion,
|
|
79
|
+
showBorders,
|
|
80
|
+
disableBrightness,
|
|
81
|
+
fontSize,
|
|
82
|
+
]);
|
|
83
|
+
/* eslint-enable react-hooks/set-state-in-effect */
|
|
84
|
+
|
|
85
|
+
const handleSliderChange = useCallback((value: number) => {
|
|
86
|
+
setLocalIndex(value);
|
|
87
|
+
document.documentElement.style.setProperty(
|
|
88
|
+
"--font-size-base",
|
|
89
|
+
`${STOPS[value]}px`,
|
|
90
|
+
);
|
|
91
|
+
}, []);
|
|
92
|
+
|
|
93
|
+
const handleLargerTextChange = useCallback(
|
|
94
|
+
(on: boolean) => {
|
|
95
|
+
setDraftLargerText(on);
|
|
96
|
+
document.documentElement.style.setProperty(
|
|
97
|
+
"--font-size-base",
|
|
98
|
+
on ? `${STOPS[localIndex]}px` : `${fontSize}px`,
|
|
99
|
+
);
|
|
100
|
+
},
|
|
101
|
+
[localIndex, fontSize],
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
const handleContrastChange = useCallback((on: boolean) => {
|
|
105
|
+
setDraftContrast(on ? "medium" : "none");
|
|
106
|
+
}, []);
|
|
107
|
+
|
|
108
|
+
const handleSave = useCallback(() => {
|
|
109
|
+
onSave?.({
|
|
110
|
+
contrast: draftContrast,
|
|
111
|
+
largerText: draftLargerText,
|
|
112
|
+
fontSize: draftLargerText ? STOPS[localIndex] : 16,
|
|
113
|
+
reduceMotion: draftReduceMotion,
|
|
114
|
+
showBorders: draftShowBorders,
|
|
115
|
+
disableBrightness: draftDisableBrightness,
|
|
116
|
+
});
|
|
117
|
+
}, [
|
|
118
|
+
onSave,
|
|
119
|
+
draftContrast,
|
|
120
|
+
draftLargerText,
|
|
121
|
+
localIndex,
|
|
122
|
+
draftReduceMotion,
|
|
123
|
+
draftShowBorders,
|
|
124
|
+
draftDisableBrightness,
|
|
125
|
+
]);
|
|
126
|
+
|
|
127
|
+
const handleCancel = useCallback(() => {
|
|
128
|
+
document.documentElement.style.setProperty(
|
|
129
|
+
"--font-size-base",
|
|
130
|
+
`${fontSize}px`,
|
|
131
|
+
);
|
|
132
|
+
onCancel?.();
|
|
133
|
+
}, [onCancel, fontSize]);
|
|
134
|
+
|
|
135
|
+
return (
|
|
136
|
+
<Modal
|
|
137
|
+
size="sm"
|
|
138
|
+
isPresented={isOpen}
|
|
139
|
+
isDismissable={true}
|
|
140
|
+
onOpenChange={(open) => {
|
|
141
|
+
if (!open) handleCancel();
|
|
142
|
+
}}
|
|
143
|
+
>
|
|
144
|
+
<Modal.Header
|
|
145
|
+
title="Accessibility"
|
|
146
|
+
withIcon={{
|
|
147
|
+
systemName: "accessibility_new",
|
|
148
|
+
variant: "secondary",
|
|
149
|
+
shapePath: "gem",
|
|
150
|
+
}}
|
|
151
|
+
closeTrigger
|
|
152
|
+
/>
|
|
153
|
+
<Modal.Content>
|
|
154
|
+
<div style={{ display: "flex", flexDirection: "column", gap: "12px" }}>
|
|
155
|
+
<Card variant="lowest">
|
|
156
|
+
<p>
|
|
157
|
+
Personalise your experience in ways that work best for you with
|
|
158
|
+
accessibility settings for vision and motion.
|
|
159
|
+
</p>
|
|
160
|
+
</Card>
|
|
161
|
+
<Card variant="highest">
|
|
162
|
+
<p>
|
|
163
|
+
Remaining triggers to be hooked: REDUCE_TRANSPARENCY,
|
|
164
|
+
<br />
|
|
165
|
+
ON/OFF_LABELS,
|
|
166
|
+
<br />
|
|
167
|
+
BOLD_TEXT
|
|
168
|
+
<br />
|
|
169
|
+
</p>
|
|
170
|
+
</Card>
|
|
171
|
+
<Card variant="highest">
|
|
172
|
+
<p>
|
|
173
|
+
Remaining to be fixed: SHOW_BORDERS <br /> REDUCE_MOTION (Framer)
|
|
174
|
+
</p>
|
|
175
|
+
</Card>
|
|
176
|
+
<List style={{ marginTop: 24 }}>
|
|
177
|
+
<List.Group
|
|
178
|
+
variant="tertiary"
|
|
179
|
+
title="Display & Text Size"
|
|
180
|
+
comment="Increase color contrast between app colors foreground and background colors."
|
|
181
|
+
>
|
|
182
|
+
<List.Row
|
|
183
|
+
title="Increase Contrast"
|
|
184
|
+
withIcon={{ shapePath: "bun", systemName: "contrast" }}
|
|
185
|
+
toggle={{
|
|
186
|
+
checked: draftContrast === "medium",
|
|
187
|
+
onToggleOff: () => handleContrastChange(false),
|
|
188
|
+
onToggleOn: () => handleContrastChange(true),
|
|
189
|
+
}}
|
|
190
|
+
/>
|
|
191
|
+
</List.Group>
|
|
192
|
+
<List.Group
|
|
193
|
+
variant="secondary"
|
|
194
|
+
comment="Increase contrast by reducing transparency and blurs on some backgrounds to increase legibility."
|
|
195
|
+
>
|
|
196
|
+
<List.Row
|
|
197
|
+
title="Reduce Transparency"
|
|
198
|
+
withIcon={{ shapePath: "ghost-ish", systemName: "deblur" }}
|
|
199
|
+
toggle={{
|
|
200
|
+
checked: draftContrast === "medium",
|
|
201
|
+
onToggleOff: () => handleContrastChange(false),
|
|
202
|
+
onToggleOn: () => handleContrastChange(true),
|
|
203
|
+
}}
|
|
204
|
+
/>
|
|
205
|
+
</List.Group>
|
|
206
|
+
<List.Group variant="lowest">
|
|
207
|
+
<List.Row
|
|
208
|
+
title="On/Off Labels"
|
|
209
|
+
toggle={{
|
|
210
|
+
checked: draftReduceMotion === true,
|
|
211
|
+
onToggleOff: () => setDraftReduceMotion(false),
|
|
212
|
+
onToggleOn: () => setDraftReduceMotion(true),
|
|
213
|
+
}}
|
|
214
|
+
/>
|
|
215
|
+
<List.Row
|
|
216
|
+
title="Show Borders"
|
|
217
|
+
toggle={{
|
|
218
|
+
checked: draftShowBorders === true,
|
|
219
|
+
onToggleOff: () => setDraftShowBorders(false),
|
|
220
|
+
onToggleOn: () => setDraftShowBorders(true),
|
|
221
|
+
}}
|
|
222
|
+
/>
|
|
223
|
+
<List.Row
|
|
224
|
+
title="Disable Bright Effect"
|
|
225
|
+
toggle={{
|
|
226
|
+
checked: draftDisableBrightness === true,
|
|
227
|
+
onToggleOff: () => setDraftDisableBrightness(false),
|
|
228
|
+
onToggleOn: () => setDraftDisableBrightness(true),
|
|
229
|
+
}}
|
|
230
|
+
/>
|
|
231
|
+
</List.Group>
|
|
232
|
+
<List.Group
|
|
233
|
+
variant="primary"
|
|
234
|
+
comment="Reduce the motion effect of the app's interface including the bouncing effect of various components."
|
|
235
|
+
>
|
|
236
|
+
<List.Row
|
|
237
|
+
title="Reduce Motion"
|
|
238
|
+
withIcon={{
|
|
239
|
+
shapePath: "4-leaf-clover",
|
|
240
|
+
systemName: "motion_mode",
|
|
241
|
+
}}
|
|
242
|
+
toggle={{
|
|
243
|
+
checked: draftReduceMotion === true,
|
|
244
|
+
onToggleOff: () => setDraftReduceMotion(false),
|
|
245
|
+
onToggleOn: () => setDraftReduceMotion(true),
|
|
246
|
+
}}
|
|
247
|
+
/>
|
|
248
|
+
</List.Group>
|
|
249
|
+
<List.Group
|
|
250
|
+
variant="lowest"
|
|
251
|
+
comment="Increase color contrast between app colors foreground and background colors."
|
|
252
|
+
>
|
|
253
|
+
<List.Row
|
|
254
|
+
title="Larger Text"
|
|
255
|
+
toggle={{
|
|
256
|
+
checked: draftLargerText === true,
|
|
257
|
+
onToggleOff: () => handleLargerTextChange(false),
|
|
258
|
+
onToggleOn: () => handleLargerTextChange(true),
|
|
259
|
+
}}
|
|
260
|
+
>
|
|
261
|
+
{draftLargerText == true && (
|
|
262
|
+
<div
|
|
263
|
+
style={{
|
|
264
|
+
display: "flex",
|
|
265
|
+
alignItems: "center",
|
|
266
|
+
gap: 8,
|
|
267
|
+
margin: -6,
|
|
268
|
+
}}
|
|
269
|
+
>
|
|
270
|
+
<Icon systemName="text_decrease" />
|
|
271
|
+
<Slider
|
|
272
|
+
label="Font Size"
|
|
273
|
+
stops={4}
|
|
274
|
+
minValue={0}
|
|
275
|
+
maxValue={3}
|
|
276
|
+
step={1}
|
|
277
|
+
value={localIndex}
|
|
278
|
+
showOutput={String(STOPS[localIndex])}
|
|
279
|
+
onChange={(v) => handleSliderChange(v as number)}
|
|
280
|
+
/>
|
|
281
|
+
<Icon systemName="text_increase" />
|
|
282
|
+
</div>
|
|
283
|
+
)}
|
|
284
|
+
</List.Row>
|
|
285
|
+
<List.Row
|
|
286
|
+
title="Bold Text"
|
|
287
|
+
toggle={{
|
|
288
|
+
checked: draftContrast === "medium",
|
|
289
|
+
onToggleOff: () => handleContrastChange(false),
|
|
290
|
+
onToggleOn: () => handleContrastChange(true),
|
|
291
|
+
}}
|
|
292
|
+
/>
|
|
293
|
+
</List.Group>
|
|
294
|
+
</List>
|
|
295
|
+
</div>
|
|
296
|
+
</Modal.Content>
|
|
297
|
+
<Modal.Footer>
|
|
298
|
+
<Button value="cancel" text>
|
|
299
|
+
<Label label="Cancel" />
|
|
300
|
+
</Button>
|
|
301
|
+
<Button value="confirm" primary onClick={handleSave}>
|
|
302
|
+
<Label label="Save settings" />
|
|
303
|
+
</Button>
|
|
304
|
+
</Modal.Footer>
|
|
305
|
+
</Modal>
|
|
306
|
+
);
|
|
307
|
+
}
|