@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
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
<script server>
|
|
2
|
+
export const checked = $bool($props.checked)
|
|
3
|
+
|
|
4
|
+
/*
|
|
5
|
+
* Form participation, which a <button role="switch"> cannot have on its own
|
|
6
|
+
* (stacksjs/stx#2043).
|
|
7
|
+
*
|
|
8
|
+
* The control the user operates is a button, and a button is never submitted
|
|
9
|
+
* by name -- so a Switch inside a form contributed nothing to FormData no
|
|
10
|
+
* matter what it was set to. A hidden input carries the state instead, which
|
|
11
|
+
* is what it takes for a custom switch to be readable the way a checkbox is.
|
|
12
|
+
*
|
|
13
|
+
* Only rendered when a `name` is given, so a Switch used as a plain toggle
|
|
14
|
+
* emits exactly the markup it did before.
|
|
15
|
+
*/
|
|
16
|
+
export const name = $props.name || ''
|
|
17
|
+
export const form = $props.form || ''
|
|
18
|
+
export const checkedValue = $props.checkedValue || 'true'
|
|
19
|
+
export const uncheckedValue = $props.uncheckedValue || 'false'
|
|
20
|
+
export const disabled = $bool($props.disabled)
|
|
21
|
+
export const size = $props.size || 'md'
|
|
22
|
+
export const className = $props.className || ''
|
|
23
|
+
export const label = $props.label || ''
|
|
24
|
+
/*
|
|
25
|
+
* `variant="mac"` draws the switch System Settings draws: a 36x20 capsule with
|
|
26
|
+
* a pill for a knob, green when on (never the accent), and 26x15 at
|
|
27
|
+
* `size="mini"`. It is the same button, the same hidden input and the same
|
|
28
|
+
* events in other clothes: the classes below are replaced by `stx-mac-switch`,
|
|
29
|
+
* which this file's <style> block draws from the `--stx-mac-*` tokens.
|
|
30
|
+
*/
|
|
31
|
+
export const mac = $props.variant === 'mac'
|
|
32
|
+
export const macSize = size === 'mini' ? 'mini' : 'regular'
|
|
33
|
+
|
|
34
|
+
const sizeConfig = {
|
|
35
|
+
sm: { track: 'h-5 w-9', thumb: 'h-4 w-4', translate: 'translate-x-4' },
|
|
36
|
+
md: { track: 'h-[38px] w-[74px]', thumb: 'h-[34px] w-[34px]', translate: 'translate-x-9' },
|
|
37
|
+
lg: { track: 'h-12 w-24', thumb: 'h-11 w-11', translate: 'translate-x-12' },
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Falls back rather than indexing to undefined: `size="huge"` is a typo, and
|
|
41
|
+
// without this it became `const config = {{ config }}` in the client script --
|
|
42
|
+
// a SyntaxError that killed the whole component rather than mis-sizing it.
|
|
43
|
+
export const config = sizeConfig[size] || sizeConfig.md
|
|
44
|
+
|
|
45
|
+
export const trackBaseClasses = 'relative inline-flex shrink-0 cursor-pointer border-2 border-transparent rounded-full transition-colors duration-200 ease-in-out focus:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-panel'
|
|
46
|
+
export const trackDisabledClasses = 'opacity-50 cursor-not-allowed pointer-events-none'
|
|
47
|
+
export const thumbBaseClasses = 'pointer-events-none inline-block transform rounded-full bg-white shadow-lg ring-0 transition duration-200 ease-in-out'
|
|
48
|
+
</script>
|
|
49
|
+
|
|
50
|
+
<script client>
|
|
51
|
+
const emit = defineEmits(['change'])
|
|
52
|
+
const isDisabled = useReactiveProp('disabled', {{ disabled }})
|
|
53
|
+
const currentLabel = useReactiveProp('label', {{ label }}, { parse: value => value ?? '' })
|
|
54
|
+
const config = {{ config }}
|
|
55
|
+
const trackBase = {{ trackBaseClasses }}
|
|
56
|
+
const trackDisabled = {{ trackDisabledClasses }}
|
|
57
|
+
const thumbBase = {{ thumbBaseClasses }}
|
|
58
|
+
const extraClass = {{ className }}
|
|
59
|
+
// v-model:checked adds two-way binding; keep @change for existing callers.
|
|
60
|
+
const isChecked = useModel('checked', { default: {{ checked }} })
|
|
61
|
+
|
|
62
|
+
function toggle() {
|
|
63
|
+
if (isDisabled()) return
|
|
64
|
+
isChecked.set(!isChecked())
|
|
65
|
+
emit('change', isChecked())
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function trackClasses() {
|
|
69
|
+
const stateClass = isChecked()
|
|
70
|
+
? 'bg-accent-solid'
|
|
71
|
+
: 'bg-neutral-400 dark:bg-neutral-600'
|
|
72
|
+
return `${trackBase} ${stateClass} ${isDisabled() ? trackDisabled : ''} ${config.track} ${extraClass}`.trim()
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// The platform's switch reports its new value itself (a native host's
|
|
76
|
+
// value change); the web's button only says it was pressed.
|
|
77
|
+
function onNativeChange(event) {
|
|
78
|
+
if (isDisabled()) return
|
|
79
|
+
const next = event && typeof event === 'object'
|
|
80
|
+
? (event.value ?? event.nativeEvent?.value ?? event.target?.value)
|
|
81
|
+
: event
|
|
82
|
+
if (typeof next !== 'boolean' || next === isChecked()) return
|
|
83
|
+
isChecked.set(next)
|
|
84
|
+
emit('change', isChecked())
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function thumbClasses() {
|
|
88
|
+
const pos = isChecked() ? config.translate : 'translate-x-0'
|
|
89
|
+
return `${thumbBase} ${pos} ${config.thumb}`.trim()
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
defineExpose({ isChecked, toggle })
|
|
93
|
+
</script>
|
|
94
|
+
|
|
95
|
+
@if($native)
|
|
96
|
+
{{-- On a native host the control is the platform's own switch (UISwitch,
|
|
97
|
+
Android's Switch), at the end of its row as a settings row puts it. --}}
|
|
98
|
+
<label class="flex-row items-center justify-between gap-3 {{ className }}">
|
|
99
|
+
<span :if="currentLabel()" :text="currentLabel()" class="flex-1 text-[17px] text-[#000000] dark:text-[#ffffff]">{{ label }}</span>
|
|
100
|
+
@if(name)
|
|
101
|
+
<input
|
|
102
|
+
type="hidden"
|
|
103
|
+
name="{{ name }}"
|
|
104
|
+
@if(disabled)disabled@endif
|
|
105
|
+
:disabled="isDisabled()"
|
|
106
|
+
@if(form)form="{{ form }}"@endif
|
|
107
|
+
value="{{ checked ? checkedValue : uncheckedValue }}"
|
|
108
|
+
:value="isChecked() ? '{{ checkedValue }}' : '{{ uncheckedValue }}'"
|
|
109
|
+
/>
|
|
110
|
+
@endif
|
|
111
|
+
{{-- Keep the controlled value boolean when a nullable model resets. --}}
|
|
112
|
+
<div
|
|
113
|
+
data-native="Switch"
|
|
114
|
+
data-stx-native-host-root
|
|
115
|
+
role="switch"
|
|
116
|
+
value="{{ checked ? 'true' : 'false' }}"
|
|
117
|
+
:value="!!isChecked()"
|
|
118
|
+
aria-label="{{ label || 'Toggle switch' }}"
|
|
119
|
+
:aria-label="currentLabel() || 'Toggle switch'"
|
|
120
|
+
:aria-checked="isChecked() ? 'true' : 'false'"
|
|
121
|
+
@if(disabled)disabled@endif
|
|
122
|
+
:disabled="isDisabled()"
|
|
123
|
+
:aria-disabled="isDisabled() ? 'true' : 'false'"
|
|
124
|
+
class="text-accent disabled:opacity-50"
|
|
125
|
+
@change="onNativeChange($event)"
|
|
126
|
+
></div>
|
|
127
|
+
</label>
|
|
128
|
+
@elseif(mac)
|
|
129
|
+
<label class="stx-mac-switch-row">
|
|
130
|
+
<span :if="currentLabel()" :text="currentLabel()" class="stx-mac-switch-label">{{ label }}</span>
|
|
131
|
+
|
|
132
|
+
@if(name)
|
|
133
|
+
<input
|
|
134
|
+
type="hidden"
|
|
135
|
+
name="{{ name }}"
|
|
136
|
+
@if(disabled)disabled@endif
|
|
137
|
+
:disabled="isDisabled()"
|
|
138
|
+
@if(form)form="{{ form }}"@endif
|
|
139
|
+
value="{{ checked ? checkedValue : uncheckedValue }}"
|
|
140
|
+
:value="isChecked() ? '{{ checkedValue }}' : '{{ uncheckedValue }}'"
|
|
141
|
+
/>
|
|
142
|
+
@endif
|
|
143
|
+
|
|
144
|
+
{{-- Drawn from `aria-checked`, so the state a reader hears is the state on
|
|
145
|
+
screen. It is served as well as bound: the capsule is green on the
|
|
146
|
+
first paint rather than once the page has hydrated. --}}
|
|
147
|
+
<button
|
|
148
|
+
data-stx-native-host-root
|
|
149
|
+
type="button"
|
|
150
|
+
role="switch"
|
|
151
|
+
aria-label="{{ label || 'Toggle switch' }}"
|
|
152
|
+
:aria-label="currentLabel() || 'Toggle switch'"
|
|
153
|
+
aria-checked="{{ checked ? 'true' : 'false' }}"
|
|
154
|
+
:aria-checked="isChecked() ? 'true' : 'false'"
|
|
155
|
+
class="stx-mac-switch {{ className }}"
|
|
156
|
+
data-size="{{ macSize }}"
|
|
157
|
+
@if(disabled)disabled aria-disabled="true"@endif
|
|
158
|
+
:disabled="isDisabled()"
|
|
159
|
+
:aria-disabled="isDisabled() ? 'true' : 'false'"
|
|
160
|
+
@click="toggle()"
|
|
161
|
+
>
|
|
162
|
+
<span aria-hidden="true" class="stx-mac-switch-knob"></span>
|
|
163
|
+
</button>
|
|
164
|
+
</label>
|
|
165
|
+
@else
|
|
166
|
+
<label class="inline-flex items-center gap-3 cursor-pointer">
|
|
167
|
+
<span :if="currentLabel()" :text="currentLabel()" class="text-sm font-medium text-fg-strong">
|
|
168
|
+
{{ label }}
|
|
169
|
+
</span>
|
|
170
|
+
|
|
171
|
+
@if(name)
|
|
172
|
+
{{-- Always submitted, carrying one of two values, rather than a checkbox's
|
|
173
|
+
present-or-absent convention: a reader then gets an explicit "false"
|
|
174
|
+
instead of a missing key, which is the difference between "switched
|
|
175
|
+
off" and "field was never in the form". --}}
|
|
176
|
+
<input
|
|
177
|
+
type="hidden"
|
|
178
|
+
name="{{ name }}"
|
|
179
|
+
@if(disabled)disabled@endif
|
|
180
|
+
:disabled="isDisabled()"
|
|
181
|
+
@if(form)form="{{ form }}"@endif
|
|
182
|
+
value="{{ checked ? checkedValue : uncheckedValue }}"
|
|
183
|
+
:value="isChecked() ? '{{ checkedValue }}' : '{{ uncheckedValue }}'"
|
|
184
|
+
/>
|
|
185
|
+
@endif
|
|
186
|
+
|
|
187
|
+
<button
|
|
188
|
+
data-stx-native-host-root
|
|
189
|
+
type="button"
|
|
190
|
+
role="switch"
|
|
191
|
+
aria-label="{{ label || 'Toggle switch' }}"
|
|
192
|
+
:aria-label="currentLabel() || 'Toggle switch'"
|
|
193
|
+
:aria-checked="isChecked() ? 'true' : 'false'"
|
|
194
|
+
:class="trackClasses()"
|
|
195
|
+
@if(disabled)disabled aria-disabled="true"@endif
|
|
196
|
+
:disabled="isDisabled()"
|
|
197
|
+
:aria-disabled="isDisabled() ? 'true' : 'false'"
|
|
198
|
+
@click="toggle()"
|
|
199
|
+
>
|
|
200
|
+
<span aria-hidden="true" :class="thumbClasses()"></span>
|
|
201
|
+
</button>
|
|
202
|
+
</label>
|
|
203
|
+
@endif
|
|
204
|
+
|
|
205
|
+
<style data-native-exclude>
|
|
206
|
+
:where(:root) {
|
|
207
|
+
--stx-mac-font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI Variable Text', 'Segoe UI', system-ui, Roboto, 'Helvetica Neue', sans-serif;
|
|
208
|
+
--stx-mac-font-size: 13px;
|
|
209
|
+
--stx-mac-font-size-small: 11px;
|
|
210
|
+
--stx-mac-hairline: 0.5px;
|
|
211
|
+
--stx-mac-focus-ring: 0 0 0 3px color-mix(in srgb, var(--stx-mac-accent) 35%, transparent);
|
|
212
|
+
--stx-mac-card-radius: 12px;
|
|
213
|
+
--stx-mac-control-radius: 6px;
|
|
214
|
+
--stx-mac-row-height: 38px;
|
|
215
|
+
--stx-mac-row-inset: 10px;
|
|
216
|
+
--stx-mac-sidebar-width: 226px;
|
|
217
|
+
--stx-mac-accent: var(--stx-accent, rgb(0, 122, 255));
|
|
218
|
+
--stx-mac-accent-ink: #ffffff;
|
|
219
|
+
--stx-mac-ink: rgba(0, 0, 0, 0.85);
|
|
220
|
+
--stx-mac-ink-secondary: rgba(0, 0, 0, 0.5);
|
|
221
|
+
--stx-mac-ink-tertiary: rgba(0, 0, 0, 0.26);
|
|
222
|
+
--stx-mac-window: #ffffff;
|
|
223
|
+
--stx-mac-sidebar: #f2f1f0;
|
|
224
|
+
--stx-mac-card: rgba(0, 0, 0, 0.04);
|
|
225
|
+
--stx-mac-separator: rgba(0, 0, 0, 0.1);
|
|
226
|
+
--stx-mac-hover: rgba(0, 0, 0, 0.05);
|
|
227
|
+
--stx-mac-selection-inactive: rgba(0, 0, 0, 0.08);
|
|
228
|
+
--stx-mac-well: rgba(0, 0, 0, 0.07);
|
|
229
|
+
--stx-mac-control: #ffffff;
|
|
230
|
+
--stx-mac-control-line: rgba(0, 0, 0, 0.12);
|
|
231
|
+
--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);
|
|
232
|
+
--stx-mac-switch-on: #34c759;
|
|
233
|
+
--stx-mac-knob: #ffffff;
|
|
234
|
+
--stx-mac-danger: #ff3b30;
|
|
235
|
+
}
|
|
236
|
+
:where(.dark) {
|
|
237
|
+
--stx-mac-accent: var(--stx-accent, #0a84ff);
|
|
238
|
+
--stx-mac-accent-ink: #ffffff;
|
|
239
|
+
--stx-mac-ink: rgba(255, 255, 255, 0.85);
|
|
240
|
+
--stx-mac-ink-secondary: rgba(255, 255, 255, 0.55);
|
|
241
|
+
--stx-mac-ink-tertiary: rgba(255, 255, 255, 0.25);
|
|
242
|
+
--stx-mac-window: #1e1e1e;
|
|
243
|
+
--stx-mac-sidebar: #2a2a2a;
|
|
244
|
+
--stx-mac-card: rgba(255, 255, 255, 0.05);
|
|
245
|
+
--stx-mac-separator: rgba(255, 255, 255, 0.1);
|
|
246
|
+
--stx-mac-hover: rgba(255, 255, 255, 0.06);
|
|
247
|
+
--stx-mac-selection-inactive: rgba(255, 255, 255, 0.1);
|
|
248
|
+
--stx-mac-well: rgba(255, 255, 255, 0.1);
|
|
249
|
+
--stx-mac-control: rgba(255, 255, 255, 0.14);
|
|
250
|
+
--stx-mac-control-line: rgba(255, 255, 255, 0.06);
|
|
251
|
+
--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);
|
|
252
|
+
--stx-mac-switch-on: #30d158;
|
|
253
|
+
--stx-mac-knob: #ffffff;
|
|
254
|
+
--stx-mac-danger: #ff453a;
|
|
255
|
+
}
|
|
256
|
+
@media (max-resolution: 1.5dppx) {
|
|
257
|
+
:where(:root) {
|
|
258
|
+
--stx-mac-hairline: 1px;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
@media (prefers-contrast: more) {
|
|
262
|
+
:where(:root) {
|
|
263
|
+
--stx-mac-separator: rgba(0, 0, 0, 0.4);
|
|
264
|
+
--stx-mac-control-line: rgba(0, 0, 0, 0.5);
|
|
265
|
+
--stx-mac-ink-secondary: rgba(0, 0, 0, 0.75);
|
|
266
|
+
--stx-mac-hairline: 1px;
|
|
267
|
+
}
|
|
268
|
+
:where(.dark) {
|
|
269
|
+
--stx-mac-separator: rgba(255, 255, 255, 0.45);
|
|
270
|
+
--stx-mac-control-line: rgba(255, 255, 255, 0.5);
|
|
271
|
+
--stx-mac-ink-secondary: rgba(255, 255, 255, 0.8);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
.stx-mac-switch-row {
|
|
276
|
+
display: inline-flex;
|
|
277
|
+
align-items: center;
|
|
278
|
+
gap: 8px;
|
|
279
|
+
font-family: var(--stx-mac-font);
|
|
280
|
+
font-size: var(--stx-mac-font-size);
|
|
281
|
+
letter-spacing: -0.08px;
|
|
282
|
+
-webkit-font-smoothing: antialiased;
|
|
283
|
+
color: var(--stx-mac-ink);
|
|
284
|
+
cursor: default;
|
|
285
|
+
-webkit-user-select: none;
|
|
286
|
+
user-select: none;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
.stx-mac-switch {
|
|
290
|
+
--stx-mac-switch-width: 36px;
|
|
291
|
+
--stx-mac-switch-height: 20px;
|
|
292
|
+
--stx-mac-switch-knob-width: 22px;
|
|
293
|
+
--stx-mac-switch-knob-height: 16px;
|
|
294
|
+
--stx-mac-switch-travel: 10px;
|
|
295
|
+
--stx-mac-switch-knob-shadow: 0 0.5px 2px rgba(0, 0, 0, 0.22), 0 0 0 0.5px rgba(0, 0, 0, 0.04);
|
|
296
|
+
--stx-mac-switch-inactive: color-mix(in srgb, var(--stx-mac-ink) 24%, transparent);
|
|
297
|
+
position: relative;
|
|
298
|
+
display: inline-block;
|
|
299
|
+
flex: none;
|
|
300
|
+
box-sizing: border-box;
|
|
301
|
+
width: var(--stx-mac-switch-width);
|
|
302
|
+
height: var(--stx-mac-switch-height);
|
|
303
|
+
margin: 0;
|
|
304
|
+
padding: 0;
|
|
305
|
+
border: 0;
|
|
306
|
+
border-radius: calc(var(--stx-mac-switch-height) / 2);
|
|
307
|
+
background: var(--stx-mac-well);
|
|
308
|
+
-webkit-appearance: none;
|
|
309
|
+
appearance: none;
|
|
310
|
+
cursor: default;
|
|
311
|
+
outline: none;
|
|
312
|
+
transition: background-color 150ms ease;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
.stx-mac-switch[data-size='mini'] {
|
|
316
|
+
--stx-mac-switch-width: 26px;
|
|
317
|
+
--stx-mac-switch-height: 15px;
|
|
318
|
+
--stx-mac-switch-knob-width: 16px;
|
|
319
|
+
--stx-mac-switch-knob-height: 11px;
|
|
320
|
+
--stx-mac-switch-travel: 6px;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
.stx-mac-switch[aria-checked='true'] {
|
|
324
|
+
background: var(--stx-mac-switch-on);
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
.stx-mac-switch-knob {
|
|
328
|
+
position: absolute;
|
|
329
|
+
top: 2px;
|
|
330
|
+
left: 2px;
|
|
331
|
+
width: var(--stx-mac-switch-knob-width);
|
|
332
|
+
height: var(--stx-mac-switch-knob-height);
|
|
333
|
+
border-radius: calc(var(--stx-mac-switch-knob-height) / 2);
|
|
334
|
+
background: var(--stx-mac-knob);
|
|
335
|
+
box-shadow: var(--stx-mac-switch-knob-shadow);
|
|
336
|
+
pointer-events: none;
|
|
337
|
+
transition: transform 150ms ease;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
.stx-mac-switch[aria-checked='true'] .stx-mac-switch-knob {
|
|
341
|
+
transform: translateX(var(--stx-mac-switch-travel));
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
.stx-mac-switch:focus-visible {
|
|
345
|
+
box-shadow: var(--stx-mac-focus-ring);
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
.stx-mac-switch:disabled {
|
|
349
|
+
opacity: 0.5;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/* A window that is not the key window draws its controls without colour. */
|
|
353
|
+
:where([data-stx-window-active='false']) .stx-mac-switch[aria-checked='true'],
|
|
354
|
+
:root[data-craft-window-active='false'] .stx-mac-switch[aria-checked='true'] {
|
|
355
|
+
background: var(--stx-mac-switch-inactive);
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
@media (prefers-reduced-motion: reduce) {
|
|
359
|
+
.stx-mac-switch,
|
|
360
|
+
.stx-mac-switch-knob {
|
|
361
|
+
transition: none;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
@media (prefers-contrast: more) {
|
|
366
|
+
.stx-mac-switch {
|
|
367
|
+
box-shadow: inset 0 0 0 1px var(--stx-mac-control-line);
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
.stx-mac-switch:focus-visible {
|
|
371
|
+
box-shadow: inset 0 0 0 1px var(--stx-mac-control-line), var(--stx-mac-focus-ring);
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
</style>
|