@kolkrabbi/kol-component 0.378.0 → 0.379.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 +4 -3
- package/src/atoms/BezierPathEditor.jsx +1 -1
- package/src/atoms/Button.jsx +84 -1
- package/src/atoms/Figure.jsx +19 -1
- package/src/atoms/FunctionPlot.jsx +1 -1
- package/src/atoms/Input.jsx +105 -1
- package/src/atoms/Kbd.jsx +42 -2
- package/src/atoms/Link.jsx +20 -0
- package/src/atoms/OriginPicker.jsx +9 -5
- package/src/atoms/SectionFooter.jsx +22 -0
- package/src/atoms/SectionHeader.jsx +24 -0
- package/src/atoms/SizeOrDownload.jsx +1 -1
- package/src/atoms/Textarea.jsx +11 -2
- package/src/atoms/ToggleCheckbox.jsx +23 -1
- package/src/atoms/ToggleSwitch.jsx +39 -0
- package/src/atoms/ViewToggle.jsx +2 -2
- package/src/atoms/XYPad.jsx +25 -0
- package/src/hooks/useDragResize.js +1 -1
- package/src/index.js +26 -3
- package/src/molecules/AccountMenu.jsx +14 -1
- package/src/molecules/AlignmentGrid.jsx +13 -1
- package/src/molecules/ButtonGroup.jsx +73 -1
- package/src/molecules/ButtonSplit.jsx +64 -3
- package/src/molecules/Chip.jsx +26 -0
- package/src/molecules/CodeBlock.jsx +39 -2
- package/src/molecules/ColorInputRow.jsx +125 -4
- package/src/molecules/ColorSwatch.jsx +43 -2
- package/src/molecules/ContentCard.jsx +104 -3
- package/src/molecules/ContentMedia.jsx +1 -1
- package/src/molecules/ContentRow.jsx +3 -3
- package/src/molecules/DividerLabel.jsx +19 -0
- package/src/molecules/Dropdown.jsx +111 -1
- package/src/molecules/DropdownStepper.jsx +29 -0
- package/src/molecules/FieldPair.jsx +41 -2
- package/src/molecules/LabeledControl.jsx +51 -0
- package/src/molecules/Menu.jsx +239 -3
- package/src/molecules/Modal.jsx +214 -9
- package/src/molecules/ModalShell.jsx +18 -5
- package/src/molecules/OptionRow.jsx +1 -1
- package/src/molecules/ParamBindDot.jsx +29 -2
- package/src/molecules/QuantityInput.jsx +48 -0
- package/src/molecules/RailHeader.jsx +32 -2
- package/src/molecules/SectionText.jsx +54 -1
- package/src/molecules/Slider.jsx +101 -2
- package/src/molecules/SplitToolButton.jsx +4 -6
- package/src/molecules/SwatchControls.jsx +28 -0
- package/src/molecules/SwatchGrid.jsx +39 -0
- package/src/molecules/TabsDocument.jsx +131 -0
- package/src/molecules/TabsRow.jsx +35 -1
- package/src/molecules/Toast.jsx +55 -0
- package/src/molecules/TreeRow.jsx +87 -1
- package/src/organisms/AppItemMenuProvider.jsx +2 -2
- package/src/organisms/ColorPickerPopover.jsx +133 -4
- package/src/organisms/ColumnBrowser.jsx +1 -1
- package/src/organisms/CommandOverlay.jsx +396 -21
- package/src/organisms/FindBar.jsx +70 -0
- package/src/organisms/FramedMediaBand.jsx +2 -2
- package/src/organisms/GalleryCarousel.jsx +1 -1
- package/src/organisms/LogoSystem.jsx +38 -0
- package/src/organisms/LogoTuner.jsx +32 -0
- package/src/organisms/MediaLibrary.jsx +1 -1
- package/src/organisms/MediaLibraryPages.jsx +1 -1
- package/src/organisms/Rail.jsx +33 -1
- package/src/organisms/RailSwitcher.jsx +62 -0
- package/src/organisms/ReadingContents.jsx +63 -1
- package/src/organisms/SectionSplit.jsx +1 -1
- package/src/organisms/SettingsPanel.jsx +45 -1
- package/src/organisms/ShortcutsOverlay.jsx +46 -2
- package/src/organisms/SpectrumControls.jsx +112 -19
- package/src/organisms/StatusBar.jsx +30 -0
- package/src/organisms/Table.jsx +141 -2
- package/src/organisms/TimelineDock.jsx +281 -1
- package/src/organisms/logoBoard.jsx +61 -0
- package/src/utilities/AssetPlaceholder.jsx +1 -1
- package/src/utilities/EditorShell.jsx +42 -1
- package/src/utilities/OverlayGlassPanel.jsx +1 -1
- package/src/utilities/Popover.jsx +298 -2
- package/src/utilities/SelectionOverlay.jsx +74 -1
- package/src/utilities/kolboxGlyph.jsx +10 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { forwardRef } from 'react'
|
|
2
|
+
import { KolboxShell } from '../utilities/Popover.jsx'
|
|
2
3
|
|
|
3
4
|
/* taxonomy-ok: molecule — the modal family's panel: the surface every modal, dialog and sheet window draws its parts on */
|
|
4
5
|
|
|
@@ -13,14 +14,20 @@ import { forwardRef } from 'react'
|
|
|
13
14
|
* …body
|
|
14
15
|
* </ModalShell>
|
|
15
16
|
*
|
|
16
|
-
* ONE RADIUS: `--kol-radius-
|
|
17
|
+
* ONE RADIUS: `--kol-radius-4` (4px) — the radius Modal's prompts and Dialog wore. The float style's windows keep the
|
|
17
18
|
* float window radius (`float`, 28) and the generator settings window its 20 (`settings`, no outer border — his mock 143:35343, plan-2026-11-12-one-header W8.1); both are the float style's
|
|
18
19
|
* own, drawn in its Figma.
|
|
19
20
|
*
|
|
20
|
-
* @param {'lift'|'bordered'|'float'|'settings'} [variant='lift']
|
|
21
|
+
* @param {'lift'|'bordered'|'float'|'settings'|'kolbox'|'folio'} [variant='lift']
|
|
21
22
|
* `lift` — the overlay panel every KOL overlay wears (`.kol-overlay-panel`: oq-04, no border, the scrim is the edge);
|
|
22
23
|
* `bordered` — the page surface behind an fg-08 hairline (Modal's prompts); `float` — the float window
|
|
23
24
|
* (`kol-float-solid`); `settings` — the generator settings window (the secondary surface, radius 20, the float shadow, no border).
|
|
25
|
+
* `kolbox` (plan-2026-11-18-kolbox-system W31.2 batch 4, 2026-11-18) — kolbox's panel shell (its PopoverShell, carried
|
|
26
|
+
* line for line): radius 16, the secondary surface on the one floating surface, 240 wide (`--kol-kolbox-popover-w`)
|
|
27
|
+
* unless `width` says; it draws its own header from `leading`, `title`, `actions` and the close (`onClose`), the body,
|
|
28
|
+
* and `footer` as a row of buttons; `aria-label` defaults to the title. The panel every kolbox popover and window is.
|
|
29
|
+
* `folio` (Folio migration batch B, 2026-11-22) — Folio's overlay panel: `bordered`'s hairline and radius 4 on Folio's
|
|
30
|
+
* paper and rule (`.kol-modal--folio`); its ink and shadow are the caller's (the search modal's, the dialog's).
|
|
24
31
|
* @param {ReactNode} [header] drawn first
|
|
25
32
|
* @param {ReactNode} [footer] drawn last
|
|
26
33
|
* @param {string} [className] the caller's layout: padding, gap, size
|
|
@@ -28,13 +35,19 @@ import { forwardRef } from 'react'
|
|
|
28
35
|
* Any other prop (role, aria-*, onMouseDown, data-*) lands on the panel; the ref is the panel.
|
|
29
36
|
*/
|
|
30
37
|
const VARIANTS = {
|
|
31
|
-
lift: { className: 'kol-overlay-panel rounded-[var(--kol-radius-
|
|
32
|
-
bordered: { className: 'border border-fg-08 rounded-[var(--kol-radius-
|
|
38
|
+
lift: { className: 'kol-overlay-panel rounded-[var(--kol-radius-4)]', style: {} },
|
|
39
|
+
bordered: { className: 'border border-fg-08 rounded-[var(--kol-radius-4)]', style: { background: 'var(--kol-surface-primary)', color: 'var(--kol-surface-on-primary)' } },
|
|
33
40
|
float: { className: 'kol-float-solid !rounded-[var(--kol-float-window-r)] text-fg-emphasis', style: {} },
|
|
41
|
+
folio: { className: 'kol-modal--folio border rounded-[var(--kol-radius-4)]', style: {} },
|
|
34
42
|
settings: { className: 'rounded-[20px] bg-surface-secondary text-fg-96 font-(family-name:--kol-font-family-float) shadow-[var(--kol-shadow-float)]', style: {} },
|
|
35
43
|
}
|
|
36
44
|
|
|
37
|
-
const ModalShell = forwardRef(function ModalShell(
|
|
45
|
+
const ModalShell = forwardRef(function ModalShell(props, ref) {
|
|
46
|
+
if (props.variant === 'kolbox') {
|
|
47
|
+
const { variant, ...shell } = props
|
|
48
|
+
return <KolboxShell ref={ref} {...shell} />
|
|
49
|
+
}
|
|
50
|
+
const { variant = 'lift', header, footer, className = '', style, children, ...rest } = props
|
|
38
51
|
const look = VARIANTS[variant] ?? VARIANTS.lift
|
|
39
52
|
return (
|
|
40
53
|
<div ref={ref} {...rest} className={`kol-modal flex flex-col ${look.className} ${className}`.trim()} style={{ ...look.style, ...style }}>
|
|
@@ -78,7 +78,7 @@ export default function OptionRow({
|
|
|
78
78
|
const lead = leading ?? (icon && <IconLoader name={icon} size={glyphSize(size)} />)
|
|
79
79
|
return (
|
|
80
80
|
<Tag
|
|
81
|
-
className={`flex items-center gap-2 px-4 border border-transparent ${ROW_HEIGHT[size] ?? ROW_HEIGHT.md} rounded-[var(--kol-radius-
|
|
81
|
+
className={`flex items-center gap-2 px-4 border border-transparent ${ROW_HEIGHT[size] ?? ROW_HEIGHT.md} rounded-[var(--kol-radius-4)] ${disabled ? 'cursor-not-allowed' : 'cursor-pointer'} text-left ${type ?? ROW_TYPE[size] ?? ROW_TYPE.md} transition-colors ${state} ${className}`.trim()}
|
|
82
82
|
{...rest}
|
|
83
83
|
>
|
|
84
84
|
{/* the glyph takes the row's ink when selected — a grey mark on a white fill reads as a hole */}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useRef, useState } from 'react'
|
|
1
2
|
import { Menu } from './Menu.jsx'
|
|
2
3
|
import { Tooltip } from '../utilities/Popover.jsx'
|
|
3
4
|
|
|
@@ -39,7 +40,7 @@ const SIZE = {
|
|
|
39
40
|
* @param {number} [minWidth=180] - The menu's minimum width
|
|
40
41
|
* @param {string} [className] - Extra classes on the trigger
|
|
41
42
|
*/
|
|
42
|
-
|
|
43
|
+
function ParamBindDotDefault({
|
|
43
44
|
bound = false,
|
|
44
45
|
mode,
|
|
45
46
|
items = [],
|
|
@@ -60,7 +61,7 @@ export default function ParamBindDot({
|
|
|
60
61
|
aria-label={name}
|
|
61
62
|
{...props}
|
|
62
63
|
className={[
|
|
63
|
-
'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-
|
|
64
|
+
'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',
|
|
64
65
|
'focus-visible:outline focus-visible:outline-1 focus-visible:outline-[var(--kol-focus-ring-quiet)]',
|
|
65
66
|
SIZE[size] ?? SIZE.sm,
|
|
66
67
|
className,
|
|
@@ -77,3 +78,29 @@ export default function ParamBindDot({
|
|
|
77
78
|
)} />
|
|
78
79
|
)
|
|
79
80
|
}
|
|
81
|
+
|
|
82
|
+
/* kolbox (plan-2026-11-18-kolbox-system W31.2 batch 5, 2026-11-18): kolbox's BindDot (round 4, W5), its drawing carried
|
|
83
|
+
* 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
|
|
84
|
+
* ring, filled in the accent once `bound`; the kolbox Tooltip (`tooltip`, else "Modulate"); a press opens Menu kolbox
|
|
85
|
+
* beside it with `items` ({ label, checked, onClick }) as one group. */
|
|
86
|
+
function ParamBindDotKolbox({ bound = false, items = [], label, tooltip, minWidth = 180 }) {
|
|
87
|
+
const ref = useRef(null)
|
|
88
|
+
const [open, setOpen] = useState(false)
|
|
89
|
+
return (
|
|
90
|
+
<>
|
|
91
|
+
<Tooltip variant="kolbox" label={tooltip ?? 'Modulate'}>
|
|
92
|
+
<button ref={ref} type="button" aria-label={`Modulate${label ? ` ${label}` : ''}`} aria-haspopup="menu" aria-expanded={open} data-bind-dot
|
|
93
|
+
onClick={() => setOpen((o) => !o)}
|
|
94
|
+
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">
|
|
95
|
+
<span className={`kol-bind-dot-mark${bound ? ' is-bound' : ''} size-1.5 rounded-full`} />
|
|
96
|
+
</button>
|
|
97
|
+
</Tooltip>
|
|
98
|
+
<Menu variant="kolbox" aria-label="Modulate" anchor={ref} open={open} onClose={() => setOpen(false)} minWidth={minWidth}
|
|
99
|
+
groups={[items.map((it, i) => ({ label: it.label, value: i, check: !!it.checked }))]} onSelect={(r) => items[r.value]?.onClick?.()} />
|
|
100
|
+
</>
|
|
101
|
+
)
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export default function ParamBindDot(props) {
|
|
105
|
+
return props.variant === 'kolbox' ? <ParamBindDotKolbox {...props} /> : <ParamBindDotDefault {...props} />
|
|
106
|
+
}
|
|
@@ -23,9 +23,26 @@ import { useEffect, useState } from 'react'
|
|
|
23
23
|
* well, − value + in Inter 500 (the glyphs oq, 40% at a bound), the float heights by `size`
|
|
24
24
|
* @param {string} unit FLOAT: a word after the value (`22 px` — the reader's text size, W11 row 151, 2026-11-04)
|
|
25
25
|
* @param {string} ariaLabel FLOAT: what the value is; the − + read `Decrease <it>` / `Increase <it>` (default quantity)
|
|
26
|
+
* @param {'folio'} variant also `folio` (Folio migration batch A, 2026-11-22): Folio's stepper, two 32 squares at radius
|
|
27
|
+
* 4 with the rule line round the value (JetBrains Mono 12 / 16), the step glyphs 12 / 500;
|
|
28
|
+
* 8 apart, the root as wide as its row; a bound dims its square to 40%
|
|
29
|
+
* @param {number} step FOLIO: how far one press moves the value (default 1; the reader's sizes step by 2)
|
|
30
|
+
* @param {ReactNode} down FOLIO: the − square's text (`A−`)
|
|
31
|
+
* @param {ReactNode} up FOLIO: the + square's text (`A+`)
|
|
32
|
+
* @param {string} downLabel FOLIO: the − square's name (`Smaller text`)
|
|
33
|
+
* @param {string} upLabel FOLIO: the + square's name (`Larger text`)
|
|
34
|
+
* @param {'kolbox'} variant also `kolbox` (Folio on kolbox, 2026-11-22): kolbox has no stepper of its own, so it is built
|
|
35
|
+
* from its parts: `Input variant="kolbox"` (its sm field, `--kol-kolbox-ctl` high: the value
|
|
36
|
+
* in mono with `unit` after it, typed and committed on Enter or leaving, ↑↓ step it) between
|
|
37
|
+
* two kolbox icon Buttons, − and + (your icons' `minus` and `plus`), 4 apart, the root as wide
|
|
38
|
+
* as its row. `step`, `min`, `max` as folio's: a typed value is held to the range and the step;
|
|
39
|
+
* a button at a bound is disabled. `downLabel`, `upLabel` name the buttons (else
|
|
40
|
+
* `Decrease <ariaLabel>`, `Increase <ariaLabel>`); `down`, `up` are not drawn (the set's glyphs are)
|
|
26
41
|
* @param {string} className extra classes on the root
|
|
27
42
|
*/
|
|
28
43
|
import { IconLoader } from '@kolkrabbi/kol-icons'
|
|
44
|
+
import Input from '../atoms/Input.jsx'
|
|
45
|
+
import Button from '../atoms/Button.jsx'
|
|
29
46
|
const FLOAT_H = { sm: 'h-[var(--kol-float-h-sm)]', md: 'h-[var(--kol-float-h-md)]', lg: 'h-[var(--kol-float-h-lg)]' }
|
|
30
47
|
|
|
31
48
|
const SIZE_MAP = {
|
|
@@ -44,6 +61,11 @@ const QuantityInput = ({
|
|
|
44
61
|
variant,
|
|
45
62
|
unit,
|
|
46
63
|
ariaLabel = 'quantity',
|
|
64
|
+
step = 1,
|
|
65
|
+
down,
|
|
66
|
+
up,
|
|
67
|
+
downLabel,
|
|
68
|
+
upLabel,
|
|
47
69
|
className = '',
|
|
48
70
|
}) => {
|
|
49
71
|
const [resolvedSize, setResolvedSize] = useState('md')
|
|
@@ -90,6 +112,32 @@ const QuantityInput = ({
|
|
|
90
112
|
)
|
|
91
113
|
}
|
|
92
114
|
|
|
115
|
+
/* folio (Folio migration batch A, 2026-11-22): Folio's Stepper carried class for class (apps/folio Chrome.jsx), two 32
|
|
116
|
+
* squares round the value, stepping by `step`; the chrome in kol-theme `.kol-quantity-input--folio` */
|
|
117
|
+
if (variant === 'folio') {
|
|
118
|
+
const stepCls = 'kol-quantity-input-step flex size-[32px] items-center justify-center rounded-[4px] border disabled:opacity-40'
|
|
119
|
+
return (
|
|
120
|
+
<div className={`kol-quantity-input--folio flex items-center gap-[8px] ${className}`.trim()}>
|
|
121
|
+
<button type="button" aria-label={downLabel} disabled={value <= min} onClick={() => onChange?.(value - step)} className={stepCls}>{down}</button>
|
|
122
|
+
<p className="kol-quantity-input-value flex-1 text-center tabular-nums">{value}{unit ? ` ${unit}` : ''}</p>
|
|
123
|
+
<button type="button" aria-label={upLabel} disabled={value >= max} onClick={() => onChange?.(value + step)} className={stepCls}>{up}</button>
|
|
124
|
+
</div>
|
|
125
|
+
)
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/* kolbox (Folio on kolbox, 2026-11-22): kolbox's field between its two icon buttons */
|
|
129
|
+
if (variant === 'kolbox') {
|
|
130
|
+
const to = (n) => Math.min(max, Math.max(min, min + Math.round((n - min) / step) * step))
|
|
131
|
+
const commit = (text) => { const n = parseFloat(text); if (Number.isFinite(n) && to(n) !== value) onChange?.(to(n)) }
|
|
132
|
+
return (
|
|
133
|
+
<div className={`flex min-w-0 items-center gap-1 ${className}`.trim()}>
|
|
134
|
+
<Button variant="kolbox" iconOnly="minus" aria-label={downLabel ?? `Decrease ${ariaLabel}`} disabled={value <= min} onClick={() => onChange?.(to(value - step))} />
|
|
135
|
+
<Input variant="kolbox" aria-label={ariaLabel} value={value} onCommit={commit} suffix={unit} className="flex-1" />
|
|
136
|
+
<Button variant="kolbox" iconOnly="plus" aria-label={upLabel ?? `Increase ${ariaLabel}`} disabled={value >= max} onClick={() => onChange?.(to(value + step))} />
|
|
137
|
+
</div>
|
|
138
|
+
)
|
|
139
|
+
}
|
|
140
|
+
|
|
93
141
|
/* controls="split" — the − value + pill (formerly QuantityStepper). */
|
|
94
142
|
if (controls === 'split') {
|
|
95
143
|
const btn = (disabled) => ({
|
|
@@ -10,10 +10,40 @@ import Header from './Header.jsx'
|
|
|
10
10
|
* retirement ledger: `actions` → `end`, `collapsedV` / `onCollapseV` (the old `folded` / `onFold` still accepted).
|
|
11
11
|
* The default line stays here: it is not one of Header's four variants.
|
|
12
12
|
*
|
|
13
|
-
*
|
|
13
|
+
* `variant="kolbox"` (W31.2 batch 5): kolbox's rail header, with `leading` and `size` md · sm (below).
|
|
14
|
+
*
|
|
15
|
+
* @param {'default'|'float'|'kolbox'} [variant='default']
|
|
14
16
|
* @param {ReactNode} [title] · {ReactNode} [subtitle] · {ReactNode} [actions] · {string} [className]
|
|
15
17
|
*/
|
|
16
|
-
export default function RailHeader({ variant = 'default', title, subtitle, actions, collapsedV, onCollapseV, folded, onFold, className = '' }) {
|
|
18
|
+
export default function RailHeader({ variant = 'default', title, subtitle, actions, leading, size = 'md', collapsedV, onCollapseV, folded, onFold, className = '' }) {
|
|
19
|
+
/* kolbox (plan-2026-11-18-kolbox-system W31.2 batch 5, 2026-11-18): kolbox's RailHeader, carried from
|
|
20
|
+
* apps/kolbox/src/ui/RailHeader.jsx: a `leading` slot, the title, the `subtitle` as a quiet meta line at the right,
|
|
21
|
+
* the actions; inset 16. `size` md the plain header (48 high), sm the document header (the file's RailHeader 61:11315:
|
|
22
|
+
* 65 high as Figma's, the title on the document voice 13 / 22; below). */
|
|
23
|
+
if (variant === 'kolbox') {
|
|
24
|
+
const sm = size === 'sm'
|
|
25
|
+
return (
|
|
26
|
+
<div className={`kol-rail-header--kolbox flex items-center ${sm ? 'items-start! gap-2 pt-[13px] pb-[9px] pr-2 pl-4' : 'h-12 gap-2 px-4'} ${className}`.trim()} data-rail-header>
|
|
27
|
+
{leading}
|
|
28
|
+
{sm ? (
|
|
29
|
+
/* sm, the document header: the subtitle is a quiet line UNDER the title, as his reference draws it (2026-11-19);
|
|
30
|
+
the header grows by that line only when there is one. As Figma's file header measures (plan-2026-11-23-editor-
|
|
31
|
+
measured-against-figma W3): 240 x 65, the title row 22 at 13 down, 5 to the line, the line 16, 9 under it; 16
|
|
32
|
+
left, 8 right, the actions 8 down */
|
|
33
|
+
<span className="flex! h-auto! min-w-0 flex-1 flex-col">
|
|
34
|
+
<span className="kol-rail-header-title--sm flex h-[22px] min-w-0 items-center">{title}</span>
|
|
35
|
+
{subtitle && <span className="kol-rail-header-sub truncate">{subtitle}</span>}
|
|
36
|
+
</span>
|
|
37
|
+
) : (
|
|
38
|
+
<>
|
|
39
|
+
<span className="kol-rail-header-title--md min-w-0 truncate">{title}</span>
|
|
40
|
+
<span className="kol-rail-header-meta min-w-0 flex-1 truncate text-right">{subtitle}</span>
|
|
41
|
+
</>
|
|
42
|
+
)}
|
|
43
|
+
{actions && <span className={`flex shrink-0 items-center ${sm ? '-mt-[5px]' : '-mr-1'}`}>{actions}</span>}
|
|
44
|
+
</div>
|
|
45
|
+
)
|
|
46
|
+
}
|
|
17
47
|
if (variant !== 'float') {
|
|
18
48
|
return (
|
|
19
49
|
<div className={`flex min-w-0 items-center gap-2 ${className}`.trim()}>
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import KolboxGlyph from '../utilities/kolboxGlyph.jsx'
|
|
1
2
|
/**
|
|
2
3
|
* SectionText — The label, headline and body block. the ruled text block of the SECTION family (SectionSet,
|
|
3
4
|
* kol-website 2026-08-26): label · headline · body · actions, every slot
|
|
@@ -85,7 +86,7 @@ export const SECTION_TEXT_LEVELS = {
|
|
|
85
86
|
float: { title: 'kol-float-sheet', lede: 'kol-float-body text-fg-64', eyebrow: 'kol-float-ruler text-fg-64', gap: 'gap-2', mb: '24px' },
|
|
86
87
|
}
|
|
87
88
|
|
|
88
|
-
|
|
89
|
+
function SectionTextDefault({
|
|
89
90
|
eyebrow,
|
|
90
91
|
label,
|
|
91
92
|
headline,
|
|
@@ -219,3 +220,55 @@ export default function SectionText({
|
|
|
219
220
|
</div>
|
|
220
221
|
)
|
|
221
222
|
}
|
|
223
|
+
|
|
224
|
+
/* kolbox's title row (W31.2 batch 5), below */
|
|
225
|
+
function SectionTextKolbox({ headline, menu, actions, className = '' }) {
|
|
226
|
+
/* kolbox (plan-2026-11-18-kolbox-system W31.2 batch 5, 2026-11-18): kolbox's BrowserTitleRow (Figma `BrowserTitleRow`),
|
|
227
|
+
* carried from apps/kolbox/src/home/BrowserTitleRow.jsx: 64 high, 12 under the top bar, inset 32; the 40 folder glyph,
|
|
228
|
+
* the `headline` (22 / 28, read off the Figma build) and its `menu` (the chevron node) at the left; `actions` (the
|
|
229
|
+
* filters and the view switch) at the right. Under 768 it wraps. */
|
|
230
|
+
return (
|
|
231
|
+
<div className={`kol-section-text--kolbox mt-3 flex h-16 shrink-0 items-center gap-4 px-8 max-md:h-auto max-md:flex-wrap max-md:gap-y-2 max-md:px-4 ${className}`.trim()} data-browser-title-row>
|
|
232
|
+
<KolboxGlyph name="folder" size={40} className="kol-section-text-glyph" />
|
|
233
|
+
<div className="flex min-w-0 flex-1 items-center gap-1 max-md:flex-wrap">
|
|
234
|
+
<h1 className="kol-section-text-title truncate">{headline}</h1>
|
|
235
|
+
{menu}
|
|
236
|
+
</div>
|
|
237
|
+
<div className="flex shrink-0 items-center gap-2 max-md:w-full max-md:flex-wrap">{actions}</div>
|
|
238
|
+
</div>
|
|
239
|
+
)
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/* folio (Folio batch E, 2026-11-22): Folio's page titles and section heads, carried from apps/folio's FolioShelf (the
|
|
243
|
+
* shelf's title block and its numbered `Heading`) and FolioDocument (a chapter's and an article's head). The `eyebrow`
|
|
244
|
+
* in Folio's label over the `headline` over the `body`, muted; `children` (the document's date row) after the body.
|
|
245
|
+
* `headlineSize` is Folio's type step: `title` (the default, a page's), `chapter` or `section`; `headlineAs` h1 by
|
|
246
|
+
* default. `inline` (Folio's, no twin) sets the three on one baseline row, the numbered section head: the eyebrow its
|
|
247
|
+
* number, `meta` the quiet fact after the headline. `gap` is the rhythm and `slotClass.headline` the headline's extra
|
|
248
|
+
* classes (a title that carries the language flags lays them in a row), as in the default. */
|
|
249
|
+
const FOLIO_HEADLINE = { title: 'kol-folio-title', chapter: 'kol-folio-chapter', section: 'kol-folio-section' }
|
|
250
|
+
function SectionTextFolio({ eyebrow, label, headline, headlineSize = 'title', headlineAs: H = 'h1', body, meta, inline = false, gap = 'gap-[12px]', slotClass = {}, className = '', children }) {
|
|
251
|
+
const eb = eyebrow ?? label
|
|
252
|
+
if (inline) {
|
|
253
|
+
return (
|
|
254
|
+
<div className={`kol-section-text--folio flex items-baseline whitespace-nowrap ${gap} ${className}`.trim()}>
|
|
255
|
+
{eb != null && <p className="kol-folio-label kol-section-text-muted">{eb}</p>}
|
|
256
|
+
<H className={FOLIO_HEADLINE[headlineSize]}>{headline}</H>
|
|
257
|
+
{meta && <p className="kol-folio-meta kol-section-text-muted">{meta}</p>}
|
|
258
|
+
</div>
|
|
259
|
+
)
|
|
260
|
+
}
|
|
261
|
+
return (
|
|
262
|
+
<div className={`kol-section-text--folio flex flex-col ${gap} ${className}`.trim()}>
|
|
263
|
+
{eb != null && <p className="kol-folio-label kol-section-text-muted">{eb}</p>}
|
|
264
|
+
<H className={`${FOLIO_HEADLINE[headlineSize]} ${slotClass.headline ?? ''}`.trim()}>{headline}</H>
|
|
265
|
+
{body && <p className="kol-folio-body kol-section-text-muted">{body}</p>}
|
|
266
|
+
{children}
|
|
267
|
+
</div>
|
|
268
|
+
)
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
export default function SectionText(props) {
|
|
272
|
+
if (props.variant === 'folio') return <SectionTextFolio {...props} />
|
|
273
|
+
return props.variant === 'kolbox' ? <SectionTextKolbox {...props} /> : <SectionTextDefault {...props} />
|
|
274
|
+
}
|
package/src/molecules/Slider.jsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useCallback, useEffect, useId, useMemo, useRef, useState } from 'react'
|
|
2
|
-
import Input from '../atoms/Input.jsx'
|
|
2
|
+
import Input, { selectOnFirstPress } from '../atoms/Input.jsx'
|
|
3
3
|
import SliderPanel from './SliderPanel.jsx'
|
|
4
4
|
import LabeledControl from './LabeledControl.jsx'
|
|
5
5
|
|
|
@@ -47,7 +47,9 @@ 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`. On `float` unset is `none`; `input` puts the value as an `Input variant="float"` pill at the track's right, sized in `ch` to the widest value (plan-2026-11-12-one-header W6.1 — the settings window's rows; typed values commit on Enter or blur, clamped, Escape reverts)
|
|
50
|
-
* @param {'minimal'|'dual'|'scrub'|'panel'|'float'} 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 · label` plus `onHold` · `float` (float-everything W2 row 23, 2026-11-04; track only since 2026-11-12): the 3px capsule track at the float sm height — the run fg-64 to a 12 thumb (`.kol-slider-float`); a `label` is drawn by `LabeledControl variant="float"`, a `value` readout as its hint, `formatValue` its words (`65%`)
|
|
50
|
+
* @param {'minimal'|'dual'|'scrub'|'panel'|'float'|'kolbox'} props.variant - `kolbox` (W31.2 batch 3): kolbox's track (2px oq-24, the run in the ink to the value, a 12 ink thumb) in a 24 row (`--kol-kolbox-ctl`); `readout` `value` (its default) the mono 12 value beside it, 40 wide, or `input` the track in an oq-16 field and the value in a text field 2 apart; no visible label (`aria-label` names it), `formatValue` defaults to the raw value · `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 · label` plus `onHold` · `float` (float-everything W2 row 23, 2026-11-04; track only since 2026-11-12): the 3px capsule track at the float sm height — the run fg-64 to a 12 thumb (`.kol-slider-float`); a `label` is drawn by `LabeledControl variant="float"`, a `value` readout as its hint, `formatValue` its words (`65%`)
|
|
51
|
+
* @param {'folio'} props.variant - also `folio` (Folio migration batch A, 2026-11-22): Folio's slider, a 24 row, the 2px track in the rule with the run in the accent to a 12 accent thumb, the value (JetBrains Mono 12 / 16, `formatValue` its words, raw by default) 32 wide at the right, 12 off; no visible label (`aria-label`). Chrome in kol-theme `.kol-slider--folio`
|
|
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)
|
|
51
53
|
* @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
|
|
52
54
|
* @param {number} props.height - vertical only — the track's length in px (default 96; panel 60)
|
|
53
55
|
* @param {string} props['aria-label'] - names the range when there is no visible `label`
|
|
@@ -59,6 +61,84 @@ import LabeledControl from './LabeledControl.jsx'
|
|
|
59
61
|
* @param {number|null} props.playhead - dual only — marker position in min…max; null renders nothing and attaches no listeners
|
|
60
62
|
* @param {Function} props.onPlayheadChange - dual only — (next: number) => void; omit and the marker is not draggable and the rail does not seek
|
|
61
63
|
*/
|
|
64
|
+
/* `variant="kolbox"` (plan-2026-11-18-kolbox-system W31.2 batch 3, 2026-11-18): kolbox's Slider carried class for
|
|
65
|
+
* class, its own component so its draft is its own state. `readout` value (its default): the bare track, the value
|
|
66
|
+
* beside it, 12 apart; `input`: the track in its own field, then 2 apart the number in a field as wide as its value
|
|
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 = '' }) {
|
|
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 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 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
|
+
}
|
|
141
|
+
|
|
62
142
|
const Slider = ({
|
|
63
143
|
label,
|
|
64
144
|
min = 0,
|
|
@@ -86,6 +166,7 @@ const Slider = ({
|
|
|
86
166
|
direction,
|
|
87
167
|
height,
|
|
88
168
|
onHold,
|
|
169
|
+
stops,
|
|
89
170
|
'aria-label': ariaLabel,
|
|
90
171
|
}) => {
|
|
91
172
|
/* Label ↔ input pairing — the <label> is a sibling of the range input, so
|
|
@@ -184,6 +265,24 @@ const Slider = ({
|
|
|
184
265
|
onChange(defaultValue ?? min)
|
|
185
266
|
}
|
|
186
267
|
|
|
268
|
+
if (variant === 'kolbox') {
|
|
269
|
+
return <SliderKolbox value={value} min={min} max={max} step={step} onChange={onChange} formatValue={formatValue} readout={readout} ariaLabel={ariaLabel} stops={stops} className={className} />
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/* folio (Folio migration batch A, 2026-11-22): Folio's Slider carried class for class (apps/folio Chrome.jsx): a 24
|
|
273
|
+
* row, the native range (its track and thumb in kol-theme `.kol-slider--folio`), the value beside it, 32 wide */
|
|
274
|
+
if (variant === 'folio') {
|
|
275
|
+
const format = formatValue ?? ((n) => n)
|
|
276
|
+
const run = `${((value - min) / (max - min)) * 100}%`
|
|
277
|
+
return (
|
|
278
|
+
<div className={`kol-slider--folio flex h-[24px] w-full items-center gap-[12px] ${className}`}>
|
|
279
|
+
<input type="range" min={min} max={max} step={step} value={value} onChange={handleChange} aria-label={ariaLabel} style={{ '--run': run }}
|
|
280
|
+
className="kol-slider-input h-[24px] min-w-0 flex-1 cursor-pointer appearance-none bg-transparent" />
|
|
281
|
+
<span className="kol-slider-value w-[32px] shrink-0 text-right tabular-nums">{format(value)}</span>
|
|
282
|
+
</div>
|
|
283
|
+
)
|
|
284
|
+
}
|
|
285
|
+
|
|
187
286
|
if (variant === 'panel') {
|
|
188
287
|
return <SliderPanel value={value} onChange={onChange} min={min} max={max} step={step} label={label} direction={direction} height={height} onHold={onHold} />
|
|
189
288
|
}
|
|
@@ -66,14 +66,12 @@ import { glyphSize } from '../hooks/glyphLadders.js'
|
|
|
66
66
|
* @param {string} props.className - Additional classes on the trigger
|
|
67
67
|
*/
|
|
68
68
|
|
|
69
|
-
/* Corner fold marker —
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
* this is that. Lives inside the button so it dims with kol-btn-quiet and
|
|
73
|
-
* inverts with kol-btn-pressed (currentColor). */
|
|
69
|
+
/* Corner fold marker — drawn here, not an icon: it belongs to this button only
|
|
70
|
+
* (out of the icon set 2026-11-23, his ruling). Lives inside the button so it dims
|
|
71
|
+
* with kol-btn-quiet and inverts with kol-btn-pressed (currentColor). */
|
|
74
72
|
const FoldIndicator = () => (
|
|
75
73
|
<span aria-hidden="true" className="pointer-events-none absolute right-0.5 bottom-0.5 opacity-70 inline-flex">
|
|
76
|
-
<
|
|
74
|
+
<svg width="4" height="4" viewBox="0 0 4 4" fill="none"><path d="M0 4L4 4L4 0Z" fill="currentColor" /></svg>
|
|
77
75
|
</span>
|
|
78
76
|
)
|
|
79
77
|
|
|
@@ -68,6 +68,11 @@ function PaintChip({ id, label, color, slot, onSwap }) {
|
|
|
68
68
|
* @param {'fill'|'stroke'} activePaint which chip paints on top. Default 'fill'
|
|
69
69
|
* @param {Function} onSwap () => void — either chip or the swap arrow
|
|
70
70
|
* @param {Function} onClear () => void — the "set to none" marker
|
|
71
|
+
* @param {'default'|'kolbox'} variant `kolbox` (kolbox's SwatchStack, plan-2026-11-18-kolbox-system W31.2, 2026-11-18,
|
|
72
|
+
* carried class for class): the stack scaled into the 32 dock cell, 16 chips at 4 / 4 and 12 / 11, each with a halo of
|
|
73
|
+
* the ground then the oq-24 line; the swap arrow (your icons' `swap`, 12) top right in oq-64, the ink on hover; the
|
|
74
|
+
* none marker an 8 disc of the ink with the error slash. Chrome in kol-theme `.kol-swatch-stack--kolbox`.
|
|
75
|
+
* @param {string} className kolbox: extra classes on the stack
|
|
71
76
|
*/
|
|
72
77
|
export function SwatchStack({
|
|
73
78
|
fillColor = '#FFFFFF',
|
|
@@ -75,7 +80,30 @@ export function SwatchStack({
|
|
|
75
80
|
activePaint = 'fill',
|
|
76
81
|
onSwap,
|
|
77
82
|
onClear,
|
|
83
|
+
variant = 'default',
|
|
84
|
+
className = '',
|
|
78
85
|
}) {
|
|
86
|
+
if (variant === 'kolbox') {
|
|
87
|
+
const chip = (key, label, pos) => (
|
|
88
|
+
<button key={key} type="button" aria-label={label} onClick={onSwap} data-paint={label}
|
|
89
|
+
className={`kol-swatch-stack-chip absolute size-4 rounded-full outline-none focus-visible:outline-solid focus-visible:outline-1 ${pos}`}
|
|
90
|
+
style={{ background: key === 'fill' ? fillColor : strokeColor }} />
|
|
91
|
+
)
|
|
92
|
+
const fill = chip('fill', 'Fill color', 'top-1 left-1')
|
|
93
|
+
const stroke = chip('stroke', 'Stroke color', 'top-3 left-[11px]')
|
|
94
|
+
return (
|
|
95
|
+
<div className={`kol-swatch-stack--kolbox relative size-8 shrink-0 ${className}`.trim()} data-swatch-stack={activePaint}>
|
|
96
|
+
{activePaint === 'fill' ? [stroke, fill] : [fill, stroke]}
|
|
97
|
+
<button type="button" aria-label="Swap colors" onClick={onSwap}
|
|
98
|
+
className="kol-swatch-stack-swap absolute top-0 right-0 inline-flex outline-none focus-visible:outline-solid focus-visible:outline-1">
|
|
99
|
+
<IconLoader name="swap" size={12} className="kol-kolbox-icon shrink-0" />
|
|
100
|
+
</button>
|
|
101
|
+
<button type="button" aria-label="Clear color" onClick={onClear}
|
|
102
|
+
className="kol-swatch-stack-none absolute bottom-0 left-0 size-2 overflow-hidden rounded-full" />
|
|
103
|
+
</div>
|
|
104
|
+
)
|
|
105
|
+
}
|
|
106
|
+
|
|
79
107
|
const fill = <PaintChip key="fill" id="fill" label="Fill color" color={fillColor} slot={FILL_SLOT} onSwap={onSwap} />
|
|
80
108
|
const stroke = <PaintChip key="stroke" id="stroke" label="Stroke color" color={strokeColor} slot={STROKE_SLOT} onSwap={onSwap} />
|
|
81
109
|
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/* taxonomy-ok: molecule — a listbox of swatches, the current one ringed */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* SwatchGrid — Pick one color from a grid of swatches (plan-2026-11-18-kolbox-system W31.2 batch 4, 2026-11-18;
|
|
5
|
+
* kolbox's, the swatches under "On this page" in its color popover). Squares at radius 2, 8 across, 8 apart; each ringed
|
|
6
|
+
* by a 1px oq-24 line inside it, the current one by a 2px accent ring 1 off the secondary surface. A listbox of options,
|
|
7
|
+
* each named by its color. Its one look. Input.
|
|
8
|
+
*
|
|
9
|
+
* @param {string[]} colors any CSS colors
|
|
10
|
+
* @param {string} [value] the current one
|
|
11
|
+
* @param {Function} [onChange] `(color)`
|
|
12
|
+
* @param {string} [className]
|
|
13
|
+
* @param {'folio'|'kolbox'} [variant] `folio` (Folio's Swatches, Folio batch C, 2026-11-22, carried class for class): a row of
|
|
14
|
+
* the caller's swatches (`children`, each a `ColorSwatch variant="folio"`), 8 apart, a group named by `aria-label`;
|
|
15
|
+
* `colors`, `value` and `onChange` are not read. `kolbox` with `children` (Folio on kolbox, 2026-11-22): the same row of
|
|
16
|
+
* the caller's swatches (`ColorSwatch variant="kolbox"`), 8 apart; without children, kolbox's grid as above.
|
|
17
|
+
*/
|
|
18
|
+
export default function SwatchGrid({ colors = [], value, onChange, className = '', variant, children, ...rest }) {
|
|
19
|
+
/* kolbox (Folio on kolbox, 2026-11-22) with `children`: a row of the caller's swatches (`ColorSwatch variant="kolbox"`),
|
|
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>
|
|
23
|
+
return (
|
|
24
|
+
<div role="listbox" aria-label="Swatches" className={`grid grid-cols-8 gap-2 ${className}`}>
|
|
25
|
+
{colors.map((c) => (
|
|
26
|
+
<button
|
|
27
|
+
key={c}
|
|
28
|
+
type="button"
|
|
29
|
+
role="option"
|
|
30
|
+
aria-label={c}
|
|
31
|
+
aria-selected={c === value}
|
|
32
|
+
onClick={() => onChange?.(c)}
|
|
33
|
+
className={`kol-swatch-grid-cell${c === value ? ' is-current ring-2 ring-offset-1' : ' ring-1 ring-inset'} aspect-square outline-none`}
|
|
34
|
+
style={{ background: c }}
|
|
35
|
+
/>
|
|
36
|
+
))}
|
|
37
|
+
</div>
|
|
38
|
+
)
|
|
39
|
+
}
|