@kolkrabbi/kol-component 0.365.0 → 0.367.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 +1 -1
- package/src/index.js +1 -0
- package/src/molecules/FloatModule.jsx +31 -39
- package/src/molecules/FloatModuleHeader.jsx +34 -0
- package/src/molecules/LabeledControl.jsx +14 -10
- package/src/molecules/LayerRow.jsx +29 -10
- package/src/organisms/NavRail.jsx +1 -1
- package/src/organisms/NavRailFloat.jsx +52 -35
- package/src/organisms/ReadingContents.jsx +33 -40
- package/src/organisms/SettingsPanel.jsx +30 -4
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -52,6 +52,7 @@ export { default as Input } from './atoms/Input.jsx'
|
|
|
52
52
|
export { default as Label } from './atoms/Label.jsx'
|
|
53
53
|
export { default as LabeledControl } from './molecules/LabeledControl.jsx'
|
|
54
54
|
export { default as FloatModule } from './molecules/FloatModule.jsx'
|
|
55
|
+
export { default as FloatModuleHeader } from './molecules/FloatModuleHeader.jsx'
|
|
55
56
|
export { default as OverlayGlassPanel } from './utilities/OverlayGlassPanel.jsx'
|
|
56
57
|
export { default as Pill } from './atoms/Pill.jsx'
|
|
57
58
|
export { usePopover, PopoverPanel, Tooltip } from './utilities/Popover.jsx'
|
|
@@ -1,73 +1,65 @@
|
|
|
1
1
|
import { useState } from 'react'
|
|
2
|
-
import
|
|
2
|
+
import FloatModuleHeader from './FloatModuleHeader.jsx'
|
|
3
3
|
import { floatSurfaceClass } from '../utilities/tone.js'
|
|
4
4
|
|
|
5
|
-
/* taxonomy-ok: molecule —
|
|
5
|
+
/* taxonomy-ok: molecule — FloatModuleHeader (molecule) in the header slot over a body and a footer slot; the float module every float Rail is drawn on */
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* FloatModule — the one float Rail shell (plan-2026-11-12-float-system W4.1; the user: *"why arent all rails in the same
|
|
9
|
-
* shell? also the floating nav?? because it should ALSO have a collapsed state"*).
|
|
10
|
-
* sheet radius
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
9
|
+
* shell? also the floating nav?? because it should ALSO have a collapsed state"*). Three slots on the float surface at the
|
|
10
|
+
* sheet radius (plan-2026-11-12-float-rails-figma W4.1, his approved tree):
|
|
11
|
+
*
|
|
12
|
+
* header `header`, default a `FloatModuleHeader` (the title, `actions`, the fold); renders when any of them is given
|
|
13
|
+
* body the children, scrolling under the header with its scrollbar hidden
|
|
14
|
+
* footer `footer`, after the body, outside its scroll; renders only when given
|
|
15
|
+
*
|
|
16
|
+
* Folded is the SAME component (P14 *"EVEN THE FOLDED will get header body and footer"*): the same header, the body and
|
|
17
|
+
* the footer hidden (never removed), drawn as the pill of `--kol-float-fold-h`, fully round, at the module's width.
|
|
18
|
+
* PropertyRail (kol-shell), NavRail float and the reader's Contents draw on it. It lives in kol-component so NavRail float
|
|
19
|
+
* can use it without a reverse dependency; kol-shell re-exports it (the way NavRail itself moved, ARCHITECTURE §3 2026-10-22).
|
|
15
20
|
*
|
|
16
21
|
* Every size is a token of the float spec (docs/documentation/04-compositions/25-float-spec.md): the width
|
|
17
22
|
* `--kol-float-module-w` (`wide` `--kol-float-module-w-wide`), the radius `--kol-float-menu-r`, the rows
|
|
18
23
|
* `--kol-float-module-gap` (`compact` spacing-2), the fold `--kol-float-fold-h`.
|
|
19
24
|
*
|
|
25
|
+
* @param {ReactNode} [header] the header slot; unset, a FloatModuleHeader of `title` · `head` · `actions` · the fold
|
|
20
26
|
* @param {ReactNode} [title] the header's title, and the folded pill's
|
|
21
|
-
* @param {ReactNode} [head] replaces the title
|
|
22
|
-
* @param {ReactNode} [actions] buttons after the title (expand, collapse), before the fold
|
|
23
|
-
* @param {boolean} [foldable] the fold
|
|
27
|
+
* @param {ReactNode} [head] replaces the title in the open header (NavRail's switcher row)
|
|
28
|
+
* @param {ReactNode} [actions] buttons after the title (expand, collapse), before the fold; not on the folded pill
|
|
29
|
+
* @param {boolean} [foldable] the fold in the header; `folded` controlled, `defaultFolded` uncontrolled,
|
|
24
30
|
* `onFold(folded)` on every press
|
|
25
31
|
* @param {boolean} [compact] the tool Rail's rhythm: rows spacing-2 apart (default `--kol-float-module-gap`)
|
|
26
32
|
* @param {boolean} [wide] the wide module width
|
|
27
33
|
* @param {number|string} [width] an explicit width (a phone's `100%`, a footprint token); unset, the module width
|
|
28
34
|
* @param {'md'|'sm'|'none'} [inset='md'] the sheet's inset: spacing-4 · spacing-3 (a nav's) · none
|
|
29
35
|
* @param {'solid'|'glass-dark'|'glass-light'} [surface='solid']
|
|
30
|
-
* @param {ReactNode} [footer]
|
|
36
|
+
* @param {ReactNode} [footer] the footer slot (a status line, the tool's action)
|
|
31
37
|
* @param {string} [as='section'] the element (`nav` for NavRail float)
|
|
32
38
|
* @param {string} [className] on the sheet · {string} [bodyClassName] on the body · {Object} [style]
|
|
33
39
|
*/
|
|
34
40
|
const INSET = { md: 'p-4', sm: 'p-3', none: '' }
|
|
35
41
|
|
|
36
|
-
export default function FloatModule({ title, head, actions, foldable = false, folded, defaultFolded = false, onFold, compact = false, wide = false, width, inset = 'md', surface = 'solid', footer, as: Tag = 'section', className = '', bodyClassName = '', style, 'aria-label': ariaLabel, children }) {
|
|
42
|
+
export default function FloatModule({ header, title, head, actions, foldable = false, folded, defaultFolded = false, onFold, compact = false, wide = false, width, inset = 'md', surface = 'solid', footer, as: Tag = 'section', className = '', bodyClassName = '', style, 'aria-label': ariaLabel, children }) {
|
|
37
43
|
const [ownFolded, setOwnFolded] = useState(defaultFolded)
|
|
38
44
|
const isFolded = foldable && (folded ?? ownFolded)
|
|
39
45
|
const fold = () => { const next = !isFolded; if (folded === undefined) setOwnFolded(next); onFold?.(next) }
|
|
40
46
|
const w = width ?? `var(--kol-float-module-w${wide ? '-wide' : ''})`
|
|
41
47
|
const label = ariaLabel ?? (typeof title === 'string' ? title : undefined)
|
|
42
|
-
const
|
|
43
|
-
const
|
|
44
|
-
<
|
|
45
|
-
)
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
<Tag data-float-module="folded" aria-label={label} style={{ ...style, width: w, height: 'var(--kol-float-fold-h)' }}
|
|
50
|
-
className={`kol-float-module kol-float-chrome flex shrink-0 items-center justify-between gap-2 rounded-full pl-4 pr-1.5 ${surfaceClass} ${className}`.trim()}>
|
|
51
|
-
<span className="kol-float-panel text-emphasis min-w-0 truncate">{title}</span>
|
|
52
|
-
{foldButton}
|
|
53
|
-
</Tag>
|
|
54
|
-
)
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const hasHead = head || title || actions || foldable
|
|
48
|
+
const gap = compact ? 'gap-2' : 'gap-[var(--kol-float-module-gap)]'
|
|
49
|
+
const headerSlot = header ?? ((head || title || actions || foldable) && (
|
|
50
|
+
<FloatModuleHeader title={isFolded ? title : head ?? title} actions={isFolded ? undefined : actions} folded={isFolded} onFold={foldable ? fold : undefined} />
|
|
51
|
+
))
|
|
52
|
+
const shape = isFolded
|
|
53
|
+
? 'flex-row items-center rounded-full pl-4 pr-1.5'
|
|
54
|
+
: `flex-col ${gap} rounded-[var(--kol-float-menu-r)] ${INSET[inset] ?? INSET.md}`
|
|
58
55
|
return (
|
|
59
|
-
<Tag data-float-module=
|
|
60
|
-
className={`kol-float-module kol-float-chrome flex min-h-0
|
|
61
|
-
{
|
|
62
|
-
|
|
63
|
-
{head ?? <span className="kol-float-panel text-emphasis min-w-0 truncate">{title}</span>}
|
|
64
|
-
{(actions || foldButton) && <span className="flex shrink-0 items-center gap-1">{actions}{foldButton}</span>}
|
|
65
|
-
</div>
|
|
66
|
-
)}
|
|
67
|
-
<div className={`flex min-h-0 flex-1 flex-col overflow-y-auto [scrollbar-width:none] ${compact ? 'gap-2' : 'gap-[var(--kol-float-module-gap)]'} ${bodyClassName}`.trim()}>
|
|
56
|
+
<Tag data-float-module={isFolded ? 'folded' : 'open'} aria-label={label} style={{ ...style, width: w, ...(isFolded && { height: 'var(--kol-float-fold-h)' }) }}
|
|
57
|
+
className={`kol-float-module kol-float-chrome flex min-h-0 ${isFolded ? 'shrink-0' : ''} ${shape} ${floatSurfaceClass(surface, true)} ${className}`.replace(/\s+/g, ' ').trim()}>
|
|
58
|
+
{headerSlot}
|
|
59
|
+
<div data-float-module-body="" hidden={isFolded} className={`flex min-h-0 flex-1 flex-col overflow-y-auto [scrollbar-width:none] ${gap} ${bodyClassName}`.trim()}>
|
|
68
60
|
{children}
|
|
69
61
|
</div>
|
|
70
|
-
{footer}
|
|
62
|
+
{footer && <div data-float-module-footer="" hidden={isFolded} className="flex shrink-0 flex-col">{footer}</div>}
|
|
71
63
|
</Tag>
|
|
72
64
|
)
|
|
73
65
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { isValidElement } from 'react'
|
|
2
|
+
import Button from '../atoms/Button.jsx'
|
|
3
|
+
|
|
4
|
+
/* taxonomy-ok: molecule — the title, an actions slot and the fold Button (atom); FloatModule's header slot */
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* FloatModuleHeader — A float module's header: the title, an `actions` slot and the fold ⌃ / ⌄ (plan-2026-11-12-float-rails-figma
|
|
8
|
+
* W4.1; the user: *"why is header not component?"*). FloatModule's `header` slot defaults to it, open and folded alike: the
|
|
9
|
+
* same header, the module hides its body and footer around it. A row, the title filling it and truncating
|
|
10
|
+
* (`kol-float-panel`, the emphasis ink), then `end`: the actions and the fold, 4 apart, 8 off the title.
|
|
11
|
+
*
|
|
12
|
+
* The fold is a float ghost sm Button whose glyph is the 12 chevron token (`--kol-float-chev-sm`, 14 on touch), the
|
|
13
|
+
* Dropdown's and the layer rows' chevron, never the float button's 18 glyph (P15 *"USE 12px chevron"*): the button sets
|
|
14
|
+
* its own `--kol-float-ic` to the chevron token, so the float button's glyph rule draws 12. Each part renders
|
|
15
|
+
* only when given: no `onFold`, no fold; no `actions`, no slot.
|
|
16
|
+
*
|
|
17
|
+
* @param {ReactNode} [title] text takes the panel role; an element (NavRail float's switcher row) goes in as it is
|
|
18
|
+
* @param {ReactNode} [actions] buttons before the fold (expand, collapse)
|
|
19
|
+
* @param {boolean} [folded] the fold's state: ⌄ (Open) when folded, ⌃ (Fold) when open
|
|
20
|
+
* @param {Function} [onFold] the fold's press; unset, no fold
|
|
21
|
+
* @param {string} [className]
|
|
22
|
+
*/
|
|
23
|
+
export default function FloatModuleHeader({ title, actions, folded = false, onFold, className = '' }) {
|
|
24
|
+
const fold = onFold && (
|
|
25
|
+
<Button variant="float" tone="ghost" size="sm" iconOnly={folded ? 'chevron-down' : 'chevron-up'} className="[--kol-float-ic:var(--kol-float-chev-sm)]"
|
|
26
|
+
aria-label={folded ? 'Open' : 'Fold'} aria-expanded={!folded} onClick={onFold} />
|
|
27
|
+
)
|
|
28
|
+
return (
|
|
29
|
+
<div data-float-module-header="" className={`flex w-full min-w-0 shrink-0 items-center justify-between gap-2 ${className}`.trim()}>
|
|
30
|
+
{title != null && title !== false && (isValidElement(title) ? title : <span className="kol-float-panel text-emphasis min-w-0 flex-1 truncate">{title}</span>)}
|
|
31
|
+
{(actions || fold) && <span className="ml-auto flex shrink-0 items-center gap-1">{actions}{fold}</span>}
|
|
32
|
+
</div>
|
|
33
|
+
)
|
|
34
|
+
}
|
|
@@ -1,29 +1,32 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* LabeledControl — generic slot for label + interactive control body.
|
|
3
3
|
*
|
|
4
|
-
* Default layout: label on top (`flex-col`). Pass `
|
|
5
|
-
*
|
|
4
|
+
* Default layout: label on top (`flex-col`). Pass `horizontal` for the label
|
|
5
|
+
* beside the control (label fixed-width, control flex-1).
|
|
6
6
|
*
|
|
7
7
|
* Compose with any control as children:
|
|
8
8
|
* <LabeledControl label="Columns · 4">
|
|
9
9
|
* <Slider ... />
|
|
10
10
|
* </LabeledControl>
|
|
11
|
-
* <LabeledControl
|
|
11
|
+
* <LabeledControl horizontal label="Weight">
|
|
12
12
|
* <Input ... />
|
|
13
13
|
* </LabeledControl>
|
|
14
14
|
*
|
|
15
15
|
* Props:
|
|
16
|
-
* label —
|
|
16
|
+
* label — any node: the label text, or an icon with text (a ToggleSwitch row's glyph). A string takes the
|
|
17
|
+
* variant's label style (kol-helper-10, tracked; float: the float hint at fg-64).
|
|
17
18
|
* hint — optional secondary text after the label (lower-case, less
|
|
18
19
|
* weight). Useful for current-value displays, units, etc.
|
|
19
|
-
*
|
|
20
|
-
*
|
|
20
|
+
* horizontal — bool. true: the label beside the control (left); false (default): the label above it
|
|
21
|
+
* (plan-2026-11-12-float-rails-figma W7.1, the user: *"this is obviously horizontal and this vertical"*).
|
|
22
|
+
* inline — deprecated 2026-11-12, the old name of `horizontal`: the same bool (on the retirement ledger).
|
|
23
|
+
* labelWidth — px width for the label column when `horizontal`. Default 48.
|
|
21
24
|
* `'auto'` flips which cell yields: the label flexes and TRUNCATES,
|
|
22
25
|
* the control hugs its content (SettingsShortcutsComboOverflow,
|
|
23
26
|
* kol-monitor 2026-09-01 — in a narrow multi-column grid a fixed
|
|
24
27
|
* 160 label left the control 4px, and a nowrap combo painted into
|
|
25
28
|
* the neighbour column; the 48px column gap had been hiding it).
|
|
26
|
-
* text — bool, `
|
|
29
|
+
* text — bool, `horizontal` only. A row whose value is TEXT (a shortcut's combo, a reading): the label keeps
|
|
27
30
|
* the Settings label look (helper-10, tracked, meta ink) on a real 16px line, label and value share
|
|
28
31
|
* a baseline, and the value cell is a flex box so no inherited line-height strut makes the row taller
|
|
29
32
|
* than its text (SettingsRowMonoBaseline → SettingsRowTextKeepsLabel, kol-monitor 2026-10-18: a
|
|
@@ -32,7 +35,7 @@
|
|
|
32
35
|
* 2026-10-01): `kol-helper-8`, uppercase, hugging the control; it takes
|
|
33
36
|
* `labelPosition` (`top · bottom · left · right`, default bottom), `labelClass` and `gap`.
|
|
34
37
|
* `'float'` (float-everything W3 row 37, 2026-11-04): the label over a capsule — the float hint role
|
|
35
|
-
* (Inter 12) at fg-64, no uppercase, no tracking, `--kol-float-label-gap` from the control; `
|
|
38
|
+
* (Inter 12) at fg-64, no uppercase, no tracking, `--kol-float-label-gap` from the control; `horizontal` keeps
|
|
36
39
|
* the same label in the `--kol-float-label-w` column (a `labelWidth` still wins), the row at least the float
|
|
37
40
|
* sm height. Every float row is this (plan-2026-11-12-float-system W2.1); the wrapper carries
|
|
38
41
|
* `data-labeled-control`.
|
|
@@ -42,7 +45,8 @@
|
|
|
42
45
|
export default function LabeledControl({
|
|
43
46
|
label,
|
|
44
47
|
hint,
|
|
45
|
-
|
|
48
|
+
horizontal,
|
|
49
|
+
inline,
|
|
46
50
|
labelWidth,
|
|
47
51
|
children,
|
|
48
52
|
className = '',
|
|
@@ -82,7 +86,7 @@ export default function LabeledControl({
|
|
|
82
86
|
</>
|
|
83
87
|
)
|
|
84
88
|
|
|
85
|
-
if (inline) {
|
|
89
|
+
if (horizontal ?? inline ?? false) {
|
|
86
90
|
/* `'auto'`: the label is the yielding cell — flex-1, truncating — and the
|
|
87
91
|
* control hugs. The control still carries min-w-0 + overflow-hidden so a
|
|
88
92
|
* combo wider than the whole column CLIPS at the column edge rather than
|
|
@@ -1,15 +1,23 @@
|
|
|
1
1
|
import { IconLoader } from '@kolkrabbi/kol-icons'
|
|
2
|
+
import Button from '../atoms/Button.jsx'
|
|
2
3
|
import TreeRow from './TreeRow.jsx'
|
|
3
4
|
|
|
4
|
-
/* taxonomy-ok: molecule — TreeRow (molecule) + kol-icons's Icon. */
|
|
5
|
+
/* taxonomy-ok: molecule — TreeRow (molecule) + Button (atom) + kol-icons's Icon. */
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* LayerRow — A layer in a layers list: glyph · name · eye · lock. `Orbit field` (float-everything W8 row 119,
|
|
8
9
|
* 2026-11-04 — kol-float--style 48:3546). `TreeRow` at `xs` (26, a 14 glyph, the 11 name) with two toggles at its end:
|
|
9
|
-
* the eye (`visible` · `onToggleVisible`) and the lock (`locked` · `onToggleLock`)
|
|
10
|
-
*
|
|
11
|
-
* to fg-
|
|
10
|
+
* the eye (`visible` · `onToggleVisible`) and the lock (`locked` · `onToggleLock`), each drawn only when its handler is
|
|
11
|
+
* given (PropertyRail's selected line has an eye and no lock, plan-2026-11-12-float-rails-figma W8.1). The toggles stay
|
|
12
|
+
* on oq-64 and go oq-96 under the pointer; a hidden layer's name drops to fg-48 and its eye shows `eye-off`. `selected`
|
|
13
|
+
* lifts the row to fg-16.
|
|
12
14
|
*
|
|
15
|
+
* `variant="head"` is the same part as the selected object's line at the top of an inspector (PropertyRail's `selected`,
|
|
16
|
+
* plan-2026-11-12-float-rails-figma W8.1, the user: *"'select' why is this not a component?!?!"*; decided for his review):
|
|
17
|
+
* no row inset and no lift, the 18 glyph at oq-64, the name in `kol-float-panel` at the emphasis ink, the eye and the lock
|
|
18
|
+
* float ghost sm Buttons.
|
|
19
|
+
*
|
|
20
|
+
* @param {'row'|'head'} [variant='row']
|
|
13
21
|
* @param {string} [icon='layers']
|
|
14
22
|
* @param {ReactNode} name
|
|
15
23
|
* @param {boolean} [selected]
|
|
@@ -19,15 +27,26 @@ import TreeRow from './TreeRow.jsx'
|
|
|
19
27
|
* @param {Function} [onClick]
|
|
20
28
|
* @param {string} [className]
|
|
21
29
|
*/
|
|
22
|
-
export default function LayerRow({ icon = 'layers', name, selected = false, visible = true, onToggleVisible, locked = false, onToggleLock, depth = 0, onClick, className = '' }) {
|
|
30
|
+
export default function LayerRow({ variant = 'row', icon = 'layers', name, selected = false, visible = true, onToggleVisible, locked = false, onToggleLock, depth = 0, onClick, className = '' }) {
|
|
31
|
+
if (variant === 'head') {
|
|
32
|
+
const btn = (label, glyph, on, fn) => <Button variant="float" tone="ghost" size="sm" iconOnly={glyph} aria-label={label} aria-pressed={on} onClick={fn} />
|
|
33
|
+
return (
|
|
34
|
+
<div className={`flex items-center gap-2 ${className}`.trim()}>
|
|
35
|
+
<IconLoader name={icon} size={18} className="shrink-0 text-oq-64" />
|
|
36
|
+
<span className="kol-float-panel text-emphasis min-w-0 flex-1 truncate">{name}</span>
|
|
37
|
+
{onToggleVisible && btn(visible ? 'Hide' : 'Show', visible ? 'eye-on' : 'eye-off', visible, onToggleVisible)}
|
|
38
|
+
{onToggleLock && btn(locked ? 'Unlock' : 'Lock', locked ? 'lock' : 'unlock', locked, onToggleLock)}
|
|
39
|
+
</div>
|
|
40
|
+
)
|
|
41
|
+
}
|
|
23
42
|
const ctl = (label, glyph, on, fn) => (
|
|
24
43
|
<span
|
|
25
44
|
role="button"
|
|
26
45
|
tabIndex={0}
|
|
27
46
|
aria-label={label}
|
|
28
47
|
aria-pressed={on}
|
|
29
|
-
onClick={(e) => { e.stopPropagation(); fn
|
|
30
|
-
onKeyDown={(e) => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); e.stopPropagation(); fn
|
|
48
|
+
onClick={(e) => { e.stopPropagation(); fn() }}
|
|
49
|
+
onKeyDown={(e) => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); e.stopPropagation(); fn() } }}
|
|
31
50
|
className="inline-flex size-5 shrink-0 items-center justify-center rounded-full text-oq-64 hover:text-oq-96 focus-visible:outline-none focus-visible:shadow-[var(--kol-float-focus)]"
|
|
32
51
|
>
|
|
33
52
|
<IconLoader name={glyph} size={12} />
|
|
@@ -42,10 +61,10 @@ export default function LayerRow({ icon = 'layers', name, selected = false, visi
|
|
|
42
61
|
depth={depth}
|
|
43
62
|
onClick={onClick}
|
|
44
63
|
className={`gap-2 pr-1.5 ${className}`.trim()}
|
|
45
|
-
trailing={(
|
|
64
|
+
trailing={(onToggleVisible || onToggleLock) && (
|
|
46
65
|
<span className="flex shrink-0 items-center">
|
|
47
|
-
{ctl(visible ? 'Hide layer' : 'Show layer', visible ? 'eye-on' : 'eye-off', !visible, onToggleVisible)}
|
|
48
|
-
{ctl(locked ? 'Unlock layer' : 'Lock layer', locked ? 'lock' : 'unlock', locked, onToggleLock)}
|
|
66
|
+
{onToggleVisible && ctl(visible ? 'Hide layer' : 'Show layer', visible ? 'eye-on' : 'eye-off', !visible, onToggleVisible)}
|
|
67
|
+
{onToggleLock && ctl(locked ? 'Unlock layer' : 'Lock layer', locked ? 'lock' : 'unlock', locked, onToggleLock)}
|
|
49
68
|
</span>
|
|
50
69
|
)}
|
|
51
70
|
/>
|
|
@@ -84,7 +84,7 @@ import NavRailFloat from './NavRailFloat.jsx'
|
|
|
84
84
|
*
|
|
85
85
|
* @param {'app'|'site'|'workshop'} preset which rail (default `app`); `variant="site"` is the old spelling of `preset="site"`
|
|
86
86
|
* @param {'top'|'float'} variant `top` — the horizontal top rail (TopRail): logomark · items · `actions` (the right slot);
|
|
87
|
-
* `float` — the float sidebar, expanded
|
|
87
|
+
* `float` — the float sidebar, expanded 264 · collapsed 72 (NavRailFloat.jsx, float-everything W9 rows 127 · 128)
|
|
88
88
|
* @param {Array} items `{ icon, path, label, sub?: [{ icon?, path, label }] }`
|
|
89
89
|
* a section (`sub`) with `to` is a FOLDER NOTE: its icon and label open `to`, its chevron expands or enters
|
|
90
90
|
* @param {Array} bottomItems pinned below the rule (Settings)
|
|
@@ -3,22 +3,25 @@ import { IconLoader } from '@kolkrabbi/kol-icons'
|
|
|
3
3
|
import Kbd from '../atoms/Kbd.jsx'
|
|
4
4
|
import TreeRow from '../molecules/TreeRow.jsx'
|
|
5
5
|
import FloatModule from '../molecules/FloatModule.jsx'
|
|
6
|
+
import { LabeledControlSection } from './SettingsPanel.jsx'
|
|
6
7
|
import { Tooltip } from '../utilities/Popover.jsx'
|
|
7
8
|
import { floatMotion } from '../utilities/motion.js'
|
|
8
9
|
|
|
9
|
-
/* taxonomy-ok: organism — nests FloatModule + TreeRow (molecules) + Kbd (atom) + Tooltip (utility) + kol-icons's Icon. */
|
|
10
|
+
/* taxonomy-ok: organism — nests FloatModule + TreeRow (molecules) + LabeledControlSection (organism) + Kbd (atom) + Tooltip (utility) + kol-icons's Icon. */
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* NavRailFloat — the float sidebar, `NavRail variant="float"` (float-everything W9 rows 122 · 127 · 128 · 131,
|
|
13
14
|
* 2026-11-04 — kol-float--style 48:4015 expanded, 48:4277 rail). Its own path: none of the app rail's grab, drag or
|
|
14
|
-
* width token. Two states, the rail's words — EXPANDED (
|
|
15
|
+
* width token. Two states, the rail's words — EXPANDED (264) and COLLAPSED (72):
|
|
15
16
|
*
|
|
16
17
|
* expanded the switcher row (glyph · title · ⌄, or your `switcher`) · the search capsule (`Search pages ⌘K`) · the
|
|
17
|
-
* tree: a `{ heading }` entry
|
|
18
|
+
* tree: a `{ heading }` entry opens a group, a float `LabeledControlSection` whose label is the heading
|
|
19
|
+
* (`kol-float-ruler`, fg-64, as authored) over the items under it; an item a
|
|
18
20
|
* `TreeRow size="lg"` (40 · 18 glyph · Inter 13 · count · chevron), its `sub` rows `TreeRow size="sm"`
|
|
19
21
|
* indented under it · `footer` at the foot (kol-shell's RailDisplayControls, a theme row)
|
|
20
22
|
* collapsed 44 round slots on a 72 rail, 20 glyphs; the lit slot fg-16 with a 3 × 14 bar at the rail's edge — a
|
|
21
|
-
* section with the current page inside lights too;
|
|
23
|
+
* section with the current page inside lights too; each group is a LabeledControlSection without its
|
|
24
|
+
* label, 24 apart. Expand on top and search ·
|
|
22
25
|
* hide at the foot, on the well. Each slot names itself in the float Tooltip
|
|
23
26
|
*
|
|
24
27
|
* On `surface-secondary` lifted by the float shadow (`--kol-shadow-float`, the pill's and the card's — FloatRailOverlayShadowRestore,
|
|
@@ -45,6 +48,13 @@ import { floatMotion } from '../utilities/motion.js'
|
|
|
45
48
|
* FloatLayout's (it holds the rail while it leaves)
|
|
46
49
|
*/
|
|
47
50
|
const isOn = (path, current) => !!path && path === current
|
|
51
|
+
/* the flat item list in groups: the items before the first `{ heading }`, then each heading with the items under it —
|
|
52
|
+
* each group one float LabeledControlSection (plan-2026-11-12-float-rails-figma W10.1), never a loose heading */
|
|
53
|
+
const groupsOf = (items) => {
|
|
54
|
+
const out = [{ items: [] }]
|
|
55
|
+
for (const it of items) it.heading ? out.push({ heading: it.heading, items: [] }) : out[out.length - 1].items.push(it)
|
|
56
|
+
return out[0].items.length ? out : out.slice(1)
|
|
57
|
+
}
|
|
48
58
|
|
|
49
59
|
export default function NavRailFloat({ items = [], currentPath = '', onNavigate, collapsed = false, onCollapsedChange, title, icon = 'grid', onSwitch, switcher, onSearch, onHide, defaultExpanded = [], footer, onItemHover, motion = true, foldable = false, folded, defaultFolded = false, onFold, className = '' }) {
|
|
50
60
|
const motionStyle = floatMotion(motion).style
|
|
@@ -65,18 +75,21 @@ export default function NavRailFloat({ items = [], currentPath = '', onNavigate,
|
|
|
65
75
|
<FloatModule as="nav" aria-label="Navigation" inset="none" width="var(--kol-shell-float-rail-width, 72px)" style={motionStyle} bodyClassName="items-center !gap-1"
|
|
66
76
|
className={`kol-float-rail h-full !gap-1 items-center py-3.5 ${className}`.trim()}>
|
|
67
77
|
{onCollapsedChange && slot('expand', 'Expand', 'panel-left', { well: true, onClick: () => onCollapsedChange(false) })}
|
|
68
|
-
<div className="flex min-h-0 w-full flex-1 flex-col
|
|
69
|
-
{items.map((
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
78
|
+
<div className="flex min-h-0 w-full flex-1 flex-col gap-6 overflow-y-auto py-3 [scrollbar-width:none]">
|
|
79
|
+
{groupsOf(items).map((g, gi) => (
|
|
80
|
+
<LabeledControlSection key={gi} variant="float" rowGap={1} className="w-full">
|
|
81
|
+
{g.items.map((it) => {
|
|
82
|
+
const on = isOn(it.path, currentPath) || !!it.sub?.some((c) => isOn(c.path, currentPath))
|
|
83
|
+
return (
|
|
84
|
+
<span key={it.path ?? it.label} className="relative flex w-full justify-center"
|
|
85
|
+
onMouseEnter={onItemHover && ((e) => onItemHover(it, e.currentTarget))} onMouseLeave={onItemHover && (() => onItemHover(null, null))}>
|
|
86
|
+
{on && <span className="absolute left-[5px] top-1/2 h-3.5 w-[3px] -translate-y-1/2 rounded-full bg-[var(--kol-surface-on-primary)]" aria-hidden />}
|
|
87
|
+
{slot(it.path ?? it.label, it.label, it.icon, { on, onClick: go(it.path) })}
|
|
88
|
+
</span>
|
|
89
|
+
)
|
|
90
|
+
})}
|
|
91
|
+
</LabeledControlSection>
|
|
92
|
+
))}
|
|
80
93
|
</div>
|
|
81
94
|
{onSearch && slot('search', 'Search pages', 'search', { well: true, onClick: onSearch })}
|
|
82
95
|
{onHide && slot('hide', 'Hide', 'hamburger', { well: true, onClick: onHide })}
|
|
@@ -85,7 +98,7 @@ export default function NavRailFloat({ items = [], currentPath = '', onNavigate,
|
|
|
85
98
|
}
|
|
86
99
|
|
|
87
100
|
return (
|
|
88
|
-
<FloatModule as="nav" aria-label="Navigation" inset="sm" width="var(--kol-shell-float-rail-open,
|
|
101
|
+
<FloatModule as="nav" aria-label="Navigation" inset="sm" width="var(--kol-shell-float-rail-open, 264px)" style={motionStyle}
|
|
89
102
|
title={title} foldable={foldable} folded={folded} defaultFolded={defaultFolded} onFold={onFold}
|
|
90
103
|
bodyClassName="!gap-3" className={`kol-float-rail h-full !gap-3 ${className}`.trim()}
|
|
91
104
|
footer={footer && <div className="flex shrink-0 flex-col gap-2">{footer}</div>}
|
|
@@ -103,24 +116,28 @@ export default function NavRailFloat({ items = [], currentPath = '', onNavigate,
|
|
|
103
116
|
<Kbd size="sm" icon="command">K</Kbd>
|
|
104
117
|
</button>
|
|
105
118
|
)}
|
|
106
|
-
<div className="flex min-h-0 flex-1 flex-col gap-
|
|
107
|
-
{items.map((
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
119
|
+
<div className="flex min-h-0 flex-1 flex-col gap-[18px] overflow-y-auto [scrollbar-width:none]">
|
|
120
|
+
{groupsOf(items).map((g, gi) => (
|
|
121
|
+
<LabeledControlSection key={gi} variant="float" gap={1.5} rowGap={0.5} className={gi === 0 && g.heading ? 'pt-1' : ''}
|
|
122
|
+
label={g.heading && <span className="kol-float-ruler px-2.5 text-fg-64">{g.heading}</span>}>
|
|
123
|
+
{g.items.map((it) => {
|
|
124
|
+
const kids = it.sub ?? []
|
|
125
|
+
const isOpen = open.has(it.path)
|
|
126
|
+
const childOn = kids.some((c) => isOn(c.path, currentPath))
|
|
127
|
+
return (
|
|
128
|
+
<div key={it.path ?? it.label} className="flex flex-col gap-0.5">
|
|
129
|
+
<TreeRow size="lg" icon={it.icon} label={it.label} count={it.count}
|
|
130
|
+
active={isOn(it.path, currentPath)} open={childOn && isOpen}
|
|
131
|
+
expanded={kids.length ? isOpen : undefined} onToggle={kids.length ? () => toggle(it.path) : undefined}
|
|
132
|
+
onClick={kids.length && !it.to ? () => toggle(it.path) : go(it.to ?? it.path)} />
|
|
133
|
+
{isOpen && kids.map((c) => (
|
|
134
|
+
<TreeRow key={c.path} size="sm" depth={1} icon={c.icon} label={c.label} count={c.count} active={isOn(c.path, currentPath)} onClick={go(c.path)} />
|
|
135
|
+
))}
|
|
136
|
+
</div>
|
|
137
|
+
)
|
|
138
|
+
})}
|
|
139
|
+
</LabeledControlSection>
|
|
140
|
+
))}
|
|
124
141
|
</div>
|
|
125
142
|
</FloatModule>
|
|
126
143
|
)
|
|
@@ -1,58 +1,52 @@
|
|
|
1
|
-
import FloatModule from '../molecules/FloatModule.jsx'
|
|
2
1
|
import ProgressBar from '../atoms/ProgressBar.jsx'
|
|
3
2
|
import TocRow from '../molecules/TocRow.jsx'
|
|
3
|
+
import { LabeledControlSection } from './SettingsPanel.jsx'
|
|
4
4
|
|
|
5
|
-
/* taxonomy-ok: organism — the reader's contents
|
|
5
|
+
/* taxonomy-ok: organism — the reader's contents, a module's body: book head, LabeledControlSection of TocRows, progress */
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* ReadingContents — The book's contents, where the reader is in them, and how far through. `
|
|
8
|
+
* ReadingContents — The book's contents, where the reader is in them, and how far through. `The Waves · 9 interludes ·
|
|
9
9
|
* 01 First interlude … · Through the book 42%` (float-everything W11 row 149, 2026-11-04 — kol-float--style W2.9
|
|
10
|
-
* `Contents panel`).
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
10
|
+
* `Contents panel`). It is BODY CONTENT (plan-2026-11-12-float-rails-figma W4.1): no sheet, no header, no margins of its
|
|
11
|
+
* own. It goes in a `FloatModule`'s body, the module carrying the title (`Contents`), the fold and the status line in its
|
|
12
|
+
* footer:
|
|
13
|
+
*
|
|
14
|
+
* <FloatModule title="Contents" foldable footer={<span className="kol-float-label text-fg-64">Reading position saved</span>}>
|
|
15
|
+
* <ReadingContents book="The Waves" author="Virginia Woolf" count="9 interludes" chapters={chapters} … />
|
|
16
|
+
* </FloatModule>
|
|
17
|
+
*
|
|
18
|
+
* A column, 24 between its parts: `book` (the title in `kol-float-section` over the author in `kol-float-hint` fg-64,
|
|
19
|
+
* 4 apart), the chapters as a float `LabeledControlSection` (the count in `kol-float-ruler` over one 36 `TocRow` per
|
|
20
|
+
* chapter, 12 under the count, 4 between rows; `current` lifted fg-16), then `progress` (`Through the book` and the
|
|
21
|
+
* share in mono over the float ProgressBar, 12 apart). Each part renders only when given.
|
|
14
22
|
*
|
|
15
|
-
* @param {string} [title] default `Contents`
|
|
16
23
|
* @param {ReactNode} [book] · {ReactNode} [author] · {ReactNode} [count] `9 interludes`
|
|
17
24
|
* @param {Array} chapters `[{ id, label, href? }]`
|
|
18
25
|
* @param {string} [current] the id the reader is in
|
|
19
26
|
* @param {Function} [onSelect] `(id) => void`
|
|
20
27
|
* @param {number} [progress] 0–100; unset, no progress line
|
|
21
28
|
* @param {string} [progressLabel] default `Through the book`
|
|
22
|
-
* @param {ReactNode} [status] `Reading position saved`
|
|
23
|
-
* @param {Function} [onFold] `(folded) => void` on every fold press; the fold ⌃ shows when this or `foldable` is set
|
|
24
|
-
* @param {boolean} [foldable] · {boolean} [folded] controlled · {boolean} [defaultFolded] — FloatModule's fold: the
|
|
25
|
-
* sheet folds to its `Contents ⌄` pill (plan-2026-11-12-float-system W4.1)
|
|
26
|
-
* @param {number|string} [width] unset, the module width (`--kol-float-module-w`; was 304 — the float spec's two widths)
|
|
27
|
-
* @param {boolean} [bare] the body only — book, chapters, progress, status — with no sheet and no header, for
|
|
28
|
-
* kol-shell's PropertyRail, the float module that carries the title and the fold (2026-11-12)
|
|
29
29
|
* @param {string} [className]
|
|
30
30
|
*/
|
|
31
|
-
export default function ReadingContents({
|
|
32
|
-
const body = <Body {...{ title, book, author, count, chapters, current, onSelect, progress, progressLabel, status }} />
|
|
33
|
-
if (bare) return <div className={`flex flex-col ${className}`.trim()}>{body}</div>
|
|
34
|
-
/* drawn on FloatModule (W4.1): the title in its header, the fold, the folded pill */
|
|
31
|
+
export default function ReadingContents({ book, author, count, chapters = [], current, onSelect, progress, progressLabel = 'Through the book', className = '' }) {
|
|
35
32
|
return (
|
|
36
|
-
<
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
<TocRow key={c.id} number={i + 1} label={c.label} href={c.href} current={c.id === current} onClick={onSelect ? () => onSelect(c.id) : undefined} className="h-9" />
|
|
52
|
-
))}
|
|
53
|
-
</nav>
|
|
33
|
+
<div data-reading-contents="" className={`flex flex-col gap-6 ${className}`.trim()}>
|
|
34
|
+
{(book || author) && (
|
|
35
|
+
<div className="flex flex-col gap-1">
|
|
36
|
+
{book && <span className="kol-float-section text-fg-emphasis">{book}</span>}
|
|
37
|
+
{author && <span className="kol-float-hint text-fg-64">{author}</span>}
|
|
38
|
+
</div>
|
|
39
|
+
)}
|
|
40
|
+
{(count || chapters.length > 0) && (
|
|
41
|
+
<LabeledControlSection variant="float" as="nav" aria-label="Contents" rowGap={1}
|
|
42
|
+
label={count && <span className="kol-float-ruler uppercase text-fg-64">{count}</span>}>
|
|
43
|
+
{chapters.map((c, i) => (
|
|
44
|
+
<TocRow key={c.id} number={i + 1} label={c.label} href={c.href} current={c.id === current} onClick={onSelect ? () => onSelect(c.id) : undefined} className="h-9" />
|
|
45
|
+
))}
|
|
46
|
+
</LabeledControlSection>
|
|
47
|
+
)}
|
|
54
48
|
{progress != null && (
|
|
55
|
-
<div className="
|
|
49
|
+
<div className="flex flex-col gap-3">
|
|
56
50
|
<div className="flex items-center justify-between">
|
|
57
51
|
<span className="kol-float-hint text-fg-64">{progressLabel}</span>
|
|
58
52
|
<span className="kol-float-timecode tabular-nums text-fg-emphasis">{Math.round(progress)}%</span>
|
|
@@ -60,7 +54,6 @@ function Body({ title, book, author, count, chapters, current, onSelect, progres
|
|
|
60
54
|
<ProgressBar variant="float" value={progress} ariaLabel={progressLabel} />
|
|
61
55
|
</div>
|
|
62
56
|
)}
|
|
63
|
-
|
|
64
|
-
</>
|
|
57
|
+
</div>
|
|
65
58
|
)
|
|
66
59
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Children } from 'react'
|
|
1
2
|
import Button from '../atoms/Button.jsx'
|
|
2
3
|
import Dropdown from '../molecules/Dropdown.jsx'
|
|
3
4
|
import CloseButton from '../molecules/CloseButton.jsx'
|
|
@@ -137,7 +138,7 @@ export default function SettingsPanel({
|
|
|
137
138
|
}
|
|
138
139
|
|
|
139
140
|
/**
|
|
140
|
-
* SettingsRow — One labelled setting. a `LabeledControl
|
|
141
|
+
* SettingsRow — One labelled setting. a `LabeledControl horizontal` (SettingsPanelApproved, 2026-08-27):
|
|
141
142
|
* uppercase label (`kol-helper-10` tracked, meta ink) in a 160px column, the
|
|
142
143
|
* control fills the rest. A switch sits at the far right (`align="end"`, the
|
|
143
144
|
* default); a dropdown fills the row (`align="fill"`). No hint sentences on the
|
|
@@ -153,7 +154,7 @@ export default function SettingsPanel({
|
|
|
153
154
|
export function SettingsRow({ label, hint, align = 'end', labelWidth = 160, text = false, stack = false, children }) {
|
|
154
155
|
if (stack) align = 'fill'
|
|
155
156
|
return (
|
|
156
|
-
<LabeledControl
|
|
157
|
+
<LabeledControl horizontal={!stack} text={text} label={typeof label === 'string' ? label.toUpperCase() : label} labelWidth={labelWidth}>
|
|
157
158
|
{hint
|
|
158
159
|
? <Tooltip label={hint} triggerClassName={`flex min-h-6 items-center w-full ${align === 'fill' ? '' : 'justify-end'}`.trim()}>{children}</Tooltip>
|
|
159
160
|
/* `flex`, not `inline-flex`: an inline box rode the label's text baseline and sat 5px low (2026-10-31) */
|
|
@@ -186,8 +187,33 @@ export function SettingsSwitch({ on = false, onChange, disabled = false, disable
|
|
|
186
187
|
* Was `SettingsSection` until 2026-08-27 (LabeledControlSection, kol-r2b2 —
|
|
187
188
|
* user ruling: it named the place it was first used, not what it is; kol-fxr
|
|
188
189
|
* took it for a params rail the same day). RENAMED, NO ALIAS — the render is
|
|
189
|
-
* the 0.104.0 locked composition, untouched.
|
|
190
|
-
|
|
190
|
+
* the 0.104.0 locked composition, untouched.
|
|
191
|
+
*
|
|
192
|
+
* `variant="float"` — the one float section (plan-2026-11-12-float-rails-figma W10.1, the user: *"this should be a
|
|
193
|
+
* component with slots that has multiple items?"*): a `head` (the `label`, any node, a string in the float label role,
|
|
194
|
+
* and `end`, a + button or a meta, at the far end) over the items (children, any number). PropertyRail's sections and
|
|
195
|
+
* subheads, ReadingContents' chapters and NavRail float's groups all draw it. The head renders only when a label or an
|
|
196
|
+
* end is given, the items only when there are any. `gap` is head to items, `rowGap` items to items, each a spacing step
|
|
197
|
+
* (0.5 · 1 · 1.5 · 2 · 3) or `'module'` (`--kol-float-module-gap`); float defaults 3 (12) and 2 (8). `as` the element
|
|
198
|
+
* (`nav` for a list of links), the rest of the props on it. */
|
|
199
|
+
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)]' }
|
|
200
|
+
export function LabeledControlSection({ label, end, variant, divided = false, gap, rowGap, as: Tag = 'div', children, className = '', ...rest }) {
|
|
201
|
+
if (variant === 'float') {
|
|
202
|
+
const items = Children.toArray(children)
|
|
203
|
+
const hasLabel = label != null && label !== false && label !== ''
|
|
204
|
+
return (
|
|
205
|
+
<Tag data-labeled-control-section="" className={`flex flex-col ${GAP[gap ?? 3]} ${className}`.trim()} {...rest}>
|
|
206
|
+
{(hasLabel || end) && (
|
|
207
|
+
<div className="flex items-center justify-between">
|
|
208
|
+
{hasLabel && (typeof label === 'string' ? <span className="kol-float-label text-oq-64">{label}</span> : label)}
|
|
209
|
+
{end}
|
|
210
|
+
</div>
|
|
211
|
+
)}
|
|
212
|
+
{items.length > 0 && <div className={`flex flex-col ${GAP[rowGap ?? 2]}`}>{items}</div>}
|
|
213
|
+
</Tag>
|
|
214
|
+
)
|
|
215
|
+
}
|
|
216
|
+
rowGap ??= 2
|
|
191
217
|
return (
|
|
192
218
|
<div className={`flex flex-col gap-3 ${divided ? 'kol-section--divided' : ''} ${className}`.replace(/\s+/g, ' ').trim()}>
|
|
193
219
|
{label && <p className="kol-eyebrow text-fg-80">{label}</p>}
|