@kolkrabbi/kol-component 0.2.0 → 0.4.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.
Files changed (77) hide show
  1. package/package.json +11 -3
  2. package/src/atoms/AnimatedTitle.jsx +108 -0
  3. package/src/atoms/AssetGrid.jsx +29 -0
  4. package/src/atoms/Button.jsx +17 -6
  5. package/src/atoms/CurveOverlay.jsx +180 -0
  6. package/src/atoms/DocsToc.jsx +48 -0
  7. package/src/atoms/EmptyState.jsx +22 -0
  8. package/src/atoms/Figure.jsx +27 -0
  9. package/src/atoms/HlsVideo.jsx +56 -0
  10. package/src/atoms/OverlayGlassPanel.jsx +40 -0
  11. package/src/atoms/PriceDisplay.jsx +34 -0
  12. package/src/atoms/ProsePreview.jsx +53 -0
  13. package/src/atoms/QuantityInput.jsx +76 -114
  14. package/src/atoms/RotaryDial.jsx +150 -0
  15. package/src/atoms/SearchInput.jsx +108 -0
  16. package/src/atoms/TextPressure.jsx +331 -0
  17. package/src/atoms/TiltCard.jsx +127 -0
  18. package/src/atoms/TypeSample.jsx +50 -0
  19. package/src/atoms/TypeSpecCard.jsx +42 -0
  20. package/src/hooks/cssVar.js +53 -0
  21. package/src/hooks/useAxisAnimation.js +91 -0
  22. package/src/hooks/usePrefersReducedMotion.js +21 -0
  23. package/src/hooks/useTilt.js +49 -0
  24. package/src/index.js +66 -2
  25. package/src/molecules/AlignmentGrid.jsx +53 -0
  26. package/src/molecules/ArticleCard.jsx +178 -0
  27. package/src/molecules/CardFeatureItem.jsx +130 -0
  28. package/src/molecules/ColorInputRow.jsx +179 -0
  29. package/src/molecules/ColorRamp.jsx +114 -0
  30. package/src/molecules/FramedMediaBand.jsx +56 -0
  31. package/src/molecules/ImageBlock.jsx +34 -0
  32. package/src/molecules/MenuPopover.jsx +4 -27
  33. package/src/molecules/SelectionOverlay.jsx +108 -0
  34. package/src/molecules/ShapeDropdown.jsx +92 -0
  35. package/src/molecules/ShellDrawer.jsx +169 -0
  36. package/src/molecules/ShellSearchOverlay.jsx +177 -0
  37. package/src/molecules/SpecList.jsx +30 -0
  38. package/src/molecules/SpectrumControls.jsx +504 -0
  39. package/src/molecules/SwatchControls.jsx +217 -0
  40. package/src/molecules/TabsRow.jsx +87 -0
  41. package/src/molecules/VideoBlock.jsx +86 -0
  42. package/src/molecules/WorkListItem.jsx +83 -0
  43. package/src/molecules/foundry/SpecimenSectionHeader.jsx +89 -0
  44. package/src/organisms/ArticleHeader.jsx +95 -0
  45. package/src/organisms/AsciiCursor.jsx +526 -0
  46. package/src/organisms/BentoCard.jsx +187 -0
  47. package/src/organisms/Canvas.jsx +299 -0
  48. package/src/organisms/ColorLoader.jsx +155 -0
  49. package/src/organisms/CtaGlobal.jsx +67 -0
  50. package/src/organisms/DiagonalMarqueeRiver.jsx +138 -0
  51. package/src/organisms/EditorShell.jsx +111 -0
  52. package/src/organisms/ErrorBoundary.jsx +70 -0
  53. package/src/organisms/FeatureSplit.jsx +82 -0
  54. package/src/organisms/FeaturedCarousel.jsx +258 -0
  55. package/src/organisms/FeaturesCardSection.jsx +90 -0
  56. package/src/organisms/FullBleedHero.jsx +111 -0
  57. package/src/organisms/GalleryCarousel.jsx +83 -0
  58. package/src/organisms/LoaderOverlay.jsx +30 -0
  59. package/src/organisms/MediaViewer.jsx +95 -0
  60. package/src/organisms/NewsletterBand.jsx +122 -0
  61. package/src/organisms/ParallaxShelf.jsx +141 -0
  62. package/src/organisms/PortableTextRenderer.jsx +115 -0
  63. package/src/organisms/ProductDetailLayout.jsx +189 -0
  64. package/src/organisms/ScrollDriftGallery.jsx +214 -0
  65. package/src/organisms/SpectrumGrid.jsx +90 -0
  66. package/src/organisms/StackHero.jsx +83 -0
  67. package/src/organisms/WorkCard.jsx +120 -0
  68. package/src/organisms/WorkViewToggle.jsx +170 -0
  69. package/src/organisms/foundry/FontPreviewSection.jsx +187 -0
  70. package/src/organisms/foundry/FoundryCharacterSets.jsx +113 -0
  71. package/src/organisms/foundry/GlyphMetricsGrid.jsx +335 -0
  72. package/src/organisms/foundry/TypefaceHero.jsx +107 -0
  73. package/src/organisms/foundry/TypefaceStyleSection.jsx +163 -0
  74. package/src/organisms/foundry/VariableFontSection.jsx +158 -0
  75. package/src/organisms/foundry/glyphData.js +30 -0
  76. package/src/organisms/foundry/index.js +21 -0
  77. package/src/atoms/QuantityStepper.jsx +0 -149
@@ -0,0 +1,53 @@
1
+ /**
2
+ * ProsePreview — a full rich-text specimen: one `.kol-prose` block exercising
3
+ * every long-form element — H1–H4 ladder, section lede, body paragraph,
4
+ * blockquote, indented passage, code block, pullout, and unordered/ordered
5
+ * lists — so the KOL prose stylesheet can be reviewed end-to-end in one view.
6
+ * The "long-form" member of the type-specimen kit.
7
+ *
8
+ * Fixed structure; only the text slots vary. All element styling comes from
9
+ * the prose stylesheet (kol-typography.css) plus the kit's
10
+ * `.kol-prose-indented` / `.kol-prose-pullout` chrome — none lives here.
11
+ *
12
+ * @param {string} h1 trailing text of the H1 (rendered as `H1 — {h1}`)
13
+ * @param {string} paragraph body paragraph text
14
+ * @param {string} code contents of the <pre><code> block
15
+ * @param {string} pullout trailing text of the pullout (rendered as `Pullout — {pullout}`)
16
+ * @param {string} quote blockquote text
17
+ */
18
+ export default function ProsePreview({ h1, paragraph, code, pullout, quote = 'Above as below — justice is a starfield.' }) {
19
+ return (
20
+ <div className="kol-prose">
21
+ <h1>H1 — {h1}</h1>
22
+ <h2>H2 — Section title</h2>
23
+ <h3>H3 — Subsection</h3>
24
+ <h4>H4 — Block title</h4>
25
+ <p className="kol-sans-body-01 text-strong mb-6">
26
+ Section lede — a larger paragraph used to introduce a section and
27
+ establish tone before the body copy begins.
28
+ </p>
29
+ <p>{paragraph}</p>
30
+ <blockquote><p>{quote}</p></blockquote>
31
+ <div className="kol-prose-indented">
32
+ <p>
33
+ Indented passage. Used for tangential copy, contextual notes, or
34
+ nested argument that supports the main line.
35
+ </p>
36
+ </div>
37
+ <pre className="bg-fg-04 border border-fg-08"><code>{code}</code></pre>
38
+ <p className="kol-prose-pullout kol-helper-12 tracking-widest text-body">
39
+ Pullout — {pullout}
40
+ </p>
41
+ <ul>
42
+ <li>Unordered list — item one</li>
43
+ <li>Item two</li>
44
+ <li>Item three</li>
45
+ </ul>
46
+ <ol>
47
+ <li>Ordered list — item one</li>
48
+ <li>Item two</li>
49
+ <li>Item three</li>
50
+ </ol>
51
+ </div>
52
+ )
53
+ }
@@ -1,9 +1,31 @@
1
1
  import { useEffect, useState } from 'react'
2
2
 
3
+ /**
4
+ * QuantityInput — a compact integer quantity picker with two control layouts.
5
+ *
6
+ * controls="chevron" (default) — value with a stacked up/down chevron pair
7
+ * on the right, inside a full-width field.
8
+ * controls="split" — a − value + pill (minus and plus flank the
9
+ * value). The former `QuantityStepper`.
10
+ *
11
+ * Display-only value (not a text-editable input) — for an editable number
12
+ * field with bump chevrons use `Stepper`. Size auto-adapts to the viewport
13
+ * (sm < 768 ≤ md < 1024 ≤ lg) unless `size` pins it. Controlled: `value` +
14
+ * `(next) => onChange`, clamped to [min, max].
15
+ *
16
+ * @param {number} value current quantity (default 1)
17
+ * @param {Function} onChange (next) => void
18
+ * @param {number} min lower bound (default 1)
19
+ * @param {number} max upper bound (default 99)
20
+ * @param {string} controls 'chevron' (default) | 'split'
21
+ * @param {string} size 'sm' | 'md' | 'lg' — pins the responsive size
22
+ * @param {string} className extra classes on the root
23
+ */
24
+
3
25
  const SIZE_MAP = {
4
26
  sm: { fontSize: 11, paddingY: 12, paddingX: 24, radius: 20, icon: 10 },
5
27
  md: { fontSize: 12, paddingY: 14, paddingX: 24, radius: 22, icon: 12 },
6
- lg: { fontSize: 14, paddingY: 16, paddingX: 24, radius: 24, icon: 14 }
28
+ lg: { fontSize: 14, paddingY: 16, paddingX: 24, radius: 24, icon: 14 },
7
29
  }
8
30
 
9
31
  const QuantityInput = ({
@@ -11,33 +33,21 @@ const QuantityInput = ({
11
33
  onChange,
12
34
  min = 1,
13
35
  max = 99,
36
+ controls = 'chevron',
14
37
  size,
15
- className = ''
38
+ className = '',
16
39
  }) => {
17
40
  const [resolvedSize, setResolvedSize] = useState('md')
18
41
  const [componentWidth, setComponentWidth] = useState('180px')
19
42
 
20
43
  useEffect(() => {
21
44
  const determineSize = () => {
22
- if (size) {
23
- setResolvedSize(size)
24
- return
25
- }
26
-
27
- if (typeof window === 'undefined') {
28
- setResolvedSize('md')
29
- return
30
- }
31
-
32
- if (window.innerWidth >= 1024) {
33
- setResolvedSize('lg')
34
- } else if (window.innerWidth >= 768) {
35
- setResolvedSize('md')
36
- } else {
37
- setResolvedSize('sm')
38
- }
45
+ if (size) { setResolvedSize(size); return }
46
+ if (typeof window === 'undefined') { setResolvedSize('md'); return }
47
+ if (window.innerWidth >= 1024) setResolvedSize('lg')
48
+ else if (window.innerWidth >= 768) setResolvedSize('md')
49
+ else setResolvedSize('sm')
39
50
  }
40
-
41
51
  determineSize()
42
52
  window.addEventListener('resize', determineSize)
43
53
  return () => window.removeEventListener('resize', determineSize)
@@ -46,14 +56,9 @@ const QuantityInput = ({
46
56
  useEffect(() => {
47
57
  const updateWidth = () => {
48
58
  if (typeof window === 'undefined') return
49
-
50
- if (window.innerWidth >= 1024) {
51
- setComponentWidth('180px')
52
- } else if (window.innerWidth >= 768) {
53
- setComponentWidth('140px')
54
- } else {
55
- setComponentWidth('100px')
56
- }
59
+ if (window.innerWidth >= 1024) setComponentWidth('180px')
60
+ else if (window.innerWidth >= 768) setComponentWidth('140px')
61
+ else setComponentWidth('100px')
57
62
  }
58
63
  updateWidth()
59
64
  window.addEventListener('resize', updateWidth)
@@ -61,108 +66,65 @@ const QuantityInput = ({
61
66
  }, [])
62
67
 
63
68
  const metrics = SIZE_MAP[resolvedSize] || SIZE_MAP.md
69
+ const increment = () => { if (value < max) onChange?.(value + 1) }
70
+ const decrement = () => { if (value > min) onChange?.(value - 1) }
64
71
 
65
- const increment = () => {
66
- if (value < max) onChange?.(value + 1)
67
- }
68
-
69
- const decrement = () => {
70
- if (value > min) onChange?.(value - 1)
72
+ /* controls="split" — the − value + pill (formerly QuantityStepper). */
73
+ if (controls === 'split') {
74
+ const btn = (disabled) => ({
75
+ padding: `${metrics.paddingY}px 12px`,
76
+ display: 'flex', alignItems: 'center', justifyContent: 'center',
77
+ backgroundColor: 'transparent', border: 'none',
78
+ color: 'var(--kol-surface-on-primary)',
79
+ cursor: disabled ? 'not-allowed' : 'pointer',
80
+ opacity: disabled ? 0.3 : 1,
81
+ transition: 'opacity 0.15s',
82
+ fontFamily: 'var(--kol-font-family-mono)',
83
+ fontSize: `${metrics.fontSize}px`, lineHeight: '120%',
84
+ })
85
+ return (
86
+ <div
87
+ className={`flex items-center justify-center ${className}`}
88
+ style={{
89
+ width: componentWidth, minWidth: componentWidth,
90
+ border: '1px solid var(--kol-border-default)',
91
+ borderRadius: `${metrics.radius}px`,
92
+ backgroundColor: 'var(--kol-surface-primary)',
93
+ }}
94
+ >
95
+ <button type="button" onClick={decrement} disabled={value <= min} style={btn(value <= min)} aria-label="Decrease quantity">−</button>
96
+ <span style={{ minWidth: '24px', textAlign: 'center', color: 'var(--kol-surface-on-primary)', fontFamily: 'var(--kol-font-family-mono)', fontSize: `${metrics.fontSize}px`, lineHeight: '120%' }}>{value}</span>
97
+ <button type="button" onClick={increment} disabled={value >= max} style={btn(value >= max)} aria-label="Increase quantity">+</button>
98
+ </div>
99
+ )
71
100
  }
72
101
 
102
+ /* controls="chevron" (default) — value + stacked chevron pair on the right. */
73
103
  return (
74
- <div
75
- className={`relative block ${className}`}
76
- >
77
- {/* Border wrapper - EXPLICIT 42.5px height */}
104
+ <div className={`relative block ${className}`}>
78
105
  <div
79
106
  className="w-full flex items-center"
80
107
  style={{
81
- position: 'relative',
82
- height: '42.5px',
108
+ position: 'relative', height: '42.5px',
83
109
  border: '1px solid var(--kol-border-default)',
84
110
  borderRadius: `${metrics.radius}px`,
85
111
  backgroundColor: 'var(--kol-surface-primary)',
86
112
  color: 'var(--kol-surface-on-primary)',
87
- paddingLeft: `${metrics.paddingX}px`,
88
- paddingRight: `${metrics.paddingX}px`,
89
- fontSize: `${metrics.fontSize}px`,
90
- lineHeight: '120%',
91
- fontFamily: 'var(--kol-font-family-mono)',
92
- boxSizing: 'border-box'
113
+ paddingLeft: `${metrics.paddingX}px`, paddingRight: `${metrics.paddingX}px`,
114
+ fontSize: `${metrics.fontSize}px`, lineHeight: '120%',
115
+ fontFamily: 'var(--kol-font-family-mono)', boxSizing: 'border-box',
93
116
  }}
94
117
  >
95
118
  <span>{value}</span>
96
-
97
- {/* Chevrons - absolute, OUTSIDE the padded content */}
98
- <div
99
- style={{
100
- position: 'absolute',
101
- right: `${metrics.paddingX}px`,
102
- top: '50%',
103
- transform: 'translateY(-50%)',
104
- display: 'flex',
105
- flexDirection: 'column'
106
- }}
107
- >
108
- <button
109
- type="button"
110
- onClick={increment}
111
- disabled={value >= max}
112
- style={{
113
- backgroundColor: 'transparent',
114
- border: 'none',
115
- padding: '0',
116
- cursor: value >= max ? 'not-allowed' : 'pointer',
117
- opacity: value >= max ? 0.3 : 1,
118
- lineHeight: 0,
119
- display: 'block'
120
- }}
121
- aria-label="Increase quantity"
122
- >
123
- <svg
124
- width={metrics.icon}
125
- height={metrics.icon}
126
- viewBox="0 0 12 12"
127
- fill="none"
128
- >
129
- <path
130
- d="m3 7 3-3 3 3"
131
- stroke="currentColor"
132
- strokeWidth="1.25"
133
- strokeLinecap="round"
134
- strokeLinejoin="round"
135
- />
119
+ <div style={{ position: 'absolute', right: `${metrics.paddingX}px`, top: '50%', transform: 'translateY(-50%)', display: 'flex', flexDirection: 'column' }}>
120
+ <button type="button" onClick={increment} disabled={value >= max} style={{ backgroundColor: 'transparent', border: 'none', padding: '0', cursor: value >= max ? 'not-allowed' : 'pointer', opacity: value >= max ? 0.3 : 1, lineHeight: 0, display: 'block' }} aria-label="Increase quantity">
121
+ <svg width={metrics.icon} height={metrics.icon} viewBox="0 0 12 12" fill="none">
122
+ <path d="m3 7 3-3 3 3" stroke="currentColor" strokeWidth="1.25" strokeLinecap="round" strokeLinejoin="round" />
136
123
  </svg>
137
124
  </button>
138
- <button
139
- type="button"
140
- onClick={decrement}
141
- disabled={value <= min}
142
- style={{
143
- backgroundColor: 'transparent',
144
- border: 'none',
145
- padding: '0',
146
- cursor: value <= min ? 'not-allowed' : 'pointer',
147
- opacity: value <= min ? 0.3 : 1,
148
- lineHeight: 0,
149
- display: 'block'
150
- }}
151
- aria-label="Decrease quantity"
152
- >
153
- <svg
154
- width={metrics.icon}
155
- height={metrics.icon}
156
- viewBox="0 0 12 12"
157
- fill="none"
158
- >
159
- <path
160
- d="m3 5 3 3 3-3"
161
- stroke="currentColor"
162
- strokeWidth="1.25"
163
- strokeLinecap="round"
164
- strokeLinejoin="round"
165
- />
125
+ <button type="button" onClick={decrement} disabled={value <= min} style={{ backgroundColor: 'transparent', border: 'none', padding: '0', cursor: value <= min ? 'not-allowed' : 'pointer', opacity: value <= min ? 0.3 : 1, lineHeight: 0, display: 'block' }} aria-label="Decrease quantity">
126
+ <svg width={metrics.icon} height={metrics.icon} viewBox="0 0 12 12" fill="none">
127
+ <path d="m3 5 3 3 3-3" stroke="currentColor" strokeWidth="1.25" strokeLinecap="round" strokeLinejoin="round" />
166
128
  </svg>
167
129
  </button>
168
130
  </div>
@@ -0,0 +1,150 @@
1
+ import { useEffect, useRef, useState } from 'react'
2
+
3
+ /** Clamp to min–max, snapped to the nearest step from min. */
4
+ const snapTo = (v, min, max, step) => {
5
+ const stepped = min + Math.round((v - min) / step) * step
6
+ return Math.max(min, Math.min(max, stepped))
7
+ }
8
+
9
+ /**
10
+ * RotaryDial — drag-to-set rotary knob numeric input. Vertical pointer drag
11
+ * rotates the whole dial over a 270° sweep (−135° to +135°) mapped onto
12
+ * min–max; a full sweep is ~200px of drag, movement measured absolute from
13
+ * drag start. Controlled (`value`/`onChange`) with a local visual buffer so
14
+ * rotation stays smooth while parent updates are RAF-throttled; the final
15
+ * value fires on release. Focus + arrow keys step the value
16
+ * (role="slider" with aria-valuemin/max/now). The label and `%` readout
17
+ * rows render only when `label` is set; label text renders as authored.
18
+ *
19
+ * @param {string} label text under the dial; also gates the label + readout rows
20
+ * @param {number} value controlled value within min–max
21
+ * @param {Function} onChange (next: number) => void — RAF-throttled while dragging, final on release
22
+ * @param {number} min minimum value (default 0)
23
+ * @param {number} max maximum value (default 100)
24
+ * @param {number} step drag snap / arrow-key increment (default 1)
25
+ * @param {number} size dial px size (default 80); derives ring + disc radii
26
+ */
27
+ export default function RotaryDial({
28
+ label,
29
+ value = 0,
30
+ onChange,
31
+ min = 0,
32
+ max = 100,
33
+ step = 1,
34
+ size = 80,
35
+ }) {
36
+ const [isDragging, setIsDragging] = useState(false)
37
+ const [localValue, setLocalValue] = useState(value) // visual buffer — updates every move
38
+ const dragRef = useRef({ startY: 0, startValue: 0 })
39
+ const rafRef = useRef(null)
40
+ const onChangeRef = useRef(onChange)
41
+ onChangeRef.current = onChange
42
+
43
+ // External updates land whenever a drag isn't in progress
44
+ useEffect(() => {
45
+ if (!isDragging) setLocalValue(value)
46
+ }, [value, isDragging])
47
+
48
+ useEffect(() => {
49
+ if (!isDragging) return
50
+ let current = dragRef.current.startValue
51
+ const handleMove = (e) => {
52
+ // absolute delta from drag start; full min→max sweep ≈ 200px
53
+ const deltaY = dragRef.current.startY - e.clientY
54
+ current = snapTo(dragRef.current.startValue + deltaY * ((max - min) / 200), min, max, step)
55
+ setLocalValue(current)
56
+ if (!rafRef.current) {
57
+ rafRef.current = requestAnimationFrame(() => {
58
+ onChangeRef.current?.(current)
59
+ rafRef.current = null
60
+ })
61
+ }
62
+ }
63
+ const handleUp = () => {
64
+ setIsDragging(false)
65
+ if (rafRef.current) {
66
+ cancelAnimationFrame(rafRef.current)
67
+ rafRef.current = null
68
+ }
69
+ onChangeRef.current?.(current)
70
+ }
71
+ window.addEventListener('pointermove', handleMove)
72
+ window.addEventListener('pointerup', handleUp)
73
+ window.addEventListener('pointercancel', handleUp)
74
+ return () => {
75
+ window.removeEventListener('pointermove', handleMove)
76
+ window.removeEventListener('pointerup', handleUp)
77
+ window.removeEventListener('pointercancel', handleUp)
78
+ }
79
+ }, [isDragging, min, max, step])
80
+
81
+ const handlePointerDown = (e) => {
82
+ setIsDragging(true)
83
+ dragRef.current = { startY: e.clientY, startValue: localValue }
84
+ }
85
+
86
+ const handleKeyDown = (e) => {
87
+ let next = null
88
+ if (e.key === 'ArrowUp' || e.key === 'ArrowRight') next = snapTo(localValue + step, min, max, step)
89
+ else if (e.key === 'ArrowDown' || e.key === 'ArrowLeft') next = snapTo(localValue - step, min, max, step)
90
+ if (next === null) return
91
+ e.preventDefault()
92
+ setLocalValue(next)
93
+ onChange?.(next)
94
+ }
95
+
96
+ const outerRadius = size / 2
97
+ const innerRadius = (size * 0.7) / 2
98
+ const strokeWidth = 2
99
+ const angle = -135 + ((localValue - min) / (max - min || 1)) * 270
100
+
101
+ return (
102
+ <div className="flex flex-col items-center gap-2">
103
+ <div
104
+ role="slider"
105
+ tabIndex={0}
106
+ aria-label={label}
107
+ aria-valuemin={min}
108
+ aria-valuemax={max}
109
+ aria-valuenow={localValue}
110
+ className="relative cursor-pointer select-none touch-none"
111
+ style={{
112
+ width: size,
113
+ height: size,
114
+ transform: `rotate(${angle}deg)`,
115
+ willChange: isDragging ? 'transform' : 'auto',
116
+ }}
117
+ onPointerDown={handlePointerDown}
118
+ onKeyDown={handleKeyDown}
119
+ >
120
+ <svg width={size} height={size} viewBox={`0 0 ${size} ${size}`} style={{ overflow: 'visible' }}>
121
+ {/* outer dashed tick ring */}
122
+ <circle
123
+ cx={outerRadius}
124
+ cy={outerRadius}
125
+ r={outerRadius - strokeWidth}
126
+ fill="none"
127
+ stroke="currentColor"
128
+ strokeWidth={strokeWidth}
129
+ strokeDasharray="4 4"
130
+ className="text-fg-24"
131
+ />
132
+ {/* inner solid disc */}
133
+ <circle cx={outerRadius} cy={outerRadius} r={innerRadius} fill="currentColor" className="text-fg-96" />
134
+ {/* pointer notch — reads as a cut into the disc */}
135
+ <line
136
+ x1={outerRadius}
137
+ y1={outerRadius}
138
+ x2={outerRadius}
139
+ y2={outerRadius - innerRadius + 4}
140
+ stroke="var(--kol-surface-primary)"
141
+ strokeWidth={2}
142
+ strokeLinecap="round"
143
+ />
144
+ </svg>
145
+ </div>
146
+ {label && <div className="kol-helper-12 text-fg-64">{label}</div>}
147
+ {label && <div className="kol-helper-12 text-fg-96">{value}%</div>}
148
+ </div>
149
+ )
150
+ }
@@ -0,0 +1,108 @@
1
+ import { Icon } from '@kolkrabbi/kol-loader'
2
+
3
+ /**
4
+ * SearchInput — controlled search field on the .kol-control shell. The
5
+ * search-flavored sibling of Input (same variant/size chrome + inner-input
6
+ * treatment), standalone because atoms can't nest atoms. Leading search
7
+ * icon, then two mutually exclusive trailing affordances: a caller-authored
8
+ * shortcut kbd chip while the value is empty, a clear × while it isn't.
9
+ *
10
+ * Always controlled (`value` defaults to ''). Controlled + no onChange =
11
+ * deliberate display-only → readOnly, same convention as Input. Extra props
12
+ * (onKeyDown, autoFocus, role, aria-*) spread onto the inner <input> —
13
+ * ShellSearchOverlay drives its combobox wiring through that seam.
14
+ *
15
+ * `type="search"` for semantics (searchbox role, mobile "search" enter key);
16
+ * the native WebKit cancel button is hidden so the × stays the only clear
17
+ * affordance.
18
+ *
19
+ * @param {string} value controlled value
20
+ * @param {Function} onChange (event) => void — input change
21
+ * @param {string} placeholder placeholder text
22
+ * @param {Function} onClear () => void — trailing × click; × renders only when set and value is non-empty
23
+ * @param {string} shortcutHint caller-authored kbd chip (e.g. "⌘K"); shown while the value is empty
24
+ * @param {Function} onFocus (event) => void — input focus
25
+ * @param {string} size 'sm' | 'md' — kol-control size + matched mono type class
26
+ * @param {string} variant 'filled' | 'ghost' | 'outline' — kol-control variant, same chrome as Input (ignored when bare)
27
+ * @param {boolean} bare borderless inline field for overlay panels (full width, no shell chrome; keeps icon/clear/chip slots)
28
+ * @param {string} className extra classes on the shell
29
+ */
30
+
31
+ const SIZE_TYPE = { sm: 'kol-mono-12', md: 'kol-mono-14' }
32
+ const ICON_SIZE = { sm: 14, md: 14 }
33
+
34
+ export default function SearchInput({
35
+ value = '',
36
+ onChange,
37
+ placeholder = 'Search…',
38
+ onClear,
39
+ shortcutHint,
40
+ onFocus,
41
+ size = 'md',
42
+ variant = 'filled',
43
+ bare = false,
44
+ className = '',
45
+ ...inputProps
46
+ }) {
47
+ const shellCls = [
48
+ bare
49
+ ? 'flex w-full gap-2.5 px-4 py-3'
50
+ : `kol-control kol-control--${variant} kol-control-${size} gap-2`,
51
+ 'items-center cursor-text',
52
+ SIZE_TYPE[size],
53
+ className,
54
+ ].filter(Boolean).join(' ')
55
+
56
+ /* Same height pin as Input: Chromium sizes an <input> from font metrics,
57
+ * not CSS line-height, so without this the shell lands ~0.5px tall.
58
+ * h-4 / h-[18px] match the kol-mono-12 / -14 line-heights. */
59
+ const heightCls = size === 'sm' ? 'h-4' : 'h-[18px]'
60
+
61
+ const inputCls = [
62
+ 'min-w-0 flex-1 bg-transparent border-none outline-none text-auto',
63
+ 'appearance-none [&::-webkit-search-cancel-button]:hidden',
64
+ heightCls,
65
+ ].join(' ')
66
+
67
+ return (
68
+ <label className={shellCls}>
69
+ <span
70
+ aria-hidden="true"
71
+ className={`flex items-center shrink-0 ${bare ? 'text-fg-48' : 'text-auto opacity-50'}`}
72
+ >
73
+ <Icon name="search" size={ICON_SIZE[size] ?? 14} />
74
+ </span>
75
+ <input
76
+ type="search"
77
+ value={value ?? ''}
78
+ onChange={onChange}
79
+ readOnly={!onChange || undefined}
80
+ onFocus={onFocus}
81
+ placeholder={placeholder}
82
+ spellCheck={false}
83
+ className={inputCls}
84
+ {...inputProps}
85
+ />
86
+ {onClear && value ? (
87
+ <button
88
+ type="button"
89
+ aria-label="Clear"
90
+ /* preventDefault on mousedown keeps focus in the input across the clear */
91
+ onMouseDown={(e) => e.preventDefault()}
92
+ onClick={onClear}
93
+ className="inline-flex items-center justify-center shrink-0 cursor-pointer text-fg-48 hover:text-fg-96 transition-colors"
94
+ >
95
+ <Icon name="x" size={12} />
96
+ </button>
97
+ ) : shortcutHint ? (
98
+ /* aria-hidden — affordance, not a label (same stance as Input's prefix/suffix) */
99
+ <kbd
100
+ aria-hidden="true"
101
+ className="inline-flex items-center justify-center shrink-0 h-4 min-w-4 px-1 rounded-[3px] bg-fg-08 kol-helper-10 text-fg-48"
102
+ >
103
+ {shortcutHint}
104
+ </kbd>
105
+ ) : null}
106
+ </label>
107
+ )
108
+ }