@kolkrabbi/kol-component 0.378.0 → 0.380.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 -4
- package/src/atoms/Badge.jsx +1 -5
- package/src/atoms/BezierPathEditor.jsx +1 -1
- package/src/atoms/Button.jsx +88 -12
- package/src/atoms/Figure.jsx +19 -1
- package/src/atoms/FunctionPlot.jsx +1 -1
- package/src/atoms/Input.jsx +107 -7
- package/src/atoms/Kbd.jsx +42 -2
- package/src/atoms/Link.jsx +20 -0
- package/src/atoms/OriginPicker.jsx +9 -5
- package/src/atoms/Pill.jsx +1 -3
- package/src/atoms/ProgressBar.jsx +3 -6
- package/src/atoms/SectionFooter.jsx +22 -0
- package/src/atoms/SectionHeader.jsx +24 -0
- package/src/atoms/SectionLabel.jsx +0 -22
- package/src/atoms/SizeOrDownload.jsx +1 -1
- package/src/atoms/Tag.jsx +4 -7
- package/src/atoms/Textarea.jsx +12 -7
- package/src/atoms/ToggleCheckbox.jsx +25 -5
- package/src/atoms/ToggleSwitch.jsx +41 -7
- package/src/atoms/ViewToggle.jsx +2 -29
- package/src/atoms/XYPad.jsx +25 -0
- package/src/hooks/useDragResize.js +1 -1
- package/src/index.js +26 -4
- package/src/molecules/AccountMenu.jsx +16 -3
- package/src/molecules/AlignmentGrid.jsx +13 -1
- package/src/molecules/ButtonGroup.jsx +78 -15
- package/src/molecules/ButtonSplit.jsx +75 -28
- package/src/molecules/Chip.jsx +26 -0
- package/src/molecules/CodeBlock.jsx +39 -2
- package/src/molecules/ColorInputRow.jsx +125 -4
- package/src/molecules/ColorSwatch.jsx +43 -2
- package/src/molecules/ContentCard.jsx +104 -3
- package/src/molecules/ContentMedia.jsx +1 -1
- package/src/molecules/ContentRow.jsx +4 -32
- package/src/molecules/ContextMenu.jsx +0 -1
- package/src/molecules/DividerLabel.jsx +19 -0
- package/src/molecules/DocsToc.jsx +1 -16
- package/src/molecules/Dropdown.jsx +115 -18
- package/src/molecules/DropdownStepper.jsx +29 -0
- package/src/molecules/EmptyState.jsx +1 -15
- package/src/molecules/FieldPair.jsx +41 -2
- package/src/molecules/Header.jsx +4 -4
- package/src/molecules/IndexRow.jsx +1 -1
- package/src/molecules/InlineAddRow.jsx +2 -2
- package/src/molecules/LabeledControl.jsx +56 -11
- package/src/molecules/LayerRow.jsx +1 -1
- package/src/molecules/LinkAddRow.jsx +5 -7
- package/src/molecules/Menu.jsx +250 -33
- package/src/molecules/MenuFloat.jsx +6 -12
- package/src/molecules/MenuList.jsx +5 -11
- package/src/molecules/Modal.jsx +228 -55
- package/src/molecules/ModalHeader.jsx +12 -20
- package/src/molecules/ModalShell.jsx +20 -10
- package/src/molecules/NoticeBanner.jsx +1 -1
- package/src/molecules/OptionRow.jsx +1 -1
- package/src/molecules/PanelsMenu.jsx +2 -2
- package/src/molecules/ParamBindDot.jsx +29 -2
- package/src/molecules/PasswordInput.jsx +1 -1
- package/src/molecules/QuantityInput.jsx +45 -13
- package/src/molecules/QuickLookFrame.jsx +2 -31
- package/src/molecules/RailHeader.jsx +37 -16
- package/src/molecules/ReadingActions.jsx +2 -2
- package/src/molecules/ReadingNotes.jsx +3 -3
- package/src/molecules/ReadingSettings.jsx +8 -8
- package/src/molecules/SearchInput.jsx +4 -5
- package/src/molecules/SectionText.jsx +56 -10
- package/src/molecules/SettingsControls.jsx +23 -23
- package/src/molecules/Slider.jsx +103 -55
- package/src/molecules/SpecList.jsx +1 -21
- package/src/molecules/SplitToolButton.jsx +4 -6
- package/src/molecules/SwatchControls.jsx +28 -0
- package/src/molecules/SwatchGrid.jsx +39 -0
- package/src/molecules/TabsDocument.jsx +131 -0
- package/src/molecules/TabsRow.jsx +40 -50
- package/src/molecules/TaskRow.jsx +2 -2
- package/src/molecules/Toast.jsx +55 -0
- package/src/molecules/TocRow.jsx +1 -1
- package/src/molecules/TreeRow.jsx +87 -1
- package/src/molecules/WorkspaceSwitcher.jsx +3 -6
- package/src/organisms/AppItemMenuProvider.jsx +2 -2
- package/src/organisms/ColorPickerPopover.jsx +133 -4
- package/src/organisms/ColumnBrowser.jsx +1 -1
- package/src/organisms/CommandOverlay.jsx +362 -87
- package/src/organisms/ContentFilters.jsx +4 -12
- package/src/organisms/FindBar.jsx +70 -0
- package/src/organisms/FramedMediaBand.jsx +2 -2
- package/src/organisms/GalleryCarousel.jsx +1 -1
- package/src/organisms/LogoSystem.jsx +38 -0
- package/src/organisms/LogoTuner.jsx +32 -0
- package/src/organisms/MediaLibrary.jsx +1 -56
- package/src/organisms/MediaLibraryPages.jsx +1 -1
- package/src/organisms/NavRail.jsx +1 -4
- package/src/organisms/Rail.jsx +33 -1
- package/src/organisms/RailSwitcher.jsx +62 -0
- package/src/organisms/ReadingContents.jsx +65 -3
- package/src/organisms/ReadingOverview.jsx +5 -5
- package/src/organisms/ReadingPanel.jsx +1 -1
- package/src/organisms/SectionSplit.jsx +1 -1
- package/src/organisms/SettingsPanel.jsx +64 -41
- package/src/organisms/ShortcutsOverlay.jsx +46 -2
- package/src/organisms/SpectrumControls.jsx +112 -19
- package/src/organisms/StatusBar.jsx +30 -0
- package/src/organisms/Table.jsx +136 -45
- package/src/organisms/TimelineDock.jsx +281 -1
- package/src/organisms/logoBoard.jsx +61 -0
- package/src/utilities/AssetPlaceholder.jsx +1 -1
- package/src/utilities/EditorShell.jsx +42 -1
- package/src/utilities/OverlayGlassPanel.jsx +1 -1
- package/src/utilities/Popover.jsx +299 -5
- package/src/utilities/SelectionOverlay.jsx +60 -31
- package/src/utilities/kolboxGlyph.jsx +10 -0
- package/src/molecules/FloatModuleHeader.jsx +0 -11
- package/src/organisms/NavRailFloat.jsx +0 -139
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* ButtonGroup — the one component for a group of buttons (plan-2026-11-06-buttons-page 2.7; the user,
|
|
3
3
|
* 2026-11-06: *"button group CAN be segmented toggle … just by the fact it wraps multiple buttons"*).
|
|
4
|
-
*
|
|
4
|
+
* Five layouts:
|
|
5
5
|
*
|
|
6
6
|
* layout="row" (default) — a responsive layout wrapper for a group of Buttons: stacked full-width on
|
|
7
7
|
* mobile, a horizontal row from `sm` up, aligned left / center / right. Pure layout —
|
|
@@ -13,11 +13,15 @@
|
|
|
13
13
|
* layout="stack" — the same wrapper, stacked at every width (the row's 8 stacked gap).
|
|
14
14
|
* layout="joined" — the segmented control (was `SegmentedToggle`, kept as its alias on the retirement
|
|
15
15
|
* ledger): joined cells, no gap, built from `options` instead of children. See below.
|
|
16
|
+
* layout="wrap" — the buttons 8 apart in a row that wraps to the next line when its column runs out, full
|
|
17
|
+
* width (kolbox's rail rows, plan-2026-11-18-kolbox-system W31.2, 2026-11-18).
|
|
18
|
+
* layout="grid" — two equal columns 8 apart, full width, so the longest label fits a narrow rail (kolbox's
|
|
19
|
+
* Rolls and randomise rows). wrap and grid take no `align` or `title`; other props land on the box.
|
|
16
20
|
*
|
|
17
21
|
* row / stack props:
|
|
18
22
|
* @param {'left'|'center'|'right'|'between'} align horizontal alignment + container layout mode (default 'center'); `between`
|
|
19
|
-
* (2026-11-12, plan-2026-11-12-one-header W6.1) sets the first button at the left and the last at the right — a
|
|
20
|
-
*
|
|
23
|
+
* (2026-11-12, plan-2026-11-12-one-header W6.1) sets the first button at the left and the last at the right — a window's
|
|
24
|
+
* Cancel · Export row
|
|
21
25
|
* @param {string} title optional heading rendered above the group, authored at the call site
|
|
22
26
|
* @param {string} className extra container classes (appended) — note this lands on the OUTER
|
|
23
27
|
* container, not the flex row that carries the gap; the gap is responsive by default (8 stacked,
|
|
@@ -53,10 +57,8 @@
|
|
|
53
57
|
* strip (canvas alignment, transform cluster); onChange is the
|
|
54
58
|
* action dispatch.
|
|
55
59
|
* onChange — handler (newValue) => void
|
|
56
|
-
* options — [{ value, label, ariaLabel?, tooltip?, disabled
|
|
60
|
+
* options — [{ value, label, ariaLabel?, tooltip?, disabled? }] — a cell whose label is not a string
|
|
57
61
|
* (a glyph) shows its `ariaLabel` as a KOL Tooltip; `tooltip` overrides it.
|
|
58
|
-
* `count` (float-everything W2 row 26, 2026-11-04): a number after the label, mono one step down,
|
|
59
|
-
* 12 off the label — `Open 5`; drawn on `variant="float"` (`.kol-seg-count`), ignored elsewhere.
|
|
60
62
|
* `disabled` (kol-fxr 2026-10-09): the cell draws the family's disabled ink
|
|
61
63
|
* (`aria-disabled`, not the attribute — the tooltip still gives the reason),
|
|
62
64
|
* refuses the press, and ←/→ step over it. It may still be the current `value`
|
|
@@ -70,8 +72,6 @@
|
|
|
70
72
|
* outline shell; the inset ring marks ONLY the selected cell) |
|
|
71
73
|
* 'tonal' (filled tiles, but the clicked cell marks itself by
|
|
72
74
|
* TONE — surface-tertiary fill, no ring; 2026-08-12).
|
|
73
|
-
* 'float' (W16, round 3 — 2026-10-31): a capsule track 6 in on its `surface`, pills 4 apart at the
|
|
74
|
-
* float heights (28/36/44, touch 36/44/52), the selected pill filled with the ink.
|
|
75
75
|
* Every other variant renders at the SAME pinned button-ladder
|
|
76
76
|
* height (22/26/32/40) — icon or text, the box never moves.
|
|
77
77
|
* size — mirrors Button exactly: 'sm' (26px, mono-12, 4/12 pad) |
|
|
@@ -85,13 +85,18 @@
|
|
|
85
85
|
* selected cell on `--kol-surface-sunken` / `fg-96`, rest cells as the default paints
|
|
86
86
|
* them; `filled` and `tonal` keep their own selected law. Through `toneClass`, so a
|
|
87
87
|
* `kol-tone-sunken` wrapper reaches it too. Unset = inherit.
|
|
88
|
-
* surface — `variant="float"` only: 'solid' (default) | 'glass-dark' | 'glass-light' — the track's material
|
|
89
|
-
* (`floatSurfaceClass`, kol-theme `.kol-float-*`)
|
|
90
88
|
* ariaLabel — accessible name for the group
|
|
91
89
|
* className — additional classes on the outer shell
|
|
90
|
+
* variant="kolbox" — kolbox's icon group (W31.2 batch 3): `options` `[{ icon, ariaLabel, pressed, onPress }]`, each its
|
|
91
|
+
* own action; `tone` unset (cells) or `sunken` (the track). With `value` (Folio on kolbox, 2026-11-22) kolbox's
|
|
92
|
+
* choice that stays, its tab track: `options` `[{ value, label }]`, the picked cell lit, aria-pressed
|
|
93
|
+
* variant="folio" — Folio's (batch A, 2026-11-22), by the state law: with `value` its segmented choice (`options`
|
|
94
|
+
* `[{ value, label }]`, the picked cell lit, aria-pressed); without, its tool icons joined (`options`
|
|
95
|
+
* `[{ icon, ariaLabel, pressed, onPress }]`)
|
|
92
96
|
*/
|
|
93
|
-
import { toneClass
|
|
97
|
+
import { toneClass } from '../utilities/tone.js'
|
|
94
98
|
import { Tooltip } from '../utilities/Popover.jsx'
|
|
99
|
+
import Button from '../atoms/Button.jsx'
|
|
95
100
|
|
|
96
101
|
const CONTAINER = {
|
|
97
102
|
left: 'flex flex-col w-full',
|
|
@@ -109,6 +114,9 @@ const JUSTIFY = {
|
|
|
109
114
|
|
|
110
115
|
export default function ButtonGroup({ layout = 'row', align = 'center', title, className = '', children, ...joined }) {
|
|
111
116
|
if (layout === 'joined') return <Joined className={className} {...joined} />
|
|
117
|
+
if (layout === 'wrap' || layout === 'grid') {
|
|
118
|
+
return <div className={`${layout === 'grid' ? 'grid grid-cols-2' : 'flex flex-wrap items-center'} w-full min-w-0 gap-2 ${className}`.trim()} {...joined}>{children}</div>
|
|
119
|
+
}
|
|
112
120
|
return (
|
|
113
121
|
<div className={[CONTAINER[align] || CONTAINER.center, className].filter(Boolean).join(' ')}>
|
|
114
122
|
{title && <h3 className="kol-sans-heading-05 text-emphasis mb-6">{title}</h3>}
|
|
@@ -134,9 +142,66 @@ export default function ButtonGroup({ layout = 'row', align = 'center', title, c
|
|
|
134
142
|
)
|
|
135
143
|
}
|
|
136
144
|
|
|
145
|
+
/* layout="joined" variant="kolbox" (plan-2026-11-18-kolbox-system W31.2 batch 3, 2026-11-18): kolbox's IconGroup carried
|
|
146
|
+
* class for class. Each option is its own action, a kolbox icon Button (`{ icon, ariaLabel, pressed, onPress }`): no
|
|
147
|
+
* `value`, every option lights by its own `pressed`. Unset tone: each glyph in its own oq-16 cell, 1px apart so the
|
|
148
|
+
* ground shows between them, radius 4 on the group's outer corners only, a pressed cell the accent tint. `tone="sunken"`:
|
|
149
|
+
* Home's view switch, square cells the group's height (24, Figma's view toggles measured, plan-2026-11-23-editor-measured-
|
|
150
|
+
* against-figma W7), side by side on the ground, the pressed cell (aria-pressed only) the oq-16 field
|
|
151
|
+
* with its glyph in the ink, the others bare. Chrome in kol-theme `.kol-btn-group--kolbox`. */
|
|
152
|
+
function JoinedKolbox({ options, tone, className }) {
|
|
153
|
+
const sunken = tone === 'sunken'
|
|
154
|
+
return (
|
|
155
|
+
<div className={`kol-btn-group--kolbox${sunken ? ' kol-btn-group--kolbox-sunken' : ' gap-px overflow-hidden'} inline-flex h-(--kol-kolbox-ctl) shrink-0 ${className}`}>
|
|
156
|
+
{options.map(({ icon, ariaLabel, pressed, onPress }) => (sunken
|
|
157
|
+
? <Button key={ariaLabel} variant="kolbox" iconOnly={icon} aria-label={ariaLabel} aria-pressed={!!pressed} onClick={onPress} className="aspect-square h-full! w-auto!" />
|
|
158
|
+
: <Button key={ariaLabel} variant="kolbox" iconOnly={icon} aria-label={ariaLabel} pressed={pressed} onClick={onPress} className="flex-1 rounded-none" />))}
|
|
159
|
+
</div>
|
|
160
|
+
)
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/* layout="joined" variant="folio" (Folio migration batch A, 2026-11-22): Folio's two joined parts, split by the segmented
|
|
164
|
+
* state law. With a `value` it is Folio's Seg (apps/folio Chrome.jsx), a choice that stays: 32 high, radius 4, the rule
|
|
165
|
+
* line round equal cells padded 16, the picked one the accent's soft ground and strong ink (aria-pressed, as Folio's),
|
|
166
|
+
* the rest muted, the ink on hover. Stateless it is Folio's ToolGroup (EditorChrome.jsx): Folio's tool icons side by side,
|
|
167
|
+
* no gap, `options` `[{ icon, ariaLabel, pressed, onPress }]`, each its own action. Chrome in kol-theme
|
|
168
|
+
* `.kol-btn-group--folio`. */
|
|
169
|
+
function JoinedFolio({ value, onChange, options, ariaLabel, className }) {
|
|
170
|
+
if (value == null) {
|
|
171
|
+
return (
|
|
172
|
+
<span role="group" aria-label={ariaLabel} className={`flex shrink-0 items-center ${className}`.trim()}>
|
|
173
|
+
{options.map(({ icon, ariaLabel: name, pressed, onPress }) => <Button key={name} variant="folio" iconOnly={icon} aria-label={name} pressed={pressed} onClick={onPress} />)}
|
|
174
|
+
</span>
|
|
175
|
+
)
|
|
176
|
+
}
|
|
177
|
+
return (
|
|
178
|
+
<div role="group" aria-label={ariaLabel} className={`kol-btn-group--folio flex h-[32px] overflow-hidden rounded-[4px] border ${className}`.trim()}>
|
|
179
|
+
{options.map((opt) => (
|
|
180
|
+
<button key={opt.value} type="button" aria-pressed={value === opt.value} onClick={() => onChange?.(opt.value)} className="kol-btn-group-cell flex-1 whitespace-nowrap px-[16px]">{opt.label}</button>
|
|
181
|
+
))}
|
|
182
|
+
</div>
|
|
183
|
+
)
|
|
184
|
+
}
|
|
185
|
+
/* layout="joined" variant="kolbox" with a `value` (Folio on kolbox, 2026-11-22): kolbox's choice that stays (Off and On,
|
|
186
|
+
* Miter, Round and Bevel) is its tab track, so this draws TabsRow kolbox sm's track and cells (its chrome,
|
|
187
|
+
* `.kol-tabs--kolbox-sm`, kol-components-molecules.css) as a group: `options` `[{ value, label }]`, the picked cell lit and
|
|
188
|
+
* aria-pressed, `ariaLabel` names it. */
|
|
189
|
+
function JoinedKolboxChoice({ value, onChange, options, ariaLabel, className }) {
|
|
190
|
+
return (
|
|
191
|
+
<div role="group" aria-label={ariaLabel} className={`kol-tabs--kolbox kol-tabs--kolbox-sm inline-flex h-(--kol-kolbox-ctl) items-center gap-px p-0.5 ${className}`.trim()}>
|
|
192
|
+
{options.map((opt) => (
|
|
193
|
+
<button key={opt.value} type="button" aria-pressed={opt.value === value} disabled={opt.disabled} onClick={() => onChange?.(opt.value)}
|
|
194
|
+
className={`kol-tabs-tab${opt.value === value ? ' is-active' : ''} flex h-full min-w-0 flex-1 items-center justify-center px-3 whitespace-nowrap outline-none focus-visible:outline-solid focus-visible:outline-1 disabled:opacity-40`}>{opt.label}</button>
|
|
195
|
+
))}
|
|
196
|
+
</div>
|
|
197
|
+
)
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
|
|
137
201
|
/* layout="joined" — the segmented control (SegmentedToggle's implementation, moved here 2026-11-06) */
|
|
138
|
-
function Joined({ value, onChange, options = [], variant = 'default', size = 'md', tone = 'default',
|
|
139
|
-
|
|
202
|
+
function Joined({ value, onChange, options = [], variant = 'default', size = 'md', tone = 'default', ariaLabel, className = '' }) {
|
|
203
|
+
if (variant === 'kolbox') return value == null ? <JoinedKolbox options={options} tone={tone} className={className} /> : <JoinedKolboxChoice value={value} onChange={onChange} options={options} ariaLabel={ariaLabel} className={className} />
|
|
204
|
+
if (variant === 'folio') return <JoinedFolio value={value} onChange={onChange} options={options} ariaLabel={ariaLabel} className={className} />
|
|
140
205
|
const cellType = { xs: 'kol-mono-8', sm: 'kol-mono-12', md: 'kol-mono-14', lg: 'kol-mono-16' }[size]
|
|
141
206
|
const stateless = value == null
|
|
142
207
|
const focusIdx = Math.max(0, options.findIndex((opt) => opt.value === value))
|
|
@@ -168,7 +233,6 @@ function Joined({ value, onChange, options = [], variant = 'default', size = 'md
|
|
|
168
233
|
(variant === 'filled' || variant === 'tonal') && 'kol-seg--filled',
|
|
169
234
|
variant === 'tonal' && 'kol-seg--tonal',
|
|
170
235
|
size !== 'md' && `kol-seg--${size}`,
|
|
171
|
-
float && `kol-seg--float ${floatSurfaceClass(surface)}`,
|
|
172
236
|
toneClass(resolvedTone),
|
|
173
237
|
className,
|
|
174
238
|
].filter(Boolean).join(' ')}
|
|
@@ -188,7 +252,6 @@ function Joined({ value, onChange, options = [], variant = 'default', size = 'md
|
|
|
188
252
|
className={['kol-seg-cell', cellType, isActive && 'is-active'].filter(Boolean).join(' ')}
|
|
189
253
|
>
|
|
190
254
|
{opt.label}
|
|
191
|
-
{float && opt.count != null && <span className="kol-seg-count">{opt.count}</span>}
|
|
192
255
|
</button>
|
|
193
256
|
</Tooltip>
|
|
194
257
|
)
|
|
@@ -1,57 +1,104 @@
|
|
|
1
1
|
import { useState } from 'react'
|
|
2
2
|
import Button from '../atoms/Button.jsx'
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
3
|
+
import { IconLoader } from '@kolkrabbi/kol-icons'
|
|
4
|
+
import { PopoverPanel, Tooltip, usePopover } from '../utilities/Popover.jsx'
|
|
5
|
+
import KolboxGlyph from '../utilities/kolboxGlyph.jsx'
|
|
6
|
+
import { Menu } from './Menu.jsx'
|
|
6
7
|
|
|
7
|
-
/* taxonomy-ok: molecule — two Buttons (atoms) and a divider, the ⌄ opening a PopoverPanel (utility) of rows
|
|
8
|
+
/* taxonomy-ok: molecule — two Buttons (atoms) and a divider, the ⌄ opening a PopoverPanel (utility) of rows */
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* ButtonSplit — the main action, a 1px divider and a ⌄ that opens a menu of the other actions (plan-2026-11-12-one-header
|
|
11
|
-
* W4.1; the user: *"its basically 4 exports and 1 open, isnt that just 2 buttons with menufloat?"*).
|
|
12
|
+
* W4.1; the user: *"its basically 4 exports and 1 open, isnt that just 2 buttons with menufloat?"*). The app's square Buttons at `size`, the menu a plain list (SplitToolButton's rows).
|
|
12
13
|
*
|
|
13
|
-
*
|
|
14
|
-
* float the float capsule (`variant="float"`, sm), the menu on the float sheet (`kol-more-sheet-float`): `items` drawn
|
|
15
|
-
* by MenuFloatRows — the one float menu, beside it in kol-component since 2026-11-12 (it lived in kol-shell and
|
|
16
|
-
* was redrawn here). `menu(close)` still replaces the rows
|
|
17
|
-
*
|
|
18
|
-
* `tone` is the Buttons' ground (Button's tones); `grey` is the float well on a float (the secondary look).
|
|
19
|
-
* The ⌄ is 12 (`--kol-float-chev-sm` on a float), never the button's glyph.
|
|
14
|
+
* `tone` is the Buttons' ground (Button's tones).
|
|
20
15
|
*
|
|
21
16
|
* @param {ReactNode} children the main action's label
|
|
22
17
|
* @param {string} [icon] the main action's glyph
|
|
23
18
|
* @param {Function} onClick the main action
|
|
24
19
|
* @param {Array} [items] `[{ label, icon?, onPress, disabled? }]` — the menu's rows
|
|
25
|
-
* @param {Function} [menu] `(close) => ReactNode` — the menu's content instead of `items`
|
|
26
|
-
* @param {'default'|'
|
|
27
|
-
*
|
|
20
|
+
* @param {Function} [menu] `(close) => ReactNode` — the menu's content instead of `items`
|
|
21
|
+
* @param {'default'|'kolbox'|'folio'} [variant='default'] `folio`: Folio's split (see its branch), `tone`
|
|
22
|
+
* primary or unset, `items` on Menu folio; `kolbox`: see the branch below; takes `tone` (primary, secondary), `icon`,
|
|
23
|
+
* `onClick`, `onMenu` (the ⌄'s press; the host opens its menu), `menuLabel`; with `iconOnly`
|
|
24
|
+
* (a glyph name) it is the tool dock's slot: `pressed` the armed look, `tooltip` the
|
|
25
|
+
* main half's tooltip label, `aria-label` the main half's name, `menuOpen` the ⌄'s
|
|
26
|
+
* menu is open (its quiet fill)
|
|
27
|
+
* @param {string} [tone] · {'xs'|'sm'|'md'|'lg'} [size='md']
|
|
28
28
|
* @param {boolean} [disabled] the main action off; the menu still opens
|
|
29
29
|
* @param {string} [menuLabel='More actions'] the ⌄'s aria-label
|
|
30
30
|
* @param {string} [placement='bottom-end'] · {string} [className]
|
|
31
31
|
*/
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
export default function ButtonSplit({ children, icon, onClick, items = [], menu, variant = 'default', tone, size = 'md', disabled = false, menuLabel = 'More actions', placement = 'bottom-end', className = '' }) {
|
|
32
|
+
export default function ButtonSplit({ children, icon, onClick, items = [], menu, variant = 'default', tone, size = 'md', disabled = false, menuLabel = 'More actions', placement = 'bottom-end', className = '', onMenu, menuOpen, iconOnly, pressed, tooltip, 'aria-label': ariaLabel }) {
|
|
35
33
|
const [open, setOpen] = useState(false)
|
|
36
34
|
const popover = usePopover({ open, onOpenChange: setOpen, placement, offset: 6, role: 'menu' })
|
|
35
|
+
/* `variant="kolbox"` (plan-2026-11-18-kolbox-system W31.2 batch 3, 2026-11-18): kolbox's SplitButton carried class for
|
|
36
|
+
* class, the action and its ⌄ as two kolbox Buttons of one tone, 1px apart, square where they meet; the hovered half
|
|
37
|
+
* takes the fg-04 hover over its own fill (kol-theme `.kol-btn-split--kolbox`). The host opens its own menu: `onMenu`
|
|
38
|
+
* is the ⌄'s press. */
|
|
39
|
+
if (variant === 'kolbox') {
|
|
40
|
+
/* the icon-only form (the tool dock's slot with a fold), Figma's dock as measured 2026-11-20 (W16.3): two boxes 1
|
|
41
|
+
* apart, no divider and no joined half. The tool a 32 tile with the 22 glyph (Figma's draw 16 to 18, W2), rounded on all four corners, solid
|
|
42
|
+
* accent while `pressed`; the ⌄ its own 16 by 32 button, no fill at rest (pressed or not), the quiet fill on hover
|
|
43
|
+
* and while its menu is open (`menuOpen`); `tooltip` names the main half */
|
|
44
|
+
if (iconOnly) {
|
|
45
|
+
const main = (
|
|
46
|
+
<button type="button" aria-label={ariaLabel} aria-pressed={!!pressed} disabled={disabled} onClick={onClick}
|
|
47
|
+
className="kol-btn-split-main inline-flex size-8 shrink-0 items-center justify-center outline-none focus-visible:outline-solid focus-visible:outline-1">
|
|
48
|
+
<IconLoader name={iconOnly} size={22} className="kol-kolbox-icon shrink-0" />
|
|
49
|
+
</button>
|
|
50
|
+
)
|
|
51
|
+
return (
|
|
52
|
+
<div className={`kol-btn-split--kolbox kol-btn-split--kolbox-icon${pressed ? ' is-pressed' : ''} inline-flex shrink-0 gap-px ${className}`.trim()}>
|
|
53
|
+
{tooltip ? <Tooltip variant="kolbox" label={tooltip}>{main}</Tooltip> : main}
|
|
54
|
+
<Tooltip variant="kolbox" asChild label={menuLabel}>
|
|
55
|
+
<button type="button" aria-label={menuLabel} aria-expanded={!!menuOpen} onClick={onMenu}
|
|
56
|
+
className={`kol-btn-split-menu${menuOpen ? ' is-open' : ''} inline-flex h-8 w-4 shrink-0 items-center justify-center outline-none focus-visible:outline-solid focus-visible:outline-1`}>
|
|
57
|
+
<KolboxGlyph name="chevron-down" />
|
|
58
|
+
</button>
|
|
59
|
+
</Tooltip>
|
|
60
|
+
</div>
|
|
61
|
+
)
|
|
62
|
+
}
|
|
63
|
+
return (
|
|
64
|
+
<div className={`kol-btn-split--kolbox inline-flex shrink-0 gap-px ${className}`}>
|
|
65
|
+
<Button variant="kolbox" tone={tone} iconLeft={icon} onClick={onClick} className="rounded-r-none">{children}</Button>
|
|
66
|
+
<Tooltip variant="kolbox" asChild label={menuLabel}><Button variant="kolbox" tone={tone} iconLeft="chevron-down" onClick={onMenu} aria-label={menuLabel} className="rounded-l-none px-1" /></Tooltip>
|
|
67
|
+
</div>
|
|
68
|
+
)
|
|
69
|
+
}
|
|
70
|
+
/* `variant="folio"` (Folio migration batch B, 2026-11-22): Folio's ActionSplit carried class for class (kol-theme
|
|
71
|
+
* `.kol-btn-split--folio`): two joined 32-high halves at radius 4 inside one line, the label padded 16, the ⌄ a 32
|
|
72
|
+
* square, a hairline in the ink at 20% between; `tone="primary"` the green ground, unset the paper. The ⌄ opens
|
|
73
|
+
* `items` on `Menu variant="folio"` under its right edge, in place (never portalled). Esc or a press outside closes. */
|
|
74
|
+
if (variant === 'folio') {
|
|
75
|
+
return (
|
|
76
|
+
<span className={`kol-btn-split--folio${tone === 'primary' ? ' kol-btn-split--folio-primary' : ''} relative inline-flex ${className}`.trim()}>
|
|
77
|
+
<span className="kol-btn-split-box flex h-[32px] shrink-0 overflow-hidden rounded-[4px] border">
|
|
78
|
+
<button type="button" onClick={onClick} className="kol-btn-split-main whitespace-nowrap px-[16px]">{children}</button>
|
|
79
|
+
<span aria-hidden className="w-px bg-current opacity-20" />
|
|
80
|
+
<button type="button" aria-label={menuLabel} aria-haspopup="menu" aria-expanded={open} onClick={() => setOpen(!open)} className="flex w-[32px] items-center justify-center"><IconLoader name="chevron-down" size={16} /></button>
|
|
81
|
+
</span>
|
|
82
|
+
<Menu variant="folio" open={open} onClose={() => setOpen(false)} aria-label={menuLabel} minWidth={160}
|
|
83
|
+
panelClassName="absolute right-0 top-[calc(100%+4px)] whitespace-nowrap"
|
|
84
|
+
items={items.map((it) => ({ label: it.label, onClick: it.onPress, disabled: it.disabled }))} />
|
|
85
|
+
</span>
|
|
86
|
+
)
|
|
87
|
+
}
|
|
37
88
|
const close = () => setOpen(false)
|
|
38
|
-
const
|
|
39
|
-
const shared = float
|
|
40
|
-
? { variant: 'float', tone: tone === 'grey' ? undefined : tone, size: 'sm', style: tone === 'grey' ? WELL : undefined }
|
|
41
|
-
: { tone, size }
|
|
89
|
+
const shared = { tone, size }
|
|
42
90
|
const pick = (it) => () => { if (it.disabled) return; it.onPress?.(); close() }
|
|
43
91
|
return (
|
|
44
92
|
<div className={`kol-btn-split inline-flex items-stretch ${className}`.trim()}>
|
|
45
|
-
<Button {...shared} iconLeft={icon} iconSize={
|
|
93
|
+
<Button {...shared} iconLeft={icon} iconSize={12} disabled={disabled} onClick={onClick} className="flex-1 min-w-0 rounded-r-none">{children}</Button>
|
|
46
94
|
<span aria-hidden="true" className="w-px shrink-0 bg-oq-16" />
|
|
47
95
|
<span ref={popover.refs.setReference} {...popover.getReferenceProps()} className="inline-flex">
|
|
48
|
-
<Button {...shared} iconOnly="chevron-down" iconSize={
|
|
49
|
-
className=
|
|
96
|
+
<Button {...shared} iconOnly="chevron-down" iconSize={12} pressed={open} aria-label={menuLabel}
|
|
97
|
+
className="rounded-l-none" />
|
|
50
98
|
</span>
|
|
51
99
|
<PopoverPanel popover={popover} panel={false} focus={false}
|
|
52
|
-
className=
|
|
53
|
-
|
|
54
|
-
{menu ? menu(close) : float ? <MenuFloatRows variant="float" actions={items} onPick={close} /> : items.map((it) => (
|
|
100
|
+
className="w-max bg-surface-secondary border border-oq-08 rounded shadow-lg">
|
|
101
|
+
{menu ? menu(close) : items.map((it) => (
|
|
55
102
|
<button key={it.label} type="button" disabled={it.disabled} onClick={pick(it)}
|
|
56
103
|
className="w-full kol-helper-12 px-3 h-8 flex items-center gap-2 text-body hover:text-emphasis disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:text-body text-left">
|
|
57
104
|
<span className="flex-1 truncate">{it.label}</span>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chip — A tile with a leading slot, a title and a meta line.
|
|
3
|
+
*
|
|
4
|
+
* The library master `Chip` (Molecules page, 2167:11003; type-ramp plan 6.3): a 192 × 64 tile on surface-tertiary,
|
|
5
|
+
* the leading slot a 48 square on oq-04 (an `IconFrame` or "Aa" in the Specimen font chips), then the title in sans 14
|
|
6
|
+
* at full ink and the meta in sans 12 at fg-64. A molecule because its slot holds an `IconFrame`, as `CloseButton` does.
|
|
7
|
+
* Not the `chip` icon, not `Tag` (interactive), `Pill` (a static word) or `SizeChip` (one letter).
|
|
8
|
+
*
|
|
9
|
+
* @param {React.ReactNode} [leading] the slot's content; omitted, nothing is drawn in the slot
|
|
10
|
+
* @param {string} title
|
|
11
|
+
* @param {string} [meta]
|
|
12
|
+
* @param {string} [className]
|
|
13
|
+
*/
|
|
14
|
+
export default function Chip({ leading, title, meta, className = '', ...rest }) {
|
|
15
|
+
return (
|
|
16
|
+
<div className={`flex h-16 w-48 items-center gap-3 rounded-lg bg-surface-tertiary p-2 ${className}`.trim()} {...rest}>
|
|
17
|
+
{leading != null && (
|
|
18
|
+
<div className="flex size-12 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-oq-04">{leading}</div>
|
|
19
|
+
)}
|
|
20
|
+
<div className="flex min-w-0 flex-col items-start gap-1 overflow-hidden whitespace-nowrap font-[family-name:var(--kol-font-family-sans)] font-normal leading-[14px]">
|
|
21
|
+
<p className="text-[14px] text-auto">{title}</p>
|
|
22
|
+
{meta != null && <p className="text-[12px] text-fg-64">{meta}</p>}
|
|
23
|
+
</div>
|
|
24
|
+
</div>
|
|
25
|
+
)
|
|
26
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { useState } from 'react'
|
|
1
2
|
import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter'
|
|
2
|
-
import { oneDark } from 'react-syntax-highlighter/dist/esm/styles/prism'
|
|
3
|
+
import { oneDark, oneLight } from 'react-syntax-highlighter/dist/esm/styles/prism'
|
|
3
4
|
import CopyButton from './CopyButton.jsx'
|
|
4
5
|
|
|
5
6
|
/**
|
|
@@ -77,7 +78,7 @@ const syntaxTheme = (foregroundToken = 80) => ({
|
|
|
77
78
|
* for anything else. `md` is those exact values, named; `sm` is one step down
|
|
78
79
|
* on both axes. Size is INDEPENDENT of `bare`: bare removes the frame, size
|
|
79
80
|
* sets the box, and a bare block still has one. */
|
|
80
|
-
|
|
81
|
+
function CodeBlockDefault({ children, code: codeProp, language: languageProp, filename: filenameProp, value, bare = false, size = 'md', copy = true }) {
|
|
81
82
|
const code = String(value?.code ?? codeProp ?? children ?? '')
|
|
82
83
|
const language = value?.language ?? languageProp ?? 'text'
|
|
83
84
|
const filename = value?.filename ?? filenameProp
|
|
@@ -125,3 +126,39 @@ export default function CodeBlock({ children, code: codeProp, language: language
|
|
|
125
126
|
</div>
|
|
126
127
|
)
|
|
127
128
|
}
|
|
129
|
+
|
|
130
|
+
/* ── folio (Folio batch E, 2026-11-22) ─────────────────────────────────────────────────────────────────────────────
|
|
131
|
+
* Folio's fenced code, carried from apps/folio's Fence.jsx: a 36 header naming the language (Folio's names, mono 11
|
|
132
|
+
* capitals, muted) with Copy (Copied for 1.4s), over the code coloured by Prism, oneLight or oneDark flattened onto
|
|
133
|
+
* Folio's code ground (the ink at 4% on the paper), in mono 13 / 1.7, long lines wrapped; a hairline frame at radius 3.
|
|
134
|
+
* CodeBlock's words: `code` (or children) and `language`. Folio's own: `dark` (oneDark for Folio's night; the theme is the
|
|
135
|
+
* caller's, which reads its own reader or canvas). `data-wide` stays on the root: Folio's prose grid runs it full width. */
|
|
136
|
+
const flatFolio = (theme) => ({
|
|
137
|
+
...theme,
|
|
138
|
+
'pre[class*="language-"]': { ...theme['pre[class*="language-"]'], background: 'transparent', margin: 0, padding: 0, textShadow: 'none', fontSize: '13px', lineHeight: '1.7' },
|
|
139
|
+
'code[class*="language-"]': { ...theme['code[class*="language-"]'], background: 'transparent', textShadow: 'none', fontFamily: 'var(--kol-font-family-mono), ui-monospace, monospace', fontSize: '13px' },
|
|
140
|
+
})
|
|
141
|
+
const FOLIO_LIGHT = flatFolio(oneLight)
|
|
142
|
+
const FOLIO_DARK = flatFolio(oneDark)
|
|
143
|
+
const FOLIO_NAME = { js: 'JavaScript', javascript: 'JavaScript', jsx: 'JSX', ts: 'TypeScript', typescript: 'TypeScript', json: 'JSON', css: 'CSS', html: 'HTML', markup: 'HTML', md: 'Markdown', sh: 'Shell', bash: 'Shell', yaml: 'YAML', yml: 'YAML', py: 'Python', python: 'Python' }
|
|
144
|
+
|
|
145
|
+
function CodeBlockFolio({ code: codeProp, children, language, dark = false }) {
|
|
146
|
+
const text = String(codeProp ?? children ?? '')
|
|
147
|
+
const [copied, setCopied] = useState(false)
|
|
148
|
+
const copy = () => navigator.clipboard?.writeText(text).then(() => { setCopied(true); setTimeout(() => setCopied(false), 1400) }).catch(() => {})
|
|
149
|
+
return (
|
|
150
|
+
<div data-wide className="kol-codeblock--folio overflow-hidden rounded-[3px] border">
|
|
151
|
+
<div className="kol-codeblock-head flex h-[36px] items-center justify-between border-b px-[14px]">
|
|
152
|
+
<span className="kol-codeblock-language uppercase">{FOLIO_NAME[language] ?? language}</span>
|
|
153
|
+
<button type="button" onClick={copy} className="kol-folio-meta kol-codeblock-action rounded-[3px] px-[8px] py-[4px]">{copied ? 'Copied' : 'Copy'}</button>
|
|
154
|
+
</div>
|
|
155
|
+
<div className="overflow-x-auto px-[16px] py-[14px]">
|
|
156
|
+
<SyntaxHighlighter language={language} style={dark ? FOLIO_DARK : FOLIO_LIGHT} wrapLongLines>{text}</SyntaxHighlighter>
|
|
157
|
+
</div>
|
|
158
|
+
</div>
|
|
159
|
+
)
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export default function CodeBlock(props) {
|
|
163
|
+
return props.variant === 'folio' ? <CodeBlockFolio {...props} /> : <CodeBlockDefault {...props} />
|
|
164
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { useState } from 'react'
|
|
1
|
+
import { useMemo, useRef, useState } from 'react'
|
|
2
2
|
import { IconLoader } from '@kolkrabbi/kol-icons'
|
|
3
3
|
import ColorSwatch from './ColorSwatch.jsx'
|
|
4
|
-
import Input from '../atoms/Input.jsx'
|
|
4
|
+
import Input, { selectOnFirstPress, useKolboxField } from '../atoms/Input.jsx'
|
|
5
|
+
import FieldPair from './FieldPair.jsx'
|
|
5
6
|
import { usePopover, PopoverPanel, Tooltip } from '../utilities/Popover.jsx'
|
|
6
7
|
|
|
7
8
|
/**
|
|
@@ -66,7 +67,7 @@ import { usePopover, PopoverPanel, Tooltip } from '../utilities/Popover.jsx'
|
|
|
66
67
|
* transparentTone — TransparentX stroke tone for the null/unused swatch:
|
|
67
68
|
* 'warning' (default) | 'error' | 'info' | 'success'
|
|
68
69
|
*/
|
|
69
|
-
|
|
70
|
+
function ColorInputRowDefault({
|
|
70
71
|
value,
|
|
71
72
|
onChange,
|
|
72
73
|
label,
|
|
@@ -160,7 +161,7 @@ export default function ColorInputRow({
|
|
|
160
161
|
{chip('stretch')}
|
|
161
162
|
<span
|
|
162
163
|
aria-hidden="true"
|
|
163
|
-
className={`absolute inset-0 inline-flex items-center justify-center rounded-[var(--kol-radius-
|
|
164
|
+
className={`absolute inset-0 inline-flex items-center justify-center rounded-[var(--kol-radius-2)] transition-opacity bg-fg-ab-48 text-white pointer-events-none ${
|
|
164
165
|
locked ? 'opacity-100' : 'opacity-0 group-hover:opacity-100'
|
|
165
166
|
}`}
|
|
166
167
|
>
|
|
@@ -279,3 +280,123 @@ export default function ColorInputRow({
|
|
|
279
280
|
</>
|
|
280
281
|
)
|
|
281
282
|
}
|
|
283
|
+
|
|
284
|
+
/* ── kolbox (plan-2026-11-18-kolbox-system W31.2 batch 5, 2026-11-18) ─────────────────────────────────────────────────
|
|
285
|
+
* kolbox's FillRow (Figma 84:12831), carried from apps/kolbox/src/ui/FillRow.jsx: one joined field (oq-16, radius 4, no
|
|
286
|
+
* outline) holding the hex segment (the 16 swatch and the hex in Inter 11, padding 6 and 8, gap 8) and, after a 1px
|
|
287
|
+
* gap in the rail ground (1 by 22, W16.5), the opacity segment (the value mono 11 and "%" muted, 8 in, the % 16 after the
|
|
288
|
+
* value and 4 off the end); with `actions` the row is FieldPair
|
|
289
|
+
* kolbox's: the field over both field columns of the rail's grid, the actions on its icon columns (R3.1). The
|
|
290
|
+
* swatch opens the caller's color overlay through `onSwatch` (with `lit` while it is open), or else the row's own
|
|
291
|
+
* `picker` (ColorPickerPopover variant="kolbox": this row is a molecule and cannot import the organism, so the caller
|
|
292
|
+
* hands it in), beside the rail level with the swatch. The hex is edited in place (one press selects it, a short hex grows on Enter or blur: `expandHex`); a value that is not a plain hex shows
|
|
293
|
+
* `resolved` on the swatch and its own text in the field. `opacity` 0 to 100 through `onOpacity` (read-only without it);
|
|
294
|
+
* null draws no opacity segment. `clearable`: emptying the hex commits null (an optional color, unset). `hidden` (the paint's eye is off) dims the opacity value; the color stays readable. `label` names the row's parts for a reader; this look draws no label. */
|
|
295
|
+
const HEX_KOLBOX = /^[0-9a-f]{6}$/i
|
|
296
|
+
/* a short hex grows on commit: 1 character six times, 2 three times, 3 each doubled; 6 as written; anything else is null */
|
|
297
|
+
export function expandHex(raw) {
|
|
298
|
+
const d = String(raw ?? '').trim().replace(/^#/, '')
|
|
299
|
+
if (!/^[0-9a-f]+$/i.test(d)) return null
|
|
300
|
+
if (d.length === 1) return d.repeat(6)
|
|
301
|
+
if (d.length === 2) return d.repeat(3)
|
|
302
|
+
if (d.length === 3) return [...d].map((c) => c + c).join('')
|
|
303
|
+
return d.length === 6 ? d : null
|
|
304
|
+
}
|
|
305
|
+
function ColorInputRowKolbox({ label, value, resolved, onChange, onSwatch, opacity, onOpacity, actions, lit = false, hidden = false, clearable = false, picker: Picker }) {
|
|
306
|
+
const hex = HEX_KOLBOX.test(String(value ?? '').replace('#', '')) ? String(value).replace('#', '').toUpperCase() : null
|
|
307
|
+
const swatch = resolved ?? (hex ? `#${hex}` : null)
|
|
308
|
+
const swatchRef = useRef(null)
|
|
309
|
+
const [picking, setPicking] = useState(false)
|
|
310
|
+
/* the row's own picker opens beside the rail (never over it), level with the swatch; outside a rail, beside the swatch */
|
|
311
|
+
const anchor = useMemo(() => ({
|
|
312
|
+
getBoundingClientRect() {
|
|
313
|
+
const sw = swatchRef.current?.getBoundingClientRect()
|
|
314
|
+
const rail = swatchRef.current?.closest('[data-rail]')?.getBoundingClientRect()
|
|
315
|
+
return rail ? { left: rail.left, right: rail.left, top: sw.top, bottom: sw.top } : sw
|
|
316
|
+
},
|
|
317
|
+
contains: (t) => !!swatchRef.current?.contains(t),
|
|
318
|
+
}), [])
|
|
319
|
+
/* the hex and the opacity are kolbox's fields (Input's useKolboxField): Escape restores, the opacity's arrows step */
|
|
320
|
+
const hexField = useKolboxField(hex ?? String(value ?? ''), (text) => {
|
|
321
|
+
if (clearable && !text) { if (value) onChange?.(null); return }
|
|
322
|
+
const d = expandHex(text)
|
|
323
|
+
if (d) onChange?.(`#${d.toLowerCase()}`)
|
|
324
|
+
}, { step: false })
|
|
325
|
+
const op = opacity == null ? null : Math.round(opacity)
|
|
326
|
+
const opField = useKolboxField(op, (text) => { const n = parseFloat(text); if (Number.isFinite(n)) onOpacity?.(Math.min(100, Math.max(0, n))) })
|
|
327
|
+
const field = (
|
|
328
|
+
<div className={`kol-color-row-field flex h-(--kol-kolbox-ctl) min-w-0 flex-1 items-stretch${lit || picking ? ' is-lit' : ''}`} data-fill-field>
|
|
329
|
+
<div className="flex min-w-0 flex-1 items-center gap-2 pr-2 pl-1.5" data-fill-hex>
|
|
330
|
+
<Tooltip variant="kolbox" asChild label={label}>
|
|
331
|
+
<button
|
|
332
|
+
ref={swatchRef}
|
|
333
|
+
type="button"
|
|
334
|
+
aria-label={`${label}: ${swatch ?? hexField.value}`}
|
|
335
|
+
aria-expanded={onSwatch ? lit : picking}
|
|
336
|
+
className="kol-color-row-swatch relative size-3.5 shrink-0 outline-none focus-visible:outline-solid focus-visible:outline-1"
|
|
337
|
+
style={{ background: swatch ?? 'transparent' }}
|
|
338
|
+
onClick={(e) => (onSwatch ? onSwatch(e) : setPicking((o) => !o))}
|
|
339
|
+
/>
|
|
340
|
+
</Tooltip>
|
|
341
|
+
<input
|
|
342
|
+
className="kol-color-row-hex min-w-0 flex-1 self-stretch bg-transparent uppercase outline-none"
|
|
343
|
+
aria-label={`${label} hex`}
|
|
344
|
+
{...hexField}
|
|
345
|
+
onMouseDown={selectOnFirstPress}
|
|
346
|
+
/>
|
|
347
|
+
</div>
|
|
348
|
+
{op != null && (
|
|
349
|
+
<>
|
|
350
|
+
{/* Figma's pair (W16.5): a 1 by 22 gap in the rail's ground; the number 8 in, the % 16 after it and 4 off the end */}
|
|
351
|
+
<span className="kol-color-row-rule my-px w-px shrink-0" />
|
|
352
|
+
<label className="flex shrink-0 items-center gap-4 self-stretch pr-1 pl-2" data-fill-opacity>
|
|
353
|
+
<input
|
|
354
|
+
aria-label={`${label} opacity`}
|
|
355
|
+
readOnly={!onOpacity}
|
|
356
|
+
{...opField}
|
|
357
|
+
onMouseDown={selectOnFirstPress}
|
|
358
|
+
className="kol-color-row-opacity field-sizing-content min-w-0 self-stretch bg-transparent outline-none"
|
|
359
|
+
/>
|
|
360
|
+
<span className="kol-color-row-unit">%</span>
|
|
361
|
+
</label>
|
|
362
|
+
</>
|
|
363
|
+
)}
|
|
364
|
+
</div>
|
|
365
|
+
)
|
|
366
|
+
const picker = !onSwatch && Picker && (
|
|
367
|
+
<Picker
|
|
368
|
+
variant="kolbox"
|
|
369
|
+
anchor={anchor}
|
|
370
|
+
open={picking}
|
|
371
|
+
onClose={() => setPicking(false)}
|
|
372
|
+
color={swatch && HEX_KOLBOX.test(swatch.replace('#', '')) ? swatch : undefined}
|
|
373
|
+
opacity={op ?? 100}
|
|
374
|
+
onChange={({ value: v, opacity: o }) => { onChange?.(v.toLowerCase()); if (op != null && o !== op) onOpacity?.(o) }}
|
|
375
|
+
/>
|
|
376
|
+
)
|
|
377
|
+
const root = `kol-color-row--kolbox min-w-0 flex-1 ${hidden ? 'is-hidden' : ''}`
|
|
378
|
+
/* with actions the row is a rail row: the field spans the grid's two field columns, the actions sit on its icon
|
|
379
|
+
columns (FieldPair kolbox, R3.1); alone it is a field that fills its cell */
|
|
380
|
+
return actions
|
|
381
|
+
? <><FieldPair variant="kolbox" span className={root} data-fill-row first={field} trailing={actions} />{picker}</>
|
|
382
|
+
: <div className={`${root} flex h-(--kol-kolbox-ctl) items-center`} data-fill-row>{field}{picker}</div>
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
/* ── folio (Folio batch C, 2026-11-22): Folio's SwatchRow, carried class for class. The swatch (the `picker`,
|
|
386
|
+
* ColorPickerPopover variant="folio", handed in as kolbox's is: a molecule cannot import the organism), the `label`
|
|
387
|
+
* (12 / 16 medium, taking the room) and the hex (mono 12 / 16, capitals, Folio's muted ink), 12 apart. `swatches`
|
|
388
|
+
* ([name, hex]) go to the picker; `onChange(hex)`. Chrome in kol-theme `.kol-color-row--folio`. ── */
|
|
389
|
+
function ColorInputRowFolio({ label, value, swatches, onChange, picker: Picker }) {
|
|
390
|
+
return (
|
|
391
|
+
<div className="kol-color-row--folio flex w-full items-center gap-[12px]">
|
|
392
|
+
{Picker && <Picker variant="folio" label={label} color={value} swatches={swatches} onChange={onChange} />}
|
|
393
|
+
<p className="kol-color-row-label min-w-0 flex-1 truncate">{label}</p>
|
|
394
|
+
<p className="kol-color-row-value shrink-0 uppercase">{value}</p>
|
|
395
|
+
</div>
|
|
396
|
+
)
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
export default function ColorInputRow(props) {
|
|
400
|
+
if (props.variant === 'folio') return <ColorInputRowFolio {...props} />
|
|
401
|
+
return props.variant === 'kolbox' ? <ColorInputRowKolbox {...props} /> : <ColorInputRowDefault {...props} />
|
|
402
|
+
}
|
|
@@ -24,7 +24,20 @@
|
|
|
24
24
|
* used by tightly-packed grid layouts.
|
|
25
25
|
* variant — 'default' (border-based chrome) |
|
|
26
26
|
* 'halo' (macOS-port double box-shadow halo). Halo
|
|
27
|
-
* overrides `frame` since it provides its own ring.
|
|
27
|
+
* overrides `frame` since it provides its own ring. |
|
|
28
|
+
* 'folio' (Folio's Swatch, Folio batch C, 2026-11-22, carried
|
|
29
|
+
* class for class): always a button, 24 square at radius 4,
|
|
30
|
+
* `frame` Folio's hairline round it, `selected` a 2px outline
|
|
31
|
+
* of Folio's ink 2 off it; `title` is the native title, `size`
|
|
32
|
+
* and `radius` are not read. With no `hex` the caller paints
|
|
33
|
+
* it (an accent swatch: `data-folio-accent` and `hex`
|
|
34
|
+
* `var(--kol-folio-green)`). Chrome in kol-theme
|
|
35
|
+
* `.kol-color-swatch--folio`. |
|
|
36
|
+
* 'kolbox' (Folio on kolbox, 2026-11-22): SwatchGrid kolbox's
|
|
37
|
+
* cell as one chip, always a button: `size` square (24), radius
|
|
38
|
+
* 2, `frame` its 1px oq-24 ring inside it, `selected` the 2px
|
|
39
|
+
* accent ring 1 off the secondary surface (chrome
|
|
40
|
+
* `.kol-swatch-grid-cell`); `title` names it in Tooltip kolbox.
|
|
28
41
|
* hoverable — boolean (default true). When false, no hover border
|
|
29
42
|
* state is applied even if `onClick` is set. For static
|
|
30
43
|
* chips that just open a popover (e.g. inspector fill /
|
|
@@ -55,7 +68,7 @@ const NAMED_PX = {
|
|
|
55
68
|
|
|
56
69
|
const RADIUS_CLASSES = {
|
|
57
70
|
none: 'rounded-none',
|
|
58
|
-
tight: 'rounded-[var(--kol-radius-
|
|
71
|
+
tight: 'rounded-[var(--kol-radius-2)]',
|
|
59
72
|
sm: 'rounded',
|
|
60
73
|
full: 'rounded-full',
|
|
61
74
|
}
|
|
@@ -84,6 +97,34 @@ export default function ColorSwatch({
|
|
|
84
97
|
className = '',
|
|
85
98
|
...rest
|
|
86
99
|
}) {
|
|
100
|
+
if (variant === 'kolbox') {
|
|
101
|
+
return (
|
|
102
|
+
<Tooltip variant="kolbox" asChild label={title}>
|
|
103
|
+
<button
|
|
104
|
+
type="button"
|
|
105
|
+
aria-pressed={selected}
|
|
106
|
+
onClick={onClick}
|
|
107
|
+
{...rest}
|
|
108
|
+
className={`kol-swatch-grid-cell${selected ? ' is-current ring-2 ring-offset-1' : frame ? ' ring-1 ring-inset' : ''} shrink-0 outline-none ${className}`.trim()}
|
|
109
|
+
style={{ width: size, height: size, background: hex, ...rest.style }}
|
|
110
|
+
/>
|
|
111
|
+
</Tooltip>
|
|
112
|
+
)
|
|
113
|
+
}
|
|
114
|
+
if (variant === 'folio') {
|
|
115
|
+
return (
|
|
116
|
+
<button
|
|
117
|
+
type="button"
|
|
118
|
+
aria-pressed={selected}
|
|
119
|
+
/* title-ok: a port, verbatim (Folio batch C): Folio's swatches name their color in the browser's own tooltip */
|
|
120
|
+
title={title}
|
|
121
|
+
onClick={onClick}
|
|
122
|
+
{...rest}
|
|
123
|
+
className={`kol-color-swatch--folio size-[24px] rounded-[4px] ${frame ? 'border ' : ''}${selected ? 'is-selected outline outline-2 outline-offset-2' : ''} ${className}`}
|
|
124
|
+
style={hex ? { background: hex, ...rest.style } : rest.style}
|
|
125
|
+
/>
|
|
126
|
+
)
|
|
127
|
+
}
|
|
87
128
|
const interactive = typeof onClick === 'function'
|
|
88
129
|
const resolvedSize = NAMED_PX[size] ?? size
|
|
89
130
|
const isNamed = typeof resolvedSize === 'string'
|