viewkitjs 0.21.0 → 0.23.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/CHANGELOG.md +49 -0
- package/MIGRATION.md +1 -1
- package/README.md +1 -1
- package/fields/dist/conventions.d.ts +15 -3
- package/fields/dist/conventions.js +25 -0
- package/fields/dist/design/category-colors.d.ts +12 -5
- package/fields/dist/design/category-colors.js +7 -7
- package/fields/dist/query/buckets.js +42 -35
- package/fields/dist/query/date.js +2 -13
- package/fields/docs/guides/conventions.md +1 -1
- package/fields/docs/guides/options.md +2 -1
- package/fields/docs/reference/design-category-colors.md +2 -2
- package/fields/docs/reference/fields.md +1 -1
- package/package.json +13 -1
- package/views/dist/atoms/tones.js +7 -7
- package/views/dist/contract.d.ts +6 -1
- package/views/dist/contract.js +1 -0
- package/views/dist/controls/atoms.d.ts +8 -0
- package/views/dist/controls/atoms.js +8 -0
- package/views/dist/controls/button/button.d.ts +40 -0
- package/views/dist/controls/button/button.js +40 -0
- package/views/dist/controls/button/looks.d.ts +4 -0
- package/views/dist/controls/button/looks.js +20 -0
- package/views/dist/controls/button/map-button.d.ts +11 -0
- package/views/dist/controls/button/map-button.js +20 -0
- package/views/dist/controls/button/own-look.d.ts +59 -0
- package/views/dist/controls/button/own-look.js +33 -0
- package/views/dist/controls/button/tokens.d.ts +351 -0
- package/views/dist/controls/button/tokens.js +90 -0
- package/views/dist/controls/button.css +530 -0
- package/views/dist/controls/checkbox/checkbox.d.ts +28 -0
- package/views/dist/controls/checkbox/checkbox.js +15 -0
- package/views/dist/controls/checkbox/looks.d.ts +3 -0
- package/views/dist/controls/checkbox/looks.js +8 -0
- package/views/dist/controls/checkbox/map-checkbox.d.ts +2 -0
- package/views/dist/controls/checkbox/map-checkbox.js +5 -0
- package/views/dist/controls/checkbox/tokens.d.ts +131 -0
- package/views/dist/controls/checkbox/tokens.js +35 -0
- package/views/dist/controls/checkbox.css +133 -0
- package/views/dist/controls/controls.d.ts +14 -0
- package/views/dist/controls/controls.js +14 -0
- package/views/dist/controls/field/field.d.ts +94 -0
- package/views/dist/controls/field/field.js +46 -0
- package/views/dist/controls/field/looks.d.ts +13 -0
- package/views/dist/controls/field/looks.js +22 -0
- package/views/dist/controls/field/tokens.d.ts +75 -0
- package/views/dist/controls/field/tokens.js +21 -0
- package/views/dist/controls/field.css +98 -0
- package/views/dist/controls/glass-button/glass-button.d.ts +40 -0
- package/views/dist/controls/glass-button/glass-button.js +16 -0
- package/views/dist/controls/glass-button/looks.d.ts +4 -0
- package/views/dist/controls/glass-button/looks.js +4 -0
- package/views/dist/controls/glass-button/tokens.d.ts +127 -0
- package/views/dist/controls/glass-button/tokens.js +34 -0
- package/views/dist/controls/glass-button.css +111 -0
- package/views/dist/controls/index.d.ts +37 -0
- package/views/dist/controls/index.js +31 -0
- package/views/dist/controls/inline-input/inline-input.d.ts +14 -0
- package/views/dist/controls/inline-input/inline-input.js +10 -0
- package/views/dist/controls/inline-input/looks.d.ts +3 -0
- package/views/dist/controls/inline-input/looks.js +16 -0
- package/views/dist/controls/inline-input/tokens.d.ts +79 -0
- package/views/dist/controls/inline-input/tokens.js +22 -0
- package/views/dist/controls/inline-input.css +78 -0
- package/views/dist/controls/input/autofill.d.ts +25 -0
- package/views/dist/controls/input/autofill.js +17 -0
- package/views/dist/controls/input/input.d.ts +119 -0
- package/views/dist/controls/input/input.js +127 -0
- package/views/dist/controls/input/looks.d.ts +41 -0
- package/views/dist/controls/input/looks.js +48 -0
- package/views/dist/controls/input/map-input.d.ts +2 -0
- package/views/dist/controls/input/map-input.js +5 -0
- package/views/dist/controls/input/tokens.d.ts +171 -0
- package/views/dist/controls/input/tokens.js +45 -0
- package/views/dist/controls/input.css +381 -0
- package/views/dist/controls/internal/anchor.d.ts +16 -0
- package/views/dist/controls/internal/anchor.js +8 -0
- package/views/dist/controls/internal/close-reason.d.ts +5 -0
- package/views/dist/controls/internal/close-reason.js +2 -0
- package/views/dist/controls/internal/popup-host.d.ts +7 -0
- package/views/dist/controls/internal/popup-host.js +10 -0
- package/views/dist/controls/internal/scroll.d.ts +11 -0
- package/views/dist/controls/internal/scroll.js +14 -0
- package/views/dist/controls/kbd/kbd.d.ts +13 -0
- package/views/dist/controls/kbd/kbd.js +10 -0
- package/views/dist/controls/kbd/looks.d.ts +4 -0
- package/views/dist/controls/kbd/looks.js +4 -0
- package/views/dist/controls/kbd/tokens.d.ts +47 -0
- package/views/dist/controls/kbd/tokens.js +14 -0
- package/views/dist/controls/kbd.css +46 -0
- package/views/dist/controls/number-field/number-field.d.ts +48 -0
- package/views/dist/controls/number-field/number-field.js +34 -0
- package/views/dist/controls/number-field/tokens.d.ts +47 -0
- package/views/dist/controls/number-field/tokens.js +14 -0
- package/views/dist/controls/number-field.css +54 -0
- package/views/dist/controls/option/atom-tag.d.ts +6 -0
- package/views/dist/controls/option/atom-tag.js +6 -0
- package/views/dist/controls/option/looks.d.ts +7 -0
- package/views/dist/controls/option/looks.js +21 -0
- package/views/dist/controls/option/option.d.ts +35 -0
- package/views/dist/controls/option/option.js +32 -0
- package/views/dist/controls/option/tokens.d.ts +223 -0
- package/views/dist/controls/option/tokens.js +58 -0
- package/views/dist/controls/option.css +92 -0
- package/views/dist/controls/phone-header/header-bar.d.ts +18 -0
- package/views/dist/controls/phone-header/header-bar.js +9 -0
- package/views/dist/controls/phone-header/looks.d.ts +4 -0
- package/views/dist/controls/phone-header/looks.js +4 -0
- package/views/dist/controls/phone-header/soft-edge.d.ts +5 -0
- package/views/dist/controls/phone-header/soft-edge.js +3 -0
- package/views/dist/controls/phone-header/tokens.d.ts +59 -0
- package/views/dist/controls/phone-header/tokens.js +17 -0
- package/views/dist/controls/phone-header.css +51 -0
- package/views/dist/controls/popover/looks.d.ts +4 -0
- package/views/dist/controls/popover/looks.js +10 -0
- package/views/dist/controls/popover/map-popover.d.ts +3 -0
- package/views/dist/controls/popover/map-popover.js +5 -0
- package/views/dist/controls/popover/popover.d.ts +74 -0
- package/views/dist/controls/popover/popover.js +106 -0
- package/views/dist/controls/popover/tokens.d.ts +83 -0
- package/views/dist/controls/popover/tokens.js +23 -0
- package/views/dist/controls/popover.css +94 -0
- package/views/dist/controls/scrollbar/scrollbar.d.ts +10 -0
- package/views/dist/controls/scrollbar/scrollbar.js +143 -0
- package/views/dist/controls/scrollbar/tokens.d.ts +43 -0
- package/views/dist/controls/scrollbar/tokens.js +13 -0
- package/views/dist/controls/scrollbar.css +47 -0
- package/views/dist/controls/sheet/bottom-sheet.d.ts +98 -0
- package/views/dist/controls/sheet/bottom-sheet.js +372 -0
- package/views/dist/controls/sheet/forms.d.ts +38 -0
- package/views/dist/controls/sheet/forms.js +26 -0
- package/views/dist/controls/sheet/looks.d.ts +4 -0
- package/views/dist/controls/sheet/looks.js +10 -0
- package/views/dist/controls/sheet/map-sheet.d.ts +3 -0
- package/views/dist/controls/sheet/map-sheet.js +12 -0
- package/views/dist/controls/sheet/spring.d.ts +22 -0
- package/views/dist/controls/sheet/spring.js +48 -0
- package/views/dist/controls/sheet/tokens.d.ts +143 -0
- package/views/dist/controls/sheet/tokens.js +38 -0
- package/views/dist/controls/sheet.css +220 -0
- package/views/dist/controls/smooth.css +101 -0
- package/views/dist/controls/spinner/looks.d.ts +4 -0
- package/views/dist/controls/spinner/looks.js +32 -0
- package/views/dist/controls/spinner/spinner.d.ts +23 -0
- package/views/dist/controls/spinner/spinner.js +16 -0
- package/views/dist/controls/spinner/tokens.d.ts +55 -0
- package/views/dist/controls/spinner/tokens.js +16 -0
- package/views/dist/controls/spinner.css +147 -0
- package/views/dist/controls/status/atom-status-badge.d.ts +10 -0
- package/views/dist/controls/status/atom-status-badge.js +13 -0
- package/views/dist/controls/status/looks.d.ts +4 -0
- package/views/dist/controls/status/looks.js +22 -0
- package/views/dist/controls/status/marks.d.ts +26 -0
- package/views/dist/controls/status/marks.js +73 -0
- package/views/dist/controls/status/status.d.ts +43 -0
- package/views/dist/controls/status/status.js +26 -0
- package/views/dist/controls/status/tokens.d.ts +407 -0
- package/views/dist/controls/status/tokens.js +104 -0
- package/views/dist/controls/status.css +164 -0
- package/views/dist/controls/switch/looks.d.ts +4 -0
- package/views/dist/controls/switch/looks.js +19 -0
- package/views/dist/controls/switch/switch.d.ts +15 -0
- package/views/dist/controls/switch/switch.js +11 -0
- package/views/dist/controls/switch/tokens.d.ts +139 -0
- package/views/dist/controls/switch/tokens.js +37 -0
- package/views/dist/controls/switch.css +169 -0
- package/views/dist/controls/tag/atom-cell-more.d.ts +3 -0
- package/views/dist/controls/tag/atom-cell-more.js +5 -0
- package/views/dist/controls/tag/looks.d.ts +4 -0
- package/views/dist/controls/tag/looks.js +4 -0
- package/views/dist/controls/tag/tag.d.ts +25 -0
- package/views/dist/controls/tag/tag.js +19 -0
- package/views/dist/controls/tag/tokens.d.ts +63 -0
- package/views/dist/controls/tag/tokens.js +18 -0
- package/views/dist/controls/tag.css +81 -0
- package/views/dist/controls/toggle/looks.d.ts +3 -0
- package/views/dist/controls/toggle/looks.js +12 -0
- package/views/dist/controls/toggle/toggle.d.ts +47 -0
- package/views/dist/controls/toggle/toggle.js +23 -0
- package/views/dist/controls/toggle/tokens.d.ts +55 -0
- package/views/dist/controls/toggle/tokens.js +16 -0
- package/views/dist/controls/toggle.css +67 -0
- package/views/dist/controls/tokens.d.ts +16 -0
- package/views/dist/controls/tokens.js +45 -0
- package/views/dist/controls/tooltip/looks.d.ts +4 -0
- package/views/dist/controls/tooltip/looks.js +4 -0
- package/views/dist/controls/tooltip/map-tooltip.d.ts +3 -0
- package/views/dist/controls/tooltip/map-tooltip.js +5 -0
- package/views/dist/controls/tooltip/tokens.d.ts +75 -0
- package/views/dist/controls/tooltip/tokens.js +21 -0
- package/views/dist/controls/tooltip/tooltip.d.ts +54 -0
- package/views/dist/controls/tooltip/tooltip.js +78 -0
- package/views/dist/controls/tooltip.css +94 -0
- package/views/dist/display/date.js +15 -2
- package/views/dist/grid/chrome/GridTable.js +21 -19
- package/views/dist/grid/chrome/grid-row-window.js +3 -0
- package/views/dist/grid/chrome/useGridColumnLayout.d.ts +4 -1
- package/views/dist/grid/chrome/useGridColumnLayout.js +17 -2
- package/views/dist/grid/chrome/useGridFittedWidths.d.ts +29 -0
- package/views/dist/grid/chrome/useGridFittedWidths.js +46 -0
- package/views/dist/looks/index.d.ts +17 -0
- package/views/dist/looks/index.js +17 -0
- package/views/dist/looks/looks.d.ts +2 -1
- package/views/dist/looks/pieces.js +37 -1
- package/views/dist/model/column-schema.d.ts +3 -2
- package/views/dist/model/column-state.d.ts +11 -1
- package/views/dist/model/column-state.js +8 -2
- package/views/dist/panels/react/views-row/FoldingViewRow.js +8 -8
- package/views/dist/styles.css +2748 -56
- package/views/dist/styles.unlayered.css +2765 -56
- package/views/docs/contract.md +39 -8
- package/views/docs/controls/button.md +93 -0
- package/views/docs/controls/checkbox.md +38 -0
- package/views/docs/controls/field.md +26 -0
- package/views/docs/controls/glass-button.md +37 -0
- package/views/docs/controls/inline-input.md +27 -0
- package/views/docs/controls/input.md +48 -0
- package/views/docs/controls/kbd.md +17 -0
- package/views/docs/controls/number-field.md +17 -0
- package/views/docs/controls/option.md +61 -0
- package/views/docs/controls/phone-header.md +20 -0
- package/views/docs/controls/popover.md +26 -0
- package/views/docs/controls/scrollbar.md +16 -0
- package/views/docs/controls/sheet.md +41 -0
- package/views/docs/controls/spinner.md +19 -0
- package/views/docs/controls/status.md +107 -0
- package/views/docs/controls/switch.md +40 -0
- package/views/docs/controls/tag.md +21 -0
- package/views/docs/controls/toggle.md +19 -0
- package/views/docs/controls/tooltip.md +24 -0
- package/views/docs/getting-started.md +1 -1
- package/views/docs/guides/the-provider.md +1 -1
- package/views/docs/index.md +1 -0
- package/views/docs/install.md +2 -0
- package/views/docs/reference/controls.md +207 -0
- package/views/docs/reference/looks.md +77 -2
- package/views/docs/reference/views.md +10 -2
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/* The Status, as the Outright kit draws it. Every value it draws with is a public name (its tokens list);
|
|
2
|
+
this file only says which token each part, place and pick takes. With nothing picked, the Outright look's: a dot before the word in a pale pill.
|
|
3
|
+
|
|
4
|
+
What an app picks (looks.ts) is a data attribute on the frame or the app around it: its mark (data-status-mark), its
|
|
5
|
+
shape (data-status-shape), its colouring (data-status-colour) and what it says along the path (data-status-path). Every mark
|
|
6
|
+
is in the drawing for the status's own place (marks.ts); this file shows the one picked. A place sets its colours as
|
|
7
|
+
variables (--st-hue for the mark, --st-soft and --st-fill for a pill's ground, --st-fg for a word on it, --st-bold and --st-on
|
|
8
|
+
for a solid box, --st-edge for an edge), a colouring sets them again for the deal's places, and a shape reads them. The tick
|
|
9
|
+
and the cross are cut out in the ground the status stands on (--st-cut).
|
|
10
|
+
|
|
11
|
+
The rules sit in the components layer, so a utility class on a status still wins. */
|
|
12
|
+
@layer components {
|
|
13
|
+
|
|
14
|
+
/* ── The Status, as nothing picked draws it ───────────────────────────────────────────────────────────── */
|
|
15
|
+
.o-status {
|
|
16
|
+
--st-g0: calc(var(--vk-spacing) * 3.5); --st-g: var(--st-g0); --st-h: calc(var(--vk-spacing) * 5.5); --st-px: calc(var(--vk-spacing) * 2);
|
|
17
|
+
--st-cut: var(--vk-ground);
|
|
18
|
+
position: relative; flex: none; display: inline-flex; align-items: center; gap: calc(var(--vk-spacing) * 1.5); height: var(--st-h);
|
|
19
|
+
color: var(--vk-fg); font-size: var(--vk-font-size-xs); line-height: 1; font-weight: var(--vk-font-weight-medium); white-space: nowrap;
|
|
20
|
+
}
|
|
21
|
+
.o-status-svg { display: none; flex: none; height: var(--st-g); width: calc(var(--st-g) * var(--st-w, 1)); overflow: visible; fill: none; stroke: currentColor; stroke-linecap: round; color: var(--st-hue); }
|
|
22
|
+
.o-status-fill, .o-status-num { fill: currentColor; stroke: none; }
|
|
23
|
+
.o-status-mark { stroke: var(--st-cut); }
|
|
24
|
+
.o-status-off { opacity: 0.22; }
|
|
25
|
+
.o-status-spin { align-items: center; justify-content: center; width: var(--st-g); }
|
|
26
|
+
.o-list .o-status { --st-cut: var(--vk-overlay); }
|
|
27
|
+
|
|
28
|
+
/* The glyph alone, as a mark in a list or a menu. */
|
|
29
|
+
.o-status.o-status-glyph { height: auto; }
|
|
30
|
+
|
|
31
|
+
/* ── Sizes: sm in a dense row or a cell, md in a list, lg at the top of a record, xl a record's head on a phone ── */
|
|
32
|
+
.o-status.o-status-sm { --st-g0: calc(var(--vk-spacing) * 3); --st-h: calc(var(--vk-spacing) * 5); --st-px: calc(var(--vk-spacing) * 1.75); gap: calc(var(--vk-spacing) * 1.25); }
|
|
33
|
+
.o-status.o-status-lg { --st-g0: calc(var(--vk-spacing) * 4.25); --st-h: calc(var(--vk-spacing) * 7); --st-px: calc(var(--vk-spacing) * 2.5); gap: calc(var(--vk-spacing) * 2); font-size: var(--vk-font-size-sm); }
|
|
34
|
+
.o-status.o-status-xl { --st-g0: calc(var(--vk-spacing) * 4.5); --st-h: calc(var(--vk-spacing) * 8); --st-px: calc(var(--vk-spacing) * 3); gap: calc(var(--vk-spacing) * 2); font-size: var(--vk-font-size-base); }
|
|
35
|
+
|
|
36
|
+
/* ── Mark: the dot where nothing is picked, the Outright look's pick, or the one picked; a kind's place shows its own unless None is ── */
|
|
37
|
+
.o-status-svg[data-mark="dot"]:not([data-status-mark] *), .o-status-svg[data-mark="own"] { display: block; }
|
|
38
|
+
.o-status-svg.o-status-spin[data-mark="own"] { display: inline-flex; }
|
|
39
|
+
[data-status-mark] .o-status-svg[data-mark="quarters"] { display: none; }
|
|
40
|
+
[data-status-mark="quarters"] .o-status-svg[data-mark="quarters"], [data-status-mark="linear"] .o-status-svg[data-mark="linear"],
|
|
41
|
+
[data-status-mark="segments"] .o-status-svg[data-mark="segments"], [data-status-mark="progress"] .o-status-svg[data-mark="progress"],
|
|
42
|
+
[data-status-mark="pie"] .o-status-svg[data-mark="pie"], [data-status-mark="square"] .o-status-svg[data-mark="square"],
|
|
43
|
+
[data-status-mark="dot"] .o-status-svg[data-mark="dot"], [data-status-mark="dots"] .o-status-svg[data-mark="dots"],
|
|
44
|
+
[data-status-mark="bar"] .o-status-svg[data-mark="bar"], [data-status-mark="signal"] .o-status-svg[data-mark="signal"],
|
|
45
|
+
[data-status-mark="number"] .o-status-svg[data-mark="number"], [data-status-mark="stroke"] .o-status-svg[data-mark="stroke"] { display: block; }
|
|
46
|
+
[data-status-mark="none"] .o-status-svg[data-mark="own"] { display: none; }
|
|
47
|
+
/* A list's mark alone has nothing else to say where it stands: under None it is the dot. */
|
|
48
|
+
[data-status-mark="none"] .o-status-glyph .o-status-svg[data-mark="dot"], [data-status-mark="none"] .o-status-glyph .o-status-svg[data-mark="own"] { display: block; }
|
|
49
|
+
[data-status-mark="none"] .o-status-glyph .o-status-svg.o-status-spin[data-mark="own"] { display: inline-flex; }
|
|
50
|
+
|
|
51
|
+
/* ── Colour by meaning, every place's own: the start the brand, a step between information; then success, danger, warning,
|
|
52
|
+
and the subtlest grey for what is put away; the rest of a run's, a health's and a publication's places grey ──── */
|
|
53
|
+
.o-status[data-place="start"] {
|
|
54
|
+
--st-hue: var(--vk-fg-accent); --st-soft: var(--vk-brand-subtlest); --st-fill: var(--vk-brand-subtler); --st-fg: var(--vk-fg-accent);
|
|
55
|
+
--st-bold: var(--vk-brand); --st-on: var(--vk-fg-on-brand); --st-edge: var(--vk-border-accent);
|
|
56
|
+
}
|
|
57
|
+
.o-status:is([data-place="between"], [data-place="running"], [data-place="scheduled"]) {
|
|
58
|
+
--st-hue: var(--vk-info); --st-soft: var(--vk-info-subtlest); --st-fill: var(--vk-info-subtler); --st-fg: var(--vk-info);
|
|
59
|
+
--st-bold: var(--vk-info-bold); --st-on: var(--vk-fg-on-brand); --st-edge: var(--vk-border-info);
|
|
60
|
+
}
|
|
61
|
+
.o-status:is([data-place="won"], [data-place="succeeded"], [data-place="on-track"], [data-place="live"]) {
|
|
62
|
+
--st-hue: var(--vk-success); --st-soft: var(--vk-success-subtlest); --st-fill: var(--vk-success-subtler); --st-fg: var(--vk-success);
|
|
63
|
+
--st-bold: var(--vk-success-bold); --st-on: var(--vk-fg-inverse); --st-edge: var(--vk-border-success);
|
|
64
|
+
}
|
|
65
|
+
.o-status:is([data-place="lost"], [data-place="failed"], [data-place="off-track"]) {
|
|
66
|
+
--st-hue: var(--vk-danger); --st-soft: var(--vk-danger-subtlest); --st-fill: var(--vk-danger-subtler); --st-fg: var(--vk-danger);
|
|
67
|
+
--st-bold: var(--vk-danger-bold); --st-on: var(--vk-fg-inverse); --st-edge: var(--vk-border-danger);
|
|
68
|
+
}
|
|
69
|
+
.o-status:is([data-place="risk"], [data-place="at-risk"], [data-place="paused"]) {
|
|
70
|
+
--st-hue: var(--vk-warning); --st-soft: var(--vk-warning-subtlest); --st-fill: var(--vk-warning-subtler); --st-fg: var(--vk-warning);
|
|
71
|
+
--st-bold: var(--vk-warning-bold); --st-on: var(--vk-fg-warning-inverse); --st-edge: var(--vk-border-warning);
|
|
72
|
+
}
|
|
73
|
+
.o-status:is([data-place="archived"], [data-place="ended"]),
|
|
74
|
+
[data-status-colour="quiet"] .o-status[data-place="lost"] {
|
|
75
|
+
--st-hue: var(--vk-fg-subtlest); --st-soft: var(--vk-neutral); --st-fill: var(--vk-neutral-hovered); --st-fg: var(--vk-fg-subtle);
|
|
76
|
+
--st-bold: var(--vk-neutral-hovered); --st-on: var(--vk-fg); --st-edge: var(--vk-border-bold);
|
|
77
|
+
}
|
|
78
|
+
.o-status:is([data-place="queued"], [data-place="cancelled"], [data-place="skipped"], [data-place="no-update"], [data-place="draft"]),
|
|
79
|
+
:is([data-status-colour="quiet"], [data-status-colour="groups"]) .o-status[data-place="start"],
|
|
80
|
+
[data-status-colour="quiet"] .o-status[data-place="between"] {
|
|
81
|
+
--st-hue: var(--vk-fg-subtle); --st-soft: var(--vk-neutral); --st-fill: var(--vk-neutral-hovered); --st-fg: var(--vk-fg-subtle);
|
|
82
|
+
--st-bold: var(--vk-neutral-hovered); --st-on: var(--vk-fg); --st-edge: var(--vk-border-bold);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/* ── Colour › Each step its own: the step's own colour where it is given one (data-colour), else its place's on the canvas: the
|
|
86
|
+
start blue, its steps teal, purple and pink, won green, lost red, at risk amber ──────────────────────── */
|
|
87
|
+
[data-status-colour="step"] :is(.o-status[data-colour="blue"], .o-status:not([data-colour])[data-place="start"]) {
|
|
88
|
+
--st-hue: var(--vk-label-blue); --st-soft: var(--vk-label-blue-soft); --st-fill: var(--vk-label-blue-fill); --st-fg: var(--vk-label-blue-strong); --st-bold: var(--vk-blue-700); --st-on: var(--vk-fg-inverse); --st-edge: var(--vk-label-blue-edge);
|
|
89
|
+
}
|
|
90
|
+
[data-status-colour="step"] :is(.o-status[data-colour="teal"], .o-status:not([data-colour])[data-place="between"][data-quarters="1"]) {
|
|
91
|
+
--st-hue: var(--vk-label-teal); --st-soft: var(--vk-label-teal-soft); --st-fill: var(--vk-label-teal-fill); --st-fg: var(--vk-label-teal-strong); --st-bold: var(--vk-teal-700); --st-on: var(--vk-fg-inverse); --st-edge: var(--vk-label-teal-edge);
|
|
92
|
+
}
|
|
93
|
+
[data-status-colour="step"] :is(.o-status[data-colour="purple"], .o-status:not([data-colour])[data-place="between"][data-quarters="2"]) {
|
|
94
|
+
--st-hue: var(--vk-label-purple); --st-soft: var(--vk-label-purple-soft); --st-fill: var(--vk-label-purple-fill); --st-fg: var(--vk-label-purple-strong); --st-bold: var(--vk-purple-700); --st-on: var(--vk-fg-inverse); --st-edge: var(--vk-label-purple-edge);
|
|
95
|
+
}
|
|
96
|
+
[data-status-colour="step"] :is(.o-status[data-colour="pink"], .o-status:not([data-colour])[data-place="between"][data-quarters="3"]) {
|
|
97
|
+
--st-hue: var(--vk-label-pink); --st-soft: var(--vk-label-pink-soft); --st-fill: var(--vk-label-pink-fill); --st-fg: var(--vk-label-pink-strong); --st-bold: var(--vk-pink-700); --st-on: var(--vk-fg-inverse); --st-edge: var(--vk-label-pink-edge);
|
|
98
|
+
}
|
|
99
|
+
[data-status-colour="step"] :is(.o-status[data-colour="green"], .o-status:not([data-colour])[data-place="won"]) {
|
|
100
|
+
--st-hue: var(--vk-label-green); --st-soft: var(--vk-label-green-soft); --st-fill: var(--vk-label-green-fill); --st-fg: var(--vk-label-green-strong); --st-bold: var(--vk-green-700); --st-on: var(--vk-fg-inverse); --st-edge: var(--vk-label-green-edge);
|
|
101
|
+
}
|
|
102
|
+
[data-status-colour="step"] :is(.o-status[data-colour="red"], .o-status:not([data-colour])[data-place="lost"]) {
|
|
103
|
+
--st-hue: var(--vk-label-red); --st-soft: var(--vk-label-red-soft); --st-fill: var(--vk-label-red-fill); --st-fg: var(--vk-label-red-strong); --st-bold: var(--vk-red-700); --st-on: var(--vk-fg-inverse); --st-edge: var(--vk-label-red-edge);
|
|
104
|
+
}
|
|
105
|
+
[data-status-colour="step"] :is(.o-status[data-colour="amber"], .o-status:not([data-colour])[data-place="risk"]) {
|
|
106
|
+
--st-hue: var(--vk-label-amber); --st-soft: var(--vk-label-amber-soft); --st-fill: var(--vk-label-amber-fill); --st-fg: var(--vk-label-amber-strong); --st-bold: var(--vk-amber-700); --st-on: var(--vk-fg-warning-inverse); --st-edge: var(--vk-label-amber-edge);
|
|
107
|
+
}
|
|
108
|
+
[data-status-colour="step"] .o-status[data-colour="grey"] {
|
|
109
|
+
--st-hue: var(--vk-fg-subtle); --st-soft: var(--vk-neutral); --st-fill: var(--vk-neutral-hovered); --st-fg: var(--vk-fg-subtle); --st-bold: var(--vk-neutral-hovered); --st-on: var(--vk-fg); --st-edge: var(--vk-border-bold);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/* ── Colour › Deeper as it goes: the brand from its 500 to its 800 along the path; the ends keep their meaning ── */
|
|
113
|
+
[data-status-colour="deeper"] .o-status[data-place="start"] { --st-hue: var(--vk-brand-500); --st-soft: var(--vk-brand-100); --st-fill: var(--vk-brand-200); --st-fg: var(--vk-brand-700); --st-bold: var(--vk-brand-500); --st-on: var(--vk-brand-1000); --st-edge: var(--vk-brand-400); }
|
|
114
|
+
[data-status-colour="deeper"] .o-status[data-place="between"][data-quarters="1"] { --st-hue: var(--vk-brand-600); --st-soft: var(--vk-brand-100); --st-fill: var(--vk-brand-200); --st-fg: var(--vk-brand-700); --st-bold: var(--vk-brand-600); --st-on: var(--vk-brand-1000); --st-edge: var(--vk-brand-500); }
|
|
115
|
+
[data-status-colour="deeper"] .o-status[data-place="between"][data-quarters="2"] { --st-hue: var(--vk-brand-700); --st-soft: var(--vk-brand-100); --st-fill: var(--vk-brand-200); --st-fg: var(--vk-brand-700); --st-bold: var(--vk-brand-700); --st-on: var(--vk-fg-on-brand); --st-edge: var(--vk-brand-600); }
|
|
116
|
+
[data-status-colour="deeper"] .o-status[data-place="between"][data-quarters="3"] { --st-hue: var(--vk-brand-800); --st-soft: var(--vk-brand-100); --st-fill: var(--vk-brand-200); --st-fg: var(--vk-brand-800); --st-bold: var(--vk-brand-800); --st-on: var(--vk-fg-on-brand); --st-edge: var(--vk-brand-700); }
|
|
117
|
+
|
|
118
|
+
/* ── Shape. Word in colour: the word takes the mark's colour. A pill (pale, edged, quiet, solid, a lozenge, a square tag) holds
|
|
119
|
+
both on its ground, its mark half a step smaller and its cut-out in its ground. Mark alone: the word hidden from sight, still
|
|
120
|
+
read ─────────────────────────────────────────────────────────────────────────────────────────────── */
|
|
121
|
+
[data-status-shape="coloured"] .o-status { color: var(--st-hue); }
|
|
122
|
+
:is([data-status-shape="tint"], [data-status-shape="edged"], [data-status-shape="quiet"], [data-status-shape="solid"], [data-status-shape="lozenge"], [data-status-shape="tag"]) .o-status:not(.o-status-glyph),
|
|
123
|
+
.o-status:not(.o-status-glyph):not([data-status-shape] *) {
|
|
124
|
+
--st-g: calc(var(--st-g0) - var(--vk-spacing) * 0.5); --st-cut: var(--st-ground);
|
|
125
|
+
padding: 0 var(--st-px) 0 calc(var(--st-px) - var(--vk-spacing) * 0.5); border-radius: var(--vk-radius-full); background-color: var(--st-ground); color: var(--st-fg);
|
|
126
|
+
}
|
|
127
|
+
:is([data-status-shape="tint"], [data-status-shape="edged"], [data-status-shape="lozenge"]) .o-status, .o-status:not([data-status-shape] *) { --st-ground: var(--st-soft); }
|
|
128
|
+
[data-status-shape="edged"] .o-status:not(.o-status-glyph) { box-shadow: inset 0 0 0 var(--vk-border-width) var(--st-edge); }
|
|
129
|
+
[data-status-shape="quiet"] .o-status { --st-ground: var(--vk-raised); }
|
|
130
|
+
[data-status-shape="quiet"] .o-status:not(.o-status-glyph) { box-shadow: inset 0 0 0 var(--vk-border-width) var(--vk-border); color: var(--vk-fg); }
|
|
131
|
+
[data-status-shape="solid"] .o-status { --st-ground: var(--st-bold); }
|
|
132
|
+
[data-status-shape="solid"] .o-status:not(.o-status-glyph) { border-radius: var(--vk-radius-sm); color: var(--st-on); font-weight: var(--vk-font-weight-semibold); }
|
|
133
|
+
[data-status-shape="solid"] .o-status:not(.o-status-glyph) .o-status-svg { color: var(--st-on); }
|
|
134
|
+
[data-status-shape="lozenge"] .o-status:not(.o-status-glyph) {
|
|
135
|
+
height: calc(var(--st-h) - var(--vk-spacing)); padding: 0 var(--vk-spacing); gap: var(--vk-spacing); border-radius: var(--vk-radius-xs);
|
|
136
|
+
font-weight: var(--vk-font-weight-bold); text-transform: uppercase; letter-spacing: var(--vk-tracking-wide);
|
|
137
|
+
}
|
|
138
|
+
[data-status-shape="tag"] .o-status { --st-ground: var(--st-fill); }
|
|
139
|
+
[data-status-shape="tag"] .o-status:not(.o-status-glyph) { height: calc(var(--st-h) - var(--vk-spacing) * 0.5); border-radius: var(--vk-radius-xs); padding: 0 calc(var(--st-px) - var(--vk-spacing) * 0.5); }
|
|
140
|
+
[data-status-shape="alone"] .o-status-word { position: absolute; width: var(--vk-border-width); height: var(--vk-border-width); overflow: hidden; clip-path: inset(50%); }
|
|
141
|
+
[data-status-shape="alone"] .o-status { --st-g: calc(var(--st-g0) + var(--vk-spacing) * 0.5); }
|
|
142
|
+
|
|
143
|
+
/* ── Along the path: what it says of the steps around it, where it is told. Steps under the word, five short bars; a small
|
|
144
|
+
path, five chevrons before it; in words, its step of five or where it was lost; time there, how long it has stood there,
|
|
145
|
+
in the warning colour once it has stood too long ─────────────────────────────────────────────────────── */
|
|
146
|
+
.o-status-path, .o-status-more { display: none; }
|
|
147
|
+
.o-status-path > span { flex: none; background-color: var(--vk-border); }
|
|
148
|
+
.o-status-path > span[data-on] { background-color: var(--st-hue); }
|
|
149
|
+
[data-status-path="before"] .o-status-path[data-form="before"] { display: inline-flex; gap: calc(var(--vk-spacing) * 0.25); order: -1; }
|
|
150
|
+
[data-status-path="before"] .o-status-path[data-form="before"] > span { width: calc(var(--vk-spacing) * 1.75); height: calc(var(--vk-spacing) * 2.75); clip-path: polygon(0 0, 50% 0, 100% 50%, 50% 100%, 0 100%, 50% 50%); }
|
|
151
|
+
/* Under the word: a grid, so the bars take a line of their own across the mark and the word and the status is as wide as the
|
|
152
|
+
wider of the two, never as wide as all three side by side. */
|
|
153
|
+
[data-status-path="under"] .o-status:not(.o-status-glyph) { display: inline-grid; grid-template-columns: repeat(3, auto); justify-content: start; height: auto; min-height: var(--st-h); row-gap: calc(var(--vk-spacing) * 1.25); }
|
|
154
|
+
[data-status-path="under"] .o-status-path[data-form="under"] { display: flex; grid-row: 2; grid-column: 1 / -1; gap: calc(var(--vk-spacing) * 0.75); }
|
|
155
|
+
[data-status-path="under"] .o-status-path[data-form="under"] > span { width: calc(var(--vk-spacing) * 3.25); height: var(--vk-spacing); border-radius: var(--vk-radius-full); }
|
|
156
|
+
:is([data-status-path="words"] .o-status-more[data-form="words"], [data-status-path="time"] .o-status-more[data-form="time"]) {
|
|
157
|
+
display: inline; margin-left: calc(var(--vk-spacing) * -0.5); color: var(--vk-fg-subtlest); font-weight: var(--vk-font-weight-normal);
|
|
158
|
+
}
|
|
159
|
+
[data-status-path="time"] .o-status-more[data-form="time"][data-stale] { color: var(--vk-warning); }
|
|
160
|
+
|
|
161
|
+
/* A status drawn as a field's value (the StatusBadge atom at size `row`): the size of the text around it, a cell's or a field
|
|
162
|
+
row's, its mark and its height as above. */
|
|
163
|
+
.o-status.vk-status-row { font-size: inherit; }
|
|
164
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const options = [
|
|
2
|
+
{ id: "shape", name: "Shape", device: "desktop", def: "capsule", values: [{ id: "slim", name: "Slim" }, { id: "capsule", name: "Capsule" }, { id: "thin", name: "Thin track" }, { id: "hairline", name: "Hairline" }, { id: "classic", name: "Classic" }] },
|
|
3
|
+
{ id: "phone", name: "Shape", device: "phone", def: "capsule", values: [{ id: "round", name: "Round" }, { id: "capsule", name: "Capsule" }] },
|
|
4
|
+
{ id: "mark", name: "Mark", def: "none", values: [{ id: "none", name: "None" }, { id: "tick", name: "A tick" }, { id: "both", name: "Cross or tick" }, { id: "io", name: "I and O" }, { id: "words", name: "On and Off" }] },
|
|
5
|
+
{ id: "motion", name: "Motion", def: "quick", values: [{ id: "quick", name: "Quick" }, { id: "held", name: "Stretch while held" }, { id: "spring", name: "Spring" }, { id: "stretch", name: "Stretch as it goes" }, { id: "follow", name: "Colour follows" }] },
|
|
6
|
+
];
|
|
7
|
+
const base = { shape: "slim", phone: "round", mark: "none", motion: "quick" };
|
|
8
|
+
export const SWITCH_LOOKS = {
|
|
9
|
+
id: "switch",
|
|
10
|
+
name: "Switch",
|
|
11
|
+
options,
|
|
12
|
+
looks: [
|
|
13
|
+
{ id: "slim", name: "Slim", picks: { ...base } },
|
|
14
|
+
{ id: "capsule", name: "Capsule", picks: { ...base, shape: "capsule", phone: "capsule" } },
|
|
15
|
+
{ id: "thin", name: "Thin track", picks: { ...base, shape: "thin" } },
|
|
16
|
+
{ id: "hairline", name: "Hairline", picks: { ...base, shape: "hairline" } },
|
|
17
|
+
{ id: "classic", name: "Classic", picks: { ...base, shape: "classic", motion: "held" } },
|
|
18
|
+
],
|
|
19
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Switch as BaseSwitch } from "@base-ui/react/switch";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
export interface SwitchProps extends Omit<React.ComponentProps<typeof BaseSwitch.Root>, "className"> {
|
|
4
|
+
/** sm in dense rows, md everywhere else, lg the phone's; on a phone md takes lg's size. */
|
|
5
|
+
size?: "sm" | "md" | "lg";
|
|
6
|
+
/** The change is being saved: its thumb turns, a press does nothing, and it lands when this is over. */
|
|
7
|
+
saving?: boolean;
|
|
8
|
+
/** It can't be changed here, and a lock in its thumb says so; a line beside it says why. */
|
|
9
|
+
locked?: boolean;
|
|
10
|
+
/** Its two words, drawn in its track when the Mark picked is On and Off; "On" and "Off" unless given. */
|
|
11
|
+
words?: [on: string, off: string];
|
|
12
|
+
className?: string;
|
|
13
|
+
}
|
|
14
|
+
/** Turns a setting on or off, and the change happens at once. Give it an aria-label, or put it in a labelled row. */
|
|
15
|
+
export declare const Switch: React.ForwardRefExoticComponent<Omit<SwitchProps, "ref"> & React.RefAttributes<HTMLElement>>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { Switch as BaseSwitch } from "@base-ui/react/switch";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { cx } from "../../internal/cx.js";
|
|
5
|
+
import { Spinner } from "../spinner/spinner.js";
|
|
6
|
+
const glyph = (className, d) => (_jsx("svg", { className: className, viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: _jsx("path", { d: d }) }));
|
|
7
|
+
const TICK = glyph("o-switch-tick", "M3.8 8.4 6.6 11.1 12.2 5.2"), CROSS = glyph("o-switch-cross", "M4.8 4.8 11.2 11.2M11.2 4.8 4.8 11.2");
|
|
8
|
+
const LOCK = (_jsxs("svg", { className: "o-switch-lock", viewBox: "0 0 16 16", "aria-hidden": "true", children: [_jsx("rect", { x: "4.2", y: "7.4", width: "7.6", height: "5.4", rx: "1.3", fill: "currentColor" }), _jsx("path", { d: "M5.8 7.4V5.7a2.2 2.2 0 0 1 4.4 0v1.7", fill: "none", stroke: "currentColor", strokeLinecap: "round" })] }));
|
|
9
|
+
export const Switch = React.forwardRef(function Switch({ size = "md", saving, locked, words = ["On", "Off"], className, disabled, readOnly, ...props }, ref) {
|
|
10
|
+
return (_jsxs(BaseSwitch.Root, { ref: ref, className: cx("o-switch", size === "sm" && "o-switch-sm", size === "lg" && "o-switch-lg", className), "data-kit": "switch", disabled: disabled || locked, readOnly: readOnly || saving, "aria-busy": saving || undefined, "data-saving": saving ? "" : undefined, "data-locked": locked ? "" : undefined, ...props, children: [_jsx("span", { className: "o-switch-fill", "aria-hidden": "true" }), _jsx("span", { className: "o-switch-i", "aria-hidden": "true" }), _jsx("span", { className: "o-switch-o", "aria-hidden": "true" }), _jsx("span", { className: "o-switch-word", "data-for": "on", "aria-hidden": "true", children: words[0] }), _jsx("span", { className: "o-switch-word", "data-for": "off", "aria-hidden": "true", children: words[1] }), _jsx(BaseSwitch.Thumb, { className: "o-switch-thumb", children: saving ? _jsx(Spinner, { size: size === "lg" ? 16 : size === "sm" ? 10 : 12, label: "" }) : locked ? LOCK : _jsxs(_Fragment, { children: [TICK, CROSS] }) })] }));
|
|
11
|
+
});
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
export declare const SWITCH_TOKENS: readonly [{
|
|
2
|
+
readonly name: "--vk-border-bold";
|
|
3
|
+
readonly kind: "colour";
|
|
4
|
+
readonly outright: "--border-bold";
|
|
5
|
+
}, {
|
|
6
|
+
readonly name: "--vk-border-brand";
|
|
7
|
+
readonly kind: "colour";
|
|
8
|
+
readonly outright: "--border-focused";
|
|
9
|
+
}, {
|
|
10
|
+
readonly name: "--vk-border-danger";
|
|
11
|
+
readonly kind: "colour";
|
|
12
|
+
readonly outright: "--border-danger";
|
|
13
|
+
}, {
|
|
14
|
+
readonly name: "--vk-border-input";
|
|
15
|
+
readonly kind: "colour";
|
|
16
|
+
readonly outright: "--border-input";
|
|
17
|
+
}, {
|
|
18
|
+
readonly name: "--vk-border-input-hovered";
|
|
19
|
+
readonly kind: "colour";
|
|
20
|
+
readonly outright: "--border-input-hovered";
|
|
21
|
+
}, {
|
|
22
|
+
readonly name: "--vk-border-subtle";
|
|
23
|
+
readonly kind: "colour";
|
|
24
|
+
readonly outright: "--border-subtle";
|
|
25
|
+
}, {
|
|
26
|
+
readonly name: "--vk-brand";
|
|
27
|
+
readonly kind: "colour";
|
|
28
|
+
readonly outright: "--background-brand-bold";
|
|
29
|
+
}, {
|
|
30
|
+
readonly name: "--vk-brand-hovered";
|
|
31
|
+
readonly kind: "colour";
|
|
32
|
+
readonly outright: "--background-brand-bold-hovered";
|
|
33
|
+
}, {
|
|
34
|
+
readonly name: "--vk-brand-subtler";
|
|
35
|
+
readonly kind: "colour";
|
|
36
|
+
readonly outright: "--background-brand-subtler";
|
|
37
|
+
}, {
|
|
38
|
+
readonly name: "--vk-danger-bold";
|
|
39
|
+
readonly kind: "colour";
|
|
40
|
+
readonly outright: "--background-danger-bold";
|
|
41
|
+
}, {
|
|
42
|
+
readonly name: "--vk-danger-bold-hovered";
|
|
43
|
+
readonly kind: "colour";
|
|
44
|
+
readonly outright: "--background-danger-bold-hovered";
|
|
45
|
+
}, {
|
|
46
|
+
readonly name: "--vk-fg-accent";
|
|
47
|
+
readonly kind: "colour";
|
|
48
|
+
readonly outright: "--text-brand";
|
|
49
|
+
}, {
|
|
50
|
+
readonly name: "--vk-fg-disabled";
|
|
51
|
+
readonly kind: "colour";
|
|
52
|
+
readonly outright: "--text-disabled";
|
|
53
|
+
}, {
|
|
54
|
+
readonly name: "--vk-fg-inverse";
|
|
55
|
+
readonly kind: "colour";
|
|
56
|
+
readonly outright: "--text-inverse";
|
|
57
|
+
}, {
|
|
58
|
+
readonly name: "--vk-fg-on-brand";
|
|
59
|
+
readonly kind: "colour";
|
|
60
|
+
readonly outright: "--text-brand-inverse";
|
|
61
|
+
}, {
|
|
62
|
+
readonly name: "--vk-fg-subtle";
|
|
63
|
+
readonly kind: "colour";
|
|
64
|
+
readonly outright: "--text-subtle";
|
|
65
|
+
}, {
|
|
66
|
+
readonly name: "--vk-ground";
|
|
67
|
+
readonly kind: "colour";
|
|
68
|
+
readonly outright: "--surface";
|
|
69
|
+
}, {
|
|
70
|
+
readonly name: "--vk-neutral";
|
|
71
|
+
readonly kind: "colour";
|
|
72
|
+
readonly outright: "--background-neutral";
|
|
73
|
+
}, {
|
|
74
|
+
readonly name: "--vk-neutral-hovered";
|
|
75
|
+
readonly kind: "colour";
|
|
76
|
+
readonly outright: "--background-neutral-hovered";
|
|
77
|
+
}, {
|
|
78
|
+
readonly name: "--vk-shadow-md";
|
|
79
|
+
readonly kind: "shadow";
|
|
80
|
+
readonly outright: "--shadow-md";
|
|
81
|
+
}, {
|
|
82
|
+
readonly name: "--vk-shadow-sm";
|
|
83
|
+
readonly kind: "shadow";
|
|
84
|
+
readonly outright: "--shadow-sm";
|
|
85
|
+
}, {
|
|
86
|
+
readonly name: "--vk-shadow-xs";
|
|
87
|
+
readonly kind: "shadow";
|
|
88
|
+
readonly outright: "--shadow-xs";
|
|
89
|
+
}, {
|
|
90
|
+
readonly name: "--vk-border-width";
|
|
91
|
+
readonly kind: "size";
|
|
92
|
+
readonly outright: "--border-width";
|
|
93
|
+
}, {
|
|
94
|
+
readonly name: "--vk-focus-offset";
|
|
95
|
+
readonly kind: "size";
|
|
96
|
+
readonly outright: "--focus-offset";
|
|
97
|
+
}, {
|
|
98
|
+
readonly name: "--vk-focus-width";
|
|
99
|
+
readonly kind: "size";
|
|
100
|
+
readonly outright: "--focus-width";
|
|
101
|
+
}, {
|
|
102
|
+
readonly name: "--vk-font-weight-semibold";
|
|
103
|
+
readonly kind: "size";
|
|
104
|
+
readonly outright: "--font-weight-semibold";
|
|
105
|
+
}, {
|
|
106
|
+
readonly name: "--vk-radius-full";
|
|
107
|
+
readonly kind: "size";
|
|
108
|
+
readonly outright: "--radius-full";
|
|
109
|
+
}, {
|
|
110
|
+
readonly name: "--vk-spacing";
|
|
111
|
+
readonly kind: "size";
|
|
112
|
+
readonly outright: "--spacing";
|
|
113
|
+
}, {
|
|
114
|
+
readonly name: "--vk-duration-base";
|
|
115
|
+
readonly kind: "motion";
|
|
116
|
+
readonly outright: "--duration-base";
|
|
117
|
+
}, {
|
|
118
|
+
readonly name: "--vk-duration-fast";
|
|
119
|
+
readonly kind: "motion";
|
|
120
|
+
readonly outright: "--duration-fast";
|
|
121
|
+
}, {
|
|
122
|
+
readonly name: "--vk-duration-slow";
|
|
123
|
+
readonly kind: "motion";
|
|
124
|
+
readonly outright: "--duration-slow";
|
|
125
|
+
}, {
|
|
126
|
+
readonly name: "--vk-ease-in-out";
|
|
127
|
+
readonly kind: "motion";
|
|
128
|
+
readonly outright: "--ease-in-out";
|
|
129
|
+
}, {
|
|
130
|
+
readonly name: "--vk-ease-out";
|
|
131
|
+
readonly kind: "motion";
|
|
132
|
+
readonly outright: "--ease-out";
|
|
133
|
+
}, {
|
|
134
|
+
readonly name: "--vk-ease-spring";
|
|
135
|
+
readonly kind: "motion";
|
|
136
|
+
readonly outright: "--ease-spring";
|
|
137
|
+
}];
|
|
138
|
+
/** The prefixes of the Switch's own machinery, set and read by it alone: not public. */
|
|
139
|
+
export declare const SWITCH_PRIVATE: readonly ["--sw-"];
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export const SWITCH_TOKENS = [
|
|
2
|
+
{ name: "--vk-border-bold", kind: "colour", outright: "--border-bold" },
|
|
3
|
+
{ name: "--vk-border-brand", kind: "colour", outright: "--border-focused" },
|
|
4
|
+
{ name: "--vk-border-danger", kind: "colour", outright: "--border-danger" },
|
|
5
|
+
{ name: "--vk-border-input", kind: "colour", outright: "--border-input" },
|
|
6
|
+
{ name: "--vk-border-input-hovered", kind: "colour", outright: "--border-input-hovered" },
|
|
7
|
+
{ name: "--vk-border-subtle", kind: "colour", outright: "--border-subtle" },
|
|
8
|
+
{ name: "--vk-brand", kind: "colour", outright: "--background-brand-bold" },
|
|
9
|
+
{ name: "--vk-brand-hovered", kind: "colour", outright: "--background-brand-bold-hovered" },
|
|
10
|
+
{ name: "--vk-brand-subtler", kind: "colour", outright: "--background-brand-subtler" },
|
|
11
|
+
{ name: "--vk-danger-bold", kind: "colour", outright: "--background-danger-bold" },
|
|
12
|
+
{ name: "--vk-danger-bold-hovered", kind: "colour", outright: "--background-danger-bold-hovered" },
|
|
13
|
+
{ name: "--vk-fg-accent", kind: "colour", outright: "--text-brand" },
|
|
14
|
+
{ name: "--vk-fg-disabled", kind: "colour", outright: "--text-disabled" },
|
|
15
|
+
{ name: "--vk-fg-inverse", kind: "colour", outright: "--text-inverse" },
|
|
16
|
+
{ name: "--vk-fg-on-brand", kind: "colour", outright: "--text-brand-inverse" },
|
|
17
|
+
{ name: "--vk-fg-subtle", kind: "colour", outright: "--text-subtle" },
|
|
18
|
+
{ name: "--vk-ground", kind: "colour", outright: "--surface" },
|
|
19
|
+
{ name: "--vk-neutral", kind: "colour", outright: "--background-neutral" },
|
|
20
|
+
{ name: "--vk-neutral-hovered", kind: "colour", outright: "--background-neutral-hovered" },
|
|
21
|
+
{ name: "--vk-shadow-md", kind: "shadow", outright: "--shadow-md" },
|
|
22
|
+
{ name: "--vk-shadow-sm", kind: "shadow", outright: "--shadow-sm" },
|
|
23
|
+
{ name: "--vk-shadow-xs", kind: "shadow", outright: "--shadow-xs" },
|
|
24
|
+
{ name: "--vk-border-width", kind: "size", outright: "--border-width" },
|
|
25
|
+
{ name: "--vk-focus-offset", kind: "size", outright: "--focus-offset" },
|
|
26
|
+
{ name: "--vk-focus-width", kind: "size", outright: "--focus-width" },
|
|
27
|
+
{ name: "--vk-font-weight-semibold", kind: "size", outright: "--font-weight-semibold" },
|
|
28
|
+
{ name: "--vk-radius-full", kind: "size", outright: "--radius-full" },
|
|
29
|
+
{ name: "--vk-spacing", kind: "size", outright: "--spacing" },
|
|
30
|
+
{ name: "--vk-duration-base", kind: "motion", outright: "--duration-base" },
|
|
31
|
+
{ name: "--vk-duration-fast", kind: "motion", outright: "--duration-fast" },
|
|
32
|
+
{ name: "--vk-duration-slow", kind: "motion", outright: "--duration-slow" },
|
|
33
|
+
{ name: "--vk-ease-in-out", kind: "motion", outright: "--ease-in-out" },
|
|
34
|
+
{ name: "--vk-ease-out", kind: "motion", outright: "--ease-out" },
|
|
35
|
+
{ name: "--vk-ease-spring", kind: "motion", outright: "--ease-spring" },
|
|
36
|
+
];
|
|
37
|
+
export const SWITCH_PRIVATE = ["--sw-"];
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/* The Switch, as the Outright kit draws it. Every value it draws with is a public name (its tokens list);
|
|
2
|
+
this file only says which token each part, shape and state takes. Its sizes are spacing steps, its shares of its own height
|
|
3
|
+
and its shapes' proportions the drawing's geometry. Base UI marks the track and the thumb data-checked and data-disabled;
|
|
4
|
+
data-force draws a state for the sheet.
|
|
5
|
+
|
|
6
|
+
What an app picks (looks.ts) is a data attribute on the frame or the app around it: its shape on a computer
|
|
7
|
+
(data-switch-shape), its shape on a phone (data-switch-phone), what it holds (data-switch-mark) and how it moves
|
|
8
|
+
(data-switch-motion). A shape sets its sizes and its resting paint as variables; the states after them (the pointer, on,
|
|
9
|
+
error, disabled) choose among those, a later one winning. The track is painted by ::before, since ::after is its pressing
|
|
10
|
+
area (the pressing area the app gives it) and a thin track is narrower than the switch itself.
|
|
11
|
+
|
|
12
|
+
The rules sit in the components layer, so a utility class on a switch still wins. */
|
|
13
|
+
@layer components {
|
|
14
|
+
|
|
15
|
+
/* ── Slim (after shadcn), the shape the others start from: a track 18 × 32 barely larger than its 16 thumb, 1 from its edge, with no
|
|
16
|
+
edge of its own; off, the field edge's grey; on, the brand ─────────────────────────────────────────────────────── */
|
|
17
|
+
.o-switch {
|
|
18
|
+
--sw-u: 1; --sw-more: 0px;
|
|
19
|
+
--sw-h: calc(var(--vk-spacing) * 4.5 * var(--sw-u)); --sw-w0: calc(var(--vk-spacing) * 8 * var(--sw-u)); --sw-w: calc(var(--sw-w0) + var(--sw-more));
|
|
20
|
+
--sw-tw: calc(var(--vk-spacing) * 4 * var(--sw-u)); --sw-th: var(--sw-tw); --sw-inset: calc(var(--vk-spacing) * 0.25 * var(--sw-u)); --sw-bar: 100%;
|
|
21
|
+
--sw-rest: var(--vk-border-input); --sw-hover: var(--vk-border-input-hovered); --sw-edge-rest: transparent; --sw-edge-hover: transparent;
|
|
22
|
+
--sw-thumb-rest: var(--vk-fg-inverse); --sw-thumb-on: var(--vk-fg-on-brand); --sw-thumb-shadow: var(--vk-shadow-xs);
|
|
23
|
+
--sw-glyph-on: var(--sw-on); --sw-glyph-off: var(--vk-fg-subtle); --sw-ink: var(--vk-fg-on-brand);
|
|
24
|
+
/* What it paints now: the states below choose. */
|
|
25
|
+
--sw-off: var(--sw-rest); --sw-edge: var(--sw-edge-rest); --sw-on: var(--vk-brand); --sw-on-track: var(--sw-on);
|
|
26
|
+
--sw-paint: var(--sw-off); --sw-ring: var(--sw-edge); --sw-knob: var(--sw-thumb-rest); --sw-knob-on: var(--sw-thumb-on); --sw-knob-shadow: var(--sw-thumb-shadow);
|
|
27
|
+
/* Quick, the motion nothing picked draws: no stretch, duration-fast, fast at first. Lead is its front edge's time, trail its back's. */
|
|
28
|
+
--sw-time: var(--vk-duration-fast); --sw-ease: var(--vk-ease-out); --sw-lead: var(--sw-time); --sw-trail: var(--sw-time);
|
|
29
|
+
position: relative; isolation: isolate; flex: none; display: inline-block; box-sizing: border-box;
|
|
30
|
+
width: var(--sw-w); height: var(--sw-h); border-radius: var(--vk-radius-full);
|
|
31
|
+
cursor: pointer; outline: none; -webkit-tap-highlight-color: transparent;
|
|
32
|
+
}
|
|
33
|
+
.o-switch::before {
|
|
34
|
+
content: ""; position: absolute; inset: calc((100% - var(--sw-bar)) / 2) 0; border-radius: inherit;
|
|
35
|
+
background-color: var(--sw-paint); box-shadow: inset 0 0 0 var(--vk-border-width) var(--sw-ring);
|
|
36
|
+
transition: background-color var(--sw-time) var(--vk-ease-out), box-shadow var(--sw-time) var(--vk-ease-out);
|
|
37
|
+
}
|
|
38
|
+
.o-switch-thumb {
|
|
39
|
+
position: absolute; z-index: 2; top: 50%; height: var(--sw-th); translate: 0 -50%;
|
|
40
|
+
left: var(--sw-inset); right: calc(var(--sw-w) - var(--sw-inset) - var(--sw-tw));
|
|
41
|
+
border-radius: var(--vk-radius-full); background-color: var(--sw-knob); box-shadow: var(--sw-knob-shadow);
|
|
42
|
+
transition: left var(--sw-lead) var(--sw-ease), right var(--sw-trail) var(--sw-ease), background-color var(--sw-time) var(--vk-ease-out);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/* ── The other shapes on a computer. Capsule (after iOS 26), what nothing picked draws, the Outright look's pick: a wider
|
|
46
|
+
track 20 × 46 and a capsule for a thumb. Thin track: the
|
|
47
|
+
thumb, 20, larger than its 14 track, which takes the brand's pale step when on while the thumb takes the brand. Hairline
|
|
48
|
+
(after Fluent 2): an outlined, empty track 20 × 40 and a 14 thumb in the edge's grey. Classic, the kit's before these looks:
|
|
49
|
+
20 × 34, an edge when off ──────────────────────────────────────────────────────────────────────────────────────── */
|
|
50
|
+
[data-switch-shape="capsule"] .o-switch, .o-switch:not([data-switch-shape] *) {
|
|
51
|
+
--sw-h: calc(var(--vk-spacing) * 5 * var(--sw-u)); --sw-w0: calc(var(--vk-spacing) * 11.5 * var(--sw-u)); --sw-tw: calc(var(--vk-spacing) * 6.75 * var(--sw-u)); --sw-th: calc(var(--vk-spacing) * 4 * var(--sw-u)); --sw-inset: calc(var(--vk-spacing) * 0.5 * var(--sw-u));
|
|
52
|
+
--sw-rest: var(--vk-neutral); --sw-hover: var(--vk-neutral-hovered); --sw-thumb-shadow: var(--vk-shadow-sm);
|
|
53
|
+
}
|
|
54
|
+
[data-switch-shape="thin"] .o-switch {
|
|
55
|
+
--sw-h: calc(var(--vk-spacing) * 5 * var(--sw-u)); --sw-w0: calc(var(--vk-spacing) * 8.5 * var(--sw-u)); --sw-tw: calc(var(--vk-spacing) * 5 * var(--sw-u)); --sw-inset: 0px; --sw-bar: 70%;
|
|
56
|
+
--sw-on-track: var(--vk-brand-subtler); --sw-thumb-on: var(--sw-on); --sw-thumb-shadow: var(--vk-shadow-sm); --sw-glyph-on: var(--vk-fg-on-brand); --sw-ink: var(--vk-fg-accent);
|
|
57
|
+
}
|
|
58
|
+
[data-switch-shape="hairline"] .o-switch {
|
|
59
|
+
--sw-h: calc(var(--vk-spacing) * 5 * var(--sw-u)); --sw-w0: calc(var(--vk-spacing) * 10 * var(--sw-u)); --sw-tw: calc(var(--vk-spacing) * 3.5 * var(--sw-u)); --sw-inset: calc(var(--vk-spacing) * 0.75 * var(--sw-u));
|
|
60
|
+
--sw-rest: transparent; --sw-hover: transparent; --sw-edge-rest: var(--vk-border-bold); --sw-edge-hover: var(--vk-fg-subtle);
|
|
61
|
+
--sw-thumb-rest: var(--vk-fg-subtle); --sw-thumb-shadow: none; --sw-glyph-off: var(--vk-ground);
|
|
62
|
+
}
|
|
63
|
+
[data-switch-shape="classic"] .o-switch {
|
|
64
|
+
--sw-h: calc(var(--vk-spacing) * 5 * var(--sw-u)); --sw-w0: calc(var(--vk-spacing) * 8.5 * var(--sw-u)); --sw-inset: calc(var(--vk-spacing) * 0.5 * var(--sw-u));
|
|
65
|
+
--sw-rest: var(--vk-neutral); --sw-hover: var(--vk-neutral-hovered); --sw-edge-rest: var(--vk-border-input); --sw-edge-hover: var(--vk-border-input-hovered); --sw-thumb-shadow: var(--vk-shadow-sm);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/* ── Sizes: sm, four fifths of its shape, in dense rows. On a phone every switch but a small one draws the phone's shape, and
|
|
69
|
+
lg draws it anywhere: Round (after iOS 18), 31 × 51 with a 27 thumb; or Capsule (after iOS 26), what nothing picked draws, 31 × 71, its thumb 27 × 41.
|
|
70
|
+
Both on the neutral fill with no edge, whatever the computer's shape ─────────────────────────────────────────── */
|
|
71
|
+
.o-switch.o-switch-sm { --sw-u: 0.8; }
|
|
72
|
+
.o-switch.o-switch-lg {
|
|
73
|
+
--sw-h: calc(var(--vk-spacing) * 7.75); --sw-w0: calc(var(--vk-spacing) * 12.75); --sw-tw: calc(var(--vk-spacing) * 6.75); --sw-th: calc(var(--vk-spacing) * 6.75); --sw-inset: calc(var(--vk-spacing) * 0.5); --sw-bar: 100%;
|
|
74
|
+
--sw-rest: var(--vk-neutral); --sw-hover: var(--vk-neutral-hovered); --sw-edge-rest: transparent; --sw-edge-hover: transparent;
|
|
75
|
+
--sw-on-track: var(--sw-on); --sw-thumb-rest: var(--vk-fg-inverse); --sw-thumb-on: var(--vk-fg-on-brand); --sw-thumb-shadow: var(--vk-shadow-md); --sw-glyph-on: var(--sw-on); --sw-glyph-off: var(--vk-fg-subtle); --sw-ink: var(--vk-fg-on-brand);
|
|
76
|
+
}
|
|
77
|
+
[data-switch-phone="capsule"] .o-switch.o-switch-lg, .o-switch.o-switch-lg:not([data-switch-phone] *) { --sw-w0: calc(var(--vk-spacing) * 17.75); --sw-tw: calc(var(--vk-spacing) * 10.25); }
|
|
78
|
+
@media (width < 640px) {
|
|
79
|
+
.o-switch:not(.o-switch-sm):where(:not([data-computer-host], [data-computer-host] *)) {
|
|
80
|
+
--sw-h: calc(var(--vk-spacing) * 7.75); --sw-w0: calc(var(--vk-spacing) * 12.75); --sw-tw: calc(var(--vk-spacing) * 6.75); --sw-th: calc(var(--vk-spacing) * 6.75); --sw-inset: calc(var(--vk-spacing) * 0.5); --sw-bar: 100%;
|
|
81
|
+
--sw-rest: var(--vk-neutral); --sw-hover: var(--vk-neutral-hovered); --sw-edge-rest: transparent; --sw-edge-hover: transparent;
|
|
82
|
+
--sw-on-track: var(--sw-on); --sw-thumb-rest: var(--vk-fg-inverse); --sw-thumb-on: var(--vk-fg-on-brand); --sw-thumb-shadow: var(--vk-shadow-md); --sw-glyph-on: var(--sw-on); --sw-glyph-off: var(--vk-fg-subtle); --sw-ink: var(--vk-fg-on-brand);
|
|
83
|
+
}
|
|
84
|
+
[data-switch-phone="capsule"] .o-switch:not(.o-switch-sm):where(:not([data-computer-host], [data-computer-host] *)), .o-switch:not(.o-switch-sm):not([data-switch-phone] *):where(:not([data-computer-host], [data-computer-host] *)) { --sw-w0: calc(var(--vk-spacing) * 17.75); --sw-tw: calc(var(--vk-spacing) * 10.25); }
|
|
85
|
+
}
|
|
86
|
+
@container o-phone (width < 640px) {
|
|
87
|
+
.o-switch:not(.o-switch-sm) {
|
|
88
|
+
--sw-h: calc(var(--vk-spacing) * 7.75); --sw-w0: calc(var(--vk-spacing) * 12.75); --sw-tw: calc(var(--vk-spacing) * 6.75); --sw-th: calc(var(--vk-spacing) * 6.75); --sw-inset: calc(var(--vk-spacing) * 0.5); --sw-bar: 100%;
|
|
89
|
+
--sw-rest: var(--vk-neutral); --sw-hover: var(--vk-neutral-hovered); --sw-edge-rest: transparent; --sw-edge-hover: transparent;
|
|
90
|
+
--sw-on-track: var(--sw-on); --sw-thumb-rest: var(--vk-fg-inverse); --sw-thumb-on: var(--vk-fg-on-brand); --sw-thumb-shadow: var(--vk-shadow-md); --sw-glyph-on: var(--sw-on); --sw-glyph-off: var(--vk-fg-subtle); --sw-ink: var(--vk-fg-on-brand);
|
|
91
|
+
}
|
|
92
|
+
[data-switch-phone="capsule"] .o-switch:not(.o-switch-sm), .o-switch:not(.o-switch-sm):not([data-switch-phone] *) { --sw-w0: calc(var(--vk-spacing) * 17.75); --sw-tw: calc(var(--vk-spacing) * 10.25); }
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/* ── Motion. Stretch while held, the kit's until duration-base on ease-in-out, the thumb a spacing step longer toward
|
|
96
|
+
where it is going while pressed. Spring: it runs a little past and settles. Stretch as it goes: its front edge leaves first
|
|
97
|
+
and its back catches up. Colour follows: the track keeps its off paint and the brand fills in behind the thumb ─────── */
|
|
98
|
+
[data-switch-motion="held"] .o-switch { --sw-time: var(--vk-duration-base); --sw-ease: var(--vk-ease-in-out); }
|
|
99
|
+
[data-switch-motion="spring"] .o-switch { --sw-time: calc(var(--vk-duration-slow) * 1.5); --sw-ease: var(--vk-ease-spring); }
|
|
100
|
+
[data-switch-motion="stretch"] .o-switch { --sw-time: var(--vk-duration-base); --sw-ease: var(--vk-ease-in-out); --sw-lead: var(--vk-duration-fast); --sw-trail: var(--vk-duration-slow); }
|
|
101
|
+
[data-switch-motion="follow"] .o-switch { --sw-time: calc(var(--vk-duration-base) * 1.2); --sw-ease: var(--vk-ease-in-out); }
|
|
102
|
+
|
|
103
|
+
/* ── Under the pointer, on the track or its row: its shape's deeper paint; on, a deeper brand ─────────────────────────── */
|
|
104
|
+
/* A hover only on a screen with a pointer (iOS keeps :hover on what was last tapped); a press and the forced state stay out. */
|
|
105
|
+
.o-switch[data-force="hover"]:not([data-disabled]) { --sw-off: var(--sw-hover); --sw-edge: var(--sw-edge-hover); --sw-on: var(--vk-brand-hovered); }
|
|
106
|
+
@media (hover: hover) { :is(.o-switch:hover, .o-switch-row:hover .o-switch):not([data-disabled]) { --sw-off: var(--sw-hover); --sw-edge: var(--sw-edge-hover); --sw-on: var(--vk-brand-hovered); } }
|
|
107
|
+
|
|
108
|
+
/* ── On: the brand fills the track, the thumb crosses, its front edge in lead and its back in trail ───────────────────── */
|
|
109
|
+
.o-switch[data-checked] { --sw-paint: var(--sw-on-track); --sw-ring: var(--sw-on-track); }
|
|
110
|
+
.o-switch[data-checked] > .o-switch-thumb {
|
|
111
|
+
left: calc(var(--sw-w) - var(--sw-inset) - var(--sw-tw)); right: var(--sw-inset); background-color: var(--sw-knob-on);
|
|
112
|
+
transition-duration: var(--sw-trail), var(--sw-lead), var(--sw-time);
|
|
113
|
+
}
|
|
114
|
+
[data-switch-motion="held"] .o-switch:is(:active, [data-force="press"]):not([data-disabled], [data-checked]) > .o-switch-thumb { right: calc(var(--sw-w) - var(--sw-inset) - var(--sw-tw) - var(--vk-spacing) * var(--sw-u)); }
|
|
115
|
+
[data-switch-motion="held"] .o-switch[data-checked]:is(:active, [data-force="press"]):not([data-disabled]) > .o-switch-thumb { left: calc(var(--sw-w) - var(--sw-inset) - var(--sw-tw) - var(--vk-spacing) * var(--sw-u)); }
|
|
116
|
+
.o-switch-fill { display: none; }
|
|
117
|
+
[data-switch-motion="follow"] .o-switch[data-checked] { --sw-paint: var(--sw-off); --sw-ring: var(--sw-edge); }
|
|
118
|
+
[data-switch-motion="follow"] .o-switch-fill {
|
|
119
|
+
display: block; position: absolute; z-index: 0; inset: calc((100% - var(--sw-bar)) / 2) auto calc((100% - var(--sw-bar)) / 2) 0; width: var(--sw-h); border-radius: var(--vk-radius-full);
|
|
120
|
+
background-color: var(--sw-on-track); opacity: 0; transition: width var(--sw-time) var(--sw-ease), opacity var(--sw-time) var(--vk-ease-out);
|
|
121
|
+
}
|
|
122
|
+
[data-switch-motion="follow"] .o-switch[data-checked] > .o-switch-fill { width: 100%; opacity: 1; transition-duration: var(--sw-time), calc(var(--vk-duration-fast) * 0.5); }
|
|
123
|
+
|
|
124
|
+
/* ── Mark: what it holds. A tick in its thumb when on; a cross when off too; I where it is on and O where it is off, in its
|
|
125
|
+
track; or its two words there, the track a little wider for them. Each is always in the switch, shown only when picked ── */
|
|
126
|
+
.o-switch-thumb > svg { display: none; position: absolute; inset: 0; margin: auto; width: calc(var(--sw-th) * 0.68); height: calc(var(--sw-th) * 0.68); stroke-width: calc(var(--vk-spacing) * 0.45); }
|
|
127
|
+
:is([data-switch-mark="tick"], [data-switch-mark="both"]) .o-switch[data-checked] .o-switch-tick { display: block; color: var(--sw-glyph-on); }
|
|
128
|
+
[data-switch-mark="both"] .o-switch:not([data-checked]) .o-switch-cross { display: block; color: var(--sw-glyph-off); }
|
|
129
|
+
.o-switch-i, .o-switch-o, .o-switch-word { display: none; }
|
|
130
|
+
[data-switch-mark="io"] :is(.o-switch-i, .o-switch-o) { display: block; position: absolute; z-index: 1; top: 50%; box-sizing: border-box; border-radius: var(--vk-radius-full); transition: opacity var(--sw-time) var(--vk-ease-out); }
|
|
131
|
+
[data-switch-mark="io"] .o-switch-i { left: calc((var(--sw-w) - var(--sw-inset) - var(--sw-tw)) / 2); translate: -50% -50%; width: calc(var(--sw-h) * 0.08); height: calc(var(--sw-h) * 0.36); background-color: var(--sw-ink); opacity: 0; }
|
|
132
|
+
[data-switch-mark="io"] .o-switch-o { right: calc((var(--sw-w) - var(--sw-inset) - var(--sw-tw)) / 2); translate: 50% -50%; width: calc(var(--sw-h) * 0.32); height: calc(var(--sw-h) * 0.32); border: calc(var(--sw-h) * 0.07) solid var(--vk-fg-subtle); }
|
|
133
|
+
[data-switch-mark="io"] .o-switch[data-checked] > .o-switch-i { opacity: 1; }
|
|
134
|
+
[data-switch-mark="io"] .o-switch[data-checked] > .o-switch-o { opacity: 0; }
|
|
135
|
+
[data-switch-mark="words"] .o-switch { --sw-more: calc(var(--sw-h) * 0.7); }
|
|
136
|
+
[data-switch-mark="words"] .o-switch-word {
|
|
137
|
+
display: flex; position: absolute; z-index: 1; inset-block: 0; align-items: center; pointer-events: none;
|
|
138
|
+
font-size: calc(var(--sw-h) * 0.45); line-height: 1; font-weight: var(--vk-font-weight-semibold); opacity: 0; transition: opacity var(--sw-time) var(--vk-ease-out);
|
|
139
|
+
}
|
|
140
|
+
[data-switch-mark="words"] .o-switch-word[data-for="on"] { left: calc(var(--sw-h) * 0.4); color: var(--sw-ink); }
|
|
141
|
+
[data-switch-mark="words"] .o-switch-word[data-for="off"] { right: calc(var(--sw-h) * 0.35); color: var(--vk-fg-subtle); }
|
|
142
|
+
[data-switch-mark="words"] .o-switch[data-checked] > .o-switch-word[data-for="on"], [data-switch-mark="words"] .o-switch:not([data-checked]) > .o-switch-word[data-for="off"] { opacity: 1; }
|
|
143
|
+
|
|
144
|
+
/* ── What one switch is told. Saving: the Spinner in its thumb while the change is saved, and a press does nothing. Locked: it
|
|
145
|
+
can't be changed here, a lock in its thumb, which keeps its own colour so the lock reads ───────────────────────────── */
|
|
146
|
+
.o-switch-thumb > .o-spinner { position: absolute; inset: 0; margin: auto; color: var(--vk-fg-subtle); }
|
|
147
|
+
.o-switch[data-saving] { cursor: progress; }
|
|
148
|
+
.o-switch-thumb > .o-switch-lock { display: block; color: var(--vk-fg-subtle); stroke-width: calc(var(--vk-spacing) * 0.35); }
|
|
149
|
+
|
|
150
|
+
/* ── In error (aria-invalid, its Field's error, or a group in error around it): a red edge inside the track; on, the danger
|
|
151
|
+
colour fills it. The pointer never takes it away; focus rings it in red; disabled wins ─────────────────────────────── */
|
|
152
|
+
.o-switch:is([aria-invalid="true"], [data-invalid], .o-fieldset[data-invalid] *):not([data-disabled]),
|
|
153
|
+
.o-switch[data-force="hover"]:is([aria-invalid="true"], [data-invalid], .o-fieldset[data-invalid] *):not([data-disabled]) { --sw-edge: var(--vk-border-danger); --sw-on: var(--vk-danger-bold); --sw-knob-on: var(--vk-fg-inverse); }
|
|
154
|
+
@media (hover: hover) { :is(.o-switch:hover, .o-switch-row:hover .o-switch):is([aria-invalid="true"], [data-invalid], .o-fieldset[data-invalid] *):not([data-disabled]) { --sw-edge: var(--vk-border-danger); --sw-on: var(--vk-danger-bold-hovered); --sw-knob-on: var(--vk-fg-inverse); } }
|
|
155
|
+
.o-switch[data-force="hover"][data-checked]:is([aria-invalid="true"], [data-invalid], .o-fieldset[data-invalid] *):not([data-disabled]) { --sw-on: var(--vk-danger-bold-hovered); }
|
|
156
|
+
.o-switch:is(:focus-visible, [data-force="focus"]):is([aria-invalid="true"], [data-invalid], .o-fieldset[data-invalid] *) { outline-color: var(--vk-border-danger); }
|
|
157
|
+
|
|
158
|
+
/* ── Focus: the outline 2px outside the track ──────────────────────────────────────────────────────── */
|
|
159
|
+
.o-switch:is(:focus-visible, [data-force="focus"]) { outline: var(--vk-focus-width) solid var(--vk-border-brand); outline-offset: var(--vk-focus-offset); }
|
|
160
|
+
|
|
161
|
+
/* ── Disabled: off, grey with a softer edge; on, the brand's palest tint; the thumb greyed, no shadow. Locked keeps its thumb ─ */
|
|
162
|
+
.o-switch[data-disabled] {
|
|
163
|
+
--sw-off: var(--vk-neutral); --sw-edge: var(--vk-border-subtle); --sw-on: var(--vk-brand-subtler); --sw-on-track: var(--sw-on);
|
|
164
|
+
--sw-knob: var(--vk-fg-disabled); --sw-knob-on: var(--vk-fg-disabled); --sw-knob-shadow: none; cursor: not-allowed;
|
|
165
|
+
}
|
|
166
|
+
.o-switch[data-disabled][data-locked] { --sw-knob: var(--vk-fg-inverse); --sw-knob-on: var(--vk-fg-inverse); --sw-knob-shadow: var(--sw-thumb-shadow); }
|
|
167
|
+
|
|
168
|
+
@media (prefers-reduced-motion: reduce) { .o-switch::before, .o-switch-thumb, .o-switch-fill, .o-switch-i, .o-switch-o, .o-switch-word { transition: none; } }
|
|
169
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
const options = [
|
|
2
|
+
{ id: "smoothing", name: "Corner smoothing", def: "app", demo: false, values: [{ id: "app", name: "The app's" }, { id: "smooth", name: "Smooth" }, { id: "round", name: "Round" }] },
|
|
3
|
+
];
|
|
4
|
+
export const TAG_LOOKS = { id: "tag", name: "Tag", options, looks: [] };
|