@kolkrabbi/kol-component 0.376.0 → 0.378.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/ToggleSwitch.jsx +10 -0
- package/src/index.js +5 -1
- package/src/molecules/ButtonGroup.jsx +5 -1
- package/src/molecules/ButtonSplit.jsx +7 -8
- package/src/molecules/Header.jsx +8 -4
- package/src/molecules/MenuFloat.jsx +164 -0
- package/src/molecules/Modal.jsx +13 -9
- package/src/molecules/ModalShell.jsx +3 -3
- package/src/molecules/RailFloat.jsx +4 -3
- package/src/molecules/SettingsControls.jsx +100 -155
- package/src/molecules/Slider.jsx +32 -8
- package/src/organisms/ReadingPanel.jsx +5 -6
- package/src/organisms/SettingsPanel.jsx +20 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kolkrabbi/kol-component",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.378.0",
|
|
4
4
|
"description": "The core component library",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
"pdfjs-dist": "^6.3.289",
|
|
34
34
|
"react-syntax-highlighter": "^16.1.1",
|
|
35
35
|
"@kolkrabbi/kol-search": "^0.3.0",
|
|
36
|
-
"@kolkrabbi/kol-
|
|
37
|
-
"@kolkrabbi/kol-
|
|
36
|
+
"@kolkrabbi/kol-growth": "^0.5.0",
|
|
37
|
+
"@kolkrabbi/kol-markdown": "^0.2.0"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
40
|
"@kolkrabbi/kol-icons": ">=0.69.0",
|
|
@@ -14,6 +14,10 @@ import React from 'react'
|
|
|
14
14
|
* (22/26/32/40); the track scales with size in all variants. xs is the
|
|
15
15
|
* panel rung (2026-09-01).
|
|
16
16
|
*
|
|
17
|
+
* `label` (and its `hint`) is DEPRECATED 2026-11-12 (plan-2026-11-12-one-header W6.1, LAW 17 — the user: *"illegal
|
|
18
|
+
* toggleswitch that has LABEL!! no toggle with label is LABELEDCONTROL"*): a switch is the bare control; its words are a
|
|
19
|
+
* `LabeledControl` (`horizontal`) around it. It still draws, and warns once in dev.
|
|
20
|
+
*
|
|
17
21
|
* Legacy aliases: 'plain' → bare · 'default' (the old boxed look) → outline.
|
|
18
22
|
* Type via kol-mono-{12,14,16}; no auto-uppercase — casing is authored at
|
|
19
23
|
* the call site (KOL no-auto-casing rule).
|
|
@@ -21,6 +25,7 @@ import React from 'react'
|
|
|
21
25
|
|
|
22
26
|
const SIZE_TYPE = { xs: 'kol-mono-8', sm: 'kol-mono-12', md: 'kol-mono-14', lg: 'kol-mono-16' }
|
|
23
27
|
const LEGACY_VARIANTS = { plain: 'bare', default: 'outline' }
|
|
28
|
+
let warnedLabel = false
|
|
24
29
|
|
|
25
30
|
const ToggleSwitch = ({
|
|
26
31
|
label,
|
|
@@ -38,6 +43,11 @@ const ToggleSwitch = ({
|
|
|
38
43
|
if (onChange) onChange(!checked)
|
|
39
44
|
}
|
|
40
45
|
|
|
46
|
+
if (import.meta.env?.DEV && (label != null || hint != null) && !warnedLabel) {
|
|
47
|
+
warnedLabel = true
|
|
48
|
+
console.warn('ToggleSwitch: `label` is deprecated — wrap the switch in <LabeledControl horizontal label="…">')
|
|
49
|
+
}
|
|
50
|
+
|
|
41
51
|
const resolvedVariant = LEGACY_VARIANTS[variant] || variant
|
|
42
52
|
const float = resolvedVariant === 'float'
|
|
43
53
|
|
package/src/index.js
CHANGED
|
@@ -182,7 +182,8 @@ export { Menu, MenuTrigger, MenuPanel, MenuLabel, MenuFilter, MenuDatePicker, Me
|
|
|
182
182
|
export { MenuList } from './molecules/MenuList.jsx'
|
|
183
183
|
export { ModalProvider, useModal, ModalDialog, ModalDialog as Dialog } from './molecules/Modal.jsx'
|
|
184
184
|
export { default as ModalShell } from './molecules/ModalShell.jsx'
|
|
185
|
-
/* the generator settings window's
|
|
185
|
+
/* the generator settings window's composite parts (plan-2026-11-05-float-editor W7.2); SettingsCell · SettingsSlider · SettingsRange ·
|
|
186
|
+
* SettingsSelect · SettingsSegmented · SettingsToggle · SettingsText are deprecated aliases of their bases (plan-2026-11-12-one-header W6.1) */
|
|
186
187
|
export {
|
|
187
188
|
SettingsGrid, SettingsCell, SettingsSlider, SettingsRange, SettingsSelect, SettingsSegmented, SettingsToggle,
|
|
188
189
|
SettingsText, SettingsPoint, SettingsRamp, SettingsRampHead, SettingsLights, SettingsFieldMap,
|
|
@@ -291,6 +292,9 @@ export { default as RailHeader } from './molecules/RailHeader.jsx'
|
|
|
291
292
|
export { default as Header } from './molecules/Header.jsx'
|
|
292
293
|
/* ButtonSplit — the main action, a divider and a ⌄ menu (plan-2026-11-12-one-header W4.1) */
|
|
293
294
|
export { default as ButtonSplit } from './molecules/ButtonSplit.jsx'
|
|
295
|
+
/* MenuFloat + MenuFloatRows — the float menu card and its rows, moved from kol-shell 2026-11-12 so ButtonSplit's float menu
|
|
296
|
+
* is the same menu (plan-2026-11-12-one-header W6.1); kol-shell re-exports both */
|
|
297
|
+
export { default as MenuFloatRows, MenuFloat } from './molecules/MenuFloat.jsx'
|
|
294
298
|
export { RailTabs, RailHint, RailActions, RailFoot, RailNav } from './organisms/RailKit.jsx'
|
|
295
299
|
export { LabeledControlSection as RailSection, SettingsRow as RailRow } from './organisms/SettingsPanel.jsx'
|
|
296
300
|
export { default as SectionNewsletter } from './organisms/SectionNewsletter.jsx'
|
|
@@ -15,7 +15,9 @@
|
|
|
15
15
|
* ledger): joined cells, no gap, built from `options` instead of children. See below.
|
|
16
16
|
*
|
|
17
17
|
* row / stack props:
|
|
18
|
-
* @param {'left'|'center'|'right'} align horizontal alignment + container layout mode (default 'center')
|
|
18
|
+
* @param {'left'|'center'|'right'|'between'} align horizontal alignment + container layout mode (default 'center'); `between`
|
|
19
|
+
* (2026-11-12, plan-2026-11-12-one-header W6.1) sets the first button at the left and the last at the right — a float
|
|
20
|
+
* window's Cancel · Export row
|
|
19
21
|
* @param {string} title optional heading rendered above the group, authored at the call site
|
|
20
22
|
* @param {string} className extra container classes (appended) — note this lands on the OUTER
|
|
21
23
|
* container, not the flex row that carries the gap; the gap is responsive by default (8 stacked,
|
|
@@ -95,12 +97,14 @@ const CONTAINER = {
|
|
|
95
97
|
left: 'flex flex-col w-full',
|
|
96
98
|
center: 'flex sm:inline-flex flex-col w-full sm:w-auto sm:mx-auto',
|
|
97
99
|
right: 'flex flex-col w-full',
|
|
100
|
+
between: 'flex flex-col w-full',
|
|
98
101
|
}
|
|
99
102
|
|
|
100
103
|
const JUSTIFY = {
|
|
101
104
|
left: 'sm:justify-start',
|
|
102
105
|
center: 'sm:justify-center',
|
|
103
106
|
right: 'sm:justify-end',
|
|
107
|
+
between: 'sm:justify-between',
|
|
104
108
|
}
|
|
105
109
|
|
|
106
110
|
export default function ButtonGroup({ layout = 'row', align = 'center', title, className = '', children, ...joined }) {
|
|
@@ -2,17 +2,18 @@ import { useState } from 'react'
|
|
|
2
2
|
import Button from '../atoms/Button.jsx'
|
|
3
3
|
import { PopoverPanel, usePopover } from '../utilities/Popover.jsx'
|
|
4
4
|
import { floatSurfaceClass } from '../utilities/tone.js'
|
|
5
|
+
import MenuFloatRows from './MenuFloat.jsx'
|
|
5
6
|
|
|
6
|
-
/* taxonomy-ok: molecule — two Buttons (atoms) and a divider, the ⌄ opening a PopoverPanel (utility) of rows */
|
|
7
|
+
/* taxonomy-ok: molecule — two Buttons (atoms) and a divider, the ⌄ opening a PopoverPanel (utility) of rows (MenuFloatRows on a float) */
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* ButtonSplit — the main action, a 1px divider and a ⌄ that opens a menu of the other actions (plan-2026-11-12-one-header
|
|
10
11
|
* W4.1; the user: *"its basically 4 exports and 1 open, isnt that just 2 buttons with menufloat?"*). One shape, two looks:
|
|
11
12
|
*
|
|
12
13
|
* default the app's square Buttons at `size`, the menu a plain list (SplitToolButton's rows)
|
|
13
|
-
* float the float capsule (`variant="float"`, sm), the menu on the float sheet (`kol-more-sheet-float`)
|
|
14
|
-
*
|
|
15
|
-
*
|
|
14
|
+
* float the float capsule (`variant="float"`, sm), the menu on the float sheet (`kol-more-sheet-float`): `items` drawn
|
|
15
|
+
* by MenuFloatRows — the one float menu, beside it in kol-component since 2026-11-12 (it lived in kol-shell and
|
|
16
|
+
* was redrawn here). `menu(close)` still replaces the rows
|
|
16
17
|
*
|
|
17
18
|
* `tone` is the Buttons' ground (Button's tones); `grey` is the float well on a float (the secondary look).
|
|
18
19
|
* The ⌄ is 12 (`--kol-float-chev-sm` on a float), never the button's glyph.
|
|
@@ -50,14 +51,12 @@ export default function ButtonSplit({ children, icon, onClick, items = [], menu,
|
|
|
50
51
|
<PopoverPanel popover={popover} panel={false} focus={false}
|
|
51
52
|
className={float ? `kol-more-sheet kol-more-sheet-float ${floatSurfaceClass('solid', true)}` : 'w-max bg-surface-secondary border border-oq-08 rounded shadow-lg'}
|
|
52
53
|
style={float ? { minWidth: 220 } : undefined}>
|
|
53
|
-
{menu ? menu(close) : items.map((it) => (
|
|
54
|
-
? <Button key={it.label} variant="nav" size="lg" iconLeft={it.icon} iconSize="var(--kol-float-ic)" disabled={it.disabled} className="w-full justify-start kol-btn-float" onClick={pick(it)}>{it.label}</Button>
|
|
55
|
-
: (
|
|
54
|
+
{menu ? menu(close) : float ? <MenuFloatRows variant="float" actions={items} onPick={close} /> : items.map((it) => (
|
|
56
55
|
<button key={it.label} type="button" disabled={it.disabled} onClick={pick(it)}
|
|
57
56
|
className="w-full kol-helper-12 px-3 h-8 flex items-center gap-2 text-body hover:text-emphasis disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:text-body text-left">
|
|
58
57
|
<span className="flex-1 truncate">{it.label}</span>
|
|
59
58
|
</button>
|
|
60
|
-
))
|
|
59
|
+
))}
|
|
61
60
|
</PopoverPanel>
|
|
62
61
|
</div>
|
|
63
62
|
)
|
package/src/molecules/Header.jsx
CHANGED
|
@@ -29,7 +29,8 @@ import Button from '../atoms/Button.jsx'
|
|
|
29
29
|
* @param {'nav'|'property'|'modal'|'settings'} [variant='property']
|
|
30
30
|
* @param {string} [icon] nav · modal: the lead glyph
|
|
31
31
|
* @param {ReactNode} [title] the title slot — text, or a node in the title position
|
|
32
|
-
* @param {ReactNode} [kind] settings: the
|
|
32
|
+
* @param {ReactNode} [kind] settings · property: the quiet second text beside the title (the preset beside the effect —
|
|
33
|
+
* no middot in a title, plan-2026-11-12-one-header W10.1)
|
|
33
34
|
* @param {Function} [onSwitch] nav: the switcher's press; shows the ⌄
|
|
34
35
|
* @param {ReactNode} [end] the end slot — before the toggles
|
|
35
36
|
* @param {Function} [onExpand] · {Function} [onCollapseH] · {boolean} [collapsedV] · {Function} [onCollapseV]
|
|
@@ -50,14 +51,14 @@ export default function Header({ variant = 'property', icon, title, kind, onSwit
|
|
|
50
51
|
const any = end || onExpand || onCollapseH || onCollapseV
|
|
51
52
|
|
|
52
53
|
if (variant === 'settings') return (
|
|
53
|
-
<header className={`flex items-center gap-4 h-[60px] shrink-0 pl-6 pr-[
|
|
54
|
+
<header className={`flex items-center gap-4 h-[60px] shrink-0 pl-6 pr-[15px] border-b border-oq-16 ${className}`.trim()}>
|
|
54
55
|
<h2 className="text-[14px] font-semibold leading-none">{title}</h2>
|
|
55
56
|
{kind && <span className="text-[11px] text-oq-64 leading-none mt-px">{kind}</span>}
|
|
56
57
|
{/* `end`: the header's right side pushed by its own margin, no spacer (LAW 10) */}
|
|
57
58
|
<div className="ml-auto flex items-center gap-4">
|
|
58
59
|
{end}{toggles}
|
|
59
60
|
{onClose && <button type="button" aria-label="Close" onClick={onClose}
|
|
60
|
-
className="ml-3 size-7
|
|
61
|
+
className="ml-3 size-7 inline-flex items-center justify-center rounded-md text-[20px] leading-none text-oq-64 hover:text-(--kol-fg-96) hover:bg-(--kol-oq-08) focus-visible:outline-none focus-visible:shadow-[var(--kol-float-focus)]">×</button>}
|
|
61
62
|
</div>
|
|
62
63
|
</header>
|
|
63
64
|
)
|
|
@@ -86,7 +87,10 @@ export default function Header({ variant = 'property', icon, title, kind, onSwit
|
|
|
86
87
|
<div data-float-module-header="" className={`flex w-full min-w-0 shrink-0 items-center justify-between gap-2 ${className}`.trim()}>
|
|
87
88
|
{slot != null && slot !== false && (isValidElement(slot)
|
|
88
89
|
? <div data-rail-header-title="" className="flex min-w-0 flex-1">{slot}</div>
|
|
89
|
-
:
|
|
90
|
+
: kind != null && kind !== ''
|
|
91
|
+
/* `kind` — the quiet second text beside the title (W10.1: "Drift" + "Storm", never "Drift · Storm") */
|
|
92
|
+
? <span className="flex min-w-0 flex-1 items-baseline gap-2"><span className="kol-float-panel text-emphasis min-w-0 shrink truncate">{slot}</span><span className="kol-float-panel text-oq-64 min-w-0 truncate">{kind}</span></span>
|
|
93
|
+
: <span className="kol-float-panel text-emphasis min-w-0 flex-1 truncate">{slot}</span>)}
|
|
90
94
|
{(any || onClose) && <span className="ml-auto flex shrink-0 items-center gap-1">
|
|
91
95
|
{end}{toggles}
|
|
92
96
|
{onClose && <Button variant="float" tone="ghost" size="sm" iconOnly="x" aria-label="Close" onClick={onClose} />}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { createContext, useContext, useEffect, useRef, useState } from 'react'
|
|
2
|
+
import Button from '../atoms/Button.jsx'
|
|
3
|
+
import Header from './Header.jsx'
|
|
4
|
+
import ModalHeader from './ModalHeader.jsx'
|
|
5
|
+
import { usePopover, PopoverPanel } from '../utilities/Popover.jsx'
|
|
6
|
+
import { IconLoader } from '@kolkrabbi/kol-icons'
|
|
7
|
+
|
|
8
|
+
/* the open level a row sits in (MenuFloat); null outside one, where a row's `sub` is ignored as before */
|
|
9
|
+
const Level = (globalThis[Symbol.for('@kolkrabbi/kol-shell/FloatMenuLevel')] ??= createContext(null))
|
|
10
|
+
const FLOAT_ROW = 'w-full justify-start kol-btn-float'
|
|
11
|
+
|
|
12
|
+
/* taxonomy-ok: molecule — a column of nav Buttons (moved from kol-shell 2026-11-12 so ButtonSplit's float menu is this one;
|
|
13
|
+
* kol-shell re-exports both names) */
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* MenuFloatRows — The sheet's rows, wherever the sheet opens. the one list of 44px nav rows (mono-16, 22px glyphs,
|
|
17
|
+
* the pill's rounding on each) that the phone bar's More sheet and Home's masthead button both draw
|
|
18
|
+
* (user 2026-10-23: *"we could even make similar dropdown as we use in phone nav"*). The sheet's chrome is
|
|
19
|
+
* `.kol-more-sheet` — the pill's ground and hairline, a 24px rounding, 8px pad — on whatever box holds the rows.
|
|
20
|
+
*
|
|
21
|
+
* @param {Array} actions `[{ label, icon?, avatar?, onPress, checked?, disabled? }]` — the page's own buttons, first. `avatar` (a picture
|
|
22
|
+
* url — the account row) draws in the glyph's place. A row with `checked`
|
|
23
|
+
* (a pick list — TransportPill's loop lengths) draws the 22px check, or keeps its space when false
|
|
24
|
+
* @param {Array} items `[{ path, label, icon? }]` — destinations, after a divider's worth of nothing
|
|
25
|
+
* @param {string} active the item path that is current
|
|
26
|
+
* @param {Function} onPick `(item | action) => void` — after the row's own press; the sheet closes here
|
|
27
|
+
* @param {'float'} variant the floating style (round 3, W16 2026-10-31): each row a `kol-btn-float` pill — 40 (48 on touch)
|
|
28
|
+
* tall, 12 in, an 18 (20) glyph, the current row oq-16 — in a `.kol-more-sheet-float`; AppFloatNav
|
|
29
|
+
* and the signed-out Home pass it. Unset, the rows are A
|
|
30
|
+
* @param {boolean} itemsFirst the destinations above the actions (PhoneNav's More, 2026-10-28: the whole nav, then the
|
|
31
|
+
* page's buttons); Home's masthead button keeps actions first
|
|
32
|
+
*/
|
|
33
|
+
export default function MenuFloatRows({ actions = [], items = [], active, onPick, itemsFirst = false, variant }) {
|
|
34
|
+
/* the float row's height, inset and gap are the theme's (`.kol-more-sheet-float`, round 3) — no h-11 / gap-3 utility,
|
|
35
|
+
* which would outrank the components layer */
|
|
36
|
+
const float = variant === 'float'
|
|
37
|
+
const rowCls = float ? FLOAT_ROW : 'w-full justify-start h-11 gap-3'
|
|
38
|
+
const level = useContext(Level)
|
|
39
|
+
const glyph = float ? 'var(--kol-float-ic)' : 22
|
|
40
|
+
const acts = (
|
|
41
|
+
<>
|
|
42
|
+
{actions.map((a) => {
|
|
43
|
+
/* a row with `sub` inside a MenuFloat opens its level instead of picking — the chevron at the row's end */
|
|
44
|
+
const nests = level && a.sub?.length > 0
|
|
45
|
+
/* the account row is the ModalHeader (menu-system W4.1) — avatar · title, pressable */
|
|
46
|
+
if (a.avatar && !nests) return <ModalHeader key={a.label} variant={float ? 'float' : 'default'} avatar={a.avatar} title={a.label} onClick={() => { onPick?.(a); a.onPress?.() }} />
|
|
47
|
+
return (
|
|
48
|
+
/* a nesting row draws its own glyph so the label can take the room between it and the chevron; 8 apart, as Button's */
|
|
49
|
+
<Button key={a.label} variant="nav" size="lg" iconLeft={a.checked === undefined && !nests ? a.icon : undefined} iconSize={glyph} disabled={a.disabled}
|
|
50
|
+
className={rowCls} style={nests ? { gap: 8 } : undefined}
|
|
51
|
+
aria-haspopup={nests ? 'menu' : undefined} aria-expanded={nests ? level.isOpen(a) : undefined}
|
|
52
|
+
onClick={(e) => { if (nests) { level.open(a, e.currentTarget); return } onPick?.(a); a.onPress?.() }}>
|
|
53
|
+
{a.checked !== undefined && (
|
|
54
|
+
<span className="inline-flex items-center justify-center shrink-0" style={{ width: float ? 'var(--kol-float-ic)' : 22, height: float ? 'var(--kol-float-ic)' : 22 }}>{a.checked && <IconLoader name="check" size={22} />}</span>
|
|
55
|
+
)}
|
|
56
|
+
{nests ? <>{a.icon && <IconLoader name={a.icon} size={glyph} />}<span className="flex-1 text-left">{a.label}</span><IconLoader name="chevron-right" size={glyph} className="shrink-0 text-oq-48" /></> : a.label}
|
|
57
|
+
</Button>
|
|
58
|
+
)
|
|
59
|
+
})}
|
|
60
|
+
</>
|
|
61
|
+
)
|
|
62
|
+
const dests = (
|
|
63
|
+
<>
|
|
64
|
+
{items.map((i) => (
|
|
65
|
+
<Button
|
|
66
|
+
key={i.path ?? i.id ?? i.label}
|
|
67
|
+
variant="nav"
|
|
68
|
+
size="lg"
|
|
69
|
+
iconLeft={i.icon}
|
|
70
|
+
iconSize={glyph}
|
|
71
|
+
aria-current={i.path != null && i.path === active ? 'page' : undefined}
|
|
72
|
+
className={rowCls}
|
|
73
|
+
onClick={() => onPick?.(i)}
|
|
74
|
+
>
|
|
75
|
+
{i.label}
|
|
76
|
+
</Button>
|
|
77
|
+
))}
|
|
78
|
+
</>
|
|
79
|
+
)
|
|
80
|
+
return itemsFirst ? <>{dests}{acts}</> : <>{acts}{dests}</>
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const rowKey = (r) => r.id ?? r.path ?? r.label
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* MenuFloat — A float's card with NESTED LEVELS (FloatsOwnItems, kol-fxr 2026-10-31 — *"does the float nav offer nested
|
|
87
|
+
* menus"*). Wraps the card's first level (`children`, MenuFloatRows); a MenuFloatRows action with `sub` opens the next level, the same
|
|
88
|
+
* row shape to any depth (`sub[].sub[].sub…`). How a level opens is one rule, by room:
|
|
89
|
+
* - `beside` (the desk's `dock`) — a card of the same chrome beside its parent row, right of it, the bottom edges on one
|
|
90
|
+
* line, through the existing popover (`usePopover` + `PopoverPanel`, flips and shifts at the window's edge);
|
|
91
|
+
* - else (every phone variant) — the level REPLACES the card's rows, under a Back row naming the parent.
|
|
92
|
+
* A leaf runs its `onPress`, then `onLeaf(row)` closes every level (the caller closes the card — Escape and an outside press
|
|
93
|
+
* are the card's, and closing it closes everything). Keys: ↑ ↓ move, → or Enter opens a level, ← goes back one.
|
|
94
|
+
*
|
|
95
|
+
* @param {boolean} beside levels open beside their row (else they replace the card's rows)
|
|
96
|
+
* @param {string} cardClass a beside level's chrome — the first card's classes
|
|
97
|
+
* @param {Function} onLeaf `(row) => void` — a nested leaf was picked (its `onPress` has run); close everything here
|
|
98
|
+
* @param {ReactNode} [title] the card's header — Header variant="property", the header every float Rail wears (the user
|
|
99
|
+
* 2026-11-12: *"why is it so hard TO USE THE SAME FUCKING HEADER"*); each opener passes the label of
|
|
100
|
+
* the button that opened it. Unset, no header
|
|
101
|
+
* @param {ReactNode} [titleActions] the header's actions slot (RailTrigger's ×)
|
|
102
|
+
*/
|
|
103
|
+
export function MenuFloat({ beside = false, cardClass = '', onLeaf, title, titleActions, children }) {
|
|
104
|
+
/* the open rows, outermost first — `{ row, el }`, `el` the row a beside level hangs off.
|
|
105
|
+
* ponytail: the row object is kept as opened; a consumer that rebuilds its rows mid-open sees the old `sub` until reopened */
|
|
106
|
+
const [trail, setTrail] = useState([])
|
|
107
|
+
const at = (depth) => ({
|
|
108
|
+
open: (row, el) => setTrail((t) => (t[depth] && rowKey(t[depth].row) === rowKey(row) ? t.slice(0, depth) : [...t.slice(0, depth), { row, el }])),
|
|
109
|
+
isOpen: (row) => !!trail[depth] && rowKey(trail[depth].row) === rowKey(row),
|
|
110
|
+
})
|
|
111
|
+
const back = (depth) => { const parent = trail[depth - 1]?.el; setTrail((t) => t.slice(0, depth - 1)); if (beside) parent?.focus({ preventScroll: true }) }
|
|
112
|
+
const keys = (depth) => (e) => {
|
|
113
|
+
const rows = [...e.currentTarget.querySelectorAll('button')]
|
|
114
|
+
const i = rows.indexOf(document.activeElement)
|
|
115
|
+
if (e.key === 'ArrowDown' || e.key === 'ArrowUp') rows[(i + (e.key === 'ArrowDown' ? 1 : -1) + rows.length) % rows.length]?.focus()
|
|
116
|
+
else if (e.key === 'ArrowRight' && e.target.getAttribute?.('aria-haspopup')) { if (e.target.getAttribute('aria-expanded') !== 'true') e.target.click() }
|
|
117
|
+
else if (e.key === 'ArrowLeft' && depth > 0) back(depth)
|
|
118
|
+
else return
|
|
119
|
+
e.preventDefault()
|
|
120
|
+
e.stopPropagation()
|
|
121
|
+
}
|
|
122
|
+
const level = (depth, rows, lead) => (
|
|
123
|
+
<Level.Provider value={at(depth)}>
|
|
124
|
+
<LevelRows key={`${depth}:${rowKey(trail[depth - 1].row)}`} onKeyDown={keys(depth)}>
|
|
125
|
+
{lead}
|
|
126
|
+
<MenuFloatRows variant="float" actions={rows} onPick={onLeaf} />
|
|
127
|
+
</LevelRows>
|
|
128
|
+
</Level.Provider>
|
|
129
|
+
)
|
|
130
|
+
|
|
131
|
+
/* the header stays on top while a level replaces the rows; title 12 in, as the rows' labels */
|
|
132
|
+
const head = title != null && title !== false && (
|
|
133
|
+
<Header variant="property" title={title} end={titleActions} className={`pl-3 ${titleActions ? 'pr-1' : 'pr-3'} pt-1 pb-2`} />
|
|
134
|
+
)
|
|
135
|
+
if (!beside && trail.length) {
|
|
136
|
+
const d = trail.length
|
|
137
|
+
return <>{head}{level(d, trail[d - 1].row.sub, (
|
|
138
|
+
<Button variant="nav" size="lg" iconLeft="chevron-left" iconSize="var(--kol-float-ic)" className={FLOAT_ROW} onClick={() => back(d)}>{trail[d - 1].row.label}</Button>
|
|
139
|
+
))}</>
|
|
140
|
+
}
|
|
141
|
+
return (
|
|
142
|
+
<Level.Provider value={at(0)}>
|
|
143
|
+
{head}
|
|
144
|
+
<div className="contents" onKeyDown={keys(0)}>{children}</div>
|
|
145
|
+
{beside && trail.map((s, i) => (
|
|
146
|
+
<Beside key={i} anchor={s.el} cardClass={cardClass}>{level(i + 1, s.row.sub)}</Beside>
|
|
147
|
+
))}
|
|
148
|
+
</Level.Provider>
|
|
149
|
+
)
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/* a nested level's rows — its first row takes the focus when it opens, so the keys carry on in it */
|
|
153
|
+
function LevelRows({ onKeyDown, children }) {
|
|
154
|
+
const ref = useRef(null)
|
|
155
|
+
useEffect(() => { ref.current?.querySelector('button')?.focus({ preventScroll: true }) }, [])
|
|
156
|
+
return <div ref={ref} className="contents" onKeyDown={onKeyDown}>{children}</div>
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/* a level beside its row — the + menu's popover: right of the row, 12 off the card (the row sits 6 in), the bottom edges on
|
|
160
|
+
* one line. `kol-float-level` marks it so a parent popover's outside press lets it be */
|
|
161
|
+
function Beside({ anchor, cardClass, children }) {
|
|
162
|
+
const pop = usePopover({ open: true, placement: 'right-end', offset: { mainAxis: 18, crossAxis: 6 }, click: false, dismiss: false, role: 'menu', referenceElement: anchor })
|
|
163
|
+
return <PopoverPanel popover={pop} panel={false} focus={false} className={`kol-float-level ${cardClass}`} style={{ minWidth: 220, maxWidth: 'calc(100vw - 24px)' }}>{children}</PopoverPanel>
|
|
164
|
+
}
|
package/src/molecules/Modal.jsx
CHANGED
|
@@ -3,6 +3,7 @@ import { createPortal } from 'react-dom'
|
|
|
3
3
|
import Button from '../atoms/Button.jsx'
|
|
4
4
|
import Input from '../atoms/Input.jsx'
|
|
5
5
|
import ToggleCheckbox from '../atoms/ToggleCheckbox.jsx'
|
|
6
|
+
import ButtonGroup from './ButtonGroup.jsx'
|
|
6
7
|
import Header from './Header.jsx'
|
|
7
8
|
import ModalShell from './ModalShell.jsx'
|
|
8
9
|
|
|
@@ -221,15 +222,15 @@ function ModalView({ state, closeWith, variant, contained }) {
|
|
|
221
222
|
style={{
|
|
222
223
|
minWidth: 320,
|
|
223
224
|
maxWidth: contained ? '90%' : '90vw',
|
|
224
|
-
...(float ? { width:
|
|
225
|
+
...(float ? { width: 'var(--kol-float-window-w)' } : {}),
|
|
225
226
|
}}
|
|
226
227
|
header={float && state.header && <Header variant="modal" icon={state.icon} title={state.header} onClose={cancel} />}
|
|
227
228
|
footer={float ? (
|
|
228
|
-
/* the float's actions sit apart: recovery quiet at the left, the next step at the right */
|
|
229
|
-
<
|
|
229
|
+
/* the float's actions sit apart: recovery quiet at the left, the next step at the right — one ButtonGroup (LAW 17) */
|
|
230
|
+
<ButtonGroup align="between">
|
|
230
231
|
{state.kind !== 'alert' ? <Button variant="float" tone="ghost" size="md" onClick={cancel}>{state.cancelLabel ?? 'Cancel'}</Button> : <span />}
|
|
231
232
|
<Button variant="float" tone={state.tone === 'danger' ? 'danger' : 'inverted'} size="md" onClick={submit} data-modal-ok>{state.okLabel ?? 'OK'}</Button>
|
|
232
|
-
</
|
|
233
|
+
</ButtonGroup>
|
|
233
234
|
) : (
|
|
234
235
|
<div className="flex gap-2 justify-end">
|
|
235
236
|
{state.kind !== 'alert' && <Button size="sm" onClick={cancel}>{state.cancelLabel ?? 'Cancel'}</Button>}
|
|
@@ -332,7 +333,8 @@ export function useModal() {
|
|
|
332
333
|
* <ModalDialog open={open} onClose={() => setOpen(false)} title="Filter by page" width={560}>…</ModalDialog>
|
|
333
334
|
*
|
|
334
335
|
* `variant="float"` (float-everything W6 rows 83 · 84 · 89, 2026-11-04 — kol-float--style 46:2655): the float window —
|
|
335
|
-
* `kol-float-solid` on `--kol-float-window-r`,
|
|
336
|
+
* `kol-float-solid` on `--kol-float-window-r`, `--kol-float-window-w` wide unless `width` says otherwise (plan-2026-11-12-one-header
|
|
337
|
+
* W6.1), 24 in, 18 between its parts, the title drawn as `Header
|
|
336
338
|
* variant="modal"` (`icon` · title · − when `onMinimise` · ×) over the children. `blocking` (default true) keeps the
|
|
337
339
|
* scrim: a blocking task dims the scene, a utility window does not (row 89) — `blocking={false}` drops the scrim and the
|
|
338
340
|
* press-outside close and leaves the scene live (QuickLookFrame float is the utility window proper).
|
|
@@ -350,7 +352,8 @@ export function useModal() {
|
|
|
350
352
|
* `[{ key, label, state }]` — the name and a one-line state, 6 apart; the lit one carries its 2px marker and no fill,
|
|
351
353
|
* hover the only fill (LAW 16, plan-2026-11-12-float-rails-figma W13.1; it sat on oq-12 until then); `section` /
|
|
352
354
|
* `onSection`), the body (`children`, 24 in, scrolling), an `aside` column 248 wide (the preview), and a 60 `footer`. The
|
|
353
|
-
* secondary surface, a
|
|
355
|
+
* secondary surface, a 20 round, no outer border (his mock 143:35343, W8.1), oq-16 rules between the parts; the footer hugs
|
|
356
|
+
* its 60 and the body fills the rest. `height` (default 656) and
|
|
354
357
|
* `width` (default 880) are its size; both shrink to the viewport.
|
|
355
358
|
* @param {string} [kind] settings: the line beside the title ("Generate")
|
|
356
359
|
* @param {ReactNode} [headerEnd] settings: the header's right side, before the × (the preset select)
|
|
@@ -358,7 +361,7 @@ export function useModal() {
|
|
|
358
361
|
* @param {string} [section] · @param {Function} [onSection]
|
|
359
362
|
* @param {ReactNode} [aside] · @param {ReactNode} [footer] · @param {number} [height=656]
|
|
360
363
|
*/
|
|
361
|
-
export function ModalDialog({ open, onClose, title, width
|
|
364
|
+
export function ModalDialog({ open, onClose, title, width, variant = 'lift', icon, onMinimise, blocking = true, container, kind, headerEnd, sections, section, onSection, aside, footer, height = 656, children }) {
|
|
362
365
|
const look = variant === 'settings' ? 'settings' : modalVariant(variant, 'lift')
|
|
363
366
|
const float = look === 'float'
|
|
364
367
|
useEffect(() => {
|
|
@@ -376,7 +379,7 @@ export function ModalDialog({ open, onClose, title, width = 560, variant = 'lift
|
|
|
376
379
|
style={{ position: container ? 'absolute' : 'fixed', inset: 0, zIndex: 150, display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
|
|
377
380
|
<ModalShell variant="settings" role="dialog" aria-modal={blocking ? 'true' : undefined} aria-label={title} data-dialog onMouseDown={(e) => e.stopPropagation()}
|
|
378
381
|
className="kol-settings-window pointer-events-auto overflow-hidden"
|
|
379
|
-
style={{ width: `min(${width}px, calc(${within} - 32px))`, height: `min(${height}px, calc(${withinH} - 32px))` }}
|
|
382
|
+
style={{ width: `min(${width ?? 880}px, calc(${within} - 32px))`, height: `min(${height}px, calc(${withinH} - 32px))` }}
|
|
380
383
|
header={<Header variant="settings" title={title} kind={kind} end={headerEnd} onClose={onClose} />}
|
|
381
384
|
footer={footer && <footer className="flex items-center gap-3 h-[60px] shrink-0 px-6 border-t border-oq-16">{footer}</footer>}>
|
|
382
385
|
<div className="flex flex-1 min-h-0">
|
|
@@ -433,7 +436,8 @@ export function ModalDialog({ open, onClose, title, width = 560, variant = 'lift
|
|
|
433
436
|
* mid-page"): it painted the page's own surface behind an fg-08 hairline, so on a dark page it was the page.
|
|
434
437
|
* `.kol-overlay-panel` is the lift every KOL overlay wears (oq-04, no border — the scrim is the edge). */
|
|
435
438
|
className={float ? `pointer-events-auto gap-[18px] p-6 ${container ? 'max-h-[85%]' : 'max-h-[85vh]'} overflow-auto` : `${container ? 'max-h-[85%]' : 'max-h-[85vh]'}${blocking ? '' : ' pointer-events-auto'}`}
|
|
436
|
-
|
|
439
|
+
/* the float window's width is the token (P8: *"why doesnt it use width?"*); `width` (px) still overrides */
|
|
440
|
+
style={{ width: `min(${width != null ? `${width}px` : float ? 'var(--kol-float-window-w)' : '560px'}, calc(${container ? '100%' : '100vw'} - 32px))` }}
|
|
437
441
|
header={float && title && <Header variant="modal" icon={icon} title={title} onMinimise={onMinimise} onClose={onClose} />}
|
|
438
442
|
>
|
|
439
443
|
{children}
|
|
@@ -14,13 +14,13 @@ import { forwardRef } from 'react'
|
|
|
14
14
|
* </ModalShell>
|
|
15
15
|
*
|
|
16
16
|
* ONE RADIUS: `--kol-radius-sm` (4px) — the radius Modal's prompts and Dialog wore. The float style's windows keep the
|
|
17
|
-
* float window radius (`float`, 28) and the generator settings window its
|
|
17
|
+
* 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
18
|
* own, drawn in its Figma.
|
|
19
19
|
*
|
|
20
20
|
* @param {'lift'|'bordered'|'float'|'settings'} [variant='lift']
|
|
21
21
|
* `lift` — the overlay panel every KOL overlay wears (`.kol-overlay-panel`: oq-04, no border, the scrim is the edge);
|
|
22
22
|
* `bordered` — the page surface behind an fg-08 hairline (Modal's prompts); `float` — the float window
|
|
23
|
-
* (`kol-float-solid`); `settings` — the generator settings window (the secondary surface,
|
|
23
|
+
* (`kol-float-solid`); `settings` — the generator settings window (the secondary surface, radius 20, the float shadow, no border).
|
|
24
24
|
* @param {ReactNode} [header] drawn first
|
|
25
25
|
* @param {ReactNode} [footer] drawn last
|
|
26
26
|
* @param {string} [className] the caller's layout: padding, gap, size
|
|
@@ -31,7 +31,7 @@ const VARIANTS = {
|
|
|
31
31
|
lift: { className: 'kol-overlay-panel rounded-[var(--kol-radius-sm)]', style: {} },
|
|
32
32
|
bordered: { className: 'border border-fg-08 rounded-[var(--kol-radius-sm)]', style: { background: 'var(--kol-surface-primary)', color: 'var(--kol-surface-on-primary)' } },
|
|
33
33
|
float: { className: 'kol-float-solid !rounded-[var(--kol-float-window-r)] text-fg-emphasis', style: {} },
|
|
34
|
-
settings: { className: 'rounded-
|
|
34
|
+
settings: { className: 'rounded-[20px] bg-surface-secondary text-fg-96 font-(family-name:--kol-font-family-float) shadow-[var(--kol-shadow-float)]', style: {} },
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
const ModalShell = forwardRef(function ModalShell({ variant = 'lift', header, footer, className = '', style, children, ...rest }, ref) {
|
|
@@ -26,6 +26,7 @@ import { floatSurfaceClass } from '../utilities/tone.js'
|
|
|
26
26
|
* @param {'property'|'nav'} [headerVariant='property'] the Header's variant while open (`nav`: NavRail float's switcher,
|
|
27
27
|
* with `icon` and `onSwitch`); collapsed-v, the pill is always the plain title
|
|
28
28
|
* @param {ReactNode} [title] the header's title, and the collapsed pill's
|
|
29
|
+
* @param {ReactNode} [kind] the quiet second text beside the title (the preset beside the effect, W10.1)
|
|
29
30
|
* @param {ReactNode} [head] replaces the title in the open header (a consumer's own switcher)
|
|
30
31
|
* @param {ReactNode} [actions] the Header's `end`: before the toggles; not on the collapsed pill
|
|
31
32
|
* @param {Function} [onExpand] · {Function} [onCollapseH] the Header's expand and collapse-h; not on the collapsed pill
|
|
@@ -43,7 +44,7 @@ import { floatSurfaceClass } from '../utilities/tone.js'
|
|
|
43
44
|
*/
|
|
44
45
|
const INSET = { md: 'p-4', sm: 'p-3', none: '' }
|
|
45
46
|
|
|
46
|
-
export default function RailFloat({ header, headerVariant = 'property', icon, onSwitch, title, head, actions, onExpand, onCollapseH, collapsibleV, collapsedV, defaultCollapsedV, onCollapseV, foldable, folded, defaultFolded, onFold, compact = false, wide = false, width, inset = 'md', surface = 'solid', footer, as: Tag = 'section', className = '', bodyClassName = '', style, 'aria-label': ariaLabel, children }) {
|
|
47
|
+
export default function RailFloat({ header, headerVariant = 'property', icon, onSwitch, title, kind, head, actions, onExpand, onCollapseH, collapsibleV, collapsedV, defaultCollapsedV, onCollapseV, foldable, folded, defaultFolded, onFold, compact = false, wide = false, width, inset = 'md', surface = 'solid', footer, as: Tag = 'section', className = '', bodyClassName = '', style, 'aria-label': ariaLabel, children }) {
|
|
47
48
|
const canV = collapsibleV ?? foldable ?? false
|
|
48
49
|
const ctlV = collapsedV ?? folded
|
|
49
50
|
const [ownV, setOwnV] = useState(defaultCollapsedV ?? defaultFolded ?? false)
|
|
@@ -53,8 +54,8 @@ export default function RailFloat({ header, headerVariant = 'property', icon, on
|
|
|
53
54
|
const label = ariaLabel ?? (typeof title === 'string' ? title : undefined)
|
|
54
55
|
const gap = compact ? 'gap-2' : 'gap-[var(--kol-float-module-gap)]'
|
|
55
56
|
const headerSlot = header ?? ((head || title || actions || canV || onExpand || onCollapseH) && (isV
|
|
56
|
-
? <Header variant="property" title={title} collapsedV onCollapseV={toggleV} />
|
|
57
|
-
: <Header variant={headerVariant} icon={icon} onSwitch={onSwitch} title={head ?? title} end={actions} onExpand={onExpand} onCollapseH={onCollapseH} onCollapseV={canV ? toggleV : undefined} />
|
|
57
|
+
? <Header variant="property" title={title} kind={kind} collapsedV onCollapseV={toggleV} />
|
|
58
|
+
: <Header variant={headerVariant} icon={icon} onSwitch={onSwitch} title={head ?? title} kind={head ? undefined : kind} end={actions} onExpand={onExpand} onCollapseH={onCollapseH} onCollapseV={canV ? toggleV : undefined} />
|
|
58
59
|
))
|
|
59
60
|
const shape = isV
|
|
60
61
|
? 'flex-row items-center rounded-full pl-4 pr-1.5'
|
|
@@ -1,163 +1,58 @@
|
|
|
1
1
|
import Input from '../atoms/Input.jsx'
|
|
2
2
|
import Button from '../atoms/Button.jsx'
|
|
3
|
-
import ButtonGroup from './ButtonGroup.jsx'
|
|
4
3
|
import ToggleSwitch from '../atoms/ToggleSwitch.jsx'
|
|
5
4
|
import Dropdown from './Dropdown.jsx'
|
|
6
5
|
import Slider from './Slider.jsx'
|
|
6
|
+
import TabsRow from './TabsRow.jsx'
|
|
7
7
|
import LabeledControl from './LabeledControl.jsx'
|
|
8
|
-
import { useEffect, useState } from 'react'
|
|
9
8
|
|
|
10
|
-
/* taxonomy-ok: molecule — the settings window's
|
|
9
|
+
/* taxonomy-ok: molecule — the settings window's composite parts, each built from shipped float atoms */
|
|
11
10
|
|
|
12
11
|
/**
|
|
13
|
-
* The SETTINGS
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
12
|
+
* The SETTINGS parts — what the generator settings window (`ModalDialog variant="settings"`) draws that is MORE than one
|
|
13
|
+
* base control (plan-2026-11-12-one-header W6.1; the user, P9: *"whats the point of taking a base, and wrapping it and
|
|
14
|
+
* adding nothing"*). A plain row is `LabeledControl variant="float"` around the base itself — `Slider variant="float"
|
|
15
|
+
* readout="input"`, `Dropdown variant="float"`, `Input variant="float"`, `TabsRow variant="float"`, a bare float
|
|
16
|
+
* `ToggleSwitch` in a `horizontal` row — never a Settings* part. What stays here composes several:
|
|
17
17
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* SettingsRange two handles on one track (From / To) — the dual Slider, boxed, both values number boxes
|
|
26
|
-
* SettingsSelect the boxed Dropdown (`options` `[{ value, label }]`)
|
|
27
|
-
* SettingsSegmented the boxed SegmentedToggle (Rows / Columns), the lit cell on oq-16
|
|
28
|
-
* SettingsToggle `LabeledControl variant="settings" horizontal`: its words, then the ToggleSwitch
|
|
29
|
-
* SettingsText the boxed Input (text or number)
|
|
30
|
-
* SettingsPoint an X / Y pair of number fields
|
|
31
|
-
* SettingsRamp an A→B row, `LabeledControl variant="settings" horizontal` (an 88 label column): value A · curve ·
|
|
32
|
-
* value B (`SettingsRampHead` the VALUE A · CURVE · VALUE B row)
|
|
33
|
-
* SettingsLights a list of points — X · Y · radius · intensity · delete — and Add light
|
|
34
|
-
* SettingsFieldMap the field's gradient strip: FIELD MAP over a 26 strip (`background`) and two captions
|
|
35
|
-
* SettingsDisclosure a group that starts closed: `LabeledControlSection variant="settings"` whose label is the toggle
|
|
36
|
-
* (the 12 chevron, More geometry … its note)
|
|
18
|
+
* SettingsGrid the two-up grid a group lays its rows in
|
|
19
|
+
* SettingsPoint an X / Y pair of float Inputs (the prefix names the axis)
|
|
20
|
+
* SettingsRamp an A→B row, `LabeledControl variant="float" horizontal`: value A · curve · value B (float Input ·
|
|
21
|
+
* float Dropdown · float Input); `SettingsRampHead` the VALUE A · CURVE · VALUE B row over them
|
|
22
|
+
* SettingsLights a list of points — X · Y · radius · intensity float Inputs · delete — and Add light
|
|
23
|
+
* SettingsFieldMap the field's gradient strip: FIELD MAP over a 26 strip (`background`) and two captions
|
|
24
|
+
* (SettingsDisclosure lives beside LabeledControlSection in organisms/SettingsPanel.jsx)
|
|
37
25
|
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
26
|
+
* Retired 2026-11-12 (deprecated aliases on the retirement ledger, each now rendering its base): SettingsCell →
|
|
27
|
+
* LabeledControl · SettingsSlider → Slider float `readout="input"` · SettingsRange → Slider `dual` · SettingsSelect →
|
|
28
|
+
* Dropdown float · SettingsSegmented → TabsRow float · SettingsToggle → LabeledControl `horizontal` + ToggleSwitch ·
|
|
29
|
+
* SettingsText → Input float. Their originals: `_tmp/2026-11-12-one-header/SettingsControls.before.jsx`.
|
|
30
|
+
*
|
|
31
|
+
* `disabled` on a part dims it to 40% and takes it out of the tab order (a control whose engine param does not exist yet).
|
|
40
32
|
*/
|
|
41
33
|
|
|
42
|
-
const FIELD = 'h-7 w-full min-w-0 rounded-[5px] border border-oq-16 bg-surface-primary'
|
|
43
|
-
const INK = 'text-[11px] leading-[13px] text-fg-96 font-(family-name:--kol-font-family-float)'
|
|
44
34
|
const LABEL = 'text-[10px] leading-[12px] text-oq-64 font-(family-name:--kol-font-family-float)'
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const Dim = ({ disabled, className = '', row, children, ...rest }) => (
|
|
35
|
+
const INK = 'text-[11px] leading-[13px] text-fg-96 font-(family-name:--kol-font-family-float)'
|
|
36
|
+
/* a float Dropdown filling its cell */
|
|
37
|
+
const FILL = 'w-full [&_.kol-dd-trigger]:w-full [&_.kol-dd-trigger]:justify-between'
|
|
38
|
+
const num = (s, fallback) => { const n = parseFloat(String(s).replace(',', '.')); return Number.isFinite(n) ? n : fallback }
|
|
39
|
+
|
|
40
|
+
/* a disabled part: a fieldset disables every input and button inside it natively */
|
|
41
|
+
const Dim = ({ disabled, className = '', children, ...rest }) => (
|
|
53
42
|
<fieldset disabled={disabled || undefined} aria-disabled={disabled || undefined} {...rest}
|
|
54
|
-
className={`min-w-0 m-0 p-0
|
|
55
|
-
{
|
|
43
|
+
className={`min-w-0 m-0 p-0 border-0 ${disabled ? 'opacity-40' : ''} ${className}`.trim()}>
|
|
44
|
+
{children}
|
|
56
45
|
</fieldset>
|
|
57
46
|
)
|
|
58
47
|
|
|
59
48
|
export const SettingsGrid = ({ className = '', children }) => <div className={`grid grid-cols-2 gap-x-3 gap-y-[7px] ${className}`.trim()}>{children}</div>
|
|
60
49
|
|
|
61
|
-
export function
|
|
62
|
-
return (
|
|
63
|
-
<Dim disabled={disabled} className={`${span === 2 ? 'col-span-2' : ''} ${className}`.trim()} {...rest}>
|
|
64
|
-
<LabeledControl variant="settings" label={label}>{children}</LabeledControl>
|
|
65
|
-
</Dim>
|
|
66
|
-
)
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/* a slider's value as a number box (the float spec: a slider's value is the caller's number box, never raw text — the
|
|
70
|
-
* user's Figma issue 60, "no Input shown, just raw text"): the formatted value at rest, typed numbers commit on Enter or
|
|
71
|
-
* blur, clamped to the range; Escape reverts */
|
|
72
|
-
function NumberBox({ value, onCommit, min, max, format, disabled, label, fit = false, className = '' }) {
|
|
73
|
-
const [draft, setDraft] = useState(null)
|
|
74
|
-
useEffect(() => { setDraft(null) }, [value])
|
|
75
|
-
const commit = () => {
|
|
76
|
-
const n = parseFloat(String(draft ?? '').replace(',', '.'))
|
|
77
|
-
if (draft != null && Number.isFinite(n)) onCommit?.(Math.min(max, Math.max(min, n)))
|
|
78
|
-
setDraft(null)
|
|
79
|
-
}
|
|
80
|
-
return (
|
|
81
|
-
<input type="text" inputMode="decimal" value={draft ?? format(value)} disabled={disabled} aria-label={label}
|
|
82
|
-
onFocus={(e) => { setDraft(String(value)); requestAnimationFrame(() => e.target.select()) }} onChange={(e) => setDraft(e.target.value)} onBlur={commit}
|
|
83
|
-
onKeyDown={(e) => { if (e.key === 'Enter') e.currentTarget.blur(); if (e.key === 'Escape') { setDraft(null); requestAnimationFrame(() => e.target.blur()) } }}
|
|
84
|
-
style={fit ? { width: `${Math.max(1, String(draft ?? format(value)).length)}ch` } : undefined}
|
|
85
|
-
className={`${MONO} min-w-0 bg-transparent border-0 p-0 focus:outline-none tabular-nums ${className}`.trim()} />
|
|
86
|
-
)
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export function SettingsSlider({ value, onChange, min = 0, max = 1, step = 0.01, format = (v) => String(v), disabled, 'aria-label': ariaLabel }) {
|
|
90
|
-
return (
|
|
91
|
-
<Dim disabled={disabled} className={FIELD} row="gap-3 pl-[9px] pr-2">
|
|
92
|
-
<Slider variant="float" readout="none" value={value} onChange={onChange} min={min} max={max} step={step} disabled={disabled}
|
|
93
|
-
aria-label={ariaLabel} className="flex-1 min-w-0 [&_.kol-slider-float]:h-4" />
|
|
94
|
-
<NumberBox value={value} onCommit={onChange} min={min} max={max} format={format} disabled={disabled} label={`${ariaLabel ?? 'Value'} value`} className="w-[52px] shrink-0" />
|
|
95
|
-
</Dim>
|
|
96
|
-
)
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export function SettingsRange({ value = [0, 1], onChange, min = 0, max = 1, step = 0.01, format = (v) => String(v), disabled, 'aria-label': ariaLabel }) {
|
|
100
|
-
const [a, b] = value
|
|
101
|
-
return (
|
|
102
|
-
<Dim disabled={disabled} className={FIELD} row="gap-2 px-2">
|
|
103
|
-
<NumberBox value={a} onCommit={(v) => onChange?.([Math.min(v, b), b])} min={min} max={max} format={format} disabled={disabled} label={`${ariaLabel ?? 'Range'} from`} className="shrink-0" fit />
|
|
104
|
-
<Slider variant="dual" value={a} value2={b} min={min} max={max} step={step} aria-label={ariaLabel}
|
|
105
|
-
onChange={(v) => onChange?.([Math.min(v, b), b])} onChange2={(v) => onChange?.([a, Math.max(v, a)])}
|
|
106
|
-
label1="" label2="" className="flex-1 min-w-0" />
|
|
107
|
-
<NumberBox value={b} onCommit={(v) => onChange?.([a, Math.max(v, a)])} min={min} max={max} format={format} disabled={disabled} label={`${ariaLabel ?? 'Range'} to`} className="shrink-0 text-right" fit />
|
|
108
|
-
</Dim>
|
|
109
|
-
)
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
export function SettingsSelect({ value, onChange, options = [], disabled, ariaLabel, className = '' }) {
|
|
113
|
-
return (
|
|
114
|
-
<Dim disabled={disabled} className="w-full">
|
|
115
|
-
<Dropdown value={value} onChange={onChange} options={options} ariaLabel={ariaLabel} size="sm"
|
|
116
|
-
className={`w-full [&_.kol-dd-trigger]:w-full [&_.kol-dd-trigger]:!h-7 [&_.kol-dd-trigger]:!rounded-[5px] [&_.kol-dd-trigger]:!border [&_.kol-dd-trigger]:!border-(--kol-oq-16) [&_.kol-dd-trigger]:!bg-(--kol-surface-primary) [&_.kol-dd-trigger]:!px-2 [&_.kol-dd-trigger]:!text-[11px] [&_.kol-dd-trigger]:!font-normal [&_.kol-dd-trigger]:!text-(--kol-fg-96) [&_.kol-dd-trigger]:font-(family-name:--kol-font-family-float) [&_.kol-dd-trigger]:justify-between [&_.kol-dd-caret]:text-(--kol-oq-64) ${className}`.trim()} />
|
|
117
|
-
</Dim>
|
|
118
|
-
)
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
export function SettingsSegmented({ value, onChange, options = [], disabled, ariaLabel }) {
|
|
122
|
-
return (
|
|
123
|
-
<Dim disabled={disabled} className={`${FIELD} p-0.5`}>
|
|
124
|
-
<ButtonGroup layout="joined" value={value} onChange={onChange} options={options} ariaLabel={ariaLabel} size="sm"
|
|
125
|
-
className="!flex w-full h-full !border-0 !bg-transparent !p-0 gap-0 [&_.kol-seg-cell]:flex-1 [&_.kol-seg-cell]:h-full [&_.kol-seg-cell]:!rounded-[3px] [&_.kol-seg-cell]:!border-0 [&_.kol-seg-cell]:!bg-transparent [&_.kol-seg-cell]:!text-[10px] [&_.kol-seg-cell]:!text-(--kol-oq-64) [&_.kol-seg-cell]:font-(family-name:--kol-font-family-float) [&_.kol-seg-cell.is-active]:!bg-(--kol-oq-16) [&_.kol-seg-cell.is-active]:!text-(--kol-fg-96) [&_.kol-seg-cell.is-active]:font-medium" />
|
|
126
|
-
</Dim>
|
|
127
|
-
)
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
export function SettingsToggle({ label, checked, onChange, disabled }) {
|
|
131
|
-
return (
|
|
132
|
-
<Dim disabled={disabled} className="h-7" row="min-w-0">
|
|
133
|
-
<LabeledControl variant="settings" horizontal label={label} labelClass={INK}>
|
|
134
|
-
<ToggleSwitch checked={!!checked} onChange={onChange} aria-label={label} disabled={disabled} />
|
|
135
|
-
</LabeledControl>
|
|
136
|
-
</Dim>
|
|
137
|
-
)
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
export function SettingsText({ value, onChange, onCommit, type = 'text', placeholder, disabled, 'aria-label': ariaLabel, className = '' }) {
|
|
141
|
-
return (
|
|
142
|
-
<Dim disabled={disabled} className="w-full">
|
|
143
|
-
<Input variant="outline" size="sm" type={type} value={value ?? ''} placeholder={placeholder} aria-label={ariaLabel}
|
|
144
|
-
onChange={onChange ? (e) => onChange(type === 'number' ? Number(e.target.value) : e.target.value) : undefined}
|
|
145
|
-
onCommit={onCommit} disabled={disabled}
|
|
146
|
-
className={`${FIELD} !px-2 !py-0 [&_input]:text-[11px] [&_input]:text-(--kol-fg-96) [&_input]:font-(family-name:--kol-font-family-float) ${className}`.trim()} />
|
|
147
|
-
</Dim>
|
|
148
|
-
)
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
export function SettingsPoint({ value = [0.5, 0.5], onChange, min, max, step = 0.01, disabled, 'aria-label': ariaLabel }) {
|
|
50
|
+
export function SettingsPoint({ value = [0.5, 0.5], onChange, min, max, disabled, 'aria-label': ariaLabel }) {
|
|
152
51
|
const [x, y] = value
|
|
153
52
|
const clamp = (n) => Math.min(max ?? Infinity, Math.max(min ?? -Infinity, n))
|
|
154
53
|
const field = (axis, v, set) => (
|
|
155
|
-
<
|
|
156
|
-
|
|
157
|
-
<input type="number" value={v} min={min} max={max} step={step} disabled={disabled} aria-label={`${ariaLabel ?? 'Point'} ${axis}`}
|
|
158
|
-
onChange={(e) => { const n = Number(e.target.value); if (Number.isFinite(n)) set(clamp(n)) }}
|
|
159
|
-
className={`${INK} w-full min-w-0 bg-transparent border-0 p-0 focus:outline-none tabular-nums`} />
|
|
160
|
-
</label>
|
|
54
|
+
<Input variant="float" size="sm" prefix={axis} value={String(v)} disabled={disabled} aria-label={`${ariaLabel ?? 'Point'} ${axis}`}
|
|
55
|
+
onCommit={(s) => set(clamp(num(s, v)))} width="100%" />
|
|
161
56
|
)
|
|
162
57
|
return (
|
|
163
58
|
<Dim disabled={disabled} className="grid grid-cols-2 gap-2">
|
|
@@ -167,8 +62,9 @@ export function SettingsPoint({ value = [0.5, 0.5], onChange, min, max, step = 0
|
|
|
167
62
|
)
|
|
168
63
|
}
|
|
169
64
|
|
|
65
|
+
/* the head over a ramp table: an empty label column (the float label width), then the three columns */
|
|
170
66
|
export const SettingsRampHead = () => (
|
|
171
|
-
<div className="grid grid-cols-[
|
|
67
|
+
<div className="grid grid-cols-[var(--kol-float-label-w)_minmax(0,87fr)_minmax(0,122fr)_minmax(0,87fr)] gap-x-2 pb-0.5" aria-hidden="true">
|
|
172
68
|
<span />
|
|
173
69
|
{['Value A', 'Curve', 'Value B'].map((t) => <span key={t} className={`${LABEL} uppercase text-center`}>{t}</span>)}
|
|
174
70
|
</div>
|
|
@@ -176,20 +72,19 @@ export const SettingsRampHead = () => (
|
|
|
176
72
|
|
|
177
73
|
export function SettingsRamp({ label, value = { a: 0, b: 1, curve: 'linear' }, onChange, curves = [], disabled, partial, ...rest }) {
|
|
178
74
|
const set = (k) => (v) => onChange?.({ ...value, [k]: v })
|
|
179
|
-
const
|
|
180
|
-
<
|
|
181
|
-
|
|
182
|
-
className={`${FIELD} ${INK} px-2 focus:outline-none focus-visible:shadow-[var(--kol-float-focus)] tabular-nums ${partial?.[k] ? 'opacity-40' : ''}`} />
|
|
75
|
+
const box = (k) => (
|
|
76
|
+
<Input variant="float" size="sm" value={String(value[k])} aria-label={`${label} value ${k.toUpperCase()}`} disabled={disabled || partial?.[k]}
|
|
77
|
+
onCommit={(s) => set(k)(num(s, value[k]))} width="100%" className={partial?.[k] ? 'opacity-40' : ''} />
|
|
183
78
|
)
|
|
184
79
|
return (
|
|
185
80
|
<Dim disabled={disabled} {...rest}>
|
|
186
|
-
<LabeledControl variant="
|
|
81
|
+
<LabeledControl variant="float" horizontal label={label}>
|
|
187
82
|
<div className="grid grid-cols-[minmax(0,87fr)_minmax(0,122fr)_minmax(0,87fr)] gap-x-2 items-center">
|
|
188
|
-
{
|
|
83
|
+
{box('a')}
|
|
189
84
|
<div className={partial?.curve ? 'opacity-40' : ''}>
|
|
190
|
-
<
|
|
85
|
+
<Dropdown variant="float" size="sm" value={value.curve} onChange={set('curve')} options={curves} ariaLabel={`${label} curve`} disabled={disabled || partial?.curve} className={FILL} />
|
|
191
86
|
</div>
|
|
192
|
-
{
|
|
87
|
+
{box('b')}
|
|
193
88
|
</div>
|
|
194
89
|
</LabeledControl>
|
|
195
90
|
</Dim>
|
|
@@ -198,25 +93,23 @@ export function SettingsRamp({ label, value = { a: 0, b: 1, curve: 'linear' }, o
|
|
|
198
93
|
|
|
199
94
|
export function SettingsLights({ value = [], onChange, disabled }) {
|
|
200
95
|
const set = (i, k, n) => onChange?.(value.map((l, j) => (j === i ? { ...l, [k]: n } : l)))
|
|
201
|
-
const cell = (i, k, v, label
|
|
202
|
-
<
|
|
203
|
-
|
|
204
|
-
className={`${FIELD} ${INK} px-2 focus:outline-none focus-visible:shadow-[var(--kol-float-focus)] tabular-nums`} />
|
|
96
|
+
const cell = (i, k, v, label) => (
|
|
97
|
+
<Input variant="float" size="sm" value={String(v)} aria-label={`Light ${i + 1} ${label}`} width="100%"
|
|
98
|
+
onCommit={(s) => set(i, k, num(s, v))} />
|
|
205
99
|
)
|
|
206
100
|
return (
|
|
207
101
|
<Dim disabled={disabled} className="flex flex-col gap-1">
|
|
208
|
-
<div className="grid grid-cols-[
|
|
102
|
+
<div className="grid grid-cols-[repeat(4,minmax(0,1fr))_28px] gap-x-2 pb-0.5" aria-hidden="true">
|
|
209
103
|
{['X', 'Y', 'Radius', 'Intensity'].map((t) => <span key={t} className={`${LABEL} uppercase`}>{t}</span>)}
|
|
210
104
|
<span />
|
|
211
105
|
</div>
|
|
212
106
|
{value.map((l, i) => (
|
|
213
|
-
<div key={i} className="grid grid-cols-[
|
|
107
|
+
<div key={i} className="grid grid-cols-[repeat(4,minmax(0,1fr))_28px] gap-x-2 items-center">
|
|
214
108
|
{cell(i, 'x', l.x, 'X')}{cell(i, 'y', l.y, 'Y')}{cell(i, 'radius', l.radius, 'radius')}{cell(i, 'intensity', l.intensity, 'intensity')}
|
|
215
|
-
<Button tone="ghost"
|
|
109
|
+
<Button variant="float" tone="ghost" size="sm" iconOnly="trash" aria-label={`Delete light ${i + 1}`} onClick={() => onChange?.(value.filter((_, j) => j !== i))} />
|
|
216
110
|
</div>
|
|
217
111
|
))}
|
|
218
|
-
<
|
|
219
|
-
className={`${INK} self-start h-7 px-2 rounded-[5px] hover:bg-(--kol-oq-08) focus-visible:outline-none focus-visible:shadow-[var(--kol-float-focus)]`}>+ Add light</button>
|
|
112
|
+
<Button variant="float" tone="ghost" size="sm" className="self-start" onClick={() => onChange?.([...value, { x: 0.5, y: 0.5, radius: 0.3, intensity: 1 }])}>+ Add light</Button>
|
|
220
113
|
</Dim>
|
|
221
114
|
)
|
|
222
115
|
}
|
|
@@ -233,3 +126,55 @@ export function SettingsFieldMap({ background, left, right, label = 'Field map'
|
|
|
233
126
|
</div>
|
|
234
127
|
)
|
|
235
128
|
}
|
|
129
|
+
|
|
130
|
+
/* ── retired 2026-11-12: each renders its base; on the retirement ledger until no repo imports it ─────────────────── */
|
|
131
|
+
|
|
132
|
+
/** @deprecated 2026-11-12 — `LabeledControl variant="float"` around the control (`col-span-2` for a wide cell) */
|
|
133
|
+
export function SettingsCell({ label, span = 1, disabled, className = '', children, ...rest }) {
|
|
134
|
+
return (
|
|
135
|
+
<Dim disabled={disabled} className={`${span === 2 ? 'col-span-2' : ''} ${className}`.trim()} {...rest}>
|
|
136
|
+
<LabeledControl variant="float" label={label}>{children}</LabeledControl>
|
|
137
|
+
</Dim>
|
|
138
|
+
)
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/** @deprecated 2026-11-12 — `Slider variant="float" readout="input"` (`format` → `formatValue`) */
|
|
142
|
+
export function SettingsSlider({ value, onChange, min = 0, max = 1, step = 0.01, format, disabled, 'aria-label': ariaLabel }) {
|
|
143
|
+
return <Slider variant="float" readout="input" value={value} onChange={onChange} min={min} max={max} step={step} formatValue={format} disabled={disabled} aria-label={ariaLabel} />
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/** @deprecated 2026-11-12 — `Slider variant="dual"` (`value` / `value2`, the formatted values as `label1` / `label2`) */
|
|
147
|
+
export function SettingsRange({ value = [0, 1], onChange, min = 0, max = 1, step = 0.01, format = (v) => String(v), disabled, 'aria-label': ariaLabel }) {
|
|
148
|
+
const [a, b] = value
|
|
149
|
+
return (
|
|
150
|
+
<Slider variant="dual" value={a} value2={b} min={min} max={max} step={step} disabled={disabled} aria-label={ariaLabel} label1={format(a)} label2={format(b)}
|
|
151
|
+
onChange={(v) => onChange?.([Math.min(v, b), b])} onChange2={(v) => onChange?.([a, Math.max(v, a)])} />
|
|
152
|
+
)
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/** @deprecated 2026-11-12 — `Dropdown variant="float"` */
|
|
156
|
+
export function SettingsSelect({ value, onChange, options = [], disabled, ariaLabel, className = '' }) {
|
|
157
|
+
return <Dropdown variant="float" size="sm" value={value} onChange={onChange} options={options} ariaLabel={ariaLabel} disabled={disabled} className={`${FILL} ${className}`.trim()} />
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/** @deprecated 2026-11-12 — `TabsRow variant="float"` */
|
|
161
|
+
export function SettingsSegmented({ value, onChange, options = [], ariaLabel }) {
|
|
162
|
+
return <TabsRow variant="float" size="xs" tabs={options} value={value} onChange={onChange} ariaLabel={ariaLabel} className="w-full [&>*]:flex-1" />
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/** @deprecated 2026-11-12 — `LabeledControl variant="float" horizontal` around a bare `ToggleSwitch variant="float"` */
|
|
166
|
+
export function SettingsToggle({ label, checked, onChange, disabled }) {
|
|
167
|
+
return (
|
|
168
|
+
<LabeledControl variant="float" horizontal label={label} labelWidth="fit-content" className={disabled ? 'opacity-40' : ''}>
|
|
169
|
+
<ToggleSwitch variant="float" checked={!!checked} onChange={onChange} aria-label={label} disabled={disabled} />
|
|
170
|
+
</LabeledControl>
|
|
171
|
+
)
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/** @deprecated 2026-11-12 — `Input variant="float"` */
|
|
175
|
+
export function SettingsText({ value, onChange, onCommit, type = 'text', placeholder, disabled, 'aria-label': ariaLabel, className = '' }) {
|
|
176
|
+
return (
|
|
177
|
+
<Input variant="float" size="sm" type={type} value={value ?? ''} placeholder={placeholder} aria-label={ariaLabel} disabled={disabled} width="100%" className={className}
|
|
178
|
+
onChange={onChange ? (e) => onChange(type === 'number' ? Number(e.target.value) : e.target.value) : undefined} onCommit={onCommit} />
|
|
179
|
+
)
|
|
180
|
+
}
|
package/src/molecules/Slider.jsx
CHANGED
|
@@ -46,7 +46,7 @@ import LabeledControl from './LabeledControl.jsx'
|
|
|
46
46
|
* @param {string} props.fontSize - Font size for label/value (e.g., '11px')
|
|
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
|
-
* @param {'input'|'value'|'none'} props.readout - `input` (default) an editable Input · `value` a plain right-aligned span, Knob's own display-only readout · `none`
|
|
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
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%`)
|
|
51
51
|
* @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
52
|
* @param {number} props.height - vertical only — the track's length in px (default 96; panel 60)
|
|
@@ -74,7 +74,7 @@ const Slider = ({
|
|
|
74
74
|
readoutPreset,
|
|
75
75
|
fontSize,
|
|
76
76
|
defaultValue,
|
|
77
|
-
readout
|
|
77
|
+
readout,
|
|
78
78
|
variant = 'minimal',
|
|
79
79
|
value2,
|
|
80
80
|
onChange2,
|
|
@@ -159,7 +159,8 @@ const Slider = ({
|
|
|
159
159
|
|
|
160
160
|
const commit = () => {
|
|
161
161
|
setEditing(false)
|
|
162
|
-
|
|
162
|
+
/* parseFloat, so a formatted value typed back (`45°`, `0,5`) still reads; an empty field reverts */
|
|
163
|
+
const parsed = parseFloat(String(draft).replace(',', '.'))
|
|
163
164
|
if (!Number.isFinite(parsed) || onChange == null) {
|
|
164
165
|
setDraft(displayValue)
|
|
165
166
|
return
|
|
@@ -286,14 +287,37 @@ const Slider = ({
|
|
|
286
287
|
onClick={onAltReset}
|
|
287
288
|
disabled={disabled}
|
|
288
289
|
aria-label={ariaLabel ?? (typeof label === 'string' ? label : undefined)}
|
|
289
|
-
className={`kol-slider-float block min-w-0 ${label ? 'w-full' : className || 'w-full'}`.trim()}
|
|
290
|
-
style={{ '--kol-slider-pct': `${pct}%`, ...(length ? { width: length } : null), ...(label ? null : style) }}
|
|
290
|
+
className={`kol-slider-float block min-w-0 ${readout === 'input' ? 'flex-1 w-full' : label ? 'w-full' : className || 'w-full'}`.trim()}
|
|
291
|
+
style={{ '--kol-slider-pct': `${pct}%`, ...(length ? { width: length } : null), ...(label || readout === 'input' ? null : style) }}
|
|
291
292
|
/>
|
|
292
293
|
)
|
|
293
|
-
|
|
294
|
+
/* the value pill: the float Input, its width the widest value in `ch` (never a fixed px — validate:float F4) */
|
|
295
|
+
const box = readout === 'input' && (
|
|
296
|
+
<Input
|
|
297
|
+
type="text"
|
|
298
|
+
inputMode="decimal"
|
|
299
|
+
variant="float"
|
|
300
|
+
size="sm"
|
|
301
|
+
chars={Math.max(2, fmt(min).length, fmt(max).length)}
|
|
302
|
+
value={draft}
|
|
303
|
+
disabled={disabled}
|
|
304
|
+
aria-label={`${ariaLabel ?? (typeof label === 'string' ? label : 'Value')} value`}
|
|
305
|
+
/* editing shows the raw number (a `50%` reading is typed as 0.5, the engine's unit) */
|
|
306
|
+
onFocus={(e) => { const el = e.target; setEditing(true); setDraft(String(value)); requestAnimationFrame(() => el.select()) }}
|
|
307
|
+
onChange={(e) => setDraft(e.target.value)}
|
|
308
|
+
onBlur={commit}
|
|
309
|
+
onKeyDown={onKeyDown}
|
|
310
|
+
className="shrink-0"
|
|
311
|
+
inputClassName="text-center"
|
|
312
|
+
/>
|
|
313
|
+
)
|
|
314
|
+
const control = box
|
|
315
|
+
? <div className={`flex min-w-0 items-center gap-3 ${label ? 'w-full' : className || 'w-full'}`.trim()} style={label ? undefined : style}>{track}{box}</div>
|
|
316
|
+
: track
|
|
317
|
+
if (!label) return control
|
|
294
318
|
return (
|
|
295
319
|
<LabeledControl variant="float" label={label} hint={readout === 'value' ? displayValue : undefined} className={`${disabled ? 'opacity-40' : ''} ${className}`.trim()}>
|
|
296
|
-
{
|
|
320
|
+
{control}
|
|
297
321
|
</LabeledControl>
|
|
298
322
|
)
|
|
299
323
|
}
|
|
@@ -316,7 +340,7 @@ const Slider = ({
|
|
|
316
340
|
/>
|
|
317
341
|
)
|
|
318
342
|
|
|
319
|
-
const readoutNode = readout === 'input' ? (
|
|
343
|
+
const readoutNode = (readout ?? 'input') === 'input' ? (
|
|
320
344
|
<Input
|
|
321
345
|
type="text"
|
|
322
346
|
inputMode="decimal"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import Header from '../molecules/Header.jsx'
|
|
2
2
|
import TabsRow from '../molecules/TabsRow.jsx'
|
|
3
3
|
|
|
4
4
|
/* taxonomy-ok: organism — the reader's side sheet: header, collapse-v, chip track, body */
|
|
@@ -8,7 +8,7 @@ const TRACK = 'w-full rounded-full bg-[var(--kol-float-well)] p-1 [&>button]:fle
|
|
|
8
8
|
/**
|
|
9
9
|
* ReadingPanel — The reader's side sheet: Notes and Reading behind one track (float-everything W11 rows 150 · 151,
|
|
10
10
|
* 2026-11-04 — kol-float--style W2.9 `Contextual reading panel`). A 320 sheet on `surface-secondary` at the sheet
|
|
11
|
-
* radius (`--kol-float-menu-r`), 20 in: the title in `kol-float-body-lg` with the collapse-v ⌃ (
|
|
11
|
+
* radius (`--kol-float-menu-r`), 20 in: `Header variant="property"` — the title in `kol-float-body-lg` with the collapse-v ⌃ (12) at the
|
|
12
12
|
* end, the float chip track under it (fg-16 on the well, the halves equal), then the body — `ReadingNotes` or
|
|
13
13
|
* `ReadingSettings` as `children`. No hairline edge.
|
|
14
14
|
*
|
|
@@ -25,10 +25,9 @@ const TABS = [{ value: 'notes', label: 'Notes' }, { value: 'reading', label: 'Re
|
|
|
25
25
|
export default function ReadingPanel({ title = 'Reading panel', tabs = TABS, tab = 'notes', onTab, onCollapseV, onFold, children, width = 320, className = '' }) {
|
|
26
26
|
return (
|
|
27
27
|
<aside className={`flex flex-col rounded-[var(--kol-float-menu-r)] bg-surface-secondary p-5 ${className}`.trim()} style={{ width }} aria-label={title}>
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
</div>
|
|
28
|
+
{/* the one Header (property), its collapse-v chevron the 12 token (plan-2026-11-12-one-header W1.1 leftover); the title
|
|
29
|
+
* keeps its body-lg face as the title slot */}
|
|
30
|
+
<Header variant="property" title={<span className="kol-float-body-lg text-fg-emphasis truncate">{title}</span>} onCollapseV={onCollapseV ?? onFold} className="h-7 [&>span:last-child]:-mr-1.5" />
|
|
32
31
|
<TabsRow variant="float" size="xs" overflow="wrap" tabs={tabs} value={tab} onChange={onTab} ariaLabel={title} className={`mt-4 ${TRACK}`} />
|
|
33
32
|
<div className="mt-6">{children}</div>
|
|
34
33
|
</aside>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Children } from 'react'
|
|
1
|
+
import { Children, useState } from 'react'
|
|
2
2
|
import { IconLoader } from '@kolkrabbi/kol-icons'
|
|
3
3
|
import Button from '../atoms/Button.jsx'
|
|
4
4
|
import Dropdown from '../molecules/Dropdown.jsx'
|
|
@@ -199,7 +199,8 @@ export function SettingsSwitch({ on = false, onChange, disabled = false, disable
|
|
|
199
199
|
* (`nav` for a list of links), the rest of the props on it. */
|
|
200
200
|
const GAP = { 0.5: 'gap-0.5', 1: 'gap-1', 1.5: 'gap-1.5', 2: 'gap-2', 3: 'gap-3', module: 'gap-[var(--kol-float-module-gap)]' }
|
|
201
201
|
const SETTINGS_GAP = { 3: 'gap-3', 4: 'gap-4', settings: 'gap-[7px]' }
|
|
202
|
-
export function LabeledControlSection({ label, end, variant, divided = false, gap, rowGap, as: Tag = 'div', children, className = '', ...rest }) {
|
|
202
|
+
export function LabeledControlSection({ label, end, variant, divided = false, gap, rowGap, collapsible = false, open, defaultOpen = true, onToggle, as: Tag = 'div', children, className = '', ...rest }) {
|
|
203
|
+
const [ownOpen, setOwnOpen] = useState(defaultOpen)
|
|
203
204
|
/* `variant="settings"` (plan-2026-11-12-float-rails-figma W13.1): the generator settings window's group — the head is
|
|
204
205
|
* the title (a string in Inter 12 semibold) with `end` (the note) at its right on one baseline, 15 over the items;
|
|
205
206
|
* `divided` rules it off from the next group (22 under the items, an oq-16 rule, 18 to the next; the last none).
|
|
@@ -222,15 +223,28 @@ export function LabeledControlSection({ label, end, variant, divided = false, ga
|
|
|
222
223
|
if (variant === 'float') {
|
|
223
224
|
const items = Children.toArray(children)
|
|
224
225
|
const hasLabel = label != null && label !== false && label !== ''
|
|
226
|
+
const head = hasLabel && (typeof label === 'string' ? <span className="kol-float-label text-oq-64">{label}</span> : label)
|
|
227
|
+
/* `collapsible` (plan-2026-11-12-one-header W10.1): the head is the toggle, ONE indicator — the 12 chevron at its right
|
|
228
|
+
* end (⌄ open, › closed), the Header's chevron; `open` controlled or `defaultOpen`, `onToggle(open)`. `end` sits before
|
|
229
|
+
* the chevron and must not be interactive. The items hide while closed. */
|
|
230
|
+
const isOpen = !collapsible || (open ?? ownOpen)
|
|
231
|
+
const toggle = () => { const next = !isOpen; if (open === undefined) setOwnOpen(next); onToggle?.(next) }
|
|
225
232
|
return (
|
|
226
|
-
<Tag data-labeled-control-section="" className={`flex flex-col ${GAP[gap ?? 3]} ${className}`.trim()} {...rest}>
|
|
227
|
-
{
|
|
233
|
+
<Tag data-labeled-control-section="" data-open={collapsible ? String(isOpen) : undefined} className={`flex flex-col ${GAP[gap ?? 3]} ${className}`.trim()} {...rest}>
|
|
234
|
+
{collapsible ? (
|
|
235
|
+
<button type="button" aria-expanded={isOpen} onClick={toggle}
|
|
236
|
+
className="flex w-full items-center gap-2 text-left rounded-sm cursor-pointer focus-visible:outline-none focus-visible:shadow-[var(--kol-float-focus)]">
|
|
237
|
+
<span className="flex min-w-0 flex-1 items-center">{head}</span>
|
|
238
|
+
{end}
|
|
239
|
+
<IconLoader name={isOpen ? 'chevron-down' : 'chevron-right'} size="var(--kol-float-chev-sm)" className="shrink-0 text-oq-64" />
|
|
240
|
+
</button>
|
|
241
|
+
) : (hasLabel || end) && (
|
|
228
242
|
<div className="flex items-center justify-between">
|
|
229
|
-
{
|
|
243
|
+
{head}
|
|
230
244
|
{end}
|
|
231
245
|
</div>
|
|
232
246
|
)}
|
|
233
|
-
{items.length > 0 && <div className={`flex flex-col ${GAP[rowGap ?? 2]}`}>{items}</div>}
|
|
247
|
+
{isOpen && items.length > 0 && <div className={`flex flex-col ${GAP[rowGap ?? 2]}`}>{items}</div>}
|
|
234
248
|
</Tag>
|
|
235
249
|
)
|
|
236
250
|
}
|