@kolkrabbi/kol-component 0.362.0 → 0.363.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 +3 -3
- package/src/molecules/LabeledControl.jsx +12 -6
- package/src/molecules/Slider.jsx +23 -20
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kolkrabbi/kol-component",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.363.0",
|
|
4
4
|
"description": "The core component library",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
"pdfjs-dist": "^6.3.289",
|
|
34
34
|
"react-syntax-highlighter": "^16.1.1",
|
|
35
35
|
"@kolkrabbi/kol-search": "^0.3.0",
|
|
36
|
-
"@kolkrabbi/kol-
|
|
37
|
-
"@kolkrabbi/kol-
|
|
36
|
+
"@kolkrabbi/kol-markdown": "^0.2.0",
|
|
37
|
+
"@kolkrabbi/kol-growth": "^0.5.0"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
40
|
"@kolkrabbi/kol-icons": ">=0.69.0",
|
|
@@ -32,7 +32,10 @@
|
|
|
32
32
|
* 2026-10-01): `kol-helper-8`, uppercase, hugging the control; it takes
|
|
33
33
|
* `labelPosition` (`top · bottom · left · right`, default bottom), `labelClass` and `gap`.
|
|
34
34
|
* `'float'` (float-everything W3 row 37, 2026-11-04): the label over a capsule — the float hint role
|
|
35
|
-
* (Inter 12) at fg-64,
|
|
35
|
+
* (Inter 12) at fg-64, no uppercase, no tracking, `--kol-float-label-gap` from the control; `inline` keeps
|
|
36
|
+
* the same label in the `--kol-float-label-w` column (a `labelWidth` still wins), the row at least the float
|
|
37
|
+
* sm height. Every float row is this (plan-2026-11-12-float-system W2.1); the wrapper carries
|
|
38
|
+
* `data-labeled-control`.
|
|
36
39
|
* children — the control body.
|
|
37
40
|
* className — additional classes on the wrapper.
|
|
38
41
|
*/
|
|
@@ -40,7 +43,7 @@ export default function LabeledControl({
|
|
|
40
43
|
label,
|
|
41
44
|
hint,
|
|
42
45
|
inline = false,
|
|
43
|
-
labelWidth
|
|
46
|
+
labelWidth,
|
|
44
47
|
children,
|
|
45
48
|
className = '',
|
|
46
49
|
text = false,
|
|
@@ -66,6 +69,9 @@ export default function LabeledControl({
|
|
|
66
69
|
}
|
|
67
70
|
const showLabel = !!label
|
|
68
71
|
const float = variant === 'float'
|
|
72
|
+
const lw = labelWidth ?? (float ? 'var(--kol-float-label-w)' : 48)
|
|
73
|
+
const gapClass = float ? 'gap-[var(--kol-float-label-gap)]' : null
|
|
74
|
+
const mark = float ? { 'data-labeled-control': '' } : undefined
|
|
69
75
|
const labelType = float ? 'kol-float-hint text-fg-64' : 'kol-helper-10 tracking-widest text-meta'
|
|
70
76
|
const labelInner = (
|
|
71
77
|
<>
|
|
@@ -84,15 +90,15 @@ export default function LabeledControl({
|
|
|
84
90
|
* BELOW `sm` IT STACKS (apps review, 2026-09-29): the yielding label yielded to
|
|
85
91
|
* nothing on a phone — a sentence-long combo took the whole row and the label
|
|
86
92
|
* showed as "C" or not at all. Label on its line, the value under it. */
|
|
87
|
-
const labelAuto =
|
|
93
|
+
const labelAuto = lw === 'auto'
|
|
88
94
|
return (
|
|
89
|
-
<div className={`flex ${labelAuto ? `flex-col items-start gap-1 sm:flex-row ${text ? 'sm:items-baseline' : 'sm:items-center'} sm:gap-3` : `${text ? 'items-baseline' : 'items-center'} gap-3`} ${className}`}>
|
|
95
|
+
<div {...mark} className={`flex ${labelAuto ? `flex-col items-start gap-1 sm:flex-row ${text ? 'sm:items-baseline' : 'sm:items-center'} sm:gap-3` : `${text ? 'items-baseline' : 'items-center'} ${gapClass ?? 'gap-3'}`}${float ? ' min-h-[var(--kol-float-h-sm)]' : ''} ${className}`}>
|
|
90
96
|
{showLabel && (
|
|
91
97
|
<span
|
|
92
98
|
/* A LABEL NEVER WRAPS (review 2, § 6.2 — the helper law by construction, 01-foundations/03-typography.md:29):
|
|
93
99
|
* `whitespace-nowrap truncate`, so a long one ends in an ellipsis instead of breaking onto a second line */
|
|
94
100
|
className={`${labelType} whitespace-nowrap truncate${text ? ' leading-4' : ''} ${labelAuto ? 'max-w-full min-w-0 sm:flex-1' : 'shrink-0'}`}
|
|
95
|
-
style={labelAuto ? undefined : { width:
|
|
101
|
+
style={labelAuto ? undefined : { width: lw }}
|
|
96
102
|
>
|
|
97
103
|
{labelInner}
|
|
98
104
|
</span>
|
|
@@ -103,7 +109,7 @@ export default function LabeledControl({
|
|
|
103
109
|
}
|
|
104
110
|
|
|
105
111
|
return (
|
|
106
|
-
<div className={`flex flex-col gap-2 ${className}`}>
|
|
112
|
+
<div {...mark} className={`flex flex-col ${gapClass ?? 'gap-2'} ${className}`}>
|
|
107
113
|
{showLabel && (
|
|
108
114
|
<span className={labelType}>{labelInner}</span>
|
|
109
115
|
)}
|
package/src/molecules/Slider.jsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useCallback, useEffect, useId, useMemo, useRef, useState } from 'react'
|
|
2
2
|
import Input from '../atoms/Input.jsx'
|
|
3
3
|
import SliderPanel from './SliderPanel.jsx'
|
|
4
|
+
import LabeledControl from './LabeledControl.jsx'
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Slider — range slider with label and a value readout. The LINEAR VARIANT of
|
|
@@ -46,7 +47,7 @@ import SliderPanel from './SliderPanel.jsx'
|
|
|
46
47
|
* @param {Object} props.style - forwarded to the wrapper; the seam for `--kol-slider-track` / `--kol-slider-playhead`
|
|
47
48
|
* @param {number} props.defaultValue - alt-click the control resets to this (falls back to `min`). Same contract on Knob
|
|
48
49
|
* @param {'input'|'value'|'none'} props.readout - `input` (default) an editable Input · `value` a plain right-aligned span, Knob's own display-only readout · `none`
|
|
49
|
-
* @param {'minimal'|'dual'|'scrub'|'panel'|'float'} props.variant - `dual` = two thumbs on one rail · `scrub` = a media scrubber: the thin track with the 4 × 28 pill knob (`.kol-playback-scrub`; `PlaybackBar`'s, 2026-10-02) · `panel` = the rack slider (was kol-hardware `Fader`, merged 2026-10-01): a drawn 2px track for a hardware panel; takes `value · onChange · min · max · step · label` plus `onHold` · `float` (float-everything W2 row 23, 2026-11-04
|
|
50
|
+
* @param {'minimal'|'dual'|'scrub'|'panel'|'float'} props.variant - `dual` = two thumbs on one rail · `scrub` = a media scrubber: the thin track with the 4 × 28 pill knob (`.kol-playback-scrub`; `PlaybackBar`'s, 2026-10-02) · `panel` = the rack slider (was kol-hardware `Fader`, merged 2026-10-01): a drawn 2px track for a hardware panel; takes `value · onChange · min · max · step · label` plus `onHold` · `float` (float-everything W2 row 23, 2026-11-04; track only since 2026-11-12): the 3px capsule track at the float sm height — the run fg-64 to a 12 thumb (`.kol-slider-float`); a `label` is drawn by `LabeledControl variant="float"`, a `value` readout as its hint, `formatValue` its words (`65%`)
|
|
50
51
|
* @param {'horizontal'|'vertical'} props.direction - `vertical` stands the track upright at `height`, label above and readout below (2026-10-02 — the volume ranges were hand-drawn for want of it). On `panel`, horizontal takes the row and shows a readout
|
|
51
52
|
* @param {number} props.height - vertical only — the track's length in px (default 96; panel 60)
|
|
52
53
|
* @param {string} props['aria-label'] - names the range when there is no visible `label`
|
|
@@ -258,28 +259,30 @@ const Slider = ({
|
|
|
258
259
|
const scrub = variant === 'scrub'
|
|
259
260
|
const length = vertical ? height ?? 96 : size
|
|
260
261
|
|
|
261
|
-
/* the float slider:
|
|
262
|
+
/* the float slider: track and thumb only, at the float sm height (plan-2026-11-12-float-system W2.1 — the label head it
|
|
263
|
+
* carried went; the user: "SOME IDIOT tried to put label on the slider instead of using a fucking LABELEDCONTROL").
|
|
264
|
+
* Its name is a LabeledControl's: a `label` passed here is drawn by `LabeledControl variant="float"`, the `value`
|
|
265
|
+
* readout as its hint. The run is the value as a percent on the track. */
|
|
262
266
|
if (variant === 'float') {
|
|
263
267
|
const pct = max > min ? ((value - min) / (max - min)) * 100 : 0
|
|
268
|
+
const track = (
|
|
269
|
+
<input
|
|
270
|
+
id={sliderId}
|
|
271
|
+
type="range"
|
|
272
|
+
min={min} max={max} step={step} value={value}
|
|
273
|
+
onChange={handleChange}
|
|
274
|
+
onClick={onAltReset}
|
|
275
|
+
disabled={disabled}
|
|
276
|
+
aria-label={ariaLabel ?? (typeof label === 'string' ? label : undefined)}
|
|
277
|
+
className={`kol-slider-float block min-w-0 ${label ? 'w-full' : className || 'w-full'}`.trim()}
|
|
278
|
+
style={{ '--kol-slider-pct': `${pct}%`, ...(length ? { width: length } : null), ...(label ? null : style) }}
|
|
279
|
+
/>
|
|
280
|
+
)
|
|
281
|
+
if (!label) return track
|
|
264
282
|
return (
|
|
265
|
-
<
|
|
266
|
-
{
|
|
267
|
-
|
|
268
|
-
{label && <label htmlFor={sliderId} className="kol-float-hint text-fg-emphasis whitespace-nowrap">{label}</label>}
|
|
269
|
-
{readout !== 'none' && <span className="kol-float-timecode text-fg-emphasis">{displayValue}</span>}
|
|
270
|
-
</div>
|
|
271
|
-
)}
|
|
272
|
-
<input
|
|
273
|
-
id={sliderId}
|
|
274
|
-
type="range"
|
|
275
|
-
min={min} max={max} step={step} value={value}
|
|
276
|
-
onChange={handleChange}
|
|
277
|
-
disabled={disabled}
|
|
278
|
-
aria-label={ariaLabel}
|
|
279
|
-
className="kol-slider-float w-full min-w-0"
|
|
280
|
-
style={{ '--kol-slider-pct': `${pct}%` }}
|
|
281
|
-
/>
|
|
282
|
-
</div>
|
|
283
|
+
<LabeledControl variant="float" label={label} hint={readout === 'value' ? displayValue : undefined} className={`${disabled ? 'opacity-40' : ''} ${className}`.trim()}>
|
|
284
|
+
{track}
|
|
285
|
+
</LabeledControl>
|
|
283
286
|
)
|
|
284
287
|
}
|
|
285
288
|
|