cursedbelt 6.14.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/ControlPanel.d.ts +2 -1
- package/dist/react/components/ControlPanel.d.ts.map +1 -1
- package/dist/react/components/ControlPanel.js +4 -3
- package/dist/react/components/ControlPanel.js.map +1 -1
- package/dist/react/components/FieldGrid.d.ts +23 -1
- package/dist/react/components/FieldGrid.d.ts.map +1 -1
- package/dist/react/components/FieldGrid.js +26 -4
- package/dist/react/components/FieldGrid.js.map +1 -1
- 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/react/components/SliderField.d.ts.map +1 -1
- package/dist/react/components/SliderField.js +8 -2
- package/dist/react/components/SliderField.js.map +1 -1
- package/dist/scenes.css +217 -0
- package/package.json +3 -2
- package/src/react/components/ControlPanel.tsx +5 -4
- package/src/react/components/FieldGrid.tsx +41 -3
- package/src/react/components/Slider.spec.tsx +19 -0
- package/src/react/components/Slider.tsx +5 -2
- package/src/react/components/SliderField.tsx +8 -2
- package/src/react/components/SliderField.valueColumn.spec.tsx +73 -0
- package/src/scenes.css +217 -0
- package/src/scenes.spec.ts +126 -0
|
@@ -35,7 +35,8 @@ export interface ControlPanelProps {
|
|
|
35
35
|
* boxes — whitespace and a 1px vertical rule between columns. Columns wrap whole, every column in
|
|
36
36
|
* a row is the same height and padding, and each group's fields share one label column. On a
|
|
37
37
|
* phone the groups become stacked accordions (the first open), so the canvas above stays in view
|
|
38
|
-
* and no column is squeezed past use.
|
|
38
|
+
* and no column is squeezed past use. Every slider in the panel shares one value column
|
|
39
|
+
* ({@link SliderValueColumnScope}), across its groups.
|
|
39
40
|
*/
|
|
40
41
|
export declare function ControlPanel({ title, actions, children, columnMin, className, ...rest }: ControlPanelProps): import("react").JSX.Element;
|
|
41
42
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ControlPanel.d.ts","sourceRoot":"","sources":["../../../src/react/components/ControlPanel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,SAAS,EAAE,MAAM,OAAO,CAAC;AAItD,OAAO,EAAa,KAAK,cAAc,
|
|
1
|
+
{"version":3,"file":"ControlPanel.d.ts","sourceRoot":"","sources":["../../../src/react/components/ControlPanel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,SAAS,EAAE,MAAM,OAAO,CAAC;AAItD,OAAO,EAAa,KAAK,cAAc,EAA0B,MAAM,gBAAgB,CAAC;AAKxF,MAAM,WAAW,iBAAiB;IAChC,yEAAyE;IACzE,KAAK,EAAE,MAAM,CAAC;IACd,8FAA8F;IAC9F,QAAQ,EAAE,SAAS,CAAC;IACpB,6FAA6F;IAC7F,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,yEAAyE;IACzE,UAAU,CAAC,EAAE,cAAc,CAAC,YAAY,CAAC,CAAC;IAC1C,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,iBAAiB;IAChC,6DAA6D;IAC7D,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB;;;OAGG;IACH,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,wCAAwC;IACxC,QAAQ,EAAE,SAAS,CAAC;IACpB;;;;OAIG;IACH,SAAS,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAQD;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAgB,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,EAAE,iBAAiB,+BAiCjH;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,UAAiB,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,EAAE,iBAAiB,+BAsBtH"}
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { useMediaQuery } from '../hooks/useMediaQuery.js';
|
|
3
3
|
import { cn } from '../lib/cn.js';
|
|
4
4
|
import { Collapsible } from './Collapsible.js';
|
|
5
|
-
import { FieldGrid } from './FieldGrid.js';
|
|
5
|
+
import { FieldGrid, SliderValueColumnScope } from './FieldGrid.js';
|
|
6
6
|
/** Below this a panel's columns would be squeezed past use, so they stack as accordions (FRM-17). */
|
|
7
7
|
const PHONE_QUERY = '(max-width: 639px)';
|
|
8
8
|
const COLUMN_MIN = {
|
|
@@ -16,12 +16,13 @@ const COLUMN_MIN = {
|
|
|
16
16
|
* boxes — whitespace and a 1px vertical rule between columns. Columns wrap whole, every column in
|
|
17
17
|
* a row is the same height and padding, and each group's fields share one label column. On a
|
|
18
18
|
* phone the groups become stacked accordions (the first open), so the canvas above stays in view
|
|
19
|
-
* and no column is squeezed past use.
|
|
19
|
+
* and no column is squeezed past use. Every slider in the panel shares one value column
|
|
20
|
+
* ({@link SliderValueColumnScope}), across its groups.
|
|
20
21
|
*/
|
|
21
22
|
export function ControlPanel({ title, actions, children, columnMin = 'md', className, ...rest }) {
|
|
22
23
|
const phone = useMediaQuery(PHONE_QUERY);
|
|
23
24
|
const name = typeof title === 'string' ? title : undefined;
|
|
24
|
-
return (_jsxs("section", { ...rest, className: cn('flex min-w-0 flex-col gap-4', className), "data-cb-control-panel": phone ? 'stacked' : 'columns', "aria-label": name, children: [title != null || actions != null ? (_jsxs("div", { className: 'flex min-w-0 items-center justify-between gap-3', "data-cb-control-panel-header": '', children: [title != null ? _jsx("h2", { className: 'm-0 min-w-0 truncate text-sm font-semibold text-foreground', children: title }) : _jsx("span", {}), actions != null ? _jsx("div", { className: 'flex shrink-0 items-center gap-2', children: actions }) : null] })) : null, phone ? (_jsx("div", { className: 'flex flex-col divide-y divide-border', "data-cb-control-panel-groups": '', "data-phone": '', children: children })) : (_jsx("div", { className: 'cb-control-panel-frame', children: _jsx("div", { className: 'cb-control-panel-groups', "data-cb-control-panel-groups": '', style: { '--cb-panel-col-min': COLUMN_MIN[columnMin] }, children: children }) }))] }));
|
|
25
|
+
return (_jsxs("section", { ...rest, className: cn('flex min-w-0 flex-col gap-4', className), "data-cb-control-panel": phone ? 'stacked' : 'columns', "aria-label": name, children: [title != null || actions != null ? (_jsxs("div", { className: 'flex min-w-0 items-center justify-between gap-3', "data-cb-control-panel-header": '', children: [title != null ? _jsx("h2", { className: 'm-0 min-w-0 truncate text-sm font-semibold text-foreground', children: title }) : _jsx("span", {}), actions != null ? _jsx("div", { className: 'flex shrink-0 items-center gap-2', children: actions }) : null] })) : null, phone ? (_jsx("div", { className: 'flex flex-col divide-y divide-border', "data-cb-control-panel-groups": '', "data-phone": '', children: _jsx(SliderValueColumnScope, { children: children }) })) : (_jsx("div", { className: 'cb-control-panel-frame', children: _jsx("div", { className: 'cb-control-panel-groups', "data-cb-control-panel-groups": '', style: { '--cb-panel-col-min': COLUMN_MIN[columnMin] }, children: _jsx(SliderValueColumnScope, { children: children }) }) }))] }));
|
|
25
26
|
}
|
|
26
27
|
/**
|
|
27
28
|
* One topic column of a {@link ControlPanel}: a `.cb-meta-label` eyebrow over a {@link FieldGrid},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ControlPanel.js","sourceRoot":"","sources":["../../../src/react/components/ControlPanel.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAuB,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"ControlPanel.js","sourceRoot":"","sources":["../../../src/react/components/ControlPanel.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,a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P,cAAK,SAAS,EAAC,sCAAsC,kCAA8B,EAAE,gBAAY,EAAE,YACjG,KAAC,sBAAsB,cAAE,QAAQ,GAA0B,GACvD,CACP,CAAC,CAAC,CAAC,CACF,cAAK,SAAS,EAAC,wBAAwB,YACrC,cACE,SAAS,EAAC,yBAAyB,kCACN,EAAE,EAC/B,KAAK,EAAE,EAAE,oBAAoB,EAAE,UAAU,CAAC,SAAS,CAAC,EAAmB,YAEvE,KAAC,sBAAsB,cAAE,QAAQ,GAA0B,GACvD,GACF,CACP,IACO,CACX,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,UAAU,GAAG,IAAI,EAAE,SAAS,EAAE,GAAG,IAAI,EAAqB;IACrH,MAAM,KAAK,GAAG,aAAa,CAAC,WAAW,CAAC,CAAC;IACzC,MAAM,IAAI,GAAG,KAAC,SAAS,IAAC,UAAU,EAAE,UAAU,YAAG,QAAQ,GAAa,CAAC;IACvE,IAAI,KAAK,EAAE,CAAC;QACV,OAAO,CACL,iBAAS,IAAI,EAAE,SAAS,EAAE,SAAS,2BAAwB,EAAE,YAC3D,KAAC,WAAW,IACV,OAAO,EAAE,eAAM,SAAS,EAAC,eAAe,YAAE,KAAK,GAAQ,EACvD,WAAW,EAAE,WAAW,EACxB,gBAAgB,EAAC,WAAW,YAE3B,IAAI,GACO,GACV,CACP,CAAC;IACJ,CAAC;IACD,OAAO,CACL,uBAAc,IAAI,EAAE,SAAS,EAAE,EAAE,CAAC,0BAA0B,EAAE,SAAS,CAAC,2BAAwB,EAAE,aAChG,iBAAQ,SAAS,EAAC,wBAAwB,YAAE,KAAK,GAAU,EAC1D,IAAI,IACI,CACZ,CAAC;AACJ,CAAC"}
|
|
@@ -13,13 +13,35 @@ export interface FieldGridProps {
|
|
|
13
13
|
}
|
|
14
14
|
/** The enclosing FieldGrid's label width, or `null` outside one — SliderField sizes its narrow-grid threshold from it (forge task 2667). */
|
|
15
15
|
export declare const useFieldGridLabelWidth: () => NonNullable<"sm" | "md" | "lg" | undefined> | null;
|
|
16
|
+
/**
|
|
17
|
+
* The value column a panel's `SliderField`s share (forge task 5550). Each slider measures its own
|
|
18
|
+
* longest readout; one that needs the wide box registers here, and while any does, every slider in
|
|
19
|
+
* the scope draws the wide box — so a `1.00×` row and an `Auto 2×` row end their tracks on one edge.
|
|
20
|
+
*/
|
|
21
|
+
export interface SliderValueColumn {
|
|
22
|
+
/** Some slider in the scope needs the wide value box. */
|
|
23
|
+
wide: boolean;
|
|
24
|
+
/** A slider that needs the wide box calls this; the returned function takes it back. */
|
|
25
|
+
claimWide: () => () => void;
|
|
26
|
+
}
|
|
27
|
+
/** The enclosing scope's shared value column, or `null` outside one — then a slider sizes its box alone. */
|
|
28
|
+
export declare const useSliderValueColumn: () => SliderValueColumn | null;
|
|
29
|
+
/**
|
|
30
|
+
* Opens a shared value column for the `SliderField`s inside it. `ControlPanel` opens one for the
|
|
31
|
+
* whole panel and `FieldGrid` for itself; an inner scope defers to the outer, so every group of
|
|
32
|
+
* one panel shares ONE column, not one per group.
|
|
33
|
+
*/
|
|
34
|
+
export declare function SliderValueColumnScope({ children }: {
|
|
35
|
+
children: ReactNode;
|
|
36
|
+
}): import("react").JSX.Element;
|
|
16
37
|
/**
|
|
17
38
|
* A column of fields whose labels share ONE label column (FRM-1, FRM-2): every label shares a
|
|
18
39
|
* left edge, and every control shares its left edge, so a dense settings list or a control
|
|
19
40
|
* panel reads as one straight-edged table instead of a zig-zag. Put `Field layout="inline"`
|
|
20
41
|
* and `SliderField` inside it. Stacked labels (a plain `Stack` of `Field`s) stay the default
|
|
21
42
|
* for an ordinary form; reach for this only for a dense panel or a settings list. On a phone
|
|
22
|
-
* each row stacks its label over its control.
|
|
43
|
+
* each row stacks its label over its control. Its sliders share one value column too
|
|
44
|
+
* ({@link SliderValueColumnScope}), so their tracks end on one right edge.
|
|
23
45
|
*/
|
|
24
46
|
export declare function FieldGrid({ children, labelWidth, density, className, ...rest }: FieldGridProps): import("react").JSX.Element;
|
|
25
47
|
//# sourceMappingURL=FieldGrid.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldGrid.d.ts","sourceRoot":"","sources":["../../../src/react/components/FieldGrid.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAqC,KAAK,SAAS,
|
|
1
|
+
{"version":3,"file":"FieldGrid.d.ts","sourceRoot":"","sources":["../../../src/react/components/FieldGrid.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAqC,KAAK,SAAS,EAA8C,MAAM,OAAO,CAAC;AAGtH,MAAM,WAAW,cAAc;IAC7B,yGAAyG;IACzG,QAAQ,EAAE,SAAS,CAAC;IACpB;;;OAGG;IACH,UAAU,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IAChC,0GAA0G;IAC1G,OAAO,CAAC,EAAE,OAAO,GAAG,UAAU,CAAC;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAUD,4IAA4I;AAC5I,eAAO,MAAM,sBAAsB,0DAAsC,CAAC;AAE1E;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC,yDAAyD;IACzD,IAAI,EAAE,OAAO,CAAC;IACd,wFAAwF;IACxF,SAAS,EAAE,MAAM,MAAM,IAAI,CAAC;CAC7B;AAID,4GAA4G;AAC5G,eAAO,MAAM,oBAAoB,gCAAuC,CAAC;AAEzE;;;;GAIG;AAEH,wBAAgB,sBAAsB,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,+BAU3E;AAED;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,EAAE,QAAQ,EAAE,UAAiB,EAAE,OAAiB,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,EAAE,cAAc,+BAe/G"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { createContext, useContext } from 'react';
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useCallback, useContext, useMemo, useState } from 'react';
|
|
3
3
|
import { cn } from '../lib/cn.js';
|
|
4
4
|
const LABEL_COL = {
|
|
5
5
|
sm: '7rem',
|
|
@@ -9,17 +9,39 @@ const LABEL_COL = {
|
|
|
9
9
|
const LabelWidthContext = createContext(null);
|
|
10
10
|
/** The enclosing FieldGrid's label width, or `null` outside one — SliderField sizes its narrow-grid threshold from it (forge task 2667). */
|
|
11
11
|
export const useFieldGridLabelWidth = () => useContext(LabelWidthContext);
|
|
12
|
+
const ValueColumnContext = createContext(null);
|
|
13
|
+
/** The enclosing scope's shared value column, or `null` outside one — then a slider sizes its box alone. */
|
|
14
|
+
export const useSliderValueColumn = () => useContext(ValueColumnContext);
|
|
15
|
+
/**
|
|
16
|
+
* Opens a shared value column for the `SliderField`s inside it. `ControlPanel` opens one for the
|
|
17
|
+
* whole panel and `FieldGrid` for itself; an inner scope defers to the outer, so every group of
|
|
18
|
+
* one panel shares ONE column, not one per group.
|
|
19
|
+
*/
|
|
20
|
+
// no-attribute-forward: a context provider around its children, with no element of its own.
|
|
21
|
+
export function SliderValueColumnScope({ children }) {
|
|
22
|
+
const outer = useContext(ValueColumnContext);
|
|
23
|
+
const [claims, setClaims] = useState(0);
|
|
24
|
+
const claimWide = useCallback(() => {
|
|
25
|
+
setClaims((n) => n + 1);
|
|
26
|
+
return () => setClaims((n) => n - 1);
|
|
27
|
+
}, []);
|
|
28
|
+
const own = useMemo(() => ({ wide: claims > 0, claimWide }), [claims, claimWide]);
|
|
29
|
+
if (outer)
|
|
30
|
+
return _jsx(_Fragment, { children: children });
|
|
31
|
+
return _jsx(ValueColumnContext.Provider, { value: own, children: children });
|
|
32
|
+
}
|
|
12
33
|
/**
|
|
13
34
|
* A column of fields whose labels share ONE label column (FRM-1, FRM-2): every label shares a
|
|
14
35
|
* left edge, and every control shares its left edge, so a dense settings list or a control
|
|
15
36
|
* panel reads as one straight-edged table instead of a zig-zag. Put `Field layout="inline"`
|
|
16
37
|
* and `SliderField` inside it. Stacked labels (a plain `Stack` of `Field`s) stay the default
|
|
17
38
|
* for an ordinary form; reach for this only for a dense panel or a settings list. On a phone
|
|
18
|
-
* each row stacks its label over its control.
|
|
39
|
+
* each row stacks its label over its control. Its sliders share one value column too
|
|
40
|
+
* ({@link SliderValueColumnScope}), so their tracks end on one right edge.
|
|
19
41
|
*/
|
|
20
42
|
export function FieldGrid({ children, labelWidth = 'md', density = 'dense', className, ...rest }) {
|
|
21
43
|
return (_jsx("div", { ...rest, className: cn('cb-field-grid', className), "data-cb-field-grid": '', "data-density": density,
|
|
22
44
|
// A live custom property — the one track every row's label column reads.
|
|
23
|
-
style: { '--cb-label-col': LABEL_COL[labelWidth] }, children: _jsx(LabelWidthContext.Provider, { value: labelWidth, children: children }) }));
|
|
45
|
+
style: { '--cb-label-col': LABEL_COL[labelWidth] }, children: _jsx(LabelWidthContext.Provider, { value: labelWidth, children: _jsx(SliderValueColumnScope, { children: children }) }) }));
|
|
24
46
|
}
|
|
25
47
|
//# sourceMappingURL=FieldGrid.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldGrid.js","sourceRoot":"","sources":["../../../src/react/components/FieldGrid.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAsB,aAAa,EAAkB,UAAU,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"FieldGrid.js","sourceRoot":"","sources":["../../../src/react/components/FieldGrid.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAsB,aAAa,EAAkB,WAAW,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACtH,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAelC,MAAM,SAAS,GAA8D;IAC3E,EAAE,EAAE,MAAM;IACV,EAAE,EAAE,MAAM;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K,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,C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;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,SAAS,CAAC;IAC3C;;;OAGG;IACH,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB;;;;;;;OAOG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1B;;;OAGG;IACH,IAAI,CAAC,EAAE,SAAS,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IACvC;;;;OAIG;IACH,KAAK,CAAC,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC7D,kGAAkG;IAClG,KAAK,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAC;IAC1B,mGAAmG;IACnG,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CAAC,EAC1B,KAAK,EACL,KAAK,EACL,GAAG,EACH,GAAG,EACH,IAAQ,EACR,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,UAAc,EACd,QAAQ,EACR,KAAK,EACL,IAAI,EACJ,KAAK,EACL,WAAW,EACX,IAAI,EACJ,KAAgB,EAChB,YAAY,EAAE,SAAS,EACvB,SAAS,EACT,GAAG,IAAI,EACR,EAAE,gBAAgB,+
|
|
1
|
+
{"version":3,"file":"SliderField.d.ts","sourceRoot":"","sources":["../../../src/react/components/SliderField.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAuD,MAAM,OAAO,CAAC;AAC5F,OAAO,mBAAmB,CAAC;AAU3B;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAA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OAGG;IACH,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB;;;;;;;OAOG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1B;;;OAGG;IACH,IAAI,CAAC,EAAE,SAAS,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IACvC;;;;OAIG;IACH,KAAK,CAAC,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC7D,kGAAkG;IAClG,KAAK,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAC;IAC1B,mGAAmG;IACnG,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CAAC,EAC1B,KAAK,EACL,KAAK,EACL,GAAG,EACH,GAAG,EACH,IAAQ,EACR,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,UAAc,EACd,QAAQ,EACR,KAAK,EACL,IAAI,EACJ,KAAK,EACL,WAAW,EACX,IAAI,EACJ,KAAgB,EAChB,YAAY,EAAE,SAAS,EACvB,SAAS,EACT,GAAG,IAAI,EACR,EAAE,gBAAgB,+BAyLlB"}
|
|
@@ -5,7 +5,7 @@ import { useDebouncedCallback } from '../hooks/useDebouncedCallback.js';
|
|
|
5
5
|
import { cn } from '../lib/cn.js';
|
|
6
6
|
import { HELP_FOLD_CHARS } from '../lib/field.js';
|
|
7
7
|
import { Button } from './Button.js';
|
|
8
|
-
import { useFieldGridLabelWidth } from './FieldGrid.js';
|
|
8
|
+
import { useFieldGridLabelWidth, useSliderValueColumn } from './FieldGrid.js';
|
|
9
9
|
import { InfoHint } from './InfoHint.js';
|
|
10
10
|
import { Input } from './Input.js';
|
|
11
11
|
import { Slider } from './Slider.js';
|
|
@@ -162,7 +162,13 @@ export function SliderField({ label, value, min, max, step = 1, disabled, onChan
|
|
|
162
162
|
const r = formatValue ? formatValue(v) : formatSliderValue(v, step);
|
|
163
163
|
return typeof r === 'string' || typeof r === 'number' ? String(r).length : 0;
|
|
164
164
|
}));
|
|
165
|
-
const
|
|
165
|
+
const ownWide = widest > WIDE_READOUT_CHARS;
|
|
166
|
+
// Inside a FieldGrid or ControlPanel the box is the scope's: any slider that needs the wide box
|
|
167
|
+
// widens every one, so the panel's tracks end on one edge (forge task 5550). Alone, its own.
|
|
168
|
+
const column = useSliderValueColumn();
|
|
169
|
+
const claimWide = column?.claimWide;
|
|
170
|
+
useLayoutEffect(() => (ownWide && claimWide ? claimWide() : undefined), [ownWide, claimWide]);
|
|
171
|
+
const wide = ownWide || (column?.wide ?? false);
|
|
166
172
|
const gridLabel = useFieldGridLabelWidth();
|
|
167
173
|
const folds = typeof hint === 'string' && hint.length > HELP_FOLD_CHARS;
|
|
168
174
|
const resetNow = () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SliderField.js","sourceRoot":"","sources":["../../../src/react/components/SliderField.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAkB,SAAS,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5F,OAAO,mBAAmB,CAAC;AAC3B,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AACxE,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAClC,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"SliderField.js","sourceRoot":"","sources":["../../../src/react/components/SliderField.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAkB,SAAS,EAAE,KAA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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",
|
|
@@ -2,7 +2,7 @@ import type { CSSProperties, ReactNode } from 'react';
|
|
|
2
2
|
import { useMediaQuery } from '../hooks/useMediaQuery.js';
|
|
3
3
|
import { cn } from '../lib/cn.js';
|
|
4
4
|
import { Collapsible } from './Collapsible.js';
|
|
5
|
-
import { FieldGrid, type FieldGridProps } from './FieldGrid.js';
|
|
5
|
+
import { FieldGrid, type FieldGridProps, SliderValueColumnScope } from './FieldGrid.js';
|
|
6
6
|
|
|
7
7
|
/** Below this a panel's columns would be squeezed past use, so they stack as accordions (FRM-17). */
|
|
8
8
|
const PHONE_QUERY = '(max-width: 639px)';
|
|
@@ -50,7 +50,8 @@ const COLUMN_MIN: Record<NonNullable<ControlPanelProps['columnMin']>, string> =
|
|
|
50
50
|
* boxes — whitespace and a 1px vertical rule between columns. Columns wrap whole, every column in
|
|
51
51
|
* a row is the same height and padding, and each group's fields share one label column. On a
|
|
52
52
|
* phone the groups become stacked accordions (the first open), so the canvas above stays in view
|
|
53
|
-
* and no column is squeezed past use.
|
|
53
|
+
* and no column is squeezed past use. Every slider in the panel shares one value column
|
|
54
|
+
* ({@link SliderValueColumnScope}), across its groups.
|
|
54
55
|
*/
|
|
55
56
|
export function ControlPanel({ title, actions, children, columnMin = 'md', className, ...rest }: ControlPanelProps) {
|
|
56
57
|
const phone = useMediaQuery(PHONE_QUERY);
|
|
@@ -70,7 +71,7 @@ export function ControlPanel({ title, actions, children, columnMin = 'md', class
|
|
|
70
71
|
) : null}
|
|
71
72
|
{phone ? (
|
|
72
73
|
<div className='flex flex-col divide-y divide-border' data-cb-control-panel-groups='' data-phone=''>
|
|
73
|
-
{children}
|
|
74
|
+
<SliderValueColumnScope>{children}</SliderValueColumnScope>
|
|
74
75
|
</div>
|
|
75
76
|
) : (
|
|
76
77
|
<div className='cb-control-panel-frame'>
|
|
@@ -79,7 +80,7 @@ export function ControlPanel({ title, actions, children, columnMin = 'md', class
|
|
|
79
80
|
data-cb-control-panel-groups=''
|
|
80
81
|
style={{ '--cb-panel-col-min': COLUMN_MIN[columnMin] } as CSSProperties}
|
|
81
82
|
>
|
|
82
|
-
{children}
|
|
83
|
+
<SliderValueColumnScope>{children}</SliderValueColumnScope>
|
|
83
84
|
</div>
|
|
84
85
|
</div>
|
|
85
86
|
)}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type CSSProperties, createContext, type ReactNode, useContext } from 'react';
|
|
1
|
+
import { type CSSProperties, createContext, type ReactNode, useCallback, useContext, useMemo, useState } from 'react';
|
|
2
2
|
import { cn } from '../lib/cn.js';
|
|
3
3
|
|
|
4
4
|
export interface FieldGridProps {
|
|
@@ -25,13 +25,49 @@ const LabelWidthContext = createContext<NonNullable<FieldGridProps['labelWidth']
|
|
|
25
25
|
/** The enclosing FieldGrid's label width, or `null` outside one — SliderField sizes its narrow-grid threshold from it (forge task 2667). */
|
|
26
26
|
export const useFieldGridLabelWidth = () => useContext(LabelWidthContext);
|
|
27
27
|
|
|
28
|
+
/**
|
|
29
|
+
* The value column a panel's `SliderField`s share (forge task 5550). Each slider measures its own
|
|
30
|
+
* longest readout; one that needs the wide box registers here, and while any does, every slider in
|
|
31
|
+
* the scope draws the wide box — so a `1.00×` row and an `Auto 2×` row end their tracks on one edge.
|
|
32
|
+
*/
|
|
33
|
+
export interface SliderValueColumn {
|
|
34
|
+
/** Some slider in the scope needs the wide value box. */
|
|
35
|
+
wide: boolean;
|
|
36
|
+
/** A slider that needs the wide box calls this; the returned function takes it back. */
|
|
37
|
+
claimWide: () => () => void;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const ValueColumnContext = createContext<SliderValueColumn | null>(null);
|
|
41
|
+
|
|
42
|
+
/** The enclosing scope's shared value column, or `null` outside one — then a slider sizes its box alone. */
|
|
43
|
+
export const useSliderValueColumn = () => useContext(ValueColumnContext);
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Opens a shared value column for the `SliderField`s inside it. `ControlPanel` opens one for the
|
|
47
|
+
* whole panel and `FieldGrid` for itself; an inner scope defers to the outer, so every group of
|
|
48
|
+
* one panel shares ONE column, not one per group.
|
|
49
|
+
*/
|
|
50
|
+
// no-attribute-forward: a context provider around its children, with no element of its own.
|
|
51
|
+
export function SliderValueColumnScope({ children }: { children: ReactNode }) {
|
|
52
|
+
const outer = useContext(ValueColumnContext);
|
|
53
|
+
const [claims, setClaims] = useState(0);
|
|
54
|
+
const claimWide = useCallback(() => {
|
|
55
|
+
setClaims((n) => n + 1);
|
|
56
|
+
return () => setClaims((n) => n - 1);
|
|
57
|
+
}, []);
|
|
58
|
+
const own = useMemo(() => ({ wide: claims > 0, claimWide }), [claims, claimWide]);
|
|
59
|
+
if (outer) return <>{children}</>;
|
|
60
|
+
return <ValueColumnContext.Provider value={own}>{children}</ValueColumnContext.Provider>;
|
|
61
|
+
}
|
|
62
|
+
|
|
28
63
|
/**
|
|
29
64
|
* A column of fields whose labels share ONE label column (FRM-1, FRM-2): every label shares a
|
|
30
65
|
* left edge, and every control shares its left edge, so a dense settings list or a control
|
|
31
66
|
* panel reads as one straight-edged table instead of a zig-zag. Put `Field layout="inline"`
|
|
32
67
|
* and `SliderField` inside it. Stacked labels (a plain `Stack` of `Field`s) stay the default
|
|
33
68
|
* for an ordinary form; reach for this only for a dense panel or a settings list. On a phone
|
|
34
|
-
* each row stacks its label over its control.
|
|
69
|
+
* each row stacks its label over its control. Its sliders share one value column too
|
|
70
|
+
* ({@link SliderValueColumnScope}), so their tracks end on one right edge.
|
|
35
71
|
*/
|
|
36
72
|
export function FieldGrid({ children, labelWidth = 'md', density = 'dense', className, ...rest }: FieldGridProps) {
|
|
37
73
|
return (
|
|
@@ -43,7 +79,9 @@ export function FieldGrid({ children, labelWidth = 'md', density = 'dense', clas
|
|
|
43
79
|
// A live custom property — the one track every row's label column reads.
|
|
44
80
|
style={{ '--cb-label-col': LABEL_COL[labelWidth] } as CSSProperties}
|
|
45
81
|
>
|
|
46
|
-
<LabelWidthContext.Provider value={labelWidth}>
|
|
82
|
+
<LabelWidthContext.Provider value={labelWidth}>
|
|
83
|
+
<SliderValueColumnScope>{children}</SliderValueColumnScope>
|
|
84
|
+
</LabelWidthContext.Provider>
|
|
47
85
|
</div>
|
|
48
86
|
);
|
|
49
87
|
}
|
|
@@ -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} />
|
|
@@ -4,7 +4,7 @@ import { useDebouncedCallback } from '../hooks/useDebouncedCallback.js';
|
|
|
4
4
|
import { cn } from '../lib/cn.js';
|
|
5
5
|
import { HELP_FOLD_CHARS } from '../lib/field.js';
|
|
6
6
|
import { Button } from './Button.js';
|
|
7
|
-
import { useFieldGridLabelWidth } from './FieldGrid.js';
|
|
7
|
+
import { useFieldGridLabelWidth, useSliderValueColumn } from './FieldGrid.js';
|
|
8
8
|
import { InfoHint } from './InfoHint.js';
|
|
9
9
|
import { Input } from './Input.js';
|
|
10
10
|
import { Slider } from './Slider.js';
|
|
@@ -260,7 +260,13 @@ export function SliderField({
|
|
|
260
260
|
return typeof r === 'string' || typeof r === 'number' ? String(r).length : 0;
|
|
261
261
|
}),
|
|
262
262
|
);
|
|
263
|
-
const
|
|
263
|
+
const ownWide = widest > WIDE_READOUT_CHARS;
|
|
264
|
+
// Inside a FieldGrid or ControlPanel the box is the scope's: any slider that needs the wide box
|
|
265
|
+
// widens every one, so the panel's tracks end on one edge (forge task 5550). Alone, its own.
|
|
266
|
+
const column = useSliderValueColumn();
|
|
267
|
+
const claimWide = column?.claimWide;
|
|
268
|
+
useLayoutEffect(() => (ownWide && claimWide ? claimWide() : undefined), [ownWide, claimWide]);
|
|
269
|
+
const wide = ownWide || (column?.wide ?? false);
|
|
264
270
|
const gridLabel = useFieldGridLabelWidth();
|
|
265
271
|
const folds = typeof hint === 'string' && hint.length > HELP_FOLD_CHARS;
|
|
266
272
|
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { afterEach, describe, expect, test } from 'bun:test';
|
|
2
|
+
import { cleanup, render } from '@testing-library/react';
|
|
3
|
+
import { ControlGroup, ControlPanel } from './ControlPanel.js';
|
|
4
|
+
import { FieldGrid } from './FieldGrid.js';
|
|
5
|
+
import { SliderField } from './SliderField.js';
|
|
6
|
+
|
|
7
|
+
afterEach(cleanup);
|
|
8
|
+
|
|
9
|
+
// Forge task 5550: patterns' Controls inspector drew "Auto 2×" and "133 iter" in an 8rem box and
|
|
10
|
+
// "1.00×" in a 5rem one, so the Shape group's tracks stopped 3rem short of View's and Motion's. A
|
|
11
|
+
// panel's sliders share ONE value column: any slider whose readout needs the wide box widens all.
|
|
12
|
+
const times = (v: number) => `${v.toFixed(2)}×`;
|
|
13
|
+
const iter = (v: number) => `${v} iter`;
|
|
14
|
+
const Warp = () => <SliderField label='Text warp' value={1} min={0} max={4} step={0.01} formatValue={times} />;
|
|
15
|
+
const Detail = () => <SliderField label='Detail' value={133} min={10} max={500} step={1} formatValue={iter} />;
|
|
16
|
+
|
|
17
|
+
const boxes = (root: HTMLElement) => [...root.querySelectorAll<HTMLInputElement>('[data-cb-slider-value]')];
|
|
18
|
+
const widths = (root: HTMLElement) => boxes(root).map((b) => (b.className.includes('w-32') ? 'wide' : 'narrow'));
|
|
19
|
+
const fits = (root: HTMLElement) => [...root.querySelectorAll('.cb-slider-row')].map((r) => r.getAttribute('data-cb-slider-fit'));
|
|
20
|
+
|
|
21
|
+
describe('SliderField value column', () => {
|
|
22
|
+
test('one group: a 1.00× slider takes the wide box a 133 iter slider needs, and the wide stack threshold', () => {
|
|
23
|
+
const { container } = render(
|
|
24
|
+
<ControlGroup title='Shape' labelWidth='sm'>
|
|
25
|
+
<Warp />
|
|
26
|
+
<Detail />
|
|
27
|
+
</ControlGroup>,
|
|
28
|
+
);
|
|
29
|
+
expect(widths(container)).toEqual(['wide', 'wide']);
|
|
30
|
+
expect(fits(container)).toEqual(['22.5', '22.5']);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
test('one panel: every group shares the column, not one column per group', () => {
|
|
34
|
+
const { container } = render(
|
|
35
|
+
<ControlPanel title='Pattern'>
|
|
36
|
+
<ControlGroup title='Shape' labelWidth='sm'>
|
|
37
|
+
<Detail />
|
|
38
|
+
</ControlGroup>
|
|
39
|
+
<ControlGroup title='View' labelWidth='sm'>
|
|
40
|
+
<Warp />
|
|
41
|
+
</ControlGroup>
|
|
42
|
+
</ControlPanel>,
|
|
43
|
+
);
|
|
44
|
+
expect(widths(container)).toEqual(['wide', 'wide']);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
test('a grid of short readouts keeps the narrow box, and loses the wide one when its wide slider goes', () => {
|
|
48
|
+
const { container, rerender } = render(
|
|
49
|
+
<FieldGrid>
|
|
50
|
+
<Warp />
|
|
51
|
+
<Detail />
|
|
52
|
+
</FieldGrid>,
|
|
53
|
+
);
|
|
54
|
+
expect(widths(container)).toEqual(['wide', 'wide']);
|
|
55
|
+
rerender(
|
|
56
|
+
<FieldGrid>
|
|
57
|
+
<Warp />
|
|
58
|
+
</FieldGrid>,
|
|
59
|
+
);
|
|
60
|
+
expect(widths(container)).toEqual(['narrow']);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
test('outside a grid each slider sizes its own box', () => {
|
|
64
|
+
const { container } = render(
|
|
65
|
+
<div>
|
|
66
|
+
<Warp />
|
|
67
|
+
<Detail />
|
|
68
|
+
</div>,
|
|
69
|
+
);
|
|
70
|
+
expect(widths(container)).toEqual(['narrow', 'wide']);
|
|
71
|
+
expect(fits(container)).toEqual([null, null]);
|
|
72
|
+
});
|
|
73
|
+
});
|
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
|
+
});
|