cursedbelt 6.15.0 → 6.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/react/components/Slider.d.ts.map +1 -1
- package/dist/react/components/Slider.js +5 -2
- package/dist/react/components/Slider.js.map +1 -1
- package/dist/scenes.css +217 -0
- package/package.json +3 -2
- package/src/react/components/Slider.spec.tsx +19 -0
- package/src/react/components/Slider.tsx +5 -2
- package/src/scenes.css +217 -0
- package/src/scenes.spec.ts +126 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Slider.d.ts","sourceRoot":"","sources":["../../../src/react/components/Slider.tsx"],"names":[],"mappings":"AAGA,UAAU,eAAe;IACvB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,wCAAwC;IACxC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,WAAY,SAAQ,eAAe;IAClD,wBAAwB;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,uCAAuC;IACvC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,sEAAsE;IACtE,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,+EAA+E;IAC/E,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,uJAAuJ;IACvJ,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC3B;
|
|
1
|
+
{"version":3,"file":"Slider.d.ts","sourceRoot":"","sources":["../../../src/react/components/Slider.tsx"],"names":[],"mappings":"AAGA,UAAU,eAAe;IACvB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,wCAAwC;IACxC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,WAAY,SAAQ,eAAe;IAClD,wBAAwB;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,uCAAuC;IACvC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,sEAAsE;IACtE,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,+EAA+E;IAC/E,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,uJAAuJ;IACvJ,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC3B;AAYD;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,EACrB,KAAK,EACL,YAAY,EACZ,QAAQ,EACR,QAAQ,EACR,GAAO,EACP,GAAS,EACT,IAAQ,EACR,QAAQ,EACR,YAAY,EAAE,SAAS,EACvB,gBAAgB,EAAE,aAAa,EAC/B,KAAK,EACL,SAAS,EACT,GAAG,IAAI,EACR,EAAE,WAAW,+BAiCb;AAED,MAAM,WAAW,gBAAiB,SAAQ,eAAe;IACvD,mCAAmC;IACnC,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzB,sCAAsC;IACtC,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,IAAI,CAAC;IAC7C,oEAAoE;IACpE,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,IAAI,CAAC;IAC7C,+EAA+E;IAC/E,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,yEAAyE;IACzE,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAChC;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,EAC1B,KAAK,EACL,YAAY,EACZ,QAAQ,EACR,QAAQ,EACR,GAAO,EACP,GAAS,EACT,IAAQ,EACR,MAAU,EACV,QAAQ,EACR,WAAoC,EACpC,SAAS,EACT,GAAG,IAAI,EACR,EAAE,gBAAgB,+BAuBlB"}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import * as RadixSlider from '@radix-ui/react-slider';
|
|
3
3
|
import { cn } from '../lib/cn.js';
|
|
4
|
+
// The root is what takes the press (a tap anywhere on it jumps the thumb there), so it is the
|
|
5
|
+
// target the 44px touch floor measures on a coarse pointer — `py-2` alone left it 22px tall.
|
|
6
|
+
const ROOT = 'relative flex w-full touch-none select-none items-center py-2 pointer-coarse:min-h-11';
|
|
4
7
|
const TRACK = 'relative h-1.5 grow rounded-full bg-muted data-[disabled]:opacity-50';
|
|
5
8
|
const RANGE = 'absolute h-full rounded-full bg-accent-solid';
|
|
6
9
|
const THUMB = 'block size-4 rounded-full border border-border bg-background shadow-raised transition-colors ' +
|
|
@@ -13,7 +16,7 @@ const THUMB = 'block size-4 rounded-full border border-border bg-background shad
|
|
|
13
16
|
* `TrimRangeSlider`; this is the general form control.
|
|
14
17
|
*/
|
|
15
18
|
export function Slider({ value, defaultValue, onChange, onCommit, min = 0, max = 100, step = 1, disabled, 'aria-label': ariaLabel, 'aria-valuetext': ariaValueText, ticks, className, ...rest }) {
|
|
16
|
-
return (_jsxs(RadixSlider.Root, { ...rest, value: value == null ? undefined : [value], defaultValue: defaultValue == null ? undefined : [defaultValue], onValueChange: (v) => onChange?.(v[0] ?? min), onValueCommit: (v) => onCommit?.(v[0] ?? min), min: min, max: max, step: step, disabled: disabled, className: cn(
|
|
19
|
+
return (_jsxs(RadixSlider.Root, { ...rest, value: value == null ? undefined : [value], defaultValue: defaultValue == null ? undefined : [defaultValue], onValueChange: (v) => onChange?.(v[0] ?? min), onValueCommit: (v) => onCommit?.(v[0] ?? min), min: min, max: max, step: step, disabled: disabled, className: cn(ROOT, className), children: [_jsx(RadixSlider.Track, { className: TRACK, children: _jsx(RadixSlider.Range, { className: RANGE }) }), _jsx(RadixSlider.Thumb, { "aria-label": ariaLabel, "aria-valuetext": ariaValueText, className: THUMB }), ticks
|
|
17
20
|
?.filter((tick) => tick >= min && tick <= max && max > min)
|
|
18
21
|
.map((tick) => (_jsx("span", { "aria-hidden": true, "data-cb-slider-tick": '', className: 'pointer-events-none absolute bottom-0 h-1 w-px -translate-x-1/2 bg-border-strong',
|
|
19
22
|
// Radix keeps the thumb inside the track, so its centre runs from half a thumb in at `min`
|
|
@@ -27,6 +30,6 @@ export function Slider({ value, defaultValue, onChange, onCommit, min = 0, max =
|
|
|
27
30
|
*/
|
|
28
31
|
export function RangeSlider({ value, defaultValue, onChange, onCommit, min = 0, max = 100, step = 1, minGap = 0, disabled, thumbLabels = ['Minimum', 'Maximum'], className, ...rest }) {
|
|
29
32
|
const pair = (v) => [v[0] ?? min, v[1] ?? max];
|
|
30
|
-
return (_jsxs(RadixSlider.Root, { ...rest, value: value, defaultValue: defaultValue, onValueChange: (v) => onChange?.(pair(v)), onValueCommit: (v) => onCommit?.(pair(v)), min: min, max: max, step: step, minStepsBetweenThumbs: step > 0 ? Math.ceil(minGap / step) : 0, disabled: disabled, className: cn(
|
|
33
|
+
return (_jsxs(RadixSlider.Root, { ...rest, value: value, defaultValue: defaultValue, onValueChange: (v) => onChange?.(pair(v)), onValueCommit: (v) => onCommit?.(pair(v)), min: min, max: max, step: step, minStepsBetweenThumbs: step > 0 ? Math.ceil(minGap / step) : 0, disabled: disabled, className: cn(ROOT, className), children: [_jsx(RadixSlider.Track, { className: TRACK, children: _jsx(RadixSlider.Range, { className: RANGE }) }), _jsx(RadixSlider.Thumb, { "aria-label": thumbLabels[0], className: THUMB }), _jsx(RadixSlider.Thumb, { "aria-label": thumbLabels[1], className: THUMB })] }));
|
|
31
34
|
}
|
|
32
35
|
//# sourceMappingURL=Slider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Slider.js","sourceRoot":"","sources":["../../../src/react/components/Slider.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,WAAW,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AA0BlC,MAAM,KAAK,GAAG,sEAAsE,CAAC;AACrF,MAAM,KAAK,GAAG,8CAA8C,CAAC;AAC7D,MAAM,KAAK,GACT,+FAA+F;IAC/F,8FAA8F;IAC9F,2DAA2D,CAAC;AAE9D;;;;;GAKG;AACH,MAAM,UAAU,MAAM,CAAC,EACrB,KAAK,EACL,YAAY,EACZ,QAAQ,EACR,QAAQ,EACR,GAAG,GAAG,CAAC,EACP,GAAG,GAAG,GAAG,EACT,IAAI,GAAG,CAAC,EACR,QAAQ,EACR,YAAY,EAAE,SAAS,EACvB,gBAAgB,EAAE,aAAa,EAC/B,KAAK,EACL,SAAS,EACT,GAAG,IAAI,EACK;IACZ,OAAO,CACL,MAAC,WAAW,CAAC,IAAI,OACX,IAAI,EACR,KAAK,EAAE,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,EAC1C,YAAY,EAAE,YAAY,IAAI,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,EAC/D,aAAa,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,EAC7C,aAAa,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,EAC7C,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,GAAG,EACR,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,EAAE,CAAC
|
|
1
|
+
{"version":3,"file":"Slider.js","sourceRoot":"","sources":["../../../src/react/components/Slider.tsx"],"names":[],"mappings":"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"}
|
package/dist/scenes.css
ADDED
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* SCENES — theme scopes for a game board, a canvas, a hero: the region a scene is put on wears it,
|
|
3
|
+
* and the page around it keeps the reader's look. A scene is the same kind of scope as a look
|
|
4
|
+
* (`looks.css`): a class that re-binds the semantic tokens every component and painter already
|
|
5
|
+
* reads, so nothing downstream takes a variant prop. Where it differs is the one thing a look may
|
|
6
|
+
* not touch: a scene re-binds the ACCENT too, because the accent is half of its identity.
|
|
7
|
+
*
|
|
8
|
+
* @import "cursedbelt/theme.css";
|
|
9
|
+
* @import "cursedbelt/scenes.css";
|
|
10
|
+
*
|
|
11
|
+
* <div class="cb-synthwave">…</div> never on <html>: a scene is a region's, not the app's
|
|
12
|
+
*
|
|
13
|
+
* ── The contract every scene keeps (`src/scenes.spec.ts` holds it) ───────────────────────────
|
|
14
|
+
* · Both schemes: a light block and a dark one (`.cb-<scene>.dark, .dark .cb-<scene>`), so a scene
|
|
15
|
+
* follows the reader's scheme from any `.dark` ancestor.
|
|
16
|
+
* · Every token `.cb-aurora` re-binds, plus the five accent tokens AND every alias theme.css derives
|
|
17
|
+
* from them (`--primary`, `--ring`, `--on-accent` …): `var()` is substituted where a property is
|
|
18
|
+
* declared, so an alias left to `:root` would keep the app's accent inside the scene.
|
|
19
|
+
* · The looks' floors — text 4.5:1 on every surface, border-strong 3:1 on the card, the hairline
|
|
20
|
+
* 1.3–1.6:1 — and two of its own: the accent clears 3:1 on the card and on the sunken surface (a
|
|
21
|
+
* board's field), and the solid accent's foreground clears 4.5:1 on it.
|
|
22
|
+
*
|
|
23
|
+
* ── The two ────────────────────────────────────────────────────────────────────────────────────
|
|
24
|
+
* steampunk Brass and copper on parchment; by night, brass on oiled walnut. Inertia's July theme.
|
|
25
|
+
* synthwave Magenta on lilac; by night, neon pink on a deep indigo grid. Inertia's July theme.
|
|
26
|
+
*
|
|
27
|
+
* Every literal below is a scene's token definition — the one place a color may be spelled.
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
/* ────────────────────────────── steampunk ────────────────────────────── */
|
|
31
|
+
.cb-steampunk {
|
|
32
|
+
--background: #f2e8d5; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
33
|
+
--foreground: #2b1d0e; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
34
|
+
--surface: #faf4e7; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
35
|
+
--card: #faf4e7; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
36
|
+
--card-foreground: #2b1d0e; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
37
|
+
--card-raised: #efe3c9; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
38
|
+
--card-overlay: #fffaf0; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
39
|
+
--popover: #fffaf0; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
40
|
+
--popover-foreground: #2b1d0e; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
41
|
+
--muted: #ebdec3; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
42
|
+
--muted-foreground: #5a4630; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
43
|
+
--surface-sunken: #e9dbbd; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
44
|
+
--border: #d9c8a4; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
45
|
+
--border-strong: #8a7350; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
46
|
+
--accent: #93531a; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
47
|
+
--accent-hover: #74400f; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
48
|
+
--accent-solid: #8a4c15; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
49
|
+
--accent-solid-hover: #a05a1a; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
50
|
+
--accent-solid-foreground: #ffffff; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
51
|
+
--rule: color-mix(in srgb, var(--border) 55%, transparent);
|
|
52
|
+
--shadow-raised: 0 1px 2px rgb(43 29 14 / 0.08); /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
53
|
+
--shadow-overlay: 0 6px 24px -6px rgb(43 29 14 / 0.18), 0 2px 8px -2px rgb(43 29 14 / 0.1); /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
54
|
+
--shadow-popover: 0 24px 64px -16px rgb(43 29 14 / 0.3), 0 8px 24px -8px rgb(43 29 14 / 0.14); /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
55
|
+
--glass-bg: color-mix(in srgb, var(--card) 88%, transparent);
|
|
56
|
+
--glass-bg-strong: color-mix(in srgb, var(--card) 96%, transparent);
|
|
57
|
+
--glass-edge: var(--border);
|
|
58
|
+
--glass-shadow: var(--shadow-overlay);
|
|
59
|
+
--ambient-strength: 0;
|
|
60
|
+
/* The accent's aliases, re-run here: `var()` substitutes where a property is declared (theme.css, .cb-aurora). */
|
|
61
|
+
--accent-strong: var(--accent-hover);
|
|
62
|
+
--accent-9: var(--accent);
|
|
63
|
+
--on-accent: var(--accent-solid-foreground);
|
|
64
|
+
--primary: var(--accent-solid);
|
|
65
|
+
--primary-foreground: var(--accent-solid-foreground);
|
|
66
|
+
--progress: var(--accent-solid);
|
|
67
|
+
--ring: var(--accent);
|
|
68
|
+
--chart-1: var(--accent);
|
|
69
|
+
--field-bg: var(--surface);
|
|
70
|
+
--field-bg-solid: var(--surface);
|
|
71
|
+
--field-border: var(--border-strong);
|
|
72
|
+
--field-fg: var(--foreground);
|
|
73
|
+
--field-placeholder: var(--muted-foreground);
|
|
74
|
+
--field-ring: var(--ring);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.cb-steampunk.dark,
|
|
78
|
+
.dark .cb-steampunk {
|
|
79
|
+
--background: #16100a; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
80
|
+
--foreground: #f1e4c8; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
81
|
+
--surface: #201810; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
82
|
+
--card: #201810; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
83
|
+
--card-foreground: #f1e4c8; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
84
|
+
--card-raised: #2a2016; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
85
|
+
--card-overlay: #34291c; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
86
|
+
--popover: #2a2016; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
87
|
+
--popover-foreground: #f1e4c8; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
88
|
+
--muted: #2d2318; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
89
|
+
--muted-foreground: #c2ab84; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
90
|
+
--surface-sunken: #110c07; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
91
|
+
--border: #3d301e; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
92
|
+
--border-strong: #7f6a47; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
93
|
+
--accent: #d9a441; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
94
|
+
--accent-hover: #e8bd66; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
95
|
+
--accent-solid: #875812; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
96
|
+
--accent-solid-hover: #9a6516; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
97
|
+
--accent-solid-foreground: #ffffff; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
98
|
+
--rule: color-mix(in srgb, var(--border) 55%, transparent);
|
|
99
|
+
--shadow-raised: 0 1px 2px rgb(0 0 0 / 0.4); /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
100
|
+
--shadow-overlay: 0 6px 24px -6px rgb(0 0 0 / 0.55), 0 2px 8px -2px rgb(0 0 0 / 0.4); /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
101
|
+
--shadow-popover: 0 24px 64px -16px rgb(0 0 0 / 0.75), 0 8px 24px -8px rgb(0 0 0 / 0.5); /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
102
|
+
--glass-bg: color-mix(in srgb, var(--card) 88%, transparent);
|
|
103
|
+
--glass-bg-strong: color-mix(in srgb, var(--card) 96%, transparent);
|
|
104
|
+
--glass-edge: var(--border);
|
|
105
|
+
--glass-shadow: var(--shadow-overlay);
|
|
106
|
+
--ambient-strength: 0;
|
|
107
|
+
/* The accent's aliases, re-run here: `var()` substitutes where a property is declared (theme.css, .cb-aurora). */
|
|
108
|
+
--accent-strong: var(--accent);
|
|
109
|
+
--accent-9: var(--accent);
|
|
110
|
+
--on-accent: var(--accent-solid-foreground);
|
|
111
|
+
--primary: var(--accent-solid);
|
|
112
|
+
--primary-foreground: var(--accent-solid-foreground);
|
|
113
|
+
--progress: var(--accent-solid);
|
|
114
|
+
--ring: var(--accent);
|
|
115
|
+
--chart-1: var(--accent);
|
|
116
|
+
--field-bg: color-mix(in srgb, var(--foreground) 4%, transparent);
|
|
117
|
+
--field-bg-solid: var(--popover);
|
|
118
|
+
--field-border: var(--border-strong);
|
|
119
|
+
--field-fg: var(--foreground);
|
|
120
|
+
--field-placeholder: var(--muted-foreground);
|
|
121
|
+
--field-ring: var(--ring);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/* ────────────────────────────── synthwave ────────────────────────────── */
|
|
125
|
+
.cb-synthwave {
|
|
126
|
+
--background: #f6f0fb; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
127
|
+
--foreground: #22123a; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
128
|
+
--surface: #fdfaff; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
129
|
+
--card: #fdfaff; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
130
|
+
--card-foreground: #22123a; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
131
|
+
--card-raised: #f0e6f8; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
132
|
+
--card-overlay: #ffffff; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
133
|
+
--popover: #ffffff; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
134
|
+
--popover-foreground: #22123a; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
135
|
+
--muted: #eee3f7; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
136
|
+
--muted-foreground: #5a4470; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
137
|
+
--surface-sunken: #ede1f7; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
138
|
+
--border: #ddcdeb; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
139
|
+
--border-strong: #8e74a6; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
140
|
+
--accent: #b8117a; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
141
|
+
--accent-hover: #940c62; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
142
|
+
--accent-solid: #ad1072; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
143
|
+
--accent-solid-hover: #c21a82; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
144
|
+
--accent-solid-foreground: #ffffff; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
145
|
+
--rule: color-mix(in srgb, var(--border) 55%, transparent);
|
|
146
|
+
--shadow-raised: 0 1px 2px rgb(34 18 58 / 0.08); /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
147
|
+
--shadow-overlay: 0 6px 24px -6px rgb(34 18 58 / 0.18), 0 2px 8px -2px rgb(34 18 58 / 0.1); /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
148
|
+
--shadow-popover: 0 24px 64px -16px rgb(34 18 58 / 0.3), 0 8px 24px -8px rgb(34 18 58 / 0.14); /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
149
|
+
--glass-bg: color-mix(in srgb, var(--card) 88%, transparent);
|
|
150
|
+
--glass-bg-strong: color-mix(in srgb, var(--card) 96%, transparent);
|
|
151
|
+
--glass-edge: var(--border);
|
|
152
|
+
--glass-shadow: var(--shadow-overlay);
|
|
153
|
+
--ambient-strength: 0;
|
|
154
|
+
/* The accent's aliases, re-run here: `var()` substitutes where a property is declared (theme.css, .cb-aurora). */
|
|
155
|
+
--accent-strong: var(--accent-hover);
|
|
156
|
+
--accent-9: var(--accent);
|
|
157
|
+
--on-accent: var(--accent-solid-foreground);
|
|
158
|
+
--primary: var(--accent-solid);
|
|
159
|
+
--primary-foreground: var(--accent-solid-foreground);
|
|
160
|
+
--progress: var(--accent-solid);
|
|
161
|
+
--ring: var(--accent);
|
|
162
|
+
--chart-1: var(--accent);
|
|
163
|
+
--field-bg: var(--surface);
|
|
164
|
+
--field-bg-solid: var(--surface);
|
|
165
|
+
--field-border: var(--border-strong);
|
|
166
|
+
--field-fg: var(--foreground);
|
|
167
|
+
--field-placeholder: var(--muted-foreground);
|
|
168
|
+
--field-ring: var(--ring);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
.cb-synthwave.dark,
|
|
172
|
+
.dark .cb-synthwave {
|
|
173
|
+
--background: #0e0a1d; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
174
|
+
--foreground: #f5ecff; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
175
|
+
--surface: #160f2b; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
176
|
+
--card: #160f2b; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
177
|
+
--card-foreground: #f5ecff; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
178
|
+
--card-raised: #1f1639; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
179
|
+
--card-overlay: #291d47; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
180
|
+
--popover: #1f1639; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
181
|
+
--popover-foreground: #f5ecff; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
182
|
+
--muted: #221842; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
183
|
+
--muted-foreground: #b4a4d8; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
184
|
+
--surface-sunken: #090615; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
185
|
+
--border: #2f2353; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
186
|
+
--border-strong: #6e5aa2; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
187
|
+
--accent: #ff4fb8; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
188
|
+
--accent-hover: #ff80cc; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
189
|
+
--accent-solid: #b3177a; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
190
|
+
--accent-solid-hover: #c7208a; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
191
|
+
--accent-solid-foreground: #ffffff; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
192
|
+
--rule: color-mix(in srgb, var(--border) 55%, transparent);
|
|
193
|
+
--shadow-raised: 0 1px 2px rgb(0 0 0 / 0.4); /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
194
|
+
--shadow-overlay: 0 6px 24px -6px rgb(0 0 0 / 0.55), 0 2px 8px -2px rgb(0 0 0 / 0.4); /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
195
|
+
--shadow-popover: 0 24px 64px -16px rgb(0 0 0 / 0.75), 0 8px 24px -8px rgb(0 0 0 / 0.5); /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
196
|
+
--glass-bg: color-mix(in srgb, var(--card) 88%, transparent);
|
|
197
|
+
--glass-bg-strong: color-mix(in srgb, var(--card) 96%, transparent);
|
|
198
|
+
--glass-edge: var(--border);
|
|
199
|
+
--glass-shadow: var(--shadow-overlay);
|
|
200
|
+
--ambient-strength: 0;
|
|
201
|
+
/* The accent's aliases, re-run here: `var()` substitutes where a property is declared (theme.css, .cb-aurora). */
|
|
202
|
+
--accent-strong: var(--accent);
|
|
203
|
+
--accent-9: var(--accent);
|
|
204
|
+
--on-accent: var(--accent-solid-foreground);
|
|
205
|
+
--primary: var(--accent-solid);
|
|
206
|
+
--primary-foreground: var(--accent-solid-foreground);
|
|
207
|
+
--progress: var(--accent-solid);
|
|
208
|
+
--ring: var(--accent);
|
|
209
|
+
--chart-1: var(--accent);
|
|
210
|
+
--field-bg: color-mix(in srgb, var(--foreground) 4%, transparent);
|
|
211
|
+
--field-bg-solid: var(--popover);
|
|
212
|
+
--field-border: var(--border-strong);
|
|
213
|
+
--field-fg: var(--foreground);
|
|
214
|
+
--field-placeholder: var(--muted-foreground);
|
|
215
|
+
--field-ring: var(--ring);
|
|
216
|
+
}
|
|
217
|
+
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cursedbelt",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.16.0",
|
|
4
4
|
"license": "ISC",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "The React design system of the cursedbelt split — components, styles, theme. cursedbelt-core below it; server tier in cursedbelt-server.",
|
|
@@ -752,6 +752,7 @@
|
|
|
752
752
|
},
|
|
753
753
|
"./theme.css": "./src/theme.css",
|
|
754
754
|
"./looks.css": "./src/looks.css",
|
|
755
|
+
"./scenes.css": "./src/scenes.css",
|
|
755
756
|
"./workspace.css": "./src/workspace.css"
|
|
756
757
|
},
|
|
757
758
|
"files": [
|
|
@@ -984,7 +985,7 @@
|
|
|
984
985
|
"@vidstack/react": "1.15.6",
|
|
985
986
|
"@vitejs/plugin-react": "^5.2.0",
|
|
986
987
|
"cursedbelt-server": "^4.76.0",
|
|
987
|
-
"cursedops": "^0.
|
|
988
|
+
"cursedops": "^0.36.1",
|
|
988
989
|
"diff": "^9.0.0",
|
|
989
990
|
"emoji-mart": "^5.6.0",
|
|
990
991
|
"hls.js": "^1.5.0",
|
|
@@ -72,3 +72,22 @@ describe('RangeSlider', () => {
|
|
|
72
72
|
expect(pair).toEqual([21, 60]);
|
|
73
73
|
});
|
|
74
74
|
});
|
|
75
|
+
|
|
76
|
+
// The thumb is 16–20px; the ROOT takes the press, so the 44px coarse-pointer floor belongs on it.
|
|
77
|
+
// Measured on games' Drift settings at Pixel 7: the root drew 274×22 before this (forge task 5563).
|
|
78
|
+
describe('the coarse-pointer touch floor', () => {
|
|
79
|
+
test('is on the root both sliders press through, not on the thumb', () => {
|
|
80
|
+
const { getAllByRole } = render(
|
|
81
|
+
<>
|
|
82
|
+
<Slider value={30} onChange={() => {}} aria-label='Volume' />
|
|
83
|
+
<RangeSlider value={[20, 60]} onChange={() => {}} aria-label='Range' />
|
|
84
|
+
</>,
|
|
85
|
+
);
|
|
86
|
+
for (const thumb of getAllByRole('slider')) {
|
|
87
|
+
expect(thumb.getAttribute('class') ?? '').not.toContain('pointer-coarse:min-h-11');
|
|
88
|
+
// The track is the thumb's sibling, so the nearest oriented ancestor is the Radix root.
|
|
89
|
+
const root = thumb.parentElement?.closest('[data-orientation]');
|
|
90
|
+
expect(root?.getAttribute('class') ?? '').toContain('pointer-coarse:min-h-11');
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
});
|
|
@@ -25,6 +25,9 @@ export interface SliderProps extends SliderBaseProps {
|
|
|
25
25
|
ticks?: readonly number[];
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
// The root is what takes the press (a tap anywhere on it jumps the thumb there), so it is the
|
|
29
|
+
// target the 44px touch floor measures on a coarse pointer — `py-2` alone left it 22px tall.
|
|
30
|
+
const ROOT = 'relative flex w-full touch-none select-none items-center py-2 pointer-coarse:min-h-11';
|
|
28
31
|
const TRACK = 'relative h-1.5 grow rounded-full bg-muted data-[disabled]:opacity-50';
|
|
29
32
|
const RANGE = 'absolute h-full rounded-full bg-accent-solid';
|
|
30
33
|
const THUMB =
|
|
@@ -64,7 +67,7 @@ export function Slider({
|
|
|
64
67
|
max={max}
|
|
65
68
|
step={step}
|
|
66
69
|
disabled={disabled}
|
|
67
|
-
className={cn(
|
|
70
|
+
className={cn(ROOT, className)}
|
|
68
71
|
>
|
|
69
72
|
<RadixSlider.Track className={TRACK}>
|
|
70
73
|
<RadixSlider.Range className={RANGE} />
|
|
@@ -133,7 +136,7 @@ export function RangeSlider({
|
|
|
133
136
|
step={step}
|
|
134
137
|
minStepsBetweenThumbs={step > 0 ? Math.ceil(minGap / step) : 0}
|
|
135
138
|
disabled={disabled}
|
|
136
|
-
className={cn(
|
|
139
|
+
className={cn(ROOT, className)}
|
|
137
140
|
>
|
|
138
141
|
<RadixSlider.Track className={TRACK}>
|
|
139
142
|
<RadixSlider.Range className={RANGE} />
|
package/src/scenes.css
ADDED
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* SCENES — theme scopes for a game board, a canvas, a hero: the region a scene is put on wears it,
|
|
3
|
+
* and the page around it keeps the reader's look. A scene is the same kind of scope as a look
|
|
4
|
+
* (`looks.css`): a class that re-binds the semantic tokens every component and painter already
|
|
5
|
+
* reads, so nothing downstream takes a variant prop. Where it differs is the one thing a look may
|
|
6
|
+
* not touch: a scene re-binds the ACCENT too, because the accent is half of its identity.
|
|
7
|
+
*
|
|
8
|
+
* @import "cursedbelt/theme.css";
|
|
9
|
+
* @import "cursedbelt/scenes.css";
|
|
10
|
+
*
|
|
11
|
+
* <div class="cb-synthwave">…</div> never on <html>: a scene is a region's, not the app's
|
|
12
|
+
*
|
|
13
|
+
* ── The contract every scene keeps (`src/scenes.spec.ts` holds it) ───────────────────────────
|
|
14
|
+
* · Both schemes: a light block and a dark one (`.cb-<scene>.dark, .dark .cb-<scene>`), so a scene
|
|
15
|
+
* follows the reader's scheme from any `.dark` ancestor.
|
|
16
|
+
* · Every token `.cb-aurora` re-binds, plus the five accent tokens AND every alias theme.css derives
|
|
17
|
+
* from them (`--primary`, `--ring`, `--on-accent` …): `var()` is substituted where a property is
|
|
18
|
+
* declared, so an alias left to `:root` would keep the app's accent inside the scene.
|
|
19
|
+
* · The looks' floors — text 4.5:1 on every surface, border-strong 3:1 on the card, the hairline
|
|
20
|
+
* 1.3–1.6:1 — and two of its own: the accent clears 3:1 on the card and on the sunken surface (a
|
|
21
|
+
* board's field), and the solid accent's foreground clears 4.5:1 on it.
|
|
22
|
+
*
|
|
23
|
+
* ── The two ────────────────────────────────────────────────────────────────────────────────────
|
|
24
|
+
* steampunk Brass and copper on parchment; by night, brass on oiled walnut. Inertia's July theme.
|
|
25
|
+
* synthwave Magenta on lilac; by night, neon pink on a deep indigo grid. Inertia's July theme.
|
|
26
|
+
*
|
|
27
|
+
* Every literal below is a scene's token definition — the one place a color may be spelled.
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
/* ────────────────────────────── steampunk ────────────────────────────── */
|
|
31
|
+
.cb-steampunk {
|
|
32
|
+
--background: #f2e8d5; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
33
|
+
--foreground: #2b1d0e; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
34
|
+
--surface: #faf4e7; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
35
|
+
--card: #faf4e7; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
36
|
+
--card-foreground: #2b1d0e; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
37
|
+
--card-raised: #efe3c9; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
38
|
+
--card-overlay: #fffaf0; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
39
|
+
--popover: #fffaf0; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
40
|
+
--popover-foreground: #2b1d0e; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
41
|
+
--muted: #ebdec3; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
42
|
+
--muted-foreground: #5a4630; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
43
|
+
--surface-sunken: #e9dbbd; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
44
|
+
--border: #d9c8a4; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
45
|
+
--border-strong: #8a7350; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
46
|
+
--accent: #93531a; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
47
|
+
--accent-hover: #74400f; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
48
|
+
--accent-solid: #8a4c15; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
49
|
+
--accent-solid-hover: #a05a1a; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
50
|
+
--accent-solid-foreground: #ffffff; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
51
|
+
--rule: color-mix(in srgb, var(--border) 55%, transparent);
|
|
52
|
+
--shadow-raised: 0 1px 2px rgb(43 29 14 / 0.08); /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
53
|
+
--shadow-overlay: 0 6px 24px -6px rgb(43 29 14 / 0.18), 0 2px 8px -2px rgb(43 29 14 / 0.1); /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
54
|
+
--shadow-popover: 0 24px 64px -16px rgb(43 29 14 / 0.3), 0 8px 24px -8px rgb(43 29 14 / 0.14); /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
55
|
+
--glass-bg: color-mix(in srgb, var(--card) 88%, transparent);
|
|
56
|
+
--glass-bg-strong: color-mix(in srgb, var(--card) 96%, transparent);
|
|
57
|
+
--glass-edge: var(--border);
|
|
58
|
+
--glass-shadow: var(--shadow-overlay);
|
|
59
|
+
--ambient-strength: 0;
|
|
60
|
+
/* The accent's aliases, re-run here: `var()` substitutes where a property is declared (theme.css, .cb-aurora). */
|
|
61
|
+
--accent-strong: var(--accent-hover);
|
|
62
|
+
--accent-9: var(--accent);
|
|
63
|
+
--on-accent: var(--accent-solid-foreground);
|
|
64
|
+
--primary: var(--accent-solid);
|
|
65
|
+
--primary-foreground: var(--accent-solid-foreground);
|
|
66
|
+
--progress: var(--accent-solid);
|
|
67
|
+
--ring: var(--accent);
|
|
68
|
+
--chart-1: var(--accent);
|
|
69
|
+
--field-bg: var(--surface);
|
|
70
|
+
--field-bg-solid: var(--surface);
|
|
71
|
+
--field-border: var(--border-strong);
|
|
72
|
+
--field-fg: var(--foreground);
|
|
73
|
+
--field-placeholder: var(--muted-foreground);
|
|
74
|
+
--field-ring: var(--ring);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.cb-steampunk.dark,
|
|
78
|
+
.dark .cb-steampunk {
|
|
79
|
+
--background: #16100a; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
80
|
+
--foreground: #f1e4c8; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
81
|
+
--surface: #201810; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
82
|
+
--card: #201810; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
83
|
+
--card-foreground: #f1e4c8; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
84
|
+
--card-raised: #2a2016; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
85
|
+
--card-overlay: #34291c; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
86
|
+
--popover: #2a2016; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
87
|
+
--popover-foreground: #f1e4c8; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
88
|
+
--muted: #2d2318; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
89
|
+
--muted-foreground: #c2ab84; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
90
|
+
--surface-sunken: #110c07; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
91
|
+
--border: #3d301e; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
92
|
+
--border-strong: #7f6a47; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
93
|
+
--accent: #d9a441; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
94
|
+
--accent-hover: #e8bd66; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
95
|
+
--accent-solid: #875812; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
96
|
+
--accent-solid-hover: #9a6516; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
97
|
+
--accent-solid-foreground: #ffffff; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
98
|
+
--rule: color-mix(in srgb, var(--border) 55%, transparent);
|
|
99
|
+
--shadow-raised: 0 1px 2px rgb(0 0 0 / 0.4); /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
100
|
+
--shadow-overlay: 0 6px 24px -6px rgb(0 0 0 / 0.55), 0 2px 8px -2px rgb(0 0 0 / 0.4); /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
101
|
+
--shadow-popover: 0 24px 64px -16px rgb(0 0 0 / 0.75), 0 8px 24px -8px rgb(0 0 0 / 0.5); /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
102
|
+
--glass-bg: color-mix(in srgb, var(--card) 88%, transparent);
|
|
103
|
+
--glass-bg-strong: color-mix(in srgb, var(--card) 96%, transparent);
|
|
104
|
+
--glass-edge: var(--border);
|
|
105
|
+
--glass-shadow: var(--shadow-overlay);
|
|
106
|
+
--ambient-strength: 0;
|
|
107
|
+
/* The accent's aliases, re-run here: `var()` substitutes where a property is declared (theme.css, .cb-aurora). */
|
|
108
|
+
--accent-strong: var(--accent);
|
|
109
|
+
--accent-9: var(--accent);
|
|
110
|
+
--on-accent: var(--accent-solid-foreground);
|
|
111
|
+
--primary: var(--accent-solid);
|
|
112
|
+
--primary-foreground: var(--accent-solid-foreground);
|
|
113
|
+
--progress: var(--accent-solid);
|
|
114
|
+
--ring: var(--accent);
|
|
115
|
+
--chart-1: var(--accent);
|
|
116
|
+
--field-bg: color-mix(in srgb, var(--foreground) 4%, transparent);
|
|
117
|
+
--field-bg-solid: var(--popover);
|
|
118
|
+
--field-border: var(--border-strong);
|
|
119
|
+
--field-fg: var(--foreground);
|
|
120
|
+
--field-placeholder: var(--muted-foreground);
|
|
121
|
+
--field-ring: var(--ring);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/* ────────────────────────────── synthwave ────────────────────────────── */
|
|
125
|
+
.cb-synthwave {
|
|
126
|
+
--background: #f6f0fb; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
127
|
+
--foreground: #22123a; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
128
|
+
--surface: #fdfaff; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
129
|
+
--card: #fdfaff; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
130
|
+
--card-foreground: #22123a; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
131
|
+
--card-raised: #f0e6f8; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
132
|
+
--card-overlay: #ffffff; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
133
|
+
--popover: #ffffff; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
134
|
+
--popover-foreground: #22123a; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
135
|
+
--muted: #eee3f7; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
136
|
+
--muted-foreground: #5a4470; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
137
|
+
--surface-sunken: #ede1f7; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
138
|
+
--border: #ddcdeb; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
139
|
+
--border-strong: #8e74a6; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
140
|
+
--accent: #b8117a; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
141
|
+
--accent-hover: #940c62; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
142
|
+
--accent-solid: #ad1072; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
143
|
+
--accent-solid-hover: #c21a82; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
144
|
+
--accent-solid-foreground: #ffffff; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
145
|
+
--rule: color-mix(in srgb, var(--border) 55%, transparent);
|
|
146
|
+
--shadow-raised: 0 1px 2px rgb(34 18 58 / 0.08); /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
147
|
+
--shadow-overlay: 0 6px 24px -6px rgb(34 18 58 / 0.18), 0 2px 8px -2px rgb(34 18 58 / 0.1); /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
148
|
+
--shadow-popover: 0 24px 64px -16px rgb(34 18 58 / 0.3), 0 8px 24px -8px rgb(34 18 58 / 0.14); /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
149
|
+
--glass-bg: color-mix(in srgb, var(--card) 88%, transparent);
|
|
150
|
+
--glass-bg-strong: color-mix(in srgb, var(--card) 96%, transparent);
|
|
151
|
+
--glass-edge: var(--border);
|
|
152
|
+
--glass-shadow: var(--shadow-overlay);
|
|
153
|
+
--ambient-strength: 0;
|
|
154
|
+
/* The accent's aliases, re-run here: `var()` substitutes where a property is declared (theme.css, .cb-aurora). */
|
|
155
|
+
--accent-strong: var(--accent-hover);
|
|
156
|
+
--accent-9: var(--accent);
|
|
157
|
+
--on-accent: var(--accent-solid-foreground);
|
|
158
|
+
--primary: var(--accent-solid);
|
|
159
|
+
--primary-foreground: var(--accent-solid-foreground);
|
|
160
|
+
--progress: var(--accent-solid);
|
|
161
|
+
--ring: var(--accent);
|
|
162
|
+
--chart-1: var(--accent);
|
|
163
|
+
--field-bg: var(--surface);
|
|
164
|
+
--field-bg-solid: var(--surface);
|
|
165
|
+
--field-border: var(--border-strong);
|
|
166
|
+
--field-fg: var(--foreground);
|
|
167
|
+
--field-placeholder: var(--muted-foreground);
|
|
168
|
+
--field-ring: var(--ring);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
.cb-synthwave.dark,
|
|
172
|
+
.dark .cb-synthwave {
|
|
173
|
+
--background: #0e0a1d; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
174
|
+
--foreground: #f5ecff; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
175
|
+
--surface: #160f2b; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
176
|
+
--card: #160f2b; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
177
|
+
--card-foreground: #f5ecff; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
178
|
+
--card-raised: #1f1639; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
179
|
+
--card-overlay: #291d47; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
180
|
+
--popover: #1f1639; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
181
|
+
--popover-foreground: #f5ecff; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
182
|
+
--muted: #221842; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
183
|
+
--muted-foreground: #b4a4d8; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
184
|
+
--surface-sunken: #090615; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
185
|
+
--border: #2f2353; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
186
|
+
--border-strong: #6e5aa2; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
187
|
+
--accent: #ff4fb8; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
188
|
+
--accent-hover: #ff80cc; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
189
|
+
--accent-solid: #b3177a; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
190
|
+
--accent-solid-hover: #c7208a; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
191
|
+
--accent-solid-foreground: #ffffff; /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
192
|
+
--rule: color-mix(in srgb, var(--border) 55%, transparent);
|
|
193
|
+
--shadow-raised: 0 1px 2px rgb(0 0 0 / 0.4); /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
194
|
+
--shadow-overlay: 0 6px 24px -6px rgb(0 0 0 / 0.55), 0 2px 8px -2px rgb(0 0 0 / 0.4); /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
195
|
+
--shadow-popover: 0 24px 64px -16px rgb(0 0 0 / 0.75), 0 8px 24px -8px rgb(0 0 0 / 0.5); /* guardrails-ignore no-hardcoded-colors: a scene's token definition */
|
|
196
|
+
--glass-bg: color-mix(in srgb, var(--card) 88%, transparent);
|
|
197
|
+
--glass-bg-strong: color-mix(in srgb, var(--card) 96%, transparent);
|
|
198
|
+
--glass-edge: var(--border);
|
|
199
|
+
--glass-shadow: var(--shadow-overlay);
|
|
200
|
+
--ambient-strength: 0;
|
|
201
|
+
/* The accent's aliases, re-run here: `var()` substitutes where a property is declared (theme.css, .cb-aurora). */
|
|
202
|
+
--accent-strong: var(--accent);
|
|
203
|
+
--accent-9: var(--accent);
|
|
204
|
+
--on-accent: var(--accent-solid-foreground);
|
|
205
|
+
--primary: var(--accent-solid);
|
|
206
|
+
--primary-foreground: var(--accent-solid-foreground);
|
|
207
|
+
--progress: var(--accent-solid);
|
|
208
|
+
--ring: var(--accent);
|
|
209
|
+
--chart-1: var(--accent);
|
|
210
|
+
--field-bg: color-mix(in srgb, var(--foreground) 4%, transparent);
|
|
211
|
+
--field-bg-solid: var(--popover);
|
|
212
|
+
--field-border: var(--border-strong);
|
|
213
|
+
--field-fg: var(--foreground);
|
|
214
|
+
--field-placeholder: var(--muted-foreground);
|
|
215
|
+
--field-ring: var(--ring);
|
|
216
|
+
}
|
|
217
|
+
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `scenes.css` keeps the contract its header states (forge task 5572).
|
|
3
|
+
*
|
|
4
|
+
* A scene is a block of forty declarations that must agree with `.cb-aurora`'s token for token AND
|
|
5
|
+
* re-run every alias theme.css derives from the accent; forget one and the app's accent shows
|
|
6
|
+
* through inside the scene (a `--primary` button in emerald on a brass board), and nothing fails.
|
|
7
|
+
* The colors are contrast claims a screenshot of one scheme cannot prove. A machine decides both.
|
|
8
|
+
*/
|
|
9
|
+
import { describe, expect, test } from 'bun:test';
|
|
10
|
+
import { readFileSync } from 'node:fs';
|
|
11
|
+
import { join } from 'node:path';
|
|
12
|
+
|
|
13
|
+
const ROOT = join(import.meta.dir, '..');
|
|
14
|
+
const THEME = readFileSync(join(ROOT, 'src/theme.css'), 'utf8');
|
|
15
|
+
const SCENES_CSS = readFileSync(join(ROOT, 'src/scenes.css'), 'utf8');
|
|
16
|
+
|
|
17
|
+
/** The scenes this file ships. An app names them by class (`cb-<id>`). */
|
|
18
|
+
export const SCENES = ['steampunk', 'synthwave'] as const;
|
|
19
|
+
|
|
20
|
+
type Decls = Map<string, string>;
|
|
21
|
+
const strip = (css: string) => css.replace(/\/\*[\s\S]*?\*\//g, '');
|
|
22
|
+
|
|
23
|
+
/** The custom-property declarations of the top-level rule whose selector is exactly `selector`. */
|
|
24
|
+
function declarationsOf(css: string, selector: string): Decls | null {
|
|
25
|
+
for (const m of strip(css).matchAll(/(?<=^|[;}])\s*([^{};@]+?)\s*\{([^{}]*)\}/g)) {
|
|
26
|
+
if (m[1]?.replace(/\s+/g, ' ').trim() !== selector) continue;
|
|
27
|
+
const out: Decls = new Map();
|
|
28
|
+
for (const d of (m[2] ?? '').matchAll(/(--[a-z0-9-]+)\s*:\s*([^;]+);/g)) out.set(d[1] as string, (d[2] as string).trim());
|
|
29
|
+
return out;
|
|
30
|
+
}
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const light = (id: string) => declarationsOf(SCENES_CSS, `.cb-${id}`);
|
|
35
|
+
const dark = (id: string) => declarationsOf(SCENES_CSS, `.cb-${id}.dark, .dark .cb-${id}`);
|
|
36
|
+
|
|
37
|
+
const auroraLight = declarationsOf(THEME, '.cb-aurora');
|
|
38
|
+
const auroraDark = declarationsOf(THEME, '.cb-aurora.dark, .dark .cb-aurora');
|
|
39
|
+
if (!auroraLight || !auroraDark) throw new Error('theme.css no longer declares .cb-aurora in both schemes');
|
|
40
|
+
|
|
41
|
+
const ACCENT = ['--accent', '--accent-hover', '--accent-solid', '--accent-solid-hover', '--accent-solid-foreground'] as const;
|
|
42
|
+
|
|
43
|
+
/** Every custom property theme.css declares (in any rule) as a value reading one of the accent tokens. */
|
|
44
|
+
function accentAliases(): string[] {
|
|
45
|
+
const out = new Set<string>();
|
|
46
|
+
for (const block of strip(THEME).matchAll(/\{([^{}]*)\}/g)) {
|
|
47
|
+
for (const d of (block[1] ?? '').matchAll(/(--[a-z0-9-]+)\s*:\s*var\((--accent[a-z-]*)\)\s*;/g)) {
|
|
48
|
+
const name = d[1] as string;
|
|
49
|
+
// Tailwind's `--color-*` theme keys are inlined into utilities, not substituted at :root.
|
|
50
|
+
if (!name.startsWith('--color-') && !(ACCENT as readonly string[]).includes(name)) out.add(name);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return [...out].sort();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// ── contrast, WCAG 2.x ───────────────────────────────────────────────────────
|
|
57
|
+
const channel = (v: number): number => {
|
|
58
|
+
const c = v / 255;
|
|
59
|
+
return c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;
|
|
60
|
+
};
|
|
61
|
+
function luminance(hex: string): number {
|
|
62
|
+
const n = Number.parseInt(hex.slice(1), 16);
|
|
63
|
+
return 0.2126 * channel(n >> 16) + 0.7152 * channel((n >> 8) & 255) + 0.0722 * channel(n & 255);
|
|
64
|
+
}
|
|
65
|
+
const contrast = (a: string, b: string): number => {
|
|
66
|
+
const [l1, l2] = [luminance(a), luminance(b)].sort((x, y) => y - x) as [number, number];
|
|
67
|
+
return (l1 + 0.05) / (l2 + 0.05);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const SURFACES = ['--background', '--surface', '--card', '--card-raised', '--card-overlay', '--popover', '--muted'] as const;
|
|
71
|
+
const TEXT = ['--foreground', '--muted-foreground'] as const;
|
|
72
|
+
|
|
73
|
+
describe('scenes.css', () => {
|
|
74
|
+
test('declares exactly the shipped scenes, each in both schemes', () => {
|
|
75
|
+
for (const id of SCENES) {
|
|
76
|
+
expect(light(id), `.cb-${id}`).not.toBeNull();
|
|
77
|
+
expect(dark(id), `.cb-${id}.dark`).not.toBeNull();
|
|
78
|
+
}
|
|
79
|
+
const scopes = new Set([...strip(SCENES_CSS).matchAll(/\.cb-([a-z-]+)/g)].map((m) => m[1]));
|
|
80
|
+
expect([...scopes].sort()).toEqual([...SCENES].sort());
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
test('the alias scan still finds the accent aliases theme.css derives (a scan that finds none proves nothing)', () => {
|
|
84
|
+
expect(accentAliases()).toEqual(expect.arrayContaining(['--primary', '--primary-foreground', '--ring', '--accent-strong']));
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
test("each scene re-binds every aurora token, the accent, and every alias derived from it (the app's accent cannot leak in)", () => {
|
|
88
|
+
const want = [...new Set([...auroraLight.keys(), ...auroraDark.keys(), ...ACCENT, ...accentAliases()])];
|
|
89
|
+
for (const id of SCENES) {
|
|
90
|
+
for (const [scheme, decls] of [
|
|
91
|
+
['light', light(id) as Decls],
|
|
92
|
+
['dark', dark(id) as Decls],
|
|
93
|
+
] as const) {
|
|
94
|
+
const missing = want.filter((k) => !decls.has(k));
|
|
95
|
+
expect({ scene: id, scheme, missing }).toEqual({ scene: id, scheme, missing: [] });
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
test("text, borders and the accent clear their floors in every scene and scheme", () => {
|
|
101
|
+
const failures: string[] = [];
|
|
102
|
+
for (const id of SCENES) {
|
|
103
|
+
for (const [scheme, decls] of [
|
|
104
|
+
['light', light(id) as Decls],
|
|
105
|
+
['dark', dark(id) as Decls],
|
|
106
|
+
] as const) {
|
|
107
|
+
const hex = (token: string): string => {
|
|
108
|
+
const v = decls.get(token);
|
|
109
|
+
if (!v || !/^#[0-9a-f]{6}$/i.test(v)) failures.push(`${id}/${scheme}: ${token} must be a 6-digit hex here, got ${v ?? 'nothing'}`);
|
|
110
|
+
return v ?? '#000000';
|
|
111
|
+
};
|
|
112
|
+
const floor = (what: string, ratio: number, min: number, max = Number.POSITIVE_INFINITY) => {
|
|
113
|
+
if (ratio < min || ratio > max) failures.push(`${id}/${scheme}: ${what} is ${ratio.toFixed(2)}:1 (want ${min}${max < 99 ? `–${max}` : '+'})`);
|
|
114
|
+
};
|
|
115
|
+
for (const text of TEXT) for (const surface of SURFACES) floor(`${text} on ${surface}`, contrast(hex(text), hex(surface)), 4.5);
|
|
116
|
+
floor('--border-strong on --card', contrast(hex('--border-strong'), hex('--card')), 3);
|
|
117
|
+
floor('--border on --card', contrast(hex('--border'), hex('--card')), 1.3, 1.6);
|
|
118
|
+
floor('--accent on --card', contrast(hex('--accent'), hex('--card')), 3);
|
|
119
|
+
floor('--accent on --surface-sunken', contrast(hex('--accent'), hex('--surface-sunken')), 3);
|
|
120
|
+
floor('--accent-solid-foreground on --accent-solid', contrast(hex('--accent-solid-foreground'), hex('--accent-solid')), 4.5);
|
|
121
|
+
floor('--accent-solid-foreground on --accent-solid-hover', contrast(hex('--accent-solid-foreground'), hex('--accent-solid-hover')), 4.5);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
expect(failures).toEqual([]);
|
|
125
|
+
});
|
|
126
|
+
});
|