@kolkrabbi/kol-component 0.334.0 → 0.335.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/SectionLabel.jsx +29 -0
- package/src/index.js +11 -0
- package/src/molecules/ContentRow.jsx +30 -1
- package/src/molecules/DocsToc.jsx +16 -1
- package/src/molecules/EmptyState.jsx +15 -1
- package/src/molecules/FlyoutRow.jsx +10 -0
- package/src/molecules/IndexRow.jsx +37 -0
- package/src/molecules/LayerRow.jsx +53 -0
- package/src/molecules/Modal.jsx +58 -19
- package/src/molecules/NoticeBanner.jsx +28 -0
- package/src/molecules/QuickLookFrame.jsx +31 -27
- package/src/molecules/QuickLookHeader.jsx +60 -0
- package/src/molecules/SectionText.jsx +15 -1
- package/src/molecules/SpecList.jsx +21 -1
- package/src/molecules/SummaryLine.jsx +18 -0
- package/src/molecules/TabsRow.jsx +54 -7
- package/src/molecules/TaskRow.jsx +43 -0
- package/src/molecules/TocRow.jsx +29 -0
- package/src/molecules/TreeRow.jsx +72 -0
- package/src/organisms/MediaLibrary.jsx +55 -0
- package/src/organisms/NavDrawer.jsx +67 -0
- package/src/organisms/NavRail.jsx +4 -1
- package/src/organisms/NavRailFloat.jsx +110 -0
- package/src/organisms/Table.jsx +50 -1
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { Icon } from '@kolkrabbi/kol-icons'
|
|
2
|
+
import Button from '../atoms/Button.jsx'
|
|
3
|
+
import CloseButton from '../atoms/CloseButton.jsx'
|
|
4
|
+
|
|
5
|
+
/* taxonomy-ok: molecule — nests Button (atom) + CloseButton (utility). */
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* QuickLookHeader — A window's title row. Lifted out of QuickLookFrame (float-everything W6 row 82, 2026-11-04) so a
|
|
9
|
+
* Dialog, a confirm and the utility window wear the same header. Unset `variant` is QuickLookFrame's header as it was,
|
|
10
|
+
* class for class: ‹ › n / N · the file's name · its facts · the actions · the close, on `.kol-quicklook-header`.
|
|
11
|
+
*
|
|
12
|
+
* `variant="float"` is the exploration's window header (kol-float--style 46:2500): the window's glyph (16, oq-64) · its
|
|
13
|
+
* title in `kol-float-panel` (Inter 13/500) · − minimise · × close, 12 apart, the controls quiet on oq-64 and bright
|
|
14
|
+
* under the pointer. No rule under it — the no-borders law holds on float.
|
|
15
|
+
*
|
|
16
|
+
* @param {'float'} [variant]
|
|
17
|
+
* @param {string} [icon] float: the window's glyph (`user`, `alert-triangle`, …)
|
|
18
|
+
* @param {ReactNode} title
|
|
19
|
+
* @param {ReactNode} [meta] default look: the facts after the name
|
|
20
|
+
* @param {ReactNode} [actions] controls before the close
|
|
21
|
+
* @param {Object} [nav] default look: `{ index, total, onPrev, onNext }`
|
|
22
|
+
* @param {Function} [onMinimise] float: shows the − control
|
|
23
|
+
* @param {Function} [onClose] shows the × control
|
|
24
|
+
* @param {string} [className]
|
|
25
|
+
*/
|
|
26
|
+
export default function QuickLookHeader({ variant, icon, title, meta, actions, nav, onMinimise, onClose, className = '' }) {
|
|
27
|
+
if (variant === 'float') {
|
|
28
|
+
const ctl = 'inline-flex size-6 shrink-0 items-center justify-center rounded-full text-oq-64 hover:text-oq-96 hover:bg-fg-08 focus-visible:outline-none focus-visible:shadow-[var(--kol-float-focus)] cursor-pointer'
|
|
29
|
+
return (
|
|
30
|
+
<div className={`flex min-h-6 w-full items-center gap-3 ${className}`.trim()}>
|
|
31
|
+
{icon && <Icon name={icon} size={16} className="shrink-0 text-oq-64" />}
|
|
32
|
+
<span className="kol-float-panel min-w-0 flex-1 truncate text-fg-emphasis">{title}</span>
|
|
33
|
+
{actions}
|
|
34
|
+
{onMinimise && <button type="button" aria-label="Minimise" onClick={onMinimise} className={ctl}><Icon name="minus" size={14} /></button>}
|
|
35
|
+
{onClose && <button type="button" aria-label="Close" onClick={onClose} className={ctl}><Icon name="x" size={16} /></button>}
|
|
36
|
+
</div>
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
return (
|
|
40
|
+
<div className={`kol-quicklook-header ${className}`.trim()}>
|
|
41
|
+
{nav?.total > 1 && (
|
|
42
|
+
/* the pager is its own group: the count sits off the chevrons, and the group sits clear of
|
|
43
|
+
* the file's name (user 2026-09-23) */
|
|
44
|
+
<span className="flex items-center gap-1 mr-3">
|
|
45
|
+
<Button variant="nav" size="sm" iconOnly="chevron-left" onClick={nav.onPrev} aria-label="Previous" />
|
|
46
|
+
<Button variant="nav" size="sm" iconOnly="chevron-right" onClick={nav.onNext} aria-label="Next" />
|
|
47
|
+
<span className="kol-mono-12 text-meta tabular-nums ml-3">{nav.index + 1} / {nav.total}</span>
|
|
48
|
+
</span>
|
|
49
|
+
)}
|
|
50
|
+
{title && <span className="kol-mono-12 text-strong truncate">{title}</span>}
|
|
51
|
+
{meta && <span className="kol-mono-12 text-meta truncate">{meta}</span>}
|
|
52
|
+
<span className="flex-1" />
|
|
53
|
+
{actions}
|
|
54
|
+
{/* THE ESTATE'S CLOSE IDIOM, and every header control wears it (user 2026-09-23): bare at
|
|
55
|
+
* rest, a wash on hover — a filled container read as a second surface on the header. LAST, at the
|
|
56
|
+
* far right (user 2026-10-18: *"X should be space between justify on the right"*) */}
|
|
57
|
+
{onClose && <CloseButton size="sm" onClick={onClose} />}
|
|
58
|
+
</div>
|
|
59
|
+
)
|
|
60
|
+
}
|
|
@@ -48,6 +48,10 @@
|
|
|
48
48
|
* to 724px — a document's own page (DocumentIndex). A level sets actions inline, and the bottom rhythm
|
|
49
49
|
* to `--kol-page-header-mb` (40px; content 16px). Unset = the section family as before.
|
|
50
50
|
* @param {ReactNode} media a mark above the eyebrow (a logo, an SVG) — with a `level` only
|
|
51
|
+
* @param {ReactNode} meta a fact at the far end of the HEADLINE's row (float-everything W9 row 140, 2026-11-04 —
|
|
52
|
+
* `Website traffic · kolkrabbi.io · Umami`): the source or scope, in mono on fg-64 (`kol-float-timecode`
|
|
53
|
+
* under `variant="float"`, else `kol-mono-12 text-meta`), baseline-aligned with the title. Unset, nothing
|
|
54
|
+
* `variant="float"` — the float page header (see SECTION_TEXT_LEVELS.float).
|
|
51
55
|
*/
|
|
52
56
|
export const HEADLINE_ROLE = {
|
|
53
57
|
pull: 'kol-section-text-pull',
|
|
@@ -74,6 +78,11 @@ export const SECTION_TEXT_LEVELS = {
|
|
|
74
78
|
/* document (DocumentIndexFigma, kol-atlas 2026-10-31) — the Research page header, the workspace sheet's: 36/1.2 bold
|
|
75
79
|
* display face at −0.005em, 12 under it; the lede 15/1.6 in the body face to a 724 edge */
|
|
76
80
|
document: { title: 'font-[family-name:var(--kol-font-family-sans)] text-[36px] font-bold leading-[1.2] tracking-[-0.005em]', lede: 'm-0 font-[family-name:var(--kol-font-family-sans-neutral)] text-[15px] leading-[1.6] text-fg-96', measure: '724px' },
|
|
81
|
+
/* float (float-everything W9 row 135, 2026-11-04 — kol-float--style 48:4542): the float page header — the eyebrow in
|
|
82
|
+
* mono (`kol-float-ruler`, fg-64, `STUDIO / WORKSPACE`), the title in `kol-float-sheet` (Inter 38/500), the subtitle
|
|
83
|
+
* in `kol-float-body` on fg-64; 8 between, 24 under. A section heading on the float is this with
|
|
84
|
+
* `headlineClass="kol-float-window"` and a `meta` (row 140). */
|
|
85
|
+
float: { title: 'kol-float-sheet', lede: 'kol-float-body text-fg-64', eyebrow: 'kol-float-ruler text-fg-64', gap: 'gap-2', mb: '24px' },
|
|
77
86
|
}
|
|
78
87
|
|
|
79
88
|
export default function SectionText({
|
|
@@ -124,6 +133,7 @@ export default function SectionText({
|
|
|
124
133
|
/* deprecated alias of `variant` (2026-10-31) */
|
|
125
134
|
level,
|
|
126
135
|
media,
|
|
136
|
+
meta,
|
|
127
137
|
}) {
|
|
128
138
|
/* a LEVEL fills the header defaults; an explicit prop always wins */
|
|
129
139
|
const variant = variantProp ?? level
|
|
@@ -153,7 +163,11 @@ export default function SectionText({
|
|
|
153
163
|
* *"more aligned like 'Studio'"* — it sat on the subtitle's line); centred on the title, not on its baseline */
|
|
154
164
|
const headRow = actionsPlacement === 'head' && !!actions && !!headline
|
|
155
165
|
const inlineHead = (actionsPlacement === 'inline' && !!actions && !body && !!headline) || headRow
|
|
156
|
-
const
|
|
166
|
+
const titleNode = headline && <Headline className={cls(`kol-section-text-headline ${headlineClass ?? (HEADLINE_ROLE[headlineSize] ?? HEADLINE_ROLE['heading-02'])}${headlineCase === 'upper' ? ' kol-section-text-caps' : ''}`, 'headline')} style={slotStyle.headline}>{headline}</Headline>
|
|
167
|
+
/* `meta` rides the headline's row, at its far end */
|
|
168
|
+
const headlineNode = titleNode && meta
|
|
169
|
+
? <div className="flex self-stretch items-baseline justify-between gap-6">{titleNode}<span className={`${variant === 'float' ? 'kol-float-timecode text-fg-64' : 'kol-mono-12 text-meta'} shrink-0`}>{meta}</span></div>
|
|
170
|
+
: titleNode
|
|
157
171
|
const bodyNode = body && (typeof body === 'string'
|
|
158
172
|
? <p className={cls(bodyClass, 'body')} style={slotStyle.body}>{body}</p>
|
|
159
173
|
: <div className={cls(bodyClass, 'body')} style={slotStyle.body}>{body}</div>)
|
|
@@ -8,8 +8,28 @@ import Divider from '../atoms/Divider.jsx'
|
|
|
8
8
|
*
|
|
9
9
|
* @param {Array<{label: string, value: ReactNode}>} items rows, keyed by label
|
|
10
10
|
* @param {boolean} framed wrap the list in leading + trailing Divider
|
|
11
|
+
* @param {'float'} [variant] `float` (float-everything W8 row 126, 2026-11-04 — kol-float--style 48:3982): the info
|
|
12
|
+
* sheet — `title` in Inter 16 (`kol-float-body-lg`) over key · value rows on the sheet radius
|
|
13
|
+
* (`--kol-float-menu-r`, surface-secondary, 24 in), no dividers (the no-borders law): the key in
|
|
14
|
+
* `kol-float-hint` on fg-64 in a 126 column, the value beside it in Inter 13 on the emphasis ink, 12 between rows
|
|
15
|
+
* @param {ReactNode} [title] float: the sheet's heading (`Book information`)
|
|
11
16
|
*/
|
|
12
|
-
export default function SpecList({ items = [], framed = false }) {
|
|
17
|
+
export default function SpecList({ items = [], framed = false, variant, title, className = '' }) {
|
|
18
|
+
if (variant === 'float') {
|
|
19
|
+
return (
|
|
20
|
+
<section className={`flex w-full flex-col gap-5 rounded-[var(--kol-float-menu-r)] bg-surface-secondary p-6 ${className}`.trim()}>
|
|
21
|
+
{title && <h3 className="kol-float-body-lg m-0 text-fg-emphasis">{title}</h3>}
|
|
22
|
+
<dl className="m-0 flex flex-col gap-3">
|
|
23
|
+
{items.map((item) => (
|
|
24
|
+
<div key={item.label} className="grid grid-cols-[126px_1fr] items-baseline gap-4">
|
|
25
|
+
<dt className="kol-float-hint text-fg-64">{item.label}</dt>
|
|
26
|
+
<dd className="kol-float-hint m-0 text-fg-emphasis" style={{ fontSize: 13 }}>{item.value}</dd>
|
|
27
|
+
</div>
|
|
28
|
+
))}
|
|
29
|
+
</dl>
|
|
30
|
+
</section>
|
|
31
|
+
)
|
|
32
|
+
}
|
|
13
33
|
return (
|
|
14
34
|
<>
|
|
15
35
|
{framed && <Divider />}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SummaryLine — A label and its value on one line. `Estimated size · 18.4 MB` (float-everything W6 row 91, 2026-11-04 —
|
|
3
|
+
* kol-float--style 46:3057): the label at the left in `kol-float-hint` on fg-64, the value at the right in
|
|
4
|
+
* `kol-float-timecode` (JetBrains Mono 12) in the emphasis ink, tabular. The line under a form that says what the
|
|
5
|
+
* action will produce; no rule above it — a gap does that.
|
|
6
|
+
*
|
|
7
|
+
* @param {ReactNode} label
|
|
8
|
+
* @param {ReactNode} value
|
|
9
|
+
* @param {string} [className]
|
|
10
|
+
*/
|
|
11
|
+
export default function SummaryLine({ label, value, className = '' }) {
|
|
12
|
+
return (
|
|
13
|
+
<div className={`flex w-full items-baseline justify-between gap-4 ${className}`.trim()}>
|
|
14
|
+
<span className="kol-float-hint min-w-0 truncate text-fg-64">{label}</span>
|
|
15
|
+
<span className="kol-float-timecode shrink-0 tabular-nums text-fg-emphasis">{value}</span>
|
|
16
|
+
</div>
|
|
17
|
+
)
|
|
18
|
+
}
|
|
@@ -79,6 +79,18 @@ import { floatSurfaceClass } from '../utilities/tone.js'
|
|
|
79
79
|
* (FloatFoldBothSidesGrey, kol-fxr 2026-11-03)
|
|
80
80
|
* @param {'ground'|'handle'} [foldTone='ground'] the edge tab's look: `ground` is the pill's own; `handle` is the grey edge
|
|
81
81
|
* handle (iOS's), `--kol-oq-24` with an `--kol-oq-96` chevron, whatever the pill's `surface`
|
|
82
|
+
* THE FLOAT ROW'S PARTS (float-everything W5 rows 67 · 78 and W9 row 137, 2026-11-04 — kol-float--style 46:1948, 46:2316,
|
|
83
|
+
* 48:4586), `variant="float"` only:
|
|
84
|
+
* @param {'xs'|'sm'|'md'|'lg'} [size] `xs` — the inspector's chip tabs: 26 capsules in `kol-float-label`, 10 in, the
|
|
85
|
+
* selected one fg-16 (row 67); sm · md · lg are the float button heights
|
|
86
|
+
* @param {'mono'} [type] `mono` — text tabs: mono labels (`kol-float-timecode`) at the sm height on the list radius, the
|
|
87
|
+
* selected one FILLED fg-16, the rest fg-48 (row 137 — the underline's rule replaced by the fill)
|
|
88
|
+
* A float tab takes `icon` (before the label, oq) and `count` (after it, mono, fg-64) — `Tasks 5` (row 78).
|
|
89
|
+
* @param {'solid'|'glass-dark'|'glass-light'} [surface] on `float`: the row sits in its own capsule — the float material,
|
|
90
|
+
* 6 in, so `size="lg"` tabs make the 56 pill (row 78). Unset, the row is bare as before
|
|
91
|
+
* @param {ReactNode} [trailing] inside the pill, after the tabs: the float capsule's (with `surface`) or the stacked
|
|
92
|
+
* phone pill's — AppFloatNav's transport puts its Timecode here. With `trailing` the phone pill anchors its LEFT
|
|
93
|
+
* edge where a centred pill without it would start, so every slot stays where it was; it grows to the right
|
|
82
94
|
* Tabs are `{ id, label }` or `{ value, label }` (either key), plus `icon` for stacked; a stacked tab's `selected`
|
|
83
95
|
* lights it whatever `value` is — action slots (the transport) light more than one.
|
|
84
96
|
*/
|
|
@@ -106,16 +118,28 @@ export const tabbarPillSlot = (at, { count, labels = false, split = false } = {}
|
|
|
106
118
|
/* the collapse's motion — one duration for the width and the glyph swap (300, user 2026-10-23: 180 read as abrupt) */
|
|
107
119
|
const COLLAPSE_MS = 300
|
|
108
120
|
|
|
109
|
-
export default function TabsRow({ tabs: raw = [], value, onChange, onClose, onMinimise, variant, look: lookLegacy, type
|
|
121
|
+
export default function TabsRow({ tabs: raw = [], value, onChange, onClose, onMinimise, variant, look: lookLegacy, type, trailing, filled = false, placement = 'inline', shape = 'bar', collapsed = false, onExpand, edge, border, shadow, dock, active, foldable, folded, onFoldChange, foldSide, foldTone, surface, split, labels, size, tracked = false, overflow = 'scroll', ariaLabel, className, style }) {
|
|
110
122
|
const tabs = raw.map((t) => ({ ...t, id: t.id ?? t.value }))
|
|
111
123
|
const look = variant ?? lookLegacy ?? 'underline'
|
|
112
124
|
const wrap = overflow === 'wrap'
|
|
113
125
|
/* `float` (W16, round 3): the chip row as capsules — float heights, pills 4 apart, the selected one oq-16 */
|
|
114
|
-
if (look === 'float')
|
|
126
|
+
if (look === 'float') {
|
|
127
|
+
const row = <ChipTabs tabs={tabs} value={value} onChange={onChange} size={size ?? 'md'} float floatType={type} ariaLabel={ariaLabel} className={`${wrap ? 'flex-wrap ' : ''}${surface ? '' : className ?? ''}`} />
|
|
128
|
+
/* the capsule (row 78): the float material, 6 in, the tabs then the trailing slot */
|
|
129
|
+
if (surface) {
|
|
130
|
+
return (
|
|
131
|
+
<div className={`inline-flex max-w-full items-center gap-1 rounded-full p-1.5 ${floatSurfaceClass(surface)} ${className ?? ''}`.trim()}>
|
|
132
|
+
<Overflow mode={overflow} value={value}>{row}</Overflow>
|
|
133
|
+
{trailing && <div className="flex shrink-0 items-center gap-1">{trailing}</div>}
|
|
134
|
+
</div>
|
|
135
|
+
)
|
|
136
|
+
}
|
|
137
|
+
return <Overflow mode={overflow} value={value}>{row}</Overflow>
|
|
138
|
+
}
|
|
115
139
|
if (look === 'chip') return <Overflow mode={overflow} value={value}><ChipTabs tabs={tabs} value={value} onChange={onChange} size={size ?? 'sm'} filled={filled} ariaLabel={ariaLabel} className={`${wrap ? 'flex-wrap ' : ''}${className ?? ''}`} /></Overflow>
|
|
116
140
|
if (look === 'text') return <Overflow mode={overflow} value={value}><TextTabs tabs={tabs} value={value} onChange={onChange} size={size ?? 14} tracked={tracked} className={`${wrap ? 'flex-wrap gap-y-2 ' : ''}${className ?? 'gap-6'}`} style={style} /></Overflow>
|
|
117
|
-
if (look === 'stacked') return <StackedTabs tabs={tabs} value={value} onChange={onChange} placement={placement} shape={shape} collapsed={collapsed} onExpand={onExpand} edge={edge} border={border} shadow={shadow} dock={dock} active={active} foldable={foldable} folded={folded} onFoldChange={onFoldChange} foldSide={foldSide} foldTone={foldTone} surface={surface} split={split} labels={labels} ariaLabel={ariaLabel} className={className ?? ''} />
|
|
118
|
-
return <Overflow mode={overflow} value={value}><UnderlineTabs tabs={tabs} value={value} onChange={onChange} onClose={onClose} onMinimise={onMinimise} wrap={wrap} type={type} /></Overflow>
|
|
141
|
+
if (look === 'stacked') return <StackedTabs trailing={trailing} tabs={tabs} value={value} onChange={onChange} placement={placement} shape={shape} collapsed={collapsed} onExpand={onExpand} edge={edge} border={border} shadow={shadow} dock={dock} active={active} foldable={foldable} folded={folded} onFoldChange={onFoldChange} foldSide={foldSide} foldTone={foldTone} surface={surface} split={split} labels={labels} ariaLabel={ariaLabel} className={className ?? ''} />
|
|
142
|
+
return <Overflow mode={overflow} value={value}><UnderlineTabs tabs={tabs} value={value} onChange={onChange} onClose={onClose} onMinimise={onMinimise} wrap={wrap} type={type ?? 'mono'} /></Overflow>
|
|
119
143
|
}
|
|
120
144
|
|
|
121
145
|
/* `overflow="scroll"`: the row in a sideways scroller that fades its clipped edges and keeps the active tab (`data-active`)
|
|
@@ -138,11 +162,31 @@ function Overflow({ mode, value, children }) {
|
|
|
138
162
|
}
|
|
139
163
|
|
|
140
164
|
/* chip — TabChips verbatim */
|
|
141
|
-
function ChipTabs({ tabs, value, onChange, size, filled, float = false, ariaLabel, className }) {
|
|
165
|
+
function ChipTabs({ tabs, value, onChange, size, filled, float = false, floatType, ariaLabel, className }) {
|
|
166
|
+
/* the float's two plain rows — the inspector's 26 chips (xs) and the mono text tabs — are drawn here, not by Button:
|
|
167
|
+
* neither is a Button rung (26 is not a float height; a mono label is not the float button's type) */
|
|
168
|
+
const plain = float && (size === 'xs' || floatType === 'mono')
|
|
142
169
|
return (
|
|
143
170
|
<div className={`flex items-center ${filled ? 'gap-2' : 'gap-1'}${float ? ' kol-tabs-float' : ''} ${className}`.trim()} role="tablist" aria-label={ariaLabel}>
|
|
144
171
|
{tabs.map((t) => {
|
|
145
172
|
const active = t.id === value
|
|
173
|
+
if (plain) {
|
|
174
|
+
const mono = floatType === 'mono'
|
|
175
|
+
return (
|
|
176
|
+
<button key={t.id} type="button" role="tab" aria-selected={active} data-active={active || undefined} onClick={() => onChange?.(t.id)}
|
|
177
|
+
className={`inline-flex shrink-0 items-center whitespace-nowrap cursor-pointer focus-visible:outline-none focus-visible:shadow-[var(--kol-float-focus)] ${mono ? 'kol-float-timecode h-[var(--kol-float-h-sm)] rounded-[var(--kol-float-list-r)] px-3' : 'kol-float-label h-[26px] rounded-full px-2.5'} ${active ? 'bg-fg-16 text-fg-emphasis' : `${mono ? 'text-fg-48' : 'text-fg-64'} hover:bg-fg-08 hover:text-fg-emphasis`}`}>
|
|
178
|
+
{t.label}
|
|
179
|
+
</button>
|
|
180
|
+
)
|
|
181
|
+
}
|
|
182
|
+
if (float && (t.icon || t.count != null)) {
|
|
183
|
+
return (
|
|
184
|
+
<Button key={t.id} variant="float" size={size} iconLeft={t.icon} pressed={active} role="tab" aria-selected={active} aria-pressed={undefined} data-active={active || undefined} onClick={() => onChange?.(t.id)}>
|
|
185
|
+
{t.label}
|
|
186
|
+
{t.count != null && <span className="kol-float-ruler ml-0.5 tabular-nums text-fg-64">{t.count}</span>}
|
|
187
|
+
</Button>
|
|
188
|
+
)
|
|
189
|
+
}
|
|
146
190
|
return (
|
|
147
191
|
/* a tab is selected, not pressed — the role's own attribute replaces Button's aria-pressed */
|
|
148
192
|
<Button key={t.id} variant={float ? 'float' : filled ? 'tab-filled' : 'tab'} size={size} pressed={active} role="tab" aria-selected={active} aria-pressed={undefined} data-active={active || undefined} onClick={() => onChange?.(t.id)}>
|
|
@@ -177,7 +221,7 @@ function TextTabs({ tabs, value, onChange, size, tracked, className, style }) {
|
|
|
177
221
|
/* the fold: a sideways swipe past this folds the pill, as frame E's prototype measures it */
|
|
178
222
|
const FOLD_SWIPE = 40
|
|
179
223
|
|
|
180
|
-
function StackedTabs({ tabs, value, onChange, placement, shape = 'bar', collapsed = false, onExpand, edge = 'bottom', border = true, shadow = false, dock = false, active: activeShape = 'fill', foldable = false, folded: foldedProp, onFoldChange, foldSide: foldSideProp = 'left', foldTone = 'ground', surface = 'solid', split: splitProp = false, labels = false, ariaLabel = 'Sections', className }) {
|
|
224
|
+
function StackedTabs({ trailing, tabs, value, onChange, placement, shape = 'bar', collapsed = false, onExpand, edge = 'bottom', border = true, shadow = false, dock = false, active: activeShape = 'fill', foldable = false, folded: foldedProp, onFoldChange, foldSide: foldSideProp = 'left', foldTone = 'ground', surface = 'solid', split: splitProp = false, labels = false, ariaLabel = 'Sections', className }) {
|
|
181
225
|
const [foldedOwn, setFoldedOwn] = useState(false)
|
|
182
226
|
const swipe = useRef({ x: null, swiped: false })
|
|
183
227
|
const [swipeSide, setSwipeSide] = useState('left')
|
|
@@ -335,6 +379,8 @@ function StackedTabs({ tabs, value, onChange, placement, shape = 'bar', collapse
|
|
|
335
379
|
gap: TABBAR_PILL_SPLIT_GAP,
|
|
336
380
|
...(dock
|
|
337
381
|
? { left: 'calc(var(--kol-shell-rail-width, 48px) + 64px)', bottom: 64 }
|
|
382
|
+
/* with a trailing slot the pill grows rightward from where a centred one would start — the slots never move */
|
|
383
|
+
: trailing ? { left: `calc(50% - ${W / 2}px)`, [top ? 'top' : 'bottom']: inset }
|
|
338
384
|
: { right: `calc(50% - ${W / 2}px)`, [top ? 'top' : 'bottom']: inset }),
|
|
339
385
|
...swipeProps.style,
|
|
340
386
|
}}
|
|
@@ -344,7 +390,7 @@ function StackedTabs({ tabs, value, onChange, placement, shape = 'bar', collapse
|
|
|
344
390
|
className={`relative flex items-center rounded-full overflow-hidden ${material}`.trim()}
|
|
345
391
|
style={{
|
|
346
392
|
height: TABBAR_PILL_H,
|
|
347
|
-
width: isCollapsed && !split ? TABBAR_PILL_H : barW,
|
|
393
|
+
width: isCollapsed && !split ? TABBAR_PILL_H : trailing ? 'auto' : barW,
|
|
348
394
|
padding: labels ? 3 : 4,
|
|
349
395
|
border: edgeLine,
|
|
350
396
|
...solidLook,
|
|
@@ -354,6 +400,7 @@ function StackedTabs({ tabs, value, onChange, placement, shape = 'bar', collapse
|
|
|
354
400
|
}}
|
|
355
401
|
>
|
|
356
402
|
{row}
|
|
403
|
+
{trailing && !isCollapsed && <div className="flex flex-none items-center pl-3 pr-4">{trailing}</div>}
|
|
357
404
|
{closeX}
|
|
358
405
|
</div>
|
|
359
406
|
{split && tip(isCollapsed ? { id: last.id, label: 'Close' } : last, (
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Icon } from '@kolkrabbi/kol-icons'
|
|
2
|
+
import ToggleCheckbox from '../atoms/ToggleCheckbox.jsx'
|
|
3
|
+
|
|
4
|
+
/* taxonomy-ok: molecule — nests ToggleCheckbox (atom) + kol-icons's Icon. */
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* TaskRow — A task: check · title · date chip. `Design the Tasks tab · 2026-07-01` (float-everything W8 row 118,
|
|
8
|
+
* 2026-11-04 — kol-float--style 48:3522). The float ToggleCheckbox, the title in `kol-float-body-lg` on the emphasis
|
|
9
|
+
* ink (fg-48 and struck once done), and the date as a chip at the right: a capsule on the well (`--kol-float-well`,
|
|
10
|
+
* the field's ground) at the float md height, the calendar glyph on oq-64, the date in `kol-float-timecode`. `onDate`
|
|
11
|
+
* makes the chip a button (open your date picker there); without it the chip is a label. Lists end in an
|
|
12
|
+
* `InlineAddRow variant="float"` — the panel's `+ New brief`.
|
|
13
|
+
*
|
|
14
|
+
* @param {ReactNode} title
|
|
15
|
+
* @param {string} [date]
|
|
16
|
+
* @param {boolean} [done] · {Function} [onDone]
|
|
17
|
+
* @param {Function} [onDate]
|
|
18
|
+
* @param {Function} [onClick] the title's press
|
|
19
|
+
* @param {string} [className]
|
|
20
|
+
*/
|
|
21
|
+
export default function TaskRow({ title, date, done = false, onDone, onDate, onClick, className = '' }) {
|
|
22
|
+
const Chip = onDate ? 'button' : 'span'
|
|
23
|
+
return (
|
|
24
|
+
<div className={`flex min-h-[var(--kol-float-h-md)] w-full items-center gap-3 ${className}`.trim()}>
|
|
25
|
+
<ToggleCheckbox variant="float" checked={done} onChange={onDone} aria-label="Done" className="shrink-0" />
|
|
26
|
+
<span
|
|
27
|
+
onClick={onClick}
|
|
28
|
+
className={`kol-float-body-lg min-w-0 flex-1 truncate ${onClick ? 'cursor-pointer' : ''} ${done ? 'text-fg-48 line-through' : 'text-fg-emphasis'}`.trim()}
|
|
29
|
+
>
|
|
30
|
+
{title}
|
|
31
|
+
</span>
|
|
32
|
+
{date && (
|
|
33
|
+
<Chip
|
|
34
|
+
{...(onDate ? { type: 'button', onClick: onDate } : {})}
|
|
35
|
+
className={`inline-flex h-[var(--kol-float-h-md)] shrink-0 items-center gap-2 rounded-full bg-[var(--kol-float-well)] px-4 ${onDate ? 'cursor-pointer hover:bg-fg-08 focus-visible:outline-none focus-visible:shadow-[var(--kol-float-focus)]' : ''}`.trim()}
|
|
36
|
+
>
|
|
37
|
+
<Icon name="calendar" size={14} className="text-oq-64" />
|
|
38
|
+
<span className="kol-float-timecode tabular-nums text-fg-64">{date}</span>
|
|
39
|
+
</Chip>
|
|
40
|
+
)}
|
|
41
|
+
</div>
|
|
42
|
+
)
|
|
43
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TocRow — One entry of a numbered contents list: `01 · First interlude` (float-everything W8 row 121, 2026-11-04 —
|
|
3
|
+
* kol-float--style 48:3582). 32 tall on the list radius, 12 in: the number in mono (`kol-float-ruler`, fg-64, two
|
|
4
|
+
* digits), 16 off it the title in `kol-float-hint`. `current` is where the reader is: the row lifts to fg-16 and the
|
|
5
|
+
* title takes the emphasis ink (`aria-current="location"`); the rest sit at fg-64 and brighten under the pointer.
|
|
6
|
+
* `DocsToc variant="float"` draws its list from these.
|
|
7
|
+
*
|
|
8
|
+
* @param {number|string} [number] padded to two digits when a number
|
|
9
|
+
* @param {ReactNode} label
|
|
10
|
+
* @param {boolean} [current]
|
|
11
|
+
* @param {string} [href]
|
|
12
|
+
* @param {Function} [onClick]
|
|
13
|
+
* @param {string} [className]
|
|
14
|
+
*/
|
|
15
|
+
export default function TocRow({ number, label, current = false, href, onClick, className = '' }) {
|
|
16
|
+
const Tag = href ? 'a' : 'button'
|
|
17
|
+
const n = typeof number === 'number' ? String(number).padStart(2, '0') : number
|
|
18
|
+
return (
|
|
19
|
+
<Tag
|
|
20
|
+
{...(href ? { href } : { type: 'button' })}
|
|
21
|
+
onClick={onClick}
|
|
22
|
+
aria-current={current ? 'location' : undefined}
|
|
23
|
+
className={`group flex h-8 w-full items-center gap-4 rounded-[var(--kol-float-list-r)] px-3 text-left no-underline cursor-pointer focus-visible:outline-none focus-visible:shadow-[var(--kol-float-focus)] ${current ? 'bg-fg-16' : 'hover:bg-fg-08'} ${className}`.trim()}
|
|
24
|
+
>
|
|
25
|
+
{n != null && <span className="kol-float-ruler w-4 shrink-0 tabular-nums text-fg-64">{n}</span>}
|
|
26
|
+
<span className={`kol-float-hint min-w-0 flex-1 truncate ${current ? 'text-fg-emphasis' : 'text-fg-64 group-hover:text-fg-emphasis'}`}>{label}</span>
|
|
27
|
+
</Tag>
|
|
28
|
+
)
|
|
29
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { Icon } from '@kolkrabbi/kol-icons'
|
|
2
|
+
|
|
3
|
+
/* taxonomy-ok: molecule — nests kol-icons's Icon. */
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* TreeRow — One row of a float tree: glyph · name · count · chevron. (float-everything W8 rows 120 · 122 · 123,
|
|
7
|
+
* 2026-11-04 — kol-float--style 48:3564 tree row, 48:3606 nav item, 48:3904 flyout row.) The navigation rows of the
|
|
8
|
+
* float are one row at four sizes, so the sidebar, its flyout and the drawer read as one list:
|
|
9
|
+
*
|
|
10
|
+
* xs 26 · glyph 14 · `kol-float-label` (11) — a drawer's child row
|
|
11
|
+
* sm 32 · glyph 15 · `kol-float-hint` (12) — a tree's row, the sidebar's child row
|
|
12
|
+
* md 34 · glyph 16 · `kol-float-hint` (12) — a flyout's destination (`FlyoutRow`)
|
|
13
|
+
* lg 40 · glyph 18 · Inter 13 — the sidebar's nav item
|
|
14
|
+
*
|
|
15
|
+
* On the list radius (`--kol-float-list-r`), 10 in. At rest the name is fg-64 and the glyph oq-64; `active` lifts the
|
|
16
|
+
* row to fg-16 with the emphasis ink (the selection rule — translucent, so glass shows through); `open` is the parent
|
|
17
|
+
* of the active row: the emphasis ink, no lift. `count` sits right in mono (`kol-float-ruler`, fg-64). A row with
|
|
18
|
+
* `expanded` defined draws the chevron at its end — right when shut, down when open — and `onToggle` is its press.
|
|
19
|
+
*
|
|
20
|
+
* @param {'xs'|'sm'|'md'|'lg'} [size='sm']
|
|
21
|
+
* @param {string} [icon]
|
|
22
|
+
* @param {ReactNode} label
|
|
23
|
+
* @param {ReactNode} [count]
|
|
24
|
+
* @param {boolean} [active]
|
|
25
|
+
* @param {boolean} [open] the active row's parent — bright, not lifted
|
|
26
|
+
* @param {boolean} [expanded] defined → the chevron; true = down
|
|
27
|
+
* @param {Function} [onToggle] the chevron's press (else the row's own)
|
|
28
|
+
* @param {number} [depth=0] indent, 16 per level
|
|
29
|
+
* @param {string} [href] renders an anchor
|
|
30
|
+
* @param {Function} [onClick]
|
|
31
|
+
* @param {ReactNode} [trailing] controls at the end (LayerRow's eye and lock)
|
|
32
|
+
* @param {string} [className]
|
|
33
|
+
*/
|
|
34
|
+
export const TREE_ROW = {
|
|
35
|
+
xs: { h: 'h-[26px]', ic: 14, type: 'kol-float-label' },
|
|
36
|
+
sm: { h: 'h-8', ic: 15, type: 'kol-float-hint' },
|
|
37
|
+
md: { h: 'h-[34px]', ic: 16, type: 'kol-float-hint' },
|
|
38
|
+
lg: { h: 'h-10', ic: 18, type: 'font-[family-name:var(--kol-font-family-float)] text-[13px] leading-[18px]' },
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export default function TreeRow({ size = 'sm', icon, label, count, active = false, open = false, expanded, onToggle, depth = 0, href, onClick, trailing, className = '', ...rest }) {
|
|
42
|
+
const S = TREE_ROW[size] ?? TREE_ROW.sm
|
|
43
|
+
const bright = active || open
|
|
44
|
+
const Tag = href ? 'a' : 'button'
|
|
45
|
+
const toggle = expanded !== undefined && (
|
|
46
|
+
<span
|
|
47
|
+
role={onToggle ? 'button' : undefined}
|
|
48
|
+
aria-label={onToggle ? (expanded ? 'Collapse' : 'Expand') : undefined}
|
|
49
|
+
onClick={onToggle ? (e) => { e.preventDefault(); e.stopPropagation(); onToggle() } : undefined}
|
|
50
|
+
className="inline-flex shrink-0 text-oq-64"
|
|
51
|
+
>
|
|
52
|
+
<Icon name={expanded ? 'chevron-down' : 'chevron-right'} size={12} />
|
|
53
|
+
</span>
|
|
54
|
+
)
|
|
55
|
+
return (
|
|
56
|
+
<Tag
|
|
57
|
+
{...(href ? { href } : { type: 'button' })}
|
|
58
|
+
onClick={onClick ?? (expanded !== undefined && !href ? onToggle : undefined)}
|
|
59
|
+
aria-current={active ? 'page' : undefined}
|
|
60
|
+
aria-expanded={expanded}
|
|
61
|
+
className={`group flex w-full ${S.h} shrink-0 items-center gap-2.5 rounded-[var(--kol-float-list-r)] pr-2.5 text-left no-underline cursor-pointer focus-visible:outline-none focus-visible:shadow-[var(--kol-float-focus)] ${active ? 'bg-fg-16' : 'hover:bg-fg-08'} ${className}`.trim()}
|
|
62
|
+
style={{ paddingLeft: 10 + depth * 16 }}
|
|
63
|
+
{...rest}
|
|
64
|
+
>
|
|
65
|
+
{icon && <Icon name={icon} size={S.ic} className={`shrink-0 ${bright ? 'text-oq-96' : 'text-oq-64 group-hover:text-oq-96'}`} />}
|
|
66
|
+
<span className={`${S.type} min-w-0 flex-1 truncate ${bright ? 'text-fg-emphasis' : 'text-fg-64 group-hover:text-fg-emphasis'}`}>{label}</span>
|
|
67
|
+
{count != null && <span className="kol-float-ruler shrink-0 tabular-nums text-fg-64">{count}</span>}
|
|
68
|
+
{trailing}
|
|
69
|
+
{toggle}
|
|
70
|
+
</Tag>
|
|
71
|
+
)
|
|
72
|
+
}
|
|
@@ -6,6 +6,7 @@ import Divider from '../atoms/Divider.jsx'
|
|
|
6
6
|
import Dropdown from '../molecules/Dropdown.jsx'
|
|
7
7
|
import Input from '../atoms/Input.jsx'
|
|
8
8
|
import ViewToggle from '../atoms/ViewToggle.jsx'
|
|
9
|
+
import SearchInput from '../molecules/SearchInput.jsx'
|
|
9
10
|
import FullscreenOverlay from '../utilities/FullscreenOverlay.jsx'
|
|
10
11
|
import { Tooltip } from '../utilities/Popover.jsx'
|
|
11
12
|
import MediaTile from '../molecules/MediaTile.jsx'
|
|
@@ -1049,6 +1050,14 @@ function PickerShell({ onClose, onPick }) {
|
|
|
1049
1050
|
* @param {boolean} flat start in flat mode
|
|
1050
1051
|
* @param {Function} onClose modal only — Esc, backdrop, close button
|
|
1051
1052
|
* @param {Function} onSelect `(url, { contentType, kind })`. In `modal` it also closes.
|
|
1053
|
+
*
|
|
1054
|
+
* `float` (float-everything W6 row 87, 2026-11-04 — kol-float--style 46:2960): the asset window — a 310 float panel,
|
|
1055
|
+
* non-modal (no scrim, the scene stays live), `kol-float-solid` on the sheet radius, 20 in. The title in
|
|
1056
|
+
* `kol-float-window` with the × · a float SearchInput · the files as rows (a 44 × 54 cover on 6, the name in Inter 13,
|
|
1057
|
+
* `ext · size` in mono 10, a check on the picked one) — a press picks (`onSelect`) · `onImport` draws `+ Import`
|
|
1058
|
+
* (a float button, secondary) beside the count. Same `open` · `client` · `accept` · `onClose` · `onSelect` as `modal`.
|
|
1059
|
+
* @param {string} title float: the window's title (default `Assets`)
|
|
1060
|
+
* @param {Function} onImport float: shows the import button · {string} importLabel (default `Import`)
|
|
1052
1061
|
*/
|
|
1053
1062
|
export default function MediaLibrary({
|
|
1054
1063
|
variant = 'page',
|
|
@@ -1063,6 +1072,7 @@ export default function MediaLibrary({
|
|
|
1063
1072
|
...pageProps
|
|
1064
1073
|
}) {
|
|
1065
1074
|
const opts = { client, accept, pageSize, defaultSort, flat }
|
|
1075
|
+
if (variant === 'float') return open ? withProvider(<FloatPicker onClose={onClose} onPick={onSelect} {...pageProps} />, opts) : null
|
|
1066
1076
|
if (variant === 'modal') {
|
|
1067
1077
|
if (!open) return null
|
|
1068
1078
|
return withProvider(<PickerShell onClose={onClose} onPick={onSelect} />, opts)
|
|
@@ -1139,6 +1149,51 @@ function PickerBrowse({ client, accept, onClose, onSelect, title = 'MEDIA', ...b
|
|
|
1139
1149
|
)
|
|
1140
1150
|
}
|
|
1141
1151
|
|
|
1152
|
+
/* THE ASSET WINDOW (`variant="float"`, W6 row 87) — read-only, a picker: rows from the provider, the search its own */
|
|
1153
|
+
function FloatPicker({ onClose, onPick, onImport, importLabel = 'Import', title = 'Assets', className = '' }) {
|
|
1154
|
+
const { sorted, search, setSearch, mediaUrl, loading, error } = useMediaLibrary()
|
|
1155
|
+
const [picked, setPicked] = useState(null)
|
|
1156
|
+
const files = sorted.filter((o) => o.type !== 'folder')
|
|
1157
|
+
const pick = (o) => { setPicked(o.key); onPick?.(mediaUrl(o.fullKey ?? o.key), { contentType: o.contentType, kind: o.kind }) }
|
|
1158
|
+
return (
|
|
1159
|
+
<section role="dialog" aria-label={title} className={`kol-float-solid flex w-[310px] max-w-full flex-col gap-4 rounded-[var(--kol-float-menu-r)] p-5 ${className}`.trim()}>
|
|
1160
|
+
<div className="flex items-center gap-3">
|
|
1161
|
+
<span className="kol-float-window min-w-0 flex-1 truncate text-fg-emphasis">{title}</span>
|
|
1162
|
+
{onClose && (
|
|
1163
|
+
<button type="button" aria-label="Close" onClick={onClose} className="inline-flex size-6 shrink-0 items-center justify-center rounded-full text-oq-64 hover:bg-fg-08 hover:text-oq-96 cursor-pointer focus-visible:outline-none focus-visible:shadow-[var(--kol-float-focus)]">
|
|
1164
|
+
<Icon name="x" size={16} />
|
|
1165
|
+
</button>
|
|
1166
|
+
)}
|
|
1167
|
+
</div>
|
|
1168
|
+
<SearchInput variant="float" value={search ?? ''} onChange={(e) => setSearch(e.target.value)} placeholder="Search assets…" />
|
|
1169
|
+
<ul className="m-0 flex max-h-[320px] list-none flex-col gap-1 overflow-y-auto p-0 [scrollbar-width:none]">
|
|
1170
|
+
{error && <li className="kol-float-hint text-ui-error">Couldn’t load: {error}</li>}
|
|
1171
|
+
{!error && loading && <li className="kol-float-hint text-fg-64">Loading…</li>}
|
|
1172
|
+
{!error && !loading && files.length === 0 && <li className="kol-float-hint text-fg-64">Nothing here.</li>}
|
|
1173
|
+
{files.map((o) => (
|
|
1174
|
+
<li key={o.key}>
|
|
1175
|
+
<button type="button" onClick={() => pick(o)} aria-pressed={picked === o.key}
|
|
1176
|
+
className={`flex w-full items-center gap-3 rounded-[var(--kol-float-list-r)] p-1 text-left cursor-pointer focus-visible:outline-none focus-visible:shadow-[var(--kol-float-focus)] ${picked === o.key ? 'bg-fg-16' : 'hover:bg-fg-08'}`}>
|
|
1177
|
+
<span className="h-[54px] w-11 shrink-0 overflow-hidden rounded-md bg-fg-08"><Thumb row={o} mediaUrl={mediaUrl} /></span>
|
|
1178
|
+
<span className="flex min-w-0 flex-1 flex-col gap-0.5">
|
|
1179
|
+
<span className="kol-float-hint truncate text-fg-emphasis" style={{ fontSize: 13 }}>{o.displayKey}</span>
|
|
1180
|
+
<span className="kol-float-ruler truncate uppercase text-fg-64">{[o.key.split('.').pop(), formatSize(o.size)].filter(Boolean).join(' · ')}</span>
|
|
1181
|
+
</span>
|
|
1182
|
+
{picked === o.key && <Icon name="check" size={14} className="mr-2 shrink-0 text-oq-96" />}
|
|
1183
|
+
</button>
|
|
1184
|
+
</li>
|
|
1185
|
+
))}
|
|
1186
|
+
</ul>
|
|
1187
|
+
{(onImport || files.length > 0) && (
|
|
1188
|
+
<div className="flex items-center gap-3">
|
|
1189
|
+
{onImport && <Button variant="float" tone="secondary" size="md" iconLeft="plus" onClick={onImport}>{importLabel}</Button>}
|
|
1190
|
+
<span className="kol-float-label text-fg-64">{files.length} {files.length === 1 ? 'asset' : 'assets'}</span>
|
|
1191
|
+
</div>
|
|
1192
|
+
)}
|
|
1193
|
+
</section>
|
|
1194
|
+
)
|
|
1195
|
+
}
|
|
1196
|
+
|
|
1142
1197
|
/** @deprecated 2026-08-01 — alias of `MediaLibrary variant="modal"`. Kept so
|
|
1143
1198
|
* existing call sites and the fxr editor's `onPick` naming keep working;
|
|
1144
1199
|
* drops when nobody imports it (04-retirements.md). */
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react'
|
|
2
|
+
import { Icon } from '@kolkrabbi/kol-icons'
|
|
3
|
+
import TreeRow from '../molecules/TreeRow.jsx'
|
|
4
|
+
|
|
5
|
+
/* taxonomy-ok: organism — nests TreeRow (molecule) + kol-icons's Icon. */
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* NavDrawer — The hidden nav, called up on demand. (float-everything W6 row 94, 2026-11-04 — kol-float--style 46:3115.)
|
|
9
|
+
* When the sidebar is hidden (kol-shell's RailTrigger), this is what the trigger opens: a 280 float overlay on the
|
|
10
|
+
* sheet radius, `kol-float-solid`, 16 in, over the page at its top-left — no scrim, it is not a blocking task. The
|
|
11
|
+
* title (`kol-float-body`) and × on one row; the tree under it — `TreeRow size="md"` for a destination, its `sub` rows
|
|
12
|
+
* `TreeRow size="xs"` (26) indented beneath; `footer` at the foot (`All pages ↓`). Escape and the × close it; picking
|
|
13
|
+
* a row navigates and closes it.
|
|
14
|
+
*
|
|
15
|
+
* @param {boolean} open · {Function} onClose
|
|
16
|
+
* @param {string} [title]
|
|
17
|
+
* @param {Array} items `{ icon, label, path, count?, sub?: [...] }` (a `{ heading }` draws a section label)
|
|
18
|
+
* @param {string} [currentPath]
|
|
19
|
+
* @param {Function} [onNavigate] `(path) => void`
|
|
20
|
+
* @param {Array} [defaultExpanded] sections open on open; default — the section holding `currentPath`
|
|
21
|
+
* @param {ReactNode} [footer]
|
|
22
|
+
* @param {boolean} [fixed=true] false renders it in flow (a preview, a story)
|
|
23
|
+
*/
|
|
24
|
+
export default function NavDrawer({ open, onClose, title, items = [], currentPath = '', onNavigate, defaultExpanded, footer, fixed = true, className = '' }) {
|
|
25
|
+
const here = items.filter((it) => it.sub?.some((c) => c.path === currentPath)).map((it) => it.path)
|
|
26
|
+
const [expanded, setExpanded] = useState(() => new Set(defaultExpanded ?? here))
|
|
27
|
+
const toggle = (p) => setExpanded((s) => { const n = new Set(s); n.has(p) ? n.delete(p) : n.add(p); return n })
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
if (!open) return undefined
|
|
30
|
+
const onKey = (e) => { if (e.key === 'Escape') onClose?.() }
|
|
31
|
+
window.addEventListener('keydown', onKey)
|
|
32
|
+
return () => window.removeEventListener('keydown', onKey)
|
|
33
|
+
}, [open, onClose])
|
|
34
|
+
if (!open) return null
|
|
35
|
+
const go = (p) => () => { onNavigate?.(p); onClose?.() }
|
|
36
|
+
return (
|
|
37
|
+
<nav aria-label={title ?? 'Navigation'}
|
|
38
|
+
className={`kol-float-solid flex max-h-[calc(100dvh-32px)] w-[280px] flex-col gap-3 rounded-[var(--kol-float-menu-r)] p-4 ${fixed ? 'fixed left-4 top-4 z-[var(--kol-z-overlay)]' : ''} ${className}`.trim()}>
|
|
39
|
+
<div className="flex items-center gap-3 pl-1">
|
|
40
|
+
<span className="kol-float-body min-w-0 flex-1 truncate text-fg-emphasis">{title}</span>
|
|
41
|
+
{onClose && (
|
|
42
|
+
<button type="button" aria-label="Close" onClick={onClose} className="inline-flex size-6 shrink-0 items-center justify-center rounded-full text-oq-64 hover:bg-fg-08 hover:text-oq-96 cursor-pointer focus-visible:outline-none focus-visible:shadow-[var(--kol-float-focus)]">
|
|
43
|
+
<Icon name="x" size={16} />
|
|
44
|
+
</button>
|
|
45
|
+
)}
|
|
46
|
+
</div>
|
|
47
|
+
<div className="flex min-h-0 flex-1 flex-col gap-0.5 overflow-y-auto [scrollbar-width:none]">
|
|
48
|
+
{items.map((it, i) => {
|
|
49
|
+
if (it.heading) return <span key={`h${i}`} className="kol-float-ruler px-2.5 pb-1 pt-3 text-fg-64">{it.heading}</span>
|
|
50
|
+
const kids = it.sub ?? []
|
|
51
|
+
const isOpen = expanded.has(it.path)
|
|
52
|
+
return (
|
|
53
|
+
<div key={it.path ?? it.label} className="flex flex-col gap-0.5">
|
|
54
|
+
<TreeRow size="md" icon={it.icon} label={it.label} count={it.count}
|
|
55
|
+
active={it.path === currentPath} open={isOpen && kids.some((c) => c.path === currentPath)}
|
|
56
|
+
onClick={kids.length ? () => toggle(it.path) : go(it.path)} aria-expanded={kids.length ? isOpen : undefined} />
|
|
57
|
+
{isOpen && kids.map((c) => (
|
|
58
|
+
<TreeRow key={c.path} size="xs" depth={1} icon={c.icon} label={c.label} count={c.count} active={c.path === currentPath} onClick={go(c.path)} />
|
|
59
|
+
))}
|
|
60
|
+
</div>
|
|
61
|
+
)
|
|
62
|
+
})}
|
|
63
|
+
</div>
|
|
64
|
+
{footer && <div className="shrink-0 pl-1">{footer}</div>}
|
|
65
|
+
</nav>
|
|
66
|
+
)
|
|
67
|
+
}
|
|
@@ -18,6 +18,7 @@ import VectorLoader from '../atoms/VectorLoader.jsx'
|
|
|
18
18
|
import { useRailSlot } from '../hooks/railSlot.jsx'
|
|
19
19
|
import { RAIL_ROW } from '../hooks/railRow.js'
|
|
20
20
|
import NavRailSite from './NavRailSite.jsx'
|
|
21
|
+
import NavRailFloat from './NavRailFloat.jsx'
|
|
21
22
|
|
|
22
23
|
/**
|
|
23
24
|
* NavRail — the flat rail. ONE fixed column, every child a direct child of it
|
|
@@ -82,7 +83,8 @@ import NavRailSite from './NavRailSite.jsx'
|
|
|
82
83
|
* EXPANDS (its rows open under it in place) and COLLAPSES. No other words, in code or docs.
|
|
83
84
|
*
|
|
84
85
|
* @param {'app'|'site'|'workshop'} preset which rail (default `app`); `variant="site"` is the old spelling of `preset="site"`
|
|
85
|
-
* @param {'top'} variant `top` — the horizontal top rail (TopRail): logomark · items · `actions` (the right slot)
|
|
86
|
+
* @param {'top'|'float'} variant `top` — the horizontal top rail (TopRail): logomark · items · `actions` (the right slot);
|
|
87
|
+
* `float` — the float sidebar, expanded 280 · collapsed 72 (NavRailFloat.jsx, float-everything W9 rows 127 · 128)
|
|
86
88
|
* @param {Array} items `{ icon, path, label, sub?: [{ icon?, path, label }] }`
|
|
87
89
|
* a section (`sub`) with `to` is a FOLDER NOTE: its icon and label open `to`, its chevron expands or enters
|
|
88
90
|
* @param {Array} bottomItems pinned below the rule (Settings)
|
|
@@ -323,6 +325,7 @@ export function registerRailPreset(name, Component) { RAIL_PRESETS[name] = { ...
|
|
|
323
325
|
|
|
324
326
|
export default function NavRail({ variant, preset, ...props }) {
|
|
325
327
|
if (variant === 'top') return <TopRail {...props} />
|
|
328
|
+
if (variant === 'float') return <NavRailFloat {...props} />
|
|
326
329
|
const name = preset ?? (variant === 'site' ? 'site' : 'app')
|
|
327
330
|
if (name === 'app') return <AppRail {...props} sections={props.sections ?? RAIL_PRESETS.app.sections} />
|
|
328
331
|
const Named = RAIL_PRESETS[name]?.component
|