@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
|
@@ -1,118 +1,119 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import React, { useRef } from "react";
|
|
4
|
-
import styles from "./Button.module.css";
|
|
5
|
-
import Ripple, { RippleHandle } from "@/components/tools/ripple/ripple";
|
|
6
|
-
import Icon from "@/components/tools/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
primary,
|
|
37
|
-
|
|
38
|
-
secondary,
|
|
39
|
-
|
|
40
|
-
tertiary,
|
|
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
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}
|
|
108
|
-
>
|
|
109
|
-
<Icon systemName={systemName}
|
|
110
|
-
<
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import React, { useRef } from "react";
|
|
4
|
+
import styles from "./Button.module.css";
|
|
5
|
+
import Ripple, { RippleHandle } from "@/components/tools/ripple/ripple";
|
|
6
|
+
import Icon from "@/components/tools/label/Icon";
|
|
7
|
+
import Label from "@/components/tools/label/Label";
|
|
8
|
+
|
|
9
|
+
type FABProps = Omit<
|
|
10
|
+
React.ButtonHTMLAttributes<HTMLButtonElement>,
|
|
11
|
+
"children"
|
|
12
|
+
> & {
|
|
13
|
+
// color booleans — first truthy one wins; defaults to "primary"
|
|
14
|
+
primary?: boolean;
|
|
15
|
+
"primary-bold"?: boolean;
|
|
16
|
+
secondary?: boolean;
|
|
17
|
+
"secondary-bold"?: boolean;
|
|
18
|
+
tertiary?: boolean;
|
|
19
|
+
"tertiary-bold"?: boolean;
|
|
20
|
+
// size booleans — first truthy one wins; defaults to "m"
|
|
21
|
+
xs?: boolean;
|
|
22
|
+
sm?: boolean;
|
|
23
|
+
l?: boolean;
|
|
24
|
+
xl?: boolean;
|
|
25
|
+
elevated?: boolean;
|
|
26
|
+
loading?: boolean;
|
|
27
|
+
rippleColor?: string;
|
|
28
|
+
systemName: string;
|
|
29
|
+
label?: string;
|
|
30
|
+
scaleOff?: boolean;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const FAB = React.forwardRef<HTMLButtonElement, FABProps>(
|
|
34
|
+
(
|
|
35
|
+
{
|
|
36
|
+
"primary-bold": primaryBold,
|
|
37
|
+
primary,
|
|
38
|
+
"secondary-bold": secondaryBold,
|
|
39
|
+
secondary,
|
|
40
|
+
"tertiary-bold": tertiaryBold,
|
|
41
|
+
tertiary,
|
|
42
|
+
xs,
|
|
43
|
+
sm,
|
|
44
|
+
l,
|
|
45
|
+
xl,
|
|
46
|
+
elevated = false,
|
|
47
|
+
loading = false,
|
|
48
|
+
disabled,
|
|
49
|
+
onClick,
|
|
50
|
+
systemName,
|
|
51
|
+
label,
|
|
52
|
+
rippleColor,
|
|
53
|
+
scaleOff,
|
|
54
|
+
...rest
|
|
55
|
+
},
|
|
56
|
+
ref,
|
|
57
|
+
) => {
|
|
58
|
+
const variant = primaryBold
|
|
59
|
+
? "primary-bold"
|
|
60
|
+
: primary
|
|
61
|
+
? "primary"
|
|
62
|
+
: secondaryBold
|
|
63
|
+
? "secondary-bold"
|
|
64
|
+
: secondary
|
|
65
|
+
? "secondary"
|
|
66
|
+
: tertiaryBold
|
|
67
|
+
? "tertiary-bold"
|
|
68
|
+
: tertiary
|
|
69
|
+
? "tertiary"
|
|
70
|
+
: "primary";
|
|
71
|
+
|
|
72
|
+
const sizeClass = xs
|
|
73
|
+
? "fabXs"
|
|
74
|
+
: sm
|
|
75
|
+
? "fabSm"
|
|
76
|
+
: l
|
|
77
|
+
? "fabL"
|
|
78
|
+
: xl
|
|
79
|
+
? "fabXl"
|
|
80
|
+
: "fabM";
|
|
81
|
+
|
|
82
|
+
const rippleRef = useRef<RippleHandle>(null);
|
|
83
|
+
|
|
84
|
+
const isDisabled = disabled || loading;
|
|
85
|
+
|
|
86
|
+
const handleClick = (e: React.MouseEvent<HTMLButtonElement>) => {
|
|
87
|
+
if (!isDisabled) {
|
|
88
|
+
rippleRef.current?.triggerRipple(e);
|
|
89
|
+
onClick?.(e);
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
return (
|
|
94
|
+
<button
|
|
95
|
+
ref={ref}
|
|
96
|
+
disabled={isDisabled}
|
|
97
|
+
className={`${styles[variant]} ${styles.fab} ${styles[sizeClass]} ${scaleOff && styles.scaleOff}`}
|
|
98
|
+
onClick={handleClick}
|
|
99
|
+
{...rest}
|
|
100
|
+
style={{
|
|
101
|
+
boxShadow:
|
|
102
|
+
elevated && !isDisabled
|
|
103
|
+
? "inset 0 0 0 1px var(--globalUIBorderCard), 0 1px 1px rgba(0, 0, 0, 0.1), 0 1px 3px rgba(0, 0, 0, 0.1),0 2px 6px rgba(0, 0, 0, 0.1)"
|
|
104
|
+
: "inset 0 0 0 1px var(--globalUIBorder)",
|
|
105
|
+
aspectRatio: label ? "none" : "1/1",
|
|
106
|
+
...rest.style,
|
|
107
|
+
}}
|
|
108
|
+
>
|
|
109
|
+
<Icon systemName={systemName} />
|
|
110
|
+
{label && <Label label={label} />}
|
|
111
|
+
<Ripple ref={rippleRef} rippleColor={rippleColor} />
|
|
112
|
+
</button>
|
|
113
|
+
);
|
|
114
|
+
},
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
FAB.displayName = "FAB";
|
|
118
|
+
|
|
119
|
+
export default FAB;
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import React, { useRef } from "react";
|
|
4
|
+
import styles from "./Button.module.css";
|
|
5
|
+
import Ripple, { RippleHandle } from "@/components/tools/ripple/ripple";
|
|
6
|
+
export type ButtonVariant =
|
|
7
|
+
| "primary"
|
|
8
|
+
| "primary-bold"
|
|
9
|
+
| "secondary"
|
|
10
|
+
| "secondary-bold"
|
|
11
|
+
| "tertiary"
|
|
12
|
+
| "tertiary-bold"
|
|
13
|
+
| "error"
|
|
14
|
+
| "error-bold"
|
|
15
|
+
| "outlined"
|
|
16
|
+
| "text"
|
|
17
|
+
| "link";
|
|
18
|
+
|
|
19
|
+
type ButtonProps = React.ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
20
|
+
// preferred: single variant prop
|
|
21
|
+
variant?: ButtonVariant;
|
|
22
|
+
// variant booleans — kept for flexibility; first truthy one wins and takes
|
|
23
|
+
// priority over `variant` if both are supplied; defaults to "primary"
|
|
24
|
+
primary?: boolean;
|
|
25
|
+
"primary-bold"?: boolean;
|
|
26
|
+
secondary?: boolean;
|
|
27
|
+
"secondary-bold"?: boolean;
|
|
28
|
+
tertiary?: boolean;
|
|
29
|
+
"tertiary-bold"?: boolean;
|
|
30
|
+
error?: boolean;
|
|
31
|
+
"error-bold"?: boolean;
|
|
32
|
+
outlined?: boolean;
|
|
33
|
+
text?: boolean;
|
|
34
|
+
link?: boolean;
|
|
35
|
+
// mode booleans — first truthy one wins; defaults to "icon-label"
|
|
36
|
+
loading?: boolean;
|
|
37
|
+
elevated?: boolean;
|
|
38
|
+
rippleColor?: string;
|
|
39
|
+
fullWidth?: boolean;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|
43
|
+
(
|
|
44
|
+
{
|
|
45
|
+
variant,
|
|
46
|
+
"primary-bold": primaryBold,
|
|
47
|
+
primary,
|
|
48
|
+
"secondary-bold": secondaryBold,
|
|
49
|
+
secondary,
|
|
50
|
+
"tertiary-bold": tertiaryBold,
|
|
51
|
+
tertiary,
|
|
52
|
+
"error-bold": errorBold,
|
|
53
|
+
error,
|
|
54
|
+
outlined,
|
|
55
|
+
text,
|
|
56
|
+
link,
|
|
57
|
+
loading = false,
|
|
58
|
+
disabled,
|
|
59
|
+
onClick,
|
|
60
|
+
children,
|
|
61
|
+
elevated = false,
|
|
62
|
+
rippleColor,
|
|
63
|
+
fullWidth = false,
|
|
64
|
+
className,
|
|
65
|
+
...rest
|
|
66
|
+
},
|
|
67
|
+
ref,
|
|
68
|
+
) => {
|
|
69
|
+
const booleanVariants = [
|
|
70
|
+
primaryBold,
|
|
71
|
+
primary,
|
|
72
|
+
secondaryBold,
|
|
73
|
+
secondary,
|
|
74
|
+
tertiaryBold,
|
|
75
|
+
tertiary,
|
|
76
|
+
errorBold,
|
|
77
|
+
error,
|
|
78
|
+
outlined,
|
|
79
|
+
text,
|
|
80
|
+
link,
|
|
81
|
+
];
|
|
82
|
+
|
|
83
|
+
// Booleans take priority over `variant` for backwards compatibility;
|
|
84
|
+
// falls back to `variant` prop, then defaults to "primary".
|
|
85
|
+
const resolvedVariant: ButtonVariant = primaryBold
|
|
86
|
+
? "primary-bold"
|
|
87
|
+
: primary
|
|
88
|
+
? "primary"
|
|
89
|
+
: secondaryBold
|
|
90
|
+
? "secondary-bold"
|
|
91
|
+
: secondary
|
|
92
|
+
? "secondary"
|
|
93
|
+
: tertiaryBold
|
|
94
|
+
? "tertiary-bold"
|
|
95
|
+
: tertiary
|
|
96
|
+
? "tertiary"
|
|
97
|
+
: errorBold
|
|
98
|
+
? "error-bold"
|
|
99
|
+
: error
|
|
100
|
+
? "error"
|
|
101
|
+
: outlined
|
|
102
|
+
? "outlined"
|
|
103
|
+
: text
|
|
104
|
+
? "text"
|
|
105
|
+
: link
|
|
106
|
+
? "link"
|
|
107
|
+
: variant
|
|
108
|
+
? variant
|
|
109
|
+
: "primary";
|
|
110
|
+
|
|
111
|
+
if (process.env.NODE_ENV !== "production") {
|
|
112
|
+
const variantCount =
|
|
113
|
+
booleanVariants.filter(Boolean).length + (variant ? 1 : 0);
|
|
114
|
+
if (variantCount === 0) {
|
|
115
|
+
console.warn(
|
|
116
|
+
'<Button>: No variant provided. Specify `variant` (or one of the legacy boolean props: primary, primary-bold, secondary, secondary-bold, tertiary, tertiary-bold, error, error-bold, outlined, text, link). Defaulting to "primary".',
|
|
117
|
+
);
|
|
118
|
+
} else if (variantCount > 1) {
|
|
119
|
+
console.warn(
|
|
120
|
+
"<Button>: Multiple variant sources provided — boolean props take priority over `variant`, and only the first truthy boolean is used. Remove the extras.",
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const rippleRef = useRef<RippleHandle>(null);
|
|
126
|
+
|
|
127
|
+
const isDisabled = disabled || loading;
|
|
128
|
+
|
|
129
|
+
const handleClick = (e: React.MouseEvent<HTMLButtonElement>) => {
|
|
130
|
+
if (!isDisabled) {
|
|
131
|
+
rippleRef.current?.triggerRipple(e);
|
|
132
|
+
onClick?.(e);
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
return (
|
|
137
|
+
<button
|
|
138
|
+
ref={ref}
|
|
139
|
+
disabled={isDisabled}
|
|
140
|
+
className={`${styles[resolvedVariant]} ${styles.buttonStyle}${className ? ` ${className}` : ""}`}
|
|
141
|
+
onClick={handleClick}
|
|
142
|
+
{...rest}
|
|
143
|
+
style={{
|
|
144
|
+
...rest.style,
|
|
145
|
+
width: fullWidth ? "100%" : "fit-content",
|
|
146
|
+
...(elevated && !isDisabled
|
|
147
|
+
? {
|
|
148
|
+
boxShadow:
|
|
149
|
+
"inset 0 0 0 1px var(--globalUIBorder), 0 1px 1px rgba(0, 0, 0, 0.1), 0 1px 3px rgba(0, 0, 0, 0.1), 0 2px 6px rgba(0, 0, 0, 0.1)",
|
|
150
|
+
}
|
|
151
|
+
: {}),
|
|
152
|
+
}}
|
|
153
|
+
>
|
|
154
|
+
{children}
|
|
155
|
+
{/* Always render Ripple; handle disabled in trigger */}
|
|
156
|
+
<Ripple ref={rippleRef} rippleColor={rippleColor} />
|
|
157
|
+
</button>
|
|
158
|
+
);
|
|
159
|
+
},
|
|
160
|
+
);
|
|
161
|
+
|
|
162
|
+
Button.displayName = "Button";
|
|
163
|
+
|
|
164
|
+
export default Button;
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
.slider {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
gap: 8px;
|
|
5
|
+
padding: 0 14px 28px 14px;
|
|
6
|
+
width: 100%;
|
|
7
|
+
--slider-color: var(--md-sys-color-primary);
|
|
8
|
+
--pill-color: white;
|
|
9
|
+
/* Clearance between the track's edge and the `stops` dots. Raise to push
|
|
10
|
+
them further out, 0 to sit them flush against it. */
|
|
11
|
+
--slider-stop-offset: 12px;
|
|
12
|
+
/* Diameter of those dots. */
|
|
13
|
+
--slider-stop-size: 4px;
|
|
14
|
+
/* Inset at each end of the dots' container, so the first and last sit
|
|
15
|
+
inside the track's ends rather than straddling them. */
|
|
16
|
+
--slider-stop-inline: 2px;
|
|
17
|
+
/* How far past the track the pointer still counts as a press. Purely a hit
|
|
18
|
+
target — it changes nothing visually. */
|
|
19
|
+
--slider-hit-area: 12px;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.slider[data-orientation="vertical"] {
|
|
23
|
+
width: fit-content;
|
|
24
|
+
height: 200px;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.slider[data-disabled="true"] {
|
|
28
|
+
opacity: 0.5;
|
|
29
|
+
pointer-events: none;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.header {
|
|
33
|
+
display: flex;
|
|
34
|
+
align-items: center;
|
|
35
|
+
justify-content: space-between;
|
|
36
|
+
gap: 12px;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.label {
|
|
40
|
+
font-size: 14px;
|
|
41
|
+
font-weight: 500;
|
|
42
|
+
color: var(--md-sys-color-on-surface);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.output {
|
|
46
|
+
font-size: 14px;
|
|
47
|
+
color: var(--md-sys-color-on-surface-variant);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.track {
|
|
51
|
+
position: relative;
|
|
52
|
+
flex: 1 1 auto;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/* Enlarges the clickable area WITHOUT changing the layout or the visual
|
|
56
|
+
track. Padding on .track can't do this: .fill and .remaining are
|
|
57
|
+
height/width 100% of it, so they inflate along with the padding box and the
|
|
58
|
+
bar just gets thicker. A pseudo-element is hit-tested as part of its parent,
|
|
59
|
+
so this hands the extra area to .track's own pointer handlers while staying
|
|
60
|
+
invisible and out of flow. */
|
|
61
|
+
.track::before {
|
|
62
|
+
content: "";
|
|
63
|
+
position: absolute;
|
|
64
|
+
z-index: 0;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.slider[data-orientation="horizontal"] .track::before {
|
|
68
|
+
left: 0;
|
|
69
|
+
right: 0;
|
|
70
|
+
top: calc(var(--slider-hit-area) * -1);
|
|
71
|
+
bottom: calc(var(--slider-hit-area) * -1);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.slider[data-orientation="vertical"] .track::before {
|
|
75
|
+
top: 0;
|
|
76
|
+
bottom: 0;
|
|
77
|
+
left: calc(var(--slider-hit-area) * -1);
|
|
78
|
+
right: calc(var(--slider-hit-area) * -1);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.slider[data-orientation="horizontal"] .track {
|
|
82
|
+
height: 4px;
|
|
83
|
+
width: 100%;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.slider[data-orientation="vertical"] .track {
|
|
87
|
+
width: 4px;
|
|
88
|
+
height: 100%;
|
|
89
|
+
margin: 0 auto;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.fill {
|
|
93
|
+
position: absolute;
|
|
94
|
+
border-radius: var(--borderRadius-xl);
|
|
95
|
+
background: var(--slider-color);
|
|
96
|
+
transition: background var(--transition-expressive-color);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.slider[data-orientation="horizontal"] .fill {
|
|
100
|
+
top: 0;
|
|
101
|
+
height: 100%;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.slider[data-orientation="vertical"] .fill {
|
|
105
|
+
left: 0;
|
|
106
|
+
width: 100%;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/* The un-filled portion of the track — a separate element from .fill
|
|
110
|
+
(not one continuous background) so the gap Slider.tsx computes between
|
|
111
|
+
it and the adjacent thumb is genuinely empty space, same idea as
|
|
112
|
+
tools/SinewaveProgress.tsx's wave/track split. */
|
|
113
|
+
.remaining {
|
|
114
|
+
position: absolute;
|
|
115
|
+
border-radius: var(--borderRadius-xl);
|
|
116
|
+
background: var(--md-sys-color-surface-container-highest);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.slider[data-orientation="horizontal"] .remaining {
|
|
120
|
+
top: 0;
|
|
121
|
+
height: 100%;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.slider[data-orientation="vertical"] .remaining {
|
|
125
|
+
left: 0;
|
|
126
|
+
width: 100%;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.endDot {
|
|
130
|
+
position: absolute;
|
|
131
|
+
width: 4px;
|
|
132
|
+
height: 4px;
|
|
133
|
+
border-radius: 50%;
|
|
134
|
+
background: var(--slider-color);
|
|
135
|
+
pointer-events: none;
|
|
136
|
+
transition: background var(--transition-expressive-color);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.slider[data-orientation="horizontal"] .endDot {
|
|
140
|
+
top: 50%;
|
|
141
|
+
transform: translateY(-50%);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.slider[data-orientation="vertical"] .endDot {
|
|
145
|
+
left: 50%;
|
|
146
|
+
transform: translateX(-50%);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/* Snap markers for the `stops` prop. They live in their own container rather
|
|
150
|
+
than being positioned against the track directly, so the inline inset below
|
|
151
|
+
shortens the span the dots are distributed across — otherwise the first and
|
|
152
|
+
last would straddle the track's ends and hang half outside it. Percentages
|
|
153
|
+
on .stopDot are therefore relative to THIS box, not the track. */
|
|
154
|
+
.stopTrack {
|
|
155
|
+
position: absolute;
|
|
156
|
+
pointer-events: none;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/* 100% is the track's own thickness, so this reads as "the far edge of the
|
|
160
|
+
track, plus the clearance". */
|
|
161
|
+
.slider[data-orientation="horizontal"] .stopTrack {
|
|
162
|
+
top: calc(100% + var(--slider-stop-offset));
|
|
163
|
+
left: var(--slider-stop-inline);
|
|
164
|
+
right: var(--slider-stop-inline);
|
|
165
|
+
height: var(--slider-stop-size);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
.slider[data-orientation="vertical"] .stopTrack {
|
|
169
|
+
left: calc(100% + var(--slider-stop-offset));
|
|
170
|
+
top: var(--slider-stop-inline);
|
|
171
|
+
bottom: var(--slider-stop-inline);
|
|
172
|
+
width: var(--slider-stop-size);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.stopDot {
|
|
176
|
+
position: absolute;
|
|
177
|
+
width: var(--slider-stop-size);
|
|
178
|
+
height: var(--slider-stop-size);
|
|
179
|
+
border-radius: 50%;
|
|
180
|
+
background: var(--globalUIBorderCard);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
.slider[data-orientation="horizontal"] .stopDot {
|
|
184
|
+
top: 0;
|
|
185
|
+
transform: translateX(-50%);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
.slider[data-orientation="vertical"] .stopDot {
|
|
189
|
+
left: 0;
|
|
190
|
+
transform: translateY(50%);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
.thumb {
|
|
194
|
+
position: absolute;
|
|
195
|
+
width: 28px;
|
|
196
|
+
height: 16px;
|
|
197
|
+
border-radius: var(--borderRadius-xl);
|
|
198
|
+
background: white;
|
|
199
|
+
box-shadow:
|
|
200
|
+
0 0 0 1px var(--globalUIBorderCard),
|
|
201
|
+
0 1px 3px rgba(0, 0, 0, 0.1),
|
|
202
|
+
0 2px 6px rgba(0, 0, 0, 0.1);
|
|
203
|
+
cursor: grab;
|
|
204
|
+
touch-action: none;
|
|
205
|
+
will-change: transform, width, height;
|
|
206
|
+
transition:
|
|
207
|
+
background var(--transition-expressive-color),
|
|
208
|
+
box-shadow var(--transition-expressive-fast);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
.slider[data-orientation="horizontal"] .thumb {
|
|
212
|
+
top: 50%;
|
|
213
|
+
transform: translate(-50%, -50%);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
.slider[data-orientation="vertical"] .thumb {
|
|
217
|
+
left: 50%;
|
|
218
|
+
width: 16px;
|
|
219
|
+
height: 28px;
|
|
220
|
+
transform: translate(-50%, 50%);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
.slider[data-orientation="vertical"] .thumb.hover {
|
|
224
|
+
width: 20px;
|
|
225
|
+
height: 32px;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
.thumb:hover {
|
|
229
|
+
filter: var(--filterBrightness);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
.thumb:focus-visible {
|
|
233
|
+
outline: 2px solid var(--slider-color);
|
|
234
|
+
outline-offset: 2px;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
.thumb[data-dragging="true"] {
|
|
238
|
+
cursor: grabbing;
|
|
239
|
+
width: 32px;
|
|
240
|
+
height: 20px;
|
|
241
|
+
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
.thumb:disabled {
|
|
245
|
+
cursor: default;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
:global([data-show-borders="true"]) .thumb {
|
|
249
|
+
box-shadow: var(--a11y-border) !important;
|
|
250
|
+
}
|