@venix-sistemas/jade 1.1.0 → 1.2.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 +339 -222
- package/dist/module.json +1 -1
- package/dist/module.mjs +25 -11
- package/dist/runtime/components/VenixThemeSwitcher.d.vue.ts +1 -1
- package/dist/runtime/components/VenixThemeSwitcher.vue +242 -99
- package/dist/runtime/components/VenixThemeSwitcher.vue.d.ts +1 -1
- package/dist/runtime/composables/useThemeColors.d.ts +6 -0
- package/dist/runtime/composables/useThemeColors.js +24 -9
- package/dist/runtime/composables/useThemeCookies.d.ts +9 -2
- package/dist/runtime/composables/useThemeCookies.js +24 -6
- package/dist/runtime/composables/useThemeLocale.d.ts +5 -0
- package/dist/runtime/composables/useThemeLocale.js +2 -2
- package/dist/runtime/composables/useThemeSeasonal.d.ts +2 -2
- package/dist/runtime/composables/useThemeSeasonal.js +1 -1
- package/dist/runtime/composables/useVenixTheme.d.ts +20 -0
- package/dist/runtime/composables/useVenixTheme.js +168 -108
- package/dist/runtime/nitro/theme-init.js +8 -5
- package/dist/runtime/plugins/theme-init.server.js +7 -12
- package/dist/runtime/plugins/vuetify-theme.js +8 -11
- package/dist/runtime/scripts/theme-init.d.ts +23 -10
- package/dist/runtime/scripts/theme-init.js +42 -88
- package/dist/shared/constants.d.ts +18 -3
- package/dist/shared/constants.js +6 -1
- package/dist/shared/css/cursor.js +9 -2
- package/dist/shared/css/index.d.ts +1 -7
- package/dist/shared/css/index.js +5 -5
- package/dist/shared/css/transition.d.ts +1 -1
- package/dist/shared/theme.json +302 -192
- package/dist/shared/types/color-options.d.ts +26 -2
- package/dist/shared/types/colors.d.ts +64 -12
- package/dist/shared/types/index.d.ts +1 -1
- package/dist/shared/types/runtime-config.d.ts +4 -2
- package/dist/shared/utils/icon-refs.d.ts +7 -3
- package/dist/shared/utils/icon.d.ts +4 -2
- package/dist/shared/utils/icon.js +6 -2
- package/dist/shared/utils/index.d.ts +5 -4
- package/dist/shared/utils/index.js +12 -6
- package/dist/shared/utils/inline-script.d.ts +6 -0
- package/dist/shared/utils/inline-script.js +3 -0
- package/dist/shared/utils/load.d.ts +0 -1
- package/dist/shared/utils/load.js +5 -12
- package/dist/shared/utils/merge-themes.d.ts +39 -9
- package/dist/shared/utils/merge-themes.js +101 -5
- package/dist/shared/utils/normalize.d.ts +0 -11
- package/dist/shared/utils/normalize.js +0 -12
- package/dist/shared/utils/theme-config.d.ts +13 -4
- package/dist/shared/utils/theme-config.js +28 -15
- package/dist/shared/utils/theme-resolve.d.ts +15 -23
- package/dist/shared/utils/theme-resolve.js +18 -67
- package/dist/shared/utils/theme-resolver.d.ts +46 -0
- package/dist/shared/utils/theme-resolver.js +139 -0
- package/package.json +13 -10
- package/README-default.md +0 -84
- package/dist/runtime/plugin.d.ts +0 -2
- package/dist/runtime/plugin.js +0 -3
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { addComponent, addPlugin, addServerPlugin, addTemplate, installModule, addImports, defineNuxtModule, createResolver } from '@nuxt/kit';
|
|
1
|
+
import { addComponent, addPlugin, addServerPlugin, addTemplate, installModule, addImports, defineNuxtModule, createResolver, useLogger } from '@nuxt/kit';
|
|
2
2
|
import { loadTheme } from '../dist/shared/utils/load.js';
|
|
3
3
|
import { DEFAULT_THEME, DEFAULT_LOCALE_COOKIE_NAME, DEFAULT_LOCALE } from '../dist/shared/constants.js';
|
|
4
4
|
import { resolveFeatureOption } from '../dist/shared/utils/options.js';
|
|
5
|
-
import {
|
|
5
|
+
import { findDeprecatedThemeEntries } from '../dist/shared/utils/merge-themes.js';
|
|
6
|
+
import { buildResolvedTheme, getBaseThemeEntries } from '../dist/shared/utils/theme-config.js';
|
|
6
7
|
import { processTheme } from '../dist/shared/css/index.js';
|
|
7
8
|
import { isColorTheme, getThemeHexColors } from '../dist/shared/utils/theme-resolve.js';
|
|
8
9
|
import { createRequire } from 'node:module';
|
|
@@ -24,10 +25,12 @@ function customizeTheme(baseTheme, options) {
|
|
|
24
25
|
if (colorOption.enabled === false) {
|
|
25
26
|
customized.colors.enabled = false;
|
|
26
27
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
const resolved = buildResolvedTheme({
|
|
29
|
+
defaultTheme: colorOption.defaultColor || customized.colors.defaultColor,
|
|
30
|
+
colorThemes: colorOption.themes,
|
|
31
|
+
seasonal: colorOption.seasonal
|
|
32
|
+
});
|
|
33
|
+
customized.colors = { ...resolved.colors, enabled: customized.colors.enabled };
|
|
31
34
|
}
|
|
32
35
|
return customized;
|
|
33
36
|
}
|
|
@@ -37,7 +40,10 @@ function registerPublicAssets(nuxt, resolver) {
|
|
|
37
40
|
nuxt.options.nitro.publicAssets = nuxt.options.nitro.publicAssets || [];
|
|
38
41
|
nuxt.options.nitro.publicAssets.push({
|
|
39
42
|
dir: resolver.resolve("./runtime/public"),
|
|
40
|
-
|
|
43
|
+
// A week, not a year: these files (cursor images, fonts) keep the same
|
|
44
|
+
// URL across releases (no content hash), so a long cache would keep
|
|
45
|
+
// serving the old file for months after an update.
|
|
46
|
+
maxAge: 60 * 60 * 24 * 7,
|
|
41
47
|
baseURL: "/"
|
|
42
48
|
});
|
|
43
49
|
}
|
|
@@ -57,7 +63,6 @@ function registerThemePlugins(_nuxt, resolver, shouldApplyColors) {
|
|
|
57
63
|
});
|
|
58
64
|
addServerPlugin(resolver.resolve("./runtime/nitro/theme-init"));
|
|
59
65
|
}
|
|
60
|
-
addPlugin(resolver.resolve("./runtime/plugin"));
|
|
61
66
|
}
|
|
62
67
|
|
|
63
68
|
function registerThemeCSS(nuxt, theme) {
|
|
@@ -132,7 +137,8 @@ async function registerThemeIcon(nuxt, resolver, options, colors) {
|
|
|
132
137
|
}
|
|
133
138
|
const explicit = new Set(options.collections);
|
|
134
139
|
const collections = options.collections.map((name) => loadFullCollection(name, projectRequire));
|
|
135
|
-
const
|
|
140
|
+
const labelled = [...Object.values(colors.groups ?? {}), ...Object.values(colors.modes ?? {})];
|
|
141
|
+
const refs = extractIconRefs(labelled, options.aliases);
|
|
136
142
|
for (const [name, iconNames] of refs) {
|
|
137
143
|
if (explicit.has(name)) continue;
|
|
138
144
|
collections.push(loadCollectionSubset(name, iconNames, projectRequire) ?? name);
|
|
@@ -182,8 +188,13 @@ const module$1 = defineNuxtModule({
|
|
|
182
188
|
apply: true,
|
|
183
189
|
defaultColor: theme.colors?.defaultColor || DEFAULT_THEME,
|
|
184
190
|
themes: {},
|
|
185
|
-
iconFormat: "svg"
|
|
191
|
+
iconFormat: "svg",
|
|
192
|
+
requireConsent: true,
|
|
193
|
+
seasonal: true
|
|
186
194
|
});
|
|
195
|
+
for (const message of findDeprecatedThemeEntries(getBaseThemeEntries(), colorOptions.themes)) {
|
|
196
|
+
useLogger("jade").warn(message);
|
|
197
|
+
}
|
|
187
198
|
const shouldApplyColors = colorOptions.enabled && colorOptions.apply && theme.colors?.defaults !== false;
|
|
188
199
|
const translationOptions = resolveFeatureOption(options.translation, {
|
|
189
200
|
enabled: true,
|
|
@@ -211,7 +222,10 @@ const module$1 = defineNuxtModule({
|
|
|
211
222
|
localeCookie: translationOptions.cookieSync,
|
|
212
223
|
defaultLocale: translationOptions.defaultLocale,
|
|
213
224
|
locale: translationOptions.locale,
|
|
214
|
-
|
|
225
|
+
// Without the icon module, @nuxt/icon isn't installed — only emoji can render
|
|
226
|
+
iconFormat: iconOptions.enabled ? colorOptions.iconFormat : "emote",
|
|
227
|
+
requireConsent: colorOptions.requireConsent,
|
|
228
|
+
seasonal: colorOptions.seasonal,
|
|
215
229
|
icon: {
|
|
216
230
|
aliases: iconOptions.aliases
|
|
217
231
|
},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
type __VLS_Props = {
|
|
2
2
|
/** Accessible label for the button and the menu. Without a value, uses the component's own translation based on the current locale. */
|
|
3
3
|
label?: string;
|
|
4
|
-
/** Shows the active theme's
|
|
4
|
+
/** Shows the active theme's and mode's names next to the icon on the button. */
|
|
5
5
|
showLabel?: boolean;
|
|
6
6
|
};
|
|
7
7
|
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
@@ -1,115 +1,251 @@
|
|
|
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
|
-
<
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
>
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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
|
-
|
|
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
|
+
class="venix-theme-switcher__menu"
|
|
48
|
+
role="menu"
|
|
49
|
+
:aria-label="resolvedLabel"
|
|
50
|
+
@keydown="handleMenuKeydown"
|
|
51
|
+
>
|
|
52
|
+
<div
|
|
53
|
+
class="venix-theme-switcher__heading"
|
|
54
|
+
aria-hidden="true"
|
|
55
|
+
>
|
|
56
|
+
{{ resolvedLabel }}
|
|
57
|
+
</div>
|
|
58
|
+
|
|
59
|
+
<div
|
|
60
|
+
class="venix-theme-switcher__separator"
|
|
61
|
+
role="separator"
|
|
62
|
+
/>
|
|
63
|
+
|
|
64
|
+
<div
|
|
65
|
+
class="venix-theme-switcher__group"
|
|
66
|
+
role="group"
|
|
67
|
+
:aria-label="modeHeading"
|
|
68
|
+
>
|
|
69
|
+
<div
|
|
70
|
+
class="venix-theme-switcher__subheading"
|
|
71
|
+
aria-hidden="true"
|
|
72
|
+
>
|
|
73
|
+
{{ modeHeading }}
|
|
74
|
+
</div>
|
|
75
|
+
<div class="venix-theme-switcher__modes">
|
|
76
|
+
<button
|
|
77
|
+
v-for="item in modes"
|
|
78
|
+
:key="item.value"
|
|
79
|
+
type="button"
|
|
80
|
+
role="menuitemradio"
|
|
81
|
+
class="venix-theme-switcher__item venix-theme-switcher__item--mode"
|
|
82
|
+
:class="{ 'venix-theme-switcher__item--active': item.value === mode.preference.value }"
|
|
83
|
+
:aria-checked="item.value === mode.preference.value"
|
|
84
|
+
@click="selectMode(item.value)"
|
|
85
|
+
>
|
|
86
|
+
<span
|
|
87
|
+
v-if="item.icon?.format === 'emote'"
|
|
88
|
+
class="venix-icon venix-icon--emoji venix-theme-switcher__item-icon"
|
|
89
|
+
aria-hidden="true"
|
|
90
|
+
>{{ item.icon.value }}</span>
|
|
91
|
+
<VenixIcon
|
|
92
|
+
v-else-if="item.icon"
|
|
93
|
+
class="venix-theme-switcher__item-icon"
|
|
94
|
+
:icon="item.icon.value"
|
|
95
|
+
:mode="item.icon.format"
|
|
96
|
+
aria-hidden="true"
|
|
97
|
+
/>
|
|
98
|
+
<span>{{ item.name }}</span>
|
|
99
|
+
</button>
|
|
100
|
+
</div>
|
|
101
|
+
</div>
|
|
102
|
+
|
|
103
|
+
<template
|
|
104
|
+
v-for="section in themeSections"
|
|
105
|
+
:key="section.key"
|
|
106
|
+
>
|
|
107
|
+
<div
|
|
108
|
+
class="venix-theme-switcher__separator"
|
|
109
|
+
role="separator"
|
|
110
|
+
/>
|
|
111
|
+
|
|
112
|
+
<div
|
|
113
|
+
class="venix-theme-switcher__group"
|
|
114
|
+
role="group"
|
|
115
|
+
:aria-label="section.heading"
|
|
116
|
+
>
|
|
117
|
+
<div
|
|
118
|
+
class="venix-theme-switcher__subheading"
|
|
119
|
+
aria-hidden="true"
|
|
120
|
+
>
|
|
121
|
+
{{ section.heading }}
|
|
122
|
+
</div>
|
|
123
|
+
<button
|
|
124
|
+
v-for="item in section.items"
|
|
125
|
+
:key="item.value"
|
|
126
|
+
type="button"
|
|
127
|
+
role="menuitemradio"
|
|
128
|
+
class="venix-theme-switcher__item"
|
|
129
|
+
:class="{ 'venix-theme-switcher__item--active': item.value === theme.preference.value }"
|
|
130
|
+
:aria-checked="item.value === theme.preference.value"
|
|
131
|
+
@click="selectTheme(item.value)"
|
|
132
|
+
>
|
|
133
|
+
<span
|
|
134
|
+
v-if="item.icon?.format === 'emote'"
|
|
135
|
+
class="venix-icon venix-icon--emoji venix-theme-switcher__item-icon"
|
|
136
|
+
aria-hidden="true"
|
|
137
|
+
>{{ item.icon.value }}</span>
|
|
138
|
+
<VenixIcon
|
|
139
|
+
v-else-if="item.icon"
|
|
140
|
+
class="venix-theme-switcher__item-icon"
|
|
141
|
+
:icon="item.icon.value"
|
|
142
|
+
:mode="item.icon.format"
|
|
143
|
+
aria-hidden="true"
|
|
144
|
+
/>
|
|
145
|
+
<span>{{ item.name }}</span>
|
|
146
|
+
</button>
|
|
147
|
+
</div>
|
|
148
|
+
</template>
|
|
149
|
+
</div>
|
|
150
|
+
</Transition>
|
|
151
|
+
</div>
|
|
74
152
|
</template>
|
|
75
153
|
|
|
76
154
|
<script setup>
|
|
77
155
|
import { ref, computed, onMounted, onUnmounted, nextTick } from "vue";
|
|
78
156
|
import { useVenixTheme } from "../composables/useVenixTheme";
|
|
157
|
+
import { getDefaultSelection } from "../../shared/utils/theme-resolve";
|
|
158
|
+
import VenixIcon from "./VenixIcon.vue";
|
|
79
159
|
const LABEL_TRANSLATIONS = {
|
|
80
|
-
"pt-BR": "
|
|
81
|
-
"en-US": "
|
|
82
|
-
"es-ES": "
|
|
83
|
-
"fr-FR": "
|
|
84
|
-
"de-DE": "
|
|
85
|
-
"it-IT": "
|
|
86
|
-
"ja-JP": "\
|
|
87
|
-
"ko-KR": "\
|
|
88
|
-
"zh-CN": "\u989C\u8272
|
|
160
|
+
"pt-BR": "Cores do site",
|
|
161
|
+
"en-US": "Website color",
|
|
162
|
+
"es-ES": "Color del sitio",
|
|
163
|
+
"fr-FR": "Couleur du site",
|
|
164
|
+
"de-DE": "Website-Farbe",
|
|
165
|
+
"it-IT": "Colore del sito",
|
|
166
|
+
"ja-JP": "\u30B5\u30A4\u30C8\u306E\u8272",
|
|
167
|
+
"ko-KR": "\uC0AC\uC774\uD2B8 \uC0C9\uC0C1",
|
|
168
|
+
"zh-CN": "\u7F51\u7AD9\u989C\u8272"
|
|
89
169
|
};
|
|
90
170
|
const CHANGED_ANNOUNCEMENT_TRANSLATIONS = {
|
|
91
|
-
"pt-BR": "
|
|
92
|
-
"en-US": "
|
|
93
|
-
"es-ES": "
|
|
94
|
-
"fr-FR": "
|
|
95
|
-
"de-DE": "
|
|
96
|
-
"it-IT": "
|
|
97
|
-
"ja-JP": "\
|
|
98
|
-
"ko-KR": "\
|
|
99
|
-
"zh-CN": "\u989C\u8272\
|
|
171
|
+
"pt-BR": "Cores do site alteradas para {theme}",
|
|
172
|
+
"en-US": "Website color changed to {theme}",
|
|
173
|
+
"es-ES": "Color del sitio cambiado a {theme}",
|
|
174
|
+
"fr-FR": "Couleur du site chang\xE9e pour {theme}",
|
|
175
|
+
"de-DE": "Website-Farbe ge\xE4ndert zu {theme}",
|
|
176
|
+
"it-IT": "Colore del sito cambiato in {theme}",
|
|
177
|
+
"ja-JP": "\u30B5\u30A4\u30C8\u306E\u8272\u304C{theme}\u306B\u5909\u66F4\u3055\u308C\u307E\u3057\u305F",
|
|
178
|
+
"ko-KR": "\uC0AC\uC774\uD2B8 \uC0C9\uC0C1\uC774 {theme}(\uC73C)\uB85C \uBCC0\uACBD\uB418\uC5C8\uC2B5\uB2C8\uB2E4",
|
|
179
|
+
"zh-CN": "\u7F51\u7AD9\u989C\u8272\u5DF2\u66F4\u6539\u4E3A{theme}"
|
|
180
|
+
};
|
|
181
|
+
const MODE_HEADING_TRANSLATIONS = {
|
|
182
|
+
"pt-BR": "Modo",
|
|
183
|
+
"en-US": "Mode",
|
|
184
|
+
"es-ES": "Modo",
|
|
185
|
+
"fr-FR": "Mode",
|
|
186
|
+
"de-DE": "Modus",
|
|
187
|
+
"it-IT": "Modalit\xE0",
|
|
188
|
+
"ja-JP": "\u30E2\u30FC\u30C9",
|
|
189
|
+
"ko-KR": "\uBAA8\uB4DC",
|
|
190
|
+
"zh-CN": "\u6A21\u5F0F"
|
|
191
|
+
};
|
|
192
|
+
const THEME_HEADING_TRANSLATIONS = {
|
|
193
|
+
"pt-BR": "Tema",
|
|
194
|
+
"en-US": "Theme",
|
|
195
|
+
"es-ES": "Tema",
|
|
196
|
+
"fr-FR": "Th\xE8me",
|
|
197
|
+
"de-DE": "Thema",
|
|
198
|
+
"it-IT": "Tema",
|
|
199
|
+
"ja-JP": "\u30C6\u30FC\u30DE",
|
|
200
|
+
"ko-KR": "\uD14C\uB9C8",
|
|
201
|
+
"zh-CN": "\u4E3B\u9898"
|
|
202
|
+
};
|
|
203
|
+
const CUSTOM_HEADING_TRANSLATIONS = {
|
|
204
|
+
"pt-BR": "Tema personalizado",
|
|
205
|
+
"en-US": "Custom theme",
|
|
206
|
+
"es-ES": "Tema personalizado",
|
|
207
|
+
"fr-FR": "Th\xE8me personnalis\xE9",
|
|
208
|
+
"de-DE": "Eigenes Thema",
|
|
209
|
+
"it-IT": "Tema personalizzato",
|
|
210
|
+
"ja-JP": "\u30AB\u30B9\u30BF\u30E0\u30C6\u30FC\u30DE",
|
|
211
|
+
"ko-KR": "\uC0AC\uC6A9\uC790 \uC9C0\uC815 \uD14C\uB9C8",
|
|
212
|
+
"zh-CN": "\u81EA\u5B9A\u4E49\u4E3B\u9898"
|
|
213
|
+
};
|
|
214
|
+
const MODE_CHANGED_ANNOUNCEMENT_TRANSLATIONS = {
|
|
215
|
+
"pt-BR": "Modo alterado para {mode}",
|
|
216
|
+
"en-US": "Mode changed to {mode}",
|
|
217
|
+
"es-ES": "Modo cambiado a {mode}",
|
|
218
|
+
"fr-FR": "Mode chang\xE9 pour {mode}",
|
|
219
|
+
"de-DE": "Modus ge\xE4ndert zu {mode}",
|
|
220
|
+
"it-IT": "Modalit\xE0 cambiata in {mode}",
|
|
221
|
+
"ja-JP": "\u30E2\u30FC\u30C9\u304C{mode}\u306B\u5909\u66F4\u3055\u308C\u307E\u3057\u305F",
|
|
222
|
+
"ko-KR": "\uBAA8\uB4DC\uAC00 {mode}(\uC73C)\uB85C \uBCC0\uACBD\uB418\uC5C8\uC2B5\uB2C8\uB2E4",
|
|
223
|
+
"zh-CN": "\u6A21\u5F0F\u5DF2\u66F4\u6539\u4E3A{mode}"
|
|
100
224
|
};
|
|
101
225
|
const props = defineProps({
|
|
102
226
|
label: { type: String, required: false },
|
|
103
227
|
showLabel: { type: Boolean, required: false }
|
|
104
228
|
});
|
|
105
|
-
const { theme, themes, locale } = useVenixTheme();
|
|
106
|
-
const resolvedLabel = computed(() => props.label ?? locale.translate(LABEL_TRANSLATIONS, "
|
|
229
|
+
const { theme, themes, mode, modes, locale } = useVenixTheme();
|
|
230
|
+
const resolvedLabel = computed(() => props.label ?? locale.translate(LABEL_TRANSLATIONS, "Website color"));
|
|
231
|
+
const modeHeading = computed(() => locale.translate(MODE_HEADING_TRANSLATIONS, "Mode"));
|
|
232
|
+
const themeHeading = computed(() => locale.translate(THEME_HEADING_TRANSLATIONS, "Theme"));
|
|
233
|
+
const themeSections = computed(() => [
|
|
234
|
+
{ key: "built-in", heading: themeHeading.value, items: themes.value.filter((item) => !item.custom) },
|
|
235
|
+
{ key: "custom", heading: locale.translate(CUSTOM_HEADING_TRANSLATIONS, "Custom theme"), items: themes.value.filter((item) => item.custom) }
|
|
236
|
+
].filter((section) => section.items.length > 0));
|
|
237
|
+
const triggerLabel = computed(() => [theme.data.value?.name, mode.data.value?.name].filter(Boolean).join(" \xB7 "));
|
|
238
|
+
const baseTheme = getDefaultSelection(theme.colors).fallbackTheme;
|
|
107
239
|
const open = ref(false);
|
|
108
240
|
const visible = ref(false);
|
|
109
241
|
const announcement = ref("");
|
|
110
242
|
const rootRef = ref(null);
|
|
111
243
|
const triggerRef = ref(null);
|
|
112
|
-
const activeIcon = computed(() =>
|
|
244
|
+
const activeIcon = computed(() => {
|
|
245
|
+
const effectiveTheme = theme.preference.value === "system" ? theme.activeSeasonalTheme.value : theme.preference.value;
|
|
246
|
+
if (!effectiveTheme || effectiveTheme === baseTheme) return mode.data.value?.icon ?? null;
|
|
247
|
+
return themes.value.find((item) => item.value === effectiveTheme)?.icon ?? null;
|
|
248
|
+
});
|
|
113
249
|
const activeIconKey = computed(() => `${theme.value.value}:${activeIcon.value?.format ?? ""}:${activeIcon.value?.value ?? ""}`);
|
|
114
250
|
const getMenuItems = () => {
|
|
115
251
|
return Array.from(rootRef.value?.querySelectorAll(".venix-theme-switcher__item") ?? []);
|
|
@@ -124,30 +260,37 @@ const toggleOpen = async () => {
|
|
|
124
260
|
if (!open.value) return;
|
|
125
261
|
await nextTick();
|
|
126
262
|
const items = getMenuItems();
|
|
127
|
-
|
|
128
|
-
(items[activeIndex] ?? items[0])?.focus();
|
|
263
|
+
(items.find((el) => el.getAttribute("aria-checked") === "true") ?? items[0])?.focus();
|
|
129
264
|
};
|
|
130
265
|
const close = (options = {}) => {
|
|
131
266
|
if (!open.value) return;
|
|
132
267
|
open.value = false;
|
|
133
268
|
if (options.restoreFocus) triggerRef.value?.focus();
|
|
134
269
|
};
|
|
135
|
-
const
|
|
270
|
+
const selectTheme = (value) => {
|
|
136
271
|
const selected = themes.value.find((item) => item.value === value);
|
|
137
|
-
theme.
|
|
138
|
-
const template = locale.translate(CHANGED_ANNOUNCEMENT_TRANSLATIONS, "
|
|
272
|
+
theme.set(value);
|
|
273
|
+
const template = locale.translate(CHANGED_ANNOUNCEMENT_TRANSLATIONS, "Website color changed to {theme}");
|
|
139
274
|
announcement.value = template.replace("{theme}", selected?.name ?? value);
|
|
140
275
|
close({ restoreFocus: true });
|
|
141
276
|
};
|
|
277
|
+
const selectMode = (value) => {
|
|
278
|
+
const selected = modes.value.find((item) => item.value === value);
|
|
279
|
+
mode.set(value);
|
|
280
|
+
const template = locale.translate(MODE_CHANGED_ANNOUNCEMENT_TRANSLATIONS, "Mode changed to {mode}");
|
|
281
|
+
announcement.value = template.replace("{mode}", selected?.name ?? value);
|
|
282
|
+
};
|
|
142
283
|
const handleMenuKeydown = (event) => {
|
|
143
284
|
const items = getMenuItems();
|
|
144
285
|
const currentIndex = items.findIndex((el) => el === document.activeElement);
|
|
145
286
|
switch (event.key) {
|
|
146
287
|
case "ArrowDown":
|
|
288
|
+
case "ArrowRight":
|
|
147
289
|
event.preventDefault();
|
|
148
290
|
focusItemAt(currentIndex + 1);
|
|
149
291
|
break;
|
|
150
292
|
case "ArrowUp":
|
|
293
|
+
case "ArrowLeft":
|
|
151
294
|
event.preventDefault();
|
|
152
295
|
focusItemAt(currentIndex - 1);
|
|
153
296
|
break;
|
|
@@ -187,5 +330,5 @@ onUnmounted(() => {
|
|
|
187
330
|
</script>
|
|
188
331
|
|
|
189
332
|
<style>
|
|
190
|
-
.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{
|
|
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}
|
|
191
334
|
</style>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
type __VLS_Props = {
|
|
2
2
|
/** Accessible label for the button and the menu. Without a value, uses the component's own translation based on the current locale. */
|
|
3
3
|
label?: string;
|
|
4
|
-
/** Shows the active theme's
|
|
4
|
+
/** Shows the active theme's and mode's names next to the icon on the button. */
|
|
5
5
|
showLabel?: boolean;
|
|
6
6
|
};
|
|
7
7
|
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
@@ -5,6 +5,12 @@ export declare const useThemeColors: (theme: ThemeConfig, translate: (translatio
|
|
|
5
5
|
value: string;
|
|
6
6
|
name: string;
|
|
7
7
|
icon: import("../../shared/utils/icon.js").ResolvedThemeIcon | null;
|
|
8
|
+
custom: boolean;
|
|
9
|
+
}[]>;
|
|
10
|
+
modes: import("vue").ComputedRef<{
|
|
11
|
+
value: "light" | "dark" | "system";
|
|
12
|
+
name: string;
|
|
13
|
+
icon: import("../../shared/utils/icon.js").ResolvedThemeIcon | null;
|
|
8
14
|
}[]>;
|
|
9
15
|
themeValues: import("vue").ComputedRef<string[]>;
|
|
10
16
|
};
|
|
@@ -1,25 +1,40 @@
|
|
|
1
1
|
import { computed } from "vue";
|
|
2
|
+
import { SYSTEM_THEME } from "../../shared/constants";
|
|
2
3
|
import { resolveThemeIcon } from "../../shared/utils/icon";
|
|
4
|
+
import { isSelectableGroup } from "../../shared/utils/theme-resolve";
|
|
5
|
+
const MODE_ORDER = ["system", "dark", "light"];
|
|
3
6
|
export const useThemeColors = (theme, translate, iconFormat = "svg") => {
|
|
4
7
|
const themes = computed(() => {
|
|
5
|
-
const list = Object.entries(theme.colors.
|
|
8
|
+
const list = Object.entries(theme.colors.groups).filter(([value]) => isSelectableGroup(theme.colors, value)).map(([value, group]) => ({
|
|
6
9
|
value,
|
|
7
|
-
name: translate(
|
|
8
|
-
icon: resolveThemeIcon(
|
|
10
|
+
name: translate(group.translations, value),
|
|
11
|
+
icon: resolveThemeIcon(group.icon, iconFormat),
|
|
12
|
+
custom: group.custom === true
|
|
9
13
|
}));
|
|
10
|
-
const
|
|
11
|
-
|
|
14
|
+
const hasSeasonal = Object.values(theme.colors.groups).some((group) => group.seasonal === true);
|
|
15
|
+
const systemTheme = theme.colors.groups[SYSTEM_THEME];
|
|
16
|
+
if (systemTheme && hasSeasonal) {
|
|
12
17
|
list.unshift({
|
|
13
|
-
value:
|
|
14
|
-
name: translate(systemTheme.translations, "
|
|
15
|
-
icon: resolveThemeIcon(systemTheme.icon, iconFormat)
|
|
18
|
+
value: SYSTEM_THEME,
|
|
19
|
+
name: translate(systemTheme.translations, "Automatic"),
|
|
20
|
+
icon: resolveThemeIcon(systemTheme.icon, iconFormat),
|
|
21
|
+
custom: false
|
|
16
22
|
});
|
|
17
23
|
}
|
|
18
24
|
return list;
|
|
19
25
|
});
|
|
20
|
-
const
|
|
26
|
+
const modes = computed(() => MODE_ORDER.map((value) => {
|
|
27
|
+
const label = theme.colors.modes?.[value];
|
|
28
|
+
return {
|
|
29
|
+
value,
|
|
30
|
+
name: translate(label?.translations, value),
|
|
31
|
+
icon: resolveThemeIcon(label?.icon, iconFormat)
|
|
32
|
+
};
|
|
33
|
+
}));
|
|
34
|
+
const themeValues = computed(() => Object.keys(theme.colors.themes));
|
|
21
35
|
return {
|
|
22
36
|
themes,
|
|
37
|
+
modes,
|
|
23
38
|
themeValues
|
|
24
39
|
};
|
|
25
40
|
};
|
|
@@ -1,7 +1,14 @@
|
|
|
1
|
-
export
|
|
1
|
+
export interface UseThemeCookiesOptions {
|
|
2
|
+
localeCookieName?: string;
|
|
3
|
+
/** See `color.requireConsent` — when `false`, the theme cookies are always written. */
|
|
4
|
+
requireConsent?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare const useThemeCookies: (options?: UseThemeCookiesOptions) => {
|
|
2
7
|
preferenceCookie: import("nuxt/app").CookieRef<string>;
|
|
3
8
|
resolvedCookie: import("nuxt/app").CookieRef<string>;
|
|
9
|
+
modeCookie: import("nuxt/app").CookieRef<string>;
|
|
4
10
|
localeCookie: import("nuxt/app").CookieRef<string>;
|
|
5
|
-
|
|
11
|
+
canPersist: () => boolean;
|
|
12
|
+
persistIfConsented: (preference: string, mode: string, resolved: string) => void;
|
|
6
13
|
disablePersistence: () => void;
|
|
7
14
|
};
|