@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
package/dist/module.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
-
import { TranslationConfig, ColorOptions, ScrollbarConfig, CursorConfig, TypographyConfig, VuetifyOptions, IconOptions } from '../dist/shared/types/index.js';
|
|
2
|
+
import { TranslationConfig, ColorOptions, ScrollbarConfig, CursorConfig, TypographyConfig, VuetifyOptions, IconOptions, ExperimentalConfig } from '../dist/shared/types/index.js';
|
|
3
3
|
|
|
4
4
|
interface ModuleOptions {
|
|
5
5
|
translation?: boolean | Partial<TranslationConfig>;
|
|
@@ -19,6 +19,13 @@ interface ModuleOptions {
|
|
|
19
19
|
* or an inline SVG from a single value. Installs `@nuxt/icon` automatically.
|
|
20
20
|
*/
|
|
21
21
|
icon?: boolean | Partial<IconOptions>;
|
|
22
|
+
/**
|
|
23
|
+
* Experimental features, to try them on a project. Off by default; a
|
|
24
|
+
* build-time choice, with nothing for the visitor to switch. Today: the
|
|
25
|
+
* semantic color tokens for every theme, built-in ones included (see
|
|
26
|
+
* `ExperimentalConfig`).
|
|
27
|
+
*/
|
|
28
|
+
experimental?: boolean | Partial<ExperimentalConfig>;
|
|
22
29
|
}
|
|
23
30
|
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
24
31
|
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { addComponent, addPlugin, addServerPlugin, addTemplate, installModule, addImports, defineNuxtModule, createResolver
|
|
1
|
+
import { addComponent, addPlugin, addServerPlugin, addTemplate, useLogger, installModule, addImports, defineNuxtModule, createResolver } from '@nuxt/kit';
|
|
2
2
|
import { loadTheme } from '../dist/shared/utils/load.js';
|
|
3
|
-
import { DEFAULT_THEME, DEFAULT_LOCALE_COOKIE_NAME, DEFAULT_LOCALE } from '../dist/shared/constants.js';
|
|
3
|
+
import { SWITCHER_ICONS, 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 { findDeprecatedThemeEntries } from '../dist/shared/utils/merge-themes.js';
|
|
6
|
-
import { buildResolvedTheme, getBaseThemeEntries } from '../dist/shared/utils/theme-config.js';
|
|
7
|
-
import {
|
|
5
|
+
import { findDeprecatedThemeEntries, overridesBrandColors } from '../dist/shared/utils/merge-themes.js';
|
|
6
|
+
import { buildResolvedTheme, getBaseThemeEntries, findInvalidDefaultColor } from '../dist/shared/utils/theme-config.js';
|
|
7
|
+
import { generateTokens, findTokenOverrideIssues, findTokenContrastIssues, collectTokens } from '../dist/shared/css/tokens.js';
|
|
8
|
+
import { tokensEnabled, TOKEN_ROLES } from '../dist/shared/token-names.js';
|
|
8
9
|
import { isColorTheme, getThemeHexColors } from '../dist/shared/utils/theme-resolve.js';
|
|
10
|
+
import { processTheme } from '../dist/shared/css/index.js';
|
|
9
11
|
import { createRequire } from 'node:module';
|
|
10
12
|
import { realpathSync } from 'node:fs';
|
|
11
13
|
import { fileURLToPath } from 'node:url';
|
|
@@ -18,6 +20,14 @@ function customizeTheme(baseTheme, options) {
|
|
|
18
20
|
customized.typography = resolveFeatureOption(options.typography, customized.typography);
|
|
19
21
|
customized.customScrollbar = resolveFeatureOption(options.scrollbar, customized.customScrollbar);
|
|
20
22
|
customized.customCursor = resolveFeatureOption(options.cursor, customized.customCursor);
|
|
23
|
+
const cursorOption = typeof options.cursor === "object" && options.cursor !== null ? options.cursor : void 0;
|
|
24
|
+
if (cursorOption?.cursors) {
|
|
25
|
+
customized.customCursor.defaultCursors = cursorOption.defaultCursors ?? cursorOption.cursors;
|
|
26
|
+
}
|
|
27
|
+
delete customized.customCursor.cursors;
|
|
28
|
+
if (cursorOption?.themeCursors) {
|
|
29
|
+
customized.customCursor.themeCursors = { ...baseTheme.customCursor.themeCursors, ...cursorOption.themeCursors };
|
|
30
|
+
}
|
|
21
31
|
const colorOption = options.color;
|
|
22
32
|
if (colorOption === false) {
|
|
23
33
|
customized.colors.enabled = false;
|
|
@@ -31,6 +41,22 @@ function customizeTheme(baseTheme, options) {
|
|
|
31
41
|
seasonal: colorOption.seasonal
|
|
32
42
|
});
|
|
33
43
|
customized.colors = { ...resolved.colors, enabled: customized.colors.enabled };
|
|
44
|
+
if (colorOption.contrast !== void 0) customized.colors.contrast = colorOption.contrast;
|
|
45
|
+
}
|
|
46
|
+
const experimental = resolveFeatureOption(options.experimental, { enabled: false }).enabled;
|
|
47
|
+
if (experimental && customized.colors.enabled !== false) {
|
|
48
|
+
for (const variant of Object.values(customized.colors.themes)) {
|
|
49
|
+
if (isColorTheme(variant) && variant.tokens === void 0) variant.tokens = true;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (!experimental && customized.colors.enabled !== false) {
|
|
53
|
+
const projectThemes = typeof colorOption === "object" && colorOption !== null ? colorOption.themes ?? {} : {};
|
|
54
|
+
const defaults = [];
|
|
55
|
+
for (const [name, entry] of Object.entries(getBaseThemeEntries())) {
|
|
56
|
+
if (!tokensEnabled(entry) || projectThemes[name]?.tokens !== void 0) continue;
|
|
57
|
+
defaults.push(...Object.values(customized.colors.groups[name]?.variants ?? {}));
|
|
58
|
+
}
|
|
59
|
+
if (defaults.length) customized.colors.defaultTokens = defaults;
|
|
34
60
|
}
|
|
35
61
|
return customized;
|
|
36
62
|
}
|
|
@@ -77,6 +103,63 @@ function registerThemeCSS(nuxt, theme) {
|
|
|
77
103
|
}
|
|
78
104
|
}
|
|
79
105
|
|
|
106
|
+
const FONT_MIME_TYPES = {
|
|
107
|
+
woff2: "font/woff2",
|
|
108
|
+
woff: "font/woff",
|
|
109
|
+
truetype: "font/ttf",
|
|
110
|
+
opentype: "font/otf"
|
|
111
|
+
};
|
|
112
|
+
function getFontPreloadLinks(theme) {
|
|
113
|
+
if (theme.typography?.enabled === false) return [];
|
|
114
|
+
const links = [];
|
|
115
|
+
for (const font of theme.typography?.customFonts ?? []) {
|
|
116
|
+
if (!font.preload) continue;
|
|
117
|
+
const [format, href] = Object.entries(font.sources ?? {})[0] ?? [];
|
|
118
|
+
if (!format || !href) continue;
|
|
119
|
+
links.push({ rel: "preload", as: "font", href, type: FONT_MIME_TYPES[format] ?? `font/${format}`, crossorigin: "anonymous" });
|
|
120
|
+
}
|
|
121
|
+
return links;
|
|
122
|
+
}
|
|
123
|
+
function registerFontPreloads(nuxt, theme) {
|
|
124
|
+
const links = getFontPreloadLinks(theme);
|
|
125
|
+
if (!links.length) return;
|
|
126
|
+
nuxt.options.app.head.link = [...nuxt.options.app.head.link ?? [], ...links];
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function resolveOverlayScrollbarsCSS() {
|
|
130
|
+
try {
|
|
131
|
+
return createRequire(import.meta.url).resolve("overlayscrollbars/overlayscrollbars.css");
|
|
132
|
+
} catch {
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
function registerOverlayScrollbars(nuxt, resolver, theme, resolveCSS = resolveOverlayScrollbarsCSS) {
|
|
137
|
+
const scrollbar = theme.customScrollbar;
|
|
138
|
+
if (scrollbar?.enabled === false || scrollbar?.overlay !== true) return;
|
|
139
|
+
const css = resolveCSS();
|
|
140
|
+
if (!css) {
|
|
141
|
+
useLogger("jade").warn("`scrollbar.overlay` needs the `overlayscrollbars` package, which isn't installed: run `pnpm add overlayscrollbars` (or npm/yarn). Using the CSS-styled native scrollbar meanwhile.");
|
|
142
|
+
scrollbar.overlay = false;
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
nuxt.options.css.push(css);
|
|
146
|
+
addPlugin({ src: resolver.resolve("./runtime/plugins/overlay-scrollbars.client"), mode: "client" });
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function tokenColorsForVuetify(themeColors, level, hasBackground2) {
|
|
150
|
+
const tokens = Object.fromEntries(generateTokens(themeColors, level));
|
|
151
|
+
const colors = {};
|
|
152
|
+
for (const role of TOKEN_ROLES) {
|
|
153
|
+
const on = tokens[`on-${role}`];
|
|
154
|
+
if (on) colors[`on-${role}`] = on;
|
|
155
|
+
}
|
|
156
|
+
if (tokens["bg-subtle"] && !hasBackground2) colors.surface = tokens["bg-subtle"];
|
|
157
|
+
if (tokens.text) {
|
|
158
|
+
colors["on-background"] = tokens.text;
|
|
159
|
+
colors["on-surface"] = tokens.text;
|
|
160
|
+
}
|
|
161
|
+
return colors;
|
|
162
|
+
}
|
|
80
163
|
function buildVuetifyThemes(colors) {
|
|
81
164
|
const themes = {};
|
|
82
165
|
for (const [name, themeColors] of Object.entries(colors.themes)) {
|
|
@@ -85,6 +168,7 @@ function buildVuetifyThemes(colors) {
|
|
|
85
168
|
const vuetifyColors = Object.fromEntries(getThemeHexColors(themeColors));
|
|
86
169
|
if (themeColors.background2) vuetifyColors.surface = themeColors.background2;
|
|
87
170
|
vuetifyColors.inverse = isDark ? "#FFFFFF" : "#000000";
|
|
171
|
+
if (tokensEnabled(themeColors) && !colors.defaultTokens?.includes(name)) Object.assign(vuetifyColors, tokenColorsForVuetify(themeColors, colors.contrast || "AA", !!themeColors.background2));
|
|
88
172
|
themes[name] = { dark: isDark, colors: vuetifyColors };
|
|
89
173
|
}
|
|
90
174
|
return themes;
|
|
@@ -137,7 +221,11 @@ async function registerThemeIcon(nuxt, resolver, options, colors) {
|
|
|
137
221
|
}
|
|
138
222
|
const explicit = new Set(options.collections);
|
|
139
223
|
const collections = options.collections.map((name) => loadFullCollection(name, projectRequire));
|
|
140
|
-
const labelled = [
|
|
224
|
+
const labelled = [
|
|
225
|
+
...Object.values(colors.groups ?? {}),
|
|
226
|
+
...Object.values(colors.modes ?? {}),
|
|
227
|
+
...Object.values(SWITCHER_ICONS).map((icon) => ({ icon }))
|
|
228
|
+
];
|
|
141
229
|
const refs = extractIconRefs(labelled, options.aliases);
|
|
142
230
|
for (const [name, iconNames] of refs) {
|
|
143
231
|
if (explicit.has(name)) continue;
|
|
@@ -171,7 +259,8 @@ const module$1 = defineNuxtModule({
|
|
|
171
259
|
cursor: true,
|
|
172
260
|
typography: true,
|
|
173
261
|
vuetify: false,
|
|
174
|
-
icon: true
|
|
262
|
+
icon: true,
|
|
263
|
+
experimental: false
|
|
175
264
|
},
|
|
176
265
|
async setup(options, nuxt) {
|
|
177
266
|
const resolver = createResolver(import.meta.url);
|
|
@@ -190,11 +279,37 @@ const module$1 = defineNuxtModule({
|
|
|
190
279
|
themes: {},
|
|
191
280
|
iconFormat: "svg",
|
|
192
281
|
requireConsent: true,
|
|
193
|
-
seasonal: true
|
|
282
|
+
seasonal: true,
|
|
283
|
+
allowVenixOverride: false,
|
|
284
|
+
contrast: "AA"
|
|
194
285
|
});
|
|
195
286
|
for (const message of findDeprecatedThemeEntries(getBaseThemeEntries(), colorOptions.themes)) {
|
|
196
287
|
useLogger("jade").warn(message);
|
|
197
288
|
}
|
|
289
|
+
if (colorOptions.enabled && !colorOptions.allowVenixOverride && overridesBrandColors(getBaseThemeEntries(), colorOptions.themes)) {
|
|
290
|
+
useLogger("jade").warn("`color.themes` changes the colors of `venix`, the Venix Sistemas brand theme. For another identity, add a theme of your own (e.g. `color.themes.myBrand`) and set `color.defaultColor` to its name; Venix stays in the switcher next to it. Set `color.allowVenixOverride: true` if changing Venix is intended.");
|
|
291
|
+
}
|
|
292
|
+
if (colorOptions.enabled) {
|
|
293
|
+
const resolvedColors = buildResolvedTheme({
|
|
294
|
+
defaultTheme: colorOptions.defaultColor,
|
|
295
|
+
colorThemes: colorOptions.themes,
|
|
296
|
+
seasonal: colorOptions.seasonal
|
|
297
|
+
}).colors;
|
|
298
|
+
const defaultColorMessage = findInvalidDefaultColor(resolvedColors);
|
|
299
|
+
if (defaultColorMessage) useLogger("jade").warn(defaultColorMessage);
|
|
300
|
+
for (const message of findTokenOverrideIssues(theme.colors.themes)) {
|
|
301
|
+
useLogger("jade").warn(message);
|
|
302
|
+
}
|
|
303
|
+
if (colorOptions.contrast) {
|
|
304
|
+
const projectThemes = Object.fromEntries(Object.entries(theme.colors.themes).filter(([id]) => !theme.colors.defaultTokens?.includes(id)));
|
|
305
|
+
for (const message of findTokenContrastIssues(projectThemes, colorOptions.contrast)) {
|
|
306
|
+
useLogger("jade").warn(message);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
if (typeof options.cursor === "object" && options.cursor?.cursors) {
|
|
311
|
+
useLogger("jade").warn("`cursor.cursors` is deprecated and stops working in 2.0. Use `cursor.defaultCursors` instead.");
|
|
312
|
+
}
|
|
198
313
|
const shouldApplyColors = colorOptions.enabled && colorOptions.apply && theme.colors?.defaults !== false;
|
|
199
314
|
const translationOptions = resolveFeatureOption(options.translation, {
|
|
200
315
|
enabled: true,
|
|
@@ -203,7 +318,9 @@ const module$1 = defineNuxtModule({
|
|
|
203
318
|
cookieSync: DEFAULT_LOCALE_COOKIE_NAME,
|
|
204
319
|
manageHtmlLang: false
|
|
205
320
|
});
|
|
321
|
+
registerOverlayScrollbars(nuxt, resolver, theme);
|
|
206
322
|
registerThemeCSS(nuxt, theme);
|
|
323
|
+
registerFontPreloads(nuxt, theme);
|
|
207
324
|
registerThemePlugins(nuxt, resolver, shouldApplyColors);
|
|
208
325
|
const vuetifyOptions = resolveFeatureOption(options.vuetify, {
|
|
209
326
|
enabled: true
|
|
@@ -215,7 +332,8 @@ const module$1 = defineNuxtModule({
|
|
|
215
332
|
aliases: {}
|
|
216
333
|
});
|
|
217
334
|
await registerThemeIcon(nuxt, resolver, iconOptions, theme.colors);
|
|
218
|
-
|
|
335
|
+
const tokens = colorOptions.enabled ? collectTokens(theme.colors.themes, colorOptions.contrast || "AA") : {};
|
|
336
|
+
const runtimeConfig = {
|
|
219
337
|
defaultTheme: theme.colors?.defaultColor || DEFAULT_THEME,
|
|
220
338
|
colorThemes: colorOptions.themes,
|
|
221
339
|
applyColors: shouldApplyColors,
|
|
@@ -226,11 +344,14 @@ const module$1 = defineNuxtModule({
|
|
|
226
344
|
iconFormat: iconOptions.enabled ? colorOptions.iconFormat : "emote",
|
|
227
345
|
requireConsent: colorOptions.requireConsent,
|
|
228
346
|
seasonal: colorOptions.seasonal,
|
|
347
|
+
tokens,
|
|
229
348
|
icon: {
|
|
230
349
|
aliases: iconOptions.aliases
|
|
231
350
|
},
|
|
232
351
|
enabled: {
|
|
233
352
|
typography: theme.typography?.enabled !== false,
|
|
353
|
+
// Something for the visitor to turn off (`font.available`)
|
|
354
|
+
customFont: theme.typography?.enabled !== false && !!theme.typography?.customFonts?.length,
|
|
234
355
|
scrollbar: theme.customScrollbar?.enabled !== false,
|
|
235
356
|
cursor: theme.customCursor?.enabled !== false,
|
|
236
357
|
color: colorOptions.enabled,
|
|
@@ -240,6 +361,7 @@ const module$1 = defineNuxtModule({
|
|
|
240
361
|
icon: iconOptions.enabled
|
|
241
362
|
}
|
|
242
363
|
};
|
|
364
|
+
Object.assign(nuxt.options.runtimeConfig.public, { venixTheme: runtimeConfig });
|
|
243
365
|
}
|
|
244
366
|
});
|
|
245
367
|
|
|
@@ -3,7 +3,13 @@ type __VLS_Props = {
|
|
|
3
3
|
label?: string;
|
|
4
4
|
/** Shows the active theme's and mode's names next to the icon on the button. */
|
|
5
5
|
showLabel?: boolean;
|
|
6
|
+
/** Hides "Save changes" in the settings, for a site whose own cookie banner already records consent. */
|
|
7
|
+
hideConsent?: boolean;
|
|
6
8
|
};
|
|
7
|
-
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
9
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
10
|
+
"consent-needed": () => any;
|
|
11
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
12
|
+
"onConsent-needed"?: (() => any) | undefined;
|
|
13
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
8
14
|
declare const _default: typeof __VLS_export;
|
|
9
15
|
export default _default;
|