@kolkrabbi/kol-component 0.352.0 → 0.353.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.
|
|
3
|
+
"version": "0.353.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-growth": "^0.5.0",
|
|
36
35
|
"@kolkrabbi/kol-markdown": "^0.2.0",
|
|
37
|
-
"@kolkrabbi/kol-search": "^0.3.0"
|
|
36
|
+
"@kolkrabbi/kol-search": "^0.3.0",
|
|
37
|
+
"@kolkrabbi/kol-growth": "^0.5.0"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
40
|
"@kolkrabbi/kol-icons": ">=0.61.1",
|
|
@@ -146,6 +146,8 @@ import useScrollFade from '../hooks/useScrollFade.js'
|
|
|
146
146
|
* `icon` on any node at any depth (page, group label, action row, nested child), through `iconComponent`
|
|
147
147
|
* `iconSize` `{ category, group, page }` (defaults 16, 12, 12); a node's own `iconSize` wins
|
|
148
148
|
* `alignIcons` `true` (default): a level where any row has an icon reserves the icon column for all its rows
|
|
149
|
+
* `pageIcons` `'inline'` (default) — a page's glyph sits before its label (the column above) · `'gutter'` — it hangs
|
|
150
|
+
* in the gutter under the category glyph and the label stays where a plain page label sits
|
|
149
151
|
* `collapsedIcons` `'category'` (default) — the collapsed rail shows category glyphs only; `'all'` also shows the
|
|
150
152
|
* icon-bearing pages of an open category under it
|
|
151
153
|
* per node `trailing` (a count, badge or node, right-aligned), `className`, `title` (the tooltip when the
|
|
@@ -244,6 +246,7 @@ export default function NavRailSite({
|
|
|
244
246
|
casePage,
|
|
245
247
|
iconSize: iconSizes,
|
|
246
248
|
alignIcons = true,
|
|
249
|
+
pageIcons = 'inline',
|
|
247
250
|
collapsedIcons = 'category',
|
|
248
251
|
toggleRef,
|
|
249
252
|
}) {
|
|
@@ -352,12 +355,27 @@ export default function NavRailSite({
|
|
|
352
355
|
/* THE ICON COLUMN (NavRailRowProps): with `alignIcons`, a level where any row has an icon reserves the column for all
|
|
353
356
|
* its rows, as wide as its widest glyph; a level with no icon draws exactly as before */
|
|
354
357
|
const levelOf = (r) => (r.children ? 'group' : 'page')
|
|
355
|
-
|
|
358
|
+
/* `pageIcons="gutter"`: a page row's glyph hangs in the gutter under the category's glyph, so its label stays where a
|
|
359
|
+
* plain page label sits — no column, no shift (kol-kerner via kol-hq 2026-11-08: "app rail has it") */
|
|
360
|
+
const hangs = (r) => pageIcons === 'gutter' && !r.children
|
|
361
|
+
const iconW = rows.reduce((w, r) => (r.icon && !hangs(r) ? Math.max(w, sizeOf(r, levelOf(r))) : w), 0)
|
|
356
362
|
const aligned = alignIcons && iconW > 0
|
|
357
363
|
/* a row with an icon, a reserved column or a tail lays out as glyph · label · tail; its case rides the label span
|
|
358
364
|
* (a flex item, so `::first-letter` applies). A plain row keeps its text bare and the case rides the row. */
|
|
359
365
|
const body = (row, cc) => {
|
|
360
366
|
const tail = tailOf(row)
|
|
367
|
+
if (hangs(row) && row.icon) {
|
|
368
|
+
const size = sizeOf(row, 'page')
|
|
369
|
+
const glyph = (
|
|
370
|
+
/* centred under the category glyph's 16px column, left of the active dot */
|
|
371
|
+
<span className="kol-sidenav-hop-icon absolute top-1/2 -translate-y-1/2 inline-flex items-center justify-center" style={{ left: `calc(var(--kol-sidenav-pad-x) + ${depth} * var(--kol-spacing-3))`, width: 16 }} aria-hidden="true">
|
|
372
|
+
<Glyph name={row.icon} size={size} />
|
|
373
|
+
</span>
|
|
374
|
+
)
|
|
375
|
+
return tail
|
|
376
|
+
? { rowCase: '', content: <>{glyph}<span className="flex items-center gap-2 min-w-0"><span className={withCls('flex-1 min-w-0 truncate', cc)}>{row.label}</span>{tail}</span></> }
|
|
377
|
+
: { rowCase: cc, content: <>{glyph}{row.label}</> }
|
|
378
|
+
}
|
|
361
379
|
if (!row.icon && !aligned && !tail) return { rowCase: cc, content: row.label }
|
|
362
380
|
const size = sizeOf(row, levelOf(row))
|
|
363
381
|
return {
|