@blockle/blocks 0.14.3 → 0.15.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/dist/index.cjs +4 -4
- package/dist/index.mjs +4 -4
- package/dist/momotaro.chunk.d.ts +272 -269
- package/dist/styles/components/form/Slider/Slider.cjs +64 -31
- package/dist/styles/components/form/Slider/Slider.mjs +65 -32
- package/dist/styles/components/form/Slider/slider.css.cjs +1 -0
- package/dist/styles/components/form/Slider/slider.css.mjs +1 -0
- package/dist/styles/lib/css/utils/cssUtils.cjs +5 -0
- package/dist/styles/lib/css/utils/cssUtils.mjs +6 -0
- package/dist/styles/themes/momotaro/components/dialog.css.cjs +11 -11
- package/dist/styles/themes/momotaro/components/dialog.css.mjs +11 -11
- package/dist/styles/themes/momotaro/components/slider.css.cjs +26 -2
- package/dist/styles/themes/momotaro/components/slider.css.mjs +26 -2
- package/dist/styles/themes/momotaro/tokens.css.cjs +11 -10
- package/dist/styles/themes/momotaro/tokens.css.mjs +11 -10
- package/package.json +1 -1
|
@@ -3,6 +3,43 @@ const jsxRuntime = require("react/jsx-runtime");
|
|
|
3
3
|
const react = require("react");
|
|
4
4
|
const styles_components_display_Divider_Divider_cjs = require("../../display/Divider/Divider.cjs");
|
|
5
5
|
const styles_components_form_Slider_slider_css_cjs = require("./slider.css.cjs");
|
|
6
|
+
function useControlledValue({
|
|
7
|
+
defaultValue,
|
|
8
|
+
value,
|
|
9
|
+
onChange,
|
|
10
|
+
transformValue
|
|
11
|
+
}) {
|
|
12
|
+
const [internValue, setInternValue] = react.useState(defaultValue);
|
|
13
|
+
const currentValue = (onChange ? value : internValue) ?? defaultValue;
|
|
14
|
+
const setValue = react.useCallback(
|
|
15
|
+
function setValue2(value2) {
|
|
16
|
+
const nextValue = transformValue ? transformValue(value2) : value2;
|
|
17
|
+
if (onChange) {
|
|
18
|
+
onChange(nextValue);
|
|
19
|
+
} else {
|
|
20
|
+
setInternValue(nextValue);
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
[onChange, transformValue]
|
|
24
|
+
);
|
|
25
|
+
if (process.env.NODE_ENV !== "production") {
|
|
26
|
+
react.useEffect(() => {
|
|
27
|
+
if (onChange && value === void 0) {
|
|
28
|
+
console.error("Slider is in controlled mode but no value is provided");
|
|
29
|
+
}
|
|
30
|
+
}, []);
|
|
31
|
+
}
|
|
32
|
+
return [currentValue, setValue];
|
|
33
|
+
}
|
|
34
|
+
function roundToPrecision(value, precision) {
|
|
35
|
+
const factor = 10 ** precision;
|
|
36
|
+
return Math.round(value * factor) / factor;
|
|
37
|
+
}
|
|
38
|
+
function getBoundValue(newValue, min, max, step) {
|
|
39
|
+
let value = Math.round(newValue / step) * step;
|
|
40
|
+
value = Math.max(min, Math.min(max, value));
|
|
41
|
+
return value;
|
|
42
|
+
}
|
|
6
43
|
function getProgress(event, rect) {
|
|
7
44
|
const { clientX, clientY } = event;
|
|
8
45
|
const { width, height, left, top } = rect;
|
|
@@ -44,11 +81,6 @@ function usePointerProgress({ container, orientation, onChange }) {
|
|
|
44
81
|
};
|
|
45
82
|
}, [container, onChange, orientation]);
|
|
46
83
|
}
|
|
47
|
-
function getBoundValue(newValue, min, max, step) {
|
|
48
|
-
let value = Math.round(newValue / step) * step;
|
|
49
|
-
value = Math.max(min, Math.min(max, value));
|
|
50
|
-
return value;
|
|
51
|
-
}
|
|
52
84
|
const Slider = ({
|
|
53
85
|
min = 0,
|
|
54
86
|
max = 100,
|
|
@@ -60,26 +92,24 @@ const Slider = ({
|
|
|
60
92
|
name,
|
|
61
93
|
size,
|
|
62
94
|
colorScheme,
|
|
95
|
+
disabled,
|
|
96
|
+
precision = 2,
|
|
63
97
|
...restProps
|
|
64
98
|
}) => {
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
99
|
+
const baseClass = styles_components_display_Divider_Divider_cjs.useComponentStyles("slider", {
|
|
100
|
+
base: true,
|
|
101
|
+
variants: { size, colorScheme, disabled }
|
|
102
|
+
});
|
|
69
103
|
const trackClass = styles_components_display_Divider_Divider_cjs.useComponentStyles("slider", { track: true }, false);
|
|
70
104
|
const filledTrackClass = styles_components_display_Divider_Divider_cjs.useComponentStyles("slider", { filledTrack: true }, false);
|
|
71
105
|
const thumbClass = styles_components_display_Divider_Divider_cjs.useComponentStyles("slider", { thumb: true }, false);
|
|
72
106
|
const containerRef = react.useRef(null);
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
if (onChange && internValue !== value) {
|
|
80
|
-
onChange(internValue);
|
|
81
|
-
}
|
|
82
|
-
}, [internValue, onChange, value]);
|
|
107
|
+
const [currentValue, setValue] = useControlledValue({
|
|
108
|
+
defaultValue,
|
|
109
|
+
value,
|
|
110
|
+
onChange,
|
|
111
|
+
transformValue: (value2) => roundToPrecision(getBoundValue(value2, min, max, step), precision)
|
|
112
|
+
});
|
|
83
113
|
usePointerProgress({
|
|
84
114
|
container: containerRef,
|
|
85
115
|
orientation,
|
|
@@ -87,29 +117,32 @@ const Slider = ({
|
|
|
87
117
|
if (orientation === "vertical") {
|
|
88
118
|
progress = 1 - progress;
|
|
89
119
|
}
|
|
90
|
-
|
|
120
|
+
setValue(max * progress);
|
|
91
121
|
}
|
|
92
122
|
});
|
|
93
123
|
const onKeyDown = react.useCallback(
|
|
94
124
|
(event) => {
|
|
125
|
+
if (event.key === "Tab") {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
95
128
|
event.preventDefault();
|
|
96
129
|
event.stopPropagation();
|
|
97
130
|
const specialKey = ["PageUp", "PageDown"];
|
|
98
131
|
const stepModifier = event.shiftKey || specialKey.includes(event.key) ? (max - min) / 10 : step;
|
|
99
132
|
if (event.key === "ArrowLeft" || event.key === "ArrowDown" || event.key === "PageDown") {
|
|
100
|
-
return
|
|
133
|
+
return setValue(currentValue - stepModifier);
|
|
101
134
|
}
|
|
102
135
|
if (event.key === "ArrowRight" || event.key === "ArrowUp" || event.key === "PageUp") {
|
|
103
|
-
return
|
|
136
|
+
return setValue(currentValue + stepModifier);
|
|
104
137
|
}
|
|
105
138
|
if (event.key === "Home") {
|
|
106
|
-
return
|
|
139
|
+
return setValue(min);
|
|
107
140
|
}
|
|
108
141
|
if (event.key === "End") {
|
|
109
|
-
return
|
|
142
|
+
return setValue(max);
|
|
110
143
|
}
|
|
111
144
|
},
|
|
112
|
-
[max, min, step]
|
|
145
|
+
[max, min, step, setValue, currentValue]
|
|
113
146
|
);
|
|
114
147
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
115
148
|
"div",
|
|
@@ -126,28 +159,28 @@ const Slider = ({
|
|
|
126
159
|
{
|
|
127
160
|
className: styles_components_display_Divider_Divider_cjs.classnames(styles_components_form_Slider_slider_css_cjs.filledTrack, filledTrackClass),
|
|
128
161
|
style: {
|
|
129
|
-
inlineSize: `${
|
|
162
|
+
inlineSize: `${currentValue / max * 100}%`
|
|
130
163
|
}
|
|
131
164
|
}
|
|
132
165
|
) }),
|
|
133
166
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
134
|
-
"
|
|
167
|
+
"button",
|
|
135
168
|
{
|
|
169
|
+
type: "button",
|
|
136
170
|
className: styles_components_display_Divider_Divider_cjs.classnames(styles_components_form_Slider_slider_css_cjs.thumb, thumbClass),
|
|
137
|
-
tabIndex: 0,
|
|
138
171
|
role: "slider",
|
|
139
172
|
"aria-valuemin": min,
|
|
140
173
|
"aria-valuemax": max,
|
|
141
|
-
"aria-valuenow":
|
|
174
|
+
"aria-valuenow": currentValue,
|
|
142
175
|
"aria-orientation": orientation,
|
|
143
176
|
style: {
|
|
144
|
-
[orientation === "horizontal" ? "insetInlineStart" : "insetInlineEnd"]: `${
|
|
177
|
+
[orientation === "horizontal" ? "insetInlineStart" : "insetInlineEnd"]: `${currentValue / max * 100}%`
|
|
145
178
|
},
|
|
146
179
|
onKeyDown,
|
|
147
180
|
...restProps
|
|
148
181
|
}
|
|
149
182
|
),
|
|
150
|
-
/* @__PURE__ */ jsxRuntime.jsx("input", { type: "hidden", name, value:
|
|
183
|
+
/* @__PURE__ */ jsxRuntime.jsx("input", { type: "hidden", disabled, name, value: currentValue })
|
|
151
184
|
]
|
|
152
185
|
}
|
|
153
186
|
);
|
|
@@ -1,7 +1,44 @@
|
|
|
1
1
|
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { useState, useCallback, useEffect, useRef } from "react";
|
|
3
3
|
import { useComponentStyles, classnames } from "../../display/Divider/Divider.mjs";
|
|
4
4
|
import { containerVertical, container, track, filledTrack, thumb } from "./slider.css.mjs";
|
|
5
|
+
function useControlledValue({
|
|
6
|
+
defaultValue,
|
|
7
|
+
value,
|
|
8
|
+
onChange,
|
|
9
|
+
transformValue
|
|
10
|
+
}) {
|
|
11
|
+
const [internValue, setInternValue] = useState(defaultValue);
|
|
12
|
+
const currentValue = (onChange ? value : internValue) ?? defaultValue;
|
|
13
|
+
const setValue = useCallback(
|
|
14
|
+
function setValue2(value2) {
|
|
15
|
+
const nextValue = transformValue ? transformValue(value2) : value2;
|
|
16
|
+
if (onChange) {
|
|
17
|
+
onChange(nextValue);
|
|
18
|
+
} else {
|
|
19
|
+
setInternValue(nextValue);
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
[onChange, transformValue]
|
|
23
|
+
);
|
|
24
|
+
if (process.env.NODE_ENV !== "production") {
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
if (onChange && value === void 0) {
|
|
27
|
+
console.error("Slider is in controlled mode but no value is provided");
|
|
28
|
+
}
|
|
29
|
+
}, []);
|
|
30
|
+
}
|
|
31
|
+
return [currentValue, setValue];
|
|
32
|
+
}
|
|
33
|
+
function roundToPrecision(value, precision) {
|
|
34
|
+
const factor = 10 ** precision;
|
|
35
|
+
return Math.round(value * factor) / factor;
|
|
36
|
+
}
|
|
37
|
+
function getBoundValue(newValue, min, max, step) {
|
|
38
|
+
let value = Math.round(newValue / step) * step;
|
|
39
|
+
value = Math.max(min, Math.min(max, value));
|
|
40
|
+
return value;
|
|
41
|
+
}
|
|
5
42
|
function getProgress(event, rect) {
|
|
6
43
|
const { clientX, clientY } = event;
|
|
7
44
|
const { width, height, left, top } = rect;
|
|
@@ -43,11 +80,6 @@ function usePointerProgress({ container: container2, orientation, onChange }) {
|
|
|
43
80
|
};
|
|
44
81
|
}, [container2, onChange, orientation]);
|
|
45
82
|
}
|
|
46
|
-
function getBoundValue(newValue, min, max, step) {
|
|
47
|
-
let value = Math.round(newValue / step) * step;
|
|
48
|
-
value = Math.max(min, Math.min(max, value));
|
|
49
|
-
return value;
|
|
50
|
-
}
|
|
51
83
|
const Slider = ({
|
|
52
84
|
min = 0,
|
|
53
85
|
max = 100,
|
|
@@ -59,26 +91,24 @@ const Slider = ({
|
|
|
59
91
|
name,
|
|
60
92
|
size,
|
|
61
93
|
colorScheme,
|
|
94
|
+
disabled,
|
|
95
|
+
precision = 2,
|
|
62
96
|
...restProps
|
|
63
97
|
}) => {
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
98
|
+
const baseClass = useComponentStyles("slider", {
|
|
99
|
+
base: true,
|
|
100
|
+
variants: { size, colorScheme, disabled }
|
|
101
|
+
});
|
|
68
102
|
const trackClass = useComponentStyles("slider", { track: true }, false);
|
|
69
103
|
const filledTrackClass = useComponentStyles("slider", { filledTrack: true }, false);
|
|
70
104
|
const thumbClass = useComponentStyles("slider", { thumb: true }, false);
|
|
71
105
|
const containerRef = useRef(null);
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
if (onChange && internValue !== value) {
|
|
79
|
-
onChange(internValue);
|
|
80
|
-
}
|
|
81
|
-
}, [internValue, onChange, value]);
|
|
106
|
+
const [currentValue, setValue] = useControlledValue({
|
|
107
|
+
defaultValue,
|
|
108
|
+
value,
|
|
109
|
+
onChange,
|
|
110
|
+
transformValue: (value2) => roundToPrecision(getBoundValue(value2, min, max, step), precision)
|
|
111
|
+
});
|
|
82
112
|
usePointerProgress({
|
|
83
113
|
container: containerRef,
|
|
84
114
|
orientation,
|
|
@@ -86,29 +116,32 @@ const Slider = ({
|
|
|
86
116
|
if (orientation === "vertical") {
|
|
87
117
|
progress = 1 - progress;
|
|
88
118
|
}
|
|
89
|
-
|
|
119
|
+
setValue(max * progress);
|
|
90
120
|
}
|
|
91
121
|
});
|
|
92
122
|
const onKeyDown = useCallback(
|
|
93
123
|
(event) => {
|
|
124
|
+
if (event.key === "Tab") {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
94
127
|
event.preventDefault();
|
|
95
128
|
event.stopPropagation();
|
|
96
129
|
const specialKey = ["PageUp", "PageDown"];
|
|
97
130
|
const stepModifier = event.shiftKey || specialKey.includes(event.key) ? (max - min) / 10 : step;
|
|
98
131
|
if (event.key === "ArrowLeft" || event.key === "ArrowDown" || event.key === "PageDown") {
|
|
99
|
-
return
|
|
132
|
+
return setValue(currentValue - stepModifier);
|
|
100
133
|
}
|
|
101
134
|
if (event.key === "ArrowRight" || event.key === "ArrowUp" || event.key === "PageUp") {
|
|
102
|
-
return
|
|
135
|
+
return setValue(currentValue + stepModifier);
|
|
103
136
|
}
|
|
104
137
|
if (event.key === "Home") {
|
|
105
|
-
return
|
|
138
|
+
return setValue(min);
|
|
106
139
|
}
|
|
107
140
|
if (event.key === "End") {
|
|
108
|
-
return
|
|
141
|
+
return setValue(max);
|
|
109
142
|
}
|
|
110
143
|
},
|
|
111
|
-
[max, min, step]
|
|
144
|
+
[max, min, step, setValue, currentValue]
|
|
112
145
|
);
|
|
113
146
|
return /* @__PURE__ */ jsxs(
|
|
114
147
|
"div",
|
|
@@ -125,28 +158,28 @@ const Slider = ({
|
|
|
125
158
|
{
|
|
126
159
|
className: classnames(filledTrack, filledTrackClass),
|
|
127
160
|
style: {
|
|
128
|
-
inlineSize: `${
|
|
161
|
+
inlineSize: `${currentValue / max * 100}%`
|
|
129
162
|
}
|
|
130
163
|
}
|
|
131
164
|
) }),
|
|
132
165
|
/* @__PURE__ */ jsx(
|
|
133
|
-
"
|
|
166
|
+
"button",
|
|
134
167
|
{
|
|
168
|
+
type: "button",
|
|
135
169
|
className: classnames(thumb, thumbClass),
|
|
136
|
-
tabIndex: 0,
|
|
137
170
|
role: "slider",
|
|
138
171
|
"aria-valuemin": min,
|
|
139
172
|
"aria-valuemax": max,
|
|
140
|
-
"aria-valuenow":
|
|
173
|
+
"aria-valuenow": currentValue,
|
|
141
174
|
"aria-orientation": orientation,
|
|
142
175
|
style: {
|
|
143
|
-
[orientation === "horizontal" ? "insetInlineStart" : "insetInlineEnd"]: `${
|
|
176
|
+
[orientation === "horizontal" ? "insetInlineStart" : "insetInlineEnd"]: `${currentValue / max * 100}%`
|
|
144
177
|
},
|
|
145
178
|
onKeyDown,
|
|
146
179
|
...restProps
|
|
147
180
|
}
|
|
148
181
|
),
|
|
149
|
-
/* @__PURE__ */ jsx("input", { type: "hidden", name, value:
|
|
182
|
+
/* @__PURE__ */ jsx("input", { type: "hidden", disabled, name, value: currentValue })
|
|
150
183
|
]
|
|
151
184
|
}
|
|
152
185
|
);
|
|
@@ -22,10 +22,18 @@ const dialog = styles_lib_theme_makeComponentTheme_cjs.makeComponentTheme("dialo
|
|
|
22
22
|
selectors: {
|
|
23
23
|
"&[open]": {
|
|
24
24
|
transform: "translate(0, 0)",
|
|
25
|
-
opacity: 1
|
|
25
|
+
opacity: 1,
|
|
26
|
+
// @ts-expect-error - Vanilla Extract does not support @starting-style (yet)
|
|
27
|
+
"@starting-style": {
|
|
28
|
+
transform: "translate(0, -120px)",
|
|
29
|
+
opacity: 0
|
|
30
|
+
}
|
|
26
31
|
},
|
|
27
32
|
"&[open]::backdrop": {
|
|
28
|
-
opacity: 1
|
|
33
|
+
opacity: 1,
|
|
34
|
+
"@starting-style": {
|
|
35
|
+
opacity: 0
|
|
36
|
+
}
|
|
29
37
|
}
|
|
30
38
|
},
|
|
31
39
|
// Apply the animation only if the user has not requested reduced motion
|
|
@@ -37,19 +45,11 @@ const dialog = styles_lib_theme_makeComponentTheme_cjs.makeComponentTheme("dialo
|
|
|
37
45
|
transitionBehavior: "allow-discrete",
|
|
38
46
|
transitionProperty: "opacity, transform, overlay, display",
|
|
39
47
|
transitionDuration: "240ms, 160ms, 240ms, 240ms",
|
|
40
|
-
// @ts-expect-error - Vanilla Extract does not support @starting-style (yet)
|
|
41
|
-
"@starting-style": {
|
|
42
|
-
transform: "translate(0, -120px)",
|
|
43
|
-
opacity: 0
|
|
44
|
-
},
|
|
45
48
|
"::backdrop": {
|
|
46
49
|
opacity: 0,
|
|
47
50
|
transitionBehavior: "allow-discrete",
|
|
48
51
|
transitionProperty: "opacity, overlay, display",
|
|
49
|
-
transitionDuration: "160ms, 240ms, 240ms"
|
|
50
|
-
"@starting-style": {
|
|
51
|
-
opacity: 0
|
|
52
|
-
}
|
|
52
|
+
transitionDuration: "160ms, 240ms, 240ms"
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
}
|
|
@@ -21,10 +21,18 @@ const dialog = makeComponentTheme("dialog", {
|
|
|
21
21
|
selectors: {
|
|
22
22
|
"&[open]": {
|
|
23
23
|
transform: "translate(0, 0)",
|
|
24
|
-
opacity: 1
|
|
24
|
+
opacity: 1,
|
|
25
|
+
// @ts-expect-error - Vanilla Extract does not support @starting-style (yet)
|
|
26
|
+
"@starting-style": {
|
|
27
|
+
transform: "translate(0, -120px)",
|
|
28
|
+
opacity: 0
|
|
29
|
+
}
|
|
25
30
|
},
|
|
26
31
|
"&[open]::backdrop": {
|
|
27
|
-
opacity: 1
|
|
32
|
+
opacity: 1,
|
|
33
|
+
"@starting-style": {
|
|
34
|
+
opacity: 0
|
|
35
|
+
}
|
|
28
36
|
}
|
|
29
37
|
},
|
|
30
38
|
// Apply the animation only if the user has not requested reduced motion
|
|
@@ -36,19 +44,11 @@ const dialog = makeComponentTheme("dialog", {
|
|
|
36
44
|
transitionBehavior: "allow-discrete",
|
|
37
45
|
transitionProperty: "opacity, transform, overlay, display",
|
|
38
46
|
transitionDuration: "240ms, 160ms, 240ms, 240ms",
|
|
39
|
-
// @ts-expect-error - Vanilla Extract does not support @starting-style (yet)
|
|
40
|
-
"@starting-style": {
|
|
41
|
-
transform: "translate(0, -120px)",
|
|
42
|
-
opacity: 0
|
|
43
|
-
},
|
|
44
47
|
"::backdrop": {
|
|
45
48
|
opacity: 0,
|
|
46
49
|
transitionBehavior: "allow-discrete",
|
|
47
50
|
transitionProperty: "opacity, overlay, display",
|
|
48
|
-
transitionDuration: "160ms, 240ms, 240ms"
|
|
49
|
-
"@starting-style": {
|
|
50
|
-
opacity: 0
|
|
51
|
-
}
|
|
51
|
+
transitionDuration: "160ms, 240ms, 240ms"
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
}
|
|
@@ -9,6 +9,7 @@ fileScope.setFileScope("src/themes/momotaro/components/slider.css.ts", "@blockle
|
|
|
9
9
|
const trackBackground = css.createVar("trackBackground");
|
|
10
10
|
const filledTrackBackground = css.createVar("filledTrackBackground");
|
|
11
11
|
const thumbBackground = css.createVar("thumbBackground");
|
|
12
|
+
const thumbActive = css.createVar("thumbActive");
|
|
12
13
|
const slider = styles_lib_theme_makeComponentTheme_cjs.makeComponentTheme("slider", {
|
|
13
14
|
base: styles_lib_css_style_style_cjs.style({
|
|
14
15
|
blockSize: "20px"
|
|
@@ -25,7 +26,22 @@ const slider = styles_lib_theme_makeComponentTheme_cjs.makeComponentTheme("slide
|
|
|
25
26
|
backgroundColor: thumbBackground,
|
|
26
27
|
borderRadius: "50%",
|
|
27
28
|
height: "16px",
|
|
28
|
-
width: "16px"
|
|
29
|
+
width: "16px",
|
|
30
|
+
boxShadow: `0 0 0 0px color-mix(in srgb, ${styles_lib_theme_vars_css_cjs.vars.color.primaryLight}, transparent 0%)`,
|
|
31
|
+
vars: {
|
|
32
|
+
[thumbActive]: `0 0 0 8px color-mix(in srgb, ${styles_lib_theme_vars_css_cjs.vars.color.primaryLight}, transparent 20%)`
|
|
33
|
+
},
|
|
34
|
+
":hover": {
|
|
35
|
+
boxShadow: thumbActive
|
|
36
|
+
},
|
|
37
|
+
":focus-visible": {
|
|
38
|
+
boxShadow: thumbActive
|
|
39
|
+
},
|
|
40
|
+
"@media": {
|
|
41
|
+
"(prefers-reduced-motion: no-preference)": {
|
|
42
|
+
transition: "box-shadow 0.2s"
|
|
43
|
+
}
|
|
44
|
+
}
|
|
29
45
|
}, styles_themes_momotaro_components_helpers_css_cjs.focusable]),
|
|
30
46
|
variants: {
|
|
31
47
|
size: {
|
|
@@ -54,7 +70,15 @@ const slider = styles_lib_theme_makeComponentTheme_cjs.makeComponentTheme("slide
|
|
|
54
70
|
[thumbBackground]: styles_lib_theme_vars_css_cjs.vars.color.secondary
|
|
55
71
|
}
|
|
56
72
|
})
|
|
57
|
-
}
|
|
73
|
+
},
|
|
74
|
+
disabled: styles_lib_css_style_style_cjs.style({
|
|
75
|
+
pointerEvents: "none",
|
|
76
|
+
vars: {
|
|
77
|
+
[trackBackground]: "#c0c0c0",
|
|
78
|
+
[filledTrackBackground]: "#ccc",
|
|
79
|
+
[thumbBackground]: "#c0c0c0"
|
|
80
|
+
}
|
|
81
|
+
})
|
|
58
82
|
},
|
|
59
83
|
defaultVariants: {
|
|
60
84
|
size: "medium",
|
|
@@ -8,6 +8,7 @@ setFileScope("src/themes/momotaro/components/slider.css.ts", "@blockle/blocks");
|
|
|
8
8
|
const trackBackground = createVar("trackBackground");
|
|
9
9
|
const filledTrackBackground = createVar("filledTrackBackground");
|
|
10
10
|
const thumbBackground = createVar("thumbBackground");
|
|
11
|
+
const thumbActive = createVar("thumbActive");
|
|
11
12
|
const slider = makeComponentTheme("slider", {
|
|
12
13
|
base: style({
|
|
13
14
|
blockSize: "20px"
|
|
@@ -24,7 +25,22 @@ const slider = makeComponentTheme("slider", {
|
|
|
24
25
|
backgroundColor: thumbBackground,
|
|
25
26
|
borderRadius: "50%",
|
|
26
27
|
height: "16px",
|
|
27
|
-
width: "16px"
|
|
28
|
+
width: "16px",
|
|
29
|
+
boxShadow: `0 0 0 0px color-mix(in srgb, ${vars.color.primaryLight}, transparent 0%)`,
|
|
30
|
+
vars: {
|
|
31
|
+
[thumbActive]: `0 0 0 8px color-mix(in srgb, ${vars.color.primaryLight}, transparent 20%)`
|
|
32
|
+
},
|
|
33
|
+
":hover": {
|
|
34
|
+
boxShadow: thumbActive
|
|
35
|
+
},
|
|
36
|
+
":focus-visible": {
|
|
37
|
+
boxShadow: thumbActive
|
|
38
|
+
},
|
|
39
|
+
"@media": {
|
|
40
|
+
"(prefers-reduced-motion: no-preference)": {
|
|
41
|
+
transition: "box-shadow 0.2s"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
28
44
|
}, focusable]),
|
|
29
45
|
variants: {
|
|
30
46
|
size: {
|
|
@@ -53,7 +69,15 @@ const slider = makeComponentTheme("slider", {
|
|
|
53
69
|
[thumbBackground]: vars.color.secondary
|
|
54
70
|
}
|
|
55
71
|
})
|
|
56
|
-
}
|
|
72
|
+
},
|
|
73
|
+
disabled: style({
|
|
74
|
+
pointerEvents: "none",
|
|
75
|
+
vars: {
|
|
76
|
+
[trackBackground]: "#c0c0c0",
|
|
77
|
+
[filledTrackBackground]: "#ccc",
|
|
78
|
+
[thumbBackground]: "#c0c0c0"
|
|
79
|
+
}
|
|
80
|
+
})
|
|
57
81
|
},
|
|
58
82
|
defaultVariants: {
|
|
59
83
|
size: "medium",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const fileScope = require("@vanilla-extract/css/fileScope");
|
|
3
|
+
const styles_lib_css_utils_cssUtils_cjs = require("../../lib/css/utils/cssUtils.cjs");
|
|
3
4
|
fileScope.setFileScope("src/themes/momotaro/tokens.css.ts", "@blockle/blocks");
|
|
4
5
|
const tokens = {
|
|
5
6
|
border: {
|
|
@@ -60,11 +61,11 @@ const tokens = {
|
|
|
60
61
|
secondary: '"Rubik", sans-serif'
|
|
61
62
|
},
|
|
62
63
|
fontSize: {
|
|
63
|
-
xsmall:
|
|
64
|
-
small:
|
|
65
|
-
medium:
|
|
66
|
-
large:
|
|
67
|
-
xlarge:
|
|
64
|
+
xsmall: styles_lib_css_utils_cssUtils_cjs.rem(12),
|
|
65
|
+
small: styles_lib_css_utils_cssUtils_cjs.rem(14),
|
|
66
|
+
medium: styles_lib_css_utils_cssUtils_cjs.rem(16),
|
|
67
|
+
large: styles_lib_css_utils_cssUtils_cjs.rem(20),
|
|
68
|
+
xlarge: styles_lib_css_utils_cssUtils_cjs.rem(24)
|
|
68
69
|
},
|
|
69
70
|
fontWeight: {
|
|
70
71
|
regular: 400,
|
|
@@ -72,11 +73,11 @@ const tokens = {
|
|
|
72
73
|
strong: 700
|
|
73
74
|
},
|
|
74
75
|
lineHeight: {
|
|
75
|
-
xsmall:
|
|
76
|
-
small:
|
|
77
|
-
medium:
|
|
78
|
-
large:
|
|
79
|
-
xlarge:
|
|
76
|
+
xsmall: styles_lib_css_utils_cssUtils_cjs.rem(16),
|
|
77
|
+
small: styles_lib_css_utils_cssUtils_cjs.rem(20),
|
|
78
|
+
medium: styles_lib_css_utils_cssUtils_cjs.rem(24),
|
|
79
|
+
large: styles_lib_css_utils_cssUtils_cjs.rem(28),
|
|
80
|
+
xlarge: styles_lib_css_utils_cssUtils_cjs.rem(32)
|
|
80
81
|
}
|
|
81
82
|
}
|
|
82
83
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { setFileScope, endFileScope } from "@vanilla-extract/css/fileScope";
|
|
2
|
+
import { rem } from "../../lib/css/utils/cssUtils.mjs";
|
|
2
3
|
setFileScope("src/themes/momotaro/tokens.css.ts", "@blockle/blocks");
|
|
3
4
|
const tokens = {
|
|
4
5
|
border: {
|
|
@@ -59,11 +60,11 @@ const tokens = {
|
|
|
59
60
|
secondary: '"Rubik", sans-serif'
|
|
60
61
|
},
|
|
61
62
|
fontSize: {
|
|
62
|
-
xsmall:
|
|
63
|
-
small:
|
|
64
|
-
medium:
|
|
65
|
-
large:
|
|
66
|
-
xlarge:
|
|
63
|
+
xsmall: rem(12),
|
|
64
|
+
small: rem(14),
|
|
65
|
+
medium: rem(16),
|
|
66
|
+
large: rem(20),
|
|
67
|
+
xlarge: rem(24)
|
|
67
68
|
},
|
|
68
69
|
fontWeight: {
|
|
69
70
|
regular: 400,
|
|
@@ -71,11 +72,11 @@ const tokens = {
|
|
|
71
72
|
strong: 700
|
|
72
73
|
},
|
|
73
74
|
lineHeight: {
|
|
74
|
-
xsmall:
|
|
75
|
-
small:
|
|
76
|
-
medium:
|
|
77
|
-
large:
|
|
78
|
-
xlarge:
|
|
75
|
+
xsmall: rem(16),
|
|
76
|
+
small: rem(20),
|
|
77
|
+
medium: rem(24),
|
|
78
|
+
large: rem(28),
|
|
79
|
+
xlarge: rem(32)
|
|
79
80
|
}
|
|
80
81
|
}
|
|
81
82
|
};
|