@stacksjs/components 0.2.867 → 0.2.869
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/dist/AppearancePicker-61r20jpp.stx +351 -0
- package/dist/{Button-sebyqeva.stx → Button-pg8mzsq3.stx} +249 -0
- package/dist/Checkbox-52mhrzkz.stx +417 -0
- package/dist/ColorSwatches-ecfxphjy.stx +287 -0
- package/dist/{NumberInput-axcfj9y8.stx → NumberInput-e2afxyh3.stx} +303 -0
- package/dist/{PasswordInput-8m3109tp.stx → PasswordInput-n2ven456.stx} +315 -0
- package/dist/RadioGroup-ps9kn22f.stx +329 -0
- package/dist/RadioGroupOption-6hyy1bvb.stx +246 -0
- package/dist/{SegmentedControl-fr69q4gb.stx → SegmentedControl-7q0t8c9s.stx} +170 -1
- package/dist/{Select-1cnqbcmg.stx → Select-ygzchedx.stx} +266 -0
- package/dist/SettingsGroup-dkae46k5.stx +200 -0
- package/dist/SettingsPane-jbd1gbdt.stx +50 -0
- package/dist/SettingsPaneHeader-f0cvkqs7.stx +188 -0
- package/dist/SettingsRow-4cxbsf1q.stx +424 -0
- package/dist/SettingsSidebarGroup-p2ygv5yy.stx +108 -0
- package/dist/SettingsSidebarItem-x8fsn3w5.stx +228 -0
- package/dist/SettingsWindow-mm490ymt.stx +537 -0
- package/dist/Slider-j59dgw1c.stx +377 -0
- package/dist/Switch-ga9ap8n8.stx +374 -0
- package/dist/{TextInput-tsvfwxmg.stx → TextInput-tyqzz3jy.stx} +325 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +35 -24
- package/dist/settings/settings.js +757 -0
- package/dist/ui/appearance-picker/AppearancePicker.d.ts +12 -0
- package/dist/ui/appearance-picker/index.d.ts +16 -0
- package/dist/ui/button/Button.d.ts +24 -1
- package/dist/ui/button/index.d.ts +1 -0
- package/dist/ui/checkbox/Checkbox.d.ts +9 -1
- package/dist/ui/checkbox/index.d.ts +1 -0
- package/dist/ui/color-swatches/ColorSwatches.d.ts +26 -0
- package/dist/ui/color-swatches/index.d.ts +18 -0
- package/dist/ui/input/NumberInput.d.ts +11 -1
- package/dist/ui/input/PasswordInput.d.ts +9 -1
- package/dist/ui/input/TextInput.d.ts +12 -1
- package/dist/ui/input/index.d.ts +7 -3
- package/dist/ui/radio-group/RadioGroup.d.ts +14 -2
- package/dist/ui/radio-group/RadioGroupOption.d.ts +6 -1
- package/dist/ui/radio-group/index.d.ts +2 -0
- package/dist/ui/segmented-control/SegmentedControl.d.ts +9 -1
- package/dist/ui/segmented-control/index.d.ts +1 -0
- package/dist/ui/select/Select.d.ts +10 -1
- package/dist/ui/select/index.d.ts +1 -0
- package/dist/ui/settings/SettingsGroup.d.ts +30 -0
- package/dist/ui/settings/SettingsPane.d.ts +19 -0
- package/dist/ui/settings/SettingsPaneHeader.d.ts +20 -0
- package/dist/ui/settings/SettingsRow.d.ts +53 -0
- package/dist/ui/settings/SettingsSidebarGroup.d.ts +11 -0
- package/dist/ui/settings/SettingsSidebarItem.d.ts +22 -0
- package/dist/ui/settings/SettingsWindow.d.ts +22 -0
- package/dist/ui/settings/core.d.ts +146 -0
- package/dist/ui/settings/index.d.ts +73 -0
- package/dist/ui/settings/settings.d.ts +8 -0
- package/dist/ui/settings/view.d.ts +36 -0
- package/dist/ui/slider/Slider.d.ts +24 -0
- package/dist/ui/slider/core.d.ts +33 -0
- package/dist/ui/slider/index.d.ts +20 -0
- package/dist/ui/switch/Switch.d.ts +10 -1
- package/dist/ui/switch/index.d.ts +2 -1
- package/dist/utils/mac-theme.d.ts +24 -0
- package/package.json +8 -3
- package/src/index.ts +6 -0
- package/src/ui/appearance-picker/AppearancePicker.stx +351 -0
- package/src/ui/appearance-picker/README.md +61 -0
- package/src/ui/appearance-picker/index.ts +22 -0
- package/src/ui/button/Button.stx +249 -0
- package/src/ui/button/README.md +21 -0
- package/src/ui/button/index.ts +8 -0
- package/src/ui/checkbox/Checkbox.stx +275 -0
- package/src/ui/checkbox/index.ts +2 -0
- package/src/ui/color-swatches/ColorSwatches.stx +287 -0
- package/src/ui/color-swatches/README.md +66 -0
- package/src/ui/color-swatches/index.ts +25 -0
- package/src/ui/input/NumberInput.stx +303 -0
- package/src/ui/input/PasswordInput.stx +315 -0
- package/src/ui/input/TextInput.stx +325 -0
- package/src/ui/input/index.ts +9 -3
- package/src/ui/radio-group/README.md +17 -0
- package/src/ui/radio-group/RadioGroup.stx +184 -6
- package/src/ui/radio-group/RadioGroupOption.stx +178 -2
- package/src/ui/radio-group/index.ts +4 -0
- package/src/ui/segmented-control/SegmentedControl.stx +170 -1
- package/src/ui/segmented-control/index.ts +2 -0
- package/src/ui/select/README.md +12 -0
- package/src/ui/select/Select.stx +266 -0
- package/src/ui/select/index.ts +2 -0
- package/src/ui/settings/README.md +221 -0
- package/src/ui/settings/SettingsGroup.stx +200 -0
- package/src/ui/settings/SettingsPane.stx +50 -0
- package/src/ui/settings/SettingsPaneHeader.stx +188 -0
- package/src/ui/settings/SettingsRow.stx +424 -0
- package/src/ui/settings/SettingsSidebarGroup.stx +108 -0
- package/src/ui/settings/SettingsSidebarItem.stx +228 -0
- package/src/ui/settings/SettingsWindow.stx +537 -0
- package/src/ui/settings/core.ts +359 -0
- package/src/ui/settings/index.ts +111 -0
- package/src/ui/settings/settings.ts +8 -0
- package/src/ui/settings/view.ts +740 -0
- package/src/ui/slider/README.md +91 -0
- package/src/ui/slider/Slider.stx +377 -0
- package/src/ui/slider/core.ts +120 -0
- package/src/ui/slider/index.ts +34 -0
- package/src/ui/switch/README.md +11 -0
- package/src/ui/switch/Switch.stx +217 -0
- package/src/ui/switch/index.ts +4 -1
- package/src/utils/mac-theme.ts +95 -0
- package/dist/Checkbox-80myyzzm.stx +0 -142
- package/dist/RadioGroup-smqcqgds.stx +0 -151
- package/dist/RadioGroupOption-twcw1b2a.stx +0 -70
- package/dist/Switch-s8yf2rvm.stx +0 -157
|
@@ -137,3 +137,20 @@ function handleChange(plan) {
|
|
|
137
137
|
- Disabled state support
|
|
138
138
|
- Active state on focus
|
|
139
139
|
- Customizable styling
|
|
140
|
+
|
|
141
|
+
## Mac look
|
|
142
|
+
|
|
143
|
+
`variant="mac"` draws the radio buttons a Mac draws: a 15px circle beside each label, sunk when off and the accent around a white dot when on, 22px from one row to the next. Set it on the group, and on each `RadioGroupOption` written as a child (an option does not learn its look from the group).
|
|
144
|
+
|
|
145
|
+
```html
|
|
146
|
+
<RadioGroup variant="mac" value="auto" :options="[{ value: 'auto', label: 'Automatically' }, { value: 'always', label: 'Always' }]" />
|
|
147
|
+
|
|
148
|
+
<RadioGroup variant="mac" value="page">
|
|
149
|
+
<RadioGroupOption variant="mac" value="page">Jump to the next page</RadioGroupOption>
|
|
150
|
+
<RadioGroupOption variant="mac" value="spot">Jump to the spot that's clicked</RadioGroupOption>
|
|
151
|
+
</RadioGroup>
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
Roles, values, `@change` and the keys (Space or Enter chooses the focused option) are unchanged. `RadioGroupLabel` and `RadioGroupDescription` have no Mac look; under it an option's words are plain text.
|
|
155
|
+
|
|
156
|
+
Colours and type come from the `--stx-mac-*` custom properties (`src/utils/mac-theme.ts`), light and dark, so an app re-themes it by setting a variable. A window that is not the key window (`data-stx-window-active="false"` on an ancestor, or Craft's `data-craft-window-active`) draws it without colour. The inactive fill is `--stx-mac-radio-inactive`.
|
|
@@ -24,11 +24,24 @@ export const as = $props.as || 'div'
|
|
|
24
24
|
export const options = Array.isArray($props.options) ? $props.options : []
|
|
25
25
|
export const hasPropOptions = options.length > 0
|
|
26
26
|
|
|
27
|
+
/*
|
|
28
|
+
* `variant="mac"` draws the radio buttons a Mac draws: a 15px circle beside
|
|
29
|
+
* each label, sunk when off and the accent around a white dot when on, 22px
|
|
30
|
+
* from one row to the next. The roles, the values and the keys are the ones
|
|
31
|
+
* below; only the classes change, to `stx-mac-radio`, which this file's
|
|
32
|
+
* <style> block draws from the `--stx-mac-*` tokens. An option written as a
|
|
33
|
+
* <RadioGroupOption> child takes `variant="mac"` itself.
|
|
34
|
+
*/
|
|
35
|
+
export const mac = $props.variant === 'mac'
|
|
36
|
+
|
|
27
37
|
const optionBaseClasses = 'relative flex cursor-pointer rounded-panel px-5 py-4 shadow-md focus:outline-none transition-all bg-panel text-fg focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-panel'
|
|
28
|
-
export const optionClasses = optionBaseClasses
|
|
29
|
-
export const optionDisabledClasses = `${optionBaseClasses} opacity-50 cursor-not-allowed`
|
|
38
|
+
export const optionClasses = mac ? 'stx-mac-radio' : optionBaseClasses
|
|
39
|
+
export const optionDisabledClasses = mac ? 'stx-mac-radio' : `${optionBaseClasses} opacity-50 cursor-not-allowed`
|
|
40
|
+
export const optionTextClasses = mac ? 'stx-mac-radio-text' : 'flex flex-col'
|
|
41
|
+
export const optionLabelClasses = mac ? 'stx-mac-radio-label' : 'text-sm font-medium'
|
|
42
|
+
export const optionDescriptionClasses = mac ? 'stx-mac-radio-description' : 'text-sm opacity-70'
|
|
30
43
|
|
|
31
|
-
const baseClasses = 'w-full'
|
|
44
|
+
const baseClasses = mac ? 'stx-mac-radio-group' : 'w-full'
|
|
32
45
|
export const groupClasses = `${baseClasses} ${className}`.trim()
|
|
33
46
|
export const radioGroupInstanceId = $uid
|
|
34
47
|
</script>
|
|
@@ -137,10 +150,10 @@ defineExpose({ selected, selectValue })
|
|
|
137
150
|
tabindex="{{ option.disabled ? '-1' : '0' }}"
|
|
138
151
|
class="{{ option.disabled ? optionDisabledClasses : optionClasses }}"
|
|
139
152
|
>
|
|
140
|
-
<span class="
|
|
141
|
-
<span class="
|
|
153
|
+
<span class="{{ optionTextClasses }}">
|
|
154
|
+
<span class="{{ optionLabelClasses }}">{{ option.label }}</span>
|
|
142
155
|
@if(option.description)
|
|
143
|
-
<span class="
|
|
156
|
+
<span class="{{ optionDescriptionClasses }}">{{ option.description }}</span>
|
|
144
157
|
@endif
|
|
145
158
|
</span>
|
|
146
159
|
</div>
|
|
@@ -149,3 +162,168 @@ defineExpose({ selected, selectValue })
|
|
|
149
162
|
<slot />
|
|
150
163
|
@endif
|
|
151
164
|
</component>
|
|
165
|
+
|
|
166
|
+
<style data-native-exclude>
|
|
167
|
+
:where(:root) {
|
|
168
|
+
--stx-mac-font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI Variable Text', 'Segoe UI', system-ui, Roboto, 'Helvetica Neue', sans-serif;
|
|
169
|
+
--stx-mac-font-size: 13px;
|
|
170
|
+
--stx-mac-font-size-small: 11px;
|
|
171
|
+
--stx-mac-hairline: 0.5px;
|
|
172
|
+
--stx-mac-focus-ring: 0 0 0 3px color-mix(in srgb, var(--stx-mac-accent) 35%, transparent);
|
|
173
|
+
--stx-mac-card-radius: 12px;
|
|
174
|
+
--stx-mac-control-radius: 6px;
|
|
175
|
+
--stx-mac-row-height: 38px;
|
|
176
|
+
--stx-mac-row-inset: 10px;
|
|
177
|
+
--stx-mac-sidebar-width: 226px;
|
|
178
|
+
--stx-mac-accent: var(--stx-accent, rgb(0, 122, 255));
|
|
179
|
+
--stx-mac-accent-ink: #ffffff;
|
|
180
|
+
--stx-mac-ink: rgba(0, 0, 0, 0.85);
|
|
181
|
+
--stx-mac-ink-secondary: rgba(0, 0, 0, 0.5);
|
|
182
|
+
--stx-mac-ink-tertiary: rgba(0, 0, 0, 0.26);
|
|
183
|
+
--stx-mac-window: #ffffff;
|
|
184
|
+
--stx-mac-sidebar: #f2f1f0;
|
|
185
|
+
--stx-mac-card: rgba(0, 0, 0, 0.04);
|
|
186
|
+
--stx-mac-separator: rgba(0, 0, 0, 0.1);
|
|
187
|
+
--stx-mac-hover: rgba(0, 0, 0, 0.05);
|
|
188
|
+
--stx-mac-selection-inactive: rgba(0, 0, 0, 0.08);
|
|
189
|
+
--stx-mac-well: rgba(0, 0, 0, 0.07);
|
|
190
|
+
--stx-mac-control: #ffffff;
|
|
191
|
+
--stx-mac-control-line: rgba(0, 0, 0, 0.12);
|
|
192
|
+
--stx-mac-control-shadow: 0 0.5px 1.5px rgba(0, 0, 0, 0.14), 0 0 0 0.5px rgba(0, 0, 0, 0.08);
|
|
193
|
+
--stx-mac-switch-on: #34c759;
|
|
194
|
+
--stx-mac-knob: #ffffff;
|
|
195
|
+
--stx-mac-danger: #ff3b30;
|
|
196
|
+
}
|
|
197
|
+
:where(.dark) {
|
|
198
|
+
--stx-mac-accent: var(--stx-accent, #0a84ff);
|
|
199
|
+
--stx-mac-accent-ink: #ffffff;
|
|
200
|
+
--stx-mac-ink: rgba(255, 255, 255, 0.85);
|
|
201
|
+
--stx-mac-ink-secondary: rgba(255, 255, 255, 0.55);
|
|
202
|
+
--stx-mac-ink-tertiary: rgba(255, 255, 255, 0.25);
|
|
203
|
+
--stx-mac-window: #1e1e1e;
|
|
204
|
+
--stx-mac-sidebar: #2a2a2a;
|
|
205
|
+
--stx-mac-card: rgba(255, 255, 255, 0.05);
|
|
206
|
+
--stx-mac-separator: rgba(255, 255, 255, 0.1);
|
|
207
|
+
--stx-mac-hover: rgba(255, 255, 255, 0.06);
|
|
208
|
+
--stx-mac-selection-inactive: rgba(255, 255, 255, 0.1);
|
|
209
|
+
--stx-mac-well: rgba(255, 255, 255, 0.1);
|
|
210
|
+
--stx-mac-control: rgba(255, 255, 255, 0.14);
|
|
211
|
+
--stx-mac-control-line: rgba(255, 255, 255, 0.06);
|
|
212
|
+
--stx-mac-control-shadow: 0 0.5px 1.5px rgba(0, 0, 0, 0.4), inset 0 0.5px 0 rgba(255, 255, 255, 0.12);
|
|
213
|
+
--stx-mac-switch-on: #30d158;
|
|
214
|
+
--stx-mac-knob: #ffffff;
|
|
215
|
+
--stx-mac-danger: #ff453a;
|
|
216
|
+
}
|
|
217
|
+
@media (max-resolution: 1.5dppx) {
|
|
218
|
+
:where(:root) {
|
|
219
|
+
--stx-mac-hairline: 1px;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
@media (prefers-contrast: more) {
|
|
223
|
+
:where(:root) {
|
|
224
|
+
--stx-mac-separator: rgba(0, 0, 0, 0.4);
|
|
225
|
+
--stx-mac-control-line: rgba(0, 0, 0, 0.5);
|
|
226
|
+
--stx-mac-ink-secondary: rgba(0, 0, 0, 0.75);
|
|
227
|
+
--stx-mac-hairline: 1px;
|
|
228
|
+
}
|
|
229
|
+
:where(.dark) {
|
|
230
|
+
--stx-mac-separator: rgba(255, 255, 255, 0.45);
|
|
231
|
+
--stx-mac-control-line: rgba(255, 255, 255, 0.5);
|
|
232
|
+
--stx-mac-ink-secondary: rgba(255, 255, 255, 0.8);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
.stx-mac-radio-group {
|
|
237
|
+
display: flex;
|
|
238
|
+
flex-direction: column;
|
|
239
|
+
font-family: var(--stx-mac-font);
|
|
240
|
+
font-size: var(--stx-mac-font-size);
|
|
241
|
+
letter-spacing: -0.08px;
|
|
242
|
+
-webkit-font-smoothing: antialiased;
|
|
243
|
+
color: var(--stx-mac-ink);
|
|
244
|
+
cursor: default;
|
|
245
|
+
-webkit-user-select: none;
|
|
246
|
+
user-select: none;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
.stx-mac-radio.stx-mac-radio {
|
|
250
|
+
--stx-mac-radio-inactive: color-mix(in srgb, var(--stx-mac-ink) 16%, transparent);
|
|
251
|
+
position: relative;
|
|
252
|
+
display: flex;
|
|
253
|
+
align-items: flex-start;
|
|
254
|
+
gap: 8px;
|
|
255
|
+
box-sizing: border-box;
|
|
256
|
+
min-height: 22px;
|
|
257
|
+
padding: 3px 0;
|
|
258
|
+
line-height: 16px;
|
|
259
|
+
background: transparent;
|
|
260
|
+
outline: none;
|
|
261
|
+
font-family: var(--stx-mac-font);
|
|
262
|
+
font-size: var(--stx-mac-font-size);
|
|
263
|
+
letter-spacing: -0.08px;
|
|
264
|
+
-webkit-font-smoothing: antialiased;
|
|
265
|
+
color: var(--stx-mac-ink);
|
|
266
|
+
cursor: default;
|
|
267
|
+
-webkit-user-select: none;
|
|
268
|
+
user-select: none;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/* The circle: sunk when off, the accent around a white dot when on. */
|
|
272
|
+
.stx-mac-radio::before {
|
|
273
|
+
content: '';
|
|
274
|
+
flex: none;
|
|
275
|
+
box-sizing: border-box;
|
|
276
|
+
width: 15px;
|
|
277
|
+
height: 15px;
|
|
278
|
+
margin-top: 0.5px;
|
|
279
|
+
border-radius: 50%;
|
|
280
|
+
background-color: var(--stx-mac-well);
|
|
281
|
+
transition: background-color 150ms ease;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
.stx-mac-radio[aria-checked='true']::before {
|
|
285
|
+
background-color: var(--stx-mac-accent);
|
|
286
|
+
background-image: radial-gradient(circle, var(--stx-mac-accent-ink) 0 2.5px, transparent 3px);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
.stx-mac-radio:focus-visible::before {
|
|
290
|
+
box-shadow: var(--stx-mac-focus-ring);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
.stx-mac-radio[aria-disabled='true'] {
|
|
294
|
+
opacity: 0.5;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
.stx-mac-radio-text {
|
|
298
|
+
display: flex;
|
|
299
|
+
flex-direction: column;
|
|
300
|
+
gap: 1px;
|
|
301
|
+
min-width: 0;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
.stx-mac-radio-description {
|
|
305
|
+
font-size: var(--stx-mac-font-size-small);
|
|
306
|
+
line-height: 14px;
|
|
307
|
+
letter-spacing: 0;
|
|
308
|
+
color: var(--stx-mac-ink-secondary);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/* A window that is not the key window draws its controls without colour. */
|
|
312
|
+
:where([data-stx-window-active='false']) .stx-mac-radio[aria-checked='true']::before,
|
|
313
|
+
:root[data-craft-window-active='false'] .stx-mac-radio[aria-checked='true']::before {
|
|
314
|
+
background-color: var(--stx-mac-radio-inactive);
|
|
315
|
+
background-image: radial-gradient(circle, var(--stx-mac-ink) 0 2.5px, transparent 3px);
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
@media (prefers-reduced-motion: reduce) {
|
|
319
|
+
.stx-mac-radio::before {
|
|
320
|
+
transition: none;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
@media (prefers-contrast: more) {
|
|
325
|
+
.stx-mac-radio:not([aria-checked='true'])::before {
|
|
326
|
+
box-shadow: inset 0 0 0 1px var(--stx-mac-control-line);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
</style>
|
|
@@ -6,7 +6,14 @@ export const as = $props.as || 'div'
|
|
|
6
6
|
|
|
7
7
|
const baseClasses = 'relative flex cursor-pointer rounded-panel px-5 py-4 shadow-md focus:outline-none transition-all bg-panel text-fg focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-panel'
|
|
8
8
|
const disabledClasses = disabled ? 'opacity-50 cursor-not-allowed' : ''
|
|
9
|
-
|
|
9
|
+
/*
|
|
10
|
+
* `variant="mac"`: the radio button a Mac draws, a 15px circle beside the
|
|
11
|
+
* words. See RadioGroup, which takes the same prop for the group.
|
|
12
|
+
*/
|
|
13
|
+
export const mac = $props.variant === 'mac'
|
|
14
|
+
export const optionClasses = mac
|
|
15
|
+
? `stx-mac-radio ${className}`.trim()
|
|
16
|
+
: `${baseClasses} ${disabledClasses} ${className}`.trim()
|
|
10
17
|
export const valueJson = JSON.stringify(value === undefined ? null : value)
|
|
11
18
|
</script>
|
|
12
19
|
|
|
@@ -59,7 +66,76 @@ function onKey(event) {
|
|
|
59
66
|
<slot :disabled="disabled" />
|
|
60
67
|
</component>
|
|
61
68
|
|
|
62
|
-
<style>
|
|
69
|
+
<style data-native-exclude>
|
|
70
|
+
:where(:root) {
|
|
71
|
+
--stx-mac-font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI Variable Text', 'Segoe UI', system-ui, Roboto, 'Helvetica Neue', sans-serif;
|
|
72
|
+
--stx-mac-font-size: 13px;
|
|
73
|
+
--stx-mac-font-size-small: 11px;
|
|
74
|
+
--stx-mac-hairline: 0.5px;
|
|
75
|
+
--stx-mac-focus-ring: 0 0 0 3px color-mix(in srgb, var(--stx-mac-accent) 35%, transparent);
|
|
76
|
+
--stx-mac-card-radius: 12px;
|
|
77
|
+
--stx-mac-control-radius: 6px;
|
|
78
|
+
--stx-mac-row-height: 38px;
|
|
79
|
+
--stx-mac-row-inset: 10px;
|
|
80
|
+
--stx-mac-sidebar-width: 226px;
|
|
81
|
+
--stx-mac-accent: var(--stx-accent, rgb(0, 122, 255));
|
|
82
|
+
--stx-mac-accent-ink: #ffffff;
|
|
83
|
+
--stx-mac-ink: rgba(0, 0, 0, 0.85);
|
|
84
|
+
--stx-mac-ink-secondary: rgba(0, 0, 0, 0.5);
|
|
85
|
+
--stx-mac-ink-tertiary: rgba(0, 0, 0, 0.26);
|
|
86
|
+
--stx-mac-window: #ffffff;
|
|
87
|
+
--stx-mac-sidebar: #f2f1f0;
|
|
88
|
+
--stx-mac-card: rgba(0, 0, 0, 0.04);
|
|
89
|
+
--stx-mac-separator: rgba(0, 0, 0, 0.1);
|
|
90
|
+
--stx-mac-hover: rgba(0, 0, 0, 0.05);
|
|
91
|
+
--stx-mac-selection-inactive: rgba(0, 0, 0, 0.08);
|
|
92
|
+
--stx-mac-well: rgba(0, 0, 0, 0.07);
|
|
93
|
+
--stx-mac-control: #ffffff;
|
|
94
|
+
--stx-mac-control-line: rgba(0, 0, 0, 0.12);
|
|
95
|
+
--stx-mac-control-shadow: 0 0.5px 1.5px rgba(0, 0, 0, 0.14), 0 0 0 0.5px rgba(0, 0, 0, 0.08);
|
|
96
|
+
--stx-mac-switch-on: #34c759;
|
|
97
|
+
--stx-mac-knob: #ffffff;
|
|
98
|
+
--stx-mac-danger: #ff3b30;
|
|
99
|
+
}
|
|
100
|
+
:where(.dark) {
|
|
101
|
+
--stx-mac-accent: var(--stx-accent, #0a84ff);
|
|
102
|
+
--stx-mac-accent-ink: #ffffff;
|
|
103
|
+
--stx-mac-ink: rgba(255, 255, 255, 0.85);
|
|
104
|
+
--stx-mac-ink-secondary: rgba(255, 255, 255, 0.55);
|
|
105
|
+
--stx-mac-ink-tertiary: rgba(255, 255, 255, 0.25);
|
|
106
|
+
--stx-mac-window: #1e1e1e;
|
|
107
|
+
--stx-mac-sidebar: #2a2a2a;
|
|
108
|
+
--stx-mac-card: rgba(255, 255, 255, 0.05);
|
|
109
|
+
--stx-mac-separator: rgba(255, 255, 255, 0.1);
|
|
110
|
+
--stx-mac-hover: rgba(255, 255, 255, 0.06);
|
|
111
|
+
--stx-mac-selection-inactive: rgba(255, 255, 255, 0.1);
|
|
112
|
+
--stx-mac-well: rgba(255, 255, 255, 0.1);
|
|
113
|
+
--stx-mac-control: rgba(255, 255, 255, 0.14);
|
|
114
|
+
--stx-mac-control-line: rgba(255, 255, 255, 0.06);
|
|
115
|
+
--stx-mac-control-shadow: 0 0.5px 1.5px rgba(0, 0, 0, 0.4), inset 0 0.5px 0 rgba(255, 255, 255, 0.12);
|
|
116
|
+
--stx-mac-switch-on: #30d158;
|
|
117
|
+
--stx-mac-knob: #ffffff;
|
|
118
|
+
--stx-mac-danger: #ff453a;
|
|
119
|
+
}
|
|
120
|
+
@media (max-resolution: 1.5dppx) {
|
|
121
|
+
:where(:root) {
|
|
122
|
+
--stx-mac-hairline: 1px;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
@media (prefers-contrast: more) {
|
|
126
|
+
:where(:root) {
|
|
127
|
+
--stx-mac-separator: rgba(0, 0, 0, 0.4);
|
|
128
|
+
--stx-mac-control-line: rgba(0, 0, 0, 0.5);
|
|
129
|
+
--stx-mac-ink-secondary: rgba(0, 0, 0, 0.75);
|
|
130
|
+
--stx-mac-hairline: 1px;
|
|
131
|
+
}
|
|
132
|
+
:where(.dark) {
|
|
133
|
+
--stx-mac-separator: rgba(255, 255, 255, 0.45);
|
|
134
|
+
--stx-mac-control-line: rgba(255, 255, 255, 0.5);
|
|
135
|
+
--stx-mac-ink-secondary: rgba(255, 255, 255, 0.8);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
63
139
|
[data-stx-radio-option][data-checked="true"] {
|
|
64
140
|
background-color: rgb(30 58 138 / 0.75);
|
|
65
141
|
color: white;
|
|
@@ -67,4 +143,104 @@ function onKey(event) {
|
|
|
67
143
|
.dark [data-stx-radio-option][data-checked="true"] {
|
|
68
144
|
background-color: rgb(30 64 175 / 1);
|
|
69
145
|
}
|
|
146
|
+
|
|
147
|
+
/* The chosen-card fill above is not a Mac radio's: the circle says it. */
|
|
148
|
+
.stx-mac-radio.stx-mac-radio[data-stx-radio-option][data-checked='true'] {
|
|
149
|
+
background-color: transparent;
|
|
150
|
+
color: var(--stx-mac-ink);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
.stx-mac-radio-group {
|
|
154
|
+
display: flex;
|
|
155
|
+
flex-direction: column;
|
|
156
|
+
font-family: var(--stx-mac-font);
|
|
157
|
+
font-size: var(--stx-mac-font-size);
|
|
158
|
+
letter-spacing: -0.08px;
|
|
159
|
+
-webkit-font-smoothing: antialiased;
|
|
160
|
+
color: var(--stx-mac-ink);
|
|
161
|
+
cursor: default;
|
|
162
|
+
-webkit-user-select: none;
|
|
163
|
+
user-select: none;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.stx-mac-radio.stx-mac-radio {
|
|
167
|
+
--stx-mac-radio-inactive: color-mix(in srgb, var(--stx-mac-ink) 16%, transparent);
|
|
168
|
+
position: relative;
|
|
169
|
+
display: flex;
|
|
170
|
+
align-items: flex-start;
|
|
171
|
+
gap: 8px;
|
|
172
|
+
box-sizing: border-box;
|
|
173
|
+
min-height: 22px;
|
|
174
|
+
padding: 3px 0;
|
|
175
|
+
line-height: 16px;
|
|
176
|
+
background: transparent;
|
|
177
|
+
outline: none;
|
|
178
|
+
font-family: var(--stx-mac-font);
|
|
179
|
+
font-size: var(--stx-mac-font-size);
|
|
180
|
+
letter-spacing: -0.08px;
|
|
181
|
+
-webkit-font-smoothing: antialiased;
|
|
182
|
+
color: var(--stx-mac-ink);
|
|
183
|
+
cursor: default;
|
|
184
|
+
-webkit-user-select: none;
|
|
185
|
+
user-select: none;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/* The circle: sunk when off, the accent around a white dot when on. */
|
|
189
|
+
.stx-mac-radio::before {
|
|
190
|
+
content: '';
|
|
191
|
+
flex: none;
|
|
192
|
+
box-sizing: border-box;
|
|
193
|
+
width: 15px;
|
|
194
|
+
height: 15px;
|
|
195
|
+
margin-top: 0.5px;
|
|
196
|
+
border-radius: 50%;
|
|
197
|
+
background-color: var(--stx-mac-well);
|
|
198
|
+
transition: background-color 150ms ease;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
.stx-mac-radio[aria-checked='true']::before {
|
|
202
|
+
background-color: var(--stx-mac-accent);
|
|
203
|
+
background-image: radial-gradient(circle, var(--stx-mac-accent-ink) 0 2.5px, transparent 3px);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
.stx-mac-radio:focus-visible::before {
|
|
207
|
+
box-shadow: var(--stx-mac-focus-ring);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
.stx-mac-radio[aria-disabled='true'] {
|
|
211
|
+
opacity: 0.5;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
.stx-mac-radio-text {
|
|
215
|
+
display: flex;
|
|
216
|
+
flex-direction: column;
|
|
217
|
+
gap: 1px;
|
|
218
|
+
min-width: 0;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
.stx-mac-radio-description {
|
|
222
|
+
font-size: var(--stx-mac-font-size-small);
|
|
223
|
+
line-height: 14px;
|
|
224
|
+
letter-spacing: 0;
|
|
225
|
+
color: var(--stx-mac-ink-secondary);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/* A window that is not the key window draws its controls without colour. */
|
|
229
|
+
:where([data-stx-window-active='false']) .stx-mac-radio[aria-checked='true']::before,
|
|
230
|
+
:root[data-craft-window-active='false'] .stx-mac-radio[aria-checked='true']::before {
|
|
231
|
+
background-color: var(--stx-mac-radio-inactive);
|
|
232
|
+
background-image: radial-gradient(circle, var(--stx-mac-ink) 0 2.5px, transparent 3px);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
@media (prefers-reduced-motion: reduce) {
|
|
236
|
+
.stx-mac-radio::before {
|
|
237
|
+
transition: none;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
@media (prefers-contrast: more) {
|
|
242
|
+
.stx-mac-radio:not([aria-checked='true'])::before {
|
|
243
|
+
box-shadow: inset 0 0 0 1px var(--stx-mac-control-line);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
70
246
|
</style>
|
|
@@ -8,6 +8,8 @@ export interface RadioGroupProps {
|
|
|
8
8
|
onChange?: (value: any) => void
|
|
9
9
|
className?: string
|
|
10
10
|
as?: string
|
|
11
|
+
/** `'mac'` draws Mac radio buttons from the `--stx-mac-*` tokens. Child options take it too. */
|
|
12
|
+
variant?: 'mac'
|
|
11
13
|
}
|
|
12
14
|
|
|
13
15
|
export interface RadioGroupLabelProps {
|
|
@@ -18,6 +20,8 @@ export interface RadioGroupLabelProps {
|
|
|
18
20
|
export interface RadioGroupOptionProps {
|
|
19
21
|
value: any
|
|
20
22
|
disabled?: boolean
|
|
23
|
+
/** `'mac'` draws the Mac radio button; set it on the group as well. */
|
|
24
|
+
variant?: 'mac'
|
|
21
25
|
className?: string
|
|
22
26
|
as?: string
|
|
23
27
|
currentValue?: any
|
|
@@ -41,6 +41,14 @@ export const disabled = $bool($props.disabled)
|
|
|
41
41
|
export const size = $props.size === 'sm' ? 'sm' : $props.size === 'lg' ? 'lg' : 'md'
|
|
42
42
|
export const testID = $props.testID || ''
|
|
43
43
|
export const className = $props.className || ''
|
|
44
|
+
/*
|
|
45
|
+
* `variant="mac"` draws the segmented control a Mac draws: a 24px capsule
|
|
46
|
+
* track with the chosen segment raised in it. The buttons, `aria-pressed` and
|
|
47
|
+
* the events are the ones below; only the classes change, to
|
|
48
|
+
* `stx-mac-segmented`, which this file's <style> block draws from the
|
|
49
|
+
* `--stx-mac-*` tokens. It has one size, so `size` is not read.
|
|
50
|
+
*/
|
|
51
|
+
export const mac = $props.variant === 'mac' && !$native
|
|
44
52
|
|
|
45
53
|
const sizeClasses = {
|
|
46
54
|
sm: { segment: 'min-h-[28px] px-2.5 py-1', text: 'text-[13px]' },
|
|
@@ -64,7 +72,9 @@ const segmentSizing = stretch ? sizing.segment.replace(/\bpx-\S+/, stretchedPadd
|
|
|
64
72
|
*/
|
|
65
73
|
export const trackClasses = $native
|
|
66
74
|
? `${stretch ? 'flex' : 'self-start'} flex-row gap-0.5 p-0.5 rounded-[9px] bg-[#767680]/12 dark:bg-[#767680]/24 ${className}`.replace(/\s+/g, ' ').trim()
|
|
67
|
-
:
|
|
75
|
+
: mac
|
|
76
|
+
? `stx-mac-segmented ${stretch ? 'stx-mac-segmented-stretch' : ''} ${className}`.replace(/\s+/g, ' ').trim()
|
|
77
|
+
: `${stretch ? 'flex' : 'inline-flex'} flex-row gap-0.5 p-0.5 rounded-control bg-surface-sunken ${className}`.replace(/\s+/g, ' ').trim()
|
|
68
78
|
export const segmentBase = $native
|
|
69
79
|
? `${stretch ? 'flex-1 min-w-0' : ''} items-center justify-center rounded-[7px] ${segmentSizing}`.replace(/\s+/g, ' ').trim()
|
|
70
80
|
: `${stretch ? 'flex-1 min-w-0' : ''} items-center justify-center rounded-control transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-accent ${segmentSizing}`.replace(/\s+/g, ' ').trim()
|
|
@@ -89,6 +99,9 @@ const segmentOn = {{ segmentOn }}
|
|
|
89
99
|
const segmentOff = {{ segmentOff }}
|
|
90
100
|
const labelOn = {{ labelOn }}
|
|
91
101
|
const labelOff = {{ labelOff }}
|
|
102
|
+
// The Mac look is drawn from `aria-pressed` and `disabled` in the stylesheet,
|
|
103
|
+
// so a segment's class does not change with its state.
|
|
104
|
+
const macLook = {{ mac }}
|
|
92
105
|
|
|
93
106
|
/** A choice as `{ value, label, disabled }`, whichever way it was written. */
|
|
94
107
|
function normalise(choice) {
|
|
@@ -130,11 +143,13 @@ function onNativeChange(event) {
|
|
|
130
143
|
}
|
|
131
144
|
|
|
132
145
|
function segmentClasses(segment) {
|
|
146
|
+
if (macLook) return 'stx-mac-segment'
|
|
133
147
|
const state = isOn(segment) ? segmentOn : 'bg-transparent'
|
|
134
148
|
return `${segmentBase} ${state} ${isOff(segment) ? segmentOff : 'cursor-pointer'}`
|
|
135
149
|
}
|
|
136
150
|
|
|
137
151
|
function labelClasses(segment) {
|
|
152
|
+
if (macLook) return 'stx-mac-segment-label'
|
|
138
153
|
return `${textSize} ${isOn(segment) ? labelOn : labelOff}`
|
|
139
154
|
}
|
|
140
155
|
|
|
@@ -176,3 +191,157 @@ defineExpose({ selected })
|
|
|
176
191
|
@click="choose(segment)"
|
|
177
192
|
><span class="truncate" :class="labelClasses(segment)" :text="segment.label"></span></button>
|
|
178
193
|
</div>
|
|
194
|
+
|
|
195
|
+
<style data-native-exclude>
|
|
196
|
+
:where(:root) {
|
|
197
|
+
--stx-mac-font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI Variable Text', 'Segoe UI', system-ui, Roboto, 'Helvetica Neue', sans-serif;
|
|
198
|
+
--stx-mac-font-size: 13px;
|
|
199
|
+
--stx-mac-font-size-small: 11px;
|
|
200
|
+
--stx-mac-hairline: 0.5px;
|
|
201
|
+
--stx-mac-focus-ring: 0 0 0 3px color-mix(in srgb, var(--stx-mac-accent) 35%, transparent);
|
|
202
|
+
--stx-mac-card-radius: 12px;
|
|
203
|
+
--stx-mac-control-radius: 6px;
|
|
204
|
+
--stx-mac-row-height: 38px;
|
|
205
|
+
--stx-mac-row-inset: 10px;
|
|
206
|
+
--stx-mac-sidebar-width: 226px;
|
|
207
|
+
--stx-mac-accent: var(--stx-accent, rgb(0, 122, 255));
|
|
208
|
+
--stx-mac-accent-ink: #ffffff;
|
|
209
|
+
--stx-mac-ink: rgba(0, 0, 0, 0.85);
|
|
210
|
+
--stx-mac-ink-secondary: rgba(0, 0, 0, 0.5);
|
|
211
|
+
--stx-mac-ink-tertiary: rgba(0, 0, 0, 0.26);
|
|
212
|
+
--stx-mac-window: #ffffff;
|
|
213
|
+
--stx-mac-sidebar: #f2f1f0;
|
|
214
|
+
--stx-mac-card: rgba(0, 0, 0, 0.04);
|
|
215
|
+
--stx-mac-separator: rgba(0, 0, 0, 0.1);
|
|
216
|
+
--stx-mac-hover: rgba(0, 0, 0, 0.05);
|
|
217
|
+
--stx-mac-selection-inactive: rgba(0, 0, 0, 0.08);
|
|
218
|
+
--stx-mac-well: rgba(0, 0, 0, 0.07);
|
|
219
|
+
--stx-mac-control: #ffffff;
|
|
220
|
+
--stx-mac-control-line: rgba(0, 0, 0, 0.12);
|
|
221
|
+
--stx-mac-control-shadow: 0 0.5px 1.5px rgba(0, 0, 0, 0.14), 0 0 0 0.5px rgba(0, 0, 0, 0.08);
|
|
222
|
+
--stx-mac-switch-on: #34c759;
|
|
223
|
+
--stx-mac-knob: #ffffff;
|
|
224
|
+
--stx-mac-danger: #ff3b30;
|
|
225
|
+
}
|
|
226
|
+
:where(.dark) {
|
|
227
|
+
--stx-mac-accent: var(--stx-accent, #0a84ff);
|
|
228
|
+
--stx-mac-accent-ink: #ffffff;
|
|
229
|
+
--stx-mac-ink: rgba(255, 255, 255, 0.85);
|
|
230
|
+
--stx-mac-ink-secondary: rgba(255, 255, 255, 0.55);
|
|
231
|
+
--stx-mac-ink-tertiary: rgba(255, 255, 255, 0.25);
|
|
232
|
+
--stx-mac-window: #1e1e1e;
|
|
233
|
+
--stx-mac-sidebar: #2a2a2a;
|
|
234
|
+
--stx-mac-card: rgba(255, 255, 255, 0.05);
|
|
235
|
+
--stx-mac-separator: rgba(255, 255, 255, 0.1);
|
|
236
|
+
--stx-mac-hover: rgba(255, 255, 255, 0.06);
|
|
237
|
+
--stx-mac-selection-inactive: rgba(255, 255, 255, 0.1);
|
|
238
|
+
--stx-mac-well: rgba(255, 255, 255, 0.1);
|
|
239
|
+
--stx-mac-control: rgba(255, 255, 255, 0.14);
|
|
240
|
+
--stx-mac-control-line: rgba(255, 255, 255, 0.06);
|
|
241
|
+
--stx-mac-control-shadow: 0 0.5px 1.5px rgba(0, 0, 0, 0.4), inset 0 0.5px 0 rgba(255, 255, 255, 0.12);
|
|
242
|
+
--stx-mac-switch-on: #30d158;
|
|
243
|
+
--stx-mac-knob: #ffffff;
|
|
244
|
+
--stx-mac-danger: #ff453a;
|
|
245
|
+
}
|
|
246
|
+
@media (max-resolution: 1.5dppx) {
|
|
247
|
+
:where(:root) {
|
|
248
|
+
--stx-mac-hairline: 1px;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
@media (prefers-contrast: more) {
|
|
252
|
+
:where(:root) {
|
|
253
|
+
--stx-mac-separator: rgba(0, 0, 0, 0.4);
|
|
254
|
+
--stx-mac-control-line: rgba(0, 0, 0, 0.5);
|
|
255
|
+
--stx-mac-ink-secondary: rgba(0, 0, 0, 0.75);
|
|
256
|
+
--stx-mac-hairline: 1px;
|
|
257
|
+
}
|
|
258
|
+
:where(.dark) {
|
|
259
|
+
--stx-mac-separator: rgba(255, 255, 255, 0.45);
|
|
260
|
+
--stx-mac-control-line: rgba(255, 255, 255, 0.5);
|
|
261
|
+
--stx-mac-ink-secondary: rgba(255, 255, 255, 0.8);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
.stx-mac-segmented {
|
|
266
|
+
display: inline-flex;
|
|
267
|
+
box-sizing: border-box;
|
|
268
|
+
height: 24px;
|
|
269
|
+
padding: 2px;
|
|
270
|
+
border-radius: 12px;
|
|
271
|
+
background: var(--stx-mac-well);
|
|
272
|
+
font-family: var(--stx-mac-font);
|
|
273
|
+
font-size: var(--stx-mac-font-size);
|
|
274
|
+
letter-spacing: -0.08px;
|
|
275
|
+
-webkit-font-smoothing: antialiased;
|
|
276
|
+
color: var(--stx-mac-ink);
|
|
277
|
+
cursor: default;
|
|
278
|
+
-webkit-user-select: none;
|
|
279
|
+
user-select: none;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
.stx-mac-segmented-stretch {
|
|
283
|
+
display: flex;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
.stx-mac-segment {
|
|
287
|
+
display: inline-flex;
|
|
288
|
+
flex: none;
|
|
289
|
+
align-items: center;
|
|
290
|
+
justify-content: center;
|
|
291
|
+
box-sizing: border-box;
|
|
292
|
+
min-width: 0;
|
|
293
|
+
height: 20px;
|
|
294
|
+
margin: 0;
|
|
295
|
+
padding: 0 10px;
|
|
296
|
+
border: 0;
|
|
297
|
+
border-radius: 10px;
|
|
298
|
+
background: transparent;
|
|
299
|
+
color: inherit;
|
|
300
|
+
font: inherit;
|
|
301
|
+
letter-spacing: inherit;
|
|
302
|
+
-webkit-appearance: none;
|
|
303
|
+
appearance: none;
|
|
304
|
+
cursor: default;
|
|
305
|
+
outline: none;
|
|
306
|
+
transition: background-color 150ms ease, box-shadow 150ms ease;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
.stx-mac-segmented-stretch .stx-mac-segment {
|
|
310
|
+
flex: 1 1 0;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
.stx-mac-segment[aria-pressed='true'] {
|
|
314
|
+
background: var(--stx-mac-control);
|
|
315
|
+
box-shadow: var(--stx-mac-control-shadow);
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
.stx-mac-segment:focus-visible {
|
|
319
|
+
box-shadow: var(--stx-mac-focus-ring);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
.stx-mac-segment[aria-pressed='true']:focus-visible {
|
|
323
|
+
box-shadow: var(--stx-mac-control-shadow), var(--stx-mac-focus-ring);
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
.stx-mac-segment:disabled {
|
|
327
|
+
opacity: 0.5;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
.stx-mac-segment-label {
|
|
331
|
+
overflow: hidden;
|
|
332
|
+
text-overflow: ellipsis;
|
|
333
|
+
white-space: nowrap;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
@media (prefers-reduced-motion: reduce) {
|
|
337
|
+
.stx-mac-segment {
|
|
338
|
+
transition: none;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
@media (prefers-contrast: more) {
|
|
343
|
+
.stx-mac-segmented {
|
|
344
|
+
box-shadow: inset 0 0 0 1px var(--stx-mac-control-line);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
</style>
|
|
@@ -25,6 +25,8 @@ export interface SegmentedControlProps {
|
|
|
25
25
|
disabled?: boolean
|
|
26
26
|
/** Large keeps every segment at least 44px tall for touch input. */
|
|
27
27
|
size?: 'sm' | 'md' | 'lg'
|
|
28
|
+
/** `'mac'` draws the 24px Mac capsule track from the `--stx-mac-*` tokens; `size` is not read. */
|
|
29
|
+
variant?: 'mac'
|
|
28
30
|
/** Names the group; each segment is `<testID>-<value>`. */
|
|
29
31
|
testID?: string
|
|
30
32
|
className?: string
|
package/src/ui/select/README.md
CHANGED
|
@@ -216,3 +216,15 @@ const handleCountryChange = (value) => {
|
|
|
216
216
|
/>
|
|
217
217
|
</form>
|
|
218
218
|
```
|
|
219
|
+
|
|
220
|
+
## Mac look
|
|
221
|
+
|
|
222
|
+
`variant="mac"` draws the pop-up button a Mac draws: the chosen value as 13px text, right-aligned, and a 20px disc holding an up and a down chevron. The control is as wide as the chosen value, so it sits at the end of a settings row.
|
|
223
|
+
|
|
224
|
+
```html
|
|
225
|
+
<Select variant="mac" v-model:value="size" name="size" placeholder="" :options="['Small', 'Medium', 'Large']" />
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
It is still a native `<select>`: the menu it opens, the keys that work in it and the value it submits are the platform's own. On a Mac that menu is the system's pop-up menu; the component does not draw one. `size` is not read under this look.
|
|
229
|
+
|
|
230
|
+
Colours and type come from the `--stx-mac-*` custom properties (`src/utils/mac-theme.ts`), light and dark, so an app re-themes it by setting a variable. A window that is not the key window (`data-stx-window-active="false"` on an ancestor, or Craft's `data-craft-window-active`) draws it without colour. The disc is `--stx-mac-popup-disc`, and `--stx-mac-popup-disc-hover` under the pointer.
|