@tangible/ui 0.2.0 → 0.2.2

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 (39) hide show
  1. package/components/Card/Card.d.ts +18 -1
  2. package/components/Card/Card.js +41 -4
  3. package/components/Card/index.d.ts +1 -1
  4. package/components/ColorPicker/ColorArea.d.ts +24 -0
  5. package/components/ColorPicker/ColorArea.js +62 -0
  6. package/components/ColorPicker/ColorField.d.ts +59 -0
  7. package/components/ColorPicker/ColorField.js +88 -0
  8. package/components/ColorPicker/ColorPicker.d.ts +36 -0
  9. package/components/ColorPicker/ColorPicker.js +215 -0
  10. package/components/ColorPicker/ColorSlider.d.ts +20 -0
  11. package/components/ColorPicker/ColorSlider.js +38 -0
  12. package/components/ColorPicker/index.d.ts +14 -0
  13. package/components/ColorPicker/index.js +7 -0
  14. package/components/ColorPicker/labels.d.ts +42 -0
  15. package/components/ColorPicker/labels.js +38 -0
  16. package/components/ColorPicker/tracks.d.ts +4 -0
  17. package/components/ColorPicker/tracks.js +4 -0
  18. package/components/ColorPicker/usePointerDrag.d.ts +13 -0
  19. package/components/ColorPicker/usePointerDrag.js +34 -0
  20. package/components/Popover/index.d.ts +1 -1
  21. package/components/index.d.ts +4 -1
  22. package/components/index.js +1 -0
  23. package/icons/icons.svg +1 -0
  24. package/icons/manifest.json +8 -0
  25. package/icons/registry.d.ts +2 -0
  26. package/icons/registry.js +1 -0
  27. package/icons/system/index.d.ts +2 -0
  28. package/icons/system/index.js +11 -0
  29. package/package.json +5 -1
  30. package/styles/all.css +1 -1
  31. package/styles/all.expanded.css +327 -8
  32. package/styles/all.expanded.unlayered.css +327 -8
  33. package/styles/all.unlayered.css +1 -1
  34. package/styles/components/_bundle.scss +2 -0
  35. package/styles/components/card.scss +94 -13
  36. package/styles/components/color-picker.scss +378 -0
  37. package/tui-manifest.json +117 -10
  38. package/utils/color/color.d.ts +61 -0
  39. package/utils/color/color.js +293 -0
@@ -8,6 +8,7 @@
8
8
  @use "./chip" as chip;
9
9
  @use "./chip-group" as chipgroup;
10
10
  @use "./combobox" as combobox;
11
+ @use "./color-picker" as colorpicker;
11
12
  @use "./multi-combobox" as multicombobox;
12
13
  @use "./content-indicator" as contentindicator;
13
14
  @use "./date-picker" as datepicker;
@@ -74,6 +75,7 @@ $-input-dependents: (input, field, text-input, textarea, pager);
74
75
  @if -wants($only, chip) { @include chip.styles(); }
75
76
  @if -wants($only, chip-group) { @include chipgroup.styles(); }
76
77
  @if -wants($only, combobox) { @include combobox.styles(); }
78
+ @if -wants($only, color-picker) { @include colorpicker.styles(); }
77
79
  @if -wants($only, multi-combobox) { @include multicombobox.styles(); }
78
80
  @if -wants($only, content-indicator) { @include contentindicator.styles(); }
79
81
  @if -wants($only, date-picker) { @include datepicker.styles(); }
@@ -2,12 +2,15 @@
2
2
 
3
3
  /* @tui-tokens
4
4
  --tui-card-bg
5
+ --tui-card-bg-interact
5
6
  --tui-card-border
6
7
  --tui-card-border-width
7
8
  --tui-card-border-interact
9
+ --tui-card-border-active
8
10
  --tui-card-radius
9
11
  --tui-card-shadow
10
12
  --tui-card-shadow-interact
13
+ --tui-card-gap
11
14
  --tui-card-padding
12
15
  --tui-card-foot-basis
13
16
  */
@@ -19,13 +22,15 @@
19
22
  //
20
23
  // Component API tokens (never defined here, only read via fallback):
21
24
  // --tui-card-bg Background color
25
+ // --tui-card-bg-interact Hover/focus fill (default: no change; ghost: bg-muted)
22
26
  // --tui-card-border Border color
23
27
  // --tui-card-border-width Border width (falls back to --tui-border-width)
24
28
  // --tui-card-border-interact Hover/focus border color
25
29
  // --tui-card-radius Border radius
26
30
  // --tui-card-shadow Box shadow (elevated style)
27
31
  // --tui-card-shadow-interact Hover box shadow (elevated style)
28
- // --tui-card-padding Padding (inline and block)
32
+ // --tui-card-padding Edge padding on card items (inline and block)
33
+ // --tui-card-gap Gap between card items (block for stacked, inline for side-by-side)
29
34
  // --tui-card-foot-basis Flex basis for foot in inline layout
30
35
  //
31
36
  // To override from consuming code:
@@ -42,7 +47,11 @@
42
47
  --_radius: var(--#{sys.$prefix}card-radius, var(--#{sys.$prefix}radius-md));
43
48
  --_shadow: var(--#{sys.$prefix}card-shadow, var(--#{sys.$prefix}shadow-sm));
44
49
  --_shadow-interact: var(--#{sys.$prefix}card-shadow-interact, var(--#{sys.$prefix}shadow-md));
50
+ // Hover fill — defaults to the resting bg (no change). Ghost overrides it to
51
+ // a real fill; any variant can opt in via --tui-card-bg-interact.
52
+ --_bg-interact: var(--#{sys.$prefix}card-bg-interact, var(--_bg));
45
53
  --_padding: var(--#{sys.$prefix}card-padding, var(--#{sys.$prefix}spacing-lg));
54
+ --_gap: var(--#{sys.$prefix}card-gap, var(--#{sys.$prefix}spacing-lg));
46
55
  // 500px fallback gives the foot slot enough room for action buttons in inline
47
56
  // layout without crowding the body. Override via --tui-card-foot-basis.
48
57
  --_foot-basis: var(--#{sys.$prefix}card-foot-basis, 500px);
@@ -70,6 +79,7 @@
70
79
 
71
80
  .#{sys.$prefix}card__media.is-flush {
72
81
  margin-inline: calc(var(--_padding) * -1);
82
+ max-width: 100%; // fallback if the calc below is invalid (unitless padding)
73
83
  max-width: calc(100% + 2 * var(--_padding));
74
84
  border-radius: 0;
75
85
  }
@@ -77,22 +87,38 @@
77
87
  // -------------------------------------------------------------------------
78
88
  // Slots
79
89
  // -------------------------------------------------------------------------
90
+ // Per-slot padding (matches Modal/Notice): slots sit flush so a border/bg on
91
+ // a slot reads as a clean section separator; between-slot spacing comes from
92
+ // head's bottom + foot's top padding.
80
93
  &__head {
81
- padding-block: var(--_padding);
94
+ padding-block: var(--_gap);
82
95
  padding-inline: var(--_padding);
83
96
  width: 100%;
84
97
 
98
+ &:first-child {
99
+ padding-block-start: var(--_padding);
100
+ }
101
+
102
+ &:last-child {
103
+ padding-block-end: var(--_padding);
104
+ }
105
+
106
+ &:not(:first-child) {
107
+ padding-block-start: unset;
108
+ }
109
+
85
110
  .#{sys.$prefix}card__media.is-flush:first-child {
86
111
  margin-block-start: calc(var(--_padding) * -1);
87
- // 1px inset is intentional for sub-pixel precision — ensures flush media
88
- // corners sit cleanly inside the card border. Not referencing --tui-border-width
89
- // because the visual correction is independent of border thickness.
90
- border-start-end-radius: calc(var(--_radius) - 1px);
91
- border-start-start-radius: calc(var(--_radius) - 1px);
112
+ // Concentric radius: the flush media's inner corner = outer radius minus
113
+ // the border thickness, so it tucks cleanly inside the card border at any
114
+ // border width (the old `- 1px` only held at the default 1px border).
115
+ border-start-end-radius: calc(var(--_radius) - var(--_border-width));
116
+ border-start-start-radius: calc(var(--_radius) - var(--_border-width));
92
117
  }
93
118
  }
94
119
 
95
120
  &__body {
121
+ padding-block: var(--_gap);
96
122
  padding-inline: var(--_padding);
97
123
  width: 100%;
98
124
 
@@ -115,17 +141,36 @@
115
141
  &:last-child {
116
142
  padding-block-end: var(--_padding);
117
143
  }
144
+
145
+ &:not(:first-child) {
146
+ padding-block-start: unset;
147
+ }
118
148
  }
119
149
 
120
150
  &__foot {
121
- padding-block: var(--_padding);
151
+ padding-block: var(--_gap);
122
152
  padding-inline: var(--_padding);
123
153
  width: 100%;
154
+
155
+ &:first-child {
156
+ padding-block-start: var(--_padding);
157
+ }
158
+
159
+ &:last-child {
160
+ padding-block-end: var(--_padding);
161
+ }
162
+
163
+ &:not(:first-child) {
164
+ padding-block-start: unset;
165
+ }
124
166
 
125
167
  .#{sys.$prefix}card__media.is-flush:last-child {
168
+ // Cancel the foot's last-child edge padding (--_padding), matching the
169
+ // head's flush media — not --_gap, so a bottom image bleeds to the edge
170
+ // even when gap and padding are tuned apart.
126
171
  margin-block-end: calc(var(--_padding) * -1);
127
- border-end-end-radius: calc(var(--_radius) - 1px);
128
- border-end-start-radius: calc(var(--_radius) - 1px);
172
+ border-end-end-radius: calc(var(--_radius) - var(--_border-width));
173
+ border-end-start-radius: calc(var(--_radius) - var(--_border-width));
129
174
  }
130
175
  }
131
176
 
@@ -163,9 +208,10 @@
163
208
 
164
209
  .#{sys.$prefix}card__media.is-flush:first-child {
165
210
  margin-inline-end: var(--_padding);
211
+ max-width: 100%; // fallback if the calc below is invalid
166
212
  max-width: calc(100% + var(--_padding));
167
213
  border-start-end-radius: 0;
168
- border-end-start-radius: calc(var(--_radius) - 1px);
214
+ border-end-start-radius: calc(var(--_radius) - var(--_border-width));
169
215
  }
170
216
  }
171
217
 
@@ -184,9 +230,10 @@
184
230
 
185
231
  .#{sys.$prefix}card__media.is-flush:last-child {
186
232
  margin-inline-start: var(--_padding);
233
+ max-width: 100%; // fallback if the calc below is invalid
187
234
  max-width: calc(100% + var(--_padding));
188
235
  border-end-start-radius: 0;
189
- border-start-end-radius: calc(var(--_radius) - 1px);
236
+ border-start-end-radius: calc(var(--_radius) - var(--_border-width));
190
237
  }
191
238
  }
192
239
 
@@ -214,11 +261,13 @@
214
261
 
215
262
  &:hover {
216
263
  --_border: var(--_border-interact);
264
+ background-color: var(--_bg-interact);
217
265
  }
218
266
 
219
267
  &:focus-visible,
220
268
  &:has(:focus-visible) {
221
269
  --_border: var(--_border-interact);
270
+ background-color: var(--_bg-interact);
222
271
  }
223
272
 
224
273
  &:active,
@@ -247,8 +296,12 @@
247
296
  }
248
297
 
249
298
  // -------------------------------------------------------------------------
250
- // Elevated style
299
+ // Surface variants
251
300
  // -------------------------------------------------------------------------
301
+ // Base (unclassed) = solid: fill + border. `is-style-solid` is a no-op so
302
+ // React always emitting it, and CSS-only `.tui-card`, both read as solid.
303
+
304
+ // Elevated: solid + shadow (keeps the border). Hover grows the shadow.
252
305
  &.is-style-elevated {
253
306
  box-shadow: var(--_shadow);
254
307
  transition-property: border-color, color, background-color, box-shadow;
@@ -257,5 +310,33 @@
257
310
  box-shadow: var(--_shadow-interact);
258
311
  }
259
312
  }
313
+
314
+ // Outline: border only, no fill.
315
+ &.is-style-outline {
316
+ --_bg: transparent;
317
+ }
318
+
319
+ // Ghost: no resting chrome, reveals a fill on interaction. Border colour goes
320
+ // transparent (box metrics preserved so it aligns with solid/outline in grids).
321
+ &.is-style-ghost {
322
+ --_bg: transparent;
323
+ --_border: transparent;
324
+ --_bg-interact: var(--#{sys.$prefix}card-bg-interact, var(--#{sys.$prefix}color-bg-muted));
325
+ }
326
+
327
+ // Seamless: bare structure — no fill, no border, no padding. border-width is
328
+ // zeroed so the shared `.has-interaction` hover can't paint a border either;
329
+ // it stays bare on hover (focus ring is the only affordance). Reach for
330
+ // `ghost` when you want a hover-reveal on a chrome-less card.
331
+ &.is-style-seamless {
332
+ --_bg: transparent;
333
+ --_border: transparent;
334
+ // 0px, NOT 0 — these feed calcs (`calc(100% + var(--_padding))`,
335
+ // `calc(var(--_radius) - var(--_border-width))`). A unitless zero makes
336
+ // those calcs invalid, which drops the media's max-width and blows the
337
+ // image out to its intrinsic size.
338
+ --_border-width: 0px;
339
+ --_padding: 0px;
340
+ }
260
341
  }
261
342
  }
@@ -0,0 +1,378 @@
1
+ @use "../system" as sys;
2
+
3
+ /* @tui-tokens
4
+ --tui-color-area-radius
5
+ --tui-color-area-min-height
6
+ --tui-color-area-thumb-size
7
+ --tui-color-slider-radius
8
+ --tui-color-slider-height
9
+ --tui-color-slider-thumb-size
10
+ */
11
+
12
+ @mixin styles() {
13
+ // ==========================================================================
14
+ // ColorPicker primitives — ColorArea (2D) + ColorSlider (hue / alpha)
15
+ // ==========================================================================
16
+ //
17
+ // The thumb chrome (white ring + dark halo) and the alpha checkerboard use
18
+ // fixed neutral values on purpose: they must read on top of an ARBITRARY
19
+ // user colour, so they can't defer to theme tokens.
20
+
21
+ // ---------------------------------------------------------------------------
22
+ // Color area — 2D saturation × value
23
+ // ---------------------------------------------------------------------------
24
+ .#{sys.$prefix}interface .#{sys.$prefix}color-area {
25
+ position: relative;
26
+ width: 100%;
27
+ aspect-ratio: 3 / 2;
28
+ min-height: var(--#{sys.$prefix}color-area-min-height, 140px);
29
+ border-radius: var(--#{sys.$prefix}color-area-radius, var(--#{sys.$prefix}radius-md));
30
+ cursor: crosshair;
31
+ touch-action: none;
32
+ user-select: none;
33
+
34
+ &:focus-visible {
35
+ outline: var(--#{sys.$prefix}focus-ring-width) solid var(--#{sys.$prefix}focus-ring-color);
36
+ outline-offset: var(--#{sys.$prefix}focus-ring-offset);
37
+ }
38
+
39
+ &.is-disabled {
40
+ opacity: var(--#{sys.$prefix}opacity-disabled);
41
+ pointer-events: none;
42
+ }
43
+ }
44
+
45
+ .#{sys.$prefix}interface .#{sys.$prefix}color-area__thumb {
46
+ position: absolute;
47
+ width: var(--#{sys.$prefix}color-area-thumb-size, 14px);
48
+ height: var(--#{sys.$prefix}color-area-thumb-size, 14px);
49
+ transform: translate(-50%, -50%);
50
+ border-radius: var(--#{sys.$prefix}radius-full, 999px);
51
+ background: var(--_swatch);
52
+ border: 2px solid #fff;
53
+ box-shadow: 0 0 0 1px rgb(0 0 0 / 0.35);
54
+ pointer-events: none;
55
+ }
56
+
57
+ // ---------------------------------------------------------------------------
58
+ // Color slider — hue / alpha
59
+ // ---------------------------------------------------------------------------
60
+ .#{sys.$prefix}interface .#{sys.$prefix}color-slider {
61
+ position: relative;
62
+ height: var(--#{sys.$prefix}color-slider-height, 12px);
63
+ border-radius: var(--#{sys.$prefix}color-slider-radius, var(--#{sys.$prefix}radius-full, 999px));
64
+ cursor: pointer;
65
+ touch-action: none;
66
+ user-select: none;
67
+
68
+ &:focus-visible {
69
+ outline: var(--#{sys.$prefix}focus-ring-width) solid var(--#{sys.$prefix}focus-ring-color);
70
+ outline-offset: var(--#{sys.$prefix}focus-ring-offset);
71
+ }
72
+
73
+ &.is-disabled {
74
+ opacity: var(--#{sys.$prefix}opacity-disabled);
75
+ pointer-events: none;
76
+ }
77
+
78
+ // Alpha checkerboard (fixed neutral — a transparency indicator)
79
+ &.has-checkerboard {
80
+ background-color: #fff;
81
+ background-image: linear-gradient(45deg, #ccc 25%, transparent 25%),
82
+ linear-gradient(-45deg, #ccc 25%, transparent 25%),
83
+ linear-gradient(45deg, transparent 75%, #ccc 75%),
84
+ linear-gradient(-45deg, transparent 75%, #ccc 75%);
85
+ background-size: 8px 8px;
86
+ background-position: 0 0, 0 4px, 4px -4px, -4px 0;
87
+ }
88
+ }
89
+
90
+ .#{sys.$prefix}interface .#{sys.$prefix}color-slider__track {
91
+ position: absolute;
92
+ inset: 0;
93
+ border-radius: inherit;
94
+ }
95
+
96
+ .#{sys.$prefix}interface .#{sys.$prefix}color-slider__thumb {
97
+ position: absolute;
98
+ top: 50%;
99
+ width: var(--#{sys.$prefix}color-slider-thumb-size, 16px);
100
+ height: var(--#{sys.$prefix}color-slider-thumb-size, 16px);
101
+ transform: translate(-50%, -50%);
102
+ border-radius: var(--#{sys.$prefix}radius-full, 999px);
103
+ background: transparent;
104
+ border: 2px solid #fff;
105
+ box-shadow: 0 0 0 1px rgb(0 0 0 / 0.35);
106
+ pointer-events: none;
107
+ }
108
+
109
+ // ---------------------------------------------------------------------------
110
+ // ColorPicker composition
111
+ // ---------------------------------------------------------------------------
112
+ .#{sys.$prefix}interface .#{sys.$prefix}color-picker {
113
+ display: flex;
114
+ flex-direction: column;
115
+ gap: var(--#{sys.$prefix}spacing-sm);
116
+ width: 100%;
117
+
118
+ &.is-disabled {
119
+ opacity: var(--#{sys.$prefix}opacity-disabled);
120
+ }
121
+ }
122
+
123
+ .#{sys.$prefix}interface .#{sys.$prefix}color-picker__value {
124
+ display: flex;
125
+ align-items: center;
126
+ gap: var(--#{sys.$prefix}spacing-xxs);
127
+ }
128
+
129
+ // Copy button fills the row height so it lines up with the field group.
130
+ // Extra specificity to beat IconButton's own fixed height.
131
+ .#{sys.$prefix}interface .#{sys.$prefix}color-picker__value .#{sys.$prefix}color-picker__copy {
132
+ flex: none;
133
+ align-self: stretch;
134
+ block-size: auto;
135
+ height: auto;
136
+ }
137
+
138
+ // Compact format Select trigger; the value field takes the rest of the width.
139
+ // Smaller type keeps the trigger narrow so wide formats (oklch) don't squish
140
+ // the channel inputs. Height stays put — the named control-height token wins.
141
+ .#{sys.$prefix}interface .#{sys.$prefix}color-picker__format {
142
+ flex: none;
143
+ min-width: 0;
144
+ font-size: var(--#{sys.$prefix}typography-size-xs);
145
+ padding-inline: var(--#{sys.$prefix}spacing-xs);
146
+ }
147
+
148
+ // The value field group — one bordered box holding the hex/var input OR the
149
+ // per-channel inputs, with a compact format switcher at its trailing edge.
150
+ // Matches the control height of its neighbours (swatch, copy).
151
+ .#{sys.$prefix}interface .#{sys.$prefix}color-picker__field-group {
152
+ flex: 1 1 auto;
153
+ min-width: 0;
154
+ display: flex;
155
+ align-items: center;
156
+ gap: var(--#{sys.$prefix}spacing-xxs);
157
+ min-height: var(--#{sys.$prefix}control-height-md, 2.5rem);
158
+ padding-inline: var(--#{sys.$prefix}spacing-xxs);
159
+ border: var(--#{sys.$prefix}border-width) solid var(--#{sys.$prefix}color-border);
160
+ border-radius: var(--#{sys.$prefix}radius-md);
161
+ background: var(--#{sys.$prefix}input-bg, var(--#{sys.$prefix}color-bg-surface));
162
+ font-size: var(--#{sys.$prefix}typography-size-xs);
163
+
164
+ &:focus-within {
165
+ border-color: var(--#{sys.$prefix}focus-ring-color);
166
+ outline: var(--#{sys.$prefix}focus-ring-width) solid var(--#{sys.$prefix}focus-ring-color);
167
+ outline-offset: calc(-1 * var(--#{sys.$prefix}border-width));
168
+ }
169
+ }
170
+
171
+ // Hex / var text input — borderless; the group owns the border + focus ring.
172
+ .#{sys.$prefix}interface .#{sys.$prefix}color-picker__field-input {
173
+ flex: 1 1 auto;
174
+ min-width: 0;
175
+ width: 100%;
176
+ border: 0;
177
+ padding: 0;
178
+ background: transparent;
179
+ color: inherit;
180
+ font: inherit;
181
+ text-align: start;
182
+
183
+ &:focus,
184
+ &:focus-visible {
185
+ outline: none;
186
+ }
187
+ }
188
+
189
+ // Per-channel inputs (rgb / hsl / hwb / oklch) — a borderless flex row that
190
+ // fills the field group; the group provides the border + focus ring.
191
+ .#{sys.$prefix}interface .#{sys.$prefix}color-picker__channels {
192
+ flex: 1 1 auto;
193
+ min-width: 0;
194
+ display: flex;
195
+ align-items: center;
196
+ gap: var(--#{sys.$prefix}spacing-xxs);
197
+ }
198
+
199
+ .#{sys.$prefix}interface .#{sys.$prefix}color-picker__channel {
200
+ flex: 1 1 0;
201
+ min-width: 0;
202
+ display: flex;
203
+ align-items: baseline;
204
+ gap: 0.125em;
205
+ }
206
+
207
+ .#{sys.$prefix}interface .#{sys.$prefix}color-picker__channel-letter {
208
+ flex: none;
209
+ color: var(--#{sys.$prefix}color-fg-muted);
210
+ font-size: var(--#{sys.$prefix}typography-size-xs);
211
+ line-height: 1;
212
+ user-select: none;
213
+ }
214
+
215
+ .#{sys.$prefix}interface .#{sys.$prefix}color-picker__channel-input {
216
+ flex: 1 1 auto;
217
+ min-width: 0;
218
+ width: 100%;
219
+ border: 0;
220
+ padding: 0;
221
+ background: transparent;
222
+ color: inherit;
223
+ font: inherit;
224
+ text-align: start;
225
+ border-radius: var(--#{sys.$prefix}radius-sm);
226
+
227
+ // The group carries the :focus-within ring; each field additionally shows a
228
+ // subtle tint so a sighted keyboard user can tell WHICH channel has focus.
229
+ &:focus-visible {
230
+ outline: none;
231
+ background: var(--#{sys.$prefix}color-bg-muted);
232
+ }
233
+ }
234
+
235
+ .#{sys.$prefix}interface .#{sys.$prefix}color-picker__var {
236
+ margin: 0;
237
+ font-size: var(--#{sys.$prefix}typography-size-xs);
238
+ color: var(--#{sys.$prefix}color-fg-muted);
239
+
240
+ code {
241
+ font-family: var(--#{sys.$prefix}font-family-mono, monospace);
242
+ }
243
+
244
+ // Kept in the DOM (so the aria-live region announces on toggle) but
245
+ // collapsed when there's nothing to say. Not display:none — that would
246
+ // remove it from the accessibility tree and defeat the live region.
247
+ &.is-empty {
248
+ block-size: 0;
249
+ overflow: hidden;
250
+ }
251
+ }
252
+
253
+ // ---------------------------------------------------------------------------
254
+ // ColorField — pill trigger with a circular icon-swatch, opens the picker
255
+ // ---------------------------------------------------------------------------
256
+ .#{sys.$prefix}interface .#{sys.$prefix}color-field {
257
+ display: inline-flex;
258
+ align-items: center;
259
+ gap: var(--#{sys.$prefix}spacing-sm);
260
+ min-block-size: var(--#{sys.$prefix}control-height-md, 2.5rem);
261
+ padding: var(--#{sys.$prefix}spacing-xxs);
262
+ padding-inline-end: var(--#{sys.$prefix}spacing-sm);
263
+ border: var(--#{sys.$prefix}border-width) solid var(--#{sys.$prefix}color-border);
264
+ border-radius: var(--#{sys.$prefix}radius-md);
265
+ background: var(--#{sys.$prefix}input-bg, var(--#{sys.$prefix}color-bg-surface));
266
+ color: var(--#{sys.$prefix}color-fg);
267
+ font: inherit;
268
+ font-size: var(--#{sys.$prefix}typography-size-sm);
269
+ line-height: 1;
270
+ cursor: pointer;
271
+
272
+ &.is-size-sm {
273
+ min-block-size: var(--#{sys.$prefix}control-height-sm, 2.25rem);
274
+ }
275
+ &.is-size-lg {
276
+ min-block-size: var(--#{sys.$prefix}control-height-lg, 3rem);
277
+ font-size: var(--#{sys.$prefix}typography-size-md);
278
+ }
279
+
280
+ // Compact: just the circular icon-swatch, no label.
281
+ &.is-swatch-only {
282
+ padding-inline-end: var(--#{sys.$prefix}spacing-xxs);
283
+ }
284
+
285
+ &:hover {
286
+ border-color: var(--#{sys.$prefix}color-border-strong, var(--#{sys.$prefix}color-border));
287
+ }
288
+
289
+ // Match the shared form-control focus treatment: border turns primary plus
290
+ // an offset ring. data-popover-open keeps it lit while the picker is open.
291
+ &:focus-visible,
292
+ &[data-popover-open] {
293
+ border-color: var(--#{sys.$prefix}input-border-focus, var(--#{sys.$prefix}theme-primary-base));
294
+ outline: var(--#{sys.$prefix}focus-ring-width) solid var(--#{sys.$prefix}focus-ring-color);
295
+ outline-offset: var(--#{sys.$prefix}focus-ring-offset);
296
+ }
297
+
298
+ &.is-disabled {
299
+ opacity: var(--#{sys.$prefix}opacity-disabled);
300
+ pointer-events: none;
301
+ }
302
+ }
303
+
304
+ // Icon-swatch — the colour (or a neutral fill for dynamic values) with a
305
+ // contrast-picked white/black icon centred on top. A rounded square that
306
+ // tracks the field's radius (rounds up with the token, matching the pill).
307
+ .#{sys.$prefix}interface .#{sys.$prefix}color-field__swatch {
308
+ // A square sized to the field's inner height. Both dimensions are set
309
+ // explicitly (not aspect-ratio) — in a flex row, flex-basis:auto would size
310
+ // the width from the icon content and defeat aspect-ratio.
311
+ --_size: calc(var(--#{sys.$prefix}control-height-md, 2.5rem) - 2 * var(--#{sys.$prefix}spacing-xxs) - 2 * var(--#{sys.$prefix}border-width));
312
+ flex: none;
313
+ display: inline-flex;
314
+ align-items: center;
315
+ justify-content: center;
316
+ inline-size: var(--_size);
317
+ block-size: var(--_size);
318
+ border-radius: var(--#{sys.$prefix}radius-sm);
319
+ background-color: var(--#{sys.$prefix}color-bg);
320
+ background-image: linear-gradient(var(--_swatch), var(--_swatch)),
321
+ linear-gradient(45deg, #ccc 25%, transparent 25%),
322
+ linear-gradient(-45deg, #ccc 25%, transparent 25%),
323
+ linear-gradient(45deg, transparent 75%, #ccc 75%),
324
+ linear-gradient(-45deg, transparent 75%, #ccc 75%);
325
+ background-size: 100% 100%, 6px 6px, 6px 6px, 6px 6px, 6px 6px;
326
+ background-position: 0 0, 0 0, 0 3px, 3px -3px, -3px 0;
327
+ }
328
+ .#{sys.$prefix}interface .#{sys.$prefix}color-field.is-size-sm .#{sys.$prefix}color-field__swatch {
329
+ --_size: calc(var(--#{sys.$prefix}control-height-sm, 2.25rem) - 2 * var(--#{sys.$prefix}spacing-xxs) - 2 * var(--#{sys.$prefix}border-width));
330
+ }
331
+ .#{sys.$prefix}interface .#{sys.$prefix}color-field.is-size-lg .#{sys.$prefix}color-field__swatch {
332
+ --_size: calc(var(--#{sys.$prefix}control-height-lg, 3rem) - 2 * var(--#{sys.$prefix}spacing-xxs) - 2 * var(--#{sys.$prefix}border-width));
333
+ }
334
+
335
+ // The Icon renders <span class="tui-icon …"><svg width="1em"/></span>, so the
336
+ // glyph scales with FONT-SIZE, not inline/block-size (that only grows the span).
337
+ .#{sys.$prefix}interface .#{sys.$prefix}color-field__swatch-icon {
338
+ font-size: 1.25rem; // ~20px glyph
339
+ color: var(--_swatch-icon, #fff);
340
+ }
341
+ // Per-size overrides need the size class as an ANCESTOR of the icon — a nested
342
+ // `.is-size-sm &` inverts the order and never matches.
343
+ .#{sys.$prefix}interface .#{sys.$prefix}color-field.is-size-sm .#{sys.$prefix}color-field__swatch-icon {
344
+ font-size: 1.125rem; // ~18px
345
+ }
346
+ .#{sys.$prefix}interface .#{sys.$prefix}color-field.is-size-lg .#{sys.$prefix}color-field__swatch-icon {
347
+ font-size: 1.5rem; // ~24px
348
+ }
349
+
350
+ .#{sys.$prefix}interface .#{sys.$prefix}color-field__label {
351
+ min-inline-size: 0;
352
+ overflow: hidden;
353
+ text-overflow: ellipsis;
354
+ white-space: nowrap;
355
+ }
356
+
357
+ .#{sys.$prefix}interface .#{sys.$prefix}color-field__popover {
358
+ inline-size: 20rem;
359
+ max-inline-size: calc(100vw - 2rem);
360
+ }
361
+
362
+ @media (forced-colors: active) {
363
+ .#{sys.$prefix}interface .#{sys.$prefix}color-area,
364
+ .#{sys.$prefix}interface .#{sys.$prefix}color-slider {
365
+ &:focus-visible {
366
+ outline-color: Highlight;
367
+ }
368
+ }
369
+
370
+ .#{sys.$prefix}interface .#{sys.$prefix}color-picker__channels:focus-within {
371
+ outline-color: Highlight;
372
+ }
373
+
374
+ .#{sys.$prefix}interface .#{sys.$prefix}color-picker__channel-input:focus-visible {
375
+ outline: 1px solid Highlight;
376
+ }
377
+ }
378
+ }