@kolkrabbi/kol-component 0.295.1 → 0.296.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 +2 -2
- package/src/atoms/CloseButton.jsx +24 -4
- package/src/atoms/IconToggle.jsx +1 -1
- package/src/hooks/canvasViewport.js +400 -0
- package/src/hooks/railRow.js +11 -0
- package/src/index.js +9 -4
- package/src/molecules/AppItem.jsx +43 -36
- package/src/molecules/ContentCard.jsx +6 -3
- package/src/molecules/ContentRow.jsx +5 -3
- package/src/molecules/ContentText.jsx +12 -11
- package/src/molecules/LabeledControl.jsx +3 -1
- package/src/molecules/MenuItem.jsx +1 -1
- package/src/molecules/PageHeader.jsx +2 -1
- package/src/molecules/Rail.jsx +5 -3
- package/src/molecules/SectionText.jsx +6 -2
- package/src/molecules/TabsRow.jsx +65 -9
- package/src/molecules/TextFold.jsx +1 -1
- package/src/organisms/AppItemMenuProvider.jsx +144 -0
- package/src/organisms/Canvas.jsx +49 -258
- package/src/organisms/CanvasStudio.jsx +128 -0
- package/src/organisms/CommandOverlay.jsx +7 -5
- package/src/organisms/CurveEditor.jsx +1 -1
- package/src/organisms/MediaGalleryModes.jsx +1 -1
- package/src/organisms/MediaLibrary.jsx +31 -9
- package/src/organisms/MediaLibraryPages.jsx +30 -6
- package/src/organisms/NavRail.jsx +68 -56
- package/src/organisms/SettingsPanel.jsx +16 -9
- package/src/organisms/SettingsSections.jsx +31 -6
|
@@ -15,6 +15,8 @@ import { MenuItem, MenuDropdownItem, MenuDropdownDivider } from '../molecules/Me
|
|
|
15
15
|
import MediaViewer from './MediaViewer.jsx'
|
|
16
16
|
import { MediaLibraryBrowse, MediaLibraryLibrary, SETTINGS_BASE } from './MediaLibraryPages.jsx'
|
|
17
17
|
import MediaLibraryExplorer from './MediaLibraryExplorer.jsx'
|
|
18
|
+
import { MastheadContext } from '../utilities/masthead.js'
|
|
19
|
+
import useMediaQuery from '../hooks/useMediaQuery.js'
|
|
18
20
|
import { SettingsChipRow, chipCls } from './SettingsPanel.jsx'
|
|
19
21
|
import { filterMedia } from '../utilities/mediaSearch.js'
|
|
20
22
|
|
|
@@ -877,7 +879,7 @@ function PickerBody({ items, viewMode, onOpen, onPick }) {
|
|
|
877
879
|
if (loading) return <p className="kol-helper-12 text-meta">Loading…</p>
|
|
878
880
|
const files = items.filter((r) => r.type !== 'folder')
|
|
879
881
|
const shownFolders = items.filter((r) => r.type === 'folder')
|
|
880
|
-
if (items.length === 0) return <p className="kol-
|
|
882
|
+
if (items.length === 0) return <p className="kol-mono-12 text-meta">Nothing here.</p>
|
|
881
883
|
return (
|
|
882
884
|
<div className="kol-media-scroll flex flex-col gap-3">
|
|
883
885
|
{shownFolders.length > 0 && (
|
|
@@ -1076,32 +1078,52 @@ function PickerBrowse({ client, accept, onClose, onSelect, title = 'MEDIA', ...b
|
|
|
1076
1078
|
const [settings, setSettings] = useState(() => ({ ...SETTINGS_BASE, columnHeight: `calc(var(--kol-media-picker-h) - ${PICKER_CHROME}px)` }))
|
|
1077
1079
|
const [bucket, setBucket] = useState(browseProps.bucket)
|
|
1078
1080
|
const [file, setFile] = useState(null)
|
|
1079
|
-
const
|
|
1080
|
-
const
|
|
1081
|
-
|
|
1081
|
+
const fits = (f) => !!f && acceptsKind(accept)({ ...f, kind: kindOf(f) })
|
|
1082
|
+
const ok = fits(file)
|
|
1083
|
+
const use = (f = file) => {
|
|
1084
|
+
onSelect?.(client.mediaUrl(f.storageKey ?? f.key, bucket ?? undefined), { contentType: f.contentType, kind: kindOf(f) })
|
|
1082
1085
|
onClose?.()
|
|
1083
1086
|
}
|
|
1087
|
+
/* ON A PHONE THERE IS NO FOOT (user 2026-10-23: *"on mobile you just select the image and maybe dropdown says insert"*):
|
|
1088
|
+
* a tap selects, the row's menu leads with Insert, and the × on the title row is the way out — Escape has no key there */
|
|
1089
|
+
const phone = useMediaQuery('(max-width: 767px)')
|
|
1090
|
+
/* ON A PHONE THE CARD'S BODY SCROLLS (user 2026-10-23: *"media tab doesn't scroll"*): the stack hugs its rows and
|
|
1091
|
+
* expects the PAGE to scroll, as r2b2's does — inside the card, which clips, nothing did, so rows past the fold were
|
|
1092
|
+
* unreachable. The browse page takes the card's remaining height and scrolls, header and all. */
|
|
1084
1093
|
return (
|
|
1085
1094
|
/* NO X (user 2026-10-20: *"at this point just use escape"*). Escape, the backdrop and Cancel close it.
|
|
1086
1095
|
* The X moved three times (overlay corner → title row, 2026-10-10 → beside the gear → corner again)
|
|
1087
1096
|
* and was wrong each time; without it the card's block-start lane goes too (`pt-5`). */
|
|
1088
1097
|
<FullscreenOverlay open scrim onClose={onClose} closeButton={false}>
|
|
1089
1098
|
<div className="kol-media-picker gap-4 pt-5">
|
|
1099
|
+
{/* THE PICKER READS AS THE MEDIA APP (user 2026-10-23, beside kol-r2b2 on a phone): the title in the display voice —
|
|
1100
|
+
* a modal card, not a page of the app, so the shell's masthead does not reach it — and the listing opening at
|
|
1101
|
+
* the title root, the buckets as rows (the database glyph), each with its count. The browse surface's own
|
|
1102
|
+
* `startAtRoot`; one bucket collapses it as ever. */}
|
|
1103
|
+
<MastheadContext.Provider value={null}>
|
|
1090
1104
|
<MediaLibraryBrowse
|
|
1091
1105
|
{...browseProps}
|
|
1092
1106
|
client={client}
|
|
1093
1107
|
title={title}
|
|
1094
1108
|
bucket={bucket}
|
|
1109
|
+
startAtRoot
|
|
1095
1110
|
onBucketChange={(id) => { setBucket(id); browseProps.onBucketChange?.(id) }}
|
|
1096
1111
|
settings={settings}
|
|
1097
1112
|
onSettingsChange={setSettings}
|
|
1098
1113
|
onPickFile={setFile}
|
|
1114
|
+
onHeaderClose={phone ? onClose : undefined}
|
|
1115
|
+
className={phone ? 'min-h-0 flex-1 overflow-y-auto' : browseProps.className}
|
|
1116
|
+
onInsert={phone ? use : undefined}
|
|
1117
|
+
canInsert={fits}
|
|
1099
1118
|
/>
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
<
|
|
1103
|
-
|
|
1104
|
-
|
|
1119
|
+
</MastheadContext.Provider>
|
|
1120
|
+
{!phone && (
|
|
1121
|
+
<div className="mt-auto flex items-center justify-end gap-4">
|
|
1122
|
+
<span className="kol-mono-12 text-fg-48 truncate mr-auto">{file ? file.key : 'Select a file'}</span>
|
|
1123
|
+
<Button tone="grey" size="md" onClick={onClose}>Cancel</Button>
|
|
1124
|
+
<Button size="md" disabled={!ok} onClick={() => use()}>Use</Button>
|
|
1125
|
+
</div>
|
|
1126
|
+
)}
|
|
1105
1127
|
</div>
|
|
1106
1128
|
</FullscreenOverlay>
|
|
1107
1129
|
)
|
|
@@ -1049,6 +1049,10 @@ export function MediaLibraryBrowse({
|
|
|
1049
1049
|
folderTree, headerActions, headerTrailing, refreshKey, onOpen, autoFocus = false, settingsFooter, className = '', banner,
|
|
1050
1050
|
/* `onHeaderClose` — a × alone at the far end of the title row, outside the controls (the picker card) */
|
|
1051
1051
|
onHeaderClose,
|
|
1052
|
+
/* `onInsert(o)` — a file row's menu LEADS with Insert (the picker on a phone, user 2026-10-23: *"you just select the
|
|
1053
|
+
* image and maybe dropdown says insert"*); `canInsert(o)` gates it per file (the picker's `accept`) */
|
|
1054
|
+
onInsert,
|
|
1055
|
+
canInsert,
|
|
1052
1056
|
/* `smartFolder` — a smart folder's id to open ON (a Home tile linking straight to one); the chips
|
|
1053
1057
|
* take over from there (media D1 plan v2) */
|
|
1054
1058
|
smartFolder,
|
|
@@ -1107,6 +1111,8 @@ export function MediaLibraryBrowse({
|
|
|
1107
1111
|
* and returns the list. Rows are the search modal's shape; a row with `run` calls it instead of
|
|
1108
1112
|
* jumping to `id` as a file key. */
|
|
1109
1113
|
searchSuggestions,
|
|
1114
|
+
/* `startAtRoot` — open at the title root, the buckets listed, instead of inside `bucket` (the picker, 2026-10-23) */
|
|
1115
|
+
startAtRoot = false,
|
|
1110
1116
|
/* `bucketLevel` — keep title → bucket → folders with ONE bucket (kol-client-olina 2026-09-23).
|
|
1111
1117
|
* Absent, a one-bucket consumer collapses the level as ruled 2026-09-03. */
|
|
1112
1118
|
bucketLevel = false,
|
|
@@ -1122,7 +1128,7 @@ export function MediaLibraryBrowse({
|
|
|
1122
1128
|
const [ownPrefix, setOwnPrefix] = useState('')
|
|
1123
1129
|
const prefix = prefixProp ?? ownPrefix
|
|
1124
1130
|
const setPrefix = (v) => { if (v) setAppRoot(false); if (prefixProp == null) setOwnPrefix(v); onPrefix?.(v) }
|
|
1125
|
-
const [appRoot, setAppRoot] = useState(
|
|
1131
|
+
const [appRoot, setAppRoot] = useState(!!startAtRoot)
|
|
1126
1132
|
const [ownBucket, setOwnBucket] = useState(bucket)
|
|
1127
1133
|
const bucketId = bucket ?? ownBucket
|
|
1128
1134
|
const lib = useBucketLibrary({ client, bucket: bucketId, defaults, settings: settingsProp, onSettingsChange, refreshKey })
|
|
@@ -1946,6 +1952,17 @@ export function MediaLibraryBrowse({
|
|
|
1946
1952
|
const ROOT = title
|
|
1947
1953
|
const label = bucketMeta.label || 'bucket'
|
|
1948
1954
|
const VROOT = single ? '' : `${ROOT}/${label}/`
|
|
1955
|
+
/* THE PICKER'S TILES AND COUNTS BY DEFAULT (user 2026-10-23, the Hub's Media on a phone beside kol-website's media app:
|
|
1956
|
+
* folders read bare, files drew a kind glyph). A consumer's `thumbnailFor` / `folderMeta` still win; without them an
|
|
1957
|
+
* image file shows itself (the client's URL, lazy) and a folder counts the files under it in the loaded listing. */
|
|
1958
|
+
const thumbOf = thumbnailFor ?? ((o) => (hasUrl && kindOf(o) === 'image'
|
|
1959
|
+
? <img src={mediaUrl(unroot(o.key))} alt="" loading="lazy" decoding="async" className="w-full h-full object-cover" />
|
|
1960
|
+
: null))
|
|
1961
|
+
const metaOf = folderMeta ?? ((path) => {
|
|
1962
|
+
const pre = unroot(path).replace(/\/?$/, '/')
|
|
1963
|
+
const n = objects.filter((o) => o.key.startsWith(pre) && !o.key.endsWith('/')).length
|
|
1964
|
+
return n ? `${n} item${n === 1 ? '' : 's'}` : ''
|
|
1965
|
+
})
|
|
1949
1966
|
const unroot = (p) => (VROOT && p.startsWith(VROOT) ? p.slice(VROOT.length) : p)
|
|
1950
1967
|
/* ONE LEVEL, ONE ANSWER. The column view merges the baked tree with the live partition inside its
|
|
1951
1968
|
* `partition` prop; the row view used the live partition alone and therefore disagreed with the
|
|
@@ -2074,8 +2091,8 @@ export function MediaLibraryBrowse({
|
|
|
2074
2091
|
kindLabel={KIND_LABEL}
|
|
2075
2092
|
formatSize={formatSize}
|
|
2076
2093
|
formatDate={formatDate}
|
|
2077
|
-
thumbnailFor={
|
|
2078
|
-
folderMeta={
|
|
2094
|
+
thumbnailFor={thumbOf}
|
|
2095
|
+
folderMeta={metaOf}
|
|
2079
2096
|
/* the PROP wins when a consumer passes one; otherwise the `···`
|
|
2080
2097
|
owns it through settings (item 15) */
|
|
2081
2098
|
stackView={stackView ?? settings.stackView ?? 'list'}
|
|
@@ -2192,7 +2209,7 @@ export function MediaLibraryBrowse({
|
|
|
2192
2209
|
onContextMenu={(e) => menu.openAt(e, { type: 'folder', path, targets: targetsFor(path) })}
|
|
2193
2210
|
drag={dragFor?.(path)}
|
|
2194
2211
|
dropFiles={dropFilesTo?.(path)}
|
|
2195
|
-
meta={
|
|
2212
|
+
meta={metaOf(path) || undefined}
|
|
2196
2213
|
cols={rowCols}
|
|
2197
2214
|
onToggle={() => toggleRow(path)}
|
|
2198
2215
|
onClick={(e) => { if (!selectRow(path, e, order)) rowPickFolder(path) }}
|
|
@@ -2205,14 +2222,14 @@ export function MediaLibraryBrowse({
|
|
|
2205
2222
|
onOpenFile={(o) => { const lvl = rowLevel(o.key.slice(0, o.key.lastIndexOf('/') + 1), treeObjects).files; openQuickLook({ files: lvl, index: Math.max(0, lvl.findIndex((f) => f.key === o.key)) }) }}
|
|
2206
2223
|
selectRow={selectRow} order={order} selectedKeys={rowSelection}
|
|
2207
2224
|
onRowContextMenu={(e, payload) => menu.openAt(e, payload)} dragFor={dragFor} dropFilesTo={dropFilesTo}
|
|
2208
|
-
formatDate={formatDate} folderMeta={
|
|
2225
|
+
formatDate={formatDate} folderMeta={metaOf} thumbnailFor={thumbOf} cols={rowCols}
|
|
2209
2226
|
pickedKey={pickedFolder ?? pickedFile?.key ?? null} currentKey={prefix}
|
|
2210
2227
|
/>}
|
|
2211
2228
|
</Fragment>
|
|
2212
2229
|
)
|
|
2213
2230
|
})}
|
|
2214
2231
|
{rowLevel('', treeObjects).files.map((o) => (
|
|
2215
|
-
<FileRow key={o.key} o={o} formatDate={formatDate} thumb={
|
|
2232
|
+
<FileRow key={o.key} o={o} formatDate={formatDate} thumb={thumbOf(o)} cols={rowCols}
|
|
2216
2233
|
selected={rowSelection.has(o.key) || pickedFile?.key === o.key}
|
|
2217
2234
|
onDoubleClick={() => { const lvl = rowLevel('', treeObjects).files; openQuickLook({ files: lvl, index: Math.max(0, lvl.findIndex((f) => f.key === o.key)) }) }}
|
|
2218
2235
|
onContextMenu={(e) => menu.openAt(e, { type: 'file', path: o.key, o, targets: targetsFor(o.key) })}
|
|
@@ -2694,8 +2711,15 @@ export function MediaLibraryBrowse({
|
|
|
2694
2711
|
)
|
|
2695
2712
|
}
|
|
2696
2713
|
const qlFile = onPickFile && target.type === 'file' ? objects.find((o) => o.key === target.path) : null
|
|
2714
|
+
const insFile = onInsert && target.type === 'file' ? (objects.find((o) => o.key === target.path) ?? target.o) : null
|
|
2697
2715
|
return (
|
|
2698
2716
|
<>
|
|
2717
|
+
{insFile && (!canInsert || canInsert(insFile)) && (
|
|
2718
|
+
<>
|
|
2719
|
+
<MenuDropdownItem iconLeft={<Icon name="plus" size={14} />} onClick={() => { onInsert(insFile); close() }}>Insert</MenuDropdownItem>
|
|
2720
|
+
<MenuDropdownDivider />
|
|
2721
|
+
</>
|
|
2722
|
+
)}
|
|
2699
2723
|
{/* A PICKER'S TAP SELECTS (`tapSelects`), so Quick Look needs a door of its own on a
|
|
2700
2724
|
* phone — the menu (kol-fxr 2026-10-08). Only with `onPickFile`; others are unchanged. */}
|
|
2701
2725
|
{qlFile && (
|
|
@@ -15,6 +15,7 @@ import useGrabEdge from '../hooks/useGrabEdge.js'
|
|
|
15
15
|
import { Icon } from '@kolkrabbi/kol-icons'
|
|
16
16
|
import Logomark from '../atoms/Logomark.jsx'
|
|
17
17
|
import { useRailSlot } from '../hooks/railSlot.jsx'
|
|
18
|
+
import { RAIL_ROW } from '../hooks/railRow.js'
|
|
18
19
|
import NavRailSite from './NavRailSite.jsx'
|
|
19
20
|
|
|
20
21
|
/**
|
|
@@ -69,8 +70,19 @@ import NavRailSite from './NavRailSite.jsx'
|
|
|
69
70
|
* wrong — arriving on a route reveals nothing, by construction rather than by a
|
|
70
71
|
* flag a consumer has to remember.
|
|
71
72
|
*
|
|
73
|
+
* THE PRESETS (user 2026-10-24: *"the rail, do you make a preset for this? like catalog has preset?"*) — three rails, one
|
|
74
|
+
* name each, in `RAIL_PRESETS` below: `app` is the studio rail (this file's AppRail: the 48px rail that grabs open,
|
|
75
|
+
* sections ENTER and EXPAND, the pill on the phone, Media · Sign in · Settings at the foot); `site` is the brand rail
|
|
76
|
+
* (NavRailSite — brand.kolkrabbi.io); `workshop` is the workshop rail (kol-workshop's ShellSidebar, registered through
|
|
77
|
+
* `registerRailPreset` since kol-component cannot import kol-workshop). AppShell passes the preset and reads its phone
|
|
78
|
+
* shape; an app passes nothing else about the rail.
|
|
79
|
+
*
|
|
80
|
+
* THE WORDS (user 2026-10-24): a section ENTERS (its rows replace the list under a Back row) and EXITS (Back); a section
|
|
81
|
+
* EXPANDS (its rows open under it in place) and COLLAPSES. No other words, in code or docs.
|
|
82
|
+
*
|
|
83
|
+
* @param {'app'|'site'|'workshop'} preset which rail (default `app`); `variant="site"` is the old spelling of `preset="site"`
|
|
72
84
|
* @param {Array} items `{ icon, path, label, sub?: [{ icon?, path, label }] }`
|
|
73
|
-
* a section (`sub`) with `to` is a FOLDER NOTE: its icon and label open `to`, its chevron
|
|
85
|
+
* a section (`sub`) with `to` is a FOLDER NOTE: its icon and label open `to`, its chevron expands or enters
|
|
74
86
|
* @param {Array} bottomItems pinned below the rule (Settings)
|
|
75
87
|
* @param {Object} logomark `{ svgUrl, title }` — the mark, and the app name beside it when open
|
|
76
88
|
* @param {string} currentPath active match: '/' exact, else prefix → aria-current="page"
|
|
@@ -175,12 +187,8 @@ function useRailDrag(railRef, grabRef, onSnap, snapRef, enabled = true) {
|
|
|
175
187
|
/* one row: the rung exactly where the closed rail had it, then the label and
|
|
176
188
|
* (with `sub`) the chevron — the row clips to the rail's width */
|
|
177
189
|
/* the L2 glyph goes through the same injection seam Button gives L1 */
|
|
178
|
-
function IconAt({ name, size, component }) {
|
|
179
|
-
const Cmp = component || Icon
|
|
180
|
-
return <Cmp name={name} size={size} />
|
|
181
|
-
}
|
|
182
190
|
|
|
183
|
-
function RailItem({ icon, path, to, label, sub, currentPath, onNavigate, iconComponent, railOpen, onOpenRail, onEnter }) {
|
|
191
|
+
function RailItem({ icon, path, to, label, sub, currentPath, onNavigate, iconComponent, railOpen, onOpenRail, onEnter, depth = 0 }) {
|
|
184
192
|
const [open, setOpen] = useState(false)
|
|
185
193
|
/* A SECTION ROW IS NOT A DESTINATION (RailSectionPressOpensRail, kol-fxr
|
|
186
194
|
* 2026-08-30 — user: *"if I press effects from collapsed nav it should maybe
|
|
@@ -202,7 +210,7 @@ function RailItem({ icon, path, to, label, sub, currentPath, onNavigate, iconCom
|
|
|
202
210
|
* section's name shut the nav and loaded nothing. */
|
|
203
211
|
/* FOLDER NOTE (2026-10-22, user: "like foldernote in obsidian where a parent/group/folder can
|
|
204
212
|
* also be a note"). Opt-in per section: give it `to` and its icon and label open that page,
|
|
205
|
-
* while the chevron alone
|
|
213
|
+
* while the chevron alone expands or enters — `RailSection`'s `to` split in kol-workshop. A
|
|
206
214
|
* section without `to` is unchanged. */
|
|
207
215
|
const press = () => {
|
|
208
216
|
if (isSection && to) { onNavigate?.(to); return }
|
|
@@ -214,16 +222,20 @@ function RailItem({ icon, path, to, label, sub, currentPath, onNavigate, iconCom
|
|
|
214
222
|
const active = target === '/' ? currentPath === '/' : currentPath.startsWith(target)
|
|
215
223
|
return (
|
|
216
224
|
<>
|
|
217
|
-
|
|
225
|
+
{/* an expanded row is the SAME row as its parent — same glyph, same type, same ink — shifted so its icon starts on
|
|
226
|
+
* the parent's LABEL column (user 2026-10-23: *"same image size same text size but aligned to where the word LABS
|
|
227
|
+
* starts"*): the label sits 44px in (the 32px rung + the 12px gap) and the glyph 6px inside its rung, so one step is 38px — the child's glyph starts on the parent's label column */}
|
|
228
|
+
<div className="flex items-center gap-3 w-full overflow-hidden shrink-0" style={depth ? { paddingLeft: depth * 38 } : undefined}>
|
|
218
229
|
{/* the DS tooltip, not the browser's (the native-title sweep, 2026-09-26) — to the RIGHT,
|
|
219
230
|
* out over the page, since the collapsed rail's glyph is all there is to read */}
|
|
220
231
|
<Tooltip label={label} placement="right" triggerClassName="inline-flex shrink-0">
|
|
221
232
|
<Button
|
|
222
233
|
iconOnly={icon}
|
|
223
|
-
iconSize={
|
|
234
|
+
iconSize={RAIL_ROW.glyph}
|
|
224
235
|
iconComponent={iconComponent}
|
|
225
236
|
variant="nav"
|
|
226
|
-
|
|
237
|
+
/* an expanded row sits on the sm rung (26), the glyph and the type unchanged */
|
|
238
|
+
size={depth ? 'sm' : 'md'}
|
|
227
239
|
className="shrink-0"
|
|
228
240
|
/* nav ACTIVE keys off aria-current="page" (kol-components-atoms.css) —
|
|
229
241
|
* a brighter glyph, never the pressed fill */
|
|
@@ -237,7 +249,7 @@ function RailItem({ icon, path, to, label, sub, currentPath, onNavigate, iconCom
|
|
|
237
249
|
/>
|
|
238
250
|
</Tooltip>
|
|
239
251
|
<span
|
|
240
|
-
className=
|
|
252
|
+
className={`${RAIL_ROW.label} text-oq-96 flex-1 min-w-0 truncate cursor-pointer`}
|
|
241
253
|
onClick={press}
|
|
242
254
|
>
|
|
243
255
|
{label}
|
|
@@ -261,39 +273,18 @@ function RailItem({ icon, path, to, label, sub, currentPath, onNavigate, iconCom
|
|
|
261
273
|
</Tooltip>
|
|
262
274
|
)}
|
|
263
275
|
</div>
|
|
264
|
-
{
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
aria-current={on ? 'page' : undefined}
|
|
277
|
-
>
|
|
278
|
-
{s.icon && (
|
|
279
|
-
<span
|
|
280
|
-
className="w-5 h-5 shrink-0 inline-flex items-center justify-center"
|
|
281
|
-
style={{ color: on ? 'var(--kol-oq-96)' : 'var(--kol-oq-64)' }}
|
|
282
|
-
aria-hidden="true"
|
|
283
|
-
>
|
|
284
|
-
<IconAt name={s.icon} size={12} component={iconComponent} />
|
|
285
|
-
</span>
|
|
286
|
-
)}
|
|
287
|
-
<span
|
|
288
|
-
className="kol-helper-12 uppercase flex-1 min-w-0 truncate"
|
|
289
|
-
style={{ color: on ? 'var(--kol-oq-96)' : 'var(--kol-oq-64)' }}
|
|
290
|
-
>
|
|
291
|
-
{s.label}
|
|
292
|
-
</span>
|
|
293
|
-
</div>
|
|
294
|
-
</Tooltip>
|
|
295
|
-
)
|
|
296
|
-
})}
|
|
276
|
+
{/* EXPAND: the rows open under their section as FULL rows, one label column in (user 2026-10-23 — the 12px glyph,
|
|
277
|
+
* oq-64, 18px-gutter L2 row is retired: *"why are the sub items so small? low opacity?"*). An expanded row may expand
|
|
278
|
+
* again; it recurses. THE EXPANDED ROWS ARE A GROUP (user 2026-10-24: *"should the expanded list not be a little
|
|
279
|
+
* tighter? … I dont see that its a contained group"*): their own container, `.kol-rail-group`, the rows at the sm
|
|
280
|
+
* rung (26) with the same 20 glyph and type, on a 4px gap — against the top level's 32 rows on 8 */}
|
|
281
|
+
{railOpen && open && !onEnter && (
|
|
282
|
+
<div className="kol-rail-group flex w-full flex-col items-start gap-1">
|
|
283
|
+
{sub.map((s) => (
|
|
284
|
+
<RailItem key={s.path} {...s} depth={depth + 1} currentPath={currentPath} onNavigate={onNavigate} iconComponent={iconComponent} railOpen={railOpen} onOpenRail={onOpenRail} />
|
|
285
|
+
))}
|
|
286
|
+
</div>
|
|
287
|
+
)}
|
|
297
288
|
</>
|
|
298
289
|
)
|
|
299
290
|
}
|
|
@@ -304,8 +295,21 @@ function RailItem({ icon, path, to, label, sub, currentPath, onNavigate, iconCom
|
|
|
304
295
|
* renders exactly as before — it takes SideNav's props (`navTree`, `isActive`, `background`,
|
|
305
296
|
* `currentPath`, `onNavigate(event, to)` …). kol-framework's `SideNav` is that variant under the
|
|
306
297
|
* old name, with react-router and the theme toggle wired in. */
|
|
307
|
-
|
|
308
|
-
|
|
298
|
+
/* THE PRESET TABLE — what each named rail is; AppShell reads `phone` for the bar's shape. `workshop` is registered. */
|
|
299
|
+
export const RAIL_PRESETS = {
|
|
300
|
+
app: { sections: 'enter', phone: 'pill', foot: ['media', 'signIn', 'settings'] },
|
|
301
|
+
site: { component: NavRailSite },
|
|
302
|
+
workshop: { component: null },
|
|
303
|
+
}
|
|
304
|
+
/* a package that owns a rail registers it under its name (kol-workshop → `workshop`); the name then renders here */
|
|
305
|
+
export function registerRailPreset(name, Component) { RAIL_PRESETS[name] = { ...(RAIL_PRESETS[name] ?? {}), component: Component } }
|
|
306
|
+
|
|
307
|
+
export default function NavRail({ variant, preset, ...props }) {
|
|
308
|
+
const name = preset ?? (variant === 'site' ? 'site' : 'app')
|
|
309
|
+
if (name === 'app') return <AppRail {...props} sections={props.sections ?? RAIL_PRESETS.app.sections} />
|
|
310
|
+
const Named = RAIL_PRESETS[name]?.component
|
|
311
|
+
if (!Named) { if (import.meta.env?.DEV) console.warn(`NavRail: no rail registered as preset "${name}"`); return null }
|
|
312
|
+
return <Named {...props} />
|
|
309
313
|
}
|
|
310
314
|
|
|
311
315
|
function AppRail({
|
|
@@ -318,17 +322,20 @@ function AppRail({
|
|
|
318
322
|
hidden = false,
|
|
319
323
|
drawer = false,
|
|
320
324
|
fade = true,
|
|
321
|
-
sections = '
|
|
325
|
+
sections = 'expand',
|
|
322
326
|
}) {
|
|
323
327
|
const railRef = useRef(null)
|
|
324
328
|
const grabRef = useRef(null)
|
|
325
329
|
const [railOpen, setRailOpen] = useState(false)
|
|
326
330
|
/* ENTER MODE (`sections="enter"`, 2026-10-06 — the user, on labs: "having a 'enter' mode in the
|
|
327
331
|
* left sidebar instead of collapse folder?"): pressing a section replaces the list with that
|
|
328
|
-
* section's rows under a Back row, instead of
|
|
329
|
-
* every rail had and keeps
|
|
330
|
-
*
|
|
331
|
-
|
|
332
|
+
* section's rows under a Back row, instead of expanding it in place. `expand` is the accordion
|
|
333
|
+
* every rail had and keeps (`fold` was its old spelling and still reads as `expand`).
|
|
334
|
+
* ONE RULE (user 2026-10-24: *"EFFECTS in LABS is supposed to COLLAPSE, thats the last step"*): a section whose rows
|
|
335
|
+
* hold sections of their own ENTERS; a section whose rows are leaves EXPANDS and COLLAPSES in place, its rows the
|
|
336
|
+
* expanded rows above. Chrome enters → Labs enters → Effects expands. `entered` is a PATH STACK; Back EXITS one level,
|
|
337
|
+
* the mark still goes home. */
|
|
338
|
+
const [entered, setEntered] = useState([])
|
|
332
339
|
const snapOpenRef = useRef(null)
|
|
333
340
|
const slotRef = useRef(null)
|
|
334
341
|
const ctx = useRailSlot()
|
|
@@ -342,11 +349,15 @@ function AppRail({
|
|
|
342
349
|
useGrabEdge(grabRef)
|
|
343
350
|
useRailDrag(railRef, grabRef, setRailOpen, snapOpenRef, !drawer)
|
|
344
351
|
if (hidden) return null
|
|
345
|
-
const enterMode = sections === 'enter'
|
|
346
|
-
const
|
|
352
|
+
const enterMode = (sections === 'fold' ? 'expand' : sections) === 'enter'
|
|
353
|
+
const enters = (item) => enterMode && !!item.sub?.some((s) => s.sub?.length > 0)
|
|
354
|
+
/* the entered sections, root first — a stale path (the items changed under it) ends the walk */
|
|
355
|
+
const trail = []
|
|
356
|
+
if (enterMode) for (const p of entered) { const next = (trail.at(-1)?.sub ?? items).find((i) => i.path === p); if (!next) break; trail.push(next) }
|
|
357
|
+
const section = trail.at(-1) ?? null
|
|
347
358
|
const row = (item) => (
|
|
348
359
|
<RailItem key={item.path} {...item} currentPath={currentPath} onNavigate={onNavigate} iconComponent={iconComponent} railOpen={drawer || railOpen} onOpenRail={() => snapOpenRef.current?.()}
|
|
349
|
-
onEnter={
|
|
360
|
+
onEnter={enters(item) ? () => setEntered([item.path]) : undefined} />
|
|
350
361
|
)
|
|
351
362
|
return (
|
|
352
363
|
<div
|
|
@@ -404,8 +415,9 @@ function AppRail({
|
|
|
404
415
|
<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()}>
|
|
405
416
|
{section ? (
|
|
406
417
|
<>
|
|
407
|
-
<RailItem icon="arrow-left" path={section.path} label={section.label} currentPath="" onNavigate={() => setEntered(
|
|
408
|
-
{section.sub.map((s) => <RailItem key={s.path} {...s} currentPath={currentPath} onNavigate={onNavigate} iconComponent={iconComponent} railOpen={drawer || railOpen}
|
|
418
|
+
<RailItem icon="arrow-left" path={section.path} label={section.label} currentPath="" onNavigate={() => setEntered(trail.slice(0, -1).map((t) => t.path))} iconComponent={iconComponent} railOpen={drawer || railOpen} />
|
|
419
|
+
{section.sub.map((s) => <RailItem key={s.path} {...s} currentPath={currentPath} onNavigate={onNavigate} iconComponent={iconComponent} railOpen={drawer || railOpen}
|
|
420
|
+
onEnter={enters(s) ? () => setEntered([...trail.map((t) => t.path), s.path]) : undefined} />)}
|
|
409
421
|
</>
|
|
410
422
|
) : items.map(row)}
|
|
411
423
|
</div>
|
|
@@ -44,6 +44,7 @@ import { Tooltip } from '../utilities/Popover.jsx'
|
|
|
44
44
|
* @param {string} intro a note under the header (the approved drawer passes none)
|
|
45
45
|
* @param {Function} onClose × · scrim · Escape
|
|
46
46
|
* @param {ReactNode} footer the foot slot — `SettingsFooter` is the default shape
|
|
47
|
+
* @param {ReactNode} headerActions controls on the header line, before the × (the file rail's edit pencil, 2026-10-23)
|
|
47
48
|
* @param {ReactNode} children the sections
|
|
48
49
|
*/
|
|
49
50
|
export default function SettingsPanel({
|
|
@@ -55,11 +56,13 @@ export default function SettingsPanel({
|
|
|
55
56
|
intro,
|
|
56
57
|
onClose,
|
|
57
58
|
footer,
|
|
59
|
+
headerActions,
|
|
58
60
|
children,
|
|
59
61
|
className = '',
|
|
60
62
|
}) {
|
|
61
63
|
const header = (
|
|
62
|
-
<div className="flex min-w-0
|
|
64
|
+
<div className="flex min-w-0 items-center gap-2">
|
|
65
|
+
<div className="flex min-w-0 flex-1 flex-col">
|
|
63
66
|
{/* THE APP REGISTER (SettingsPanelChromeAndColumnPreview, kol-r2b2 2026-08-27 —
|
|
64
67
|
* user: "all wrong font styles"): the collection beside the panel is the
|
|
65
68
|
* reference — helper-14 uppercase titles, the eyebrow for section labels,
|
|
@@ -67,6 +70,8 @@ export default function SettingsPanel({
|
|
|
67
70
|
{title && <span className="kol-helper-14 uppercase text-emphasis">{title}</span>}
|
|
68
71
|
{subtitle && <span className="kol-mono-12 text-meta">{subtitle}</span>}
|
|
69
72
|
</div>
|
|
73
|
+
{headerActions}
|
|
74
|
+
</div>
|
|
70
75
|
)
|
|
71
76
|
const body = (
|
|
72
77
|
<>
|
|
@@ -90,7 +95,7 @@ export default function SettingsPanel({
|
|
|
90
95
|
>
|
|
91
96
|
<div className="mb-6 flex items-center gap-4">
|
|
92
97
|
<div className="min-w-0 flex-1">{header}</div>
|
|
93
|
-
<CloseButton onClick={onClose} className="shrink-0" />
|
|
98
|
+
<CloseButton onClick={onClose} hover={false} className="shrink-0" />
|
|
94
99
|
</div>
|
|
95
100
|
<div className="flex flex-col gap-4"><Divider />{body}</div>
|
|
96
101
|
</div>
|
|
@@ -107,7 +112,7 @@ export default function SettingsPanel({
|
|
|
107
112
|
paints `bg-surface-primary`, the same token as the page, so the scrim was
|
|
108
113
|
the only thing separating them — with it off the panel was invisible and
|
|
109
114
|
the controls floated in the right third of the screen. */
|
|
110
|
-
<Rail open={open} onClose={onClose} side="right" width={width} header={header} className={className} edge={false} shadow={false}>
|
|
115
|
+
<Rail open={open} onClose={onClose} side="right" width={width} header={header} className={className} edge={false} shadow={false} closeHover={false}>
|
|
111
116
|
<div className="flex flex-col gap-4"><Divider />{body}</div>
|
|
112
117
|
</Rail>
|
|
113
118
|
)
|
|
@@ -185,7 +190,7 @@ export function LabeledControlSection({ label, divided = false, rowGap = 2, chil
|
|
|
185
190
|
* falls back to primary — the same render wherever there is no wrapper. */
|
|
186
191
|
export function SettingsChoice({ options = [], value, onChange, ariaLabel, tone = 'default', size = 'sm', variant, className = '' }) {
|
|
187
192
|
const opts = options.map((o) => (o != null && typeof o === 'object' ? o : { value: o, label: String(o) }))
|
|
188
|
-
return <Dropdown size={size} variant={variant} tone={tone} value={value} onChange={onChange} options={opts} className={`w-full ${className}`.trim()}
|
|
193
|
+
return <Dropdown size={size} variant={variant} tone={tone} value={value} onChange={onChange} options={opts} className={`w-full ${className}`.trim()} ariaLabel={ariaLabel} />
|
|
189
194
|
}
|
|
190
195
|
|
|
191
196
|
/* THE CONTROL CHIP (SettingsPanelCompliance, user 2026-08-27: "WROOOONG" on the
|
|
@@ -268,15 +273,17 @@ export function SettingsChipRow({ options = [], selected = [], onToggle, allChip
|
|
|
268
273
|
*
|
|
269
274
|
* `gap-2` on the row (user 2026-08-28): `flex justify-end` with no gap is right
|
|
270
275
|
* for one control and wrong for two — the chip and the reset icon touched. */
|
|
271
|
-
export function SettingsFooter({ onReset, resetLabel = 'Reset to defaults', children }) {
|
|
276
|
+
export function SettingsFooter({ onReset, resetLabel = 'Reset to defaults', resetDisabled = false, children }) {
|
|
272
277
|
return (
|
|
273
278
|
<div className="flex flex-col gap-4">
|
|
274
279
|
<Divider />
|
|
275
|
-
<div className="flex justify-end items-center gap-2">
|
|
280
|
+
<div className="kol-ink-step flex justify-end items-center gap-2">
|
|
276
281
|
{children}
|
|
277
|
-
{
|
|
278
|
-
|
|
279
|
-
|
|
282
|
+
{/* `resetDisabled`: the control stays in its place, dimmed and inert — one footer shape on every rail, whether or
|
|
283
|
+
* not the app has preferences to reset yet (user 2026-10-24: *"standardise what goes in"*) */}
|
|
284
|
+
{(onReset || resetDisabled) && (
|
|
285
|
+
<Tooltip label={resetDisabled ? 'Nothing to reset' : resetLabel}>
|
|
286
|
+
<IconFrame name="refresh" variant="nav" size="sm" onClick={resetDisabled ? undefined : onReset} aria-label={resetLabel} aria-disabled={resetDisabled || undefined} className={resetDisabled ? 'opacity-40 pointer-events-none' : ''} />
|
|
280
287
|
</Tooltip>
|
|
281
288
|
)}
|
|
282
289
|
</div>
|
|
@@ -1,4 +1,23 @@
|
|
|
1
|
-
import { LabeledControlSection, SettingsRow } from './SettingsPanel.jsx'
|
|
1
|
+
import { LabeledControlSection, SettingsChoice, SettingsRow, SettingsSwitch } from './SettingsPanel.jsx'
|
|
2
|
+
|
|
3
|
+
/* A STRING VALUE WEARS THE DS'S CLASS (user 2026-10-24, on Mirror's settings rail: *"YOU ARE USING A HELPER text for
|
|
4
|
+
* paragraphs"* — *"THIS SHOULDNT BE POSSIBLE if you were using a preset"*). A consumer that hands rows as data never
|
|
5
|
+
* picks a text class: a plain `value` is drawn in `kol-mono-12 text-body`, the file rail's and the shortcut rows' voice.
|
|
6
|
+
* A node passed as `value` is the consumer's and stays as given. */
|
|
7
|
+
const isText = (v) => typeof v === 'string' || typeof v === 'number'
|
|
8
|
+
const textValue = (v) => <span className="kol-mono-12 text-body">{v}</span>
|
|
9
|
+
/* a section's `note` — a sentence or two under the eyebrow, before the rows (Mirror's Memory, Monitor's Patches): mono-12
|
|
10
|
+
* in the meta ink, the panel's own intro voice. It wraps — the helper law is about helper text, and this is not helper */
|
|
11
|
+
const notes = (note) => (Array.isArray(note) ? note : [note]).map((n, i) => <p key={i} className="kol-mono-12 text-meta">{n}</p>)
|
|
12
|
+
/* the typed controls — the DS's, in the surface's tone; `render` stays the escape hatch for a control the DS has no word for */
|
|
13
|
+
const control = (row) => {
|
|
14
|
+
if (row.type === 'choice') return <SettingsChoice options={row.options ?? []} value={row.value} onChange={row.onChange} ariaLabel={row.ariaLabel ?? (typeof row.label === 'string' ? row.label : undefined)} />
|
|
15
|
+
if (row.type === 'switch') return <SettingsSwitch on={!!row.on} onChange={row.onChange} disabled={row.disabled} disabledHint={row.disabledHint} label={row.ariaLabel ?? (typeof row.label === 'string' ? row.label : undefined)} />
|
|
16
|
+
if (row.render) return row.render()
|
|
17
|
+
return isText(row.value) ? textValue(row.value) : row.value
|
|
18
|
+
}
|
|
19
|
+
/* a typed row's cell: a choice fills the value column, a switch sits at its end, text sits on the baseline */
|
|
20
|
+
const rowAlign = (row, fallback) => row.align ?? (row.type === 'choice' ? 'fill' : fallback)
|
|
2
21
|
|
|
3
22
|
/**
|
|
4
23
|
* SettingsSections — settings rows AS DATA, rendered once.
|
|
@@ -31,11 +50,16 @@ import { LabeledControlSection, SettingsRow } from './SettingsPanel.jsx'
|
|
|
31
50
|
* text (a keyboard combo, a version string), which is what lets the shortcuts
|
|
32
51
|
* sheet and the settings page's shortcut block be the same call.
|
|
33
52
|
*
|
|
53
|
+
* TYPED ROWS (user 2026-10-24, on FXR's rail drawing its own sunken dropdown beside the reference's: *"we are literally
|
|
54
|
+
* avoiding this custom per repo shit"*): a row names its CONTROL as data and this draws it — `{ type: 'choice', options,
|
|
55
|
+
* value, onChange, ariaLabel? }` is a `SettingsChoice`, `{ type: 'switch', on, onChange, disabled?, disabledHint? }` a
|
|
56
|
+
* `SettingsSwitch` — in the surface's tone, never the consumer's. The Hub's rail takes typed rows and refuses `render`.
|
|
57
|
+
*
|
|
34
58
|
* `divided` puts the hairline above a section — pass it on EVERY section, the
|
|
35
59
|
* first included: the rule is `.kol-section--divided + .kol-section--divided`,
|
|
36
60
|
* so the first draws nothing and skipping it just costs the next its line.
|
|
37
61
|
*
|
|
38
|
-
* @param {Array<{label?: string, rows
|
|
62
|
+
* @param {Array<{label?: string, note?: string|string[], rows?: Array<{label: ReactNode, type?: 'choice'|'switch', options?: Array, value?: ReactNode, on?: boolean, onChange?: Function, render?: Function, hint?: string, align?: string, labelWidth?: number|'auto', text?: boolean, id?: string}>, rowGap?: number}>} sections - The settings body, in order (`hint` → SettingsRow's hint; `note` a sentence or two under the eyebrow; a string `value` is drawn in the DS's mono-12 and sits on the baseline; `type: 'choice'` / `'switch'` rows are drawn here)
|
|
39
63
|
* @param {boolean} [divided=false] - Hairline above each section
|
|
40
64
|
* @param {number|'auto'} [labelWidth] - Default label column for every row — `'auto'` makes the label yield and the control hug, which is what a narrow column or a nowrap value needs
|
|
41
65
|
* @param {string} [align] - Default row alignment passed to `SettingsRow`
|
|
@@ -46,16 +70,17 @@ export default function SettingsSections({ sections = [], divided = false, label
|
|
|
46
70
|
<div className={`kol-settings-sections flex flex-col gap-6 ${className}`.trim()}>
|
|
47
71
|
{sections.map((sec, i) => (
|
|
48
72
|
<LabeledControlSection key={sec.label ?? i} label={sec.label} divided={divided} rowGap={sec.rowGap}>
|
|
49
|
-
{sec.
|
|
73
|
+
{sec.note != null && notes(sec.note)}
|
|
74
|
+
{(sec.rows ?? []).map((row, j) => (
|
|
50
75
|
<SettingsRow
|
|
51
76
|
key={row.id ?? row.label ?? j}
|
|
52
77
|
label={row.label}
|
|
53
78
|
hint={row.hint}
|
|
54
|
-
align={row
|
|
79
|
+
align={rowAlign(row, align)}
|
|
55
80
|
labelWidth={row.labelWidth ?? labelWidth}
|
|
56
|
-
text={row.text}
|
|
81
|
+
text={row.text ?? (!row.render && !row.type && isText(row.value))}
|
|
57
82
|
>
|
|
58
|
-
{row
|
|
83
|
+
{control(row)}
|
|
59
84
|
</SettingsRow>
|
|
60
85
|
))}
|
|
61
86
|
</LabeledControlSection>
|