@kolkrabbi/kol-component 0.364.0 → 0.365.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kolkrabbi/kol-component",
3
- "version": "0.364.0",
3
+ "version": "0.365.0",
4
4
  "description": "The core component library",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -32,9 +32,9 @@
32
32
  "embla-carousel-react": "^8.6.0",
33
33
  "pdfjs-dist": "^6.3.289",
34
34
  "react-syntax-highlighter": "^16.1.1",
35
- "@kolkrabbi/kol-search": "^0.3.0",
36
35
  "@kolkrabbi/kol-growth": "^0.5.0",
37
- "@kolkrabbi/kol-markdown": "^0.2.0"
36
+ "@kolkrabbi/kol-markdown": "^0.2.0",
37
+ "@kolkrabbi/kol-search": "^0.3.0"
38
38
  },
39
39
  "peerDependencies": {
40
40
  "@kolkrabbi/kol-icons": ">=0.69.0",
package/src/index.js CHANGED
@@ -51,6 +51,7 @@ export { default as BackgroundVideo, default as HlsVideo } from './utilities/Bac
51
51
  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
+ export { default as FloatModule } from './molecules/FloatModule.jsx'
54
55
  export { default as OverlayGlassPanel } from './utilities/OverlayGlassPanel.jsx'
55
56
  export { default as Pill } from './atoms/Pill.jsx'
56
57
  export { usePopover, PopoverPanel, Tooltip } from './utilities/Popover.jsx'
@@ -0,0 +1,73 @@
1
+ import { useState } from 'react'
2
+ import Button from '../atoms/Button.jsx'
3
+ import { floatSurfaceClass } from '../utilities/tone.js'
4
+
5
+ /* taxonomy-ok: molecule — Button (atom) in a header over a slotted body; the float module every float Rail is drawn on */
6
+
7
+ /**
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"*). A sheet on the float surface at the
10
+ * sheet radius: a header (the title in `kol-float-panel`, or your `head`, then `actions` and the fold ⌃), the body that
11
+ * scrolls under it with its scrollbar hidden, and a `footer`. Folded, it is a pill of `--kol-float-fold-h`: the title and
12
+ * the ⌄ that opens it, at the module's width. PropertyRail (kol-shell), NavRail float and ReadingContents draw on it.
13
+ * It lives in kol-component so NavRail float can use it without a reverse dependency; kol-shell re-exports it (the way
14
+ * NavRail itself moved, ARCHITECTURE §3 2026-10-22).
15
+ *
16
+ * Every size is a token of the float spec (docs/documentation/04-compositions/25-float-spec.md): the width
17
+ * `--kol-float-module-w` (`wide` `--kol-float-module-w-wide`), the radius `--kol-float-menu-r`, the rows
18
+ * `--kol-float-module-gap` (`compact` spacing-2), the fold `--kol-float-fold-h`.
19
+ *
20
+ * @param {ReactNode} [title] the header's title, and the folded pill's
21
+ * @param {ReactNode} [head] replaces the title cell in the open header (NavRail's switcher row)
22
+ * @param {ReactNode} [actions] buttons after the title (expand, collapse), before the fold
23
+ * @param {boolean} [foldable] the fold ⌃ in the header; `folded` controlled, `defaultFolded` uncontrolled,
24
+ * `onFold(folded)` on every press
25
+ * @param {boolean} [compact] the tool Rail's rhythm: rows spacing-2 apart (default `--kol-float-module-gap`)
26
+ * @param {boolean} [wide] the wide module width
27
+ * @param {number|string} [width] an explicit width (a phone's `100%`, a footprint token); unset, the module width
28
+ * @param {'md'|'sm'|'none'} [inset='md'] the sheet's inset: spacing-4 · spacing-3 (a nav's) · none
29
+ * @param {'solid'|'glass-dark'|'glass-light'} [surface='solid']
30
+ * @param {ReactNode} [footer] after the body, outside its scroll
31
+ * @param {string} [as='section'] the element (`nav` for NavRail float)
32
+ * @param {string} [className] on the sheet · {string} [bodyClassName] on the body · {Object} [style]
33
+ */
34
+ const INSET = { md: 'p-4', sm: 'p-3', none: '' }
35
+
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 }) {
37
+ const [ownFolded, setOwnFolded] = useState(defaultFolded)
38
+ const isFolded = foldable && (folded ?? ownFolded)
39
+ const fold = () => { const next = !isFolded; if (folded === undefined) setOwnFolded(next); onFold?.(next) }
40
+ const w = width ?? `var(--kol-float-module-w${wide ? '-wide' : ''})`
41
+ const label = ariaLabel ?? (typeof title === 'string' ? title : undefined)
42
+ const surfaceClass = floatSurfaceClass(surface, true)
43
+ const foldButton = foldable && (
44
+ <Button variant="float" tone="ghost" size="sm" iconOnly={isFolded ? 'chevron-down' : 'chevron-up'} aria-label={isFolded ? 'Open' : 'Fold'} aria-expanded={!isFolded} onClick={fold} />
45
+ )
46
+
47
+ if (isFolded) {
48
+ return (
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
58
+ return (
59
+ <Tag data-float-module="open" aria-label={label} style={{ ...style, width: w }}
60
+ className={`kol-float-module kol-float-chrome flex min-h-0 flex-col ${compact ? 'gap-2' : 'gap-[var(--kol-float-module-gap)]'} rounded-[var(--kol-float-menu-r)] ${INSET[inset] ?? INSET.md} ${surfaceClass} ${className}`.trim()}>
61
+ {hasHead && (
62
+ <div className="flex shrink-0 items-center justify-between gap-1">
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()}>
68
+ {children}
69
+ </div>
70
+ {footer}
71
+ </Tag>
72
+ )
73
+ }
@@ -2,10 +2,11 @@ import { useState } from 'react'
2
2
  import { IconLoader } from '@kolkrabbi/kol-icons'
3
3
  import Kbd from '../atoms/Kbd.jsx'
4
4
  import TreeRow from '../molecules/TreeRow.jsx'
5
+ import FloatModule from '../molecules/FloatModule.jsx'
5
6
  import { Tooltip } from '../utilities/Popover.jsx'
6
7
  import { floatMotion } from '../utilities/motion.js'
7
8
 
8
- /* taxonomy-ok: organism — nests TreeRow (molecule) + Kbd (atom) + Tooltip (utility) + kol-icons's Icon. */
9
+ /* taxonomy-ok: organism — nests FloatModule + TreeRow (molecules) + Kbd (atom) + Tooltip (utility) + kol-icons's Icon. */
9
10
 
10
11
  /**
11
12
  * NavRailFloat — the float sidebar, `NavRail variant="float"` (float-everything W9 rows 122 · 127 · 128 · 131,
@@ -35,6 +36,9 @@ import { floatMotion } from '../utilities/motion.js'
35
36
  * @param {ReactNode} [footer]
36
37
  * @param {Function} [onItemHover] collapsed only: `(item, element)` when the pointer enters a slot, `(null, null)` when it
37
38
  * leaves — the seam a hover flyout hangs off (kol-shell's RailFlyout, FloatLayout 2026-11-04)
39
+ * @param {boolean} [foldable] the fold ⌃ beside the switcher row (plan-2026-11-12-float-system W4.1): the rail folds to
40
+ * FloatModule's pill — `title` and ⌄ at the expanded width — apart from its 72 collapse
41
+ * and its hide. `folded` controlled, `defaultFolded` uncontrolled, `onFold(folded)`
38
42
  * @param {boolean|Object} [motion=true] expand ↔ collapse eases the width and fades the new rows in, and the slots and rows ease
39
43
  * their hover (`.kol-float-rail`, FloatActionStatesAndMotion 2026-11-04): `true` the
40
44
  * `--kol-float-*` tokens · `false` none · `{ duration, ease }` per app. Hide and show are
@@ -42,7 +46,7 @@ import { floatMotion } from '../utilities/motion.js'
42
46
  */
43
47
  const isOn = (path, current) => !!path && path === current
44
48
 
45
- export default function NavRailFloat({ items = [], currentPath = '', onNavigate, collapsed = false, onCollapsedChange, title, icon = 'grid', onSwitch, switcher, onSearch, onHide, defaultExpanded = [], footer, onItemHover, motion = true, className = '' }) {
49
+ 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 = '' }) {
46
50
  const motionStyle = floatMotion(motion).style
47
51
  const [open, setOpen] = useState(() => new Set(defaultExpanded))
48
52
  const toggle = (path) => setOpen((s) => { const n = new Set(s); n.has(path) ? n.delete(path) : n.add(path); return n })
@@ -58,7 +62,8 @@ export default function NavRailFloat({ items = [], currentPath = '', onNavigate,
58
62
  </Tooltip>
59
63
  )
60
64
  return (
61
- <nav aria-label="Navigation" style={motionStyle} className={`kol-float-rail flex h-full w-[72px] flex-col items-center gap-1 rounded-[var(--kol-float-menu-r)] bg-surface-secondary shadow-[var(--kol-shadow-float)] py-3.5 ${className}`.trim()}>
65
+ <FloatModule as="nav" aria-label="Navigation" inset="none" width="var(--kol-shell-float-rail-width, 72px)" style={motionStyle} bodyClassName="items-center !gap-1"
66
+ className={`kol-float-rail h-full !gap-1 items-center py-3.5 ${className}`.trim()}>
62
67
  {onCollapsedChange && slot('expand', 'Expand', 'panel-left', { well: true, onClick: () => onCollapsedChange(false) })}
63
68
  <div className="flex min-h-0 w-full flex-1 flex-col items-center gap-1 overflow-y-auto py-3 [scrollbar-width:none]">
64
69
  {items.map((it, i) => {
@@ -75,19 +80,22 @@ export default function NavRailFloat({ items = [], currentPath = '', onNavigate,
75
80
  </div>
76
81
  {onSearch && slot('search', 'Search pages', 'search', { well: true, onClick: onSearch })}
77
82
  {onHide && slot('hide', 'Hide', 'hamburger', { well: true, onClick: onHide })}
78
- </nav>
83
+ </FloatModule>
79
84
  )
80
85
  }
81
86
 
82
87
  return (
83
- <nav aria-label="Navigation" style={motionStyle} className={`kol-float-rail flex h-full w-[280px] flex-col gap-3 rounded-[var(--kol-float-menu-r)] bg-surface-secondary shadow-[var(--kol-shadow-float)] p-3 ${className}`.trim()}>
84
- {switcher ?? (title && (
88
+ <FloatModule as="nav" aria-label="Navigation" inset="sm" width="var(--kol-shell-float-rail-open, 280px)" style={motionStyle}
89
+ title={title} foldable={foldable} folded={folded} defaultFolded={defaultFolded} onFold={onFold}
90
+ bodyClassName="!gap-3" className={`kol-float-rail h-full !gap-3 ${className}`.trim()}
91
+ footer={footer && <div className="flex shrink-0 flex-col gap-2">{footer}</div>}
92
+ head={switcher ?? (title && (
85
93
  <button type="button" onClick={onSwitch} className="flex h-10 w-full items-center gap-2.5 rounded-[var(--kol-float-list-r)] px-2.5 text-left cursor-pointer hover:bg-fg-08 focus-visible:outline-none focus-visible:shadow-[var(--kol-float-focus)]">
86
94
  <IconLoader name={icon} size={18} className="shrink-0 text-oq-96" />
87
95
  <span className="kol-float-body-lg min-w-0 flex-1 truncate text-fg-emphasis">{title}</span>
88
96
  {onSwitch && <IconLoader name="chevron-down" size="var(--kol-float-chev-lg)" className="shrink-0 text-oq-64" />}
89
97
  </button>
90
- ))}
98
+ ))}>
91
99
  {onSearch && (
92
100
  <button type="button" onClick={onSearch} className="flex h-[var(--kol-float-h-md)] w-full items-center gap-2.5 rounded-full bg-[var(--kol-float-well)] pl-3 pr-2 text-left cursor-pointer hover:bg-fg-08 focus-visible:outline-none focus-visible:shadow-[var(--kol-float-focus)]">
93
101
  <IconLoader name="search" size={16} className="shrink-0 text-oq-64" />
@@ -114,7 +122,6 @@ export default function NavRailFloat({ items = [], currentPath = '', onNavigate,
114
122
  )
115
123
  })}
116
124
  </div>
117
- {footer && <div className="flex shrink-0 flex-col gap-2">{footer}</div>}
118
- </nav>
125
+ </FloatModule>
119
126
  )
120
127
  }
@@ -1,8 +1,8 @@
1
- import Button from '../atoms/Button.jsx'
1
+ import FloatModule from '../molecules/FloatModule.jsx'
2
2
  import ProgressBar from '../atoms/ProgressBar.jsx'
3
3
  import TocRow from '../molecules/TocRow.jsx'
4
4
 
5
- /* taxonomy-ok: organism — the reader's contents sheet: book head, TocRow list, progress */
5
+ /* taxonomy-ok: organism — the reader's contents on FloatModule: book head, TocRow list, progress */
6
6
 
7
7
  /**
8
8
  * ReadingContents — The book's contents, where the reader is in them, and how far through. `Contents · The Waves ·
@@ -20,22 +20,23 @@ import TocRow from '../molecules/TocRow.jsx'
20
20
  * @param {number} [progress] 0–100; unset, no progress line
21
21
  * @param {string} [progressLabel] default `Through the book`
22
22
  * @param {ReactNode} [status] `Reading position saved`
23
- * @param {Function} [onFold]
24
- * @param {number} [width] default 304
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)
25
27
  * @param {boolean} [bare] the body only — book, chapters, progress, status — with no sheet and no header, for
26
28
  * kol-shell's PropertyRail, the float module that carries the title and the fold (2026-11-12)
27
29
  * @param {string} [className]
28
30
  */
29
- export default function ReadingContents({ title = 'Contents', book, author, count, chapters = [], current, onSelect, progress, progressLabel = 'Through the book', status, onFold, width = 304, bare = false, className = '' }) {
30
- if (bare) return <div className={`flex flex-col ${className}`.trim()}><Body {...{ title, book, author, count, chapters, current, onSelect, progress, progressLabel, status }} /></div>
31
+ export default function ReadingContents({ title = 'Contents', book, author, count, chapters = [], current, onSelect, progress, progressLabel = 'Through the book', status, onFold, foldable = false, folded, defaultFolded = false, width, bare = false, className = '' }) {
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
35
  return (
32
- <aside className={`flex flex-col rounded-[var(--kol-float-menu-r)] bg-surface-secondary p-5 ${className}`.trim()} style={{ width }} aria-label={title}>
33
- <div className="flex h-7 items-center justify-between">
34
- <span className="kol-float-body-lg text-fg-emphasis">{title}</span>
35
- {onFold && <Button variant="float" tone="ghost" size="sm" iconOnly="chevron-up" aria-label="Fold" onClick={onFold} className="-mr-1.5" />}
36
- </div>
37
- <Body {...{ title, book, author, count, chapters, current, onSelect, progress, progressLabel, status }} />
38
- </aside>
36
+ <FloatModule as="aside" title={title} width={width} foldable={foldable || !!onFold} folded={folded} defaultFolded={defaultFolded} onFold={onFold}
37
+ className={className} bodyClassName="!gap-0">
38
+ <div className="flex flex-col">{body}</div>
39
+ </FloatModule>
39
40
  )
40
41
  }
41
42