@venix-sistemas/jade 1.2.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +969 -579
- package/dist/module.d.mts +8 -1
- package/dist/module.json +1 -1
- package/dist/module.mjs +131 -9
- package/dist/runtime/components/VenixThemeSwitcher.d.vue.ts +7 -1
- package/dist/runtime/components/VenixThemeSwitcher.vue +679 -161
- package/dist/runtime/components/VenixThemeSwitcher.vue.d.ts +7 -1
- package/dist/runtime/composables/useThemeColors.d.ts +2 -2
- package/dist/runtime/composables/useThemeCookies.d.ts +12 -4
- package/dist/runtime/composables/useThemeCookies.js +20 -1
- package/dist/runtime/composables/useThemeLocale.d.ts +2 -2
- package/dist/runtime/composables/useThemeSeasonal.d.ts +2 -2
- package/dist/runtime/composables/useVenixTheme.d.ts +32 -0
- package/dist/runtime/composables/useVenixTheme.js +153 -9
- package/dist/runtime/plugins/overlay-scrollbars.client.d.ts +2 -0
- package/dist/runtime/plugins/overlay-scrollbars.client.js +89 -0
- package/dist/runtime/plugins/theme-init.server.d.ts +1 -1
- package/dist/runtime/plugins/vuetify-theme.d.ts +1 -1
- package/dist/runtime/scripts/theme-init.d.ts +12 -3
- package/dist/runtime/scripts/theme-init.js +21 -4
- package/dist/shared/constants.d.ts +55 -1
- package/dist/shared/constants.js +23 -1
- package/dist/shared/css/colors.d.ts +2 -2
- package/dist/shared/css/colors.js +7 -2
- package/dist/shared/css/cursor-svg.d.ts +10 -0
- package/dist/shared/css/cursor-svg.js +28 -0
- package/dist/shared/css/cursor.js +146 -37
- package/dist/shared/css/index.js +1 -1
- package/dist/shared/css/scrollbar.js +68 -8
- package/dist/shared/css/tokens.d.ts +40 -0
- package/dist/shared/css/tokens.js +119 -0
- package/dist/shared/css/typography.js +13 -0
- package/dist/shared/theme.json +320 -302
- package/dist/shared/token-names.d.ts +37 -0
- package/dist/shared/token-names.js +53 -0
- package/dist/shared/types/color-options.d.ts +23 -2
- package/dist/shared/types/colors.d.ts +38 -0
- package/dist/shared/types/cursor.d.ts +34 -4
- package/dist/shared/types/experimental.d.ts +19 -0
- package/dist/shared/types/experimental.js +0 -0
- package/dist/shared/types/index.d.ts +5 -3
- package/dist/shared/types/runtime-config.d.ts +39 -24
- package/dist/shared/types/scrollbar.d.ts +11 -0
- package/dist/shared/types/theme.d.ts +7 -0
- package/dist/shared/types/typography.d.ts +2 -1
- package/dist/shared/unocss-preset.d.ts +27 -1
- package/dist/shared/unocss-preset.js +20 -2
- package/dist/shared/utils/contrast.d.ts +11 -0
- package/dist/shared/utils/contrast.js +24 -0
- package/dist/shared/utils/index.d.ts +3 -2
- package/dist/shared/utils/index.js +3 -2
- package/dist/shared/utils/load.d.ts +2 -2
- package/dist/shared/utils/load.js +2 -1
- package/dist/shared/utils/merge-themes.d.ts +8 -0
- package/dist/shared/utils/merge-themes.js +25 -3
- package/dist/shared/utils/oklab.d.ts +21 -0
- package/dist/shared/utils/oklab.js +74 -0
- package/dist/shared/utils/scale.d.ts +53 -0
- package/dist/shared/utils/scale.js +164 -0
- package/dist/shared/utils/theme-config.d.ts +11 -3
- package/dist/shared/utils/theme-config.js +10 -2
- package/dist/shared/utils/theme-resolve.d.ts +11 -2
- package/dist/shared/utils/theme-resolve.js +18 -0
- package/dist/shared/utils/theme-resolver.d.ts +1 -0
- package/dist/shared/utils/theme-resolver.js +1 -0
- package/package.json +24 -9
|
@@ -1,160 +1,349 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div
|
|
3
|
-
ref="rootRef"
|
|
4
|
-
class="venix-theme-switcher"
|
|
5
|
-
@focusout="handleFocusOut"
|
|
6
|
-
>
|
|
7
|
-
<span
|
|
8
|
-
class="venix-theme-switcher__sr-only"
|
|
9
|
-
role="status"
|
|
10
|
-
aria-live="polite"
|
|
11
|
-
>{{ announcement }}</span>
|
|
12
|
-
|
|
13
|
-
<button
|
|
14
|
-
ref="triggerRef"
|
|
15
|
-
type="button"
|
|
16
|
-
class="venix-theme-switcher__trigger"
|
|
17
|
-
:class="{ 'venix-theme-switcher__trigger--visible': visible }"
|
|
18
|
-
:aria-label="resolvedLabel"
|
|
19
|
-
:aria-expanded="open"
|
|
20
|
-
aria-haspopup="menu"
|
|
21
|
-
@click="toggleOpen"
|
|
22
|
-
>
|
|
23
|
-
<template v-if="activeIcon">
|
|
24
|
-
<span
|
|
25
|
-
v-if="activeIcon.format === 'emote'"
|
|
26
|
-
:key="activeIconKey"
|
|
27
|
-
class="venix-icon venix-icon--emoji"
|
|
28
|
-
aria-hidden="true"
|
|
29
|
-
>{{ activeIcon.value }}</span>
|
|
30
|
-
<VenixIcon
|
|
31
|
-
v-else
|
|
32
|
-
:key="activeIconKey"
|
|
33
|
-
:icon="activeIcon.value"
|
|
34
|
-
:mode="activeIcon.format"
|
|
35
|
-
aria-hidden="true"
|
|
36
|
-
/>
|
|
37
|
-
</template>
|
|
38
|
-
<span
|
|
39
|
-
v-if="showLabel"
|
|
40
|
-
class="venix-theme-switcher__trigger-label"
|
|
41
|
-
>{{ triggerLabel }}</span>
|
|
42
|
-
</button>
|
|
43
|
-
|
|
44
|
-
<Transition name="venix-theme-switcher-menu">
|
|
45
|
-
<div
|
|
46
|
-
v-show="open"
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
:
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
>
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
2
|
+
<div
|
|
3
|
+
ref="rootRef"
|
|
4
|
+
class="venix-theme-switcher"
|
|
5
|
+
@focusout="handleFocusOut"
|
|
6
|
+
>
|
|
7
|
+
<span
|
|
8
|
+
class="venix-theme-switcher__sr-only"
|
|
9
|
+
role="status"
|
|
10
|
+
aria-live="polite"
|
|
11
|
+
>{{ announcement }}</span>
|
|
12
|
+
|
|
13
|
+
<button
|
|
14
|
+
ref="triggerRef"
|
|
15
|
+
type="button"
|
|
16
|
+
class="venix-theme-switcher__trigger"
|
|
17
|
+
:class="{ 'venix-theme-switcher__trigger--visible': visible }"
|
|
18
|
+
:aria-label="resolvedLabel"
|
|
19
|
+
:aria-expanded="open"
|
|
20
|
+
aria-haspopup="menu"
|
|
21
|
+
@click="toggleOpen"
|
|
22
|
+
>
|
|
23
|
+
<template v-if="activeIcon">
|
|
24
|
+
<span
|
|
25
|
+
v-if="activeIcon.format === 'emote'"
|
|
26
|
+
:key="activeIconKey"
|
|
27
|
+
class="venix-icon venix-icon--emoji"
|
|
28
|
+
aria-hidden="true"
|
|
29
|
+
>{{ activeIcon.value }}</span>
|
|
30
|
+
<VenixIcon
|
|
31
|
+
v-else
|
|
32
|
+
:key="activeIconKey"
|
|
33
|
+
:icon="activeIcon.value"
|
|
34
|
+
:mode="activeIcon.format"
|
|
35
|
+
aria-hidden="true"
|
|
36
|
+
/>
|
|
37
|
+
</template>
|
|
38
|
+
<span
|
|
39
|
+
v-if="showLabel"
|
|
40
|
+
class="venix-theme-switcher__trigger-label"
|
|
41
|
+
>{{ triggerLabel }}</span>
|
|
42
|
+
</button>
|
|
43
|
+
|
|
44
|
+
<Transition name="venix-theme-switcher-menu">
|
|
45
|
+
<div
|
|
46
|
+
v-show="open"
|
|
47
|
+
ref="menuRef"
|
|
48
|
+
class="venix-theme-switcher__menu"
|
|
49
|
+
:class="{ 'venix-theme-switcher__menu--above': placeAbove }"
|
|
50
|
+
:style="menuStyle"
|
|
51
|
+
role="menu"
|
|
52
|
+
tabindex="-1"
|
|
53
|
+
:aria-label="resolvedLabel"
|
|
54
|
+
@keydown="handleMenuKeydown"
|
|
55
|
+
>
|
|
56
|
+
<div
|
|
57
|
+
v-if="view === 'settings'"
|
|
58
|
+
key="settings"
|
|
59
|
+
class="venix-theme-switcher__view venix-theme-switcher__view--settings"
|
|
60
|
+
>
|
|
61
|
+
<div class="venix-theme-switcher__header">
|
|
62
|
+
<button
|
|
63
|
+
type="button"
|
|
64
|
+
role="menuitem"
|
|
65
|
+
class="venix-theme-switcher__icon-button"
|
|
66
|
+
:aria-label="backLabel"
|
|
67
|
+
:title="backLabel"
|
|
68
|
+
@click="showView('main')"
|
|
69
|
+
>
|
|
70
|
+
<span
|
|
71
|
+
v-if="icons.back?.format === 'emote'"
|
|
72
|
+
class="venix-icon venix-icon--emoji"
|
|
73
|
+
aria-hidden="true"
|
|
74
|
+
>{{ icons.back.value }}</span>
|
|
75
|
+
<VenixIcon
|
|
76
|
+
v-else-if="icons.back"
|
|
77
|
+
:icon="icons.back.value"
|
|
78
|
+
:mode="icons.back.format"
|
|
79
|
+
aria-hidden="true"
|
|
80
|
+
/>
|
|
81
|
+
</button>
|
|
82
|
+
<div
|
|
83
|
+
class="venix-theme-switcher__heading"
|
|
84
|
+
aria-hidden="true"
|
|
85
|
+
>
|
|
86
|
+
{{ settingsHeading }}
|
|
87
|
+
</div>
|
|
88
|
+
</div>
|
|
89
|
+
|
|
90
|
+
<div
|
|
91
|
+
class="venix-theme-switcher__separator"
|
|
92
|
+
role="separator"
|
|
93
|
+
/>
|
|
94
|
+
|
|
95
|
+
<div
|
|
96
|
+
class="venix-theme-switcher__group"
|
|
97
|
+
role="group"
|
|
98
|
+
:aria-label="settingsHeading"
|
|
99
|
+
>
|
|
100
|
+
<button
|
|
101
|
+
v-for="option in settingsOptions"
|
|
102
|
+
:key="option.key"
|
|
103
|
+
type="button"
|
|
104
|
+
role="menuitemcheckbox"
|
|
105
|
+
class="venix-theme-switcher__item venix-theme-switcher__item--toggle"
|
|
106
|
+
:class="{ 'venix-theme-switcher__item--on': option.enabled }"
|
|
107
|
+
:aria-checked="option.enabled"
|
|
108
|
+
@click="toggleOption(option)"
|
|
109
|
+
>
|
|
110
|
+
<span
|
|
111
|
+
v-if="option.icon?.format === 'emote'"
|
|
112
|
+
class="venix-icon venix-icon--emoji venix-theme-switcher__item-icon"
|
|
113
|
+
aria-hidden="true"
|
|
114
|
+
>{{ option.icon.value }}</span>
|
|
115
|
+
<VenixIcon
|
|
116
|
+
v-else-if="option.icon"
|
|
117
|
+
class="venix-theme-switcher__item-icon"
|
|
118
|
+
:icon="option.icon.value"
|
|
119
|
+
:mode="option.icon.format"
|
|
120
|
+
aria-hidden="true"
|
|
121
|
+
/>
|
|
122
|
+
<span class="venix-theme-switcher__item-text">
|
|
123
|
+
<span class="venix-theme-switcher__item-title">{{ option.title }}</span>
|
|
124
|
+
<span
|
|
125
|
+
v-if="option.description"
|
|
126
|
+
class="venix-theme-switcher__item-description"
|
|
127
|
+
>{{ option.description }}</span>
|
|
128
|
+
</span>
|
|
129
|
+
<span
|
|
130
|
+
class="venix-theme-switcher__switch"
|
|
131
|
+
aria-hidden="true"
|
|
132
|
+
/>
|
|
133
|
+
</button>
|
|
134
|
+
</div>
|
|
135
|
+
|
|
136
|
+
<a
|
|
137
|
+
class="venix-theme-switcher__credit"
|
|
138
|
+
role="menuitem"
|
|
139
|
+
tabindex="-1"
|
|
140
|
+
:href="SWITCHER_CREDIT.url"
|
|
141
|
+
target="_blank"
|
|
142
|
+
rel="noopener"
|
|
143
|
+
>{{ SWITCHER_CREDIT.name }}</a>
|
|
144
|
+
</div>
|
|
145
|
+
|
|
146
|
+
<div
|
|
147
|
+
v-else
|
|
148
|
+
key="main"
|
|
149
|
+
class="venix-theme-switcher__view"
|
|
150
|
+
>
|
|
151
|
+
<div class="venix-theme-switcher__header">
|
|
152
|
+
<div
|
|
153
|
+
class="venix-theme-switcher__heading"
|
|
154
|
+
aria-hidden="true"
|
|
155
|
+
>
|
|
156
|
+
{{ resolvedLabel }}
|
|
157
|
+
</div>
|
|
158
|
+
<button
|
|
159
|
+
v-if="settingsOptions.length > 0"
|
|
160
|
+
type="button"
|
|
161
|
+
role="menuitem"
|
|
162
|
+
class="venix-theme-switcher__icon-button"
|
|
163
|
+
:aria-label="settingsHeading"
|
|
164
|
+
:title="settingsHeading"
|
|
165
|
+
@click="showView('settings')"
|
|
166
|
+
>
|
|
167
|
+
<span
|
|
168
|
+
v-if="icons.settings?.format === 'emote'"
|
|
169
|
+
class="venix-icon venix-icon--emoji"
|
|
170
|
+
aria-hidden="true"
|
|
171
|
+
>{{ icons.settings.value }}</span>
|
|
172
|
+
<VenixIcon
|
|
173
|
+
v-else-if="icons.settings"
|
|
174
|
+
:icon="icons.settings.value"
|
|
175
|
+
:mode="icons.settings.format"
|
|
176
|
+
aria-hidden="true"
|
|
177
|
+
/>
|
|
178
|
+
</button>
|
|
179
|
+
</div>
|
|
180
|
+
|
|
181
|
+
<div
|
|
182
|
+
class="venix-theme-switcher__separator"
|
|
183
|
+
role="separator"
|
|
184
|
+
/>
|
|
185
|
+
|
|
186
|
+
<div
|
|
187
|
+
class="venix-theme-switcher__group"
|
|
188
|
+
role="group"
|
|
189
|
+
:aria-label="modeHeading"
|
|
190
|
+
>
|
|
191
|
+
<div
|
|
192
|
+
class="venix-theme-switcher__subheading"
|
|
193
|
+
aria-hidden="true"
|
|
194
|
+
>
|
|
195
|
+
{{ modeHeading }}
|
|
196
|
+
</div>
|
|
197
|
+
<div class="venix-theme-switcher__modes">
|
|
198
|
+
<button
|
|
199
|
+
v-for="item in modes"
|
|
200
|
+
:key="item.value"
|
|
201
|
+
type="button"
|
|
202
|
+
role="menuitemradio"
|
|
203
|
+
class="venix-theme-switcher__item venix-theme-switcher__item--mode"
|
|
204
|
+
:class="{ 'venix-theme-switcher__item--active': item.value === mode.preference.value }"
|
|
205
|
+
:aria-checked="item.value === mode.preference.value"
|
|
206
|
+
@click="selectMode(item.value)"
|
|
207
|
+
>
|
|
208
|
+
<span
|
|
209
|
+
v-if="item.icon?.format === 'emote'"
|
|
210
|
+
class="venix-icon venix-icon--emoji venix-theme-switcher__item-icon"
|
|
211
|
+
aria-hidden="true"
|
|
212
|
+
>{{ item.icon.value }}</span>
|
|
213
|
+
<VenixIcon
|
|
214
|
+
v-else-if="item.icon"
|
|
215
|
+
class="venix-theme-switcher__item-icon"
|
|
216
|
+
:icon="item.icon.value"
|
|
217
|
+
:mode="item.icon.format"
|
|
218
|
+
aria-hidden="true"
|
|
219
|
+
/>
|
|
220
|
+
<span>{{ item.name }}</span>
|
|
221
|
+
</button>
|
|
222
|
+
</div>
|
|
223
|
+
</div>
|
|
224
|
+
|
|
225
|
+
<template
|
|
226
|
+
v-for="section in themeSections"
|
|
227
|
+
:key="section.key"
|
|
228
|
+
>
|
|
229
|
+
<div
|
|
230
|
+
class="venix-theme-switcher__separator"
|
|
231
|
+
role="separator"
|
|
232
|
+
/>
|
|
233
|
+
|
|
234
|
+
<div
|
|
235
|
+
class="venix-theme-switcher__group"
|
|
236
|
+
role="group"
|
|
237
|
+
:aria-label="section.heading"
|
|
238
|
+
>
|
|
239
|
+
<div
|
|
240
|
+
class="venix-theme-switcher__subheading"
|
|
241
|
+
aria-hidden="true"
|
|
242
|
+
>
|
|
243
|
+
{{ section.heading }}
|
|
244
|
+
</div>
|
|
245
|
+
<button
|
|
246
|
+
v-for="item in section.items"
|
|
247
|
+
:key="item.value"
|
|
248
|
+
type="button"
|
|
249
|
+
role="menuitemradio"
|
|
250
|
+
class="venix-theme-switcher__item"
|
|
251
|
+
:class="{ 'venix-theme-switcher__item--active': item.value === theme.preference.value }"
|
|
252
|
+
:aria-checked="item.value === theme.preference.value"
|
|
253
|
+
@click="selectTheme(item.value)"
|
|
254
|
+
>
|
|
255
|
+
<span
|
|
256
|
+
v-if="item.icon?.format === 'emote'"
|
|
257
|
+
class="venix-icon venix-icon--emoji venix-theme-switcher__item-icon"
|
|
258
|
+
aria-hidden="true"
|
|
259
|
+
>{{ item.icon.value }}</span>
|
|
260
|
+
<VenixIcon
|
|
261
|
+
v-else-if="item.icon"
|
|
262
|
+
class="venix-theme-switcher__item-icon"
|
|
263
|
+
:icon="item.icon.value"
|
|
264
|
+
:mode="item.icon.format"
|
|
265
|
+
aria-hidden="true"
|
|
266
|
+
/>
|
|
267
|
+
<span>{{ item.name }}</span>
|
|
268
|
+
<span
|
|
269
|
+
v-if="seasonLabels[item.value]"
|
|
270
|
+
class="venix-theme-switcher__item-season"
|
|
271
|
+
>{{ seasonLabels[item.value] }}</span>
|
|
272
|
+
</button>
|
|
273
|
+
</div>
|
|
274
|
+
</template>
|
|
275
|
+
|
|
276
|
+
<!-- After a change that won't be remembered (no consent yet): a
|
|
277
|
+
reminder at the bottom that saves right here, so the visitor
|
|
278
|
+
doesn't have to find "Save changes" in the settings. -->
|
|
279
|
+
<Transition
|
|
280
|
+
name="venix-theme-switcher-prompt"
|
|
281
|
+
@after-enter="revealPrompt"
|
|
282
|
+
@after-leave="updatePlacement"
|
|
283
|
+
>
|
|
284
|
+
<div
|
|
285
|
+
v-if="showSavePrompt || justSaved"
|
|
286
|
+
class="venix-theme-switcher__prompt"
|
|
287
|
+
>
|
|
288
|
+
<div class="venix-theme-switcher__prompt-inner">
|
|
289
|
+
<div
|
|
290
|
+
class="venix-theme-switcher__separator"
|
|
291
|
+
role="separator"
|
|
292
|
+
/>
|
|
293
|
+
<div
|
|
294
|
+
v-if="justSaved"
|
|
295
|
+
class="venix-theme-switcher__prompt-row venix-theme-switcher__prompt-row--saved"
|
|
296
|
+
>
|
|
297
|
+
<span aria-hidden="true">✓</span>
|
|
298
|
+
<span>{{ promptSavedLabel }}</span>
|
|
299
|
+
</div>
|
|
300
|
+
<div
|
|
301
|
+
v-else
|
|
302
|
+
class="venix-theme-switcher__prompt-row"
|
|
303
|
+
>
|
|
304
|
+
<span
|
|
305
|
+
:id="promptTextId"
|
|
306
|
+
class="venix-theme-switcher__item-text"
|
|
307
|
+
>
|
|
308
|
+
<span class="venix-theme-switcher__prompt-title">{{ promptTitle }}</span>
|
|
309
|
+
<span class="venix-theme-switcher__item-description">{{ promptDescription }}</span>
|
|
310
|
+
</span>
|
|
311
|
+
<button
|
|
312
|
+
type="button"
|
|
313
|
+
role="menuitem"
|
|
314
|
+
class="venix-theme-switcher__prompt-button venix-theme-switcher__prompt-button--save"
|
|
315
|
+
:aria-describedby="promptTextId"
|
|
316
|
+
@click="saveFromPrompt"
|
|
317
|
+
>
|
|
318
|
+
{{ promptSaveLabel }}
|
|
319
|
+
</button>
|
|
320
|
+
<button
|
|
321
|
+
type="button"
|
|
322
|
+
role="menuitem"
|
|
323
|
+
class="venix-theme-switcher__prompt-button venix-theme-switcher__prompt-button--dismiss"
|
|
324
|
+
:aria-label="promptDismissLabel"
|
|
325
|
+
:title="promptDismissLabel"
|
|
326
|
+
@click="dismissPrompt"
|
|
327
|
+
>
|
|
328
|
+
<span aria-hidden="true">×</span>
|
|
329
|
+
</button>
|
|
330
|
+
</div>
|
|
331
|
+
</div>
|
|
332
|
+
</div>
|
|
333
|
+
</Transition>
|
|
334
|
+
</div>
|
|
335
|
+
</div>
|
|
336
|
+
</Transition>
|
|
337
|
+
</div>
|
|
152
338
|
</template>
|
|
153
339
|
|
|
154
340
|
<script setup>
|
|
155
|
-
import { ref, computed, onMounted, onUnmounted, nextTick } from "vue";
|
|
341
|
+
import { ref, computed, watch, onMounted, onUnmounted, nextTick, useId } from "vue";
|
|
342
|
+
import { useRuntimeConfig } from "#app";
|
|
156
343
|
import { useVenixTheme } from "../composables/useVenixTheme";
|
|
157
|
-
import { getDefaultSelection } from "../../shared/utils/theme-resolve";
|
|
344
|
+
import { getDefaultSelection, getSeasonDates } from "../../shared/utils/theme-resolve";
|
|
345
|
+
import { resolveThemeIcon } from "../../shared/utils/icon";
|
|
346
|
+
import { SWITCHER_CREDIT, SWITCHER_ICONS } from "../../shared/constants";
|
|
158
347
|
import VenixIcon from "./VenixIcon.vue";
|
|
159
348
|
const LABEL_TRANSLATIONS = {
|
|
160
349
|
"pt-BR": "Cores do site",
|
|
@@ -222,11 +411,156 @@ const MODE_CHANGED_ANNOUNCEMENT_TRANSLATIONS = {
|
|
|
222
411
|
"ko-KR": "\uBAA8\uB4DC\uAC00 {mode}(\uC73C)\uB85C \uBCC0\uACBD\uB418\uC5C8\uC2B5\uB2C8\uB2E4",
|
|
223
412
|
"zh-CN": "\u6A21\u5F0F\u5DF2\u66F4\u6539\u4E3A{mode}"
|
|
224
413
|
};
|
|
414
|
+
const SETTINGS_HEADING_TRANSLATIONS = {
|
|
415
|
+
"pt-BR": "Configura\xE7\xF5es",
|
|
416
|
+
"en-US": "Settings",
|
|
417
|
+
"es-ES": "Configuraci\xF3n",
|
|
418
|
+
"fr-FR": "Param\xE8tres",
|
|
419
|
+
"de-DE": "Einstellungen",
|
|
420
|
+
"it-IT": "Impostazioni",
|
|
421
|
+
"ja-JP": "\u8A2D\u5B9A",
|
|
422
|
+
"ko-KR": "\uC124\uC815",
|
|
423
|
+
"zh-CN": "\u8BBE\u7F6E"
|
|
424
|
+
};
|
|
425
|
+
const BACK_TRANSLATIONS = {
|
|
426
|
+
"pt-BR": "Voltar",
|
|
427
|
+
"en-US": "Back",
|
|
428
|
+
"es-ES": "Volver",
|
|
429
|
+
"fr-FR": "Retour",
|
|
430
|
+
"de-DE": "Zur\xFCck",
|
|
431
|
+
"it-IT": "Indietro",
|
|
432
|
+
"ja-JP": "\u623B\u308B",
|
|
433
|
+
"ko-KR": "\uB4A4\uB85C",
|
|
434
|
+
"zh-CN": "\u8FD4\u56DE"
|
|
435
|
+
};
|
|
436
|
+
const SAVE_TITLE_TRANSLATIONS = {
|
|
437
|
+
"pt-BR": "Salvar altera\xE7\xF5es",
|
|
438
|
+
"en-US": "Save changes",
|
|
439
|
+
"es-ES": "Guardar cambios",
|
|
440
|
+
"fr-FR": "Enregistrer",
|
|
441
|
+
"de-DE": "Speichern",
|
|
442
|
+
"it-IT": "Salva modifiche",
|
|
443
|
+
"ja-JP": "\u5909\u66F4\u3092\u4FDD\u5B58",
|
|
444
|
+
"ko-KR": "\uBCC0\uACBD \uC0AC\uD56D \uC800\uC7A5",
|
|
445
|
+
"zh-CN": "\u4FDD\u5B58\u66F4\u6539"
|
|
446
|
+
};
|
|
447
|
+
const SAVE_DESCRIPTION_TRANSLATIONS = {
|
|
448
|
+
"pt-BR": "Lembrar suas escolhas ao voltar ao site (usa cookies)",
|
|
449
|
+
"en-US": "Remember your choices next time you visit (uses cookies)",
|
|
450
|
+
"es-ES": "Recordar tus elecciones la pr\xF3xima vez (usa cookies)",
|
|
451
|
+
"fr-FR": "Retrouver vos choix \xE0 la prochaine visite (cookies)",
|
|
452
|
+
"de-DE": "Deine Auswahl beim n\xE4chsten Besuch behalten (Cookies)",
|
|
453
|
+
"it-IT": "Ricordare le tue scelte alla prossima visita (usa cookie)",
|
|
454
|
+
"ja-JP": "\u6B21\u56DE\u306E\u30A2\u30AF\u30BB\u30B9\u6642\u3082\u9078\u629E\u3092\u4FDD\u6301\u3057\u307E\u3059\uFF08Cookie\u3092\u4F7F\u7528\uFF09",
|
|
455
|
+
"ko-KR": "\uB2E4\uC74C \uBC29\uBB38 \uB54C\uB3C4 \uC120\uD0DD\uC744 \uC720\uC9C0\uD569\uB2C8\uB2E4 (\uCFE0\uD0A4 \uC0AC\uC6A9)",
|
|
456
|
+
"zh-CN": "\u4E0B\u6B21\u8BBF\u95EE\u65F6\u4FDD\u7559\u4F60\u7684\u9009\u62E9\uFF08\u4F7F\u7528 Cookie\uFF09"
|
|
457
|
+
};
|
|
458
|
+
const SCROLLBAR_TITLE_TRANSLATIONS = {
|
|
459
|
+
"pt-BR": "Rolagem personalizada",
|
|
460
|
+
"en-US": "Custom scrollbar",
|
|
461
|
+
"es-ES": "Scroll personalizado",
|
|
462
|
+
"fr-FR": "D\xE9filement stylis\xE9",
|
|
463
|
+
"de-DE": "Eigene Scrollleiste",
|
|
464
|
+
"it-IT": "Scroll personalizzato",
|
|
465
|
+
"ja-JP": "\u30AB\u30B9\u30BF\u30E0\u30B9\u30AF\u30ED\u30FC\u30EB\u30D0\u30FC",
|
|
466
|
+
"ko-KR": "\uC0AC\uC6A9\uC790 \uC9C0\uC815 \uC2A4\uD06C\uB864\uBC14",
|
|
467
|
+
"zh-CN": "\u81EA\u5B9A\u4E49\u6EDA\u52A8\u6761"
|
|
468
|
+
};
|
|
469
|
+
const CURSOR_TITLE_TRANSLATIONS = {
|
|
470
|
+
"pt-BR": "Cursor personalizado",
|
|
471
|
+
"en-US": "Custom cursor",
|
|
472
|
+
"es-ES": "Cursor personalizado",
|
|
473
|
+
"fr-FR": "Curseur stylis\xE9",
|
|
474
|
+
"de-DE": "Eigener Mauszeiger",
|
|
475
|
+
"it-IT": "Cursore personalizzato",
|
|
476
|
+
"ja-JP": "\u30AB\u30B9\u30BF\u30E0\u30AB\u30FC\u30BD\u30EB",
|
|
477
|
+
"ko-KR": "\uC0AC\uC6A9\uC790 \uC9C0\uC815 \uCEE4\uC11C",
|
|
478
|
+
"zh-CN": "\u81EA\u5B9A\u4E49\u5149\u6807"
|
|
479
|
+
};
|
|
480
|
+
const SEASON_RANGE_TRANSLATIONS = {
|
|
481
|
+
"pt-BR": "{start} a {end}",
|
|
482
|
+
"en-US": "{start} \u2013 {end}",
|
|
483
|
+
"es-ES": "{start} a {end}",
|
|
484
|
+
"fr-FR": "{start} \u2013 {end}",
|
|
485
|
+
"de-DE": "{start} \u2013 {end}",
|
|
486
|
+
"it-IT": "{start} \u2013 {end}",
|
|
487
|
+
"ja-JP": "{start}\uFF5E{end}",
|
|
488
|
+
"ko-KR": "{start}~{end}",
|
|
489
|
+
"zh-CN": "{start}\u81F3{end}"
|
|
490
|
+
};
|
|
491
|
+
const PROMPT_TITLE_TRANSLATIONS = {
|
|
492
|
+
"pt-BR": "Lembrar suas escolhas?",
|
|
493
|
+
"en-US": "Remember your choices?",
|
|
494
|
+
"es-ES": "\xBFRecordar tus elecciones?",
|
|
495
|
+
"fr-FR": "Retenir vos choix ?",
|
|
496
|
+
"de-DE": "Auswahl merken?",
|
|
497
|
+
"it-IT": "Ricordare le tue scelte?",
|
|
498
|
+
"ja-JP": "\u9078\u629E\u3092\u4FDD\u5B58\u3057\u307E\u3059\u304B\uFF1F",
|
|
499
|
+
"ko-KR": "\uC120\uD0DD\uC744 \uAE30\uC5B5\uD560\uAE4C\uC694?",
|
|
500
|
+
"zh-CN": "\u8BB0\u4F4F\u4F60\u7684\u9009\u62E9\uFF1F"
|
|
501
|
+
};
|
|
502
|
+
const PROMPT_DESCRIPTION_TRANSLATIONS = {
|
|
503
|
+
"pt-BR": "Usa cookies",
|
|
504
|
+
"en-US": "Uses cookies",
|
|
505
|
+
"es-ES": "Usa cookies",
|
|
506
|
+
"fr-FR": "Utilise des cookies",
|
|
507
|
+
"de-DE": "Nutzt Cookies",
|
|
508
|
+
"it-IT": "Usa cookie",
|
|
509
|
+
"ja-JP": "Cookie\u3092\u4F7F\u7528",
|
|
510
|
+
"ko-KR": "\uCFE0\uD0A4 \uC0AC\uC6A9",
|
|
511
|
+
"zh-CN": "\u4F7F\u7528 Cookie"
|
|
512
|
+
};
|
|
513
|
+
const PROMPT_SAVE_TRANSLATIONS = {
|
|
514
|
+
"pt-BR": "Salvar",
|
|
515
|
+
"en-US": "Save",
|
|
516
|
+
"es-ES": "Guardar",
|
|
517
|
+
"fr-FR": "Enregistrer",
|
|
518
|
+
"de-DE": "Speichern",
|
|
519
|
+
"it-IT": "Salva",
|
|
520
|
+
"ja-JP": "\u4FDD\u5B58",
|
|
521
|
+
"ko-KR": "\uC800\uC7A5",
|
|
522
|
+
"zh-CN": "\u4FDD\u5B58"
|
|
523
|
+
};
|
|
524
|
+
const PROMPT_DISMISS_TRANSLATIONS = {
|
|
525
|
+
"pt-BR": "Agora n\xE3o",
|
|
526
|
+
"en-US": "Not now",
|
|
527
|
+
"es-ES": "Ahora no",
|
|
528
|
+
"fr-FR": "Pas maintenant",
|
|
529
|
+
"de-DE": "Nicht jetzt",
|
|
530
|
+
"it-IT": "Non ora",
|
|
531
|
+
"ja-JP": "\u4ECA\u306F\u3057\u306A\u3044",
|
|
532
|
+
"ko-KR": "\uB098\uC911\uC5D0",
|
|
533
|
+
"zh-CN": "\u6682\u4E0D"
|
|
534
|
+
};
|
|
535
|
+
const PROMPT_SAVED_TRANSLATIONS = {
|
|
536
|
+
"pt-BR": "Escolhas salvas",
|
|
537
|
+
"en-US": "Choices saved",
|
|
538
|
+
"es-ES": "Elecciones guardadas",
|
|
539
|
+
"fr-FR": "Choix enregistr\xE9s",
|
|
540
|
+
"de-DE": "Auswahl gespeichert",
|
|
541
|
+
"it-IT": "Scelte salvate",
|
|
542
|
+
"ja-JP": "\u9078\u629E\u3092\u4FDD\u5B58\u3057\u307E\u3057\u305F",
|
|
543
|
+
"ko-KR": "\uC120\uD0DD\uC774 \uC800\uC7A5\uB418\uC5C8\uC2B5\uB2C8\uB2E4",
|
|
544
|
+
"zh-CN": "\u5DF2\u4FDD\u5B58\u4F60\u7684\u9009\u62E9"
|
|
545
|
+
};
|
|
546
|
+
const FONT_TITLE_TRANSLATIONS = {
|
|
547
|
+
"pt-BR": "Fonte personalizada",
|
|
548
|
+
"en-US": "Custom font",
|
|
549
|
+
"es-ES": "Fuente personalizada",
|
|
550
|
+
"fr-FR": "Police stylis\xE9e",
|
|
551
|
+
"de-DE": "Eigene Schriftart",
|
|
552
|
+
"it-IT": "Font personalizzato",
|
|
553
|
+
"ja-JP": "\u30AB\u30B9\u30BF\u30E0\u30D5\u30A9\u30F3\u30C8",
|
|
554
|
+
"ko-KR": "\uC0AC\uC6A9\uC790 \uC9C0\uC815 \uAE00\uAF34",
|
|
555
|
+
"zh-CN": "\u81EA\u5B9A\u4E49\u5B57\u4F53"
|
|
556
|
+
};
|
|
225
557
|
const props = defineProps({
|
|
226
558
|
label: { type: String, required: false },
|
|
227
|
-
showLabel: { type: Boolean, required: false }
|
|
559
|
+
showLabel: { type: Boolean, required: false },
|
|
560
|
+
hideConsent: { type: Boolean, required: false }
|
|
228
561
|
});
|
|
229
|
-
const
|
|
562
|
+
const emit = defineEmits(["consent-needed"]);
|
|
563
|
+
const { theme, themes, mode, modes, locale, persistence, scrollbar, cursor, font } = useVenixTheme();
|
|
230
564
|
const resolvedLabel = computed(() => props.label ?? locale.translate(LABEL_TRANSLATIONS, "Website color"));
|
|
231
565
|
const modeHeading = computed(() => locale.translate(MODE_HEADING_TRANSLATIONS, "Mode"));
|
|
232
566
|
const themeHeading = computed(() => locale.translate(THEME_HEADING_TRANSLATIONS, "Theme"));
|
|
@@ -235,12 +569,161 @@ const themeSections = computed(() => [
|
|
|
235
569
|
{ key: "custom", heading: locale.translate(CUSTOM_HEADING_TRANSLATIONS, "Custom theme"), items: themes.value.filter((item) => item.custom) }
|
|
236
570
|
].filter((section) => section.items.length > 0));
|
|
237
571
|
const triggerLabel = computed(() => [theme.data.value?.name, mode.data.value?.name].filter(Boolean).join(" \xB7 "));
|
|
572
|
+
const today = ref(null);
|
|
573
|
+
const seasonLabels = computed(() => {
|
|
574
|
+
if (!today.value) return {};
|
|
575
|
+
const now = today.value;
|
|
576
|
+
let format;
|
|
577
|
+
try {
|
|
578
|
+
format = new Intl.DateTimeFormat(locale.current.value, { day: "2-digit", month: "2-digit" });
|
|
579
|
+
} catch {
|
|
580
|
+
format = new Intl.DateTimeFormat(void 0, { day: "2-digit", month: "2-digit" });
|
|
581
|
+
}
|
|
582
|
+
const template = locale.translate(SEASON_RANGE_TRANSLATIONS, "{start} \u2013 {end}");
|
|
583
|
+
const labels = {};
|
|
584
|
+
for (const item of themes.value) {
|
|
585
|
+
const group = theme.colors.groups[item.value];
|
|
586
|
+
const dates = group && getSeasonDates(group, now);
|
|
587
|
+
if (dates) labels[item.value] = template.replace("{start}", format.format(dates.start)).replace("{end}", format.format(dates.end));
|
|
588
|
+
}
|
|
589
|
+
return labels;
|
|
590
|
+
});
|
|
591
|
+
const settingsHeading = computed(() => locale.translate(SETTINGS_HEADING_TRANSLATIONS, "Settings"));
|
|
592
|
+
const backLabel = computed(() => locale.translate(BACK_TRANSLATIONS, "Back"));
|
|
593
|
+
const iconFormat = useRuntimeConfig().public.venixTheme?.iconFormat ?? "svg";
|
|
594
|
+
const icons = {
|
|
595
|
+
settings: resolveThemeIcon(SWITCHER_ICONS.settings, iconFormat),
|
|
596
|
+
back: resolveThemeIcon(SWITCHER_ICONS.back, iconFormat)
|
|
597
|
+
};
|
|
598
|
+
const promptTitle = computed(() => locale.translate(PROMPT_TITLE_TRANSLATIONS, "Remember your choices?"));
|
|
599
|
+
const promptDescription = computed(() => locale.translate(PROMPT_DESCRIPTION_TRANSLATIONS, "Uses cookies"));
|
|
600
|
+
const promptSaveLabel = computed(() => locale.translate(PROMPT_SAVE_TRANSLATIONS, "Save"));
|
|
601
|
+
const promptDismissLabel = computed(() => locale.translate(PROMPT_DISMISS_TRANSLATIONS, "Not now"));
|
|
602
|
+
const promptSavedLabel = computed(() => locale.translate(PROMPT_SAVED_TRANSLATIONS, "Choices saved"));
|
|
603
|
+
const promptTextId = useId();
|
|
604
|
+
const needsConsent = computed(() => persistence.required && !persistence.hasConsent.value);
|
|
605
|
+
const unsavedChange = ref(false);
|
|
606
|
+
const promptDismissed = ref(false);
|
|
607
|
+
const justSaved = ref(false);
|
|
608
|
+
let justSavedTimer;
|
|
609
|
+
let consentNeededEmitted = false;
|
|
610
|
+
const showSavePrompt = computed(
|
|
611
|
+
() => needsConsent.value && unsavedChange.value && !promptDismissed.value && !props.hideConsent && view.value === "main"
|
|
612
|
+
);
|
|
613
|
+
const markChanged = () => {
|
|
614
|
+
if (!needsConsent.value) return;
|
|
615
|
+
unsavedChange.value = true;
|
|
616
|
+
if (!consentNeededEmitted) {
|
|
617
|
+
consentNeededEmitted = true;
|
|
618
|
+
emit("consent-needed");
|
|
619
|
+
}
|
|
620
|
+
};
|
|
621
|
+
watch(() => persistence.hasConsent.value, (granted, wasGranted) => {
|
|
622
|
+
if (wasGranted && !granted) promptDismissed.value = true;
|
|
623
|
+
});
|
|
624
|
+
const focusSelected = async () => {
|
|
625
|
+
menuRef.value?.focus();
|
|
626
|
+
await nextTick();
|
|
627
|
+
const items = getMenuItems();
|
|
628
|
+
(items.find((el) => el.getAttribute("aria-checked") === "true") ?? items[0])?.focus();
|
|
629
|
+
};
|
|
630
|
+
const saveFromPrompt = () => {
|
|
631
|
+
persistence.grant();
|
|
632
|
+
justSaved.value = true;
|
|
633
|
+
announcement.value = promptSavedLabel.value;
|
|
634
|
+
clearTimeout(justSavedTimer);
|
|
635
|
+
justSavedTimer = setTimeout(() => {
|
|
636
|
+
justSaved.value = false;
|
|
637
|
+
}, 1800);
|
|
638
|
+
void focusSelected();
|
|
639
|
+
};
|
|
640
|
+
const revealPrompt = () => {
|
|
641
|
+
updatePlacement();
|
|
642
|
+
const menu = menuRef.value;
|
|
643
|
+
if (!menu || menu.scrollHeight <= menu.clientHeight) return;
|
|
644
|
+
const smooth = !window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
645
|
+
menu.scrollTo({ top: menu.scrollHeight, behavior: smooth ? "smooth" : "auto" });
|
|
646
|
+
};
|
|
647
|
+
const dismissPrompt = () => {
|
|
648
|
+
promptDismissed.value = true;
|
|
649
|
+
void focusSelected();
|
|
650
|
+
};
|
|
651
|
+
const settingsOptions = computed(() => {
|
|
652
|
+
const options = [];
|
|
653
|
+
if (persistence.required && !props.hideConsent) {
|
|
654
|
+
options.push({
|
|
655
|
+
key: "save",
|
|
656
|
+
icon: resolveThemeIcon(SWITCHER_ICONS.save, iconFormat),
|
|
657
|
+
title: locale.translate(SAVE_TITLE_TRANSLATIONS, "Save changes"),
|
|
658
|
+
description: locale.translate(SAVE_DESCRIPTION_TRANSLATIONS, "Remember your choices next time you visit (uses cookies)"),
|
|
659
|
+
enabled: persistence.hasConsent.value,
|
|
660
|
+
toggle: () => persistence.hasConsent.value ? persistence.revoke() : persistence.grant()
|
|
661
|
+
});
|
|
662
|
+
}
|
|
663
|
+
if (scrollbar.available) {
|
|
664
|
+
options.push({
|
|
665
|
+
key: "scrollbar",
|
|
666
|
+
icon: resolveThemeIcon(SWITCHER_ICONS.scrollbar, iconFormat),
|
|
667
|
+
title: locale.translate(SCROLLBAR_TITLE_TRANSLATIONS, "Custom scrollbar"),
|
|
668
|
+
enabled: scrollbar.enabled.value,
|
|
669
|
+
toggle: () => scrollbar.set(!scrollbar.enabled.value)
|
|
670
|
+
});
|
|
671
|
+
}
|
|
672
|
+
if (cursor.available && hasFinePointer.value) {
|
|
673
|
+
options.push({
|
|
674
|
+
key: "cursor",
|
|
675
|
+
icon: resolveThemeIcon(SWITCHER_ICONS.cursor, iconFormat),
|
|
676
|
+
title: locale.translate(CURSOR_TITLE_TRANSLATIONS, "Custom cursor"),
|
|
677
|
+
enabled: cursor.enabled.value,
|
|
678
|
+
toggle: () => cursor.set(!cursor.enabled.value)
|
|
679
|
+
});
|
|
680
|
+
}
|
|
681
|
+
if (font.available) {
|
|
682
|
+
options.push({
|
|
683
|
+
key: "font",
|
|
684
|
+
icon: resolveThemeIcon(SWITCHER_ICONS.font, iconFormat),
|
|
685
|
+
title: locale.translate(FONT_TITLE_TRANSLATIONS, "Custom font"),
|
|
686
|
+
enabled: font.enabled.value,
|
|
687
|
+
toggle: () => font.set(!font.enabled.value)
|
|
688
|
+
});
|
|
689
|
+
}
|
|
690
|
+
return options;
|
|
691
|
+
});
|
|
238
692
|
const baseTheme = getDefaultSelection(theme.colors).fallbackTheme;
|
|
239
693
|
const open = ref(false);
|
|
694
|
+
const view = ref("main");
|
|
240
695
|
const visible = ref(false);
|
|
241
696
|
const announcement = ref("");
|
|
242
697
|
const rootRef = ref(null);
|
|
243
698
|
const triggerRef = ref(null);
|
|
699
|
+
const menuRef = ref(null);
|
|
700
|
+
const placeAbove = ref(false);
|
|
701
|
+
const menuStyle = ref({});
|
|
702
|
+
const SCREEN_MARGIN = 8;
|
|
703
|
+
const MENU_GAP = 8;
|
|
704
|
+
const updatePlacement = () => {
|
|
705
|
+
const trigger = triggerRef.value;
|
|
706
|
+
const menu = menuRef.value;
|
|
707
|
+
if (!trigger || !menu) return;
|
|
708
|
+
const button = trigger.getBoundingClientRect();
|
|
709
|
+
const screenWidth = document.documentElement.clientWidth;
|
|
710
|
+
const below = window.innerHeight - button.bottom - MENU_GAP - SCREEN_MARGIN;
|
|
711
|
+
const above = button.top - MENU_GAP - SCREEN_MARGIN;
|
|
712
|
+
placeAbove.value = below < menu.scrollHeight && above > below;
|
|
713
|
+
const width = Math.min(menu.offsetWidth, screenWidth - 2 * SCREEN_MARGIN);
|
|
714
|
+
const left = button.right - width;
|
|
715
|
+
const shift = Math.min(Math.max(left, SCREEN_MARGIN), screenWidth - SCREEN_MARGIN - width) - left;
|
|
716
|
+
menuStyle.value = {
|
|
717
|
+
maxHeight: `${Math.max(placeAbove.value ? above : below, 0)}px`,
|
|
718
|
+
right: `${-shift}px`,
|
|
719
|
+
// The opening animation grows from the button, wherever it ends up
|
|
720
|
+
transformOrigin: `${Math.round(width - shift - button.width / 2)}px ${placeAbove.value ? "100%" : "0"}`
|
|
721
|
+
};
|
|
722
|
+
};
|
|
723
|
+
const handleResize = () => {
|
|
724
|
+
if (open.value) updatePlacement();
|
|
725
|
+
};
|
|
726
|
+
const hasFinePointer = ref(true);
|
|
244
727
|
const activeIcon = computed(() => {
|
|
245
728
|
const effectiveTheme = theme.preference.value === "system" ? theme.activeSeasonalTheme.value : theme.preference.value;
|
|
246
729
|
if (!effectiveTheme || effectiveTheme === baseTheme) return mode.data.value?.icon ?? null;
|
|
@@ -248,7 +731,7 @@ const activeIcon = computed(() => {
|
|
|
248
731
|
});
|
|
249
732
|
const activeIconKey = computed(() => `${theme.value.value}:${activeIcon.value?.format ?? ""}:${activeIcon.value?.value ?? ""}`);
|
|
250
733
|
const getMenuItems = () => {
|
|
251
|
-
return Array.from(rootRef.value?.querySelectorAll(".venix-theme-switcher__item") ?? []);
|
|
734
|
+
return Array.from(rootRef.value?.querySelectorAll(".venix-theme-switcher__icon-button, .venix-theme-switcher__item, .venix-theme-switcher__prompt-button") ?? []);
|
|
252
735
|
};
|
|
253
736
|
const focusItemAt = (index) => {
|
|
254
737
|
const items = getMenuItems();
|
|
@@ -258,24 +741,38 @@ const focusItemAt = (index) => {
|
|
|
258
741
|
const toggleOpen = async () => {
|
|
259
742
|
open.value = !open.value;
|
|
260
743
|
if (!open.value) return;
|
|
744
|
+
view.value = "main";
|
|
261
745
|
await nextTick();
|
|
746
|
+
updatePlacement();
|
|
262
747
|
const items = getMenuItems();
|
|
263
748
|
(items.find((el) => el.getAttribute("aria-checked") === "true") ?? items[0])?.focus();
|
|
264
749
|
};
|
|
750
|
+
const showView = async (next) => {
|
|
751
|
+
menuRef.value?.focus();
|
|
752
|
+
view.value = next;
|
|
753
|
+
await nextTick();
|
|
754
|
+
const items = getMenuItems();
|
|
755
|
+
(next === "settings" ? items[1] : items[0])?.focus();
|
|
756
|
+
};
|
|
265
757
|
const close = (options = {}) => {
|
|
266
758
|
if (!open.value) return;
|
|
267
759
|
open.value = false;
|
|
268
760
|
if (options.restoreFocus) triggerRef.value?.focus();
|
|
269
761
|
};
|
|
762
|
+
const toggleOption = (option) => {
|
|
763
|
+
option.toggle();
|
|
764
|
+
if (option.key !== "save") markChanged();
|
|
765
|
+
};
|
|
270
766
|
const selectTheme = (value) => {
|
|
271
767
|
const selected = themes.value.find((item) => item.value === value);
|
|
768
|
+
if (value !== theme.preference.value) markChanged();
|
|
272
769
|
theme.set(value);
|
|
273
770
|
const template = locale.translate(CHANGED_ANNOUNCEMENT_TRANSLATIONS, "Website color changed to {theme}");
|
|
274
771
|
announcement.value = template.replace("{theme}", selected?.name ?? value);
|
|
275
|
-
close({ restoreFocus: true });
|
|
276
772
|
};
|
|
277
773
|
const selectMode = (value) => {
|
|
278
774
|
const selected = modes.value.find((item) => item.value === value);
|
|
775
|
+
if (value !== mode.preference.value) markChanged();
|
|
279
776
|
mode.set(value);
|
|
280
777
|
const template = locale.translate(MODE_CHANGED_ANNOUNCEMENT_TRANSLATIONS, "Mode changed to {mode}");
|
|
281
778
|
announcement.value = template.replace("{mode}", selected?.name ?? value);
|
|
@@ -308,8 +805,20 @@ const handleFocusOut = (event) => {
|
|
|
308
805
|
const nextTarget = event.relatedTarget;
|
|
309
806
|
if (!nextTarget || !rootRef.value?.contains(nextTarget)) close();
|
|
310
807
|
};
|
|
311
|
-
const
|
|
312
|
-
|
|
808
|
+
const isInside = (rect, event) => event.clientX >= rect.left && event.clientX <= rect.right && event.clientY >= rect.top && event.clientY <= rect.bottom;
|
|
809
|
+
const isTransitionHitOnMenu = (event) => open.value && event.target === document.documentElement && !!menuRef.value && isInside(menuRef.value.getBoundingClientRect(), event);
|
|
810
|
+
const handleMouseDown = (event) => {
|
|
811
|
+
if (isTransitionHitOnMenu(event)) event.preventDefault();
|
|
812
|
+
};
|
|
813
|
+
const handlePointerDown = (event) => {
|
|
814
|
+
if (isTransitionHitOnMenu(event)) return;
|
|
815
|
+
if (!rootRef.value || !event.composedPath().includes(rootRef.value)) close();
|
|
816
|
+
};
|
|
817
|
+
const handleClick = (event) => {
|
|
818
|
+
if (!isTransitionHitOnMenu(event)) return;
|
|
819
|
+
const control = getMenuItems().find((el) => isInside(el.getBoundingClientRect(), event));
|
|
820
|
+
control?.focus();
|
|
821
|
+
control?.click();
|
|
313
822
|
};
|
|
314
823
|
const handleKeydown = (event) => {
|
|
315
824
|
if (event.key === "Escape") close({ restoreFocus: true });
|
|
@@ -320,15 +829,24 @@ onMounted(() => {
|
|
|
320
829
|
visible.value = true;
|
|
321
830
|
});
|
|
322
831
|
});
|
|
323
|
-
|
|
832
|
+
hasFinePointer.value = window.matchMedia("(any-pointer: fine)").matches;
|
|
833
|
+
today.value = /* @__PURE__ */ new Date();
|
|
834
|
+
document.addEventListener("pointerdown", handlePointerDown);
|
|
835
|
+
document.addEventListener("mousedown", handleMouseDown, true);
|
|
836
|
+
document.addEventListener("click", handleClick);
|
|
324
837
|
document.addEventListener("keydown", handleKeydown);
|
|
838
|
+
window.addEventListener("resize", handleResize);
|
|
325
839
|
});
|
|
326
840
|
onUnmounted(() => {
|
|
327
|
-
|
|
841
|
+
clearTimeout(justSavedTimer);
|
|
842
|
+
document.removeEventListener("pointerdown", handlePointerDown);
|
|
843
|
+
document.removeEventListener("mousedown", handleMouseDown, true);
|
|
844
|
+
document.removeEventListener("click", handleClick);
|
|
328
845
|
document.removeEventListener("keydown", handleKeydown);
|
|
846
|
+
window.removeEventListener("resize", handleResize);
|
|
329
847
|
});
|
|
330
848
|
</script>
|
|
331
849
|
|
|
332
850
|
<style>
|
|
333
|
-
.venix-theme-switcher{display:inline-block;position:relative}.venix-theme-switcher__sr-only{height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;clip:rect(0,0,0,0);border:0;white-space:nowrap}.venix-theme-switcher__trigger{align-items:center;background:transparent;border:none;border-radius:999px;color:inherit;cursor:pointer;display:inline-flex;font-size:1.25rem;gap:.5rem;line-height:1;opacity:0;padding:.5rem;transition:opacity .3s ease,background-color .2s ease}.venix-theme-switcher__trigger--visible{opacity:1}.venix-theme-switcher__trigger:focus-visible,.venix-theme-switcher__trigger:hover{background:var(--color-background3,hsla(0,0%,50%,.15))}.venix-theme-switcher__trigger-label{font-size:.875rem}.venix-theme-switcher__menu{border-radius:.75rem;margin:0;min-width:15rem;padding:.375rem;position:absolute;right:0;text-align:left;top:calc(100% + .5rem);z-index:50;--venix-switcher-bg:#1f2128;--venix-switcher-border:#3a3d46;--venix-switcher-text:#f5f5f7;--venix-switcher-text-strong:#fff;--venix-switcher-heading:rgba(245,245,247,.6);--venix-switcher-subheading:rgba(245,245,247,.45);--venix-switcher-hover:hsla(0,0%,100%,.08);--venix-switcher-active:hsla(0,0%,100%,.14);--venix-switcher-shadow:rgba(0,0,0,.25);background:var(--venix-switcher-bg);border:1px solid var(--venix-switcher-border);box-shadow:0 8px 24px var(--venix-switcher-shadow);transform-origin:top right}@supports (color:light-dark(#fff,#000)){.venix-theme-switcher__menu{--venix-switcher-bg:light-dark(#fff,#1f2128);--venix-switcher-border:light-dark(#e2e4ea,#3a3d46);--venix-switcher-text:light-dark(#1f2128,#f5f5f7);--venix-switcher-text-strong:light-dark(#000,#fff);--venix-switcher-heading:light-dark(rgba(31,33,40,.6),rgba(245,245,247,.6));--venix-switcher-subheading:light-dark(rgba(31,33,40,.5),rgba(245,245,247,.45));--venix-switcher-hover:light-dark(rgba(0,0,0,.05),hsla(0,0%,100%,.08));--venix-switcher-active:light-dark(rgba(0,0,0,.09),hsla(0,0%,100%,.14));--venix-switcher-shadow:light-dark(rgba(0,0,0,.12),rgba(0,0,0,.25))}}.venix-theme-switcher-menu-enter-active{transition:transform .22s cubic-bezier(0,0,.2,1),opacity .12s ease-out}.venix-theme-switcher-menu-leave-active{transition:opacity .2s ease-in}.venix-theme-switcher-menu-enter-from{opacity:0;transform:scale(.3)}.venix-theme-switcher-menu-leave-to{opacity:0}@media (prefers-reduced-motion:reduce){.venix-theme-switcher-menu-enter-active,.venix-theme-switcher-menu-leave-active{transition:none}}.venix-theme-switcher__heading{color:var(--venix-switcher-heading);font-size:.75rem;padding:.375rem .625rem}.venix-theme-switcher__heading,.venix-theme-switcher__subheading{font-weight:600;letter-spacing:.04em;text-align:center;text-transform:uppercase}.venix-theme-switcher__subheading{color:var(--venix-switcher-subheading);font-size:.6875rem;padding:.25rem .625rem}.venix-theme-switcher__modes{display:grid;gap:.25rem;grid-template-columns:repeat(3,1fr)}.venix-theme-switcher__separator{background:var(--venix-switcher-border);height:1px;margin:.375rem .25rem}.venix-theme-switcher__item{align-items:center;background:transparent;border:none;border-radius:.5rem;color:var(--venix-switcher-text);cursor:pointer;display:flex;font:inherit;gap:.625rem;padding:.5rem .625rem;text-align:left;width:100%}.venix-theme-switcher__item--mode{flex-direction:column;font-size:.75rem;gap:.25rem;justify-content:center;padding:.5rem .25rem;text-align:center}.venix-theme-switcher__item--mode .venix-theme-switcher__item-icon{font-size:1.125rem}.venix-theme-switcher__item:focus-visible,.venix-theme-switcher__item:hover{background:var(--venix-switcher-hover)}.venix-theme-switcher__item--active{background:var(--venix-switcher-active);color:var(--venix-switcher-text-strong);font-weight:600}.venix-theme-switcher__item-icon{flex-shrink:0}
|
|
851
|
+
.venix-theme-switcher{display:inline-block;position:relative}.venix-theme-switcher,.venix-theme-switcher *,.venix-theme-switcher :after,.venix-theme-switcher :before{box-sizing:border-box}.venix-theme-switcher__sr-only{height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;clip:rect(0,0,0,0);border:0;white-space:nowrap}.venix-theme-switcher__trigger{align-items:center;background:transparent;border:none;border-radius:999px;color:inherit;cursor:pointer;display:inline-flex;font-size:1.25rem;gap:.5rem;line-height:1;opacity:0;padding:.5rem;transition:opacity .3s ease,background-color .2s ease}.venix-theme-switcher__trigger--visible{opacity:1}.venix-theme-switcher__trigger:focus-visible{background:var(--jade-bg-hover,var(--color-background3,hsla(0,0%,50%,.15)))}@media (hover:hover){.venix-theme-switcher__trigger:hover{background:var(--jade-bg-hover,var(--color-background3,hsla(0,0%,50%,.15)))}}.venix-theme-switcher__trigger-label{font-size:.875rem}.venix-theme-switcher__menu{border-radius:.75rem;margin:0;max-width:calc(100vw - 1rem);min-width:min(16rem,calc(100vw - 1rem));overflow-x:hidden;overflow-y:auto;overscroll-behavior:contain;padding:.375rem;position:absolute;right:0;scrollbar-color:var(--venix-switcher-border) transparent;scrollbar-width:thin;text-align:left;top:calc(100% + .5rem);z-index:50;--venix-switcher-bg:var(--jade-bg-subtle,#1f2128);--venix-switcher-border:var(--jade-border,#3a3d46);--venix-switcher-text:var(--jade-text-muted,rgba(245,245,247,.7));--venix-switcher-text-strong:var(--jade-text,#fff);--venix-switcher-heading:var(--jade-text,#fff);--venix-switcher-subheading:var(--jade-text,#f5f5f7);--venix-switcher-hover:var(--jade-bg-hover,hsla(0,0%,100%,.1));--venix-switcher-active:var(--jade-bg-active,hsla(0,0%,100%,.16));--venix-switcher-description:var(--jade-text-muted,rgba(245,245,247,.45));--venix-switcher-switch-off:var(--jade-border-strong,#3a3d46);--venix-switcher-knob-off:var(--jade-bg,#9a9ca5);--venix-switcher-switch-on:var(--jade-text,#f5f5f7);--venix-switcher-shadow:rgba(0,0,0,.25);--venix-switcher-icon-button:1.75rem;background:var(--venix-switcher-bg);border:1px solid var(--venix-switcher-border);box-shadow:0 8px 24px var(--venix-switcher-shadow);transform-origin:top right}.venix-theme-switcher__menu--above{bottom:calc(100% + .5rem);top:auto}.venix-theme-switcher__icon-button,.venix-theme-switcher__item,.venix-theme-switcher__prompt-button,.venix-theme-switcher__trigger{-webkit-tap-highlight-color:transparent;touch-action:manipulation}.venix-theme-switcher__menu:focus{outline:none}@supports (color:light-dark(#fff,#000)){.venix-theme-switcher__menu{--venix-switcher-bg:var(--jade-bg-subtle,light-dark(#fff,#1f2128));--venix-switcher-border:var(--jade-border,light-dark(#e2e4ea,#3a3d46));--venix-switcher-text:var(--jade-text-muted,light-dark(rgba(31,33,40,.7),rgba(245,245,247,.7)));--venix-switcher-text-strong:var(--jade-text,light-dark(#000,#fff));--venix-switcher-heading:var(--jade-text,light-dark(#000,#fff));--venix-switcher-subheading:var(--jade-text,light-dark(#1f2128,#f5f5f7));--venix-switcher-hover:var(--jade-bg-hover,light-dark(rgba(0,0,0,.06),hsla(0,0%,100%,.1)));--venix-switcher-active:var(--jade-bg-active,light-dark(rgba(0,0,0,.1),hsla(0,0%,100%,.16)));--venix-switcher-description:var(--jade-text-muted,light-dark(rgba(31,33,40,.5),rgba(245,245,247,.45)));--venix-switcher-switch-off:var(--jade-border-strong,light-dark(#d5d7de,#3a3d46));--venix-switcher-knob-off:var(--jade-bg,light-dark(#fff,#9a9ca5));--venix-switcher-switch-on:var(--jade-text,light-dark(#1f2128,#f5f5f7));--venix-switcher-shadow:light-dark(rgba(0,0,0,.12),rgba(0,0,0,.25))}}.venix-theme-switcher-menu-enter-active{transition:transform .22s cubic-bezier(0,0,.2,1),opacity .12s ease-out}.venix-theme-switcher-menu-leave-active{transition:opacity .2s ease-in}.venix-theme-switcher-menu-enter-from{opacity:0;transform:scale(.3)}.venix-theme-switcher-menu-leave-to{opacity:0}.venix-theme-switcher__view{animation:venix-theme-switcher-view-in .18s cubic-bezier(0,0,.2,1);--venix-switcher-view-from:-0.5rem}.venix-theme-switcher__view--settings{--venix-switcher-view-from:0.5rem}@keyframes venix-theme-switcher-view-in{0%{opacity:0;transform:translateX(var(--venix-switcher-view-from))}}@media (prefers-reduced-motion:reduce){.venix-theme-switcher-menu-enter-active,.venix-theme-switcher-menu-leave-active{transition:none}.venix-theme-switcher__view{animation:none}}.venix-theme-switcher__header{align-items:center;display:grid;gap:.25rem;grid-template-columns:var(--venix-switcher-icon-button) 1fr var(--venix-switcher-icon-button)}.venix-theme-switcher__header .venix-theme-switcher__heading{grid-column:2;grid-row:1}.venix-theme-switcher__heading+.venix-theme-switcher__icon-button{grid-column:3}.venix-theme-switcher__icon-button{align-items:center;background:transparent;border:none;border-radius:.5rem;color:var(--venix-switcher-text);cursor:pointer;display:flex;font-size:1rem;height:var(--venix-switcher-icon-button);justify-content:center;padding:0;transition:background-color .15s ease,color .15s ease;width:var(--venix-switcher-icon-button)}.venix-theme-switcher__icon-button:focus-visible{background:var(--venix-switcher-hover);color:var(--venix-switcher-text-strong)}@media (hover:hover){.venix-theme-switcher__icon-button:hover{background:var(--venix-switcher-hover);color:var(--venix-switcher-text-strong)}}.venix-theme-switcher__heading{color:var(--venix-switcher-heading);font-size:.75rem;padding:.375rem .625rem}.venix-theme-switcher__heading,.venix-theme-switcher__subheading{font-weight:600;letter-spacing:.04em;text-align:center;text-transform:uppercase}.venix-theme-switcher__subheading{color:var(--venix-switcher-subheading);font-size:.6875rem;padding:.25rem .625rem}.venix-theme-switcher__modes{display:grid;gap:.25rem;grid-template-columns:repeat(3,1fr)}.venix-theme-switcher__separator{background:var(--venix-switcher-border);height:1px;margin:.375rem .25rem}.venix-theme-switcher__item{align-items:center;background:transparent;border:none;border-radius:.5rem;color:var(--venix-switcher-text);cursor:pointer;display:flex;font:inherit;gap:.625rem;padding:.5rem .625rem;text-align:left;transition:background-color .15s ease,color .15s ease;width:100%}.venix-theme-switcher__item--mode{flex-direction:column;font-size:.75rem;gap:.25rem;justify-content:center;padding:.5rem .25rem;text-align:center}.venix-theme-switcher__item--mode .venix-theme-switcher__item-icon{font-size:1.125rem}.venix-theme-switcher__item:focus-visible{background:var(--venix-switcher-hover);color:var(--venix-switcher-text-strong)}@media (hover:hover){.venix-theme-switcher__item:hover{background:var(--venix-switcher-hover);color:var(--venix-switcher-text-strong)}}@media (pointer:coarse){.venix-theme-switcher__menu{--venix-switcher-icon-button:2.5rem}.venix-theme-switcher__item{padding-block:.625rem}}.venix-theme-switcher__item--active{background:var(--venix-switcher-active);color:var(--venix-switcher-text-strong);font-weight:600}.venix-theme-switcher__item-icon{flex-shrink:0}.venix-theme-switcher__item-season{color:var(--venix-switcher-description);font-size:.6875rem;font-variant-numeric:tabular-nums;font-weight:400;margin-left:auto;opacity:.6;padding-left:.5rem;white-space:nowrap}.venix-theme-switcher__item--on{color:var(--venix-switcher-text-strong)}.venix-theme-switcher__item-text{display:flex;flex:1;flex-direction:column;gap:.125rem;min-width:0}.venix-theme-switcher__item-title{white-space:nowrap}.venix-theme-switcher__item-description{display:-webkit-box;overflow:hidden;-webkit-box-orient:vertical;color:var(--venix-switcher-description);font-size:.6875rem;-webkit-line-clamp:2;line-clamp:2;line-height:1.3}.venix-theme-switcher__switch{background:var(--venix-switcher-switch-off);border-radius:999px;flex-shrink:0;height:1rem;position:relative;transition:background-color .15s ease;width:1.75rem}.venix-theme-switcher__switch:after{background:var(--venix-switcher-knob-off);border-radius:50%;content:"";height:.75rem;left:.125rem;position:absolute;top:.125rem;transition:transform .15s ease,background-color .15s ease;width:.75rem}.venix-theme-switcher__item--on .venix-theme-switcher__switch{background:var(--venix-switcher-switch-on)}.venix-theme-switcher__item--on .venix-theme-switcher__switch:after{background:var(--venix-switcher-bg);transform:translateX(.75rem)}.venix-theme-switcher__prompt{display:grid;grid-template-rows:1fr}.venix-theme-switcher__prompt-inner{min-height:0;overflow:hidden}.venix-theme-switcher-prompt-enter-active,.venix-theme-switcher-prompt-leave-active{transition:grid-template-rows .22s cubic-bezier(0,0,.2,1),opacity .18s ease}.venix-theme-switcher-prompt-enter-from,.venix-theme-switcher-prompt-leave-to{grid-template-rows:0fr;opacity:0}.venix-theme-switcher__prompt-row{align-items:center;color:var(--venix-switcher-text-strong);display:flex;font-size:.75rem;gap:.5rem;line-height:1.25;padding:.25rem .25rem .125rem .625rem}.venix-theme-switcher__prompt-row--saved{animation:venix-theme-switcher-view-in .18s cubic-bezier(0,0,.2,1);justify-content:center;min-height:2rem;padding-inline:.625rem;--venix-switcher-view-from:0}.venix-theme-switcher__prompt-title{font-weight:600}.venix-theme-switcher__prompt-button{align-items:center;border:none;border-radius:.5rem;cursor:pointer;display:flex;flex-shrink:0;font:inherit;font-size:.75rem;font-weight:600;height:var(--venix-switcher-icon-button);justify-content:center;line-height:1;padding:0 .625rem;transition:background-color .15s ease,color .15s ease,opacity .15s ease}.venix-theme-switcher__prompt-button--save{background:var(--venix-switcher-switch-on);color:var(--venix-switcher-bg)}.venix-theme-switcher__prompt-button--dismiss{background:transparent;color:var(--venix-switcher-text);font-size:1.125rem;font-weight:400;padding:0;width:var(--venix-switcher-icon-button)}.venix-theme-switcher__prompt-button--save:focus-visible{outline:2px solid var(--venix-switcher-switch-on);outline-offset:2px}.venix-theme-switcher__prompt-button--dismiss:focus-visible{background:var(--venix-switcher-hover);color:var(--venix-switcher-text-strong)}@media (hover:hover){.venix-theme-switcher__prompt-button--save:hover{opacity:.85}.venix-theme-switcher__prompt-button--dismiss:hover{background:var(--venix-switcher-hover);color:var(--venix-switcher-text-strong)}}@media (prefers-reduced-motion:reduce){.venix-theme-switcher-prompt-enter-active,.venix-theme-switcher-prompt-leave-active{transition:none}.venix-theme-switcher__prompt-row--saved{animation:none}}.venix-theme-switcher__credit{color:var(--venix-switcher-description);display:block;font-size:.625rem;line-height:1.2;margin-top:.25rem;opacity:.6;padding:.125rem .25rem;text-align:center;text-decoration:none;transition:opacity .15s ease}.venix-theme-switcher__credit:focus-visible,.venix-theme-switcher__credit:hover{opacity:1;text-decoration:underline}@media (prefers-reduced-motion:reduce){.venix-theme-switcher__switch,.venix-theme-switcher__switch:after{transition:none}}
|
|
334
852
|
</style>
|