@kolkrabbi/kol-component 0.385.0 → 0.387.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/package.json +3 -3
- package/src/atoms/ToggleCheckbox.jsx +8 -23
- package/src/atoms/ToggleSwitch.jsx +13 -42
- package/src/atoms/XYPad.jsx +12 -31
- package/src/molecules/AlignmentGrid.jsx +13 -7
- package/src/molecules/ColorInputRow.jsx +31 -23
- package/src/molecules/ColorSwatch.jsx +17 -49
- package/src/molecules/ParamBindDot.jsx +49 -54
- package/src/molecules/QuantityInput.jsx +37 -46
- package/src/molecules/Slider.jsx +48 -111
- package/src/molecules/SwatchControls.jsx +12 -7
- package/src/molecules/SwatchGrid.jsx +6 -9
- package/src/organisms/ColorPickerPopover.jsx +1 -1
- package/src/organisms/SpectrumControls.jsx +54 -137
|
@@ -1,14 +1,7 @@
|
|
|
1
|
-
import { useRef, useState } from 'react'
|
|
1
|
+
import { forwardRef, useRef, useState } from 'react'
|
|
2
2
|
import { Menu } from './Menu.jsx'
|
|
3
3
|
import { Tooltip } from '../utilities/Popover.jsx'
|
|
4
4
|
|
|
5
|
-
/* the hit box per control rung: a field's height, a narrow width; the dot inside it */
|
|
6
|
-
const SIZE = {
|
|
7
|
-
xs: 'w-4 h-[22px] [--bd-dot:6px]',
|
|
8
|
-
sm: 'w-5 h-[26px] [--bd-dot:7px]',
|
|
9
|
-
md: 'w-6 h-8 [--bd-dot:8px]',
|
|
10
|
-
}
|
|
11
|
-
|
|
12
5
|
/**
|
|
13
6
|
* ParamBindDot — Show a param is bound and open its menu. the small dot beside a param row: hollow at rest,
|
|
14
7
|
* filled in the accent once the param is bound (modulated); a click opens a menu of actions.
|
|
@@ -39,8 +32,54 @@ const SIZE = {
|
|
|
39
32
|
* @param {'start'|'end'} [align='end'] - The menu's edge against the dot
|
|
40
33
|
* @param {number} [minWidth=180] - The menu's minimum width
|
|
41
34
|
* @param {string} [className] - Extra classes on the trigger
|
|
35
|
+
*
|
|
36
|
+
* ONE DOT, ITS LOOK THE THEME'S (plan-2026-11-29-one-set-fold W2 run 4): the hit box, the dot, its ring and the focus line are
|
|
37
|
+
* `--kol-bind-*` (kol-theme `.kol-param-bind-dot`), the default theme leaving them unset (the rung's box and dot, a 1.5
|
|
38
|
+
* ring in oq-48, oq-80 on hover and open, the quiet focus line) and `data-theme-variant="kolbox"` setting kolbox's (a 6
|
|
39
|
+
* dot in a round 16 box at every rung, a 1px ring in oq-64, the accent focus line). The menu is the one `Menu` with
|
|
40
|
+
* `items` (kolbox's `{ label, checked, onClick }` rows are Menu rows). `variant="kolbox"` and `"folio"` still open kolbox's
|
|
41
|
+
* Menu (the bridge below); the old branch is in `_tmp/2026-11-29-one-set-fold/ParamBindDot.pre-fields3.jsx`.
|
|
42
42
|
*/
|
|
43
|
-
|
|
43
|
+
const THEME_WORDS = ['kolbox', 'folio']
|
|
44
|
+
export default function ParamBindDot({ variant, ...props }) {
|
|
45
|
+
/* bridge: a theme word keeps kolbox's Menu until W3's Menu fold removes this bridge */
|
|
46
|
+
return THEME_WORDS.includes(variant) ? <ParamBindDotMenuBridge {...props} /> : <ParamBindDotMenu {...props} />
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/* the dot itself, the same button for both menus */
|
|
50
|
+
const Dot = forwardRef(function Dot({ bound, className = '', size = 'sm', accent, open, ...rest }, ref) {
|
|
51
|
+
return (
|
|
52
|
+
<button
|
|
53
|
+
ref={ref}
|
|
54
|
+
type="button"
|
|
55
|
+
data-accent={accent === 'secondary' ? accent : undefined}
|
|
56
|
+
data-size={['xs', 'sm', 'md'].includes(size) ? size : 'sm'}
|
|
57
|
+
{...rest}
|
|
58
|
+
className={`kol-param-bind-dot group inline-flex shrink-0 items-center justify-center p-0 border-0 bg-transparent cursor-pointer outline-none${open ? ' is-open' : ''} ${className}`.trim()}
|
|
59
|
+
>
|
|
60
|
+
<span aria-hidden="true" className={`kol-bind-dot-mark block rounded-full border-solid transition-colors${bound ? ' is-bound' : ''}`} />
|
|
61
|
+
</button>
|
|
62
|
+
)
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
/* the kolbox Menu bridge, as the pre-fields3 kolbox build wired it: "Modulate" (or `tooltip`), Menu kolbox beside the dot,
|
|
66
|
+
`items` ({ label, checked, onClick }) as one group */
|
|
67
|
+
function ParamBindDotMenuBridge({ bound = false, items = [], label, tooltip, size, minWidth = 180, className, accent }) {
|
|
68
|
+
const ref = useRef(null)
|
|
69
|
+
const [open, setOpen] = useState(false)
|
|
70
|
+
return (
|
|
71
|
+
<>
|
|
72
|
+
<Tooltip label={tooltip ?? 'Modulate'}>
|
|
73
|
+
<Dot ref={ref} bound={bound} size={size} className={className} accent={accent} open={open} data-bind-dot
|
|
74
|
+
aria-label={`Modulate${label ? ` ${label}` : ''}`} aria-haspopup="menu" aria-expanded={open} onClick={() => setOpen((o) => !o)} />
|
|
75
|
+
</Tooltip>
|
|
76
|
+
<Menu variant="kolbox" accent={accent} aria-label="Modulate" anchor={ref} open={open} onClose={() => setOpen(false)} minWidth={minWidth}
|
|
77
|
+
groups={[items.map((it, i) => ({ label: it.label, value: i, check: !!it.checked }))]} onSelect={(r) => items[r.value]?.onClick?.()} />
|
|
78
|
+
</>
|
|
79
|
+
)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function ParamBindDotMenu({
|
|
44
83
|
bound = false,
|
|
45
84
|
mode,
|
|
46
85
|
items = [],
|
|
@@ -57,52 +96,8 @@ function ParamBindDotDefault({
|
|
|
57
96
|
return (
|
|
58
97
|
<Menu align={align} minWidth={minWidth} items={items} trigger={({ open, props }) => (
|
|
59
98
|
<Tooltip label={open ? null : tip}>
|
|
60
|
-
<
|
|
61
|
-
type="button"
|
|
62
|
-
aria-label={name}
|
|
63
|
-
data-accent={accent === 'secondary' ? accent : undefined}
|
|
64
|
-
{...props}
|
|
65
|
-
className={[
|
|
66
|
-
'kol-param-bind-dot group inline-flex shrink-0 items-center justify-center p-0 border-0 bg-transparent cursor-pointer rounded-[var(--kol-radius-2)] outline-none',
|
|
67
|
-
'focus-visible:outline focus-visible:outline-1 focus-visible:outline-[var(--kol-focus-ring-quiet)]',
|
|
68
|
-
SIZE[size] ?? SIZE.sm,
|
|
69
|
-
className,
|
|
70
|
-
].filter(Boolean).join(' ')}
|
|
71
|
-
>
|
|
72
|
-
<span
|
|
73
|
-
aria-hidden="true"
|
|
74
|
-
className={`block rounded-full border-[1.5px] border-solid transition-colors size-[var(--bd-dot)] ${bound
|
|
75
|
-
? 'bg-[var(--kol-accent-primary)] border-[var(--kol-accent-primary)]'
|
|
76
|
-
: `bg-transparent group-hover:border-[var(--kol-oq-80)] ${open ? 'border-[var(--kol-oq-80)]' : 'border-[var(--kol-oq-48)]'}`}`}
|
|
77
|
-
/>
|
|
78
|
-
</button>
|
|
99
|
+
<Dot aria-label={name} bound={bound} size={size} className={className} accent={accent} open={open} {...props} />
|
|
79
100
|
</Tooltip>
|
|
80
101
|
)} />
|
|
81
102
|
)
|
|
82
103
|
}
|
|
83
|
-
|
|
84
|
-
/* kolbox (plan-2026-11-18-kolbox-system W31.2 batch 5, 2026-11-18): kolbox's BindDot (round 4, W5), its drawing carried
|
|
85
|
-
* from apps/kolbox/src/labs/Params.jsx (the binding itself stays the caller's): a 16 hit box, a 6 dot hollow on the muted
|
|
86
|
-
* ring, filled in the accent once `bound`; the kolbox Tooltip (`tooltip`, else "Modulate"); a press opens Menu kolbox
|
|
87
|
-
* beside it with `items` ({ label, checked, onClick }) as one group. */
|
|
88
|
-
function ParamBindDotKolbox({ bound = false, items = [], label, tooltip, minWidth = 180, accent }) {
|
|
89
|
-
const ref = useRef(null)
|
|
90
|
-
const [open, setOpen] = useState(false)
|
|
91
|
-
return (
|
|
92
|
-
<>
|
|
93
|
-
<Tooltip variant="kolbox" label={tooltip ?? 'Modulate'}>
|
|
94
|
-
<button ref={ref} type="button" aria-label={`Modulate${label ? ` ${label}` : ''}`} aria-haspopup="menu" aria-expanded={open} data-bind-dot data-accent={accent === 'secondary' ? accent : undefined}
|
|
95
|
-
onClick={() => setOpen((o) => !o)}
|
|
96
|
-
className="kol-bind-dot--kolbox inline-flex size-4 shrink-0 items-center justify-center rounded-full outline-none focus-visible:outline-solid focus-visible:outline-1">
|
|
97
|
-
<span className={`kol-bind-dot-mark${bound ? ' is-bound' : ''} size-1.5 rounded-full`} />
|
|
98
|
-
</button>
|
|
99
|
-
</Tooltip>
|
|
100
|
-
<Menu variant="kolbox" accent={accent} aria-label="Modulate" anchor={ref} open={open} onClose={() => setOpen(false)} minWidth={minWidth}
|
|
101
|
-
groups={[items.map((it, i) => ({ label: it.label, value: i, check: !!it.checked }))]} onSelect={(r) => items[r.value]?.onClick?.()} />
|
|
102
|
-
</>
|
|
103
|
-
)
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
export default function ParamBindDot(props) {
|
|
107
|
-
return props.variant === 'kolbox' ? <ParamBindDotKolbox {...props} /> : <ParamBindDotDefault {...props} />
|
|
108
|
-
}
|
|
@@ -1,58 +1,53 @@
|
|
|
1
1
|
import { useEffect, useState } from 'react'
|
|
2
|
+
import Input, { useFieldCommit, selectOnFirstPress } from '../atoms/Input.jsx'
|
|
3
|
+
import Button from '../atoms/Button.jsx'
|
|
2
4
|
|
|
3
5
|
/**
|
|
4
|
-
* QuantityInput — Pick a whole-number quantity. a compact integer quantity picker with
|
|
6
|
+
* QuantityInput — Pick a whole-number quantity. a compact integer quantity picker with three control layouts.
|
|
5
7
|
*
|
|
6
8
|
* controls="chevron" (default) — value with a stacked up/down chevron pair
|
|
7
9
|
* on the right, inside a full-width field.
|
|
8
10
|
* controls="split" — a − value + pill (minus and plus flank the
|
|
9
11
|
* value). The former `QuantityStepper`.
|
|
12
|
+
* controls="field" — the value in an `Input` (sm) between two icon `Button`s, − and +
|
|
13
|
+
* (your icons' `minus` and `plus`), 4 apart, the root as wide as its row:
|
|
14
|
+
* kolbox's stepper, every theme's since W2 run 2 (their look the theme's).
|
|
10
15
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* (sm < 768 ≤ md < 1024 ≤ lg) unless `size` pins it. Controlled: `value` +
|
|
14
|
-
* `
|
|
16
|
+
* The value is typed in every layout (kolbox's, adopted in W2 run 2): Enter or leaving commits it, held to
|
|
17
|
+
* [min, max] and snapped to `step`; Escape restores; ArrowUp and ArrowDown step it. Size auto-adapts to the
|
|
18
|
+
* viewport (sm < 768 ≤ md < 1024 ≤ lg) unless `size` pins it. Controlled: `value` + `(next) => onChange`.
|
|
19
|
+
* `variant="kolbox"` and `"folio"` are accepted and draw `controls="field"` (plan-2026-11-29-one-set-fold W2 run 2;
|
|
20
|
+
* the old branches are in `_tmp/2026-11-29-one-set-fold/`).
|
|
15
21
|
*
|
|
16
22
|
* @param {number} value current quantity (default 1)
|
|
17
23
|
* @param {Function} onChange (next) => void
|
|
18
24
|
* @param {number} min lower bound (default 1)
|
|
19
25
|
* @param {number} max upper bound (default 99)
|
|
20
|
-
* @param {string} controls 'chevron' (default) | 'split'
|
|
26
|
+
* @param {string} controls 'chevron' (default) | 'split' | 'field'
|
|
21
27
|
* @param {string} size 'sm' | 'md' | 'lg' — pins the responsive size
|
|
22
28
|
* @param {string} unit a word after the value (`22 px`)
|
|
23
29
|
* @param {string} ariaLabel what the value is; the − + read `Decrease <it>` / `Increase <it>` (default quantity)
|
|
24
|
-
* @param {
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* @param {
|
|
28
|
-
* @param {ReactNode}
|
|
29
|
-
* @param {ReactNode} up FOLIO: the + square's text (`A+`)
|
|
30
|
-
* @param {string} downLabel FOLIO: the − square's name (`Smaller text`)
|
|
31
|
-
* @param {string} upLabel FOLIO: the + square's name (`Larger text`)
|
|
32
|
-
* @param {'kolbox'} variant also `kolbox` (Folio on kolbox, 2026-11-22): kolbox has no stepper of its own, so it is built
|
|
33
|
-
* from its parts: `Input variant="kolbox"` (its sm field, `--kol-kolbox-ctl` high: the value
|
|
34
|
-
* in mono with `unit` after it, typed and committed on Enter or leaving, ↑↓ step it) between
|
|
35
|
-
* two kolbox icon Buttons, − and + (your icons' `minus` and `plus`), 4 apart, the root as wide
|
|
36
|
-
* as its row. `step`, `min`, `max` as folio's: a typed value is held to the range and the step;
|
|
37
|
-
* a button at a bound is disabled. `downLabel`, `upLabel` name the buttons (else
|
|
38
|
-
* `Decrease <ariaLabel>`, `Increase <ariaLabel>`); `down`, `up` are not drawn (the set's glyphs are)
|
|
30
|
+
* @param {number} step how far one press moves the value in `field` (default 1); a typed value snaps to it
|
|
31
|
+
* @param {string} downLabel the − button's name in `field` (else `Decrease <ariaLabel>`)
|
|
32
|
+
* @param {string} upLabel the + button's name in `field` (else `Increase <ariaLabel>`)
|
|
33
|
+
* @param {ReactNode} down accepted, not drawn (folio's square text; the set's glyphs are)
|
|
34
|
+
* @param {ReactNode} up accepted, not drawn
|
|
39
35
|
* @param {string} className extra classes on the root
|
|
40
36
|
*/
|
|
41
|
-
import Input from '../atoms/Input.jsx'
|
|
42
|
-
import Button from '../atoms/Button.jsx'
|
|
43
|
-
|
|
44
37
|
const SIZE_MAP = {
|
|
45
38
|
sm: { fontSize: 11, paddingY: 12, paddingX: 24, radius: 20, icon: 10 },
|
|
46
39
|
md: { fontSize: 12, paddingY: 14, paddingX: 24, radius: 22, icon: 12 },
|
|
47
40
|
lg: { fontSize: 14, paddingY: 16, paddingX: 24, radius: 24, icon: 14 },
|
|
48
41
|
}
|
|
49
42
|
|
|
43
|
+
const THEME_WORDS = ['kolbox', 'folio']
|
|
44
|
+
|
|
50
45
|
const QuantityInput = ({
|
|
51
46
|
value = 1,
|
|
52
47
|
onChange,
|
|
53
48
|
min = 1,
|
|
54
49
|
max = 99,
|
|
55
|
-
controls = 'chevron',
|
|
50
|
+
controls: controlsProp = 'chevron',
|
|
56
51
|
size,
|
|
57
52
|
variant,
|
|
58
53
|
unit,
|
|
@@ -92,32 +87,28 @@ const QuantityInput = ({
|
|
|
92
87
|
return () => window.removeEventListener('resize', updateWidth)
|
|
93
88
|
}, [])
|
|
94
89
|
|
|
90
|
+
/* the old theme words: accepted, they draw the field stepper they drew (on the retirement ledger) */
|
|
91
|
+
const controls = THEME_WORDS.includes(variant) ? 'field' : controlsProp
|
|
95
92
|
const metrics = SIZE_MAP[resolvedSize] || SIZE_MAP.md
|
|
96
93
|
const increment = () => { if (value < max) onChange?.(value + 1) }
|
|
97
94
|
const decrement = () => { if (value > min) onChange?.(value - 1) }
|
|
98
95
|
|
|
99
|
-
/*
|
|
100
|
-
|
|
101
|
-
if (
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
<button type="button" aria-label={upLabel} disabled={value >= max} onClick={() => onChange?.(value + step)} className={stepCls}>{up}</button>
|
|
108
|
-
</div>
|
|
109
|
-
)
|
|
110
|
-
}
|
|
96
|
+
/* a typed value, held to the range and snapped to the step (kolbox's, every layout's since W2 run 2) */
|
|
97
|
+
const to = (n) => Math.min(max, Math.max(min, min + Math.round((n - min) / step) * step))
|
|
98
|
+
const commit = (text) => { const n = parseFloat(text); if (Number.isFinite(n) && to(n) !== value) onChange?.(to(n)) }
|
|
99
|
+
const field = useFieldCommit(value, commit)
|
|
100
|
+
const typed = (style) => (
|
|
101
|
+
<input type="text" inputMode="numeric" aria-label={ariaLabel} spellCheck={false} {...field} onMouseDown={selectOnFirstPress}
|
|
102
|
+
style={{ fieldSizing: 'content', padding: 0, border: 'none', outline: 'none', background: 'transparent', ...style }} />
|
|
103
|
+
)
|
|
111
104
|
|
|
112
|
-
/* kolbox
|
|
113
|
-
if (
|
|
114
|
-
const to = (n) => Math.min(max, Math.max(min, min + Math.round((n - min) / step) * step))
|
|
115
|
-
const commit = (text) => { const n = parseFloat(text); if (Number.isFinite(n) && to(n) !== value) onChange?.(to(n)) }
|
|
105
|
+
/* controls="field" (kolbox's stepper, Folio on kolbox 2026-11-22): the field between its two icon buttons */
|
|
106
|
+
if (controls === 'field') {
|
|
116
107
|
return (
|
|
117
108
|
<div className={`flex min-w-0 items-center gap-1 ${className}`.trim()}>
|
|
118
|
-
<Button
|
|
119
|
-
<Input
|
|
120
|
-
<Button
|
|
109
|
+
<Button iconOnly="minus" aria-label={downLabel ?? `Decrease ${ariaLabel}`} disabled={value <= min} onClick={() => onChange?.(to(value - step))} />
|
|
110
|
+
<Input size="sm" aria-label={ariaLabel} value={value} onCommit={commit} suffix={unit} className="flex-1" />
|
|
111
|
+
<Button iconOnly="plus" aria-label={upLabel ?? `Increase ${ariaLabel}`} disabled={value >= max} onClick={() => onChange?.(to(value + step))} />
|
|
121
112
|
</div>
|
|
122
113
|
)
|
|
123
114
|
}
|
|
@@ -146,7 +137,7 @@ const QuantityInput = ({
|
|
|
146
137
|
}}
|
|
147
138
|
>
|
|
148
139
|
<button type="button" onClick={decrement} disabled={value <= min} style={btn(value <= min)} aria-label="Decrease quantity">−</button>
|
|
149
|
-
|
|
140
|
+
{typed({ minWidth: '24px', textAlign: 'center', color: 'var(--kol-surface-on-primary)', fontFamily: 'var(--kol-font-family-mono)', fontSize: `${metrics.fontSize}px`, lineHeight: '120%' })}
|
|
150
141
|
<button type="button" onClick={increment} disabled={value >= max} style={btn(value >= max)} aria-label="Increase quantity">+</button>
|
|
151
142
|
</div>
|
|
152
143
|
)
|
|
@@ -168,7 +159,7 @@ const QuantityInput = ({
|
|
|
168
159
|
fontFamily: 'var(--kol-font-family-mono)', boxSizing: 'border-box',
|
|
169
160
|
}}
|
|
170
161
|
>
|
|
171
|
-
|
|
162
|
+
{typed({ color: 'inherit', font: 'inherit', lineHeight: 'inherit' })}
|
|
172
163
|
<div style={{ position: 'absolute', right: `${metrics.paddingX}px`, top: '50%', transform: 'translateY(-50%)', display: 'flex', flexDirection: 'column' }}>
|
|
173
164
|
<button type="button" onClick={increment} disabled={value >= max} style={{ backgroundColor: 'transparent', border: 'none', padding: '0', cursor: value >= max ? 'not-allowed' : 'pointer', opacity: value >= max ? 0.3 : 1, lineHeight: 0, display: 'block' }} aria-label="Increase quantity">
|
|
174
165
|
<svg width={metrics.icon} height={metrics.icon} viewBox="0 0 12 12" fill="none">
|
package/src/molecules/Slider.jsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useCallback, useEffect, useId, useMemo, useRef, useState } from 'react'
|
|
2
|
-
import Input
|
|
2
|
+
import Input from '../atoms/Input.jsx'
|
|
3
3
|
import SliderPanel from './SliderPanel.jsx'
|
|
4
4
|
import LabeledControl from './LabeledControl.jsx'
|
|
5
5
|
|
|
@@ -47,9 +47,8 @@ import LabeledControl from './LabeledControl.jsx'
|
|
|
47
47
|
* @param {Object} props.style - forwarded to the wrapper; the seam for `--kol-slider-track` / `--kol-slider-playhead`
|
|
48
48
|
* @param {number} props.defaultValue - alt-click the control resets to this (falls back to `min`). Same contract on Knob
|
|
49
49
|
* @param {'input'|'value'|'none'} props.readout - `input` (default) an editable Input · `value` a plain right-aligned span, Knob's own display-only readout · `none`.
|
|
50
|
-
* @param {'minimal'|'dual'|'scrub'|'panel'
|
|
51
|
-
* @param {
|
|
52
|
-
* @param {number[]} props.stops - kolbox only: values marked on the track, a 2 mark each under the thumb's centre (a variable font's named weights)
|
|
50
|
+
* @param {'minimal'|'dual'|'scrub'|'panel'} props.variant - `dual` = two thumbs on one rail; `scrub` = a media scrubber: the thin track with the 4 × 28 pill knob (`.kol-playback-scrub`; `PlaybackBar`'s, 2026-10-02); `panel` = the rack slider (was kol-hardware `Fader`, merged 2026-10-01): a drawn 2px track for a hardware panel; takes `value`, `onChange`, `min`, `max`, `step` and `label` plus `onHold`. `kolbox` and `folio` are accepted and draw `minimal` with the `value` readout by default (plan-2026-11-29-one-set-fold W2 run 2): ONE SLIDER, ITS LOOK THE THEME'S, the row's gap, the range's hit height and field, the run, the readout's width, padding and type are `--kol-slider-*` (kol-theme, Slider); the default theme leaves them unset, `data-theme-variant="kolbox"` sets kolbox's (the 2px oq-24 track with the run in the ink, a 16 range, the value mono 12 / 16 40 wide; with the `input` readout the track in an oq-16 field and the number 2 apart, at least 48). The old branches are in `_tmp/2026-11-29-one-set-fold/`
|
|
51
|
+
* @param {number[]} props.stops - values marked on the track, a 2 mark each under the thumb's centre (a variable font's named weights); every horizontal slider's since W2 run 2
|
|
53
52
|
* @param {'horizontal'|'vertical'} props.direction - `vertical` stands the track upright at `height`, label above and readout below (2026-10-02 — the volume ranges were hand-drawn for want of it). On `panel`, horizontal takes the row and shows a readout
|
|
54
53
|
* @param {number} props.height - vertical only — the track's length in px (default 96; panel 60)
|
|
55
54
|
* @param {string} props['aria-label'] - names the range when there is no visible `label`
|
|
@@ -61,83 +60,9 @@ import LabeledControl from './LabeledControl.jsx'
|
|
|
61
60
|
* @param {number|null} props.playhead - dual only — marker position in min…max; null renders nothing and attaches no listeners
|
|
62
61
|
* @param {Function} props.onPlayheadChange - dual only — (next: number) => void; omit and the marker is not draggable and the rail does not seek
|
|
63
62
|
*/
|
|
64
|
-
/* `variant
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
* and at least 48. The number is a text field, not type="number": Chrome draws a number field's value in the OS
|
|
68
|
-
* region's format ("0,08" on an Icelandic Mac) whatever the page's lang. A draft holds what is typed until it reads
|
|
69
|
-
* as a number; kolbox's field keys: one press selects it, the arrows step it (Shift ten steps), Escape restores the value
|
|
70
|
-
* from before the edit. Chrome in kol-theme `.kol-slider--kolbox`. */
|
|
71
|
-
function SliderKolbox({ value, min, max, step, onChange, formatValue, readout = 'value', ariaLabel, stops, className = '', accent }) {
|
|
72
|
-
const [draft, setDraft] = useState(null)
|
|
73
|
-
const before = useRef(value)
|
|
74
|
-
const format = formatValue ?? ((v) => v)
|
|
75
|
-
const p = Math.min(100, Math.max(0, ((value - min) / (max - min)) * 100))
|
|
76
|
-
/* a stop: a 2 mark on the track, under the thumb's centre at that value (the thumb is 12, so its centre runs 6 to
|
|
77
|
-
the width less 6) */
|
|
78
|
-
const marks = stops?.length > 0 && stops.map((v) => (
|
|
79
|
-
<span key={v} data-slider-stop={v} className="pointer-events-none absolute top-1/2 size-0.5 -translate-x-1/2 -translate-y-1/2 rounded-full bg-oq-64"
|
|
80
|
-
style={{ left: `calc(6px + (100% - 12px) * ${(v - min) / (max - min)})` }} />
|
|
81
|
-
))
|
|
82
|
-
const input = (
|
|
83
|
-
<input
|
|
84
|
-
type="range"
|
|
85
|
-
className="kol-slider-input min-w-0 flex-1"
|
|
86
|
-
style={{ '--p': `${p}%` }}
|
|
87
|
-
aria-label={ariaLabel}
|
|
88
|
-
value={value}
|
|
89
|
-
min={min}
|
|
90
|
-
max={max}
|
|
91
|
-
step={step}
|
|
92
|
-
onChange={(e) => onChange?.(Number(e.target.value))}
|
|
93
|
-
/>
|
|
94
|
-
)
|
|
95
|
-
const range = marks ? <span className="relative flex min-w-0 flex-1 items-center">{input}{marks}</span> : input
|
|
96
|
-
if (readout === 'input') {
|
|
97
|
-
return (
|
|
98
|
-
<div data-accent={accent === 'secondary' ? accent : undefined} className={`kol-slider--kolbox flex h-(--kol-kolbox-ctl) min-w-0 items-center gap-0.5 ${className}`}>
|
|
99
|
-
<div className="kol-slider-field flex h-(--kol-kolbox-ctl) min-w-0 flex-1 items-center px-2">{range}</div>
|
|
100
|
-
<input
|
|
101
|
-
type="text"
|
|
102
|
-
inputMode="decimal"
|
|
103
|
-
aria-label={ariaLabel}
|
|
104
|
-
className="kol-slider-number field-sizing-content h-(--kol-kolbox-ctl) min-w-12 shrink-0 px-2 text-left outline-none focus-visible:outline-1 focus-visible:-outline-offset-1"
|
|
105
|
-
value={draft ?? String(format(value))}
|
|
106
|
-
onChange={(e) => {
|
|
107
|
-
/* parseFloat: a formatted value keeps its unit while it is typed ("45°") */
|
|
108
|
-
const s = e.target.value, n = parseFloat(s)
|
|
109
|
-
setDraft(s)
|
|
110
|
-
if (s.trim() !== '' && Number.isFinite(n)) onChange?.(n)
|
|
111
|
-
}}
|
|
112
|
-
onMouseDown={selectOnFirstPress}
|
|
113
|
-
onFocus={() => { before.current = value }}
|
|
114
|
-
onBlur={() => setDraft(null)}
|
|
115
|
-
onKeyDown={(e) => {
|
|
116
|
-
if (e.key === 'Enter') { e.preventDefault(); e.currentTarget.blur(); return }
|
|
117
|
-
/* Escape puts back the value from before the edit and leaves the field (kolbox's field, useKolboxField) */
|
|
118
|
-
if (e.key === 'Escape') { e.preventDefault(); e.stopPropagation(); setDraft(null); if (before.current !== value) onChange?.(before.current); e.currentTarget.blur(); return }
|
|
119
|
-
if (e.key !== 'ArrowUp' && e.key !== 'ArrowDown') return
|
|
120
|
-
e.preventDefault()
|
|
121
|
-
const dec = String(step).split('.')[1]?.length ?? 0
|
|
122
|
-
const by = (e.shiftKey ? 10 : 1) * (e.key === 'ArrowUp' ? step : -step)
|
|
123
|
-
const n = Math.min(max, Math.max(min, value + by))
|
|
124
|
-
setDraft(null)
|
|
125
|
-
before.current = Number(n.toFixed(dec))
|
|
126
|
-
onChange?.(before.current)
|
|
127
|
-
const el = e.currentTarget
|
|
128
|
-
requestAnimationFrame(() => { if (document.activeElement === el) el.select() })
|
|
129
|
-
}}
|
|
130
|
-
/>
|
|
131
|
-
</div>
|
|
132
|
-
)
|
|
133
|
-
}
|
|
134
|
-
return (
|
|
135
|
-
<div data-accent={accent === 'secondary' ? accent : undefined} className={`kol-slider--kolbox flex h-(--kol-kolbox-ctl) min-w-0 items-center gap-3 ${className}`}>
|
|
136
|
-
{range}
|
|
137
|
-
<span className="kol-slider-value w-10 shrink-0 text-right">{format(value)}</span>
|
|
138
|
-
</div>
|
|
139
|
-
)
|
|
140
|
-
}
|
|
63
|
+
/* the old theme words in `variant`: accepted, drawn as the minimal slider with their old default readout, `value`
|
|
64
|
+
(plan-2026-11-29-one-set-fold W2 run 2, on the retirement ledger) */
|
|
65
|
+
const THEME_WORDS = ['kolbox', 'folio']
|
|
141
66
|
|
|
142
67
|
const Slider = ({
|
|
143
68
|
label,
|
|
@@ -173,6 +98,9 @@ const Slider = ({
|
|
|
173
98
|
/* Label ↔ input pairing — the <label> is a sibling of the range input, so
|
|
174
99
|
* without an htmlFor/id pair the visible label confers no accessible name. */
|
|
175
100
|
const sliderId = useId()
|
|
101
|
+
const themeWord = THEME_WORDS.includes(variant)
|
|
102
|
+
if (themeWord) variant = 'minimal'
|
|
103
|
+
const readoutKind = readout ?? (themeWord ? 'value' : 'input')
|
|
176
104
|
|
|
177
105
|
const handleChange = (e) => {
|
|
178
106
|
if (onChange) {
|
|
@@ -239,8 +167,10 @@ const Slider = ({
|
|
|
239
167
|
[onPlayheadChange, seekTo],
|
|
240
168
|
)
|
|
241
169
|
|
|
170
|
+
const skipCommit = useRef(false)
|
|
242
171
|
const commit = () => {
|
|
243
172
|
setEditing(false)
|
|
173
|
+
if (skipCommit.current) { skipCommit.current = false; return }
|
|
244
174
|
/* parseFloat, so a formatted value typed back (`45°`, `0,5`) still reads; an empty field reverts */
|
|
245
175
|
const parsed = parseFloat(String(draft).replace(',', '.'))
|
|
246
176
|
if (!Number.isFinite(parsed) || onChange == null) {
|
|
@@ -252,9 +182,21 @@ const Slider = ({
|
|
|
252
182
|
setDraft(String(clamped))
|
|
253
183
|
}
|
|
254
184
|
|
|
185
|
+
/* the readout's keys, every slider's (kolbox's, adopted in W2 run 2): Enter commits, Escape puts back the value from
|
|
186
|
+
* before the edit and leaves the field, ArrowUp and ArrowDown move it one `step` (Shift ten) and commit at once */
|
|
255
187
|
const onKeyDown = (e) => {
|
|
256
188
|
if (e.key === 'Enter') { e.currentTarget.blur() }
|
|
257
|
-
if (e.key === 'Escape') { setDraft(displayValue); setEditing(false); e.currentTarget.blur() }
|
|
189
|
+
if (e.key === 'Escape') { e.preventDefault(); e.stopPropagation(); setDraft(displayValue); setEditing(false); skipCommit.current = true; e.currentTarget.blur() }
|
|
190
|
+
if ((e.key === 'ArrowUp' || e.key === 'ArrowDown') && onChange && !disabled) {
|
|
191
|
+
e.preventDefault()
|
|
192
|
+
const dec = String(step).split('.')[1]?.length ?? 0
|
|
193
|
+
const by = (e.shiftKey ? 10 : 1) * (e.key === 'ArrowUp' ? step : -step)
|
|
194
|
+
const next = Number(Math.min(max, Math.max(min, value + by)).toFixed(dec))
|
|
195
|
+
onChange(next)
|
|
196
|
+
setDraft(fmt(next))
|
|
197
|
+
const el = e.currentTarget
|
|
198
|
+
requestAnimationFrame(() => { if (document.activeElement === el) el.select() })
|
|
199
|
+
}
|
|
258
200
|
}
|
|
259
201
|
|
|
260
202
|
/* alt-click anywhere on the control resets — Knob carries the same
|
|
@@ -266,24 +208,6 @@ const Slider = ({
|
|
|
266
208
|
onChange(defaultValue ?? min)
|
|
267
209
|
}
|
|
268
210
|
|
|
269
|
-
if (variant === 'kolbox') {
|
|
270
|
-
return <SliderKolbox value={value} min={min} max={max} step={step} onChange={onChange} formatValue={formatValue} readout={readout} ariaLabel={ariaLabel} stops={stops} className={className} accent={accent} />
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
/* folio (Folio migration batch A, 2026-11-22): Folio's Slider carried class for class (apps/folio Chrome.jsx): a 24
|
|
274
|
-
* row, the native range (its track and thumb in kol-theme `.kol-slider--folio`), the value beside it, 32 wide */
|
|
275
|
-
if (variant === 'folio') {
|
|
276
|
-
const format = formatValue ?? ((n) => n)
|
|
277
|
-
const run = `${((value - min) / (max - min)) * 100}%`
|
|
278
|
-
return (
|
|
279
|
-
<div data-accent={accent === 'secondary' ? accent : undefined} className={`kol-slider--folio flex h-[24px] w-full items-center gap-[12px] ${className}`}>
|
|
280
|
-
<input type="range" min={min} max={max} step={step} value={value} onChange={handleChange} aria-label={ariaLabel} style={{ '--run': run }}
|
|
281
|
-
className="kol-slider-input h-[24px] min-w-0 flex-1 cursor-pointer appearance-none bg-transparent" />
|
|
282
|
-
<span className="kol-slider-value w-[32px] shrink-0 text-right tabular-nums">{format(value)}</span>
|
|
283
|
-
</div>
|
|
284
|
-
)
|
|
285
|
-
}
|
|
286
|
-
|
|
287
211
|
if (variant === 'panel') {
|
|
288
212
|
return <SliderPanel value={value} onChange={onChange} min={min} max={max} step={step} label={label} direction={direction} height={height} onHold={onHold} />
|
|
289
213
|
}
|
|
@@ -298,11 +222,11 @@ const Slider = ({
|
|
|
298
222
|
const labelClass = `kol-helper-12 text-fg-80 ${disabled ? 'opacity-50' : ''}`.trim()
|
|
299
223
|
const row = ({ className: cls, style: st, onClick, children }) => {
|
|
300
224
|
if (!label) return <div data-accent={accent === 'secondary' ? accent : undefined} className={cls} style={st} onClick={onClick}>{children}</div>
|
|
301
|
-
const outer = cls.split(/\s+/).filter((c) => !/^(control-slider|shadow-none|h-7)$/.test(c)).join(' ')
|
|
225
|
+
const outer = cls.split(/\s+/).filter((c) => !/^(control-slider|control-slider--input|shadow-none|h-7)$/.test(c)).join(' ')
|
|
302
226
|
return (
|
|
303
227
|
<LabeledControl data-accent={accent === 'secondary' ? accent : undefined} horizontal label={labelEl} labelWidth="fit-content" labelClass={labelClass}
|
|
304
228
|
className={`${/(^|\s)(hidden|block|flex|inline-flex|grid)(?=\s|$)/.test(outer) ? '' : 'inline-flex'} ${outer}`} style={st} onClick={onClick}>
|
|
305
|
-
<div className={`flex w-full ${cls.split(/\s+/).filter((c) => /^(control-slider|shadow-none|h-7
|
|
229
|
+
<div className={`flex w-full ${cls.split(/\s+/).filter((c) => /^(control-slider|control-slider--input|shadow-none|h-7)$/.test(c)).join(' ')}`}>{children}</div>
|
|
306
230
|
</LabeledControl>
|
|
307
231
|
)
|
|
308
232
|
}
|
|
@@ -316,7 +240,7 @@ const Slider = ({
|
|
|
316
240
|
/* an empty label is no label: `label1="" label2=""` (SettingsRange, RailSettings) drew an empty 16px row that pushed the rail low */
|
|
317
241
|
const showLabels = !!(label1 || label2)
|
|
318
242
|
const ratio = max > min ? (playhead - min) / (max - min) : 0
|
|
319
|
-
return row({ className: `control-slider
|
|
243
|
+
return row({ className: `control-slider shadow-none ${className}`, style, children: <>
|
|
320
244
|
<div className="flex-1">
|
|
321
245
|
{showLabels && (
|
|
322
246
|
<div
|
|
@@ -372,7 +296,7 @@ const Slider = ({
|
|
|
372
296
|
const scrub = variant === 'scrub'
|
|
373
297
|
const length = vertical ? height ?? 96 : size
|
|
374
298
|
|
|
375
|
-
const
|
|
299
|
+
const rangeInput = (
|
|
376
300
|
<input
|
|
377
301
|
id={sliderId}
|
|
378
302
|
type="range"
|
|
@@ -384,12 +308,24 @@ const Slider = ({
|
|
|
384
308
|
disabled={disabled}
|
|
385
309
|
aria-label={ariaLabel}
|
|
386
310
|
className={`${scrub ? 'kol-playback-scrub' : 'slider-black cursor-pointer disabled:cursor-default'} disabled:opacity-50 ${vertical ? '-rotate-90 flex-none' : length ? 'flex-none' : 'flex-1 w-full min-w-0'}`}
|
|
387
|
-
/* upright, the drag is vertical — so the page's pan is the horizontal one
|
|
388
|
-
|
|
311
|
+
/* upright, the drag is vertical — so the page's pan is the horizontal one. `--p` is the run's end, for a theme
|
|
312
|
+
* that draws the run (`--kol-slider-run`; kolbox the ink) */
|
|
313
|
+
style={{ '--p': `${Math.min(100, Math.max(0, ((value - min) / ((max - min) || 1)) * 100))}%`, ...(length && { width: length, ...(vertical && { touchAction: 'pan-x' }) }) }}
|
|
389
314
|
/>
|
|
390
315
|
)
|
|
316
|
+
/* a stop (kolbox's, every slider's since W2 run 2): a 2 mark on the track under the thumb's centre at that value (the
|
|
317
|
+
thumb is 12, so its centre runs 6 in from each end of the track, which sits `--kol-slider-field-px` in) */
|
|
318
|
+
const range = stops?.length > 0 && !vertical && !scrub ? (
|
|
319
|
+
<span className={`relative flex items-center ${length ? 'flex-none' : 'min-w-0 flex-1'}`}>
|
|
320
|
+
{rangeInput}
|
|
321
|
+
{stops.map((v) => (
|
|
322
|
+
<span key={v} data-slider-stop={v} className="pointer-events-none absolute top-1/2 size-0.5 -translate-x-1/2 -translate-y-1/2 rounded-full bg-oq-64"
|
|
323
|
+
style={{ left: `calc(var(--kol-slider-field-px, 0px) + 6px + (100% - 12px - 2 * var(--kol-slider-field-px, 0px)) * ${(v - min) / ((max - min) || 1)})` }} />
|
|
324
|
+
))}
|
|
325
|
+
</span>
|
|
326
|
+
) : rangeInput
|
|
391
327
|
|
|
392
|
-
const readoutNode =
|
|
328
|
+
const readoutNode = readoutKind === 'input' ? (
|
|
393
329
|
<Input
|
|
394
330
|
type="text"
|
|
395
331
|
inputMode="decimal"
|
|
@@ -399,18 +335,19 @@ const Slider = ({
|
|
|
399
335
|
chars={displayWidth}
|
|
400
336
|
value={draft}
|
|
401
337
|
disabled={disabled}
|
|
338
|
+
aria-label={ariaLabel}
|
|
402
339
|
onFocus={(e) => { setEditing(true); e.target.select() }}
|
|
403
340
|
onChange={(e) => setDraft(e.target.value)}
|
|
404
341
|
onBlur={commit}
|
|
405
342
|
onKeyDown={onKeyDown}
|
|
406
|
-
|
|
343
|
+
className="kol-slider-number"
|
|
407
344
|
/>
|
|
408
|
-
) :
|
|
345
|
+
) : readoutKind === 'value' ? (
|
|
409
346
|
/* `value` is Knob's readout, not a second design — a mixer running
|
|
410
347
|
* ~23 faders in a 24px row cannot afford an input chip on every one, and
|
|
411
348
|
* that is why the easy call sites could not move. */
|
|
412
349
|
<span
|
|
413
|
-
className={`kol-
|
|
350
|
+
className={`kol-slider-value shrink-0 ${disabled ? 'opacity-50' : ''}`}
|
|
414
351
|
style={fontSize ? { fontSize } : undefined}
|
|
415
352
|
>
|
|
416
353
|
{displayValue}
|
|
@@ -425,7 +362,7 @@ const Slider = ({
|
|
|
425
362
|
</> })
|
|
426
363
|
}
|
|
427
364
|
|
|
428
|
-
return row({ className: `control-slider
|
|
365
|
+
return row({ className: `control-slider shadow-none ${readoutKind === 'input' ? 'control-slider--input' : ''} ${scrub ? 'h-7' : ''} ${className}`, style, onClick: onAltReset, children: <>
|
|
429
366
|
{range}
|
|
430
367
|
{readoutNode}
|
|
431
368
|
</> })
|
|
@@ -35,6 +35,9 @@ import { Tooltip } from '../utilities/Popover.jsx'
|
|
|
35
35
|
/* Fixed chip slots inside the 44×44 stack — identical in both variants; only
|
|
36
36
|
* the render order changes. Positions live on absolutely-placed wrappers so
|
|
37
37
|
* ColorSwatch keeps its own `relative` root (its box-shadow halo needs it). */
|
|
38
|
+
/* theme words a caller may still pass; they draw `compact`, the build they named (W2 run 3) */
|
|
39
|
+
const THEME_WORDS = ['kolbox', 'folio']
|
|
40
|
+
|
|
38
41
|
const FILL_SLOT = 'left-[5px] top-[6px]'
|
|
39
42
|
const STROKE_SLOT = 'left-[15px] top-[16px]'
|
|
40
43
|
|
|
@@ -68,11 +71,13 @@ function PaintChip({ id, label, color, slot, onSwap }) {
|
|
|
68
71
|
* @param {'fill'|'stroke'} activePaint which chip paints on top. Default 'fill'
|
|
69
72
|
* @param {Function} onSwap () => void — either chip or the swap arrow
|
|
70
73
|
* @param {Function} onClear () => void — the "set to none" marker
|
|
71
|
-
* @param {'default'|'
|
|
72
|
-
* carried class for class
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
74
|
+
* @param {'default'|'compact'} variant `compact` (kolbox's SwatchStack, plan-2026-11-18-kolbox-system W31.2, 2026-11-18,
|
|
75
|
+
* carried class for class; a variant of its own since plan-2026-11-29-one-set-fold W2 run 3): the stack scaled into a
|
|
76
|
+
* 32 dock cell, 16 chips at 4 / 4 and 12 / 11, each with a halo of the ground then the theme's line
|
|
77
|
+
* (`--kol-swatch-stack-line`; unset fg-32, kolbox its line); the swap arrow (your icons' `swap`, 12) top right in oq-64,
|
|
78
|
+
* the ink on hover; the none marker an 8 disc of the ink with the error slash. Chrome in kol-theme
|
|
79
|
+
* `.kol-swatch-stack--compact`. `variant="kolbox"` and `"folio"` are accepted and draw `compact`.
|
|
80
|
+
* @param {string} className compact: extra classes on the stack
|
|
76
81
|
*/
|
|
77
82
|
export function SwatchStack({
|
|
78
83
|
fillColor = '#FFFFFF',
|
|
@@ -84,7 +89,7 @@ export function SwatchStack({
|
|
|
84
89
|
className = '',
|
|
85
90
|
accent,
|
|
86
91
|
}) {
|
|
87
|
-
if (variant === '
|
|
92
|
+
if (variant === 'compact' || THEME_WORDS.includes(variant)) {
|
|
88
93
|
const chip = (key, label, pos) => (
|
|
89
94
|
<button key={key} type="button" aria-label={label} onClick={onSwap} data-paint={label}
|
|
90
95
|
className={`kol-swatch-stack-chip absolute size-4 rounded-full outline-none focus-visible:outline-solid focus-visible:outline-1 ${pos}`}
|
|
@@ -93,7 +98,7 @@ export function SwatchStack({
|
|
|
93
98
|
const fill = chip('fill', 'Fill color', 'top-1 left-1')
|
|
94
99
|
const stroke = chip('stroke', 'Stroke color', 'top-3 left-[11px]')
|
|
95
100
|
return (
|
|
96
|
-
<div data-accent={accent === 'secondary' ? accent : undefined} className={`kol-swatch-stack--
|
|
101
|
+
<div data-accent={accent === 'secondary' ? accent : undefined} className={`kol-swatch-stack--compact relative size-8 shrink-0 ${className}`.trim()} data-swatch-stack={activePaint}>
|
|
97
102
|
{activePaint === 'fill' ? [stroke, fill] : [fill, stroke]}
|
|
98
103
|
<button type="button" aria-label="Swap colors" onClick={onSwap}
|
|
99
104
|
className="kol-swatch-stack-swap absolute top-0 right-0 inline-flex outline-none focus-visible:outline-solid focus-visible:outline-1">
|
|
@@ -10,16 +10,13 @@
|
|
|
10
10
|
* @param {string} [value] the current one
|
|
11
11
|
* @param {Function} [onChange] `(color)`
|
|
12
12
|
* @param {string} [className]
|
|
13
|
-
* @param {
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
13
|
+
* @param {React.ReactNode} [children] the caller's own swatches (`ColorSwatch`) instead of `colors`: a row of them, 8 apart,
|
|
14
|
+
* wrapping, a group named by `aria-label`; `colors`, `value` and `onChange` are not read. Was `variant="kolbox"` with
|
|
15
|
+
* children and `variant="folio"`; one row now (plan-2026-11-29-one-set-fold W2 run 3, the branches in
|
|
16
|
+
* _tmp/2026-11-29-one-set-fold/). `variant` is accepted and does nothing.
|
|
17
17
|
*/
|
|
18
|
-
export default function SwatchGrid({ colors = [], value, onChange, className = '',
|
|
19
|
-
|
|
20
|
-
8 apart as the grid's, wrapping; a group named by `aria-label` */
|
|
21
|
-
if (variant === 'kolbox' && children) return <div role="group" aria-label={rest['aria-label']} className={`flex flex-wrap gap-2 ${className}`.trim()}>{children}</div>
|
|
22
|
-
if (variant === 'folio') return <div role="group" aria-label={rest['aria-label']} className={`flex gap-[8px] ${className}`.trim()}>{children}</div>
|
|
18
|
+
export default function SwatchGrid({ colors = [], value, onChange, className = '', children, ...rest }) {
|
|
19
|
+
if (children) return <div role="group" aria-label={rest['aria-label']} className={`flex flex-wrap gap-2 ${className}`.trim()}>{children}</div>
|
|
23
20
|
return (
|
|
24
21
|
<div role="listbox" aria-label="Swatches" className={`grid grid-cols-8 gap-2 ${className}`}>
|
|
25
22
|
{colors.map((c) => (
|