@monabbous/slidebox 1.2.0 → 1.3.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/README.md +340 -158
- package/dist/css/group.css +121 -0
- package/dist/css/slidebox.css +2 -0
- package/experimental/range.css +99 -0
- package/experimental/range.d.mts +14 -0
- package/experimental/range.mjs +213 -0
- package/less/experimental.less +119 -0
- package/less/slidebox.less +139 -0
- package/package.json +2 -1
- package/scss/_experimental.scss +109 -0
- package/scss/_mixins.scss +129 -0
- package/scss/group.scss +2 -0
- package/tailwind/experimental-rules.json +125 -0
- package/tailwind/group-rules.json +152 -0
- package/tailwind/index.cjs +8 -6
- package/tailwind/rules.json +2 -0
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
{
|
|
2
|
+
"--_size": "var(--slidebox-size, 36px)",
|
|
3
|
+
"--_spacing": "var(--slidebox-spacing, .12)",
|
|
4
|
+
"--_deform": "var(--slidebox-deform, .06)",
|
|
5
|
+
"--_duration": "var(--slidebox-duration, 200ms)",
|
|
6
|
+
"--_easing": "var(--slidebox-easing, ease-in-out)",
|
|
7
|
+
"--_track": "var(--slidebox-track, Field)",
|
|
8
|
+
"--_border": "var(--slidebox-border, ButtonBorder)",
|
|
9
|
+
"--_off": "var(--slidebox-off, FieldText)",
|
|
10
|
+
"--_on": "var(--slidebox-on, var(--_accent, light-dark(#0b75ff, SelectedItem)))",
|
|
11
|
+
"--_text": "var(--slidebox-text, var(--slidebox-off, FieldText))",
|
|
12
|
+
"--_selected-text": "var(--slidebox-selected-text, HighlightText)",
|
|
13
|
+
"--_press-start": "0px",
|
|
14
|
+
"--_press-end": "0px",
|
|
15
|
+
"display": "inline-grid",
|
|
16
|
+
"grid-auto-flow": "column",
|
|
17
|
+
"grid-auto-columns": "minmax(0, 1fr)",
|
|
18
|
+
"box-sizing": "border-box",
|
|
19
|
+
"padding": "calc(var(--_size) * var(--_spacing))",
|
|
20
|
+
"gap": "calc(var(--_size) * var(--_spacing))",
|
|
21
|
+
"border": "1px solid var(--_border)",
|
|
22
|
+
"border-radius": "var(--slidebox-radius, 100vw)",
|
|
23
|
+
"background": "var(--_track)",
|
|
24
|
+
"color": "var(--_text)",
|
|
25
|
+
"isolation": "isolate",
|
|
26
|
+
"position": "relative",
|
|
27
|
+
"& > label": {
|
|
28
|
+
"position": "relative",
|
|
29
|
+
"display": "grid",
|
|
30
|
+
"min-width": "0",
|
|
31
|
+
"cursor": "pointer"
|
|
32
|
+
},
|
|
33
|
+
"& > label > input[type=\"radio\"]": {
|
|
34
|
+
"position": "absolute",
|
|
35
|
+
"width": "1px",
|
|
36
|
+
"height": "1px",
|
|
37
|
+
"padding": "0",
|
|
38
|
+
"margin": "-1px",
|
|
39
|
+
"overflow": "hidden",
|
|
40
|
+
"clip-path": "inset(50%)",
|
|
41
|
+
"white-space": "nowrap"
|
|
42
|
+
},
|
|
43
|
+
"& > label > span": {
|
|
44
|
+
"position": "relative",
|
|
45
|
+
"isolation": "isolate",
|
|
46
|
+
"display": "grid",
|
|
47
|
+
"place-items": "center",
|
|
48
|
+
"box-sizing": "border-box",
|
|
49
|
+
"min-height": "var(--_size)",
|
|
50
|
+
"padding": ".35em 1em",
|
|
51
|
+
"border": "1px solid transparent",
|
|
52
|
+
"border-radius": "var(--slidebox-radius, 100vw)",
|
|
53
|
+
"color": "var(--_text)",
|
|
54
|
+
"background": "transparent",
|
|
55
|
+
"transition": "color var(--_duration) var(--_easing)"
|
|
56
|
+
},
|
|
57
|
+
"& > label > input:checked + span": {
|
|
58
|
+
"color": "var(--_selected-text)"
|
|
59
|
+
},
|
|
60
|
+
"& > label > input:checked + span::before": {
|
|
61
|
+
"content": "\"\"",
|
|
62
|
+
"position": "absolute",
|
|
63
|
+
"inset": "0",
|
|
64
|
+
"z-index": "-1",
|
|
65
|
+
"pointer-events": "none",
|
|
66
|
+
"border-radius": "inherit",
|
|
67
|
+
"background": "var(--_on)",
|
|
68
|
+
"margin-inline-start": "var(--_press-start)",
|
|
69
|
+
"margin-inline-end": "var(--_press-end)",
|
|
70
|
+
"transition": "margin-inline-start var(--_duration) var(--_easing), margin-inline-end var(--_duration) var(--_easing)"
|
|
71
|
+
},
|
|
72
|
+
"& > label > input:not(:checked) + span": {
|
|
73
|
+
"color": "var(--_text)"
|
|
74
|
+
},
|
|
75
|
+
"&:has(> label > input:checked):has(> label:active > input:not(:checked):not(:disabled)):not(:has(> label:active ~ label > input:checked))": {
|
|
76
|
+
"--_press-end": "calc(-1 * var(--_size) * var(--_deform))"
|
|
77
|
+
},
|
|
78
|
+
"&:has(> label:active > input:not(:disabled)):has(> label:active ~ label > input:checked)": {
|
|
79
|
+
"--_press-start": "calc(-1 * var(--_size) * var(--_deform))"
|
|
80
|
+
},
|
|
81
|
+
"& > label > input:focus-visible + span": {
|
|
82
|
+
"outline": "2px solid var(--_on)",
|
|
83
|
+
"outline-offset": "2px"
|
|
84
|
+
},
|
|
85
|
+
"& > label:has(> input:disabled)": {
|
|
86
|
+
"cursor": "not-allowed"
|
|
87
|
+
},
|
|
88
|
+
"& > label > input:disabled + span": {
|
|
89
|
+
"opacity": ".5"
|
|
90
|
+
},
|
|
91
|
+
"@supports (color: AccentColor)": {
|
|
92
|
+
"&": {
|
|
93
|
+
"--_accent": "AccentColor"
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
"@supports (anchor-scope: --slidebox-selection) and (left: anchor(left))": {
|
|
97
|
+
"&": {
|
|
98
|
+
"anchor-scope": "--slidebox-selection"
|
|
99
|
+
},
|
|
100
|
+
"& > label:has(> input:checked)": {
|
|
101
|
+
"anchor-name": "--slidebox-selection"
|
|
102
|
+
},
|
|
103
|
+
"&:has(> label > input:checked)::before": {
|
|
104
|
+
"content": "\"\"",
|
|
105
|
+
"position": "absolute",
|
|
106
|
+
"position-anchor": "--slidebox-selection",
|
|
107
|
+
"left": "anchor(left)",
|
|
108
|
+
"right": "anchor(right)",
|
|
109
|
+
"top": "anchor(top)",
|
|
110
|
+
"height": "anchor-size(height)",
|
|
111
|
+
"margin-inline-start": "var(--_press-start)",
|
|
112
|
+
"margin-inline-end": "var(--_press-end)",
|
|
113
|
+
"z-index": "-1",
|
|
114
|
+
"border-radius": "var(--slidebox-radius, 100vw)",
|
|
115
|
+
"background": "var(--_on)",
|
|
116
|
+
"pointer-events": "none",
|
|
117
|
+
"transition": "left var(--_duration) var(--_easing), right var(--_duration) var(--_easing), top var(--_duration) var(--_easing), height var(--_duration) var(--_easing), margin-inline-start var(--_duration) var(--_easing), margin-inline-end var(--_duration) var(--_easing)"
|
|
118
|
+
},
|
|
119
|
+
"& > label > input:checked + span::before": {
|
|
120
|
+
"content": "none"
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
"@media (forced-colors: active)": {
|
|
124
|
+
"&": {
|
|
125
|
+
"--_track": "Field",
|
|
126
|
+
"--_border": "ButtonBorder",
|
|
127
|
+
"--_off": "FieldText",
|
|
128
|
+
"--_on": "Highlight",
|
|
129
|
+
"--_text": "FieldText",
|
|
130
|
+
"--_selected-text": "HighlightText"
|
|
131
|
+
},
|
|
132
|
+
"& > label > input:checked + span": {
|
|
133
|
+
"border-color": "Highlight",
|
|
134
|
+
"outline": "2px solid Highlight",
|
|
135
|
+
"outline-offset": "-2px"
|
|
136
|
+
},
|
|
137
|
+
"& > label > input:disabled + span": {
|
|
138
|
+
"color": "GrayText"
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
"@media (prefers-reduced-motion: reduce)": {
|
|
142
|
+
"& > label > span": {
|
|
143
|
+
"transition-duration": ".01ms"
|
|
144
|
+
},
|
|
145
|
+
"& > label > input:checked + span::before": {
|
|
146
|
+
"transition-duration": ".01ms"
|
|
147
|
+
},
|
|
148
|
+
"&::before": {
|
|
149
|
+
"transition-duration": ".01ms"
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
package/tailwind/index.cjs
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
const plugin = require("tailwindcss/plugin");
|
|
2
2
|
const rules = require("./rules.json");
|
|
3
|
+
const groupRules = require("./group-rules.json");
|
|
4
|
+
const experimentalRules = require("./experimental-rules.json");
|
|
3
5
|
|
|
4
6
|
function flatten(colors, prefix = "") {
|
|
5
7
|
return Object.fromEntries(Object.entries(colors).flatMap(([key, value]) => {
|
|
@@ -10,17 +12,17 @@ function flatten(colors, prefix = "") {
|
|
|
10
12
|
}
|
|
11
13
|
|
|
12
14
|
module.exports = plugin.withOptions((defaults = {}) => ({ addUtilities, matchUtilities, theme }) => {
|
|
13
|
-
const controls = ["size", "width", "spacing", "deform", "duration", "easing", "track", "border", "off", "on"];
|
|
15
|
+
const controls = ["size", "width", "spacing", "deform", "duration", "easing", "track", "border", "off", "on", "radius", "text", "selected-text"];
|
|
14
16
|
for (const key of Object.keys(defaults)) {
|
|
15
17
|
if (!controls.includes(key)) throw new Error(`Unknown Slidebox control: ${key}`);
|
|
16
18
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
...
|
|
20
|
-
} });
|
|
19
|
+
const properties = Object.fromEntries(Object.entries(defaults).map(([key, value]) => [`--slidebox-${key}`, String(value)]));
|
|
20
|
+
addUtilities(Object.fromEntries(Object.entries({ ".slidebox": rules, ".slidebox-group": groupRules, ...experimentalRules })
|
|
21
|
+
.map(([selector, component]) => [selector, { ...properties, ...component }])));
|
|
21
22
|
for (const key of controls) {
|
|
22
23
|
let values = theme(`slidebox.${key}`, {});
|
|
23
|
-
if (["track", "border", "off", "on"].includes(key)) values = { ...flatten(theme("colors", {})), ...values };
|
|
24
|
+
if (["track", "border", "off", "on", "text", "selected-text"].includes(key)) values = { ...flatten(theme("colors", {})), ...values };
|
|
25
|
+
if (key === "radius") values = { ...theme("borderRadius", {}), ...values };
|
|
24
26
|
if (key === "duration") values = { ...theme("transitionDuration", {}), ...values };
|
|
25
27
|
if (key === "easing") values = { ...theme("transitionTimingFunction", {}), ...values };
|
|
26
28
|
matchUtilities({ [`slidebox-${key}`]: value => ({ [`--slidebox-${key}`]: value }) }, { values });
|
package/tailwind/rules.json
CHANGED
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"&::after": {
|
|
31
31
|
"--_start": "0",
|
|
32
32
|
"--_end": "1",
|
|
33
|
+
"box-sizing": "border-box",
|
|
33
34
|
"content": "\"\"",
|
|
34
35
|
"display": "block",
|
|
35
36
|
"flex": "1 1 auto",
|
|
@@ -40,6 +41,7 @@
|
|
|
40
41
|
"margin-inline-start": "calc((1em * var(--_container-width-ratio) - 1em) * var(--_start) + var(--_thumb-spacing-ratio) * .5em)",
|
|
41
42
|
"margin-inline-end": "calc((1em * var(--_container-width-ratio) - 1em) * var(--_end) + var(--_thumb-spacing-ratio) * .5em)",
|
|
42
43
|
"border-radius": "inherit",
|
|
44
|
+
"border": "1px solid var(--_track)",
|
|
43
45
|
"background": "var(--_off)",
|
|
44
46
|
"transition": "background var(--_duration) var(--_easing-function), margin-inline-start var(--_duration) var(--_easing-function), margin-inline-end var(--_duration) var(--_easing-function)",
|
|
45
47
|
"transition-delay": "0s, 0s, calc(var(--_duration) * var(--_deform))"
|