@venix-sistemas/jade 1.3.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 -789
- package/dist/module.d.mts +8 -1
- package/dist/module.json +1 -1
- package/dist/module.mjs +66 -6
- package/dist/runtime/components/VenixThemeSwitcher.d.vue.ts +5 -1
- package/dist/runtime/components/VenixThemeSwitcher.vue +455 -280
- package/dist/runtime/components/VenixThemeSwitcher.vue.d.ts +5 -1
- package/dist/runtime/composables/useThemeCookies.d.ts +7 -7
- package/dist/runtime/composables/useVenixTheme.d.ts +12 -0
- package/dist/runtime/composables/useVenixTheme.js +68 -1
- package/dist/runtime/plugins/overlay-scrollbars.client.d.ts +1 -1
- package/dist/runtime/plugins/theme-init.server.d.ts +1 -1
- package/dist/runtime/plugins/vuetify-theme.d.ts +1 -1
- package/dist/shared/constants.d.ts +1 -1
- package/dist/shared/constants.js +3 -1
- package/dist/shared/css/colors.d.ts +2 -2
- package/dist/shared/css/colors.js +7 -2
- package/dist/shared/css/cursor.js +73 -9
- package/dist/shared/css/index.js +1 -1
- package/dist/shared/css/scrollbar.js +7 -1
- package/dist/shared/css/tokens.d.ts +40 -0
- package/dist/shared/css/tokens.js +119 -0
- package/dist/shared/theme.json +320 -308
- 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/experimental.d.ts +19 -0
- package/dist/shared/types/experimental.js +0 -0
- package/dist/shared/types/index.d.ts +3 -1
- package/dist/shared/types/runtime-config.d.ts +39 -25
- 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/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 +8 -0
- package/dist/shared/utils/theme-config.js +10 -1
- package/package.json +15 -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
|
@@ -2,11 +2,13 @@ import { addComponent, addPlugin, addServerPlugin, addTemplate, useLogger, insta
|
|
|
2
2
|
import { loadTheme } from '../dist/shared/utils/load.js';
|
|
3
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';
|
|
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';
|
|
9
|
+
import { isColorTheme, getThemeHexColors } from '../dist/shared/utils/theme-resolve.js';
|
|
7
10
|
import { processTheme } from '../dist/shared/css/index.js';
|
|
8
11
|
import { createRequire } from 'node:module';
|
|
9
|
-
import { isColorTheme, getThemeHexColors } from '../dist/shared/utils/theme-resolve.js';
|
|
10
12
|
import { realpathSync } from 'node:fs';
|
|
11
13
|
import { fileURLToPath } from 'node:url';
|
|
12
14
|
import { join } from 'node:path';
|
|
@@ -39,6 +41,22 @@ function customizeTheme(baseTheme, options) {
|
|
|
39
41
|
seasonal: colorOption.seasonal
|
|
40
42
|
});
|
|
41
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;
|
|
42
60
|
}
|
|
43
61
|
return customized;
|
|
44
62
|
}
|
|
@@ -128,6 +146,20 @@ function registerOverlayScrollbars(nuxt, resolver, theme, resolveCSS = resolveOv
|
|
|
128
146
|
addPlugin({ src: resolver.resolve("./runtime/plugins/overlay-scrollbars.client"), mode: "client" });
|
|
129
147
|
}
|
|
130
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
|
+
}
|
|
131
163
|
function buildVuetifyThemes(colors) {
|
|
132
164
|
const themes = {};
|
|
133
165
|
for (const [name, themeColors] of Object.entries(colors.themes)) {
|
|
@@ -136,6 +168,7 @@ function buildVuetifyThemes(colors) {
|
|
|
136
168
|
const vuetifyColors = Object.fromEntries(getThemeHexColors(themeColors));
|
|
137
169
|
if (themeColors.background2) vuetifyColors.surface = themeColors.background2;
|
|
138
170
|
vuetifyColors.inverse = isDark ? "#FFFFFF" : "#000000";
|
|
171
|
+
if (tokensEnabled(themeColors) && !colors.defaultTokens?.includes(name)) Object.assign(vuetifyColors, tokenColorsForVuetify(themeColors, colors.contrast || "AA", !!themeColors.background2));
|
|
139
172
|
themes[name] = { dark: isDark, colors: vuetifyColors };
|
|
140
173
|
}
|
|
141
174
|
return themes;
|
|
@@ -226,7 +259,8 @@ const module$1 = defineNuxtModule({
|
|
|
226
259
|
cursor: true,
|
|
227
260
|
typography: true,
|
|
228
261
|
vuetify: false,
|
|
229
|
-
icon: true
|
|
262
|
+
icon: true,
|
|
263
|
+
experimental: false
|
|
230
264
|
},
|
|
231
265
|
async setup(options, nuxt) {
|
|
232
266
|
const resolver = createResolver(import.meta.url);
|
|
@@ -245,11 +279,34 @@ const module$1 = defineNuxtModule({
|
|
|
245
279
|
themes: {},
|
|
246
280
|
iconFormat: "svg",
|
|
247
281
|
requireConsent: true,
|
|
248
|
-
seasonal: true
|
|
282
|
+
seasonal: true,
|
|
283
|
+
allowVenixOverride: false,
|
|
284
|
+
contrast: "AA"
|
|
249
285
|
});
|
|
250
286
|
for (const message of findDeprecatedThemeEntries(getBaseThemeEntries(), colorOptions.themes)) {
|
|
251
287
|
useLogger("jade").warn(message);
|
|
252
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
|
+
}
|
|
253
310
|
if (typeof options.cursor === "object" && options.cursor?.cursors) {
|
|
254
311
|
useLogger("jade").warn("`cursor.cursors` is deprecated and stops working in 2.0. Use `cursor.defaultCursors` instead.");
|
|
255
312
|
}
|
|
@@ -275,7 +332,8 @@ const module$1 = defineNuxtModule({
|
|
|
275
332
|
aliases: {}
|
|
276
333
|
});
|
|
277
334
|
await registerThemeIcon(nuxt, resolver, iconOptions, theme.colors);
|
|
278
|
-
|
|
335
|
+
const tokens = colorOptions.enabled ? collectTokens(theme.colors.themes, colorOptions.contrast || "AA") : {};
|
|
336
|
+
const runtimeConfig = {
|
|
279
337
|
defaultTheme: theme.colors?.defaultColor || DEFAULT_THEME,
|
|
280
338
|
colorThemes: colorOptions.themes,
|
|
281
339
|
applyColors: shouldApplyColors,
|
|
@@ -286,6 +344,7 @@ const module$1 = defineNuxtModule({
|
|
|
286
344
|
iconFormat: iconOptions.enabled ? colorOptions.iconFormat : "emote",
|
|
287
345
|
requireConsent: colorOptions.requireConsent,
|
|
288
346
|
seasonal: colorOptions.seasonal,
|
|
347
|
+
tokens,
|
|
289
348
|
icon: {
|
|
290
349
|
aliases: iconOptions.aliases
|
|
291
350
|
},
|
|
@@ -302,6 +361,7 @@ const module$1 = defineNuxtModule({
|
|
|
302
361
|
icon: iconOptions.enabled
|
|
303
362
|
}
|
|
304
363
|
};
|
|
364
|
+
Object.assign(nuxt.options.runtimeConfig.public, { venixTheme: runtimeConfig });
|
|
305
365
|
}
|
|
306
366
|
});
|
|
307
367
|
|
|
@@ -6,6 +6,10 @@ type __VLS_Props = {
|
|
|
6
6
|
/** Hides "Save changes" in the settings, for a site whose own cookie banner already records consent. */
|
|
7
7
|
hideConsent?: boolean;
|
|
8
8
|
};
|
|
9
|
-
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>;
|
|
10
14
|
declare const _default: typeof __VLS_export;
|
|
11
15
|
export default _default;
|