@kolkrabbi/kol-shell 0.72.0 → 0.74.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 +6 -6
- package/src/AppShell.jsx +1 -1
- package/src/CatalogPage.jsx +6 -1
- package/src/index.js +3 -3
- package/src/Logomark.jsx +0 -67
- package/src/NavRail.jsx +0 -399
- package/src/railSlot.jsx +0 -28
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kolkrabbi/kol-shell",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.74.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The application shell",
|
|
6
6
|
"license": "MIT",
|
|
@@ -12,18 +12,18 @@
|
|
|
12
12
|
"./src/*": "./src/*"
|
|
13
13
|
},
|
|
14
14
|
"peerDependencies": {
|
|
15
|
-
"@kolkrabbi/kol-component": ">=0.
|
|
15
|
+
"@kolkrabbi/kol-component": ">=0.283.0",
|
|
16
16
|
"@kolkrabbi/kol-icons": ">=0.16.0",
|
|
17
|
-
"@kolkrabbi/kol-theme": ">=0.
|
|
17
|
+
"@kolkrabbi/kol-theme": ">=0.179.0",
|
|
18
18
|
"gsap": "^3.13.0",
|
|
19
19
|
"react": "^18.3.0 || ^19.0.0",
|
|
20
20
|
"react-dom": "^18.3.0 || ^19.0.0"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
+
"@kolkrabbi/kol-component": "^0.287.0",
|
|
23
24
|
"@kolkrabbi/kol-icons": "^0.41.0",
|
|
24
|
-
"@kolkrabbi/kol-
|
|
25
|
-
"@kolkrabbi/kol-
|
|
26
|
-
"@kolkrabbi/kol-theme": "^0.176.0"
|
|
25
|
+
"@kolkrabbi/kol-framework": "^0.53.0",
|
|
26
|
+
"@kolkrabbi/kol-theme": "^0.183.0"
|
|
27
27
|
},
|
|
28
28
|
"files": [
|
|
29
29
|
"src",
|
package/src/AppShell.jsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useCallback, useEffect, useRef, useState } from 'react'
|
|
2
2
|
import { Button } from '@kolkrabbi/kol-component'
|
|
3
|
-
import NavRail from '
|
|
3
|
+
import { NavRail } from '@kolkrabbi/kol-component'
|
|
4
4
|
import { NavHiddenContext } from './navHidden.js'
|
|
5
5
|
import { SettingsToggleContext } from './settingsToggle.js'
|
|
6
6
|
import TouchDeviceOverlay, { useTouchPrimary } from './TouchDeviceOverlay.jsx'
|
package/src/CatalogPage.jsx
CHANGED
|
@@ -64,6 +64,7 @@ import WalkthroughPanel from './WalkthroughPanel.jsx'
|
|
|
64
64
|
* @param {string} cardVariant the grid card's variant, per page (default `catalog`); `toCard` may return `variant` per card
|
|
65
65
|
* @param {'catalog'|'file'} rowVariant the list row (default `catalog`, the 36px no-thumb row); `file` = the 48px thumb row, for a catalog whose grid shows a cover —
|
|
66
66
|
* its slots (`date` · `size` · `meta` · `selected`) come from `toCard` like everything else
|
|
67
|
+
* @param {number} listColumns the list grid's column ceiling (default 3 for a file or slide row, else 4); tracks never go under 240
|
|
67
68
|
* @param {'grid'|'stack'} listLayout the list's container (default `grid`, rows four across — monitor's ruling); `stack` = one row per line
|
|
68
69
|
* @param {ElementType} iconComponent icon renderer seam for ContentFilters
|
|
69
70
|
* @param {boolean} showCountOnlyWhenFiltering (default true)
|
|
@@ -174,6 +175,10 @@ export default function CatalogPage({
|
|
|
174
175
|
line, which is what a list of files is (MediaLibrary stacks); olina's deck list
|
|
175
176
|
rendered three 300px rows side by side (user: "why is it tiny?"). */
|
|
176
177
|
listLayout = PRESETS[preset]?.listLayout ?? 'grid',
|
|
178
|
+
/* the LIST grid's column ceiling (2026-10-22 — user: *"are you passing props on number of items/columns?"*). It was
|
|
179
|
+
a hard 4 — monitor's ruling for the 36px catalog row. A file or slide row is a contained tile with a 72 thumb, so
|
|
180
|
+
it defaults to 3 (user: *"change this one to 3"*). Tracks still never go under 240. */
|
|
181
|
+
listColumns = rowVariant === 'file' || rowVariant === 'slide' ? 3 : 4,
|
|
177
182
|
iconComponent,
|
|
178
183
|
showCountOnlyWhenFiltering = true,
|
|
179
184
|
filtersProps,
|
|
@@ -246,7 +251,7 @@ export default function CatalogPage({
|
|
|
246
251
|
/* the catalog grid is a CLASS (`.kol-catalog-grid`, kol-theme ≥0.138.0) reading
|
|
247
252
|
* `--kol-catalog-n`, the count measured above and set on PageShell — the same
|
|
248
253
|
* number the filter row's first group reads */
|
|
249
|
-
<div ref={layout === 'list' ? undefined : gridRef} className={layout === 'list' ? undefined : 'kol-catalog-grid'} style={layout === 'list' ? (listLayout === 'stack' ? { display: 'flex', flexDirection: 'column', gap: 8 } : { display: 'grid', gridTemplateColumns:
|
|
254
|
+
<div ref={layout === 'list' ? undefined : gridRef} className={layout === 'list' ? undefined : 'kol-catalog-grid'} style={layout === 'list' ? (listLayout === 'stack' ? { display: 'flex', flexDirection: 'column', gap: 8 } : { display: 'grid', gridTemplateColumns: `repeat(auto-fill, minmax(min(100%, max(240px, calc((100% - ${listColumns - 1} * 8px) / ${listColumns}))), 1fr))`, gap: 8 }) : undefined}>
|
|
250
255
|
{rows.map((item, i) => {
|
|
251
256
|
if (hidden.has(i)) return null
|
|
252
257
|
const c = cards[i]
|
package/src/index.js
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
export { default as AppShell } from './AppShell.jsx'
|
|
14
14
|
export { NavHiddenContext, useNavHidden } from './navHidden.js'
|
|
15
15
|
export { SettingsToggleContext, useSettingsToggle } from './settingsToggle.js'
|
|
16
|
-
export {
|
|
16
|
+
export { NavRail } from '@kolkrabbi/kol-component' // lives in kol-component since 2026-10-22
|
|
17
17
|
export { default as PhoneNav } from './PhoneNav.jsx'
|
|
18
18
|
export { default as PageShell, PageBleed } from './PageShell.jsx'
|
|
19
19
|
/* PageHeader MOVED to @kolkrabbi/kol-component 2026-09-03 (page-header-one-masthead).
|
|
@@ -27,7 +27,7 @@ export { default as SettingsScaffold } from './SettingsScaffold.jsx'
|
|
|
27
27
|
export { default as WalkthroughPanel } from './WalkthroughPanel.jsx'
|
|
28
28
|
/* lives in kol-component since 0.228.0 — re-exported so every kol-shell import keeps resolving */
|
|
29
29
|
export { ShortcutsOverlay, shortcutInScope } from '@kolkrabbi/kol-component'
|
|
30
|
-
export {
|
|
30
|
+
export { Logomark } from '@kolkrabbi/kol-component'
|
|
31
31
|
// the app tier, shipped once (ShellHomeSystem, kol-fxr 2026-08-27)
|
|
32
32
|
export { default as CatalogPage } from './CatalogPage.jsx'
|
|
33
33
|
export { default as SettingsShortcuts } from './SettingsShortcuts.jsx'
|
|
@@ -41,4 +41,4 @@ export { default as HubDev } from './HubDev.jsx'
|
|
|
41
41
|
// the Studio — the Hub + Home · Library · Create · Use · pages · Settings, the workstation (apps review §6c, 2026-09-29)
|
|
42
42
|
export { default as AppStudio } from './AppStudio.jsx'
|
|
43
43
|
// a consumer slot in the opened rail — the page portals into it (NavRailConsumerSlot, kol-monitor 2026-10-15)
|
|
44
|
-
export { RailSlotProvider, useRailSlot } from '
|
|
44
|
+
export { RailSlotProvider, useRailSlot } from '@kolkrabbi/kol-component'
|
package/src/Logomark.jsx
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { useState, useEffect } from 'react'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Logomark — An inlined SVG mark. fetches and INLINES an SVG so currentColor theming works: an
|
|
5
|
-
* <img> renders a currentColor mark black in dark mode (invisible). Ported
|
|
6
|
-
* verbatim from the kol-mirror cut (module-level cache; async resolve even on
|
|
7
|
-
* cache hit — sync setState in an effect cascades renders).
|
|
8
|
-
*
|
|
9
|
-
* The fetched markup is SANITIZED before injection — `<style>`/`<script>`
|
|
10
|
-
* stripped, `on*` attributes dropped (LogomarkInlineStyleLeak, kol-chess
|
|
11
|
-
* 2026-09-01). An SVG *document* may legitimately carry its own `<style>` — a
|
|
12
|
-
* theme-aware favicon does — but once inlined, that `<style>` is
|
|
13
|
-
* DOCUMENT-GLOBAL: kol-chess pointed `svgUrl` at its favicon and every <svg>
|
|
14
|
-
* in the app took OS-keyed ink and ignored `data-theme`, presenting two
|
|
15
|
-
* packages away as "the theme toggle is broken". A mark that needs its own
|
|
16
|
-
* styling inlines it as attributes, not a stylesheet.
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
const svgCache = new Map()
|
|
20
|
-
|
|
21
|
-
/* strip what must never escape into the host document: stylesheets (global
|
|
22
|
-
* once inlined), scripts and event handlers (this is a fetch → innerHTML
|
|
23
|
-
* boundary). DOMParser is the correct tool; the regex fallback only runs if
|
|
24
|
-
* the markup does not even parse as SVG. */
|
|
25
|
-
function sanitizeSvg(svg) {
|
|
26
|
-
try {
|
|
27
|
-
const doc = new DOMParser().parseFromString(svg, 'image/svg+xml')
|
|
28
|
-
if (doc.querySelector('parsererror')) throw new Error('unparseable')
|
|
29
|
-
doc.querySelectorAll('style, script').forEach((el) => el.remove())
|
|
30
|
-
doc.querySelectorAll('*').forEach((el) => {
|
|
31
|
-
for (const a of [...el.attributes]) if (/^on/i.test(a.name)) el.removeAttribute(a.name)
|
|
32
|
-
})
|
|
33
|
-
return new XMLSerializer().serializeToString(doc)
|
|
34
|
-
} catch {
|
|
35
|
-
return svg
|
|
36
|
-
.replace(/<(style|script)[\s\S]*?<\/\1\s*>/gi, '')
|
|
37
|
-
.replace(/\son[a-z]+\s*=\s*("[^"]*"|'[^']*')/gi, '')
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export default function Logomark({ svgUrl, size = 20, className = '', ...props }) {
|
|
42
|
-
const [svgContent, setSvgContent] = useState(() => svgCache.get(svgUrl) || null)
|
|
43
|
-
|
|
44
|
-
useEffect(() => {
|
|
45
|
-
if (!svgUrl) return
|
|
46
|
-
let active = true
|
|
47
|
-
Promise.resolve(
|
|
48
|
-
svgCache.get(svgUrl) ?? fetch(svgUrl).then(res => res.text()).then(raw => { const svg = sanitizeSvg(raw); svgCache.set(svgUrl, svg); return svg })
|
|
49
|
-
)
|
|
50
|
-
.then(svg => { if (active) setSvgContent(svg) })
|
|
51
|
-
.catch(() => {})
|
|
52
|
-
return () => { active = false }
|
|
53
|
-
}, [svgUrl])
|
|
54
|
-
|
|
55
|
-
if (!svgContent) return <span style={{ width: size, height: size, display: 'inline-block' }} />
|
|
56
|
-
|
|
57
|
-
return (
|
|
58
|
-
<span
|
|
59
|
-
className={className}
|
|
60
|
-
style={{ width: size, height: size, display: 'inline-flex', color: 'currentColor' }}
|
|
61
|
-
dangerouslySetInnerHTML={{
|
|
62
|
-
__html: svgContent.replace('<svg', `<svg width="${size}" height="${size}"`),
|
|
63
|
-
}}
|
|
64
|
-
{...props}
|
|
65
|
-
/>
|
|
66
|
-
)
|
|
67
|
-
}
|
package/src/NavRail.jsx
DELETED
|
@@ -1,399 +0,0 @@
|
|
|
1
|
-
import { useEffect, useRef, useState } from 'react'
|
|
2
|
-
import gsap from 'gsap'
|
|
3
|
-
import { Button, Tooltip } from '@kolkrabbi/kol-component'
|
|
4
|
-
import { GRAB } from '@kolkrabbi/kol-component/utilities/motion'
|
|
5
|
-
/* the grab pill's proximity wake, travel and dwell — ONE implementation, shared
|
|
6
|
-
* with kol-framework's useDragResize (OneGrabGestureBothRails, kol-fxr
|
|
7
|
-
* 2026-08-30: two rails on one screen felt different because each package had
|
|
8
|
-
* built the gesture itself). It lived here until then. */
|
|
9
|
-
import { useGrabEdge } from '@kolkrabbi/kol-component'
|
|
10
|
-
import { Icon } from '@kolkrabbi/kol-icons'
|
|
11
|
-
import Logomark from './Logomark.jsx'
|
|
12
|
-
import { useRailSlot } from './railSlot.jsx'
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* NavRail — the flat rail. ONE fixed column, every child a direct child of it
|
|
16
|
-
* (RailFlatGrabOpen, kol-mirror 2026-08-28 — user, on the monitor rail he
|
|
17
|
-
* measured it against: "the div structure is super simple ok … it's 1 div
|
|
18
|
-
* parent and everything is just in that container", and on the SideNav-backed
|
|
19
|
-
* rail that had replaced it: it was "impossible" to get this shape out of it).
|
|
20
|
-
*
|
|
21
|
-
* This REVERSES RailSideNavPixelParity (0.13.0), which made the rail a collapsed
|
|
22
|
-
* kol-framework `SideNav`. That ticket's pixel argument is settled the other way:
|
|
23
|
-
* the rail does not share pixels with the brand sidebar because it never becomes
|
|
24
|
-
* one. `RailLogomarkAtTop` stands — the mark is at the top in both states.
|
|
25
|
-
*
|
|
26
|
-
* THE GRAB OPENS IT (user: "when you grab it should not move the icons one
|
|
27
|
-
* pixel, only reveal the title, and a chevron to see sub categories" · "when it
|
|
28
|
-
* opens it should push the main content inside"). Closed, every row is the rail
|
|
29
|
-
* minus its gutter — the 32px rung alone shows and the label and chevron exist
|
|
30
|
-
* but are clipped by the row's own width. Open, the clip reveals them. Nothing
|
|
31
|
-
* in the icon column moves between the two states, and the content column
|
|
32
|
-
* follows because AppShell offsets by the same live variable.
|
|
33
|
-
*
|
|
34
|
-
* ONE WIDTH VARIABLE: `--kol-shell-rail-width` on `:root` — this rail is that
|
|
35
|
-
* wide and AppShell's content is offset by it, written per pointermove during a
|
|
36
|
-
* drag and tweened on release, so the page is pushed live through both. A drag
|
|
37
|
-
* writes the DOM, not React state: a pointermove per frame is not a render.
|
|
38
|
-
*
|
|
39
|
-
* The pill is kol-r2b2's, verbatim (user: "make it like it is in kol-r2b2, it
|
|
40
|
-
* has animation and gsap") — `.kol-rail-grab` in kol-theme's kol-animation.css,
|
|
41
|
-
* its pointer numbers in kol-component's `utilities/motion` (`GRAB`).
|
|
42
|
-
*
|
|
43
|
-
* TWO LEVELS (RailTwoLevelSections, kol-fxr 2026-08-28 — user: "the NAV has 20px
|
|
44
|
-
* icons in 32px containers, maybe level below has 12px icons in 20px container
|
|
45
|
-
* aligned to right? … you expand you see that they have main 56 items each, which
|
|
46
|
-
* you won't be aware of until you actually open labs, which should not happen
|
|
47
|
-
* automatically"). An item with `sub` is a SECTION: the same L1 row, plus a caret.
|
|
48
|
-
* Its rows are L2 — a 12px glyph in a 20px box, indented so its glyph column sits
|
|
49
|
-
* to the RIGHT of L1's (glyph x 14 → 30), resting a rung quieter at `oq-64` and
|
|
50
|
-
* going `oq-96` when it is the route. fxr's labs chrome is ~44 rows across four
|
|
51
|
-
* method sections; on one level they flatten into an icon column built for five
|
|
52
|
-
* destinations and the section names have nowhere to render at all.
|
|
53
|
-
*
|
|
54
|
-
* L2 is NOT a `Button`: the icon-button ladder is 22/26/32/40 (2026-09-03) and this
|
|
55
|
-
* rung is 20 — there is nothing below sm, and adding one is a change to that
|
|
56
|
-
* ladder's law, which is the user's call and not this ticket's. The row is
|
|
57
|
-
* written directly and keys `aria-current`, so kol-theme's
|
|
58
|
-
* `.kol-shell-rail .kol-btn-nav` active rules still reach it. A sub row with no
|
|
59
|
-
* `icon` renders label-only, as it did before this level existed.
|
|
60
|
-
*
|
|
61
|
-
* NOTHING AUTO-EXPANDS. An L2 row is behind BOTH the rail's clipped width and its
|
|
62
|
-
* section's own disclosure, and `open` starts `false` with no prop to get it
|
|
63
|
-
* wrong — arriving on a route reveals nothing, by construction rather than by a
|
|
64
|
-
* flag a consumer has to remember.
|
|
65
|
-
*
|
|
66
|
-
* @param {Array} items `{ icon, path, label, sub?: [{ icon?, path, label }] }`
|
|
67
|
-
* @param {Array} bottomItems pinned below the rule (Settings)
|
|
68
|
-
* @param {Object} logomark `{ svgUrl, title }` — the mark, and the app name beside it when open
|
|
69
|
-
* @param {string} currentPath active match: '/' exact, else prefix → aria-current="page"
|
|
70
|
-
* @param {Function} onNavigate `(path) => void` — every click, the mark included
|
|
71
|
-
* @param {boolean} drawer off-canvas mode: no grab, no drag, no token writes, rows always
|
|
72
|
-
* labelled, and the rail sizes itself from `--kol-shell-drawer-width` (default 240px).
|
|
73
|
-
* AppShell sets this from `touch="drawer"` — see ShellRailNoDrawerOnMobile, 2026-08-31.
|
|
74
|
-
* Under a `RailSlotProvider` the opened width also carries a CONSUMER SLOT below the rows
|
|
75
|
-
* (NavRailConsumerSlot, kol-monitor 2026-10-15) — content that is not a row list (monitor's module
|
|
76
|
-
* catalog: rows that insert, not paths). Always mounted so portalled content keeps its state across
|
|
77
|
-
* open/close; zero tall and clipped while closed. No provider → no slot, the render unchanged.
|
|
78
|
-
*
|
|
79
|
-
* @param {boolean} [fade=true] the list fades out at its foot — the workshop rail's fade
|
|
80
|
-
* (2026-10-01), here too on the user's word (2026-10-02). The rows sit in their own scroll
|
|
81
|
-
* region between the mark and the pinned bottom rows, so a list longer than the window scrolls
|
|
82
|
-
* and runs out under the fade instead of being cut by the edge. `false` draws the list plain.
|
|
83
|
-
*/
|
|
84
|
-
const RAIL_W = '--kol-shell-rail-width'
|
|
85
|
-
const CLOSED = 48
|
|
86
|
-
|
|
87
|
-
/* the OPEN width is the sidenav's ladder (kol-framework: 264, 320 from 1536),
|
|
88
|
-
* read at drag time so the rail lands on whichever rung the window is on */
|
|
89
|
-
const openWidth = () => {
|
|
90
|
-
const v = getComputedStyle(document.documentElement).getPropertyValue('--kol-sidenav-w').trim()
|
|
91
|
-
const px = parseFloat(v)
|
|
92
|
-
return Number.isFinite(px) ? (v.endsWith('rem') ? px * 16 : px) : 264
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/* THE GRAB EDGE — proximity, not contact: the pill wakes within `GRAB.near` of
|
|
96
|
-
* the line and sleeps only past `GRAB.sleep` (hovering the line itself flapped
|
|
97
|
-
* the class every frame and restarted the fade). Along the line it DWELLS (user
|
|
98
|
-
* ruling 2026-08-28: "make it come to the cursor but have some sticky time where
|
|
99
|
-
* it lands, so it's not constantly jerking"): it targets the pointer's own
|
|
100
|
-
* position and re-targets only once the pointer is `GRAB.stick` px away, so it
|
|
101
|
-
* lands on you, holds while you move inside the radius, then travels to where you
|
|
102
|
-
* are now — inside `GRAB.range`, the middle band of the edge, so it never rides
|
|
103
|
-
* up beside the logomark. One window listener, rAF-throttled. */
|
|
104
|
-
|
|
105
|
-
/* THE DRAG — hold the pill and the width follows the pointer between closed and
|
|
106
|
-
* open; release snaps to the nearer state, a click (no travel past GRAB.slop)
|
|
107
|
-
* toggles. `onSnap` reports the resting state once — the sub rows render only
|
|
108
|
-
* while open, because closed they would still take their height and push the
|
|
109
|
-
* rungs below them. */
|
|
110
|
-
function useRailDrag(railRef, grabRef, onSnap, snapRef, enabled = true) {
|
|
111
|
-
useEffect(() => {
|
|
112
|
-
const strip = grabRef.current, rail = railRef.current, root = document.documentElement
|
|
113
|
-
/* A DRAWER IS NOT A DRAGGABLE RAIL (ShellRailNoDrawerOnMobile, kol-chess
|
|
114
|
-
* 2026-08-31). In drawer mode the rail is off-canvas at a fixed width and
|
|
115
|
-
* the content owns the whole viewport, so the drag must not run at all —
|
|
116
|
-
* it writes `--kol-shell-rail-width` on `:root` per pointermove, which is
|
|
117
|
-
* exactly the inline token a consumer could not reach without `!important`. */
|
|
118
|
-
if (!enabled) return undefined
|
|
119
|
-
if (!strip || !rail) return undefined
|
|
120
|
-
gsap.set(root, { [RAIL_W]: `${CLOSED}px` })
|
|
121
|
-
let drag = null
|
|
122
|
-
const snapTo = (w) => {
|
|
123
|
-
gsap.to(root, { [RAIL_W]: `${w}px`, ...GRAB.snap, overwrite: 'auto' })
|
|
124
|
-
onSnap(w !== CLOSED)
|
|
125
|
-
}
|
|
126
|
-
/* the ONLY way out of this effect (RailSectionPressOpensRail, kol-fxr
|
|
127
|
-
* 2026-08-30). `snapTo` closes over the animation and the CLOSED/open
|
|
128
|
-
* ladder, so a section press has to reach it rather than reimplement it —
|
|
129
|
-
* a consumer setting `--kol-shell-rail-width` from outside widens the rail
|
|
130
|
-
* but leaves `railOpen` false, and the L2 rows render behind it: a wide,
|
|
131
|
-
* EMPTY rail, worse than the dead press this fixes. */
|
|
132
|
-
/* `(false)` closes, anything else opens — the same seam the L2 rows use
|
|
133
|
-
* to open, now also the tap opener's toggle */
|
|
134
|
-
if (snapRef) snapRef.current = (open = true) => snapTo(open === false ? CLOSED : openWidth())
|
|
135
|
-
const onDown = (e) => {
|
|
136
|
-
strip.setPointerCapture(e.pointerId)
|
|
137
|
-
gsap.killTweensOf(root)
|
|
138
|
-
drag = { x: e.clientX, w: rail.offsetWidth, open: openWidth(), moved: false }
|
|
139
|
-
strip.classList.add('is-dragging')
|
|
140
|
-
}
|
|
141
|
-
const onMove = (e) => {
|
|
142
|
-
if (!drag) return
|
|
143
|
-
const dx = e.clientX - drag.x
|
|
144
|
-
if (Math.abs(dx) > GRAB.slop) drag.moved = true
|
|
145
|
-
root.style.setProperty(RAIL_W, `${Math.min(Math.max(drag.w + dx, CLOSED), drag.open)}px`)
|
|
146
|
-
}
|
|
147
|
-
const onUp = () => {
|
|
148
|
-
if (!drag) return
|
|
149
|
-
const w = rail.offsetWidth
|
|
150
|
-
const open = drag.open
|
|
151
|
-
snapTo(drag.moved ? (w > (CLOSED + open) / 2 ? open : CLOSED) : (drag.w > CLOSED ? CLOSED : open))
|
|
152
|
-
drag = null
|
|
153
|
-
strip.classList.remove('is-dragging')
|
|
154
|
-
}
|
|
155
|
-
strip.addEventListener('pointerdown', onDown)
|
|
156
|
-
strip.addEventListener('pointermove', onMove)
|
|
157
|
-
strip.addEventListener('pointerup', onUp)
|
|
158
|
-
strip.addEventListener('pointercancel', onUp)
|
|
159
|
-
return () => {
|
|
160
|
-
strip.removeEventListener('pointerdown', onDown)
|
|
161
|
-
strip.removeEventListener('pointermove', onMove)
|
|
162
|
-
strip.removeEventListener('pointerup', onUp)
|
|
163
|
-
strip.removeEventListener('pointercancel', onUp)
|
|
164
|
-
}
|
|
165
|
-
}, [railRef, grabRef, onSnap, snapRef])
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
/* one row: the rung exactly where the closed rail had it, then the label and
|
|
169
|
-
* (with `sub`) the chevron — the row clips to the rail's width */
|
|
170
|
-
/* the L2 glyph goes through the same injection seam Button gives L1 */
|
|
171
|
-
function IconAt({ name, size, component }) {
|
|
172
|
-
const Cmp = component || Icon
|
|
173
|
-
return <Cmp name={name} size={size} />
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
function RailItem({ icon, path, label, sub, currentPath, onNavigate, iconComponent, railOpen, onOpenRail, onEnter }) {
|
|
177
|
-
const [open, setOpen] = useState(false)
|
|
178
|
-
/* A SECTION ROW IS NOT A DESTINATION (RailSectionPressOpensRail, kol-fxr
|
|
179
|
-
* 2026-08-30 — user: *"if I press effects from collapsed nav it should maybe
|
|
180
|
-
* open? currently pressing it does nothing"*).
|
|
181
|
-
*
|
|
182
|
-
* Closed, the row clips to 48px and the disclosure caret sits OUTSIDE that
|
|
183
|
-
* clip, so the only reachable control was the icon — which called
|
|
184
|
-
* `onNavigate` with a path no consumer dispatches, because a section has no
|
|
185
|
-
* action. A guaranteed dead press, in the rail's default state.
|
|
186
|
-
*
|
|
187
|
-
* Pressing it now opens the rail and expands that section. This is the
|
|
188
|
-
* behaviour `SideNav` had before the flat-rail reversal. It does not fight
|
|
189
|
-
* "nothing auto-expands" — that rule is about ARRIVING on a route; this is an
|
|
190
|
-
* explicit press. */
|
|
191
|
-
const isSection = sub?.length > 0
|
|
192
|
-
/* …AND IN AN OPEN RAIL THE SAME PRESS FOLDS AND UNFOLDS IT (2026-10-05, labs on a phone). Open,
|
|
193
|
-
* it still fell through to `onNavigate` with that path no consumer dispatches: dead at a desk,
|
|
194
|
-
* and worse on a touch drawer, where AppShell closes the drawer on every navigate — pressing a
|
|
195
|
-
* section's name shut the nav and loaded nothing. */
|
|
196
|
-
const press = () => {
|
|
197
|
-
if (isSection && onEnter) { if (!railOpen) onOpenRail?.(); onEnter(); return }
|
|
198
|
-
if (isSection) { if (!railOpen) onOpenRail?.(); setOpen((v) => !railOpen || !v); return }
|
|
199
|
-
onNavigate?.(path)
|
|
200
|
-
}
|
|
201
|
-
const active = path === '/' ? currentPath === '/' : currentPath.startsWith(path)
|
|
202
|
-
return (
|
|
203
|
-
<>
|
|
204
|
-
<div className="flex items-center gap-3 w-full overflow-hidden shrink-0">
|
|
205
|
-
{/* the DS tooltip, not the browser's (the native-title sweep, 2026-09-26) — to the RIGHT,
|
|
206
|
-
* out over the page, since the collapsed rail's glyph is all there is to read */}
|
|
207
|
-
<Tooltip label={label} placement="right" triggerClassName="inline-flex shrink-0">
|
|
208
|
-
<Button
|
|
209
|
-
iconOnly={icon}
|
|
210
|
-
iconSize={20}
|
|
211
|
-
iconComponent={iconComponent}
|
|
212
|
-
variant="nav"
|
|
213
|
-
size="md"
|
|
214
|
-
className="shrink-0"
|
|
215
|
-
/* nav ACTIVE keys off aria-current="page" (kol-components-atoms.css) —
|
|
216
|
-
* a brighter glyph, never the pressed fill */
|
|
217
|
-
aria-current={active ? 'page' : undefined}
|
|
218
|
-
/* oq-96 on every rung: the nav variant's oq-64 rest is site-nav quiet
|
|
219
|
-
* and too dim on an icon rail (user: "make the color .96 on every icon
|
|
220
|
-
* in the rail") */
|
|
221
|
-
style={{ color: 'var(--kol-oq-96)' }}
|
|
222
|
-
onClick={press}
|
|
223
|
-
aria-label={label}
|
|
224
|
-
/>
|
|
225
|
-
</Tooltip>
|
|
226
|
-
<span
|
|
227
|
-
className="kol-helper-12 uppercase text-oq-96 flex-1 min-w-0 truncate cursor-pointer"
|
|
228
|
-
onClick={press}
|
|
229
|
-
>
|
|
230
|
-
{label}
|
|
231
|
-
</span>
|
|
232
|
-
{sub?.length > 0 && (
|
|
233
|
-
<Tooltip label={label} placement="right" triggerClassName="inline-flex shrink-0">
|
|
234
|
-
<Button
|
|
235
|
-
iconOnly={onEnter ? 'chevron-right' : open ? 'chevron-down' : 'chevron-right'}
|
|
236
|
-
iconSize={16}
|
|
237
|
-
iconComponent={iconComponent}
|
|
238
|
-
variant="nav"
|
|
239
|
-
/* md, the row's rung — at sm it stood 26 beside the 32 glyph button (render gate R1,
|
|
240
|
-
* one row one size, found on apps/editor's labs rail 2026-09-29) */
|
|
241
|
-
size="md"
|
|
242
|
-
className="shrink-0"
|
|
243
|
-
style={{ color: 'var(--kol-oq-96)' }}
|
|
244
|
-
aria-expanded={onEnter ? undefined : open}
|
|
245
|
-
onClick={onEnter ? press : () => setOpen((v) => !v)}
|
|
246
|
-
aria-label={`${label} sub categories`}
|
|
247
|
-
/>
|
|
248
|
-
</Tooltip>
|
|
249
|
-
)}
|
|
250
|
-
</div>
|
|
251
|
-
{railOpen && open && !onEnter && sub.map((s) => {
|
|
252
|
-
const on = s.path === '/' ? currentPath === '/' : currentPath.startsWith(s.path)
|
|
253
|
-
return (
|
|
254
|
-
<Tooltip key={s.path} label={s.label} placement="right" asChild>
|
|
255
|
-
<div
|
|
256
|
-
/* 18px of gutter puts the 20px box at x 26, so its 12px glyph starts
|
|
257
|
-
* at 30 — one step right of L1's 20-in-32 at 14 (measured in fxr) */
|
|
258
|
-
className="flex items-center gap-3 w-full overflow-hidden shrink-0 cursor-pointer"
|
|
259
|
-
style={{ paddingLeft: 18 }}
|
|
260
|
-
onClick={() => onNavigate?.(s.path)}
|
|
261
|
-
aria-current={on ? 'page' : undefined}
|
|
262
|
-
>
|
|
263
|
-
{s.icon && (
|
|
264
|
-
<span
|
|
265
|
-
className="w-5 h-5 shrink-0 inline-flex items-center justify-center"
|
|
266
|
-
style={{ color: on ? 'var(--kol-oq-96)' : 'var(--kol-oq-64)' }}
|
|
267
|
-
aria-hidden="true"
|
|
268
|
-
>
|
|
269
|
-
<IconAt name={s.icon} size={12} component={iconComponent} />
|
|
270
|
-
</span>
|
|
271
|
-
)}
|
|
272
|
-
<span
|
|
273
|
-
className="kol-helper-12 uppercase flex-1 min-w-0 truncate"
|
|
274
|
-
style={{ color: on ? 'var(--kol-oq-96)' : 'var(--kol-oq-64)' }}
|
|
275
|
-
>
|
|
276
|
-
{s.label}
|
|
277
|
-
</span>
|
|
278
|
-
</div>
|
|
279
|
-
</Tooltip>
|
|
280
|
-
)
|
|
281
|
-
})}
|
|
282
|
-
</>
|
|
283
|
-
)
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
export default function NavRail({
|
|
287
|
-
items = [],
|
|
288
|
-
bottomItems = [],
|
|
289
|
-
logomark,
|
|
290
|
-
currentPath = '',
|
|
291
|
-
onNavigate,
|
|
292
|
-
iconComponent,
|
|
293
|
-
hidden = false,
|
|
294
|
-
drawer = false,
|
|
295
|
-
fade = true,
|
|
296
|
-
sections = 'fold',
|
|
297
|
-
}) {
|
|
298
|
-
const railRef = useRef(null)
|
|
299
|
-
const grabRef = useRef(null)
|
|
300
|
-
const [railOpen, setRailOpen] = useState(false)
|
|
301
|
-
/* ENTER MODE (`sections="enter"`, 2026-10-06 — the user, on labs: "having a 'enter' mode in the
|
|
302
|
-
* left sidebar instead of collapse folder?"): pressing a section replaces the list with that
|
|
303
|
-
* section's rows under a Back row, instead of unfolding it in place. `fold` is the accordion
|
|
304
|
-
* every rail had and keeps. Per consumer, not a law: labs' catalog is five sections of up to
|
|
305
|
-
* ten rows each, which is where an accordion stops reading. */
|
|
306
|
-
const [entered, setEntered] = useState(null)
|
|
307
|
-
const snapOpenRef = useRef(null)
|
|
308
|
-
const slotRef = useRef(null)
|
|
309
|
-
const ctx = useRailSlot()
|
|
310
|
-
const setSlot = ctx?.setSlot
|
|
311
|
-
const setCtxOpen = ctx?.setRailOpen
|
|
312
|
-
const slotOpen = drawer || railOpen
|
|
313
|
-
useEffect(() => { setSlot?.(slotRef.current); return () => setSlot?.(null) }, [setSlot, hidden])
|
|
314
|
-
useEffect(() => { setCtxOpen?.(slotOpen) }, [setCtxOpen, slotOpen])
|
|
315
|
-
/* the grab strip is not rendered in drawer mode, so the hook's ref stays null
|
|
316
|
-
* and it no-ops on its own — no second argument needed */
|
|
317
|
-
useGrabEdge(grabRef)
|
|
318
|
-
useRailDrag(railRef, grabRef, setRailOpen, snapOpenRef, !drawer)
|
|
319
|
-
if (hidden) return null
|
|
320
|
-
const enterMode = sections === 'enter'
|
|
321
|
-
const section = enterMode && entered ? items.find((i) => i.path === entered) : null
|
|
322
|
-
const row = (item) => (
|
|
323
|
-
<RailItem key={item.path} {...item} currentPath={currentPath} onNavigate={onNavigate} iconComponent={iconComponent} railOpen={drawer || railOpen} onOpenRail={() => snapOpenRef.current?.()}
|
|
324
|
-
onEnter={enterMode ? () => setEntered(item.path) : undefined} />
|
|
325
|
-
)
|
|
326
|
-
return (
|
|
327
|
-
<div
|
|
328
|
-
ref={railRef}
|
|
329
|
-
/* ONE SIDE, ALWAYS LEFT (ShellDrawerSideCorrection, kol-chess 2026-09-01).
|
|
330
|
-
* 0.34.0 mirrored the panel to fix a button: the complaint was the
|
|
331
|
-
* trigger travelling to mid-screen, never the navigation's side. The
|
|
332
|
-
* trigger is now pinned top-right in both states, so a left panel has
|
|
333
|
-
* nothing to collide with and the drawer opens where the rail lives. */
|
|
334
|
-
className="kol-shell-rail bg-surface-primary fixed inset-y-0 left-0 flex flex-col items-start pt-4 pb-4 px-2 gap-2 border-r border-fg-08"
|
|
335
|
-
/* A drawer takes its own width, NOT the live rail token — that token is
|
|
336
|
-
* zeroed in drawer mode so the content gets the whole viewport back. */
|
|
337
|
-
style={{ width: drawer ? 'var(--kol-shell-drawer-width, 240px)' : `var(${RAIL_W})` }}
|
|
338
|
-
>
|
|
339
|
-
{!drawer && (
|
|
340
|
-
/* A BUTTON, and on touch A THICKER LINE (ShellRailCollapsedWithTapOpen,
|
|
341
|
-
* kol-mirror 2026-09-01; corrected by RailGrabTapIsALine, kol-monitor
|
|
342
|
-
* 2026-09-02 — user: "it was a thicker line" · "who decided it should be
|
|
343
|
-
* a chevron?"): `touch="shell"` keeps the 48px rail visible and its
|
|
344
|
-
* only opener was this 8px strip, whose pill wakes on pointer
|
|
345
|
-
* PROXIMITY — a thumb never hovers. The 0.38.0 answer was a disc with a
|
|
346
|
-
* chevron; that was the DS agent's shape, not the user's ruling. The
|
|
347
|
-
* opener is the strip ITSELF: under `(pointer: coarse)` the theme
|
|
348
|
-
* widens it to a thumb-sized hit and shows the pill thick at rest — the
|
|
349
|
-
* same affordance a fine pointer drags, no glyph. A press with no travel
|
|
350
|
-
* already toggled; it just had no hit area on touch. The drag hook binds
|
|
351
|
-
* pointer events, so a button works exactly as the div did, and it says
|
|
352
|
-
* what it is. Enter/Space toggle for the keyboard. */
|
|
353
|
-
<button
|
|
354
|
-
type="button"
|
|
355
|
-
ref={grabRef}
|
|
356
|
-
className="kol-rail-grab"
|
|
357
|
-
aria-label={railOpen ? 'Collapse navigation' : 'Expand navigation'}
|
|
358
|
-
aria-expanded={railOpen}
|
|
359
|
-
onKeyDown={(e) => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); snapOpenRef.current?.(!railOpen) } }}
|
|
360
|
-
/>
|
|
361
|
-
)}
|
|
362
|
-
{logomark && (
|
|
363
|
-
/* the mark, and the app name beside it when open — uppercase like the
|
|
364
|
-
* rows (user 2026-08-28: "uppercase CONSISTENCY"). The `w-8` centring box
|
|
365
|
-
* puts the 20px mark on the same x as the 20px glyphs below it. */
|
|
366
|
-
<Tooltip label={logomark.title} placement="right" asChild>
|
|
367
|
-
<div
|
|
368
|
-
onClick={() => onNavigate?.('/')}
|
|
369
|
-
className="text-oq-96 cursor-pointer flex items-center gap-3 w-full overflow-hidden shrink-0 pt-1 mb-4"
|
|
370
|
-
>
|
|
371
|
-
<span className="w-8 flex justify-center shrink-0"><Logomark svgUrl={logomark.svgUrl} size={20} /></span>
|
|
372
|
-
<span className="kol-helper-12 uppercase flex-1 min-w-0 truncate">{logomark.title}</span>
|
|
373
|
-
</div>
|
|
374
|
-
</Tooltip>
|
|
375
|
-
)}
|
|
376
|
-
{/* THE LIST IS ITS OWN REGION (2026-10-02): it takes the room between the mark and the pinned
|
|
377
|
-
* bottom rows — what the bare spacer used to hold — scrolls when the rows outrun the window,
|
|
378
|
-
* and fades at its foot unless `fade={false}`. Same column, same gap, as the rail's own. */}
|
|
379
|
-
<div style={ctx && slotOpen ? { flex: '0 1 auto' } : undefined} className={`kol-shell-rail-list flex min-h-0 w-full flex-1 flex-col items-start gap-2 overflow-y-auto overflow-x-hidden ${fade ? 'kol-shell-rail-list--fade' : ''}`.trim()}>
|
|
380
|
-
{section ? (
|
|
381
|
-
<>
|
|
382
|
-
<RailItem icon="arrow-left" path={section.path} label={section.label} currentPath="" onNavigate={() => setEntered(null)} iconComponent={iconComponent} railOpen={drawer || railOpen} />
|
|
383
|
-
{section.sub.map((s) => <RailItem key={s.path} {...s} currentPath={currentPath} onNavigate={onNavigate} iconComponent={iconComponent} railOpen={drawer || railOpen} />)}
|
|
384
|
-
</>
|
|
385
|
-
) : items.map(row)}
|
|
386
|
-
</div>
|
|
387
|
-
{ctx && (
|
|
388
|
-
<div
|
|
389
|
-
ref={slotRef}
|
|
390
|
-
className="kol-shell-rail-slot w-full min-h-0 overflow-x-hidden"
|
|
391
|
-
style={{ flex: slotOpen ? '1 1 auto' : '0 0 0px', overflowY: slotOpen ? 'auto' : 'hidden' }}
|
|
392
|
-
/>
|
|
393
|
-
)}
|
|
394
|
-
{/* the rule runs the full rail width, out past the px-2 */}
|
|
395
|
-
{bottomItems.length > 0 && <div className="self-stretch -mx-2 border-t border-fg-08" />}
|
|
396
|
-
{bottomItems.map(row)}
|
|
397
|
-
</div>
|
|
398
|
-
)
|
|
399
|
-
}
|
package/src/railSlot.jsx
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { createContext, useContext, useMemo, useState } from 'react'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* RailSlotProvider / useRailSlot — a consumer slot in NavRail's opened width (NavRailConsumerSlot,
|
|
5
|
-
* kol-monitor 2026-10-15). The rail renders in AppShell's own tree, outside the page's providers,
|
|
6
|
-
* so it cannot read page state and the page cannot render into it. The rail publishes its slot's
|
|
7
|
-
* DOM node here instead, and the page portals into it with its own state:
|
|
8
|
-
*
|
|
9
|
-
* <RailSlotProvider><AppStudio … /></RailSlotProvider>
|
|
10
|
-
* const rail = useRailSlot(); rail?.slot && createPortal(<Panel />, rail.slot)
|
|
11
|
-
*
|
|
12
|
-
* The provider goes ABOVE the shell so the rail and the page both see it. No provider → no slot,
|
|
13
|
-
* and the rail renders as it did. `railOpen` mirrors the rail's open state for the page.
|
|
14
|
-
*
|
|
15
|
-
* Monitor's shape (`src/hooks/useRailSlot.jsx`), shipped so its NavRail fork can retire.
|
|
16
|
-
*/
|
|
17
|
-
const RailSlotContext = createContext(null)
|
|
18
|
-
|
|
19
|
-
export function useRailSlot() {
|
|
20
|
-
return useContext(RailSlotContext)
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export function RailSlotProvider({ children }) {
|
|
24
|
-
const [slot, setSlot] = useState(null)
|
|
25
|
-
const [railOpen, setRailOpen] = useState(false)
|
|
26
|
-
const value = useMemo(() => ({ slot, setSlot, railOpen, setRailOpen }), [slot, railOpen])
|
|
27
|
-
return <RailSlotContext.Provider value={value}>{children}</RailSlotContext.Provider>
|
|
28
|
-
}
|