@kolkrabbi/kol-styleguide 0.11.0 → 0.13.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 +4 -4
- package/src/BrandGuide.jsx +7 -4
- package/src/DocumentIndex.jsx +45 -0
- package/src/index.js +2 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kolkrabbi/kol-styleguide",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Brand guide components and the brand tool",
|
|
6
6
|
"license": "MIT",
|
|
@@ -20,10 +20,10 @@
|
|
|
20
20
|
"react-dom": "^18.3.0 || ^19.0.0"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@kolkrabbi/kol-
|
|
23
|
+
"@kolkrabbi/kol-theme": "^0.194.0",
|
|
24
24
|
"@kolkrabbi/kol-component": "^0.307.0",
|
|
25
|
-
"@kolkrabbi/kol-
|
|
26
|
-
"@kolkrabbi/kol-
|
|
25
|
+
"@kolkrabbi/kol-framework": "^0.59.0",
|
|
26
|
+
"@kolkrabbi/kol-icons": "^0.49.0"
|
|
27
27
|
},
|
|
28
28
|
"files": [
|
|
29
29
|
"src",
|
package/src/BrandGuide.jsx
CHANGED
|
@@ -115,13 +115,16 @@ function Spec({ spec }) {
|
|
|
115
115
|
return <Table variant="simple" caption={spec.caption ?? 'Specification'} columns={columns} rows={rows} className="mt-8" />
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
/* The contents: every indexed chapter as a row, its eyebrow carrying the number; grouped by `part` when the list has parts.
|
|
119
|
-
|
|
118
|
+
/* The contents: every indexed chapter as a row, its eyebrow carrying the number; grouped by `part` when the list has parts.
|
|
119
|
+
* A row with `to` is a route, opened through `onNavigate` (a plain link otherwise); without one it is an in-page anchor
|
|
120
|
+
* — apps/document's index reads it this way (plan-2026-10-28-document W3.3). */
|
|
121
|
+
export function Contents({ index, onNavigate }) {
|
|
120
122
|
if (!index.length) return null
|
|
121
123
|
const parts = [...new Set(index.map((s) => s.part ?? ''))]
|
|
124
|
+
const go = (to) => (e) => { if (!onNavigate || e.metaKey || e.ctrlKey || e.shiftKey || e.button !== 0) return; e.preventDefault(); onNavigate(to) }
|
|
122
125
|
const row = (s) => (
|
|
123
|
-
<li key={s.id}>
|
|
124
|
-
<IndexCard href={`#${s.id}`} onClick={scrollToAnchor} label={s.label} title={s.title ?? s.nav} />
|
|
126
|
+
<li key={s.to ?? s.id}>
|
|
127
|
+
<IndexCard href={s.href ?? s.to ?? `#${s.id}`} onClick={s.onClick ?? (s.to ? go(s.to) : scrollToAnchor)} label={s.label} title={s.title ?? s.nav} meta={s.meta} />
|
|
125
128
|
</li>
|
|
126
129
|
)
|
|
127
130
|
return (
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { useState } from 'react'
|
|
2
|
+
import { FullscreenOverlay, KindPreview, PageHeader, QuickLookFrame, KIND_LABEL } from '@kolkrabbi/kol-component'
|
|
3
|
+
import { Contents } from './BrandGuide.jsx'
|
|
4
|
+
|
|
5
|
+
/* DOCUMENT INDEX — a folder's pages as the brand book's contents cards (BrandGuide's `Contents`, routed), grouped by
|
|
6
|
+
* `part` (plan-2026-10-28-document W3.3; home here since W5.2). A compact page header, never a hero: the cards are the page.
|
|
7
|
+
*
|
|
8
|
+
* A FILE IS A CARD TOO (DocumentIndexFilesAndIcons049, kol-website 2026-10-28 — a point of the MarkdownPage ticket: *"a
|
|
9
|
+
* folder may also hold PDFs and images; the contents index lists them beside the md pages and opens them in the DS
|
|
10
|
+
* QuickLook, not as pages"*): a row with `file` sits in its part like a page, its kind on the card's small line, and
|
|
11
|
+
* opens in the DS Quick Look window (`QuickLookFrame` over the dimmed page, `KindPreview` as the body — a PDF page by
|
|
12
|
+
* page, an image at its size), paging through the folder's files with ‹ ›. `documentFiles(glob)` in kol-framework makes
|
|
13
|
+
* the rows.
|
|
14
|
+
*
|
|
15
|
+
* rows [{ id, to, label?, title, part, meta? }] — a page: label is the card's eyebrow (an entry's parent), part the group
|
|
16
|
+
* [{ id, file, title, part, ext?, kind? }] — a file: the served URL; kind from the DS's `kindOf` when not given
|
|
17
|
+
* title · lede the header, when the index is a page of its own (Reviews); a folder's index sits under its document
|
|
18
|
+
* onNavigate(to) the app's router */
|
|
19
|
+
const fileLabel = (r) => KIND_LABEL[r.kind] ?? (r.ext ? r.ext.toUpperCase() : 'File')
|
|
20
|
+
|
|
21
|
+
export default function DocumentIndex({ rows, title, lede, onNavigate }) {
|
|
22
|
+
const files = rows.filter((r) => r.file)
|
|
23
|
+
const [open, setOpen] = useState(null) // index into `files`
|
|
24
|
+
const index = rows.map((r) => (r.file
|
|
25
|
+
? { ...r, href: r.file, meta: r.meta ?? fileLabel(r), onClick: (e) => { if (e.metaKey || e.ctrlKey || e.shiftKey || e.button !== 0) return; e.preventDefault(); setOpen(files.indexOf(r)) } }
|
|
26
|
+
: r))
|
|
27
|
+
const cur = open === null ? null : files[open]
|
|
28
|
+
const step = (d) => setOpen((i) => (i + d + files.length) % files.length)
|
|
29
|
+
return (
|
|
30
|
+
<div className="kol-page flex flex-col gap-6">
|
|
31
|
+
{title && <PageHeader title={title} subtitle={lede} size="sm" voice="mono" />}
|
|
32
|
+
<Contents index={index} onNavigate={onNavigate} />
|
|
33
|
+
{cur && (
|
|
34
|
+
/* QUICK LOOK DIMS, it does not black out — the list stays in view (MediaLibraryPages' rule) */
|
|
35
|
+
<FullscreenOverlay open onClose={() => setOpen(null)} closeButton={false} scrim>
|
|
36
|
+
<QuickLookFrame title={cur.title} meta={fileLabel(cur)} onClose={() => setOpen(null)} nav={files.length > 1 ? { index: open, total: files.length, onPrev: () => step(-1), onNext: () => step(1) } : undefined}>
|
|
37
|
+
{cur.kind === 'image' || /^(png|jpe?g|webp|gif|svg|avif)$/i.test(cur.ext ?? '')
|
|
38
|
+
? <img src={cur.file} alt={cur.title} className="kol-quicklook-media" />
|
|
39
|
+
: <KindPreview key={cur.file} o={{ key: cur.file.split('?')[0], url: cur.file }} fit="sheet" urlOf={(x) => x.url} />}
|
|
40
|
+
</QuickLookFrame>
|
|
41
|
+
</FullscreenOverlay>
|
|
42
|
+
)}
|
|
43
|
+
</div>
|
|
44
|
+
)
|
|
45
|
+
}
|
package/src/index.js
CHANGED
|
@@ -25,6 +25,8 @@ export { generatePalette, fgOn, hexToHsl, hslToHex, GENERATION_MODES } from './c
|
|
|
25
25
|
// The brand-book set the two brand apps were both maintaining locally
|
|
26
26
|
// (brand-book-mocks-two-consumers, 2026-09-03).
|
|
27
27
|
export { default as AssetCard } from './AssetCard.jsx'
|
|
28
|
+
/* a folder's pages as the brand book's contents cards (plan-2026-10-28-document W5.2) */
|
|
29
|
+
export { default as DocumentIndex } from './DocumentIndex.jsx'
|
|
28
30
|
export { default as Swatch } from './Swatch.jsx'
|
|
29
31
|
export {
|
|
30
32
|
PostPhoto, PostType, PostProduct, PostEditorial, StoryPhoto, StoryType, BrandAvatar, ProfileAvatar,
|