@monabbous/slidebox 0.0.6 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +65 -55
- package/dist/css/slidebox.css +53 -203
- package/package.json +29 -21
- package/scss/slidebox.scss +58 -266
- package/dist/css/slidebox.css.map +0 -1
- package/examples/simple.html +0 -41
package/README.md
CHANGED
|
@@ -1,55 +1,65 @@
|
|
|
1
|
-
# Slidebox
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
1
|
+
# Slidebox Lab
|
|
2
|
+
|
|
3
|
+
An elastic CSS switch with a playground for geometry, colors, and motion.
|
|
4
|
+
|
|
5
|
+
[Preview the interactive playground online](https://htmlpreview.github.io/?https://github.com/monabbous/slidebox/blob/main/index.html)
|
|
6
|
+
|
|
7
|
+

|
|
8
|
+
|
|
9
|
+
The animation uses the default width (2), thumb spacing (0.33), deformation (0.1), and a 200ms `ease-in-out` transition.
|
|
10
|
+
|
|
11
|
+
## npm package
|
|
12
|
+
|
|
13
|
+
The published CSS package keeps the name [`@monabbous/slidebox`](https://www.npmjs.com/package/@monabbous/slidebox).
|
|
14
|
+
The package includes the switch stylesheet at `dist/css/slidebox.css` and a Sass-compatible entrypoint at `scss/slidebox.scss`. The playground is not included in npm.
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install @monabbous/slidebox
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Import `@monabbous/slidebox/dist/css/slidebox.css` in a stylesheet or through your bundler, then use `<input class="slidebox" type="checkbox">`. The package is built from the component rules in `style.css` using `npm run build`.
|
|
21
|
+
|
|
22
|
+
## Manual npm releases
|
|
23
|
+
|
|
24
|
+
The release workflow is [Publish to npm](.github/workflows/publish-npm.yml). It is triggered **only** through GitHub Actions > Run workflow on `main`, with a `patch`, `minor`, or `major` choice.
|
|
25
|
+
|
|
26
|
+
The manifest starts at `0.3.0`, so the first `patch` dispatch will release `0.3.1` (once npm credentials are configured). The workflow builds and tests the package, creates a `chore(release): vX.Y.Z` commit and tag, pushes both to `main`, then publishes to npm.
|
|
27
|
+
|
|
28
|
+
Before the first release:
|
|
29
|
+
|
|
30
|
+
1. In GitHub Settings > General > Default branch, change `master` to `main`.
|
|
31
|
+
2. Add a granular npm publish token as the repository Actions secret `NPM_TOKEN`, scoped to `@monabbous/slidebox`, with permission to publish. Never commit the token.
|
|
32
|
+
3. Ensure GitHub Actions has permission to write repository contents.
|
|
33
|
+
4. Manually dispatch the release workflow on `main`.
|
|
34
|
+
|
|
35
|
+
The workflow does not run on pushes or tags. A failed npm publish after the Git tag has been pushed requires fixing the publish failure for that version before choosing a new bump. The old library is preserved in `legacy/`.
|
|
36
|
+
|
|
37
|
+
## Run locally
|
|
38
|
+
|
|
39
|
+
Clone this repository, then serve its root directory:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
python3 -m http.server 8080
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Open `http://localhost:8080`. The lab uses plain HTML, CSS, and JavaScript, without a build step.
|
|
46
|
+
|
|
47
|
+
## Playground
|
|
48
|
+
|
|
49
|
+
- Adjust track width, thumb spacing, press deformation, and transition duration.
|
|
50
|
+
- Change easing family and direction (In, Out, or In-Out), including Elastic and Bounce.
|
|
51
|
+
- Compare Slidebox against native controls in light and dark schemes.
|
|
52
|
+
- Choose browser-default, CSS system, nabous.dev, or custom colors.
|
|
53
|
+
- Copy complete CSS, Tailwind v4 `@utility` CSS, or configuration variables.
|
|
54
|
+
|
|
55
|
+
Chromium currently lacks support for the `AccentColor` CSS color keyword. In browser-default mode, the custom thumb uses a blue approximation in light mode and `SelectedItem` in dark mode, while native controls retain `accent-color: auto`. Browsers that support `AccentColor` use it automatically.
|
|
56
|
+
|
|
57
|
+
Controls can be adjusted without triggering transition animations. The selected duration is restored after two animation frames.
|
|
58
|
+
|
|
59
|
+
The easing functions follow [easings.net](https://easings.net/). Elastic and Bounce use sampled CSS `linear()` timing functions.
|
|
60
|
+
|
|
61
|
+
## Original Slidebox package
|
|
62
|
+
|
|
63
|
+
The original Sass package, compiled CSS, package manifests, and example are preserved in [`legacy/`](legacy/). See the [legacy README](legacy/README.md) for the previous installation instructions.
|
|
64
|
+
|
|
65
|
+
[Source](https://github.com/monabbous/slidebox) · [nabous.dev](https://nabous.dev)
|
package/dist/css/slidebox.css
CHANGED
|
@@ -1,208 +1,58 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
.slidebox {
|
|
2
|
+
--_container-width-ratio: 2;
|
|
3
|
+
--_thumb-spacing-ratio: .33;
|
|
4
|
+
--_deform: .1;
|
|
5
|
+
--_duration: 200ms;
|
|
6
|
+
--_easing-function: ease-in-out;
|
|
7
|
+
--_track: Field;
|
|
8
|
+
--_border: ButtonBorder;
|
|
9
|
+
--_off: FieldText;
|
|
10
|
+
--_on: light-dark(#0b75ff, SelectedItem);
|
|
11
|
+
appearance: none;
|
|
12
|
+
-webkit-appearance: none;
|
|
13
|
+
box-sizing: border-box;
|
|
14
|
+
display: inline-flex;
|
|
15
|
+
align-items: center;
|
|
16
|
+
justify-content: center;
|
|
17
|
+
width: calc(1em * var(--_container-width-ratio));
|
|
18
|
+
height: 1em;
|
|
19
|
+
font-size: 54px;
|
|
20
|
+
padding: 0;
|
|
21
|
+
border: 1px solid var(--_border);
|
|
22
|
+
border-radius: 100vw;
|
|
23
|
+
background: var(--_track);
|
|
14
24
|
cursor: pointer;
|
|
15
|
-
padding: 0 0.4em;
|
|
16
|
-
font-size: 1em;
|
|
17
|
-
transform-origin: center center;
|
|
18
25
|
}
|
|
19
|
-
|
|
20
|
-
|
|
26
|
+
@supports (color: AccentColor) {
|
|
27
|
+
.slidebox { --_on: AccentColor; }
|
|
21
28
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
content: "";
|
|
26
|
-
font-weight: 900;
|
|
27
|
-
font-family: "Font Awesome 5 Free";
|
|
29
|
+
.slidebox::after {
|
|
30
|
+
--_start: 0; --_end: 1;
|
|
31
|
+
content: "";
|
|
28
32
|
display: block;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
flex: 1 1 auto;
|
|
34
|
+
min-width: 0;
|
|
35
|
+
width: calc((1 - var(--_thumb-spacing-ratio)) * 1em);
|
|
36
|
+
height: calc((1 - var(--_thumb-spacing-ratio)) * 1em);
|
|
37
|
+
margin-block: calc(var(--_thumb-spacing-ratio) * .5em);
|
|
38
|
+
margin-inline-start: calc((1em * var(--_container-width-ratio) - 1em) * var(--_start) + var(--_thumb-spacing-ratio) * .5em);
|
|
39
|
+
margin-inline-end: calc((1em * var(--_container-width-ratio) - 1em) * var(--_end) + var(--_thumb-spacing-ratio) * .5em);
|
|
40
|
+
border-radius: inherit;
|
|
41
|
+
background: var(--_off);
|
|
42
|
+
transition: background var(--_duration) var(--_easing-function), margin-inline-start var(--_duration) var(--_easing-function), margin-inline-end var(--_duration) var(--_easing-function);
|
|
43
|
+
transition-delay: 0s, 0s, calc(var(--_duration) * var(--_deform));
|
|
44
|
+
}
|
|
45
|
+
.slidebox:checked::after {
|
|
46
|
+
--_start: 1; --_end: 0;
|
|
47
|
+
background: var(--_on);
|
|
48
|
+
transition-delay: 0s, calc(var(--_duration) * var(--_deform)), 0s;
|
|
49
|
+
}
|
|
50
|
+
.slidebox:not(:checked):active::after { --_end: calc(1 - var(--_deform)); }
|
|
51
|
+
.slidebox:checked:active::after { --_start: calc(1 - var(--_deform)); }
|
|
52
|
+
.slidebox:disabled { cursor: not-allowed; opacity: .5; }
|
|
53
|
+
@media (forced-colors: active) {
|
|
54
|
+
.slidebox { --_track: Field; --_border: ButtonBorder; --_off: FieldText; --_on: Highlight; }
|
|
55
|
+
}
|
|
56
|
+
@media (prefers-reduced-motion: reduce) {
|
|
57
|
+
.slidebox::after { transition-duration: .01ms; transition-delay: 0ms; }
|
|
37
58
|
}
|
|
38
|
-
input[type=checkbox].slidebox::after {
|
|
39
|
-
line-height: 1em;
|
|
40
|
-
position: relative;
|
|
41
|
-
content: "";
|
|
42
|
-
font-weight: 900;
|
|
43
|
-
padding: 0.4em;
|
|
44
|
-
font-family: "Font Awesome 5 Free";
|
|
45
|
-
display: block;
|
|
46
|
-
transform-origin: center center;
|
|
47
|
-
animation-duration: 0.2s;
|
|
48
|
-
animation-timing-function: cubic-bezier(0.68, -0.6, 0.32, 1.6);
|
|
49
|
-
animation-fill-mode: forwards;
|
|
50
|
-
filter: drop-shadow(0 0 4px rgba(0, 0, 0, 0.5));
|
|
51
|
-
}
|
|
52
|
-
input[type=checkbox].slidebox::before, input[type=checkbox].slidebox::after {
|
|
53
|
-
transition: color 0.2s ease-in-out;
|
|
54
|
-
}
|
|
55
|
-
:not([dir=rtl]) input[type=checkbox].slidebox:not(.inverted)::after {
|
|
56
|
-
animation-name: slideboxToRight;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
[dir=rtl] input[type=checkbox].slidebox:not(.inverted)::after {
|
|
60
|
-
animation-name: slideboxToLeft;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
input[type=checkbox].slidebox:not(.inverted).dark::before {
|
|
64
|
-
color: white;
|
|
65
|
-
}
|
|
66
|
-
input[type=checkbox].slidebox:not(.inverted).dark::after {
|
|
67
|
-
color: #e6e6e6;
|
|
68
|
-
}
|
|
69
|
-
input[type=checkbox].slidebox:not(.inverted).dark::after {
|
|
70
|
-
filter: brightness(130%) drop-shadow(0 0 4px rgba(0, 0, 0, 0.5));
|
|
71
|
-
}
|
|
72
|
-
input[type=checkbox].slidebox:not(.inverted).light::before {
|
|
73
|
-
color: white;
|
|
74
|
-
}
|
|
75
|
-
input[type=checkbox].slidebox:not(.inverted).light::after {
|
|
76
|
-
color: #f7f7f7;
|
|
77
|
-
}
|
|
78
|
-
input[type=checkbox].slidebox:not(.inverted).light::before {
|
|
79
|
-
filter: brightness(70%);
|
|
80
|
-
}
|
|
81
|
-
input[type=checkbox].slidebox:not(.inverted)::before {
|
|
82
|
-
color: white;
|
|
83
|
-
}
|
|
84
|
-
input[type=checkbox].slidebox:not(.inverted)::after {
|
|
85
|
-
color: #f7f7f7;
|
|
86
|
-
}
|
|
87
|
-
input[type=checkbox].slidebox:not(.inverted)::before {
|
|
88
|
-
filter: brightness(70%);
|
|
89
|
-
}
|
|
90
|
-
input[type=checkbox].slidebox:not(.inverted):checked::before, input[type=checkbox].slidebox:not(.inverted):checked::after {
|
|
91
|
-
color: inherit;
|
|
92
|
-
}
|
|
93
|
-
:not([dir=rtl]) input[type=checkbox].slidebox:not(.inverted):checked::after {
|
|
94
|
-
animation-name: slideboxToLeft;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
[dir=rtl] input[type=checkbox].slidebox:not(.inverted):checked::after {
|
|
98
|
-
animation-name: slideboxToRight;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
:not([dir=rtl]) input[type=checkbox].slidebox:not(.inverted):active:checked::after {
|
|
102
|
-
-webkit-transform: translateX(calc(-50% + 0.4em)) scale(1.1) !important;
|
|
103
|
-
transform: translateX(calc(-50% + 0.4em)) scale(1.1) !important;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
[dir=rtl] input[type=checkbox].slidebox:not(.inverted):active:checked::after {
|
|
107
|
-
-webkit-transform: translateX(calc(50% - 0.4em)) scale(1.1) !important;
|
|
108
|
-
transform: translateX(calc(50% - 0.4em)) scale(1.1) !important;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
:not([dir=rtl]) input[type=checkbox].slidebox:not(.inverted):active:not(:checked)::after {
|
|
112
|
-
-webkit-transform: translateX(calc(50% - 0.4em)) scale(1.1) !important;
|
|
113
|
-
transform: translateX(calc(50% - 0.4em)) scale(1.1) !important;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
[dir=rtl] input[type=checkbox].slidebox:not(.inverted):active:not(:checked)::after {
|
|
117
|
-
-webkit-transform: translateX(calc(-50% + 0.4em)) scale(1.1) !important;
|
|
118
|
-
transform: translateX(calc(-50% + 0.4em)) scale(1.1) !important;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
input[type=checkbox].slidebox.inverted::before, input[type=checkbox].slidebox.inverted::after {
|
|
122
|
-
color: inherit;
|
|
123
|
-
}
|
|
124
|
-
:not([dir=rtl]) input[type=checkbox].slidebox.inverted::after {
|
|
125
|
-
animation-name: slideboxToLeft;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
[dir=rtl] input[type=checkbox].slidebox.inverted::after {
|
|
129
|
-
animation-name: slideboxToRight;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
input[type=checkbox].slidebox.inverted.dark::after {
|
|
133
|
-
filter: brightness(130%) drop-shadow(0 0 4px rgba(0, 0, 0, 0.5));
|
|
134
|
-
}
|
|
135
|
-
input[type=checkbox].slidebox.inverted.light::before {
|
|
136
|
-
filter: brightness(70%);
|
|
137
|
-
}
|
|
138
|
-
input[type=checkbox].slidebox.inverted::before {
|
|
139
|
-
filter: brightness(70%);
|
|
140
|
-
}
|
|
141
|
-
:not([dir=rtl]) input[type=checkbox].slidebox.inverted:checked::after {
|
|
142
|
-
animation-name: slideboxToRight;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
[dir=rtl] input[type=checkbox].slidebox.inverted:checked::after {
|
|
146
|
-
animation-name: slideboxToLeft;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
input[type=checkbox].slidebox.inverted:checked.dark::before {
|
|
150
|
-
color: white;
|
|
151
|
-
}
|
|
152
|
-
input[type=checkbox].slidebox.inverted:checked.dark::after {
|
|
153
|
-
color: #e6e6e6;
|
|
154
|
-
}
|
|
155
|
-
input[type=checkbox].slidebox.inverted:checked.light::before {
|
|
156
|
-
color: white;
|
|
157
|
-
}
|
|
158
|
-
input[type=checkbox].slidebox.inverted:checked.light::after {
|
|
159
|
-
color: #f7f7f7;
|
|
160
|
-
}
|
|
161
|
-
input[type=checkbox].slidebox.inverted:checked::before {
|
|
162
|
-
color: white;
|
|
163
|
-
}
|
|
164
|
-
input[type=checkbox].slidebox.inverted:checked::after {
|
|
165
|
-
color: #f7f7f7;
|
|
166
|
-
}
|
|
167
|
-
:not([dir=rtl]) input[type=checkbox].slidebox.inverted:active:checked::after {
|
|
168
|
-
-webkit-transform: translateX(calc(50% - 0.4em)) scale(1.1) !important;
|
|
169
|
-
transform: translateX(calc(50% - 0.4em)) scale(1.1) !important;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
[dir=rtl] input[type=checkbox].slidebox.inverted:active:checked::after {
|
|
173
|
-
-webkit-transform: translateX(calc(-50% + 0.4em)) scale(1.1) !important;
|
|
174
|
-
transform: translateX(calc(-50% + 0.4em)) scale(1.1) !important;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
:not([dir=rtl]) input[type=checkbox].slidebox.inverted:active:not(:checked)::after {
|
|
178
|
-
-webkit-transform: translateX(calc(-50% + 0.4em)) scale(1.1) !important;
|
|
179
|
-
transform: translateX(calc(-50% + 0.4em)) scale(1.1) !important;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
[dir=rtl] input[type=checkbox].slidebox.inverted:active:not(:checked)::after {
|
|
183
|
-
-webkit-transform: translateX(calc(50% - 0.4em)) scale(1.1) !important;
|
|
184
|
-
transform: translateX(calc(50% - 0.4em)) scale(1.1) !important;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
@keyframes slideboxToLeft {
|
|
188
|
-
from {
|
|
189
|
-
-webkit-transform: translateX(calc(50% - 0.4em));
|
|
190
|
-
transform: translateX(calc(50% - 0.4em));
|
|
191
|
-
}
|
|
192
|
-
to {
|
|
193
|
-
-webkit-transform: translateX(calc(-50% + 0.4em));
|
|
194
|
-
transform: translateX(calc(-50% + 0.4em));
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
@keyframes slideboxToRight {
|
|
198
|
-
from {
|
|
199
|
-
-webkit-transform: translateX(calc(-50% + 0.4em));
|
|
200
|
-
transform: translateX(calc(-50% + 0.4em));
|
|
201
|
-
}
|
|
202
|
-
to {
|
|
203
|
-
-webkit-transform: translateX(calc(50% - 0.4em));
|
|
204
|
-
transform: translateX(calc(50% - 0.4em));
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
/*# sourceMappingURL=slidebox.css.map */
|
package/package.json
CHANGED
|
@@ -1,30 +1,38 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@monabbous/slidebox",
|
|
3
|
-
"version": "0.0
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"css",
|
|
12
|
-
"simple",
|
|
13
|
-
"style",
|
|
14
|
-
"slidebox",
|
|
15
|
-
"checkbox"
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Elastic, system-color-aware CSS checkbox switch.",
|
|
5
|
+
"license": "ISC",
|
|
6
|
+
"style": "./dist/css/slidebox.css",
|
|
7
|
+
"sass": "./scss/slidebox.scss",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist/css/slidebox.css",
|
|
10
|
+
"scss/slidebox.scss"
|
|
16
11
|
],
|
|
12
|
+
"publishConfig": {
|
|
13
|
+
"access": "public"
|
|
14
|
+
},
|
|
17
15
|
"repository": {
|
|
18
16
|
"type": "git",
|
|
19
|
-
"url": "https://github.com/monabbous/slidebox.git"
|
|
17
|
+
"url": "git+https://github.com/monabbous/slidebox.git"
|
|
18
|
+
},
|
|
19
|
+
"homepage": "https://github.com/monabbous/slidebox#readme",
|
|
20
|
+
"bugs": {
|
|
21
|
+
"url": "https://github.com/monabbous/slidebox/issues"
|
|
20
22
|
},
|
|
21
23
|
"scripts": {
|
|
22
|
-
"build": "
|
|
23
|
-
"
|
|
24
|
+
"build": "node scripts/build.mjs",
|
|
25
|
+
"test": "node --test tests/*.test.mjs",
|
|
26
|
+
"prepack": "npm run build"
|
|
24
27
|
},
|
|
25
|
-
"
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
"
|
|
29
|
-
|
|
28
|
+
"keywords": [
|
|
29
|
+
"slidebox",
|
|
30
|
+
"switch",
|
|
31
|
+
"toggle",
|
|
32
|
+
"checkbox",
|
|
33
|
+
"css",
|
|
34
|
+
"scss",
|
|
35
|
+
"elastic",
|
|
36
|
+
"system-colors"
|
|
37
|
+
]
|
|
30
38
|
}
|
package/scss/slidebox.scss
CHANGED
|
@@ -1,266 +1,58 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
@
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
@mixin slideboxEnd($extraTransform: null) {
|
|
63
|
-
@at-root :not([dir=rtl]) & {
|
|
64
|
-
@include slideboxRight($extraTransform);
|
|
65
|
-
}
|
|
66
|
-
@at-root [dir=rtl] & {
|
|
67
|
-
@include slideboxLeft($extraTransform);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
@mixin slideboxToStartAnimation() {
|
|
74
|
-
@at-root :not([dir=rtl]) & {
|
|
75
|
-
animation-name: slideboxToLeft;
|
|
76
|
-
}
|
|
77
|
-
@at-root [dir=rtl] & {
|
|
78
|
-
animation-name: slideboxToRight;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
@mixin slideboxToEndAnimation() {
|
|
83
|
-
@at-root :not([dir=rtl]) & {
|
|
84
|
-
animation-name: slideboxToRight;
|
|
85
|
-
}
|
|
86
|
-
@at-root [dir=rtl] & {
|
|
87
|
-
animation-name: slideboxToLeft;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
input[type=checkbox].#{$slideboxClassPrefix}slidebox {
|
|
92
|
-
-webkit-appearance: none !important;
|
|
93
|
-
-moz-appearance: none !important;
|
|
94
|
-
-ms-appearance: none !important;
|
|
95
|
-
-o-appearance: none !important;
|
|
96
|
-
appearance: none !important;
|
|
97
|
-
height: auto;
|
|
98
|
-
width: auto;
|
|
99
|
-
line-height: 0px;
|
|
100
|
-
position: relative;
|
|
101
|
-
color: $slideboxColorDefaultColor;
|
|
102
|
-
outline: 0 !important;
|
|
103
|
-
cursor: pointer;
|
|
104
|
-
padding: 0 #{$spacing / 2};
|
|
105
|
-
font-size: 1em;
|
|
106
|
-
transform-origin: center center;
|
|
107
|
-
|
|
108
|
-
&:focus::after {
|
|
109
|
-
outline: auto 5px -webkit-focus-ring-color;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
&::before {
|
|
113
|
-
direction: ltr;
|
|
114
|
-
position: absolute;
|
|
115
|
-
content: '\f111\f111\f111\f111\f111\f111\f111';
|
|
116
|
-
font-weight: 900;
|
|
117
|
-
font-family: 'Font Awesome 5 Free';
|
|
118
|
-
display: block;
|
|
119
|
-
letter-spacing: -$spacing;
|
|
120
|
-
margin-left: $spacing * 0.5;
|
|
121
|
-
left: 50%;
|
|
122
|
-
top: 50%;
|
|
123
|
-
transform-origin: center center;
|
|
124
|
-
-webkit-transform: translate(-50%, -50%) scale(0.8);
|
|
125
|
-
transform: translate(-50%, -50%) scale(0.8);
|
|
126
|
-
width: #{$spacing * 4};
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
&::after {
|
|
130
|
-
line-height: 1em;
|
|
131
|
-
position: relative;
|
|
132
|
-
content: '\f111';
|
|
133
|
-
font-weight: 900;
|
|
134
|
-
padding: #{$spacing / 2};
|
|
135
|
-
font-family: 'Font Awesome 5 Free';
|
|
136
|
-
display: block;
|
|
137
|
-
transform-origin: center center;
|
|
138
|
-
animation-duration: 0.2s;
|
|
139
|
-
animation-timing-function: cubic-bezier(0.68, -0.6, 0.32, 1.6);
|
|
140
|
-
animation-fill-mode: forwards;
|
|
141
|
-
filter: $slideboxShadowFilter;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
&::before, &::after {
|
|
145
|
-
transition: color 0.2s ease-in-out;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
&:not(.inverted) {
|
|
149
|
-
&::after {
|
|
150
|
-
@include slideboxToEndAnimation;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
&.dark {
|
|
154
|
-
@include dark-colors;
|
|
155
|
-
@include dark-filters;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
&.light {
|
|
159
|
-
@include light-colors;
|
|
160
|
-
@include light-filters;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
@if (lightness($slideboxColorDefaultColor) > 40) {
|
|
164
|
-
@include light-colors;
|
|
165
|
-
@include light-filters;
|
|
166
|
-
} @else {
|
|
167
|
-
@include dark-colors;
|
|
168
|
-
@include dark-filters;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
&:checked {
|
|
172
|
-
&::before, &::after {
|
|
173
|
-
color: inherit;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
&::after {
|
|
177
|
-
@include slideboxToStartAnimation;
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
&:active {
|
|
182
|
-
&:checked::after {
|
|
183
|
-
@include slideboxStart(scale(1.1) !important);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
&:not(:checked)::after {
|
|
187
|
-
@include slideboxEnd(scale(1.1) !important);
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
&.inverted {
|
|
194
|
-
&::before, &::after {
|
|
195
|
-
color: inherit;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
&::after {
|
|
199
|
-
@include slideboxToStartAnimation;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
&.dark {
|
|
203
|
-
@include dark-filters;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
&.light {
|
|
207
|
-
@include light-filters;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
@if (lightness($slideboxColorDefaultColor) > 40) {
|
|
211
|
-
@include light-filters;
|
|
212
|
-
} @else {
|
|
213
|
-
@include dark-filters;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
&:checked {
|
|
217
|
-
&::after {
|
|
218
|
-
@include slideboxToEndAnimation;
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
&.dark {
|
|
222
|
-
@include dark-colors;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
&.light {
|
|
226
|
-
@include light-colors;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
@if (lightness($slideboxColorDefaultColor) > 40) {
|
|
230
|
-
@include light-colors;
|
|
231
|
-
} @else {
|
|
232
|
-
@include dark-colors;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
&:active {
|
|
238
|
-
&:checked::after {
|
|
239
|
-
@include slideboxEnd(scale(1.1) !important);
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
&:not(:checked)::after {
|
|
243
|
-
@include slideboxStart(scale(1.1) !important);
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
@keyframes slideboxToLeft {
|
|
251
|
-
from {
|
|
252
|
-
@include slideboxRight;
|
|
253
|
-
}
|
|
254
|
-
to {
|
|
255
|
-
@include slideboxLeft;
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
@keyframes slideboxToRight {
|
|
260
|
-
from {
|
|
261
|
-
@include slideboxLeft;
|
|
262
|
-
}
|
|
263
|
-
to {
|
|
264
|
-
@include slideboxRight;
|
|
265
|
-
}
|
|
266
|
-
}
|
|
1
|
+
.slidebox {
|
|
2
|
+
--_container-width-ratio: 2;
|
|
3
|
+
--_thumb-spacing-ratio: .33;
|
|
4
|
+
--_deform: .1;
|
|
5
|
+
--_duration: 200ms;
|
|
6
|
+
--_easing-function: ease-in-out;
|
|
7
|
+
--_track: Field;
|
|
8
|
+
--_border: ButtonBorder;
|
|
9
|
+
--_off: FieldText;
|
|
10
|
+
--_on: light-dark(#0b75ff, SelectedItem);
|
|
11
|
+
appearance: none;
|
|
12
|
+
-webkit-appearance: none;
|
|
13
|
+
box-sizing: border-box;
|
|
14
|
+
display: inline-flex;
|
|
15
|
+
align-items: center;
|
|
16
|
+
justify-content: center;
|
|
17
|
+
width: calc(1em * var(--_container-width-ratio));
|
|
18
|
+
height: 1em;
|
|
19
|
+
font-size: 54px;
|
|
20
|
+
padding: 0;
|
|
21
|
+
border: 1px solid var(--_border);
|
|
22
|
+
border-radius: 100vw;
|
|
23
|
+
background: var(--_track);
|
|
24
|
+
cursor: pointer;
|
|
25
|
+
}
|
|
26
|
+
@supports (color: AccentColor) {
|
|
27
|
+
.slidebox { --_on: AccentColor; }
|
|
28
|
+
}
|
|
29
|
+
.slidebox::after {
|
|
30
|
+
--_start: 0; --_end: 1;
|
|
31
|
+
content: "";
|
|
32
|
+
display: block;
|
|
33
|
+
flex: 1 1 auto;
|
|
34
|
+
min-width: 0;
|
|
35
|
+
width: calc((1 - var(--_thumb-spacing-ratio)) * 1em);
|
|
36
|
+
height: calc((1 - var(--_thumb-spacing-ratio)) * 1em);
|
|
37
|
+
margin-block: calc(var(--_thumb-spacing-ratio) * .5em);
|
|
38
|
+
margin-inline-start: calc((1em * var(--_container-width-ratio) - 1em) * var(--_start) + var(--_thumb-spacing-ratio) * .5em);
|
|
39
|
+
margin-inline-end: calc((1em * var(--_container-width-ratio) - 1em) * var(--_end) + var(--_thumb-spacing-ratio) * .5em);
|
|
40
|
+
border-radius: inherit;
|
|
41
|
+
background: var(--_off);
|
|
42
|
+
transition: background var(--_duration) var(--_easing-function), margin-inline-start var(--_duration) var(--_easing-function), margin-inline-end var(--_duration) var(--_easing-function);
|
|
43
|
+
transition-delay: 0s, 0s, calc(var(--_duration) * var(--_deform));
|
|
44
|
+
}
|
|
45
|
+
.slidebox:checked::after {
|
|
46
|
+
--_start: 1; --_end: 0;
|
|
47
|
+
background: var(--_on);
|
|
48
|
+
transition-delay: 0s, calc(var(--_duration) * var(--_deform)), 0s;
|
|
49
|
+
}
|
|
50
|
+
.slidebox:not(:checked):active::after { --_end: calc(1 - var(--_deform)); }
|
|
51
|
+
.slidebox:checked:active::after { --_start: calc(1 - var(--_deform)); }
|
|
52
|
+
.slidebox:disabled { cursor: not-allowed; opacity: .5; }
|
|
53
|
+
@media (forced-colors: active) {
|
|
54
|
+
.slidebox { --_track: Field; --_border: ButtonBorder; --_off: FieldText; --_on: Highlight; }
|
|
55
|
+
}
|
|
56
|
+
@media (prefers-reduced-motion: reduce) {
|
|
57
|
+
.slidebox::after { transition-duration: .01ms; transition-delay: 0ms; }
|
|
58
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sourceRoot":"","sources":["../../scss/slidebox.scss"],"names":[],"mappings":";AA0FA;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,OApG0B;EAqG1B;EACA;EACA;EACA;EACA;;AAEA;EACE;;AAGF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAGF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,QAvImB;;AA0IrB;EACE;;AA9DO;EACP;;;AAEO;EACP;;;AAvEF;EACE;;AAGF;EACE;;AAXF;EACE;;AAqBF;EACE;;AAGF;EACE;;AAXF;EACE;;AAKF;EACE;;AAGF;EACE;;AAXF;EACE;;AAiJE;EACE;;AAnGG;EACP;;;AAEO;EACP;;;AAxBO;EANT;EACA;;;AAQS;EAfT;EACA;;;AAoBS;EArBT;EACA;;;AAuBS;EAlBT;EACA;;;AAiJE;EACE;;AAzHK;EACP;;;AAEO;EACP;;;AApEF;EACE;;AAeF;EACE;;AADF;EACE;;AAwDO;EACP;;;AAEO;EACP;;;AAvEF;EACE;;AAGF;EACE;;AAWF;EACE;;AAGF;EACE;;AALF;EACE;;AAGF;EACE;;AA0BO;EArBT;EACA;;;AAuBS;EAlBT;EACA;;;AAKS;EANT;EACA;;;AAQS;EAfT;EACA;;;AA+MF;EACE;IAjNA;IACA;;EAmNA;IA9MA;IACA;;;AAkNF;EACE;IApNA;IACA;;EAsNA;IA7NA;IACA","file":"slidebox.css"}
|
package/examples/simple.html
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8">
|
|
5
|
-
<meta name="viewport"
|
|
6
|
-
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
|
|
7
|
-
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
|
8
|
-
<title>@monabbous/slidebox Simple Example</title>
|
|
9
|
-
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css"
|
|
10
|
-
integrity="sha512-+4zCK9k+qNFUR5X+cKL9EIR+ZOhtIloNl9GIKS57V1MyNsYpYcUrUeQc9vNfzsWfV28IaLL3i96P9sdNyeRssA=="
|
|
11
|
-
crossorigin="anonymous"/>
|
|
12
|
-
<link rel="stylesheet" href="https://unpkg.com/@monabbous/slidebox@0.0.6/dist/css/slidebox.css"/>
|
|
13
|
-
<style>
|
|
14
|
-
body {
|
|
15
|
-
font-family: "Source Code Pro", "SF Mono", Monaco, Inconsolata, "Fira Mono", "Droid Sans Mono", monospace, monospace;
|
|
16
|
-
}
|
|
17
|
-
</style>
|
|
18
|
-
</head>
|
|
19
|
-
<body>
|
|
20
|
-
<h2>Default Slidebox</h2>
|
|
21
|
-
<div style="font-size: 2rem">
|
|
22
|
-
<input type="checkbox" class="slidebox">
|
|
23
|
-
<input type="checkbox" checked class="slidebox">
|
|
24
|
-
</div>
|
|
25
|
-
<h2>Custom Dark Color Slidebox</h2>
|
|
26
|
-
<div style="font-size: 2rem">
|
|
27
|
-
<input style="color:#040491" type="checkbox" class="slidebox dark">
|
|
28
|
-
<input style="color:#040491" type="checkbox" checked class="slidebox dark">
|
|
29
|
-
</div>
|
|
30
|
-
<h2>Custom Light Color Slidebox</h2>
|
|
31
|
-
<div style="font-size: 2rem">
|
|
32
|
-
<input style="color:#a8a8ff" type="checkbox" class="slidebox light">
|
|
33
|
-
<input style="color:#a8a8ff" type="checkbox" checked class="slidebox light">
|
|
34
|
-
</div>
|
|
35
|
-
<h2>Inverted Slidebox</h2>
|
|
36
|
-
<div style="font-size: 2rem">
|
|
37
|
-
<input type="checkbox" class="slidebox inverted">
|
|
38
|
-
<input type="checkbox" checked class="slidebox inverted">
|
|
39
|
-
</div>
|
|
40
|
-
</body>
|
|
41
|
-
</html>
|