@kolkrabbi/kol-shell 0.7.2 → 0.9.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-shell",
3
- "version": "0.7.2",
3
+ "version": "0.9.0",
4
4
  "private": false,
5
5
  "description": "KOL application shell — fixed 48px NavRail + AppShell layout root, PageShell/PageHeader scaffolds, ContentFilters catalog organism, GridCard, SettingsScaffold, WalkthroughPanel, ShortcutsOverlay. App chrome (kol-framework owns site chrome). Nav items, content, shortcuts and settings are consumer-injected. Sits above @kolkrabbi/kol-{theme,component,framework}.",
6
6
  "license": "MIT",
@@ -12,18 +12,18 @@
12
12
  "./src/*": "./src/*"
13
13
  },
14
14
  "peerDependencies": {
15
- "@kolkrabbi/kol-component": ">=0.38.0",
15
+ "@kolkrabbi/kol-component": ">=0.99.0",
16
16
  "@kolkrabbi/kol-framework": ">=0.20.0",
17
17
  "@kolkrabbi/kol-icons": ">=0.16.0",
18
- "@kolkrabbi/kol-theme": ">=0.67.0",
18
+ "@kolkrabbi/kol-theme": ">=0.68.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.98.0",
24
- "@kolkrabbi/kol-framework": "^0.27.1",
25
- "@kolkrabbi/kol-icons": "^0.19.0",
26
- "@kolkrabbi/kol-theme": "^0.67.0"
23
+ "@kolkrabbi/kol-framework": "^0.28.0",
24
+ "@kolkrabbi/kol-icons": "^0.20.0",
25
+ "@kolkrabbi/kol-component": "^0.106.0",
26
+ "@kolkrabbi/kol-theme": "^0.71.0"
27
27
  },
28
28
  "files": [
29
29
  "src",
package/src/AppShell.jsx CHANGED
@@ -1,6 +1,7 @@
1
- import { useState } from 'react'
1
+ import { useEffect, useState } from 'react'
2
2
  import NavRail from './NavRail.jsx'
3
3
  import { NavHiddenContext } from './navHidden.js'
4
+ import TouchDeviceOverlay, { useTouchPrimary } from './TouchDeviceOverlay.jsx'
4
5
 
5
6
  /**
6
7
  * AppShell — layout root: fixed NavRail + content offset by the rail width.
@@ -18,6 +19,13 @@ import { NavHiddenContext } from './navHidden.js'
18
19
  * @param {Function} props.onNavigate `(path) => void`
19
20
  * @param {ElementType} props.iconComponent icon renderer seam (see Button)
20
21
  * @param {boolean} props.themeToggle render the ThemeToggle above bottomItems (default true)
22
+ * @param {string} props.railToggleKey a key that toggles the rail (e.g. '\\') — ignored while typing in a field;
23
+ * the rail comes back on every `currentPath` change (ShellHomeSystem, 2026-08-27)
24
+ * @param {'shell'|'bare'|'overlay'} props.touch the touch-primary policy (default 'shell' = the rail regardless):
25
+ * `bare` renders the children with NO shell on a coarse-pointer device unless
26
+ * localStorage `kol-desktop` is '1' (fxr's gate); `overlay` keeps the shell and
27
+ * mounts TouchDeviceOverlay once (monitor's)
28
+ * @param {string} props.appName TouchDeviceOverlay's subject
21
29
  */
22
30
  export default function AppShell({
23
31
  items,
@@ -27,12 +35,39 @@ export default function AppShell({
27
35
  onNavigate,
28
36
  iconComponent,
29
37
  themeToggle,
38
+ railToggleKey,
39
+ touch = 'shell',
40
+ appName,
30
41
  children,
31
42
  }) {
32
43
  const [navHidden, setNavHidden] = useState(false)
44
+ const coarse = useTouchPrimary()
45
+
46
+ /* the rail comes back on every route change */
47
+ useEffect(() => { setNavHidden(false) }, [currentPath])
48
+ /* one key toggles the rail — never while typing in a field */
49
+ useEffect(() => {
50
+ if (!railToggleKey) return undefined
51
+ const onKey = (e) => {
52
+ if (e.key !== railToggleKey || e.metaKey || e.ctrlKey || e.altKey) return
53
+ const t = e.target
54
+ if (t?.isContentEditable || /^(INPUT|TEXTAREA|SELECT)$/.test(t?.tagName)) return
55
+ e.preventDefault()
56
+ setNavHidden((h) => !h)
57
+ }
58
+ window.addEventListener('keydown', onKey)
59
+ return () => window.removeEventListener('keydown', onKey)
60
+ }, [railToggleKey])
61
+
62
+ let wantsDesktop = false
63
+ try { wantsDesktop = typeof localStorage !== 'undefined' && localStorage.getItem('kol-desktop') === '1' } catch { /* storage blocked */ }
64
+ if (touch === 'bare' && coarse && !wantsDesktop) return <div className="kol-app-shell contents">{children}</div>
33
65
 
34
66
  return (
35
67
  <NavHiddenContext.Provider value={{ navHidden, setNavHidden }}>
68
+ {/* `kol-app-shell` = the app tier: neutral ::selection (kol-theme) */}
69
+ <div className="kol-app-shell contents">
70
+ {touch === 'overlay' && <TouchDeviceOverlay appName={appName} />}
36
71
  {!navHidden && (
37
72
  <NavRail
38
73
  items={items}
@@ -47,6 +82,7 @@ export default function AppShell({
47
82
  <div style={{ marginLeft: navHidden ? 0 : 'var(--kol-shell-rail-width)' }}>
48
83
  {children}
49
84
  </div>
85
+ </div>
50
86
  </NavHiddenContext.Provider>
51
87
  )
52
88
  }
@@ -0,0 +1,108 @@
1
+ import { ContentCard, ContentFilters, ContentRow } from '@kolkrabbi/kol-component'
2
+ import PageShell from './PageShell.jsx'
3
+ import PageHeader from './PageHeader.jsx'
4
+ import WalkthroughPanel from './WalkthroughPanel.jsx'
5
+
6
+ /* taxonomy-ok: organism — nests PageShell / PageHeader / WalkthroughPanel (relative) + kol-component's ContentFilters + ContentCard / ContentRow */
7
+
8
+ /**
9
+ * CatalogPage — the app tier's Home / Library page, shipped once (ShellHomeSystem,
10
+ * kol-fxr 2026-08-27 — fxr's HomePage / LibraryPage and monitor's HomePage were
11
+ * the same page written three times): `PageHeader` → `ContentFilters` (title ·
12
+ * filter · search, the view strip in the header, LIST / GRID below the divider)
13
+ * → the catalog grid — cards `repeat(6, 1fr)` gap 24, rows `repeat(4, 1fr)` gap
14
+ * 8, `ContentCard` / `ContentRow variant="catalog"` — → the bottom action row
15
+ * (`marginTop: 48`, `alignSelf: flex-start`, gap 12). The walkthrough panel
16
+ * sits over the catalog while `walkthrough.open`; the strip hides and the grid
17
+ * yields, as both apps do.
18
+ *
19
+ * Semantics are the consumer's: what RECENT / SAVED mean, what an item is,
20
+ * what a click does. `toCard(item, { view, layout })` → `{ key, title, detail,
21
+ * media, actions, onClick, href, onNavigate, expanded, expandedContent }` is the
22
+ * whole contract — `expanded` / `expandedContent` reach `ContentCard catalog`'s
23
+ * 2×2 cell (ShellHomeSystemMonitorGaps, kol-monitor 2026-08-27; neighbour-hiding
24
+ * stays the consumer's). Anything `ContentFilters` takes that the page has no
25
+ * prop for goes through `filtersProps` — `mutuallyExclusiveFilters` was the gap.
26
+ *
27
+ * @param {Object} header PageHeader props — `{ title, subtitle, size, voice, eyebrow }`
28
+ * @param {Array} items the objects `ContentFilters` filters and searches
29
+ * @param {Function} toCard (item, { view, layout }) => card props (see above)
30
+ * @param {string} filtersTitle ContentFilters' title (e.g. "All Chromes")
31
+ * @param {Array} filterGroups ContentFilters' `[{ label, key, values }]`
32
+ * @param {string[]} searchKeys fields the search reads (default `['title', 'name']`)
33
+ * @param {Array} views the header strip `[{ value, label }]` (RECENT / SAVED); omit for none
34
+ * @param {string} view · onViewChange controlled view; or `defaultView`
35
+ * @param {Array} layouts LIST / GRID (default both)
36
+ * @param {string} defaultLayout 'grid' (default) | 'list'
37
+ * @param {{steps: Array, open: boolean, iconComponent?: ElementType}} walkthrough the panel over the catalog
38
+ * @param {ReactNode} actions the bottom row's buttons
39
+ * @param {ElementType} iconComponent icon renderer seam for ContentFilters
40
+ * @param {boolean} showCountOnlyWhenFiltering (default true)
41
+ * @param {Object} filtersProps spread onto ContentFilters last — e.g. `{ mutuallyExclusiveFilters: ['category', 'u_label'] }`
42
+ */
43
+ const LAYOUTS = [
44
+ { value: 'list', label: 'LIST' },
45
+ { value: 'grid', label: 'GRID' },
46
+ ]
47
+
48
+ export default function CatalogPage({
49
+ header,
50
+ items = [],
51
+ toCard,
52
+ filtersTitle,
53
+ filterGroups,
54
+ searchKeys = ['title', 'name'],
55
+ views,
56
+ view,
57
+ onViewChange,
58
+ defaultView,
59
+ layouts = LAYOUTS,
60
+ defaultLayout = 'grid',
61
+ walkthrough,
62
+ actions,
63
+ iconComponent,
64
+ showCountOnlyWhenFiltering = true,
65
+ filtersProps,
66
+ children,
67
+ className = '',
68
+ style,
69
+ }) {
70
+ const open = walkthrough?.open === true
71
+ return (
72
+ <PageShell className={className} style={{ overflow: 'hidden', ...style }}>
73
+ {header && <PageHeader {...header} />}
74
+ <div style={{ flex: 1, position: 'relative' }}>
75
+ {open && <WalkthroughPanel steps={walkthrough.steps} iconComponent={walkthrough.iconComponent} />}
76
+ <ContentFilters
77
+ items={items}
78
+ title={filtersTitle}
79
+ totalCount={items.length}
80
+ filterGroups={filterGroups}
81
+ searchKeys={searchKeys}
82
+ showCountOnlyWhenFiltering={showCountOnlyWhenFiltering}
83
+ iconComponent={iconComponent}
84
+ viewModeOptions={views}
85
+ viewMode={view}
86
+ onViewModeChange={onViewChange}
87
+ defaultViewMode={defaultView}
88
+ layoutOptions={open ? undefined : layouts}
89
+ defaultLayout={defaultLayout}
90
+ renderItem={(rows, viewMode, layout) => open ? null : (
91
+ <div style={{ display: 'grid', gridTemplateColumns: layout === 'list' ? 'repeat(4, 1fr)' : 'repeat(6, 1fr)', gap: layout === 'list' ? 8 : 24 }}>
92
+ {rows.map((item, i) => {
93
+ const c = toCard ? toCard(item, { view: viewMode, layout }) : { title: item.title ?? item.name, detail: item.detail }
94
+ const key = c.key ?? item.key ?? item.id ?? item.name ?? i
95
+ return layout === 'list'
96
+ ? <ContentRow key={key} variant="catalog" title={c.title} detail={c.detail} actions={c.actions} onClick={c.onClick} href={c.href} onNavigate={c.onNavigate} />
97
+ : <ContentCard key={key} variant="catalog" fit="cover" title={c.title} detail={c.detail} media={c.media} actions={c.actions} onClick={c.onClick} href={c.href} onNavigate={c.onNavigate} expanded={c.expanded} expandedContent={c.expandedContent} />
98
+ })}
99
+ </div>
100
+ )}
101
+ {...filtersProps}
102
+ />
103
+ </div>
104
+ {children}
105
+ {actions && <div style={{ display: 'flex', gap: 12, marginTop: 48, alignSelf: 'flex-start' }}>{actions}</div>}
106
+ </PageShell>
107
+ )
108
+ }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * SettingsLinks — the About / Repo link list every app hand-wrote (ShellHomeSystem,
3
+ * kol-fxr 2026-08-27): label `kol-helper-12 text-fg-32` at 72px, the URL as an
4
+ * external link `text-fg-64 hover:text-fg-96 hover:underline`.
5
+ *
6
+ * @param {Array} links `[{ label, url, text? }]` — `text` shows instead of the URL
7
+ */
8
+ export default function SettingsLinks({ links = [], className = '' }) {
9
+ return (
10
+ <div className={className} style={{ display: 'flex', flexDirection: 'column', gap: 6 }}>
11
+ {links.map(({ label, url, text }) => (
12
+ <div key={label} style={{ display: 'flex', gap: 12, alignItems: 'baseline' }}>
13
+ <span className="text-fg-32 kol-helper-12" style={{ width: 72, flexShrink: 0 }}>{label}</span>
14
+ <a href={url} target="_blank" rel="noopener noreferrer" className="text-fg-64 kol-helper-12 hover:text-fg-96 hover:underline">{text ?? url}</a>
15
+ </div>
16
+ ))}
17
+ </div>
18
+ )
19
+ }
20
+
21
+ /** SettingsColophon — the "Kolkrabbi Vinnustofa / 2026" foot under a settings scaffold. */
22
+ export function SettingsColophon({ name = 'Kolkrabbi Vinnustofa', year = new Date().getFullYear(), className = '' }) {
23
+ return (
24
+ <div className={className} style={{ display: 'flex', flexDirection: 'column', gap: 6 }}>
25
+ <span className="text-fg-32 kol-helper-12">{name}</span>
26
+ <span className="text-fg-32 kol-helper-12">{year}</span>
27
+ </div>
28
+ )
29
+ }
@@ -0,0 +1,26 @@
1
+ import { LabelRow } from './SettingsScaffold.jsx'
2
+
3
+ /**
4
+ * SettingsShortcuts — the keyboard-shortcuts block of a settings page
5
+ * (ShellHomeSystem, kol-fxr 2026-08-27): the same `[{ section, items: [{ id,
6
+ * label, combo }] }]` array `ShortcutsOverlay` takes, laid out six columns ×
7
+ * two sections per column, filled column-first (user, 2026-08-27) — each
8
+ * section an eyebrow (`kol-eyebrow`, strong ink) over LabelRows.
9
+ *
10
+ * @param {Array} sections `[{ section, items: [{ id, label, combo }] }]`
11
+ * @param {Function} comboLabel (combo) => string (default: the combo as given)
12
+ */
13
+ export default function SettingsShortcuts({ sections = [], comboLabel = (c) => c, className = '' }) {
14
+ return (
15
+ <div className={`grid grid-cols-6 grid-rows-2 grid-flow-col gap-x-12 gap-y-6 ${className}`.trim()}>
16
+ {sections.map(({ section, items }) => (
17
+ <div key={section} style={{ display: 'flex', flexDirection: 'column', gap: 4 }}>
18
+ <span className="kol-eyebrow text-strong mb-2">{section}</span>
19
+ {items.map((k) => (
20
+ <LabelRow key={k.id ?? k.label} label={k.label}>{comboLabel(k.combo)}</LabelRow>
21
+ ))}
22
+ </div>
23
+ ))}
24
+ </div>
25
+ )
26
+ }
@@ -30,7 +30,7 @@ import { useEffect } from 'react'
30
30
  * keymap, it does not own one. Formatting a combo (⌘⇧Z) is the consumer's,
31
31
  * next to wherever the binding actually lives.
32
32
  *
33
- * @param {Array} props.shortcuts - `[{ label, keys }]` or `[{ section, items }]`
33
+ * @param {Array} props.shortcuts - `[{ label, combo }]` or `[{ section, items: [{ id, label, combo }] }]` — the same array `SettingsShortcuts` takes (ShellHomeSystemMonitorGaps, kol-monitor 2026-08-27: the overlay read `keys` while the settings block read `combo`; `combo` is the name, `keys` is tolerated for a release)
34
34
  * @param {Function} props.onClose
35
35
  */
36
36
 
@@ -38,10 +38,10 @@ const isSectioned = (list) => Array.isArray(list?.[0]?.items)
38
38
 
39
39
  /* One row of the shared grid. `contents` keeps the pair on the parent grid
40
40
  * rather than making the wrapper a cell of its own. */
41
- function Row({ label, keys }) {
41
+ function Row({ label, combo, keys }) {
42
42
  return (
43
43
  <span className="contents">
44
- <span>{label}</span><span className="text-fg-96">{keys}</span>
44
+ <span>{label}</span><span className="text-fg-96">{combo ?? keys}</span>
45
45
  </span>
46
46
  )
47
47
  }
@@ -71,13 +71,13 @@ export default function ShortcutsOverlay({ shortcuts = [], onClose }) {
71
71
  >
72
72
  {section}
73
73
  </span>
74
- {items.map(({ label, keys }) => (
75
- <Row key={`${section}:${label}`} label={label} keys={keys} />
74
+ {items.map(({ label, combo, keys }) => (
75
+ <Row key={`${section}:${label}`} label={label} combo={combo} keys={keys} />
76
76
  ))}
77
77
  </span>
78
78
  ))
79
- : shortcuts.map(({ label, keys }) => (
80
- <Row key={label} label={label} keys={keys} />
79
+ : shortcuts.map(({ label, combo, keys }) => (
80
+ <Row key={label} label={label} combo={combo} keys={keys} />
81
81
  ))}
82
82
  </div>
83
83
  </div>
@@ -0,0 +1,50 @@
1
+ import { useEffect, useState } from 'react'
2
+
3
+ const STORAGE_KEY = 'kol-touch-warning-dismissed'
4
+
5
+ /** useTouchPrimary — true on a coarse-pointer device (live). */
6
+ export function useTouchPrimary() {
7
+ const [coarse, setCoarse] = useState(false)
8
+ useEffect(() => {
9
+ if (typeof window === 'undefined' || !window.matchMedia) return undefined
10
+ const mq = window.matchMedia('(pointer: coarse)')
11
+ const update = () => setCoarse(mq.matches)
12
+ update()
13
+ mq.addEventListener?.('change', update)
14
+ return () => mq.removeEventListener?.('change', update)
15
+ }, [])
16
+ return coarse
17
+ }
18
+
19
+ /**
20
+ * TouchDeviceOverlay — "Desktop recommended", once, on a touch-primary device
21
+ * (kol-monitor's overlay, promoted 2026-08-27 — ShellHomeSystem; `AppShell
22
+ * touch="overlay"` mounts it). Dismissal is remembered in localStorage.
23
+ *
24
+ * @param {string} appName the sentence's subject ("Monitor is built for mouse and keyboard…")
25
+ * @param {string} message override the sentence whole
26
+ */
27
+ export default function TouchDeviceOverlay({ appName = 'This app', message }) {
28
+ const coarse = useTouchPrimary()
29
+ const [dismissed, setDismissed] = useState(() => {
30
+ try { return localStorage.getItem(STORAGE_KEY) === '1' } catch { return false }
31
+ })
32
+ if (!coarse || dismissed) return null
33
+ const dismiss = () => {
34
+ try { localStorage.setItem(STORAGE_KEY, '1') } catch { /* storage blocked */ }
35
+ setDismissed(true)
36
+ }
37
+ return (
38
+ <div className="fixed inset-0 select-none bg-fg-inverse-08" style={{ display: 'grid', placeItems: 'center', backdropFilter: 'blur(2px)', zIndex: 100 }}>
39
+ <div className="bg-surface-primary border border-oq-08" style={{ width: 360, borderRadius: 4, padding: '20px 20px 16px', display: 'flex', flexDirection: 'column', gap: 12 }}>
40
+ <div className="kol-helper-14 text-fg-96">Desktop recommended</div>
41
+ <div className="kol-mono-12 text-fg-64">
42
+ {message ?? `${appName} is built for mouse and keyboard — drag, tweak and use keyboard shortcuts. Touch input isn't supported yet.`}
43
+ </div>
44
+ <button type="button" onClick={dismiss} className="kol-helper-12 text-fg-96 bg-fg-08 border border-oq-08 cursor-pointer" style={{ padding: '8px 12px', borderRadius: 4, marginTop: 4, alignSelf: 'flex-end' }}>
45
+ Continue anyway
46
+ </button>
47
+ </div>
48
+ </div>
49
+ )
50
+ }
package/src/index.js CHANGED
@@ -23,3 +23,8 @@ export { default as SettingsScaffold, SettingsSection, LabelRow } from './Settin
23
23
  export { default as WalkthroughPanel } from './WalkthroughPanel.jsx'
24
24
  export { default as ShortcutsOverlay } from './ShortcutsOverlay.jsx'
25
25
  export { default as Logomark } from './Logomark.jsx'
26
+ // the app tier, shipped once (ShellHomeSystem, kol-fxr 2026-08-27)
27
+ export { default as CatalogPage } from './CatalogPage.jsx'
28
+ export { default as SettingsShortcuts } from './SettingsShortcuts.jsx'
29
+ export { default as SettingsLinks, SettingsColophon } from './SettingsLinks.jsx'
30
+ export { default as TouchDeviceOverlay, useTouchPrimary } from './TouchDeviceOverlay.jsx'