@kolkrabbi/kol-component 0.386.0 → 0.388.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/index.js +1 -1
- package/src/molecules/AlignmentGrid.jsx +13 -7
- package/src/molecules/ColorInputRow.jsx +31 -23
- package/src/molecules/ColorSwatch.jsx +17 -49
- package/src/molecules/ContextMenu.jsx +1 -1
- package/src/molecules/Dropdown.jsx +24 -56
- package/src/molecules/Menu.jsx +190 -255
- package/src/molecules/MenuItem.jsx +45 -12
- package/src/molecules/MenuList.jsx +48 -17
- package/src/molecules/ParamBindDot.jsx +33 -54
- 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
- package/src/utilities/Popover.jsx +8 -4
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { useLayoutEffect, useRef, useState } from 'react'
|
|
2
2
|
import { IconLoader } from '@kolkrabbi/kol-icons'
|
|
3
3
|
import { Menu } from './Menu.jsx'
|
|
4
|
-
import Kbd from '../atoms/Kbd.jsx'
|
|
5
4
|
import Divider from '../atoms/Divider.jsx'
|
|
6
5
|
import { indicatorSize } from '../hooks/glyphLadders.js'
|
|
7
6
|
|
|
@@ -125,47 +124,81 @@ const ROW_BY_SIZE = { xs: 'kol-mono-8 px-2 h-5', sm: 'kol-helper-12 px-2 h-8', m
|
|
|
125
124
|
* row still fills a fixed panel through `w-full` and lets a content-sized one hug its longest label. */
|
|
126
125
|
const INDICATOR = { dot: 'ascii-dot', check: 'check', chevron: 'chevron-right' }
|
|
127
126
|
|
|
128
|
-
|
|
127
|
+
/* ONE ROW, ITS LOOK THE THEME'S (plan-2026-11-29-one-set-fold W3): kolbox's row keys are MenuRow's too.
|
|
128
|
+
* check true | false: a check mark, `menuitemcheckbox`. Where it sits is the theme's (`.kol-menu-check`): after the
|
|
129
|
+
* label in the default theme, the leading column in the kolbox theme. `lead` (the list's: a row in it has a
|
|
130
|
+
* check) keeps the column on every row, empty where the row is not checked.
|
|
131
|
+
* tag a small mono chip after the shortcut (`.kol-menu-tag`)
|
|
132
|
+
* flyout the row opens a child menu: no pick, `aria-haspopup`, `expanded` while it is open, the chevron last
|
|
133
|
+
* chosen the chosen row (`data-chosen`): where the keys start, what a list laid over its field puts on the field
|
|
134
|
+
* rowRef · onPointerMove for the list that holds it (MenuList's flyouts)
|
|
135
|
+
* The lit row (the pointer's or the keys') is `data-active`, set by the Menu that holds it, never by React. */
|
|
136
|
+
export function MenuRow({ href, onClick, onPointerEnter, onPointerLeave, onPointerMove, disabled, prefix, iconLeft, indicator, kbd, shortcut, hover = true, height, size = 'sm', rowClass, tone, accent, check, lead = false, tag, flyout = false, expanded, chosen, rowRef, children }) {
|
|
129
137
|
/* `href` makes the row a real link — cmd/ctrl-click and middle-click open a new tab (DocumentHeader, 2026-10-31);
|
|
130
138
|
* a plain click still runs `onClick` (the app's router), which may preventDefault */
|
|
131
139
|
const Row = href && !disabled ? 'a' : 'button'
|
|
140
|
+
const caps = kbd != null || typeof shortcut === 'string'
|
|
132
141
|
return (
|
|
133
142
|
<Row
|
|
143
|
+
ref={rowRef}
|
|
134
144
|
{...(Row === 'a' ? { href, onClick: (e) => { if (e.metaKey || e.ctrlKey || e.shiftKey || e.button === 1) return; onClick?.(e) } } : { type: 'button', onClick })}
|
|
135
|
-
data-menu-item
|
|
145
|
+
/* a flyout row only opens its child: the menu closes on a click from `[data-menu-item]`, never on this one */
|
|
146
|
+
data-menu-item={flyout ? undefined : ''}
|
|
147
|
+
data-menu-row=""
|
|
148
|
+
data-chosen={chosen || undefined}
|
|
136
149
|
data-accent={accent === 'secondary' ? accent : undefined}
|
|
137
150
|
onPointerEnter={onPointerEnter}
|
|
138
151
|
onPointerLeave={onPointerLeave}
|
|
152
|
+
onPointerMove={onPointerMove}
|
|
139
153
|
disabled={Row === 'button' ? disabled : undefined}
|
|
140
|
-
role=
|
|
154
|
+
role={check === undefined ? 'menuitem' : 'menuitemcheckbox'}
|
|
155
|
+
aria-checked={check === undefined ? undefined : !!check}
|
|
156
|
+
aria-haspopup={flyout ? 'menu' : undefined}
|
|
157
|
+
aria-expanded={flyout ? !!expanded : undefined}
|
|
141
158
|
style={height != null ? { height } : undefined}
|
|
142
|
-
className={`kol-menu-btn w-full ${rowClass ?? ROW_BY_SIZE[size] ?? ROW_BY_SIZE.sm} shrink-0 flex items-center gap-2 text-body ${hover ? 'hover:text-emphasis' : ''} ${tone === 'danger' ? 'kol-menu-row--danger' : ''} disabled:opacity-
|
|
159
|
+
className={`kol-menu-btn w-full ${rowClass ?? ROW_BY_SIZE[size] ?? ROW_BY_SIZE.sm} shrink-0 flex items-center gap-2 text-body ${hover ? 'hover:text-emphasis' : ''} ${tone === 'danger' ? 'kol-menu-row--danger' : ''} disabled:opacity-[var(--kol-menu-row-disabled-opacity,0.4)] disabled:cursor-not-allowed text-left`.replace(/\s+/g, ' ')}
|
|
143
160
|
>
|
|
144
161
|
{prefix && <span className="shrink-0 inline-flex items-center">{prefix}</span>}
|
|
145
|
-
{iconLeft && <span className="shrink-0 w-4 inline-flex items-center justify-center">{iconLeft}</span>}
|
|
162
|
+
{iconLeft && <span className="kol-menu-lead-icon shrink-0 w-4 inline-flex items-center justify-center">{iconLeft}</span>}
|
|
146
163
|
{/* leading-normal: kol-helper-12 is line-height 1, and truncate's
|
|
147
164
|
* overflow clip cuts mono descenders on a 1-em line box ("Show grid"
|
|
148
165
|
* loses its g). The h-8 centered row absorbs the taller line box —
|
|
149
166
|
* zero layout shift (MenuItemDescenderClip, 2026-08-12). */}
|
|
150
167
|
<span className="flex-1 truncate leading-normal">{children}</span>
|
|
151
|
-
{
|
|
168
|
+
{lead && <span className="kol-menu-check">{check ? <IconLoader name="check" size={size === 'xs' ? indicatorSize('xs') : 14} /> : null}</span>}
|
|
169
|
+
{(indicator || caps || (shortcut && typeof shortcut !== 'string')) && (
|
|
152
170
|
<span className="shrink-0 inline-flex items-center gap-2 text-oq-88">
|
|
153
171
|
{/* the dot is kol-icons `ascii-dot` drawn at twice the slot and pulled back into it: at the slot's own size its
|
|
154
172
|
* 2.25/24 circle is a 2.6px speck; at 24 it is the rail's • (≈4.5px) and still takes the check's 14px column */}
|
|
155
173
|
{indicator === 'dot'
|
|
156
174
|
? <IconLoader name="ascii-dot" size={size === 'xs' ? 16 : 24} style={{ margin: size === 'xs' ? -4 : -5 }} />
|
|
157
175
|
: indicator && <IconLoader name={INDICATOR[indicator] ?? indicator} size={size === 'xs' ? indicatorSize('xs') : 14} />}
|
|
158
|
-
{
|
|
159
|
-
{
|
|
160
|
-
? <Kbd size="md" icon="command" className="kol-menu-kbd">{kbd.slice(1)}</Kbd>
|
|
161
|
-
: <Kbd size="md" className="kol-menu-kbd">{kbd}</Kbd>)}
|
|
162
|
-
{typeof shortcut === 'string' ? <Kbd size="md" className="kol-menu-kbd">{shortcut}</Kbd> : shortcut}
|
|
176
|
+
{kbd != null && <MenuKbd keys={kbd} />}
|
|
177
|
+
{typeof shortcut === 'string' ? <MenuKbd keys={shortcut} plain /> : shortcut}
|
|
163
178
|
</span>
|
|
164
179
|
)}
|
|
180
|
+
{tag && <span className="kol-menu-tag shrink-0 px-1">{tag}</span>}
|
|
181
|
+
{flyout && <IconLoader name="chevron-right" size={10} className="kol-menu-chevron text-emphasis shrink-0" />}
|
|
165
182
|
</Row>
|
|
166
183
|
)
|
|
167
184
|
}
|
|
168
185
|
|
|
186
|
+
/* a row's key cap: the Kbd's plate and type (`.kol-kbd .kol-kbd-md`), its box in `.kol-menu-kbd` so the theme can draw
|
|
187
|
+
* it as plain text (kolbox: the muted ink, no plate, as Figma's menus). ⌘ is drawn, never typed — the Kbd's `command`
|
|
188
|
+
* glyph (W2 row 27, 2026-11-04) — and kolbox writes it as text: both are here, the theme shows one. `plain`: no ⌘ glyph
|
|
189
|
+
* (the old free `shortcut` string was a cap as written). */
|
|
190
|
+
function MenuKbd({ keys, plain = false }) {
|
|
191
|
+
const s = keys
|
|
192
|
+
const cmd = !plain && typeof s === 'string' && s.startsWith('⌘')
|
|
193
|
+
return (
|
|
194
|
+
<kbd aria-hidden="true" className="kol-kbd kol-kbd-md kol-menu-kbd">
|
|
195
|
+
{cmd && <span className="kol-menu-kbd-glyph"><IconLoader name="command" size={12} className="kol-kbd-icon shrink-0" /></span>}
|
|
196
|
+
{cmd && <span className="kol-menu-kbd-char">⌘</span>}
|
|
197
|
+
{cmd ? s.slice(1) : s}
|
|
198
|
+
</kbd>
|
|
199
|
+
)
|
|
200
|
+
}
|
|
201
|
+
|
|
169
202
|
/* `className` — the rule's spacing, whole (MetricDashboardUpstream, kol-website 2026-10-31); `kol-menu-rule` is the
|
|
170
203
|
* panel's edge-to-edge rule, its ink set by the panel (oq-16, float oq-08). */
|
|
171
204
|
/* MenuDivider — a rule between a menu's groups: the Divider atom on the oq ramp, oq-08 (plan-2026-11-07-menu-system
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { useState } from 'react'
|
|
2
2
|
import { IconLoader } from '@kolkrabbi/kol-icons'
|
|
3
3
|
import SearchInput from './SearchInput.jsx'
|
|
4
|
-
import { MenuRow, MenuDivider
|
|
4
|
+
import { MenuRow, MenuDivider } from './MenuItem.jsx'
|
|
5
|
+
import { Menu } from './Menu.jsx'
|
|
5
6
|
import { Tooltip } from '../utilities/Popover.jsx'
|
|
6
7
|
|
|
7
8
|
/**
|
|
@@ -16,30 +17,43 @@ import { Tooltip } from '../utilities/Popover.jsx'
|
|
|
16
17
|
* ]} />
|
|
17
18
|
*
|
|
18
19
|
* items rows as data — the row keys `Menu` documents: `label` · `icon` · `trailing` (+ `trailingSize`) · `current`
|
|
19
|
-
* · `indicator` 'dot' | 'check' | 'chevron' · `checked`
|
|
20
|
-
* · `
|
|
21
|
-
* · `
|
|
20
|
+
* · `indicator` 'dot' | 'check' | 'chevron' · `checked` (or `check`) · `kbd` · `tag` · `inset`
|
|
21
|
+
* · `highlighted` · `disabled` + `tooltip` · `tone: 'danger'` · `href` · `onClick` · `items` (a flyout) · `key`.
|
|
22
|
+
* A row may also carry MenuRow's own `rowClass` · `hover` · `size` · `height` · `prefix` · `onPointerEnter` /
|
|
23
|
+
* `onPointerLeave` (Dropdown's rows do).
|
|
22
24
|
* search `{ placeholder, empty }` — a search field above the rows that filters them by label
|
|
25
|
+
* onSelect `(row)` on a pick, before the row's own `onClick` (Menu passes its own; a flyout's pick is its parent's)
|
|
23
26
|
* children sit above the rows (under the search)
|
|
24
27
|
* dividerClassName the rule's class, whole (default `kol-menu-rule` — the panel's edge-to-edge rule)
|
|
25
28
|
* headingClassName the heading's class, whole (default the MenuLabel's)
|
|
29
|
+
*
|
|
30
|
+
* ONE LIST (plan-2026-11-29-one-set-fold W3): kolbox's rows are these rows. A flyout is a child `Menu` beside the panel,
|
|
31
|
+
* opened by the pointer moving on its row, a click, ArrowRight or Enter, closed by the pointer moving on another row,
|
|
32
|
+
* ArrowLeft or Escape in it; where it stands is the theme's (`--kol-menu-flyout-*`).
|
|
26
33
|
*/
|
|
27
34
|
|
|
28
35
|
export const MenuLabel = ({ className = 'kol-menu-label kol-helper-12', children }) => <div className={className}>{children}</div>
|
|
29
36
|
|
|
30
37
|
const glyph = (icon, size) => (typeof icon === 'string' ? <IconLoader name={icon} size={size} /> : icon)
|
|
31
|
-
/* a row's trailing marks — real icons and Kbd only (W2): `indicator` 'dot' | 'check' | 'chevron', `
|
|
32
|
-
* `
|
|
33
|
-
const
|
|
38
|
+
/* a row's trailing marks — real icons and Kbd only (W2): `indicator` 'dot' | 'check' | 'chevron', `kbd` a key cap,
|
|
39
|
+
* `trailing` an icon name for an action (download). `checked` is the check (MenuRow's `check`). */
|
|
40
|
+
const checkOf = (it) => it.check ?? it.checked
|
|
41
|
+
const focusPanel = (el) => el?.closest('[data-menu-panel]')?.focus({ preventScroll: true })
|
|
34
42
|
|
|
35
|
-
export function MenuList({ items = [], search, dividerClassName = 'kol-menu-rule', headingClassName, children }) {
|
|
43
|
+
export function MenuList({ items = [], search, onSelect, dividerClassName = 'kol-menu-rule', headingClassName, children }) {
|
|
36
44
|
const [q, setQ] = useState('')
|
|
45
|
+
const [flyout, setFlyout] = useState(null)
|
|
46
|
+
const [rowEl, setRowEl] = useState(null)
|
|
37
47
|
let rows = items
|
|
38
48
|
if (search) {
|
|
39
49
|
const s = q.toLowerCase()
|
|
40
50
|
rows = rows.filter((it) => it.label == null || String(it.label).toLowerCase().includes(s))
|
|
41
51
|
if (!rows.some((it) => it.label != null)) rows = [...rows, { key: 'empty', label: search.empty || 'Nothing matches', disabled: true }]
|
|
42
52
|
}
|
|
53
|
+
/* the check column is the list's: kept on every row once one row can be checked */
|
|
54
|
+
const lead = items.some((it) => !it.divider && !it.heading && checkOf(it) !== undefined)
|
|
55
|
+
/* a pointer on another row closes the open child and gives the keys back to this panel */
|
|
56
|
+
const shut = (el) => { if (flyout !== null) { setFlyout(null); focusPanel(el) } }
|
|
43
57
|
return (
|
|
44
58
|
<>
|
|
45
59
|
{search && <div className="pb-1"><SearchInput variant="outline" size="sm" value={q} onChange={(e) => setQ(e.target?.value ?? e)} onClear={() => setQ('')} placeholder={search.placeholder || 'Search'} /></div>}
|
|
@@ -47,21 +61,38 @@ export function MenuList({ items = [], search, dividerClassName = 'kol-menu-rule
|
|
|
47
61
|
{rows.map((it, i) => {
|
|
48
62
|
if (it.divider) return <MenuDivider key={it.key ?? `d${i}`} className={dividerClassName} />
|
|
49
63
|
if (it.heading) return <MenuLabel key={it.key ?? `h${i}`} className={headingClassName}>{it.heading}</MenuLabel>
|
|
50
|
-
const
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
64
|
+
const key = it.key ?? `r${i}`
|
|
65
|
+
const icon = it.icon ? <span className="kol-menu-icon inline-flex">{glyph(it.icon, 16)}</span> : it.inset ? <span className="size-4" /> : null
|
|
66
|
+
/* `kol-menu-row--kolbox` rides along as a hook for kol-fxr's own rules (on the retirement ledger) */
|
|
67
|
+
const cls = it.rowClass ?? `kol-menu-row kol-menu-row--kolbox kol-helper-12${it.current ? ' kol-menu-row--current' : ''}${it.tone === 'danger' ? ' kol-menu-row--danger' : ''}`
|
|
68
|
+
const common = {
|
|
69
|
+
rowClass: cls, iconLeft: icon, prefix: it.prefix, disabled: it.disabled, check: checkOf(it), lead, tag: it.tag,
|
|
70
|
+
chosen: it.highlighted, hover: it.hover, size: it.size, height: it.height, kbd: it.kbd,
|
|
71
|
+
}
|
|
72
|
+
const opens = it.items?.length && !it.disabled
|
|
73
|
+
const open = opens && flyout === key
|
|
74
|
+
const row = opens ? (
|
|
75
|
+
<>
|
|
76
|
+
<MenuRow {...common} flyout expanded={open} rowRef={open ? setRowEl : undefined}
|
|
77
|
+
onPointerMove={(e) => { if (flyout !== key) { if (flyout !== null) focusPanel(e.currentTarget); setRowEl(e.currentTarget); setFlyout(key) } }}
|
|
78
|
+
onClick={(e) => { setRowEl(e.currentTarget); setFlyout(open ? null : key) }}>
|
|
79
|
+
{it.label}
|
|
80
|
+
</MenuRow>
|
|
81
|
+
{open && rowEl && (
|
|
82
|
+
<Menu nested anchor={rowEl} open placement="flyout" aria-label={typeof it.label === 'string' ? it.label : undefined}
|
|
83
|
+
items={it.items} onSelect={onSelect} panelClassName="kol-menu-flyout"
|
|
84
|
+
onClose={() => { setFlyout(null); focusPanel(rowEl) }} />
|
|
85
|
+
)}
|
|
86
|
+
</>
|
|
56
87
|
) : (
|
|
57
|
-
<MenuRow
|
|
58
|
-
|
|
88
|
+
<MenuRow {...common} href={it.href} indicator={it.indicator}
|
|
89
|
+
onClick={onSelect ? (e) => { onSelect(it.row ?? it); it.onClick?.(e) } : it.onClick}
|
|
59
90
|
onPointerEnter={it.onPointerEnter} onPointerLeave={it.onPointerLeave}
|
|
91
|
+
onPointerMove={flyout !== null ? (e) => shut(e.currentTarget) : undefined}
|
|
60
92
|
shortcut={it.shortcut ?? (it.trailing ? <span className="text-oq-88 inline-flex">{glyph(it.trailing, it.trailingSize ?? 14)}</span> : undefined)}>
|
|
61
93
|
{it.label}
|
|
62
94
|
</MenuRow>
|
|
63
95
|
)
|
|
64
|
-
const key = it.key ?? `r${i}`
|
|
65
96
|
return it.tooltip
|
|
66
97
|
? <Tooltip key={key} label={it.tooltip} placement="left" triggerClassName="block w-full">{row}</Tooltip>
|
|
67
98
|
: <div key={key}>{row}</div>
|
|
@@ -1,14 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { forwardRef } 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,38 @@ 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; the kolbox theme draws them as kolbox's menu). The
|
|
41
|
+
* kolbox Menu bridge left with the Menu fold (W3): `variant="kolbox"` and `"folio"` are accepted, open the one Menu and
|
|
42
|
+
* keep kolbox's place for it, under the dot from its left edge (`align` unset reads `start`). The bridge is in
|
|
43
|
+
* `_tmp/2026-11-29-one-set-fold/ParamBindDot.pre-menu.jsx`.
|
|
42
44
|
*/
|
|
43
|
-
|
|
45
|
+
const THEME_WORDS = ['kolbox', 'folio']
|
|
46
|
+
export default function ParamBindDot({ variant, align, ...props }) {
|
|
47
|
+
return <ParamBindDotMenu {...props} align={align ?? (THEME_WORDS.includes(variant) ? 'start' : 'end')} />
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/* the dot itself, the same button for both menus */
|
|
51
|
+
const Dot = forwardRef(function Dot({ bound, className = '', size = 'sm', accent, open, ...rest }, ref) {
|
|
52
|
+
return (
|
|
53
|
+
<button
|
|
54
|
+
ref={ref}
|
|
55
|
+
type="button"
|
|
56
|
+
data-accent={accent === 'secondary' ? accent : undefined}
|
|
57
|
+
data-size={['xs', 'sm', 'md'].includes(size) ? size : 'sm'}
|
|
58
|
+
{...rest}
|
|
59
|
+
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()}
|
|
60
|
+
>
|
|
61
|
+
<span aria-hidden="true" className={`kol-bind-dot-mark block rounded-full border-solid transition-colors${bound ? ' is-bound' : ''}`} />
|
|
62
|
+
</button>
|
|
63
|
+
)
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
function ParamBindDotMenu({
|
|
44
67
|
bound = false,
|
|
45
68
|
mode,
|
|
46
69
|
items = [],
|
|
@@ -57,52 +80,8 @@ function ParamBindDotDefault({
|
|
|
57
80
|
return (
|
|
58
81
|
<Menu align={align} minWidth={minWidth} items={items} trigger={({ open, props }) => (
|
|
59
82
|
<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>
|
|
83
|
+
<Dot data-bind-dot aria-label={name} bound={bound} size={size} className={className} accent={accent} open={open} {...props} />
|
|
79
84
|
</Tooltip>
|
|
80
85
|
)} />
|
|
81
86
|
)
|
|
82
87
|
}
|
|
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
|
-
}
|
|
@@ -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) => (
|
|
@@ -328,7 +328,7 @@ function ColorPickerPopoverKolbox({ anchor, open, onClose, placement, color, opa
|
|
|
328
328
|
<Button variant="kolbox" key={p.value} iconOnly={p.icon} aria-label={p.value} pressed={p.value === paint} onClick={() => set(hsv, opacity, p.value)} />
|
|
329
329
|
))}
|
|
330
330
|
</div>
|
|
331
|
-
<SBSquare variant="kolbox" hue={hsv.hue} sat={hsv.sat} val={hsv.val} onChange={(sat, val) => set({ ...hsv, sat, val })} className="rounded-sm" />
|
|
331
|
+
<SBSquare variant="kolbox" hue={hsv.hue} sat={hsv.sat} val={hsv.val} onChange={(sat, val) => set({ ...hsv, sat, val })} className="aspect-square rounded-sm" />
|
|
332
332
|
<div className="flex items-center gap-2">
|
|
333
333
|
<Button variant="kolbox" iconOnly="eyedropper" aria-label="Eyedropper" onClick={eyedrop} />
|
|
334
334
|
<div className="flex flex-1 flex-col gap-2">
|