@stacksjs/components 0.2.867 → 0.2.868
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
package/src/ui/select/Select.stx
CHANGED
|
@@ -36,6 +36,15 @@ export const label = $props.label || ''
|
|
|
36
36
|
export const helperText = $props.helperText || ''
|
|
37
37
|
export const required = $bool($props.required)
|
|
38
38
|
export const className = $props.className || ''
|
|
39
|
+
/*
|
|
40
|
+
* `variant="mac"` draws the pop-up button a Mac draws: the chosen value as
|
|
41
|
+
* plain text, right-aligned, and a 20px disc holding an up and a down
|
|
42
|
+
* chevron. It is still the <select> below, so the menu it opens, the keys
|
|
43
|
+
* that work in it and the value it submits are the platform's own (on a Mac
|
|
44
|
+
* that menu is the system's). Only the classes change, to `stx-mac-popup`,
|
|
45
|
+
* which this file's <style> block draws from the `--stx-mac-*` tokens.
|
|
46
|
+
*/
|
|
47
|
+
export const mac = $props.variant === 'mac'
|
|
39
48
|
|
|
40
49
|
/*
|
|
41
50
|
* Padding decides the height here too, with no `h-*` to override it: an app
|
|
@@ -191,6 +200,64 @@ defineExpose({ value: selectedValue, options: optionList })
|
|
|
191
200
|
<p id="{{ helperId }}" class="mt-1.5 px-4 text-[13px] {{ error ? 'text-[#ff3b30] dark:text-[#ff453a]' : 'text-[#6d6d72] dark:text-[#8d8d93]' }}">{{ helperText }}</p>
|
|
192
201
|
@endif
|
|
193
202
|
</div>
|
|
203
|
+
@elseif(mac)
|
|
204
|
+
<div class="stx-mac-popup-field">
|
|
205
|
+
@if(label)
|
|
206
|
+
<label for="{{ selectId }}" class="stx-mac-popup-label">
|
|
207
|
+
{{ label }}
|
|
208
|
+
@if(required)
|
|
209
|
+
<span class="stx-mac-popup-required">*</span>
|
|
210
|
+
@endif
|
|
211
|
+
</label>
|
|
212
|
+
@endif
|
|
213
|
+
|
|
214
|
+
<div class="stx-mac-popup">
|
|
215
|
+
<select
|
|
216
|
+
@if(name)name="{{ name }}"@endif
|
|
217
|
+
@if(autocomplete)autocomplete="{{ autocomplete }}"@endif
|
|
218
|
+
@if(form)form="{{ form }}"@endif
|
|
219
|
+
id="{{ selectId }}"
|
|
220
|
+
class="stx-mac-popup-select {{ className }}"
|
|
221
|
+
:value="selectedValue()"
|
|
222
|
+
@if(disabled)disabled@endif
|
|
223
|
+
@if(required)required@endif
|
|
224
|
+
@change="onChange($event)"
|
|
225
|
+
aria-invalid="{{ error ? 'true' : 'false' }}"
|
|
226
|
+
:aria-invalid="isError() ? 'true' : 'false'"
|
|
227
|
+
@if(helperText)aria-describedby="{{ helperId }}"@endif
|
|
228
|
+
>
|
|
229
|
+
@if(placeholder)
|
|
230
|
+
<option value="" disabled>{{ placeholder }}</option>
|
|
231
|
+
@endif
|
|
232
|
+
|
|
233
|
+
{{-- The served list and the live one, as in the default look below. --}}
|
|
234
|
+
@foreach(option in options)
|
|
235
|
+
<option
|
|
236
|
+
x-no-cloak
|
|
237
|
+
x-if="false"
|
|
238
|
+
value="{{ option.value }}"
|
|
239
|
+
@if(option.disabled)disabled@endif
|
|
240
|
+
@if(option.value === String(value))selected@endif
|
|
241
|
+
>{{ option.label }}</option>
|
|
242
|
+
@endforeach
|
|
243
|
+
|
|
244
|
+
<template :for="option in optionList()" :key="option.value">
|
|
245
|
+
<option :value="option.value" :disabled="option.disabled" x-text="option.label"></option>
|
|
246
|
+
</template>
|
|
247
|
+
|
|
248
|
+
<slot />
|
|
249
|
+
</select>
|
|
250
|
+
{{-- The disc is a picture of the control, not a second one: the select
|
|
251
|
+
lies under it and takes the click. --}}
|
|
252
|
+
<span class="stx-mac-popup-disc" aria-hidden="true"></span>
|
|
253
|
+
</div>
|
|
254
|
+
|
|
255
|
+
@if(helperText)
|
|
256
|
+
<p id="{{ helperId }}" class="stx-mac-popup-helper" @if(error)data-error="true"@endif>
|
|
257
|
+
{{ helperText }}
|
|
258
|
+
</p>
|
|
259
|
+
@endif
|
|
260
|
+
</div>
|
|
194
261
|
@else
|
|
195
262
|
<div class="w-full">
|
|
196
263
|
@if(label)
|
|
@@ -263,3 +330,202 @@ defineExpose({ value: selectedValue, options: optionList })
|
|
|
263
330
|
@endif
|
|
264
331
|
</div>
|
|
265
332
|
@endif
|
|
333
|
+
|
|
334
|
+
<style data-native-exclude>
|
|
335
|
+
:where(:root) {
|
|
336
|
+
--stx-mac-font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI Variable Text', 'Segoe UI', system-ui, Roboto, 'Helvetica Neue', sans-serif;
|
|
337
|
+
--stx-mac-font-size: 13px;
|
|
338
|
+
--stx-mac-font-size-small: 11px;
|
|
339
|
+
--stx-mac-hairline: 0.5px;
|
|
340
|
+
--stx-mac-focus-ring: 0 0 0 3px color-mix(in srgb, var(--stx-mac-accent) 35%, transparent);
|
|
341
|
+
--stx-mac-card-radius: 12px;
|
|
342
|
+
--stx-mac-control-radius: 6px;
|
|
343
|
+
--stx-mac-row-height: 38px;
|
|
344
|
+
--stx-mac-row-inset: 10px;
|
|
345
|
+
--stx-mac-sidebar-width: 226px;
|
|
346
|
+
--stx-mac-accent: var(--stx-accent, rgb(0, 122, 255));
|
|
347
|
+
--stx-mac-accent-ink: #ffffff;
|
|
348
|
+
--stx-mac-ink: rgba(0, 0, 0, 0.85);
|
|
349
|
+
--stx-mac-ink-secondary: rgba(0, 0, 0, 0.5);
|
|
350
|
+
--stx-mac-ink-tertiary: rgba(0, 0, 0, 0.26);
|
|
351
|
+
--stx-mac-window: #ffffff;
|
|
352
|
+
--stx-mac-sidebar: #f2f1f0;
|
|
353
|
+
--stx-mac-card: rgba(0, 0, 0, 0.04);
|
|
354
|
+
--stx-mac-separator: rgba(0, 0, 0, 0.1);
|
|
355
|
+
--stx-mac-hover: rgba(0, 0, 0, 0.05);
|
|
356
|
+
--stx-mac-selection-inactive: rgba(0, 0, 0, 0.08);
|
|
357
|
+
--stx-mac-well: rgba(0, 0, 0, 0.07);
|
|
358
|
+
--stx-mac-control: #ffffff;
|
|
359
|
+
--stx-mac-control-line: rgba(0, 0, 0, 0.12);
|
|
360
|
+
--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);
|
|
361
|
+
--stx-mac-switch-on: #34c759;
|
|
362
|
+
--stx-mac-knob: #ffffff;
|
|
363
|
+
--stx-mac-danger: #ff3b30;
|
|
364
|
+
}
|
|
365
|
+
:where(.dark) {
|
|
366
|
+
--stx-mac-accent: var(--stx-accent, #0a84ff);
|
|
367
|
+
--stx-mac-accent-ink: #ffffff;
|
|
368
|
+
--stx-mac-ink: rgba(255, 255, 255, 0.85);
|
|
369
|
+
--stx-mac-ink-secondary: rgba(255, 255, 255, 0.55);
|
|
370
|
+
--stx-mac-ink-tertiary: rgba(255, 255, 255, 0.25);
|
|
371
|
+
--stx-mac-window: #1e1e1e;
|
|
372
|
+
--stx-mac-sidebar: #2a2a2a;
|
|
373
|
+
--stx-mac-card: rgba(255, 255, 255, 0.05);
|
|
374
|
+
--stx-mac-separator: rgba(255, 255, 255, 0.1);
|
|
375
|
+
--stx-mac-hover: rgba(255, 255, 255, 0.06);
|
|
376
|
+
--stx-mac-selection-inactive: rgba(255, 255, 255, 0.1);
|
|
377
|
+
--stx-mac-well: rgba(255, 255, 255, 0.1);
|
|
378
|
+
--stx-mac-control: rgba(255, 255, 255, 0.14);
|
|
379
|
+
--stx-mac-control-line: rgba(255, 255, 255, 0.06);
|
|
380
|
+
--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);
|
|
381
|
+
--stx-mac-switch-on: #30d158;
|
|
382
|
+
--stx-mac-knob: #ffffff;
|
|
383
|
+
--stx-mac-danger: #ff453a;
|
|
384
|
+
}
|
|
385
|
+
@media (max-resolution: 1.5dppx) {
|
|
386
|
+
:where(:root) {
|
|
387
|
+
--stx-mac-hairline: 1px;
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
@media (prefers-contrast: more) {
|
|
391
|
+
:where(:root) {
|
|
392
|
+
--stx-mac-separator: rgba(0, 0, 0, 0.4);
|
|
393
|
+
--stx-mac-control-line: rgba(0, 0, 0, 0.5);
|
|
394
|
+
--stx-mac-ink-secondary: rgba(0, 0, 0, 0.75);
|
|
395
|
+
--stx-mac-hairline: 1px;
|
|
396
|
+
}
|
|
397
|
+
:where(.dark) {
|
|
398
|
+
--stx-mac-separator: rgba(255, 255, 255, 0.45);
|
|
399
|
+
--stx-mac-control-line: rgba(255, 255, 255, 0.5);
|
|
400
|
+
--stx-mac-ink-secondary: rgba(255, 255, 255, 0.8);
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
.stx-mac-popup-field {
|
|
405
|
+
display: inline-flex;
|
|
406
|
+
flex-direction: column;
|
|
407
|
+
align-items: flex-end;
|
|
408
|
+
gap: 4px;
|
|
409
|
+
max-width: 100%;
|
|
410
|
+
font-family: var(--stx-mac-font);
|
|
411
|
+
font-size: var(--stx-mac-font-size);
|
|
412
|
+
letter-spacing: -0.08px;
|
|
413
|
+
-webkit-font-smoothing: antialiased;
|
|
414
|
+
color: var(--stx-mac-ink);
|
|
415
|
+
cursor: default;
|
|
416
|
+
-webkit-user-select: none;
|
|
417
|
+
user-select: none;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
.stx-mac-popup-required {
|
|
421
|
+
color: var(--stx-mac-danger);
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
.stx-mac-popup {
|
|
425
|
+
--stx-mac-popup-disc: var(--stx-mac-well);
|
|
426
|
+
--stx-mac-popup-disc-hover: color-mix(in srgb, var(--stx-mac-ink) 14%, transparent);
|
|
427
|
+
position: relative;
|
|
428
|
+
display: inline-flex;
|
|
429
|
+
align-items: center;
|
|
430
|
+
max-width: 100%;
|
|
431
|
+
height: 20px;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
.stx-mac-popup-select {
|
|
435
|
+
box-sizing: border-box;
|
|
436
|
+
max-width: 100%;
|
|
437
|
+
height: 20px;
|
|
438
|
+
margin: 0;
|
|
439
|
+
padding: 0 28px 0 6px;
|
|
440
|
+
border: 0;
|
|
441
|
+
border-radius: 10px;
|
|
442
|
+
background: transparent;
|
|
443
|
+
color: var(--stx-mac-ink);
|
|
444
|
+
font: inherit;
|
|
445
|
+
line-height: 20px;
|
|
446
|
+
letter-spacing: inherit;
|
|
447
|
+
text-align: right;
|
|
448
|
+
text-align-last: right;
|
|
449
|
+
field-sizing: content;
|
|
450
|
+
-webkit-appearance: none;
|
|
451
|
+
appearance: none;
|
|
452
|
+
cursor: default;
|
|
453
|
+
outline: none;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
.stx-mac-popup-select:focus-visible {
|
|
457
|
+
box-shadow: var(--stx-mac-focus-ring);
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
.stx-mac-popup-select[aria-invalid='true'] {
|
|
461
|
+
color: var(--stx-mac-danger);
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
.stx-mac-popup-select:disabled,
|
|
465
|
+
.stx-mac-popup-select:disabled + .stx-mac-popup-disc {
|
|
466
|
+
opacity: 0.5;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
.stx-mac-popup-disc {
|
|
470
|
+
position: absolute;
|
|
471
|
+
top: 0;
|
|
472
|
+
right: 0;
|
|
473
|
+
width: 20px;
|
|
474
|
+
height: 20px;
|
|
475
|
+
border-radius: 50%;
|
|
476
|
+
background: var(--stx-mac-popup-disc);
|
|
477
|
+
color: var(--stx-mac-ink);
|
|
478
|
+
pointer-events: none;
|
|
479
|
+
transition: background-color 150ms ease;
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
.stx-mac-popup:hover .stx-mac-popup-select:not(:disabled) + .stx-mac-popup-disc {
|
|
483
|
+
background: var(--stx-mac-popup-disc-hover);
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
/* The two chevrons, each the corner of a small square turned on its point. */
|
|
487
|
+
.stx-mac-popup-disc::before,
|
|
488
|
+
.stx-mac-popup-disc::after {
|
|
489
|
+
content: '';
|
|
490
|
+
position: absolute;
|
|
491
|
+
left: 7.5px;
|
|
492
|
+
box-sizing: border-box;
|
|
493
|
+
width: 5px;
|
|
494
|
+
height: 5px;
|
|
495
|
+
border: solid currentColor;
|
|
496
|
+
border-width: 1.5px 0 0 1.5px;
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
.stx-mac-popup-disc::before {
|
|
500
|
+
top: 5.5px;
|
|
501
|
+
transform: rotate(45deg);
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
.stx-mac-popup-disc::after {
|
|
505
|
+
top: 9.5px;
|
|
506
|
+
transform: rotate(225deg);
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
.stx-mac-popup-helper {
|
|
510
|
+
margin: 0;
|
|
511
|
+
font-size: var(--stx-mac-font-size-small);
|
|
512
|
+
letter-spacing: 0;
|
|
513
|
+
color: var(--stx-mac-ink-secondary);
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
.stx-mac-popup-helper[data-error='true'] {
|
|
517
|
+
color: var(--stx-mac-danger);
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
@media (prefers-reduced-motion: reduce) {
|
|
521
|
+
.stx-mac-popup-disc {
|
|
522
|
+
transition: none;
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
@media (prefers-contrast: more) {
|
|
527
|
+
.stx-mac-popup-disc {
|
|
528
|
+
box-shadow: inset 0 0 0 1px var(--stx-mac-control-line);
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
</style>
|
package/src/ui/select/index.ts
CHANGED
|
@@ -20,6 +20,8 @@ export interface SelectProps {
|
|
|
20
20
|
placeholder?: string
|
|
21
21
|
disabled?: boolean
|
|
22
22
|
size?: 'sm' | 'md' | 'lg'
|
|
23
|
+
/** `'mac'` draws the Mac pop-up button from the `--stx-mac-*` tokens; `size` is not read. */
|
|
24
|
+
variant?: 'mac'
|
|
23
25
|
error?: boolean
|
|
24
26
|
label?: string
|
|
25
27
|
helperText?: string
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
# Settings window
|
|
2
|
+
|
|
3
|
+
A Mac-native Settings window, built once: the two-column shell System Settings
|
|
4
|
+
has, its sidebar and search, panes with back and forward, the rounded groups of
|
|
5
|
+
rows, and controls drawn the way AppKit draws them. Measured against System
|
|
6
|
+
Settings on macOS 26 and later, in light, dark and an inactive window.
|
|
7
|
+
|
|
8
|
+
```html
|
|
9
|
+
<script client>
|
|
10
|
+
const pane = state('general')
|
|
11
|
+
const openAtLogin = state(true)
|
|
12
|
+
const size = state('medium')
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<SettingsWindow title="Settings" storageKey="my-app" v-model:pane="pane">
|
|
16
|
+
<template #sidebar>
|
|
17
|
+
<SettingsSidebarGroup>
|
|
18
|
+
<SettingsSidebarItem id="general" label="General" icon="i-f7-gear-alt-fill" tone="grey" />
|
|
19
|
+
<SettingsSidebarItem id="appearance" label="Appearance" icon="i-f7-circle-lefthalf-fill" tone="ink" />
|
|
20
|
+
</SettingsSidebarGroup>
|
|
21
|
+
</template>
|
|
22
|
+
|
|
23
|
+
<SettingsPane id="general" title="General" active>
|
|
24
|
+
<SettingsGroup header="Startup" footer="Starts in the background when you sign in.">
|
|
25
|
+
<SettingsRow label="Open at login" setting="open-at-login" keywords="launch start">
|
|
26
|
+
<Switch variant="mac" v-model:checked="openAtLogin" />
|
|
27
|
+
</SettingsRow>
|
|
28
|
+
<SettingsRow label="Sidebar icon size" setting="icon-size">
|
|
29
|
+
<Select variant="mac" v-model:value="size" placeholder="" :options="['small', 'medium', 'large']" />
|
|
30
|
+
</SettingsRow>
|
|
31
|
+
<SettingsRow label="About" to="about" />
|
|
32
|
+
</SettingsGroup>
|
|
33
|
+
</SettingsPane>
|
|
34
|
+
|
|
35
|
+
<SettingsPane id="about" title="About" parent="general">
|
|
36
|
+
<SettingsGroup>
|
|
37
|
+
<SettingsRow label="Version"><span>2.4</span></SettingsRow>
|
|
38
|
+
</SettingsGroup>
|
|
39
|
+
</SettingsPane>
|
|
40
|
+
|
|
41
|
+
<SettingsPane id="appearance" title="Appearance">
|
|
42
|
+
<SettingsGroup>
|
|
43
|
+
<SettingsRow label="Appearance" multiline>
|
|
44
|
+
<AppearancePicker value="auto" />
|
|
45
|
+
</SettingsRow>
|
|
46
|
+
</SettingsGroup>
|
|
47
|
+
</SettingsPane>
|
|
48
|
+
</SettingsWindow>
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Open it as its own window on Cmd+, (in a Craft app, `craft.window.open({ name:
|
|
52
|
+
'settings', ... })` on a titlebar-less window), or put it inside another window
|
|
53
|
+
with `presentation="sheet"`.
|
|
54
|
+
|
|
55
|
+
## The pieces
|
|
56
|
+
|
|
57
|
+
| Tag | What it is |
|
|
58
|
+
|---|---|
|
|
59
|
+
| `<SettingsWindow>` | The shell: sidebar with search, toolbar with back and forward, the scrolling pane. |
|
|
60
|
+
| `<SettingsSidebarGroup>`, `<SettingsSidebarItem>` | The sidebar's rows, in groups. An item's `id` is the pane it opens. |
|
|
61
|
+
| `<SettingsPane>` | One screen. With `parent`, a sub-pane reached from a navigation row. |
|
|
62
|
+
| `<SettingsPaneHeader>` | The card at the top of a pane: icon, title, a sentence. |
|
|
63
|
+
| `<SettingsGroup>` | The rounded card of rows, with an optional heading above and footnote below. |
|
|
64
|
+
| `<SettingsRow>` | A label, an optional description, and the control at the trailing edge. |
|
|
65
|
+
|
|
66
|
+
Controls, each the library's own component in its Mac look:
|
|
67
|
+
|
|
68
|
+
| Control | Tag |
|
|
69
|
+
|---|---|
|
|
70
|
+
| Switch | `<Switch variant="mac">` (`size="mini"` for the small one) |
|
|
71
|
+
| Pop-up button | `<Select variant="mac">` |
|
|
72
|
+
| Segmented control | `<SegmentedControl variant="mac">` |
|
|
73
|
+
| Checkbox, radio buttons | `<Checkbox variant="mac">`, `<RadioGroup variant="mac">` |
|
|
74
|
+
| Push button | `<Button appearance="mac">`, with `variant="primary"` or `variant="danger"` |
|
|
75
|
+
| Text and secure field, stepper | `<TextInput variant="mac">`, `<PasswordInput variant="mac">`, `<NumberInput variant="mac">` |
|
|
76
|
+
| Slider | `<Slider>` |
|
|
77
|
+
| Colour swatches | `<ColorSwatches>` |
|
|
78
|
+
| Appearance picker | `<AppearancePicker>` |
|
|
79
|
+
|
|
80
|
+
`Button` takes `appearance`, not `variant`, because its `variant` already says
|
|
81
|
+
what the button is for.
|
|
82
|
+
|
|
83
|
+
## How it works
|
|
84
|
+
|
|
85
|
+
| File | What it is |
|
|
86
|
+
|---|---|
|
|
87
|
+
| `core.ts` | What the window decides: which pane, the history trail, what a search finds and in what order, where an arrow key lands. No DOM. |
|
|
88
|
+
| `view.ts` | The DOM: shows a pane, runs the search, moves focus, remembers the pane, marks the window inactive. |
|
|
89
|
+
| `*.stx` | The templates and their styles. |
|
|
90
|
+
|
|
91
|
+
The pieces meet in the DOM, not in each other's scripts. A sidebar item is a
|
|
92
|
+
`[data-settings-item]`, a pane a `[data-settings-pane]`, a row a
|
|
93
|
+
`[data-settings-row]`; the shell finds them wherever they are, so a row can be
|
|
94
|
+
your own markup as long as it carries those attributes.
|
|
95
|
+
`@stacksjs/components/settings` exports the core and the view without the
|
|
96
|
+
templates.
|
|
97
|
+
|
|
98
|
+
## SettingsWindow
|
|
99
|
+
|
|
100
|
+
| Prop | Default | |
|
|
101
|
+
|---|---|---|
|
|
102
|
+
| `title` | `'Settings'` | The window's accessible name. |
|
|
103
|
+
| `pane` | stored, then first | The open pane. Two-way with `v-model:pane`. |
|
|
104
|
+
| `searchable` | `true` | |
|
|
105
|
+
| `searchPlaceholder` | `'Search'` | |
|
|
106
|
+
| `storageKey` | | Remembers the last pane under `stx:settings:<key>`. |
|
|
107
|
+
| `presentation` | `'window'` | `window` fills a titlebar-less window and clears its buttons. `sheet` is a rounded panel inside another window. |
|
|
108
|
+
| `sidebarWidth` | `226` | Pixels. |
|
|
109
|
+
| `height` | viewport, or `min(640px, 90vh)` for a sheet | A CSS length. |
|
|
110
|
+
| `id`, `className` | | |
|
|
111
|
+
|
|
112
|
+
Slots: `sidebar` (the groups), `account` (anything above them, such as whose
|
|
113
|
+
account this is), and the default slot (the panes).
|
|
114
|
+
|
|
115
|
+
| Event | Payload |
|
|
116
|
+
|---|---|
|
|
117
|
+
| `@pane` | `{ id, title, parent }` |
|
|
118
|
+
| `@search` | `{ query, panes, settings }` |
|
|
119
|
+
| `@navigate` | `{ id, from, setting }` |
|
|
120
|
+
|
|
121
|
+
From `componentApi(target)` (`@stacksjs/components/component-api`):
|
|
122
|
+
`showPane(id)`, `revealSetting(id)` (opens the pane that holds the row with
|
|
123
|
+
that `setting`, scrolls to it and highlights it; false when there is none),
|
|
124
|
+
`back()`, `forward()`, `focusSearch()`, `getPane()`.
|
|
125
|
+
|
|
126
|
+
```ts
|
|
127
|
+
import { componentApi } from '@stacksjs/components/component-api'
|
|
128
|
+
|
|
129
|
+
// From a menu item, a notification, a deep link:
|
|
130
|
+
componentApi('settings').revealSetting('open-at-login')
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## Rows
|
|
134
|
+
|
|
135
|
+
`<SettingsRow>` props: `label`, `description`, `icon` and `tone` (a leading
|
|
136
|
+
tile), `setting` (its id), `keywords`, `to` (a pane id: a navigation row with a
|
|
137
|
+
chevron), `value` (text beside the chevron), `multiline`, `destructive`,
|
|
138
|
+
`disabled`, `layout="stacked"` (the control under the label, for a text area or
|
|
139
|
+
a list of radio buttons).
|
|
140
|
+
|
|
141
|
+
The row's label names the control inside it: a control with no accessible name
|
|
142
|
+
of its own gets `aria-labelledby` pointing at the label, and the description
|
|
143
|
+
becomes its `aria-describedby`.
|
|
144
|
+
|
|
145
|
+
Tones: `grey`, `blue`, `red`, `orange`, `yellow`, `green`, `indigo`, `purple`,
|
|
146
|
+
`pink`, `ink`. Icons are Iconify classes, such as `i-f7-bell-fill`.
|
|
147
|
+
|
|
148
|
+
## Search
|
|
149
|
+
|
|
150
|
+
The field filters the sidebar and, like System Settings, also lists the
|
|
151
|
+
settings whose label or `keywords` match, each with the name of its pane.
|
|
152
|
+
Choosing one opens the pane, scrolls the row into view and highlights it
|
|
153
|
+
briefly. The number of results is announced to a screen reader.
|
|
154
|
+
|
|
155
|
+
## Keys
|
|
156
|
+
|
|
157
|
+
| Key | |
|
|
158
|
+
|---|---|
|
|
159
|
+
| Up, Down | Move through the sidebar and open each pane, as System Settings does. |
|
|
160
|
+
| Home, End | First and last row. |
|
|
161
|
+
| A letter | Jump to the row starting with it. |
|
|
162
|
+
| Cmd/Ctrl+F | Focus the search field. |
|
|
163
|
+
| Escape | Clear the search and go back to the list. |
|
|
164
|
+
| Cmd/Ctrl+[ and ] | Back and forward. |
|
|
165
|
+
| Enter, Space | Open a navigation row. |
|
|
166
|
+
|
|
167
|
+
The sidebar is a vertical tab list with one tab stop; each pane is a labelled
|
|
168
|
+
tab panel. Nothing traps focus.
|
|
169
|
+
|
|
170
|
+
## Theming
|
|
171
|
+
|
|
172
|
+
Everything is drawn from `--stx-mac-*` custom properties
|
|
173
|
+
(`src/utils/mac-theme.ts`), in two sets of values that follow the `dark` class.
|
|
174
|
+
The accent is `--stx-accent`: set it and the selection, the focus rings (35% of
|
|
175
|
+
it), the primary button and the pickers follow. The ones an app is most likely
|
|
176
|
+
to set:
|
|
177
|
+
|
|
178
|
+
- `--stx-mac-accent`, `--stx-mac-window`, `--stx-mac-sidebar`, `--stx-mac-card`
|
|
179
|
+
- `--stx-mac-card-radius`, `--stx-mac-control-radius`, `--stx-mac-row-height`
|
|
180
|
+
- `--stx-mac-font`, `--stx-mac-font-size`
|
|
181
|
+
- `--stx-settings-sidebar-width`, `--stx-settings-content-width`
|
|
182
|
+
|
|
183
|
+
The font is the system's: San Francisco on a Mac, Segoe UI on Windows, the
|
|
184
|
+
platform sans elsewhere, at the same sizes and layout. Hairlines are half a
|
|
185
|
+
point where a display can draw one. Motion stops under
|
|
186
|
+
`prefers-reduced-motion`, and lines and secondary text firm up under
|
|
187
|
+
`prefers-contrast: more`.
|
|
188
|
+
|
|
189
|
+
## In a Craft window
|
|
190
|
+
|
|
191
|
+
- **Window buttons.** In `presentation="window"` the top of the sidebar leaves
|
|
192
|
+
room for the traffic lights, read from `--craft-window-buttons-*`. Nothing is
|
|
193
|
+
drawn under them.
|
|
194
|
+
- **Dragging.** The sidebar's top band and the toolbar are marked
|
|
195
|
+
`data-window-drag` (and `-webkit-app-region: drag`, which Chromium honours).
|
|
196
|
+
WKWebView ignores the CSS, so on a Mac the host hands a press on
|
|
197
|
+
`[data-window-drag]` to `startDrag()`.
|
|
198
|
+
- **Inactive window.** The shell stamps `data-stx-window-active="false"` when
|
|
199
|
+
the window loses focus, and also honours Craft's
|
|
200
|
+
`data-craft-window-active`: the selection turns grey and the switches and
|
|
201
|
+
radio buttons stand down, as AppKit's do.
|
|
202
|
+
- **Appearance.** `<AppearancePicker>` reports the choice; applying it is the
|
|
203
|
+
app's business (`useColorMode()`).
|
|
204
|
+
|
|
205
|
+
## Limits of this version
|
|
206
|
+
|
|
207
|
+
- **The pop-up button's menu is the platform's.** `<Select>` is a native
|
|
208
|
+
`<select>`, so on a Mac the menu is a real NSMenu and elsewhere it is the
|
|
209
|
+
browser's. Only the button is drawn.
|
|
210
|
+
- **`<RadioGroup>` has no `v-model`.** Give it `value` and listen for `@change`.
|
|
211
|
+
- **A pane says for itself that it is open first** (`active`), because a pane
|
|
212
|
+
cannot see the window's `pane` prop while the server renders it. Without it
|
|
213
|
+
the first pane shows until the script runs.
|
|
214
|
+
- **Appearance thumbnails are sketches** drawn in CSS, not Apple's artwork.
|
|
215
|
+
- **The Mac look is for a web view.** Its styles are left out of a native
|
|
216
|
+
(iOS, Android) build, where a control has the platform's own look already.
|
|
217
|
+
- **Icons need the app's icon CSS.** A tile shows nothing if the page does not
|
|
218
|
+
generate the Iconify class it was given.
|
|
219
|
+
- **Not looked at:** a real Craft window, Windows and Linux web views, a screen
|
|
220
|
+
reader. Focus rings are tested from their CSS rules, since a headless window
|
|
221
|
+
never shows keyboard focus.
|