@kolkrabbi/kol-component 0.297.0 → 0.298.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.297.0",
3
+ "version": "0.298.0",
4
4
  "description": "The core component library",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -26,8 +26,8 @@
26
26
  "embla-carousel-react": "^8.6.0",
27
27
  "pdfjs-dist": "^6.3.289",
28
28
  "react-syntax-highlighter": "^16.1.1",
29
- "@kolkrabbi/kol-markdown": "^0.1.3",
30
- "@kolkrabbi/kol-search": "^0.3.0"
29
+ "@kolkrabbi/kol-search": "^0.3.0",
30
+ "@kolkrabbi/kol-markdown": "^0.1.3"
31
31
  },
32
32
  "peerDependencies": {
33
33
  "@kolkrabbi/kol-icons": ">=0.22.0",
@@ -24,7 +24,9 @@ import useGrabEdge from './useGrabEdge.js'
24
24
  *
25
25
  * - CLICK TOGGLES expand↔collapse: pointerup with < 3px of travel is a
26
26
  * click, never a resize — drags only start past the slop, so toggle
27
- * presses can't jitter the rail.
27
+ * presses can't jitter the rail. Expanding by a press lands on the
28
+ * stylesheet's rung for the viewport, not a remembered drag width
29
+ * (2026-10-24).
28
30
  * - DRAG resizes; live width goes to --kol-sidenav-w on :root so the grid,
29
31
  * shell-header brand block and aside follow one number. Dragging under
30
32
  * --kol-sidenav-snap stamps :root[data-sidenav="collapsed"].
@@ -189,6 +191,10 @@ export default function useDragResize(ref, options = {}) {
189
191
  const toggleCollapsed = () => {
190
192
  const { collapsed: c } = readBack(names)
191
193
  stampCollapsed(names, !c)
194
+ /* EXPANDING BY A PRESS LANDS ON THE RUNG (user 2026-10-24: "clicking the rail when collapsed should go to
195
+ * that default"): the stylesheet's width for this viewport (264 · 320 from 1536), never a remembered drag
196
+ * width — the override is cleared, and persisted as cleared */
197
+ if (c) writeWidth(names, null)
192
198
  syncAndPersist()
193
199
  }
194
200
 
package/src/index.js CHANGED
@@ -105,6 +105,7 @@ export { default as CodeBlock } from './molecules/CodeBlock.jsx'
105
105
  export { default as ColorInputRow } from './molecules/ColorInputRow.jsx'
106
106
  export { default as ColorRamp } from './molecules/ColorRamp.jsx'
107
107
  export { default as TextFold } from './molecules/TextFold.jsx'
108
+ export { default as PageControls } from './molecules/PageControls.jsx'
108
109
  export { default as ColorSwatch } from './molecules/ColorSwatch.jsx'
109
110
  export { default as Dropdown } from './molecules/Dropdown.jsx'
110
111
  /* MultiSelect — several pick-one settings in one dropdown, a column each (2026-10-01, first cut) */
@@ -131,8 +131,12 @@ const MEDIA = {
131
131
  showcase: { zoom: true },
132
132
  /* frame OFF by default (ListingCardThumbBorder, user 2026-08-27: "I hate
133
133
  * border — remove border"): the article thumb's hairline is opt-in —
134
- * `frame` turns it on, and with it the fg-08 → fg-16 hover step */
135
- article: { frame: false, borderHover: true, zoom: true },
134
+ * `frame` turns it on, and with it the fg-08 → fg-16 hover step.
135
+ * ZOOM OFF (user 2026-10-24, site-hub W4: "an annoying habit of using article
136
+ * contentcard with a stupid zoom on hover"): a page link is not image-led —
137
+ * the thumb stays put, as the app card's hover fill went (2026-10-23). `zoom`
138
+ * stays an opt-in prop; the hero rung is hero's own. */
139
+ article: { frame: false, borderHover: true, zoom: false },
136
140
  }
137
141
 
138
142
  /* VARIANTS ARE CONTENT KINDS, NEVER PAGE NAMES (user ruling 2026-08-29:
@@ -0,0 +1,69 @@
1
+ import Tag from '../atoms/Tag.jsx'
2
+ import SegmentedToggle from '../atoms/SegmentedToggle.jsx'
3
+ import TabsRow from './TabsRow.jsx'
4
+
5
+ /* taxonomy-ok: molecule — composes Tag, SegmentedToggle (atoms) and TabsRow (a molecule of chips) into one strip */
6
+
7
+ /**
8
+ * PageControls — The page's own controls, one strip. the controls a PAGE carries for itself — which series show,
9
+ * which view, where to jump, what the dots mean, how many are showing — in one sticky strip under the page
10
+ * header, every page the same (site-hub W4, user 2026-10-24: kol-branding's Compare and Moods carried the same
11
+ * five pieces in two orders, each page hand-laying its own sticky bar). Not content filters: `ContentFilters`
12
+ * narrows a COLLECTION by its facets; this strip drives the page's rendering.
13
+ *
14
+ * The slots, in the order they are drawn — an empty slot is not there:
15
+ * row 1 toggles · views · count the series chips (Tag), the view switches (SegmentedToggle), the readout
16
+ * row 2 jump the section tabs (TabsRow look="chip"), scrolling sideways when long
17
+ * row 3 legend a dot and a name per series, as many columns as series
18
+ *
19
+ * STICKY by default: `sticky top-0` on the page's z-sticky rung, a hairline under it, the surface painted so the
20
+ * page scrolls beneath — kol-branding's StickyBar line, carried. The host page gives it the page's horizontal
21
+ * edge (a `kol-shell-page-bleed` in the app shell, nothing on a site plane).
22
+ *
23
+ * @param {Object} [toggles] `{ label, items: [{ id, label, active }], onToggle(id) }` — Tag chips, pressed = showing
24
+ * @param {Array} [views] `[{ label, value, onChange, options: [{ value, label }] }]` — one SegmentedToggle each
25
+ * @param {ReactNode}[count] the readout on the row's right (`15 / 15`)
26
+ * @param {Object} [jump] `{ label, value, onChange, tabs: [{ id, label }] }` — TabsRow chips
27
+ * @param {Array} [legend] `[{ id, label, color }]` — a dot (`color`, a CSS color) and a name per series
28
+ * @param {boolean} [sticky=true]
29
+ * @param {string} [className]
30
+ */
31
+ export default function PageControls({ toggles, views = [], count, jump, legend, sticky = true, className = '' }) {
32
+ const rowOne = toggles || views.length > 0 || count != null
33
+ return (
34
+ <div
35
+ className={`${sticky ? 'md:sticky top-0 z-[calc(var(--kol-z-sticky)-1)]' : ''} flex flex-col gap-3 border-b border-fg-08 bg-surface-primary bg-[linear-gradient(var(--kol-shell-page-wash,transparent),var(--kol-shell-page-wash,transparent))] py-3 ${className}`.replace(/\s+/g, ' ').trim()}
36
+ >
37
+ {rowOne && (
38
+ <div className="flex flex-wrap items-center gap-x-6 gap-y-3">
39
+ {toggles && (
40
+ <div className="flex flex-wrap items-center gap-2" role="group" aria-label={toggles.label}>
41
+ {toggles.items.map((t) => (
42
+ <Tag key={t.id} hash={false} active={t.active} onClick={() => toggles.onToggle(t.id)}>{t.label}</Tag>
43
+ ))}
44
+ </div>
45
+ )}
46
+ {views.map((v) => (
47
+ <SegmentedToggle key={v.label} ariaLabel={v.label} size="sm" value={v.value} onChange={v.onChange} options={v.options} />
48
+ ))}
49
+ {count != null && <span className="kol-mono-12 text-fg-48 ml-auto">{count}</span>}
50
+ </div>
51
+ )}
52
+ {jump && (
53
+ <div className="overflow-x-auto">
54
+ <TabsRow look="chip" size="sm" ariaLabel={jump.label} value={jump.value} onChange={jump.onChange} tabs={jump.tabs} />
55
+ </div>
56
+ )}
57
+ {legend && legend.length > 0 && (
58
+ <div className="grid grid-cols-1 gap-4 xl:[grid-template-columns:var(--cols)]" style={{ '--cols': `repeat(${legend.length}, minmax(0, 1fr))` }}>
59
+ {legend.map((l) => (
60
+ <span key={l.id} className="flex items-center gap-2 min-w-0">
61
+ <span className="h-2.5 w-2.5 flex-none rounded-full border border-fg-24" style={{ background: l.color }} aria-hidden="true" />
62
+ <span className="kol-mono-12 truncate">{l.label}</span>
63
+ </span>
64
+ ))}
65
+ </div>
66
+ )}
67
+ </div>
68
+ )
69
+ }
@@ -24,6 +24,13 @@ import useDragResize from '../hooks/useDragResize.js'
24
24
  * and no `pages` (Home) renders as a plain link row — it has nothing to
25
25
  * disclose.
26
26
  *
27
+ * THE FOLDERNOTE (user 2026-10-24, site-hub: "make a prop so you can choose if
28
+ * you want to make the category a clickable page. this is how its set in
29
+ * kol-branding"): a category with `to` AND `pages` is a page of its own — its
30
+ * row is a link that opens the page and discloses the pages under it; the
31
+ * caret alone toggles the disclosure without navigating. Lit by its own route
32
+ * or any page beneath. No `to` = the disclosure button it always was.
33
+ *
27
34
  * The 2026-08-01 "TWO LEVELS ONLY" ruling was the BRAND APP's, about its
28
35
  * scroll-spied `#anchor` section layer — that layer stays dead (an `{ id }`
29
36
  * leaf is dropped). It was inscribed here as a law for every consumer, and
@@ -107,9 +114,12 @@ import useDragResize from '../hooks/useDragResize.js'
107
114
  * `themeToggle` `false` drops the theme slot (default `true`)
108
115
  * `iconComponent` the hop glyph's renderer, kol-shell's seam — `(props:
109
116
  * { name, size }) => element`; default the DS `Icon`
110
- * `expandOnSelect` `false` keeps the rail collapsed when a row navigates or
111
- * dispatches — an app rail stays a rail. Default `true`, the
112
- * brand ruling ("pressing any icon would expand the sidebar")
117
+ * `expandOnSelect` `true` expands the rail when a row navigates, dispatches
118
+ * or discloses from the collapsed state. Default `false`
119
+ * (user 2026-10-24: "dont auto expand rail when you click an
120
+ * icon when its collapsed" — reversing the 2026-08-09 brand
121
+ * ruling "pressing any icon would expand the sidebar"): a
122
+ * collapsed rail stays collapsed, the press does its job
113
123
  * `defaultCollapsed` boots collapsed when nothing is stored (useDragResize)
114
124
  * `background` (2026-08-09, prop): `true` (default) paints the rail surface;
115
125
  * `false` renders chromeless so the rail can float over a consumer's media
@@ -119,12 +129,13 @@ import useDragResize from '../hooks/useDragResize.js'
119
129
  */
120
130
 
121
131
  const pageBase =
122
- 'kol-sidenav-link kol-helper-10 block relative py-[4px] pl-14 pr-6 no-underline transition-colors duration-150'
132
+ 'kol-sidenav-link kol-helper-10 block relative py-[4px] pl-[calc(var(--kol-pad-chrome-x)+2rem)] pr-6 no-underline transition-colors duration-150'
123
133
 
124
134
  /* The active-dot pseudo-element is positioned by `--kol-sidenav-dot-left`
125
- * (kol-components-atoms.css). The page row indents 3.5rem (pl-14); the dot
126
- * sits 0.875rem inside that, in the gutter the icon column leaves. */
127
- const pageStyle = { '--kol-sidenav-dot-left': '2.625rem' }
135
+ * (kol-components-atoms.css). The page row indents one step past the chrome inset
136
+ * (`--kol-pad-chrome-x` + the icon column + the gap, 2026-10-24 — it was a literal
137
+ * 3.5rem); the dot sits 0.875rem inside that, in the gutter the icon column leaves. */
138
+ const pageStyle = { '--kol-sidenav-dot-left': 'calc(var(--kol-pad-chrome-x) + 1.125rem)' }
128
139
  /* Category and page must not share a stop: category `emphasis`, page `strong`
129
140
  * — two rungs of one ladder, so the tree reads as hierarchy (elder ruling). */
130
141
  const pageCls = `${pageBase} text-strong hover:text-emphasis`
@@ -140,7 +151,18 @@ const leavesOf = (rows) => rows.flatMap((r) => (r.children ? leavesOf(rowsOf(r.c
140
151
  /* A nested row sits one --kol-spacing-3 step further in per depth. Inline,
141
152
  * not a rule: `pl-14` rides the leaf as a utility and outranks anything in
142
153
  * this layer. Depth 0 carries no indent so a flat tree renders unchanged. */
143
- const indentOf = (depth) => `calc(3.5rem + ${depth} * var(--kol-spacing-3))`
154
+ const indentOf = (depth) => `calc(var(--kol-pad-chrome-x) + 2rem + ${depth} * var(--kol-spacing-3))`
155
+
156
+ /* the route leaf is always an `<a href>` handing the route to `onNavigate(event, to)` — the
157
+ * router lives in the consumer (kol-framework's `SideNav` wraps this with react-router). A
158
+ * modified click (cmd, ctrl, shift, middle) is left to the browser, as a NavLink left it.
159
+ * Hoisted out of the component so its identity is stable across renders (see `leafProps`). */
160
+ function RouteLeaf({ to, href, active, onNavigate, className, style, children, onPress }) {
161
+ return (
162
+ <a href={href} style={style} className={className(active)} aria-current={active ? 'page' : undefined}
163
+ onClick={(e) => { if (e.metaKey || e.ctrlKey || e.shiftKey || e.altKey || e.button !== 0) return; e.preventDefault(); onPress?.(); onNavigate(e, to) }}>{children}</a>
164
+ )
165
+ }
144
166
 
145
167
  export default function NavRailSite({
146
168
  currentPath: pathname = '',
@@ -164,7 +186,7 @@ export default function NavRailSite({
164
186
  footer,
165
187
  themeToggle = true,
166
188
  iconComponent,
167
- expandOnSelect = true,
189
+ expandOnSelect = false,
168
190
  defaultCollapsed = false,
169
191
  }) {
170
192
  const Glyph = iconComponent ?? Icon
@@ -190,16 +212,11 @@ export default function NavRailSite({
190
212
  setOpenPanel(null)
191
213
  if (collapsed && expandOnSelect) toggleCollapsed()
192
214
  }
193
- /* the route leaf is always an `<a href>` handing the route to `onNavigate(event, to)` — the
194
- * router lives in the consumer (kol-framework's `SideNav` wraps this with react-router). A
195
- * modified click (cmd, ctrl, shift, middle) is left to the browser, as a NavLink left it. */
196
- const RouteLeaf = ({ to, className, style, children }) => {
197
- const active = isPageActive(to)
198
- return (
199
- <a href={hrefFor ? hrefFor(to) : to} style={style} className={className(active)} aria-current={active ? 'page' : undefined}
200
- onClick={(e) => { if (e.metaKey || e.ctrlKey || e.shiftKey || e.altKey || e.button !== 0) return; e.preventDefault(); handleNavigate(e, to) }}>{children}</a>
201
- )
202
- }
215
+ /* what a route leaf needs from this render — `RouteLeaf` itself is hoisted above the component
216
+ * (2026-10-24): declared in here it was a NEW component type every render, so React threw every
217
+ * row's DOM away and rebuilt it on each toggle, disclosure or route — the rail flashed and lost
218
+ * hover and focus on the collapse. */
219
+ const leafProps = (to) => ({ to, href: hrefFor ? hrefFor(to) : to, active: isPageActive(to), onNavigate: handleNavigate })
203
220
 
204
221
  /* Which categories are disclosed. INDEPENDENT per category (elder ruling
205
222
  * 2026-08-01) — arriving somewhere must not silently close wherever you
@@ -249,11 +266,14 @@ export default function NavRailSite({
249
266
  * up the way a category does — when one of its leaves is the current route. */
250
267
  const renderRows = (rows, depth) => rows.map((row, i) => {
251
268
  if (row.children) {
252
- const lit = leavesOf(rowsOf(row.children)).some(isLeafActive)
253
269
  return (
254
270
  <li key={row.id ?? `${row.label}-${i}`}>
255
271
  <div
256
- className={`kol-sidenav-group kol-helper-10${lit ? ' text-emphasis' : ' text-subtle'}`}
272
+ /* UPPERCASE (user 2026-10-24, the another-creation reference: "look at uppercase sections") — the fork's
273
+ * `uppercase` utility returns, as the reference carries it; the group is a section label in the rows' voice.
274
+ * ONE INK (user 2026-10-24: "just keep them same opacity"): the label never lights — the row's dot says
275
+ * which row is active, and a label that brightened said it twice. */
276
+ className="kol-sidenav-group kol-helper-10 uppercase text-subtle"
257
277
  style={depth ? { paddingLeft: indentOf(depth) } : undefined}
258
278
  >
259
279
  {row.label}
@@ -263,7 +283,9 @@ export default function NavRailSite({
263
283
  )
264
284
  }
265
285
  /* the dot keeps its 0.875rem lead on the text at every depth */
266
- const leafStyle = depth ? { paddingLeft: indentOf(depth), '--kol-sidenav-dot-left': `calc(2.625rem + ${depth} * var(--kol-spacing-3))` } : pageStyle
286
+ /* a row under a group sits 2px further in than the step, dot and text together, so the dot's edge lines up under
287
+ * the group label's first letter (user 2026-10-24: "just indent the dot+text by 2px to right") */
288
+ const leafStyle = depth ? { paddingLeft: `calc(${indentOf(depth)} + 2px)`, '--kol-sidenav-dot-left': `calc(var(--kol-pad-chrome-x) + 1.125rem + 2px + ${depth} * var(--kol-spacing-3))` } : pageStyle
267
289
  if (row.onSelect) {
268
290
  return (
269
291
  <li key={row.id ?? `${row.label}-${i}`}>
@@ -281,7 +303,7 @@ export default function NavRailSite({
281
303
  }
282
304
  return (
283
305
  <li key={row.to}>
284
- <RouteLeaf to={row.to} style={leafStyle} className={(active) => (active ? pageActiveCls : pageCls)}>
306
+ <RouteLeaf {...leafProps(row.to)} style={leafStyle} className={(active) => (active ? pageActiveCls : pageCls)}>
285
307
  {row.label}
286
308
  </RouteLeaf>
287
309
  </li>
@@ -293,6 +315,8 @@ export default function NavRailSite({
293
315
  const pages = pagesOf(cat)
294
316
  const isOpen = openCats.has(cat.id)
295
317
  const isLink = !pages.length && cat.to
318
+ /* the FOLDERNOTE: a category that is a page of its own (`to` with `pages`) */
319
+ const isFolder = pages.length > 0 && !!cat.to
296
320
  const isPanel = !pages.length && !cat.to && !!cat.panel
297
321
  const isAction = !pages.length && !cat.to && !isPanel && cat.onSelect
298
322
  /* THE COLLAPSE RULE: no icon, no route, no action = a LABEL over
@@ -318,8 +342,28 @@ export default function NavRailSite({
318
342
  /* A category is a <button>, not a link — it has no route by
319
343
  definition, and an <a href> would promise a page that does
320
344
  not exist. Clicking it discloses its pages. */
321
- const head = isLink ? (
322
- <RouteLeaf to={cat.to} className={(active) => `${rowCls}${active ? ' is-active' : ''}`}>
345
+ const head = isFolder ? (
346
+ /* the row opens the page and discloses; the caret beside it (a sibling — a button cannot sit
347
+ * inside a link) toggles the disclosure alone */
348
+ <>
349
+ <RouteLeaf {...leafProps(cat.to)} onPress={() => discloseCat(cat.id)} className={(active) => `${rowCls}${(active || isActiveCat(cat)) ? ' is-active' : ''}`}>
350
+ {glyph}
351
+ <span className="kol-sidenav-hop-label flex-1 min-w-0">{cat.label}</span>
352
+ </RouteLeaf>
353
+ <button
354
+ type="button"
355
+ /* no display utility on the caret — it would outrank the collapsed rule's display:none (the 2026-08-09 defect; the
356
+ * box lives in .kol-sidenav-hop-caret, kol-framework.css) */
357
+ className={`kol-sidenav-hop-caret bg-transparent border-0 cursor-pointer p-0 text-emphasis${isOpen ? '' : ' -rotate-90'}`}
358
+ aria-expanded={isOpen}
359
+ aria-label={isOpen ? `Collapse ${cat.label}` : `Expand ${cat.label}`}
360
+ onClick={() => (collapsed ? (expandOnSelect && toggleCollapsed(), discloseCat(cat.id)) : toggleCat(cat.id))}
361
+ >
362
+ <Icon name="chevron-down" size={12} />
363
+ </button>
364
+ </>
365
+ ) : isLink ? (
366
+ <RouteLeaf {...leafProps(cat.to)} className={(active) => `${rowCls}${active ? ' is-active' : ''}`}>
323
367
  {glyph}
324
368
  <span className="kol-sidenav-hop-label flex-1 min-w-0">{cat.label}</span>
325
369
  </RouteLeaf>
@@ -354,7 +398,7 @@ export default function NavRailSite({
354
398
  * an expand that lands on a closed tree. */
355
399
  onClick={() => {
356
400
  if (collapsed) {
357
- toggleCollapsed()
401
+ if (expandOnSelect) toggleCollapsed()
358
402
  discloseCat(cat.id)
359
403
  } else {
360
404
  toggleCat(cat.id)
@@ -366,7 +410,7 @@ export default function NavRailSite({
366
410
  {/* plain wrapper span — Icon stamps inline-flex on its own
367
411
  * element, which would outrank the rail's display:none */}
368
412
  <span
369
- className={`kol-sidenav-hop-caret transition-transform duration-150${isOpen ? '' : ' -rotate-90'}`}
413
+ className={`kol-sidenav-hop-caret${isOpen ? '' : ' -rotate-90'}`}
370
414
  aria-hidden="true"
371
415
  >
372
416
  <Icon name="chevron-down" size={12} />
@@ -377,11 +421,12 @@ export default function NavRailSite({
377
421
  <li key={cat.id} className="relative">
378
422
  {/* Collapsed rail hides the label — the tooltip is the only
379
423
  thing naming the row. Portalled, so overflow can't clip it. */}
380
- {collapsed ? (
381
- <Tooltip label={cat.label} placement="right" triggerClassName="block">
382
- {head}
383
- </Tooltip>
384
- ) : head}
424
+ {/* ONE TREE IN BOTH STATES (2026-10-24, the clip model): the Tooltip wraps the row expanded too,
425
+ disabled — wrapping only when collapsed rebuilt every row on the toggle, losing hover and
426
+ focus and flashing the rail. Portalled, so overflow can't clip it. */}
427
+ <Tooltip label={cat.label} placement="right" triggerClassName="block" disabled={!collapsed}>
428
+ {head}
429
+ </Tooltip>
385
430
 
386
431
  {!isLink && !isAction && !isPanel && isOpen && (
387
432
  <ul className="kol-sidenav-list">{renderRows(pages, 0)}</ul>
@@ -420,8 +465,8 @@ export default function NavRailSite({
420
465
  </nav>
421
466
  </div>
422
467
 
423
- {/* hop-bare carries its own gutter padding; collapsed falls back to
424
- `icon` — a full-width label can't sit in the collapsed rail. */}
468
+ {/* the theme slot holds a TREE ROW (kol-framework's SideNav passes `ThemeToggle variant="row"`,
469
+ 2026-10-24): it wears .kol-sidenav-hop and follows the collapse as the rows do. */}
425
470
  <div className="pb-4">
426
471
  {/* the theme slot is the consumer's: kol-component cannot import kol-framework's
427
472
  * toggle, so `themeToggle` is a render function `({ collapsed }) => node` (kol-framework's