@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
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Names of the semantic color tokens (v1.4.0, experimental), kept apart from
|
|
3
|
+
* the code that generates their values (`css/tokens.ts`, which pulls in the
|
|
4
|
+
* color engine) so the UnoCSS preset can list them without loading it.
|
|
5
|
+
*
|
|
6
|
+
* Name: `--jade-<property>[-<role>][-<variant>][-<state>]`, where the
|
|
7
|
+
* property says what the color is for (`bg`, `text`, `fill`, `on`, `border`).
|
|
8
|
+
*/
|
|
9
|
+
/** The roles that get their own tokens. */
|
|
10
|
+
export declare const TOKEN_ROLES: readonly ["primary", "secondary"];
|
|
11
|
+
/** Neutral tokens and the step (1–12) of the neutral scale each one uses. */
|
|
12
|
+
export declare const NEUTRAL_TOKENS: ReadonlyArray<readonly [name: string, step: number]>;
|
|
13
|
+
/** Per-role tokens and the step (1–12) of the role's scale each one uses. `on` is not a step: white or black. */
|
|
14
|
+
export declare const ROLE_TOKENS: ReadonlyArray<readonly [name: string, step: number]>;
|
|
15
|
+
/** `roleTokenName('fill-hover', 'primary')` → `'fill-primary-hover'`: the role goes after the property. */
|
|
16
|
+
export declare function roleTokenName(name: string, role: string): string;
|
|
17
|
+
/** Every token name a theme with both roles and a primary gets, in the order they are written. */
|
|
18
|
+
export declare const TOKEN_NAMES: readonly string[];
|
|
19
|
+
/** Tokens that can be overridden: every one except `on-<role>`, which is white or black, not a step. */
|
|
20
|
+
export declare const OVERRIDABLE_TOKEN_NAMES: readonly string[];
|
|
21
|
+
/** `tokens` of a theme: `true`, or an object of overrides (which also turns the tokens on). */
|
|
22
|
+
export declare function tokensEnabled(entry: {
|
|
23
|
+
tokens?: boolean | object;
|
|
24
|
+
}): boolean;
|
|
25
|
+
/** The overrides in `tokens`, or none when it's a boolean. */
|
|
26
|
+
export declare function tokenOverrides(entry: {
|
|
27
|
+
tokens?: boolean | Record<string, string>;
|
|
28
|
+
}): Record<string, string>;
|
|
29
|
+
/**
|
|
30
|
+
* A step of a generated scale: `neutral-3`, `primary-9`… (1–12). The scale
|
|
31
|
+
* is the same in light and dark (step 1 is the page, 12 the strongest text),
|
|
32
|
+
* so one reference suits both modes.
|
|
33
|
+
*/
|
|
34
|
+
export declare function parseStepRef(ref: unknown): {
|
|
35
|
+
scale: string;
|
|
36
|
+
step: number;
|
|
37
|
+
} | null;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export const TOKEN_ROLES = ["primary", "secondary"];
|
|
2
|
+
export const NEUTRAL_TOKENS = [
|
|
3
|
+
["bg", 1],
|
|
4
|
+
["bg-subtle", 2],
|
|
5
|
+
["bg-muted", 3],
|
|
6
|
+
["bg-hover", 4],
|
|
7
|
+
["bg-active", 5],
|
|
8
|
+
["border", 6],
|
|
9
|
+
["border-strong", 9],
|
|
10
|
+
["text", 12],
|
|
11
|
+
["text-muted", 11],
|
|
12
|
+
["text-disabled", 8]
|
|
13
|
+
];
|
|
14
|
+
export const ROLE_TOKENS = [
|
|
15
|
+
["fill", 9],
|
|
16
|
+
["fill-hover", 10],
|
|
17
|
+
["bg", 3],
|
|
18
|
+
["bg-hover", 4],
|
|
19
|
+
["bg-active", 5],
|
|
20
|
+
["text", 11],
|
|
21
|
+
["text-strong", 12],
|
|
22
|
+
["border", 7],
|
|
23
|
+
["border-strong", 11]
|
|
24
|
+
];
|
|
25
|
+
export function roleTokenName(name, role) {
|
|
26
|
+
const [property, ...rest] = name.split("-");
|
|
27
|
+
return [property, role, ...rest].join("-");
|
|
28
|
+
}
|
|
29
|
+
export const TOKEN_NAMES = [
|
|
30
|
+
...NEUTRAL_TOKENS.map(([name]) => name),
|
|
31
|
+
"border-focus",
|
|
32
|
+
...TOKEN_ROLES.flatMap((role) => [
|
|
33
|
+
...ROLE_TOKENS.map(([name]) => roleTokenName(name, role)),
|
|
34
|
+
`on-${role}`
|
|
35
|
+
])
|
|
36
|
+
];
|
|
37
|
+
export const OVERRIDABLE_TOKEN_NAMES = TOKEN_NAMES.filter((name) => !name.startsWith("on-"));
|
|
38
|
+
export function tokensEnabled(entry) {
|
|
39
|
+
return entry.tokens === true || typeof entry.tokens === "object" && entry.tokens !== null;
|
|
40
|
+
}
|
|
41
|
+
export function tokenOverrides(entry) {
|
|
42
|
+
return typeof entry.tokens === "object" && entry.tokens !== null ? entry.tokens : {};
|
|
43
|
+
}
|
|
44
|
+
export function parseStepRef(ref) {
|
|
45
|
+
if (typeof ref !== "string") return null;
|
|
46
|
+
const match = /^([a-z]+)-(\d{1,2})$/.exec(ref);
|
|
47
|
+
if (!match) return null;
|
|
48
|
+
const scale = match[1];
|
|
49
|
+
const step = Number(match[2]);
|
|
50
|
+
if (step < 1 || step > 12) return null;
|
|
51
|
+
if (scale !== "neutral" && !TOKEN_ROLES.includes(scale)) return null;
|
|
52
|
+
return { scale, step };
|
|
53
|
+
}
|
|
@@ -1,17 +1,24 @@
|
|
|
1
|
-
import type { ThemeEntry } from './colors.js';
|
|
1
|
+
import type { ContrastLevel, ThemeEntry } from './colors.js';
|
|
2
2
|
export interface ColorOptions {
|
|
3
3
|
enabled: boolean;
|
|
4
4
|
apply: boolean;
|
|
5
5
|
/**
|
|
6
6
|
* Initial choice for new visitors: a theme name (mode follows the OS), a
|
|
7
7
|
* variant id like `'dark'` (that theme in that mode) or `'system'` (both
|
|
8
|
-
* automatic). Default: `'dark'`.
|
|
8
|
+
* automatic). Default: `'dark'`. To start on a project's own brand, add
|
|
9
|
+
* that theme to `themes` and put its name here. A value that matches no
|
|
10
|
+
* available theme warns at build time and falls back to `'system'`.
|
|
9
11
|
*/
|
|
10
12
|
defaultColor: string;
|
|
11
13
|
/**
|
|
12
14
|
* Override or add themes. Use the grouped format
|
|
13
15
|
* (`{ translations, icon, light: {...}, dark: {...} }`); the flat format
|
|
14
16
|
* (`{ dark: true, primary, ... }`) still works but is deprecated.
|
|
17
|
+
*
|
|
18
|
+
* `venix` is the brand theme of Venix Sistemas: don't change its colors.
|
|
19
|
+
* For another identity (a client's brand, say), add a new theme here and
|
|
20
|
+
* set `defaultColor` to its name. Overriding Venix's colors logs a build
|
|
21
|
+
* warning unless `allowVenixOverride` is `true`.
|
|
15
22
|
*/
|
|
16
23
|
themes: Record<string, Partial<ThemeEntry>>;
|
|
17
24
|
/**
|
|
@@ -35,4 +42,18 @@ export interface ColorOptions {
|
|
|
35
42
|
* removed entirely: not listed in pickers and never applied by date.
|
|
36
43
|
*/
|
|
37
44
|
seasonal: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Override the colors of the `venix` theme without the build warning.
|
|
47
|
+
* Default: `false`. Venix is the Venix Sistemas brand theme, so a project
|
|
48
|
+
* with its own identity should add a theme instead (see `themes`).
|
|
49
|
+
*/
|
|
50
|
+
allowVenixOverride: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Experimental (v1.4.0). The contrast the semantic tokens (themes with
|
|
53
|
+
* `tokens: true`) aim for: `'AA'` (text 4.5:1, outlines 3:1) or `'AAA'`
|
|
54
|
+
* (text 7:1). The build warns, per theme variant, about every token pair
|
|
55
|
+
* that falls short. `false` skips the warning but still generates the
|
|
56
|
+
* tokens, as AA. Default: `'AA'`.
|
|
57
|
+
*/
|
|
58
|
+
contrast: ContrastLevel | false;
|
|
38
59
|
}
|
|
@@ -26,6 +26,8 @@ export interface ThemePalette {
|
|
|
26
26
|
background2?: string;
|
|
27
27
|
background3?: string;
|
|
28
28
|
}
|
|
29
|
+
/** Token name → step of a generated scale (`'neutral-3'`, `'primary-9'`; 1–12). */
|
|
30
|
+
export type TokenOverrides = Record<string, string>;
|
|
29
31
|
/** One light/dark variant of a theme (`ThemeDefinition.light` / `.dark`). */
|
|
30
32
|
export interface ThemeVariant extends ThemePalette {
|
|
31
33
|
/**
|
|
@@ -49,6 +51,29 @@ export interface ThemeMeta {
|
|
|
49
51
|
translations?: ThemeTranslations;
|
|
50
52
|
/** A plain emoji ('🎨') or an object with per-format variants — see `ThemeIconFormats`. */
|
|
51
53
|
icon?: string | ThemeIconFormats;
|
|
54
|
+
/**
|
|
55
|
+
* Experimental (v1.4.0). Also generates the semantic color tokens
|
|
56
|
+
* (`--jade-text-primary`, `--jade-fill-primary`, `--jade-bg-subtle`…)
|
|
57
|
+
* from the variant's `primary`, `secondary` and `background`, next to the
|
|
58
|
+
* usual `--color-*` variables, which stay unchanged. Default: `false`.
|
|
59
|
+
*
|
|
60
|
+
* An object also turns them on and re-points individual tokens at another
|
|
61
|
+
* step (1–12) of the generated scales, so a surface can be stronger or
|
|
62
|
+
* weaker without a fixed color: `{ 'bg-subtle': 'neutral-3' }`. Steps are
|
|
63
|
+
* the same in light and dark, so one entry covers both modes, and the
|
|
64
|
+
* contrast check runs on the result. `on-<role>` can't be overridden.
|
|
65
|
+
*/
|
|
66
|
+
tokens?: boolean | TokenOverrides;
|
|
67
|
+
/**
|
|
68
|
+
* Only with `tokens`. The neutral tokens (`bg`, `bg-subtle`, `text`,
|
|
69
|
+
* `border`…) lean slightly toward the hue of `primary` by default, so the
|
|
70
|
+
* theme feels of one piece; a `background` with a color of its own keeps
|
|
71
|
+
* its hue instead, and its surfaces gain more of it the farther from the
|
|
72
|
+
* page. `false` makes them plain grays, like a theme built on
|
|
73
|
+
* `background2`/`background3` greys. Contrast is the same either way.
|
|
74
|
+
* Default: `true`.
|
|
75
|
+
*/
|
|
76
|
+
neutralTint?: boolean;
|
|
52
77
|
}
|
|
53
78
|
/**
|
|
54
79
|
* A theme in the grouped format: shared metadata plus a `light` and/or a
|
|
@@ -81,9 +106,22 @@ export interface ThemeModeLabel {
|
|
|
81
106
|
translations?: ThemeTranslations;
|
|
82
107
|
icon?: string | ThemeIconFormats;
|
|
83
108
|
}
|
|
109
|
+
/** The contrast level the semantic tokens aim for: WCAG AA (4.5:1 for text) or AAA (7:1). */
|
|
110
|
+
export type ContrastLevel = 'AA' | 'AAA';
|
|
84
111
|
export interface ColorsConfig {
|
|
85
112
|
enabled: boolean;
|
|
86
113
|
defaults: boolean;
|
|
114
|
+
/** Contrast target of the semantic tokens and their build check (`color.contrast`). Build time only. */
|
|
115
|
+
contrast?: ContrastLevel | false;
|
|
116
|
+
/**
|
|
117
|
+
* The variants (ids in `themes`) whose tokens are the module's own default
|
|
118
|
+
* for its built-in themes, not something the project asked for with
|
|
119
|
+
* `tokens` or `experimental`. In 1.x Vuetify leaves their colors alone, so
|
|
120
|
+
* its text on `primary` and its surfaces don't change under existing
|
|
121
|
+
* projects, and the build doesn't warn about their contrast. Build time
|
|
122
|
+
* only. Removed in 2.0, when the tokens become the only model.
|
|
123
|
+
*/
|
|
124
|
+
defaultTokens?: string[];
|
|
87
125
|
/** Initial choice for new visitors: a theme name, a variant id (`'dark'`) or `'system'`. */
|
|
88
126
|
defaultColor: string;
|
|
89
127
|
/** Every concrete color variant, by id — what `data-theme` receives. */
|
|
@@ -1,7 +1,37 @@
|
|
|
1
|
+
/** The cursors the module replaces. */
|
|
2
|
+
export type CursorType = 'default' | 'pointer' | 'text';
|
|
3
|
+
export interface CursorImage {
|
|
4
|
+
/** Image served from `public/`. */
|
|
5
|
+
path: string;
|
|
6
|
+
/** The click point ("x y"). */
|
|
7
|
+
hotspot?: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* What a color theme shows as its cursor:
|
|
11
|
+
* - `'themed'`: drawn in the theme's `primary`
|
|
12
|
+
* - `'base'`: the `defaultCursors` images (the module's fire cursors, unless
|
|
13
|
+
* the project set its own)
|
|
14
|
+
* - `'none'`: no custom cursor, the operating system's own
|
|
15
|
+
* - an object: its own images; a cursor it leaves out is shown as if the
|
|
16
|
+
* theme had no entry
|
|
17
|
+
*/
|
|
18
|
+
export type ThemeCursor = 'themed' | 'base' | 'none' | Partial<Record<CursorType, CursorImage>>;
|
|
1
19
|
export interface CursorConfig {
|
|
2
20
|
enabled: boolean;
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Draws each cursor as an SVG in the active color theme's `primary`, so it
|
|
23
|
+
* changes along with the theme. `false` shows the `defaultCursors` in
|
|
24
|
+
* every theme without an entry in `themeCursors`. Default: `true`.
|
|
25
|
+
*/
|
|
26
|
+
themed?: boolean;
|
|
27
|
+
/** The default cursors, and the fallback of the drawn ones. */
|
|
28
|
+
defaultCursors: Record<string, CursorImage>;
|
|
29
|
+
/**
|
|
30
|
+
* Cursor per color theme, by theme name (both its variants, e.g. `venix`)
|
|
31
|
+
* or variant id (just that one, e.g. `carnaval-light`), which wins over
|
|
32
|
+
* the theme name. Merged with the module's own (`venix: 'base'`).
|
|
33
|
+
*/
|
|
34
|
+
themeCursors?: Record<string, ThemeCursor>;
|
|
35
|
+
/** @deprecated Renamed to `defaultCursors`; removed in 2.0. */
|
|
36
|
+
cursors?: Record<string, CursorImage>;
|
|
7
37
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface ExperimentalConfig {
|
|
2
|
+
/**
|
|
3
|
+
* Turns the experimental features on. Default: `false`.
|
|
4
|
+
*
|
|
5
|
+
* Today that is the semantic color tokens (`color.themes.<name>.tokens`),
|
|
6
|
+
* generated for every theme that doesn't set `tokens` itself, the built-in
|
|
7
|
+
* ones included, so a project can try them without rewriting its themes:
|
|
8
|
+
* `--jade-text-primary`, `--jade-fill-primary`, `--jade-bg-subtle`… next
|
|
9
|
+
* to the usual `--color-*` variables, which stay unchanged, plus the
|
|
10
|
+
* UnoCSS token classes and `useVenixTheme().tokens`. A theme with
|
|
11
|
+
* `tokens: false` still opts out.
|
|
12
|
+
*
|
|
13
|
+
* A build-time choice: there is no switch for the visitor. It is the same
|
|
14
|
+
* as writing `tokens: true` on every theme, so Vuetify gets the token
|
|
15
|
+
* colors too (`on-primary`, `surface`…). Names, steps and behaviour may
|
|
16
|
+
* still change before the features are declared stable.
|
|
17
|
+
*/
|
|
18
|
+
enabled: boolean;
|
|
19
|
+
}
|
|
File without changes
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import './runtime-config.js';
|
|
2
2
|
export type { FontConfig, TypographyConfig } from './typography.js';
|
|
3
3
|
export type { ScrollbarConfig } from './scrollbar.js';
|
|
4
|
-
export type { CursorConfig } from './cursor.js';
|
|
5
|
-
export type { ThemeColors, ThemeTranslations, ColorsConfig, ThemeIconFormats, ThemeMode, ThemeModePreference, ThemePalette, ThemeVariant, ThemeMeta, ThemeDefinition, ThemeEntry, ResolvedThemeGroup, ThemeModeLabel, } from './colors.js';
|
|
6
|
-
export type { ThemeConfig } from './theme.js';
|
|
4
|
+
export type { CursorConfig, CursorType, CursorImage, ThemeCursor } from './cursor.js';
|
|
5
|
+
export type { ThemeColors, ThemeTranslations, ColorsConfig, ThemeIconFormats, ThemeMode, ThemeModePreference, ThemePalette, ThemeVariant, ThemeMeta, ThemeDefinition, ThemeEntry, ResolvedThemeGroup, ThemeModeLabel, ContrastLevel, } from './colors.js';
|
|
6
|
+
export type { ThemeConfig, ResolvedTheme } from './theme.js';
|
|
7
7
|
export type { TranslationConfig } from './translation.js';
|
|
8
8
|
export type { ColorOptions } from './color-options.js';
|
|
9
9
|
export type { VuetifyOptions } from './vuetify.js';
|
|
10
10
|
export type { IconOptions } from './icon.js';
|
|
11
|
+
export type { ExperimentalConfig } from './experimental.js';
|
|
12
|
+
export type { VenixRuntimeConfig } from './runtime-config.js';
|
|
@@ -1,30 +1,45 @@
|
|
|
1
1
|
import type { ThemeEntry } from './colors.js';
|
|
2
|
+
/**
|
|
3
|
+
* What the module puts in `runtimeConfig.public.venixTheme`. Its own
|
|
4
|
+
* interface (and not only the augmentation below) so `module.ts` can check
|
|
5
|
+
* what it assigns against this shape, not against the type Nuxt infers from
|
|
6
|
+
* the app's config, which names every theme of that app.
|
|
7
|
+
*/
|
|
8
|
+
export interface VenixRuntimeConfig {
|
|
9
|
+
defaultTheme: string;
|
|
10
|
+
colorThemes: Record<string, Partial<ThemeEntry>>;
|
|
11
|
+
applyColors: boolean;
|
|
12
|
+
localeCookie: string;
|
|
13
|
+
defaultLocale: string;
|
|
14
|
+
locale: string;
|
|
15
|
+
iconFormat: 'emote' | 'css' | 'svg';
|
|
16
|
+
requireConsent: boolean;
|
|
17
|
+
seasonal: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* The semantic tokens of every theme variant with `tokens: true`, by
|
|
20
|
+
* variant id (`{ 'light': { 'text-primary': '#CF0000', ... } }`).
|
|
21
|
+
* Generated at build time; empty when no theme uses tokens (the
|
|
22
|
+
* built-in themes do, so only with `color: false` is it empty).
|
|
23
|
+
*/
|
|
24
|
+
tokens?: Record<string, Record<string, string>>;
|
|
25
|
+
icon: {
|
|
26
|
+
aliases: Record<string, string>;
|
|
27
|
+
};
|
|
28
|
+
enabled: {
|
|
29
|
+
typography: boolean;
|
|
30
|
+
customFont: boolean;
|
|
31
|
+
scrollbar: boolean;
|
|
32
|
+
cursor: boolean;
|
|
33
|
+
color: boolean;
|
|
34
|
+
translation: boolean;
|
|
35
|
+
manageHtmlLang: boolean;
|
|
36
|
+
vuetify: boolean;
|
|
37
|
+
icon: boolean;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
2
40
|
declare module '@nuxt/schema' {
|
|
3
41
|
interface PublicRuntimeConfig {
|
|
4
|
-
venixTheme?:
|
|
5
|
-
defaultTheme: string;
|
|
6
|
-
colorThemes: Record<string, Partial<ThemeEntry>>;
|
|
7
|
-
applyColors: boolean;
|
|
8
|
-
localeCookie: string;
|
|
9
|
-
defaultLocale: string;
|
|
10
|
-
locale: string;
|
|
11
|
-
iconFormat: 'emote' | 'css' | 'svg';
|
|
12
|
-
requireConsent: boolean;
|
|
13
|
-
seasonal: boolean;
|
|
14
|
-
icon: {
|
|
15
|
-
aliases: Record<string, string>;
|
|
16
|
-
};
|
|
17
|
-
enabled: {
|
|
18
|
-
typography: boolean;
|
|
19
|
-
scrollbar: boolean;
|
|
20
|
-
cursor: boolean;
|
|
21
|
-
color: boolean;
|
|
22
|
-
translation: boolean;
|
|
23
|
-
manageHtmlLang: boolean;
|
|
24
|
-
vuetify: boolean;
|
|
25
|
-
icon: boolean;
|
|
26
|
-
};
|
|
27
|
-
};
|
|
42
|
+
venixTheme?: VenixRuntimeConfig;
|
|
28
43
|
}
|
|
29
44
|
}
|
|
30
45
|
declare global {
|
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
export interface ScrollbarConfig {
|
|
2
2
|
enabled: boolean;
|
|
3
|
+
/**
|
|
4
|
+
* Draws the scrollbars with OverlayScrollbars, as page elements: the
|
|
5
|
+
* browser's own scrollbar ignores CSS `cursor`, so hovering it shows the
|
|
6
|
+
* system cursor instead of the custom one. Covers the page, Vuetify's scroll
|
|
7
|
+
* containers and any element with `data-venix-scroll`; other elements keep
|
|
8
|
+
* the CSS-styled native scrollbar. Off, every scrollbar is the native one,
|
|
9
|
+
* styled with CSS. Default: `false`.
|
|
10
|
+
*/
|
|
11
|
+
overlay?: boolean;
|
|
3
12
|
width: string;
|
|
4
13
|
borderRadius: string;
|
|
14
|
+
/** Native scrollbar only: the overlay one has no border around the thumb. */
|
|
5
15
|
borderWidth: string;
|
|
6
16
|
colors: {
|
|
7
17
|
thumb: string;
|
|
8
18
|
thumbHover: string;
|
|
9
19
|
track: string;
|
|
20
|
+
/** Native scrollbar only, like `borderWidth`. */
|
|
10
21
|
border: string;
|
|
11
22
|
};
|
|
12
23
|
}
|
|
@@ -9,3 +9,10 @@ export interface ThemeConfig {
|
|
|
9
9
|
customCursor: CursorConfig;
|
|
10
10
|
colors: ColorsConfig;
|
|
11
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* The theme as rebuilt at runtime (`buildResolvedTheme`): just the colors.
|
|
14
|
+
* The other parts of `ThemeConfig` are only known at build time, where the
|
|
15
|
+
* module options are applied to them; at runtime they'd be `theme.json`'s
|
|
16
|
+
* own values, ignoring `nuxt.config`.
|
|
17
|
+
*/
|
|
18
|
+
export type ResolvedTheme = Pick<ThemeConfig, 'colors'>;
|
|
@@ -1,8 +1,22 @@
|
|
|
1
1
|
export interface VenixUnoPreset {
|
|
2
2
|
name: string;
|
|
3
|
+
enforce: 'post';
|
|
3
4
|
theme: {
|
|
4
5
|
colors: Record<string, string>;
|
|
5
6
|
};
|
|
7
|
+
rules: Array<[string, Record<string, string>]>;
|
|
8
|
+
}
|
|
9
|
+
export interface VenixUnoPresetOptions {
|
|
10
|
+
/**
|
|
11
|
+
* Also exposes the semantic color tokens (experimental, v1.4.0) as classes
|
|
12
|
+
* named after the CSS variable, with the `jade-` prefix: `--jade-bg-subtle`
|
|
13
|
+
* → `jade-bg-subtle`, `jade-text-muted`, `jade-border-strong`,
|
|
14
|
+
* `jade-fill-primary`, `jade-on-primary`… The prefix keeps them from
|
|
15
|
+
* clashing with the classes of other color systems (Vuetify's `text-primary`,
|
|
16
|
+
* Bootstrap's or shadcn's `text-muted`/`bg-muted`). They only have a value on
|
|
17
|
+
* themes with `tokens: true`. Default: `true`.
|
|
18
|
+
*/
|
|
19
|
+
tokens?: boolean;
|
|
6
20
|
}
|
|
7
21
|
/**
|
|
8
22
|
* UnoCSS preset that exposes the theme's colors as `theme.colors` (`primary`,
|
|
@@ -10,6 +24,18 @@ export interface VenixUnoPreset {
|
|
|
10
24
|
* generates (`--color-primary`, ...) — enables utilities like `text-primary`,
|
|
11
25
|
* `bg-background2/80` or `border-accent`.
|
|
12
26
|
*
|
|
27
|
+
* With `tokens` (the default), the semantic tokens too, one class per token
|
|
28
|
+
* named after its CSS variable: `--jade-text-muted` → `jade-text-muted`. They
|
|
29
|
+
* are rules and not theme colors: the class says `jade-`, not the utility, and
|
|
30
|
+
* sets the property the token is for (`bg-*`/`fill-*` the background, `text-*`/`on-*`
|
|
31
|
+
* the text color, `border-*` the border color). See `VenixUnoPresetOptions`.
|
|
32
|
+
*
|
|
33
|
+
* Also points `cursor-default`, `cursor-pointer` and `cursor-text` at the
|
|
34
|
+
* module's cursor variables (`--cursor-pointer`, ...), falling back to the
|
|
35
|
+
* system cursor when the module's cursor is off. `enforce: 'post'` puts these
|
|
36
|
+
* after `presetWind`/`presetUno`, whose own `cursor-pointer` they replace,
|
|
37
|
+
* wherever the preset sits in `presets`.
|
|
38
|
+
*
|
|
13
39
|
* Must be added manually to your `uno.config.ts`:
|
|
14
40
|
*
|
|
15
41
|
* ```ts
|
|
@@ -29,4 +55,4 @@ export interface VenixUnoPreset {
|
|
|
29
55
|
* itself, these colors become part of what's actually read from the file and
|
|
30
56
|
* survive that merge.
|
|
31
57
|
*/
|
|
32
|
-
export declare function venixUnoPreset(): VenixUnoPreset;
|
|
58
|
+
export declare function venixUnoPreset(options?: VenixUnoPresetOptions): VenixUnoPreset;
|
|
@@ -1,13 +1,31 @@
|
|
|
1
1
|
import { COLOR_PROPERTIES } from "./constants.js";
|
|
2
|
-
|
|
2
|
+
import { TOKEN_NAMES } from "./token-names.js";
|
|
3
|
+
const CURSOR_TYPES = ["default", "pointer", "text"];
|
|
4
|
+
const TOKEN_PROPERTY = {
|
|
5
|
+
bg: "background-color",
|
|
6
|
+
fill: "background-color",
|
|
7
|
+
text: "color",
|
|
8
|
+
on: "color",
|
|
9
|
+
border: "border-color"
|
|
10
|
+
};
|
|
11
|
+
export function venixUnoPreset(options = {}) {
|
|
3
12
|
const colors = {
|
|
4
13
|
inverse: "var(--color-inverse)"
|
|
5
14
|
};
|
|
6
15
|
for (const property of COLOR_PROPERTIES) {
|
|
7
16
|
colors[property] = `var(--color-${property})`;
|
|
8
17
|
}
|
|
18
|
+
const rules = CURSOR_TYPES.map((type) => [`cursor-${type}`, { cursor: `var(--cursor-${type}, ${type})` }]);
|
|
19
|
+
if (options.tokens !== false) {
|
|
20
|
+
for (const name of TOKEN_NAMES) {
|
|
21
|
+
const property = TOKEN_PROPERTY[name.split("-")[0]];
|
|
22
|
+
rules.push([`jade-${name}`, { [property]: `var(--jade-${name})` }]);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
9
25
|
return {
|
|
10
26
|
name: "venix-theme",
|
|
11
|
-
|
|
27
|
+
enforce: "post",
|
|
28
|
+
theme: { colors },
|
|
29
|
+
rules
|
|
12
30
|
};
|
|
13
31
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Relative luminance of a hex color: 0 for black, 1 for white.
|
|
3
|
+
* E.g.: "#FFFFFF" -> 1, "#000" -> 0
|
|
4
|
+
*/
|
|
5
|
+
export declare function relativeLuminance(hex: string): number;
|
|
6
|
+
/**
|
|
7
|
+
* WCAG contrast ratio between two hex colors, from 1 to 21. Symmetric: the
|
|
8
|
+
* order of the arguments doesn't matter.
|
|
9
|
+
* E.g.: ("#000000", "#FFFFFF") -> 21
|
|
10
|
+
*/
|
|
11
|
+
export declare function contrastRatio(a: string, b: string): number;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
function parseHex(hex) {
|
|
2
|
+
const match = /^#([\da-f]{3}|[\da-f]{6})$/i.exec(hex.trim());
|
|
3
|
+
if (!match) throw new Error(`[jade] Invalid hex color: "${hex}"`);
|
|
4
|
+
let digits = match[1];
|
|
5
|
+
if (digits.length === 3) digits = digits.replace(/./g, "$&$&");
|
|
6
|
+
return [
|
|
7
|
+
Number.parseInt(digits.slice(0, 2), 16),
|
|
8
|
+
Number.parseInt(digits.slice(2, 4), 16),
|
|
9
|
+
Number.parseInt(digits.slice(4, 6), 16)
|
|
10
|
+
];
|
|
11
|
+
}
|
|
12
|
+
function linearize(channel) {
|
|
13
|
+
const c = channel / 255;
|
|
14
|
+
return c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;
|
|
15
|
+
}
|
|
16
|
+
export function relativeLuminance(hex) {
|
|
17
|
+
const [r, g, b] = parseHex(hex);
|
|
18
|
+
return 0.2126 * linearize(r) + 0.7152 * linearize(g) + 0.0722 * linearize(b);
|
|
19
|
+
}
|
|
20
|
+
export function contrastRatio(a, b) {
|
|
21
|
+
const la = relativeLuminance(a);
|
|
22
|
+
const lb = relativeLuminance(b);
|
|
23
|
+
return (Math.max(la, lb) + 0.05) / (Math.min(la, lb) + 0.05);
|
|
24
|
+
}
|
|
@@ -4,8 +4,9 @@ export { resolveIcon, resolveThemeIcon } from './icon.js';
|
|
|
4
4
|
export type { IconKind, ResolvedIcon, ThemeIconFormat, ResolvedThemeIcon } from './icon.js';
|
|
5
5
|
export { extractIconRefs } from './icon-refs.js';
|
|
6
6
|
export { hasCookieConsent } from './consent.js';
|
|
7
|
+
export { contrastRatio, relativeLuminance } from './contrast.js';
|
|
7
8
|
export { isColorTheme, getActiveSeasonalTheme, getEasterSunday, getDefaultSelection, normalizeThemeSelection, resolveThemeSelection, resolveThemePreference, } from './theme-resolve.js';
|
|
8
9
|
export type { ColorModel, ThemeSelection } from './theme-resolve.js';
|
|
9
|
-
export { mergeColorThemes, normalizeColorThemes, findDeprecatedThemeEntries } from './merge-themes.js';
|
|
10
|
-
export { buildResolvedTheme, getBaseThemeEntries } from './theme-config.js';
|
|
10
|
+
export { mergeColorThemes, normalizeColorThemes, findDeprecatedThemeEntries, overridesBrandColors, BRAND_THEME } from './merge-themes.js';
|
|
11
|
+
export { buildResolvedTheme, findInvalidDefaultColor, getBaseThemeEntries } from './theme-config.js';
|
|
11
12
|
export type { VenixRuntimeThemeConfig } from './theme-config.js';
|
|
@@ -6,6 +6,7 @@ export { resolveFeatureOption } from "./options.js";
|
|
|
6
6
|
export { resolveIcon, resolveThemeIcon } from "./icon.js";
|
|
7
7
|
export { extractIconRefs } from "./icon-refs.js";
|
|
8
8
|
export { hasCookieConsent } from "./consent.js";
|
|
9
|
+
export { contrastRatio, relativeLuminance } from "./contrast.js";
|
|
9
10
|
export {
|
|
10
11
|
isColorTheme,
|
|
11
12
|
getActiveSeasonalTheme,
|
|
@@ -15,5 +16,5 @@ export {
|
|
|
15
16
|
resolveThemeSelection,
|
|
16
17
|
resolveThemePreference
|
|
17
18
|
} from "./theme-resolve.js";
|
|
18
|
-
export { mergeColorThemes, normalizeColorThemes, findDeprecatedThemeEntries } from "./merge-themes.js";
|
|
19
|
-
export { buildResolvedTheme, getBaseThemeEntries } from "./theme-config.js";
|
|
19
|
+
export { mergeColorThemes, normalizeColorThemes, findDeprecatedThemeEntries, overridesBrandColors, BRAND_THEME } from "./merge-themes.js";
|
|
20
|
+
export { buildResolvedTheme, findInvalidDefaultColor, getBaseThemeEntries } from "./theme-config.js";
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { ThemeConfig } from '../types/index.js';
|
|
1
|
+
import type { ResolvedTheme, ThemeConfig } from '../types/index.js';
|
|
2
2
|
export declare function loadTheme(_path?: string): ThemeConfig;
|
|
3
|
-
export declare function extractLocales(theme:
|
|
3
|
+
export declare function extractLocales(theme: ResolvedTheme): string[];
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import themeData from "../theme.json" with { type: "json" };
|
|
1
2
|
import { normalizeLocale } from "./normalize.js";
|
|
2
3
|
import { buildResolvedTheme } from "./theme-config.js";
|
|
3
4
|
export function loadTheme(_path) {
|
|
4
|
-
return buildResolvedTheme();
|
|
5
|
+
return { ...themeData, colors: buildResolvedTheme().colors };
|
|
5
6
|
}
|
|
6
7
|
export function extractLocales(theme) {
|
|
7
8
|
const locales = /* @__PURE__ */ new Set();
|
|
@@ -34,6 +34,14 @@ export declare function normalizeColorThemes(entries: Record<string, ThemeEntry>
|
|
|
34
34
|
themes: Record<string, ThemeColors>;
|
|
35
35
|
groups: Record<string, ResolvedThemeGroup>;
|
|
36
36
|
};
|
|
37
|
+
/** The built-in theme carrying the Venix Sistemas brand. */
|
|
38
|
+
export declare const BRAND_THEME = "venix";
|
|
39
|
+
/**
|
|
40
|
+
* Whether the overrides change any color of the brand theme (`venix`) —
|
|
41
|
+
* by its name, in either format, or by one of its variant ids in the flat
|
|
42
|
+
* format (`dark: { primary }`). Its name and icon don't count.
|
|
43
|
+
*/
|
|
44
|
+
export declare function overridesBrandColors(baseThemes: Record<string, ThemeEntry>, overrides?: Record<string, Partial<ThemeEntry>>): boolean;
|
|
37
45
|
/**
|
|
38
46
|
* Overrides still written in the deprecated flat format, with the message to
|
|
39
47
|
* show for each — logged once at build time by `module.ts`.
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { COLOR_PROPERTIES, THEME_MODES } from "../constants.js";
|
|
2
|
-
|
|
2
|
+
import { tokensEnabled } from "../token-names.js";
|
|
3
|
+
const META_PROPERTIES = ["seasonal", "dateRange", "translations", "icon", "tokens", "neutralTint"];
|
|
3
4
|
export function isThemeDefinition(entry) {
|
|
4
5
|
if (!entry) return false;
|
|
5
6
|
return THEME_MODES.some((mode) => typeof entry[mode] === "object");
|
|
@@ -23,6 +24,12 @@ function pickPalette(entry) {
|
|
|
23
24
|
}
|
|
24
25
|
return palette;
|
|
25
26
|
}
|
|
27
|
+
function tokensFlag(entry) {
|
|
28
|
+
if (entry.tokens === false) return { tokens: false };
|
|
29
|
+
if (!tokensEnabled(entry)) return {};
|
|
30
|
+
const tokens = typeof entry.tokens === "object" ? { ...entry.tokens } : true;
|
|
31
|
+
return entry.neutralTint === false ? { tokens, neutralTint: false } : { tokens };
|
|
32
|
+
}
|
|
26
33
|
const variantId = (themeName, mode, variant) => variant.id || `${themeName}-${mode}`;
|
|
27
34
|
function findVariantOwner(entries, id) {
|
|
28
35
|
for (const [themeName, entry] of Object.entries(entries)) {
|
|
@@ -82,18 +89,33 @@ export function normalizeColorThemes(entries) {
|
|
|
82
89
|
const variant = entry[mode];
|
|
83
90
|
if (!variant) continue;
|
|
84
91
|
const id = variantId(themeName, mode, variant);
|
|
85
|
-
themes[id] = { dark: mode === "dark", ...pickPalette(variant) };
|
|
92
|
+
themes[id] = { dark: mode === "dark", ...tokensFlag(entry), ...pickPalette(variant) };
|
|
86
93
|
group.variants[mode] = id;
|
|
87
94
|
}
|
|
88
95
|
} else if (isLegacyThemeEntry(entry)) {
|
|
89
96
|
const mode = entry.dark === false ? "light" : "dark";
|
|
90
|
-
themes[themeName] = { dark: mode === "dark", ...pickPalette(entry) };
|
|
97
|
+
themes[themeName] = { dark: mode === "dark", ...tokensFlag(entry), ...pickPalette(entry) };
|
|
91
98
|
group.variants[mode] = themeName;
|
|
92
99
|
}
|
|
93
100
|
groups[themeName] = group;
|
|
94
101
|
}
|
|
95
102
|
return { themes, groups };
|
|
96
103
|
}
|
|
104
|
+
export const BRAND_THEME = "venix";
|
|
105
|
+
function hasPaletteColors(entry) {
|
|
106
|
+
return !!entry && COLOR_PROPERTIES.some((key) => entry[key] !== void 0);
|
|
107
|
+
}
|
|
108
|
+
export function overridesBrandColors(baseThemes, overrides) {
|
|
109
|
+
for (const [themeName, override] of Object.entries(overrides ?? {})) {
|
|
110
|
+
if (themeName === BRAND_THEME) {
|
|
111
|
+
if (isThemeDefinition(override) ? THEME_MODES.some((mode) => hasPaletteColors(override[mode])) : hasPaletteColors(override)) return true;
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
if (baseThemes[themeName] || !isLegacyThemeEntry(override)) continue;
|
|
115
|
+
if (findVariantOwner(baseThemes, themeName)?.theme === BRAND_THEME && hasPaletteColors(override)) return true;
|
|
116
|
+
}
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
97
119
|
export function findDeprecatedThemeEntries(baseThemes, overrides) {
|
|
98
120
|
const messages = [];
|
|
99
121
|
for (const [themeName, override] of Object.entries(overrides ?? {})) {
|