@kolkrabbi/kol-component 0.350.0 → 0.351.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-component",
3
- "version": "0.350.0",
3
+ "version": "0.351.0",
4
4
  "description": "The core component library",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -32,9 +32,9 @@
32
32
  "embla-carousel-react": "^8.6.0",
33
33
  "pdfjs-dist": "^6.3.289",
34
34
  "react-syntax-highlighter": "^16.1.1",
35
- "@kolkrabbi/kol-search": "^0.3.0",
35
+ "@kolkrabbi/kol-markdown": "^0.2.0",
36
36
  "@kolkrabbi/kol-growth": "^0.5.0",
37
- "@kolkrabbi/kol-markdown": "^0.2.0"
37
+ "@kolkrabbi/kol-search": "^0.3.0"
38
38
  },
39
39
  "peerDependencies": {
40
40
  "@kolkrabbi/kol-icons": ">=0.61.1",
package/src/index.js CHANGED
@@ -159,6 +159,7 @@ export { default as TextFold } from './molecules/TextFold.jsx'
159
159
  export { default as PageControls } from './molecules/PageControls.jsx'
160
160
  export { default as ColorSwatch } from './molecules/ColorSwatch.jsx'
161
161
  export { default as SwatchTile } from './molecules/SwatchTile.jsx'
162
+ export { default as SwatchCaption } from './molecules/SwatchCaption.jsx'
162
163
  export { default as Dropdown } from './molecules/Dropdown.jsx'
163
164
  /* MultiSelect — several pick-one settings in one dropdown, a column each (2026-10-01, first cut) */
164
165
  export { default as MultiSelect } from './molecules/MultiSelect.jsx'
@@ -0,0 +1,61 @@
1
+ /**
2
+ * SwatchCaption — The name, value and meta lines under a swatch. the text block of the SWATCH family
3
+ * (SwatchTile renders it for every size, 2026-11-08), as ContentText / SectionText are for theirs: slots
4
+ * opt-in, type by ROLE, every default class a SEAM. It renders siblings (a fragment), so the parent owns the
5
+ * gap and the alignment — SwatchTile wraps it where a form needs a box.
6
+ *
7
+ * layout 'inline' — name and value share one baseline row, space-between, wrapping; meta under it (the tile)
8
+ * layout 'stacked' — name, value, meta one under the other
9
+ * tone 'muted' — name quiet (text-meta), value strong semibold (the tile, the fixed chip)
10
+ * tone 'strong' — name emphasised, value quiet, both truncating and always drawn so a grid cell keeps its
11
+ * lines (the grid cell)
12
+ *
13
+ * @param {ReactNode} name - The label
14
+ * @param {ReactNode} value - The printed value
15
+ * @param {ReactNode} meta - Optional third line, e.g. the token name
16
+ * @param {'inline'|'stacked'} layout - default 'stacked'
17
+ * @param {'muted'|'strong'} tone - default 'muted'
18
+ * @param {string} rowClass - Replaces the inline row's classes whole (inline only)
19
+ * @param {string} nameClass - Replaces the name's classes whole
20
+ * @param {string} valueClass - Replaces the value's classes whole
21
+ * @param {string} metaClass - Replaces the meta line's classes whole
22
+ */
23
+ export default function SwatchCaption({
24
+ name,
25
+ value,
26
+ meta,
27
+ layout = 'stacked',
28
+ tone = 'muted',
29
+ rowClass,
30
+ nameClass,
31
+ valueClass,
32
+ metaClass = 'kol-helper-10 text-meta',
33
+ }) {
34
+ const strong = tone === 'strong'
35
+ const inline = layout === 'inline'
36
+ const nc = nameClass ?? (inline ? 'text-meta' : strong ? 'kol-helper-10 text-emphasis max-w-full truncate' : 'kol-helper-10 text-meta')
37
+ const vc = valueClass ?? (inline ? 'text-strong font-semibold' : strong ? 'kol-helper-10 text-meta max-w-full truncate' : 'kol-helper-10 text-strong font-semibold')
38
+ const metaLine = meta && <span className={metaClass}>{meta}</span>
39
+
40
+ if (inline) return (
41
+ <>
42
+ {/* .kol-swatch-meta: row, space-between, baseline, wrapping */}
43
+ <div
44
+ className={rowClass ?? 'kol-helper-10 flex flex-row flex-wrap items-baseline justify-between'}
45
+ style={{ gap: '4px 12px' }}
46
+ >
47
+ {name && <span className={nc}>{name}</span>}
48
+ {value && <span className={vc}>{value}</span>}
49
+ </div>
50
+ {metaLine}
51
+ </>
52
+ )
53
+
54
+ return (
55
+ <>
56
+ {strong || name ? <span className={nc}>{name}</span> : null}
57
+ {strong || value ? <span className={vc}>{value}</span> : null}
58
+ {metaLine}
59
+ </>
60
+ )
61
+ }
@@ -1,4 +1,5 @@
1
1
  import ColorSwatch from './ColorSwatch.jsx'
2
+ import SwatchCaption from './SwatchCaption.jsx'
2
3
  import { isLight } from '../hooks/cssVar.js'
3
4
 
4
5
  /**
@@ -16,7 +17,7 @@ import { isLight } from '../hooks/cssVar.js'
16
17
  * <SwatchTile hex="#131316" name="Ink" anchor />
17
18
  *
18
19
  * @param {string} hex - The paint — any CSS color, `var(--token)` included
19
- * @param {ReactNode} name - The label
20
+ * @param {ReactNode} name - The label (the caption is SwatchCaption)
20
21
  * @param {ReactNode} meta - Optional third line, e.g. the token name
21
22
  * @param {ReactNode} value - The printed value (default: `hex` uppercased); null hides it
22
23
  * @param {'tile'|'grid'|number} size - The form (default 'tile')
@@ -43,7 +44,6 @@ export default function SwatchTile({
43
44
  className = '',
44
45
  }) {
45
46
  const chip = { hex, selected, onClick, title, radius: 'sm', className: chipClassName }
46
- const metaLine = meta && <span className="kol-helper-10 text-meta">{meta}</span>
47
47
 
48
48
  if (size === 'grid') return (
49
49
  <div className={`flex min-w-0 flex-col gap-1.5 ${className}`.trim()}>
@@ -56,9 +56,7 @@ export default function SwatchTile({
56
56
  )}
57
57
  </div>
58
58
  <div className="flex min-w-0 flex-col items-start gap-0.5 leading-tight">
59
- <span className="kol-helper-10 text-emphasis max-w-full truncate">{name}{anchor && ' ★'}</span>
60
- <span className="kol-helper-10 text-meta max-w-full truncate">{value}</span>
61
- {metaLine}
59
+ <SwatchCaption name={<>{name}{anchor && ' ★'}</>} value={value} meta={meta} tone="strong" />
62
60
  </div>
63
61
  </div>
64
62
  )
@@ -66,9 +64,7 @@ export default function SwatchTile({
66
64
  if (typeof size === 'number') return (
67
65
  <div className={`flex flex-col items-start gap-1.5 ${className}`.trim()}>
68
66
  <ColorSwatch {...chip} size={size} />
69
- {name && <span className="kol-helper-10 text-meta">{name}</span>}
70
- {value && <span className="kol-helper-10 text-strong font-semibold">{value}</span>}
71
- {metaLine}
67
+ <SwatchCaption name={name} value={value} meta={meta} />
72
68
  </div>
73
69
  )
74
70
 
@@ -91,15 +87,7 @@ export default function SwatchTile({
91
87
  </span>
92
88
  )}
93
89
  </div>
94
- {/* .kol-swatch-meta: row, space-between, baseline, wrapping */}
95
- <div
96
- className="kol-helper-10 flex flex-row flex-wrap items-baseline justify-between"
97
- style={{ gap: '4px 12px' }}
98
- >
99
- {name && <span className="text-meta">{name}</span>}
100
- {value && <span className="text-strong font-semibold">{value}</span>}
101
- </div>
102
- {metaLine}
90
+ <SwatchCaption name={name} value={value} meta={meta} layout="inline" />
103
91
  </div>
104
92
  )
105
93
  }