@kolkrabbi/kol-shell 0.87.2 → 0.89.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 +5 -5
- package/src/AppHub.jsx +66 -82
- package/src/HubHome.jsx +14 -2
- package/src/HubSettingsRail.jsx +108 -0
- package/src/MoreSheet.jsx +5 -3
- package/src/index.js +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kolkrabbi/kol-shell",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.89.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The application shell",
|
|
6
6
|
"license": "MIT",
|
|
@@ -21,10 +21,10 @@
|
|
|
21
21
|
"react-dom": "^18.3.0 || ^19.0.0"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@kolkrabbi/kol-component": "^0.
|
|
25
|
-
"@kolkrabbi/kol-framework": "^0.
|
|
26
|
-
"@kolkrabbi/kol-
|
|
27
|
-
"@kolkrabbi/kol-
|
|
24
|
+
"@kolkrabbi/kol-component": "^0.314.0",
|
|
25
|
+
"@kolkrabbi/kol-framework": "^0.63.0",
|
|
26
|
+
"@kolkrabbi/kol-icons": "^0.52.0",
|
|
27
|
+
"@kolkrabbi/kol-theme": "^0.197.0"
|
|
28
28
|
},
|
|
29
29
|
"files": [
|
|
30
30
|
"src",
|
package/src/AppHub.jsx
CHANGED
|
@@ -1,21 +1,16 @@
|
|
|
1
1
|
import { useEffect, useMemo, useState } from 'react'
|
|
2
|
-
/* THE TOGGLE IS THE HUB'S (user 2026-10-24:
|
|
3
|
-
|
|
4
|
-
props on every rail — no app passes a toggle. kol-framework is kol-shell's peer for this (ARCHITECTURE §3: the shell
|
|
5
|
-
consumes component + framework). `useTheme` is the Hub's own setting: reset hands the theme back to the system. */
|
|
6
|
-
import ThemeToggle from '@kolkrabbi/kol-framework/src/ThemeToggle.jsx'
|
|
7
|
-
import { useTheme } from '@kolkrabbi/kol-framework/src/theme.js'
|
|
2
|
+
/* THE TOGGLE IS THE HUB'S (user 2026-10-24): kol-framework's ThemeToggle with the Hub's props, drawn by HubSettingsRail
|
|
3
|
+
(`hubThemeToggle`) and used on the page tier too — no app passes a toggle. */
|
|
8
4
|
import AppShell from './AppShell.jsx'
|
|
9
5
|
import HubHome from './HubHome.jsx'
|
|
10
6
|
import HubSettings from './HubSettings.jsx'
|
|
7
|
+
import HubSettingsRail, { hubThemeToggle } from './HubSettingsRail.jsx'
|
|
11
8
|
import HubDev from './HubDev.jsx'
|
|
12
|
-
import SettingsLinks, { SettingsColophon } from './SettingsLinks.jsx'
|
|
13
|
-
import About from './About.jsx'
|
|
14
9
|
import { warnJsx } from './warnJsx.js'
|
|
15
10
|
import { Icon } from '@kolkrabbi/kol-icons'
|
|
16
|
-
import { Avatar, CommandOverlay,
|
|
11
|
+
import { Avatar, CommandOverlay, MediaLibrary, ModalProvider, RAIL_PRESETS, ShortcutsOverlay, shortcutInScope, useModal } from '@kolkrabbi/kol-component'
|
|
17
12
|
|
|
18
|
-
/* taxonomy-ok: organism — nests AppShell / HubHome / HubSettings / HubDev (relative) + kol-component's CommandOverlay */
|
|
13
|
+
/* taxonomy-ok: organism — nests AppShell / HubHome / HubSettings / HubSettingsRail / HubDev (relative) + kol-component's CommandOverlay */
|
|
19
14
|
|
|
20
15
|
/**
|
|
21
16
|
* AppHub — An app's shell and hub in one. Shell + Hub in one call; the app passes its Tool as children (the app anatomy,
|
|
@@ -92,7 +87,15 @@ import { Avatar, CommandOverlay, LabeledControlSection, MediaLibrary, ModalProvi
|
|
|
92
87
|
* foot, opening `MediaLibrary variant="picker"` (the column browser with the preview pane,
|
|
93
88
|
* Cancel and Use — mirror's) over `client` (kol-media-client's shape, or the media
|
|
94
89
|
* fixture's). OPT-IN: no `media`, no row
|
|
95
|
-
* @param {Object}
|
|
90
|
+
* @param {Object} phoneNav `{ more: (defaults) => rows }` — the phone pill's More sheet, edited by the app (HubAppOwnsItsRows).
|
|
91
|
+
* With `home.menu` · `home.signedOutActions` · `shell.foot`, the four places the Hub draws
|
|
92
|
+
* rows: each takes a function of its default rows, `{ icon, label, onPress | path, avatar? }`
|
|
93
|
+
* @param {Object} signIn `{ signedIn, user?, onProfile?, onPress, account? }` — the user row at the rail's foot. OPT-IN: no
|
|
94
|
+
* `account: { sections, content?, footer? }` (SettingsAccountTab, kol-fxr 2026-10-29 — *"why isnt
|
|
95
|
+
* account just in settings in account tab?"*): an Account tab, first in the settings rail while
|
|
96
|
+
* signed in — typed rows (`sections`), a node for what rows cannot say (`content`: the
|
|
97
|
+
* picture, Upload), and `footer: { label, onPress }` (Sign out). Without `onProfile` the
|
|
98
|
+
* account row opens the rail on that tab
|
|
96
99
|
* `signIn`, no row. THE ACCOUNT (HubAccountRow, kol-fxr 2026-10-28 — user: *"I am the only user.
|
|
97
100
|
* and we will treat me THE ONLY USER as a proper user"* · *"why does it say password for library
|
|
98
101
|
* sync? … stupid."*): with `user: { name, avatar? }` the row is an account — signed out it reads
|
|
@@ -131,39 +134,9 @@ const SETTINGS_DRAWER = '#settings'
|
|
|
131
134
|
const typing = (t) => t?.isContentEditable || /^(INPUT|TEXTAREA|SELECT)$/.test(t?.tagName)
|
|
132
135
|
const match = (label, q) => !q || String(label ?? '').toLowerCase().includes(q.toLowerCase())
|
|
133
136
|
|
|
134
|
-
/*
|
|
135
|
-
const toggle =
|
|
137
|
+
/* the Hub's toggle — HubSettingsRail's, so the page and the rail draw one */
|
|
138
|
+
const toggle = hubThemeToggle
|
|
136
139
|
|
|
137
|
-
/* THE RAIL'S NAMED TABS — drawn here, from what the Hub already holds, so a consumer passes a word and no JSX */
|
|
138
|
-
const RAIL_TABS = {
|
|
139
|
-
shortcuts: {
|
|
140
|
-
label: 'Shortcuts',
|
|
141
|
-
draw: ({ shortcuts }) => <SettingsSections divided sections={shortcuts.map((s) => ({ label: s.section, rows: (s.items ?? []).map((k, i) => ({ id: k.id ?? `${i}:${k.label}`, label: k.label, value: k.combo ?? k.keys })) }))} />,
|
|
142
|
-
},
|
|
143
|
-
about: {
|
|
144
|
-
label: 'About',
|
|
145
|
-
/* the links draw under About (SettingsRailDocsTab, kol-mirror 2026-10-24): Repo's list folds in here, so the row's
|
|
146
|
-
* fourth word can be Docs and it stays one line */
|
|
147
|
-
draw: ({ app }) => (
|
|
148
|
-
<div className="flex flex-col gap-8">
|
|
149
|
-
{app.about && <LabeledControlSection label={app.name}><About about={app.about} /></LabeledControlSection>}
|
|
150
|
-
{app.links?.length > 0 && <LabeledControlSection label="Links"><SettingsLinks links={app.links} /></LabeledControlSection>}
|
|
151
|
-
<SettingsColophon />
|
|
152
|
-
</div>
|
|
153
|
-
),
|
|
154
|
-
},
|
|
155
|
-
docs: {
|
|
156
|
-
label: 'Docs',
|
|
157
|
-
/* an app's explanatory prose AS DATA — `app.docs: [{ label, paragraphs }]`, each a section in About's voice, out of
|
|
158
|
-
* the settings sections' notes (user, on mirror's rail: *"settings are so overloaded with information that its hard to
|
|
159
|
-
* navigate … we should just start a documentation tab for it"*). No JSX: `About` warns on a node */
|
|
160
|
-
draw: ({ app }) => (
|
|
161
|
-
<div className="flex flex-col gap-8">
|
|
162
|
-
{app.docs.map((d, i) => <LabeledControlSection key={d.label ?? i} label={d.label}><About about={d.paragraphs ?? d.text} /></LabeledControlSection>)}
|
|
163
|
-
</div>
|
|
164
|
-
),
|
|
165
|
-
},
|
|
166
|
-
}
|
|
167
140
|
/* the rail's rows: typed, text, or nothing — a `render` row is JSX and is dropped here with a warning */
|
|
168
141
|
const railSections = (sections = []) => sections.map((s) => ({
|
|
169
142
|
...s,
|
|
@@ -197,8 +170,12 @@ function HubFrame({
|
|
|
197
170
|
shortcutsRailKey = 'S',
|
|
198
171
|
masthead,
|
|
199
172
|
shell,
|
|
173
|
+
/* `{ more: (defaults) => rows }` — the phone pill's More sheet, the app's edit of the Hub's rows (HubAppOwnsItsRows) */
|
|
174
|
+
phoneNav: phoneNavEdit,
|
|
200
175
|
children,
|
|
201
176
|
}) {
|
|
177
|
+
/* `shell.foot`: the rail's pinned foot as the app edits it — the rest of `shell` is AppShell's */
|
|
178
|
+
const { foot: footEdit, ...shellProps } = shell ?? {}
|
|
202
179
|
const [sheet, setSheet] = useState(false)
|
|
203
180
|
const [rail, setRail] = useState(false)
|
|
204
181
|
const [search, setSearch] = useState(false)
|
|
@@ -211,8 +188,8 @@ function HubFrame({
|
|
|
211
188
|
const { page: settingsPage = false, filters: settingsFilters = false, ...settingsProps } = settings ?? {}
|
|
212
189
|
const settingsDrawer = !!settings && !settingsPage
|
|
213
190
|
const [settingsTab, setSettingsTab] = useState('settings')
|
|
191
|
+
const account = signIn?.signedIn && signIn.account ? signIn.account : null
|
|
214
192
|
const modal = useModal()
|
|
215
|
-
const theme = useTheme()
|
|
216
193
|
/* THE DEFAULT THEME IS A ROOT ATTRIBUTE kol-framework's theme reads (`data-theme-default`): reset (`theme.clear()`)
|
|
217
194
|
* and the toggle's alt-click hand the page to it, not to the OS — a dark-first app stays dark on a light-mode Mac */
|
|
218
195
|
const themeDefault = defaultTheme ?? app.defaultTheme
|
|
@@ -222,27 +199,22 @@ function HubFrame({
|
|
|
222
199
|
return () => { delete document.documentElement.dataset.themeDefault }
|
|
223
200
|
}, [themeDefault])
|
|
224
201
|
if (themeToggle != null) warnJsx('themeToggle', 'The Hub draws the theme toggle itself; drop the prop.')
|
|
225
|
-
/*
|
|
226
|
-
*
|
|
227
|
-
* information … we should just start a documentation tab for it"*), so the fourth word is the app's prose, `app.docs`, drawn
|
|
228
|
-
* when it has any; an app's `tabs` are not drawn — its rows belong under Settings (dev warns) */
|
|
202
|
+
/* the rail's tabs are HubSettingsRail's (Settings · Shortcuts · About · Docs); an app's `tabs` are not drawn — its rows
|
|
203
|
+
* belong under Settings (dev warns) */
|
|
229
204
|
if (settingsDrawer && settings.tabs?.length) warnJsx('settings.tabs', 'The rail has no app tabs — put the rows under settings.sections.')
|
|
230
|
-
const railTabs = settingsDrawer ? [
|
|
231
|
-
...(shortcuts.length ? [{ value: 'shortcuts', label: RAIL_TABS.shortcuts.label, named: RAIL_TABS.shortcuts }] : []),
|
|
232
|
-
...((app.about || app.links?.length) ? [{ value: 'about', label: RAIL_TABS.about.label, named: RAIL_TABS.about }] : []),
|
|
233
|
-
...(app.docs?.length ? [{ value: 'docs', label: RAIL_TABS.docs.label, named: RAIL_TABS.docs }] : []),
|
|
234
|
-
] : []
|
|
235
205
|
if (settingsDrawer && settings.content != null) warnRailJsx('content')
|
|
236
206
|
const railRows = settingsDrawer ? railSections(settings.sections) : []
|
|
237
|
-
/* reset, live everywhere: the theme back to the system, then the app's own */
|
|
238
|
-
const reset = () => { theme.clear(); settings.drawer?.onReset?.() }
|
|
239
207
|
/* SIGN IN ASKS IN THE DS DIALOG (review 2, § 5.2 — fxr's RailSignIn, verbatim copy): signed out, the password prompt —
|
|
240
208
|
* empty cancels — then `onPress(password)`; signed in, the sign-out confirm, then `onPress(null)` */
|
|
241
209
|
const askSignIn = async () => {
|
|
242
210
|
if (!signIn) return
|
|
243
211
|
/* an account: signed in opens the profile; signed out asks email and password */
|
|
244
|
-
if (signIn.user || signIn.onProfile) {
|
|
245
|
-
if (signIn.signedIn) {
|
|
212
|
+
if (signIn.user || signIn.onProfile || signIn.account) {
|
|
213
|
+
if (signIn.signedIn) {
|
|
214
|
+
if (signIn.onProfile) { signIn.onProfile(); return }
|
|
215
|
+
if (signIn.account) { setSettingsTab('account'); setSettingsOpen(true) }
|
|
216
|
+
return
|
|
217
|
+
}
|
|
246
218
|
const got = await modal.form('Sign in', [
|
|
247
219
|
{ id: 'email', placeholder: 'Email', type: 'email', autoComplete: 'username' },
|
|
248
220
|
{ id: 'password', placeholder: 'Password', type: 'password', autoComplete: 'current-password' },
|
|
@@ -318,16 +290,22 @@ function HubFrame({
|
|
|
318
290
|
* (no More), they stay on the page */
|
|
319
291
|
const barOn = ['bar', 'pill'].includes(shell?.touch ?? RAIL_PRESETS.app.phone)
|
|
320
292
|
const onHome = home && currentPath === homePath
|
|
321
|
-
|
|
293
|
+
/* the signed-in account as a row — Home's menu and the phone's More end on it (HomeMenuAccountRow) */
|
|
294
|
+
const accountAction = signIn?.signedIn && (signIn.user || signIn.account || signIn.onProfile)
|
|
295
|
+
? { label: signIn.user?.name ?? 'Account', icon: 'user', avatar: signIn.user?.avatar, onPress: () => askSignIn() }
|
|
296
|
+
: undefined
|
|
297
|
+
const homeDefaults = onHome && barOn ? [
|
|
322
298
|
...(home.action ? [{ label: home.action.label, icon: 'plus', onPress: home.action.onClick }] : []),
|
|
323
299
|
...(walkthrough?.length ? [{ label: touring ? 'Close walkthrough' : 'Walkthrough', icon: 'book-open', onPress: () => setTouring((t) => !t) }] : []),
|
|
300
|
+
...(accountAction ? [accountAction] : []),
|
|
324
301
|
] : []
|
|
302
|
+
const homeActions = onHome && barOn && typeof home.menu === 'function' ? home.menu(homeDefaults) ?? [] : homeDefaults
|
|
325
303
|
/* SIGNED OUT (HubHomeSignedOut, 2026-10-28): Home is the stage, no files; the desk's round + carries Sign in beside New File
|
|
326
304
|
* and Walkthrough; on a phone the pill is the app's chromes and More is the rail (frame A2) */
|
|
327
305
|
const signedOutHome = onHome && (home.signedOut ?? (home.stage != null && !(home.files?.length)))
|
|
328
306
|
const signInAction = signIn && !signIn.signedIn ? { label: 'Sign in', icon: 'user', onPress: () => askSignIn() } : undefined
|
|
329
307
|
const page = onHome
|
|
330
|
-
? <HubHome app={app} iconComponent={iconComponent} walkthrough={walkthrough} {...home} touring={touring} onTouringChange={setTouring} actionsInBar={barOn} signInAction={signInAction} />
|
|
308
|
+
? <HubHome app={app} iconComponent={iconComponent} walkthrough={walkthrough} {...home} touring={touring} onTouringChange={setTouring} actionsInBar={barOn} signInAction={signInAction} accountAction={accountAction} />
|
|
331
309
|
: settingsPage && currentPath === settingsPath
|
|
332
310
|
? <HubSettings app={app} shortcuts={shortcuts} themeToggle={toggle} filters={settingsFilters} {...settingsProps} drawer={settingsProps.drawer ?? true} />
|
|
333
311
|
: devOn && (currentPath === devPath || currentPath?.startsWith(`${devPath}/`))
|
|
@@ -337,13 +315,22 @@ function HubFrame({
|
|
|
337
315
|
* *"why did the dev tab move? it was fine where it was. below stage"*); Settings keeps the bottom alone */
|
|
338
316
|
const rows = devOn ? [...items, { icon: 'code', path: devPath, label: 'Dev' }] : items
|
|
339
317
|
/* the pinned foot: Media, Sign in, Settings — each only when the app passes it */
|
|
340
|
-
const
|
|
318
|
+
const bottomDefaults = [
|
|
341
319
|
...(media ? [{ icon: 'image', path: MEDIA_PATH, label: 'Media' }] : []),
|
|
342
320
|
...(signIn ? [signIn.signedIn && signIn.user
|
|
343
321
|
? { icon: ACCOUNT_GLYPH, path: SIGN_IN_PATH, label: signIn.user.name ?? 'Account' }
|
|
344
322
|
: { icon: signIn.signedIn ? 'cloud' : 'user', path: SIGN_IN_PATH, label: signIn.signedIn ? 'Signed in' : 'Sign in' }] : []),
|
|
345
323
|
...(settings ? SETTINGS_ROW(settingsDrawer ? SETTINGS_DRAWER : settingsPath) : []),
|
|
346
324
|
]
|
|
325
|
+
/* an app's row may press rather than route (`onPress`): it travels the rail as a sentinel path, and `go` presses it */
|
|
326
|
+
const pressed = {}
|
|
327
|
+
const asRows = (list) => (list ?? []).map((r, i) => {
|
|
328
|
+
if (r.path || !r.onPress) return r
|
|
329
|
+
const path = `#row:${i}:${r.label}`
|
|
330
|
+
pressed[path] = r.onPress
|
|
331
|
+
return { ...r, path }
|
|
332
|
+
})
|
|
333
|
+
const bottom = typeof footEdit === 'function' ? asRows(footEdit(bottomDefaults)) : bottomDefaults
|
|
347
334
|
/* the phone bar lists Home as a tab — the rail draws it as the mark, the bar has no mark */
|
|
348
335
|
const barItems = [...(home ? [{ icon: 'home-01', path: homePath, label: 'Home' }] : []), ...rows, ...bottom.map((r) => (r.icon === ACCOUNT_GLYPH ? { ...r, icon: 'user' } : r))]
|
|
349
336
|
/* the rail's glyphs, with the account's avatar where its row is */
|
|
@@ -361,6 +348,7 @@ function HubFrame({
|
|
|
361
348
|
if (path === MEDIA_PATH) { setMediaOpen(true); return }
|
|
362
349
|
if (path === SIGN_IN_PATH) { askSignIn(); return }
|
|
363
350
|
if (path === SETTINGS_DRAWER) { setSettingsOpen((v) => !v); return }
|
|
351
|
+
if (pressed[path]) { pressed[path](); return }
|
|
364
352
|
return onNavigate?.(path, ...rest)
|
|
365
353
|
}
|
|
366
354
|
|
|
@@ -392,7 +380,11 @@ function HubFrame({
|
|
|
392
380
|
bottomItems={bottom}
|
|
393
381
|
barItems={signedOutHome && home.chromes?.length ? home.chromes.map((c) => ({ id: c.label, label: c.label, icon: c.icon, onPress: c.onPress })) : barItems}
|
|
394
382
|
barActions={homeActions}
|
|
395
|
-
phoneNav={
|
|
383
|
+
phoneNav={(() => {
|
|
384
|
+
const sheet = [...rows, ...bottom.map((r) => ({ ...r, icon: r.icon === ACCOUNT_GLYPH ? 'user' : r.icon, foot: true }))]
|
|
385
|
+
if (typeof phoneNavEdit?.more === 'function') return { sheetItems: asRows(phoneNavEdit.more(sheet)), moreKeepsOpen: signedOutHome || undefined }
|
|
386
|
+
return signedOutHome && home.chromes?.length ? { sheetItems: sheet, moreKeepsOpen: true } : undefined
|
|
387
|
+
})()}
|
|
396
388
|
logomark={app.logomark ? { svgUrl: app.logomark, title: app.name } : undefined}
|
|
397
389
|
currentPath={currentPath}
|
|
398
390
|
onNavigate={go}
|
|
@@ -408,7 +400,7 @@ function HubFrame({
|
|
|
408
400
|
touch={RAIL_PRESETS.app.phone}
|
|
409
401
|
masthead={masthead}
|
|
410
402
|
pageWash="var(--kol-fg-02)"
|
|
411
|
-
{...
|
|
403
|
+
{...shellProps}
|
|
412
404
|
>
|
|
413
405
|
{page}
|
|
414
406
|
{/* THE SHEET IS THE ⌘K MODAL WITH NO FIELD (ShortcutsOverlayCategories, kol-monitor 2026-10-18 — user: *"I said
|
|
@@ -423,28 +415,20 @@ function HubFrame({
|
|
|
423
415
|
{media && (
|
|
424
416
|
<MediaLibrary variant="picker" open={mediaOpen} client={media.client} accept={media.accept} onClose={() => setMediaOpen(false)} onSelect={(url, meta) => { setMediaOpen(false); media.onSelect?.(url, meta) }} />
|
|
425
417
|
)}
|
|
426
|
-
{/* THE RAIL tier — studio-hub's, the template
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
* — like the labs rail's levels, never a page. Rows only: the Hub draws every string, so no rail can wear a class
|
|
430
|
-
* the template does not */}
|
|
431
|
-
{settingsDrawer && (
|
|
432
|
-
<SettingsPanel
|
|
418
|
+
{/* THE RAIL tier — studio-hub's, the template: HubSettingsRail (lifted out of here for kol-workshop, 2026-10-29) */}
|
|
419
|
+
{(settingsDrawer || account) && (
|
|
420
|
+
<HubSettingsRail
|
|
433
421
|
open={settingsOpen}
|
|
434
|
-
variant="rail"
|
|
435
|
-
title={settings.drawer?.title ?? 'Settings'}
|
|
436
422
|
onClose={() => setSettingsOpen(false)}
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
{
|
|
441
|
-
{
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
{
|
|
445
|
-
|
|
446
|
-
: railTabs.find((x) => x.value === settingsTab)?.named?.draw({ app, shortcuts })}
|
|
447
|
-
</SettingsPanel>
|
|
423
|
+
title={settings?.drawer?.title ?? 'Settings'}
|
|
424
|
+
sections={settingsDrawer ? railRows : undefined}
|
|
425
|
+
app={app}
|
|
426
|
+
shortcuts={shortcuts}
|
|
427
|
+
account={account ? { ...account, sections: account.sections && railSections(account.sections) } : undefined}
|
|
428
|
+
tab={settingsTab}
|
|
429
|
+
onTabChange={setSettingsTab}
|
|
430
|
+
onReset={settings?.drawer?.onReset}
|
|
431
|
+
/>
|
|
448
432
|
)}
|
|
449
433
|
</AppShell>
|
|
450
434
|
)
|
package/src/HubHome.jsx
CHANGED
|
@@ -158,6 +158,15 @@ export default function HubHome({
|
|
|
158
158
|
stage,
|
|
159
159
|
chromes = [],
|
|
160
160
|
signInAction,
|
|
161
|
+
/* AppHub's: the signed-in account row (HomeMenuAccountRow, kol-fxr 2026-10-29 — *"here is supposed to be user space as
|
|
162
|
+
* well"*), the menu's last row */
|
|
163
|
+
accountAction,
|
|
164
|
+
/* THE APP OWNS ITS ROWS (HubAppOwnsItsRows, kol-fxr 2026-10-29 — *"I dont wanna file every goddamn change"*): each a
|
|
165
|
+
* function of the Hub's rows, `(defaults) => rows` — keep them and edit, or replace them. Rows keep the Hub's shape
|
|
166
|
+
* `{ icon, label, onPress, avatar? }` and the Hub still draws them. `menu` is the masthead's round button signed in,
|
|
167
|
+
* `signedOutActions` the + on the signed-out page. */
|
|
168
|
+
menu,
|
|
169
|
+
signedOutActions,
|
|
161
170
|
...unknown
|
|
162
171
|
}) {
|
|
163
172
|
if (import.meta.env.DEV) warnUnknown(unknown)
|
|
@@ -224,10 +233,12 @@ export default function HubHome({
|
|
|
224
233
|
* the phone bar's More draws (MoreRows in `.kol-more-sheet`). The foot row it replaces was a row of buttons under the
|
|
225
234
|
* catalog, hence a bottom pad that read as a clipped last row. With the bar on a phone the bar's More carries both
|
|
226
235
|
* and the button hides below `md`; with the drawer it stays on every width. */
|
|
227
|
-
const
|
|
236
|
+
const baseActions = [
|
|
228
237
|
...(action ? [{ label: action.label, icon: 'plus', onPress: action.onClick }] : []),
|
|
229
238
|
...(steps.length ? [{ label: touring ? 'Close walkthrough' : 'Walkthrough', icon: 'book-open', onPress: () => setTouring((t) => !t) }] : []),
|
|
230
239
|
]
|
|
240
|
+
const menuDefaults = [...baseActions, ...(accountAction ? [accountAction] : [])]
|
|
241
|
+
const menuActions = typeof menu === 'function' ? menu(menuDefaults) ?? [] : menuDefaults
|
|
231
242
|
/* with the drawer the button stays on the phone, stepped left of the shell's drawer trigger (fixed top-right, 32 at 12;
|
|
232
243
|
* the variants gate caught the overlap on editor-hub at 390) */
|
|
233
244
|
const headerMenu = menuActions.length ? <HomeMenu actions={menuActions} className={actionsInBar ? 'max-md:hidden' : 'max-md:mr-11'} /> : undefined
|
|
@@ -245,7 +256,8 @@ export default function HubHome({
|
|
|
245
256
|
) : undefined
|
|
246
257
|
|
|
247
258
|
if (signedOut ?? (stage != null && files.length === 0)) {
|
|
248
|
-
const
|
|
259
|
+
const outDefaults = [...baseActions, ...(signInAction ? [signInAction] : [])]
|
|
260
|
+
const outActions = typeof signedOutActions === 'function' ? signedOutActions(outDefaults) ?? [] : outDefaults
|
|
249
261
|
return (
|
|
250
262
|
<div className="relative min-h-dvh overflow-hidden" data-hub-signed-out>
|
|
251
263
|
{stage && <div className="absolute inset-0" aria-hidden="true">{stage}</div>}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { useState } from 'react'
|
|
2
|
+
import ThemeToggle from '@kolkrabbi/kol-framework/src/ThemeToggle.jsx'
|
|
3
|
+
import { useTheme } from '@kolkrabbi/kol-framework/src/theme.js'
|
|
4
|
+
import { Button, LabeledControlSection, SettingsFooter, SettingsPanel, SettingsSections, TabsRow } from '@kolkrabbi/kol-component'
|
|
5
|
+
import SettingsLinks, { SettingsColophon } from './SettingsLinks.jsx'
|
|
6
|
+
import About from './About.jsx'
|
|
7
|
+
|
|
8
|
+
/* taxonomy-ok: organism — nests SettingsLinks / About (relative) + kol-component's SettingsPanel / SettingsSections / TabsRow */
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* HubSettingsRail — The hub's settings rail. AppHub's rail tier, lifted out of AppHub as it was
|
|
12
|
+
* (WorkshopSettingsRailAndBars, kol-hq 2026-10-29 — user: *"this should be implemented on workshop as well … I dont want
|
|
13
|
+
* any reinventions"*), so kol-workshop's `ShellLayout` opens the same rail: Settings · Shortcuts · About · Docs, the
|
|
14
|
+
* theme toggle and a live reset in the footer.
|
|
15
|
+
*
|
|
16
|
+
* @param {boolean} open · onClose
|
|
17
|
+
* @param {string} title default `Settings`
|
|
18
|
+
* @param {Array} sections the Settings tab's rows (`SettingsSections` shape); omitted, there is no Settings tab and
|
|
19
|
+
* no named tabs (AppHub's account-only rail)
|
|
20
|
+
* @param {Object} app `{ name, about, links, docs }` — About draws from `about` + `links`, Docs from `docs`
|
|
21
|
+
* @param {Array} shortcuts `[{ section, items: [{ id, label, combo }] }]` — the Shortcuts tab
|
|
22
|
+
* @param {Object} account `{ content, sections, footer }` — the Account tab, first, while signed in
|
|
23
|
+
* @param {string} tab · onTabChange controlled tab (optional — the rail keeps its own otherwise)
|
|
24
|
+
* @param {Function} onReset the app's reset, after the theme goes back to the system
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
/* THE TOGGLE'S PROPS ARE THE HUB'S — studio-hub's `fill="none" label={false} size="sm"`, nothing else */
|
|
28
|
+
export const hubThemeToggle = <ThemeToggle variant="button" fill="none" label={false} size="sm" tone="default" />
|
|
29
|
+
|
|
30
|
+
/* THE RAIL'S NAMED TABS — drawn here, from what the Hub already holds, so a consumer passes a word and no JSX */
|
|
31
|
+
const RAIL_TABS = {
|
|
32
|
+
shortcuts: {
|
|
33
|
+
label: 'Shortcuts',
|
|
34
|
+
draw: ({ shortcuts }) => <SettingsSections divided sections={shortcuts.map((s) => ({ label: s.section, rows: (s.items ?? []).map((k, i) => ({ id: k.id ?? `${i}:${k.label}`, label: k.label, value: k.combo ?? k.keys })) }))} />,
|
|
35
|
+
},
|
|
36
|
+
about: {
|
|
37
|
+
label: 'About',
|
|
38
|
+
/* the links draw under About (SettingsRailDocsTab, kol-mirror 2026-10-24): Repo's list folds in here, so the row's
|
|
39
|
+
* fourth word can be Docs and it stays one line */
|
|
40
|
+
draw: ({ app }) => (
|
|
41
|
+
<div className="flex flex-col gap-8">
|
|
42
|
+
{app.about && <LabeledControlSection label={app.name}><About about={app.about} /></LabeledControlSection>}
|
|
43
|
+
{app.links?.length > 0 && <LabeledControlSection label="Links"><SettingsLinks links={app.links} /></LabeledControlSection>}
|
|
44
|
+
<SettingsColophon />
|
|
45
|
+
</div>
|
|
46
|
+
),
|
|
47
|
+
},
|
|
48
|
+
docs: {
|
|
49
|
+
label: 'Docs',
|
|
50
|
+
/* an app's explanatory prose AS DATA — `app.docs: [{ label, paragraphs }]`, each a section in About's voice, out of
|
|
51
|
+
* the settings sections' notes (user, on mirror's rail: *"settings are so overloaded with information that its hard to
|
|
52
|
+
* navigate … we should just start a documentation tab for it"*). No JSX: `About` warns on a node */
|
|
53
|
+
draw: ({ app }) => (
|
|
54
|
+
<div className="flex flex-col gap-8">
|
|
55
|
+
{app.docs.map((d, i) => <LabeledControlSection key={d.label ?? i} label={d.label}><About about={d.paragraphs ?? d.text} /></LabeledControlSection>)}
|
|
56
|
+
</div>
|
|
57
|
+
),
|
|
58
|
+
},
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export default function HubSettingsRail({ open, onClose, title = 'Settings', sections, app = {}, shortcuts = [], account, tab: tabProp, onTabChange, onReset }) {
|
|
62
|
+
const [ownTab, setOwnTab] = useState('settings')
|
|
63
|
+
const theme = useTheme()
|
|
64
|
+
const hasSettings = sections != null
|
|
65
|
+
/* THE RAIL'S TABS, the same four on every hub: Settings · Shortcuts · About · Docs, the three from what the app already
|
|
66
|
+
* passes — Repo's links sit under About since SettingsRailDocsTab, so the fourth word is the app's prose, `app.docs`,
|
|
67
|
+
* drawn when it has any */
|
|
68
|
+
const railTabs = hasSettings ? [
|
|
69
|
+
...(shortcuts.length ? [{ value: 'shortcuts', label: RAIL_TABS.shortcuts.label, named: RAIL_TABS.shortcuts }] : []),
|
|
70
|
+
...((app.about || app.links?.length) ? [{ value: 'about', label: RAIL_TABS.about.label, named: RAIL_TABS.about }] : []),
|
|
71
|
+
...(app.docs?.length ? [{ value: 'docs', label: RAIL_TABS.docs.label, named: RAIL_TABS.docs }] : []),
|
|
72
|
+
] : []
|
|
73
|
+
/* the Account tab first, while signed in (SettingsAccountTab); then Settings and the Hub's named tabs */
|
|
74
|
+
const tabs = [...(account ? [{ id: 'account', label: 'Account' }] : []), ...(hasSettings ? [{ id: 'settings', label: 'Settings' }] : []), ...railTabs.map((t) => ({ id: t.value, label: t.label }))]
|
|
75
|
+
const want = tabProp ?? ownTab
|
|
76
|
+
const tab = tabs.some((t) => t.id === want) ? want : tabs[0]?.id
|
|
77
|
+
const setTab = onTabChange ?? setOwnTab
|
|
78
|
+
/* reset, live everywhere: the theme back to the system, then the app's own */
|
|
79
|
+
const reset = () => { theme.clear(); onReset?.() }
|
|
80
|
+
|
|
81
|
+
return (
|
|
82
|
+
/* THE RAIL tier — studio-hub's, the template (user 2026-10-24: *"In studio what kind of settings tier is there? ITS A
|
|
83
|
+
* RAIL"*): `sections` in the rail, the theme toggle (the Hub's props) and reset in its footer; with tabs, a text
|
|
84
|
+
* TabsRow under the header — never a page */
|
|
85
|
+
<SettingsPanel
|
|
86
|
+
open={open}
|
|
87
|
+
variant="rail"
|
|
88
|
+
title={title}
|
|
89
|
+
onClose={onClose}
|
|
90
|
+
/* the footer on every rail: the toggle, and a live reset */
|
|
91
|
+
footer={<SettingsFooter onReset={reset}>{hubThemeToggle}</SettingsFooter>}
|
|
92
|
+
>
|
|
93
|
+
{/* the tab row wraps in the 380 rail — five tabs (Mirror's Performance beside the Hub's three) overran it */}
|
|
94
|
+
{tabs.length > 1 && <TabsRow look="text" size={12} tracked className="flex-wrap gap-x-6 gap-y-2" tabs={tabs} value={tab} onChange={setTab} ariaLabel="Settings tabs" />}
|
|
95
|
+
{tab === 'account'
|
|
96
|
+
? (
|
|
97
|
+
<div className="flex flex-col gap-8">
|
|
98
|
+
{account.content}
|
|
99
|
+
{account.sections?.length > 0 && <SettingsSections sections={account.sections} divided />}
|
|
100
|
+
{account.footer && <Button tone="outline" size="sm" className="self-start" onClick={account.footer.onPress}>{account.footer.label}</Button>}
|
|
101
|
+
</div>
|
|
102
|
+
)
|
|
103
|
+
: tab === 'settings'
|
|
104
|
+
? (sections?.length > 0 && <SettingsSections sections={sections} divided />)
|
|
105
|
+
: railTabs.find((x) => x.value === tab)?.named?.draw({ app, shortcuts })}
|
|
106
|
+
</SettingsPanel>
|
|
107
|
+
)
|
|
108
|
+
}
|
package/src/MoreSheet.jsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Button } from '@kolkrabbi/kol-component'
|
|
1
|
+
import { Avatar, Button } from '@kolkrabbi/kol-component'
|
|
2
2
|
import { Icon } from '@kolkrabbi/kol-icons'
|
|
3
3
|
|
|
4
4
|
/* taxonomy-ok: molecule — a column of nav Buttons */
|
|
@@ -9,7 +9,8 @@ import { Icon } from '@kolkrabbi/kol-icons'
|
|
|
9
9
|
* (user 2026-10-23: *"we could even make similar dropdown as we use in phone nav"*). The sheet's chrome is
|
|
10
10
|
* `.kol-more-sheet` — the pill's ground and hairline, a 24px rounding, 8px pad — on whatever box holds the rows.
|
|
11
11
|
*
|
|
12
|
-
* @param {Array} actions `[{ label, icon?, onPress, checked? }]` — the page's own buttons, first.
|
|
12
|
+
* @param {Array} actions `[{ label, icon?, avatar?, onPress, checked? }]` — the page's own buttons, first. `avatar` (a picture
|
|
13
|
+
* url — the account row) draws in the glyph's place. A row with `checked`
|
|
13
14
|
* (a pick list — TransportPill's loop lengths) draws the 22px check, or keeps its space when false
|
|
14
15
|
* @param {Array} items `[{ path, label, icon? }]` — destinations, after a divider's worth of nothing
|
|
15
16
|
* @param {string} active the item path that is current
|
|
@@ -21,7 +22,8 @@ export default function MoreRows({ actions = [], items = [], active, onPick, ite
|
|
|
21
22
|
const acts = (
|
|
22
23
|
<>
|
|
23
24
|
{actions.map((a) => (
|
|
24
|
-
<Button key={a.label} variant="nav" size="lg" iconLeft={a.checked === undefined ? a.icon : undefined} iconSize={22} className="w-full justify-start h-11 gap-3" onClick={() => { onPick?.(a); a.onPress?.() }}>
|
|
25
|
+
<Button key={a.label} variant="nav" size="lg" iconLeft={a.checked === undefined && !a.avatar ? a.icon : undefined} iconSize={22} className="w-full justify-start h-11 gap-3" onClick={() => { onPick?.(a); a.onPress?.() }}>
|
|
26
|
+
{a.avatar && <Avatar src={a.avatar} alt="" size="xs" />}
|
|
25
27
|
{a.checked !== undefined && (
|
|
26
28
|
<span className="inline-flex items-center justify-center shrink-0" style={{ width: 22, height: 22 }}>{a.checked && <Icon name="check" size={22} />}</span>
|
|
27
29
|
)}
|
package/src/index.js
CHANGED
|
@@ -39,6 +39,7 @@ export { default as TouchDeviceOverlay, useTouchPrimary } from './TouchDeviceOve
|
|
|
39
39
|
export { default as AppHub } from './AppHub.jsx'
|
|
40
40
|
export { default as HubHome } from './HubHome.jsx'
|
|
41
41
|
export { default as HubSettings } from './HubSettings.jsx'
|
|
42
|
+
export { default as HubSettingsRail, hubThemeToggle } from './HubSettingsRail.jsx'
|
|
42
43
|
export { default as HubDev } from './HubDev.jsx'
|
|
43
44
|
// the Studio — the Hub + Home · Library · Create · Use · pages · Settings, the workstation (apps review §6c, 2026-09-29)
|
|
44
45
|
export { default as AppStudio } from './AppStudio.jsx'
|