@venix-sistemas/jade 1.2.0 → 1.3.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 +367 -157
- package/dist/module.json +1 -1
- package/dist/module.mjs +66 -4
- package/dist/runtime/components/VenixThemeSwitcher.d.vue.ts +2 -0
- package/dist/runtime/components/VenixThemeSwitcher.vue +413 -70
- package/dist/runtime/components/VenixThemeSwitcher.vue.d.ts +2 -0
- package/dist/runtime/composables/useThemeColors.d.ts +2 -2
- package/dist/runtime/composables/useThemeCookies.d.ts +8 -0
- 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 +20 -0
- package/dist/runtime/composables/useVenixTheme.js +86 -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/scripts/theme-init.d.ts +12 -3
- package/dist/runtime/scripts/theme-init.js +21 -4
- package/dist/shared/constants.d.ts +54 -0
- package/dist/shared/constants.js +20 -0
- 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 +78 -33
- package/dist/shared/css/scrollbar.js +61 -7
- package/dist/shared/css/typography.js +13 -0
- package/dist/shared/theme.json +14 -8
- package/dist/shared/types/cursor.d.ts +34 -4
- package/dist/shared/types/index.d.ts +2 -2
- package/dist/shared/types/runtime-config.d.ts +1 -0
- 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/utils/load.d.ts +2 -2
- package/dist/shared/utils/load.js +2 -1
- package/dist/shared/utils/theme-config.d.ts +3 -3
- package/dist/shared/utils/theme-config.js +0 -1
- 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 +10 -1
|
@@ -1,21 +1,64 @@
|
|
|
1
|
+
import { isColorTheme } from "../utils/theme-resolve.js";
|
|
2
|
+
import { generateCursorSVG } from "./cursor-svg.js";
|
|
3
|
+
import { CURSOR_ATTRIBUTE } from "../constants.js";
|
|
4
|
+
const CURSOR_TYPES = ["default", "pointer", "text"];
|
|
5
|
+
const imageValue = (image, type) => `url('${image.path}')${image.hotspot ? ` ${image.hotspot}` : ""}, ${type}`;
|
|
1
6
|
export function generateCustomCursorCSS(theme) {
|
|
2
7
|
const cursor = theme.customCursor;
|
|
3
|
-
if (!cursor || !cursor.enabled
|
|
4
|
-
const
|
|
8
|
+
if (!cursor || !cursor.enabled) return "";
|
|
9
|
+
const images = cursor.defaultCursors ?? {};
|
|
10
|
+
const fallback = (type) => images[type] ? imageValue(images[type], type) : type;
|
|
11
|
+
const owners = {};
|
|
12
|
+
for (const [name, group] of Object.entries(theme.colors?.groups ?? {})) {
|
|
13
|
+
for (const id of Object.values(group.variants)) if (id) owners[id] = name;
|
|
14
|
+
}
|
|
15
|
+
const variants = [];
|
|
16
|
+
if (theme.colors?.enabled !== false) {
|
|
17
|
+
for (const [id, colors] of Object.entries(theme.colors?.themes ?? {})) {
|
|
18
|
+
if (id === "system" || !isColorTheme(colors)) continue;
|
|
19
|
+
const entry = cursor.themeCursors?.[id] ?? (owners[id] ? cursor.themeCursors?.[owners[id]] : void 0);
|
|
20
|
+
const own = typeof entry === "object" ? entry : {};
|
|
21
|
+
const mode = typeof entry === "string" ? entry : cursor.themed === false ? "base" : "themed";
|
|
22
|
+
const values = {};
|
|
23
|
+
for (const type of CURSOR_TYPES) {
|
|
24
|
+
const image = own[type];
|
|
25
|
+
if (image) {
|
|
26
|
+
values[type] = imageValue(image, type);
|
|
27
|
+
} else if (mode === "none") {
|
|
28
|
+
values[type] = type;
|
|
29
|
+
} else if (mode === "themed" && colors.primary?.startsWith("#")) {
|
|
30
|
+
const { url, hotspot } = generateCursorSVG(type, colors.primary);
|
|
31
|
+
values[type] = `url("${url}") ${hotspot}, ${fallback(type)}`;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (Object.keys(values).length) variants.push([id, values]);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const types = CURSOR_TYPES.filter((type) => images[type] || variants.some(([, values]) => values[type]));
|
|
38
|
+
if (!types.length) return "";
|
|
5
39
|
let css = "\n/* ============================================ */\n";
|
|
6
40
|
css += "/* Custom Cursor */\n";
|
|
7
41
|
css += "/* ============================================ */\n";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
42
|
+
css += "\n/* 0. Cursor values: the default cursors, then each theme's own (drawn in its color, its images or the system's) */\n";
|
|
43
|
+
css += `:root {
|
|
44
|
+
${types.map((type) => ` --cursor-${type}: ${fallback(type)};`).join("\n")}
|
|
45
|
+
}
|
|
46
|
+
`;
|
|
47
|
+
for (const [id, values] of variants) {
|
|
48
|
+
const vars = types.filter((type) => values[type]).map((type) => ` --cursor-${type}: ${values[type]};`);
|
|
49
|
+
css += `:root[data-theme='${id}'] {
|
|
50
|
+
${vars.join("\n")}
|
|
51
|
+
}
|
|
52
|
+
`;
|
|
53
|
+
}
|
|
54
|
+
css += `:root[${CURSOR_ATTRIBUTE}='off'] {
|
|
55
|
+
${types.map((type) => ` --cursor-${type}: ${type};`).join("\n")}
|
|
56
|
+
}
|
|
57
|
+
`;
|
|
58
|
+
if (types.includes("default")) {
|
|
16
59
|
css += "\n/* 1. Default cursor on everything */\n";
|
|
17
60
|
css += `html {
|
|
18
|
-
cursor:
|
|
61
|
+
cursor: var(--cursor-default);
|
|
19
62
|
}
|
|
20
63
|
`;
|
|
21
64
|
css += "\n/* 1b. Elements the browser stylesheet sets to `cursor: default`, which would show the system arrow instead of inheriting */\n";
|
|
@@ -23,33 +66,34 @@ export function generateCustomCursorCSS(theme) {
|
|
|
23
66
|
select,
|
|
24
67
|
input[type="checkbox"], input[type="radio"],
|
|
25
68
|
input[type="range"], input[type="color"], input[type="file"] {
|
|
26
|
-
cursor:
|
|
69
|
+
cursor: var(--cursor-default);
|
|
27
70
|
}
|
|
28
71
|
`;
|
|
29
72
|
}
|
|
30
|
-
if (
|
|
31
|
-
const value = cursorValue("pointer");
|
|
73
|
+
if (types.includes("pointer")) {
|
|
32
74
|
css += "\n/* 2. Pointer cursor for clickable elements */\n";
|
|
33
|
-
css += `a, a *,
|
|
75
|
+
css += `a[href], a[href] *,
|
|
34
76
|
button, button *,
|
|
35
|
-
|
|
77
|
+
summary,
|
|
78
|
+
[role="button"], [role="link"], [role="tab"],
|
|
36
79
|
input[type="button"], input[type="submit"], input[type="reset"],
|
|
37
80
|
.v-btn:not(.v-btn--disabled),
|
|
38
|
-
.v-
|
|
39
|
-
.v-
|
|
81
|
+
.v-icon--clickable,
|
|
82
|
+
.v-list-item--link,
|
|
83
|
+
.v-chip--link,
|
|
40
84
|
.v-tab,
|
|
41
|
-
.v-chip,
|
|
42
85
|
.v-card--link,
|
|
43
86
|
.v-breadcrumbs-item--link,
|
|
44
|
-
.v-pagination__item
|
|
45
|
-
|
|
87
|
+
.v-pagination__item,
|
|
88
|
+
.os-scrollbar, .os-scrollbar * {
|
|
89
|
+
cursor: var(--cursor-pointer) !important;
|
|
46
90
|
}
|
|
47
91
|
`;
|
|
48
92
|
}
|
|
49
|
-
if (
|
|
50
|
-
const value = cursorValue("text");
|
|
93
|
+
if (types.includes("text")) {
|
|
51
94
|
css += "\n/* 3. Text cursor (i-beam) for editable fields only */\n";
|
|
52
|
-
css += `input[type
|
|
95
|
+
css += `input:not([type]),
|
|
96
|
+
input[type="text"],
|
|
53
97
|
input[type="email"],
|
|
54
98
|
input[type="password"],
|
|
55
99
|
input[type="number"],
|
|
@@ -62,18 +106,19 @@ input[type="month"],
|
|
|
62
106
|
input[type="week"],
|
|
63
107
|
input[type="time"],
|
|
64
108
|
textarea,
|
|
65
|
-
[contenteditable="true"] {
|
|
66
|
-
cursor:
|
|
109
|
+
[contenteditable=""], [contenteditable="true"], [contenteditable="plaintext-only"] {
|
|
110
|
+
cursor: var(--cursor-text) !important;
|
|
67
111
|
}
|
|
68
112
|
`;
|
|
69
113
|
}
|
|
70
|
-
if (
|
|
71
|
-
|
|
72
|
-
css +=
|
|
73
|
-
|
|
74
|
-
[disabled],
|
|
75
|
-
.disabled
|
|
76
|
-
|
|
114
|
+
if (types.includes("default")) {
|
|
115
|
+
css += "\n/* 4. Disabled elements, and what they contain */\n";
|
|
116
|
+
css += `html :disabled, html :disabled *,
|
|
117
|
+
html [disabled], html [disabled] *,
|
|
118
|
+
html [aria-disabled="true"], html [aria-disabled="true"] *,
|
|
119
|
+
html .disabled,
|
|
120
|
+
html .v-btn--disabled, html .v-btn--disabled * {
|
|
121
|
+
cursor: var(--cursor-default) !important;
|
|
77
122
|
}
|
|
78
123
|
`;
|
|
79
124
|
}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import { OVERLAY_SCROLLBAR_THEME, SCROLLBAR_ATTRIBUTE } from "../constants.js";
|
|
2
|
+
const ON = `html:not([${SCROLLBAR_ATTRIBUTE}='off'])`;
|
|
3
|
+
const on = (pseudo) => `${ON}${pseudo},
|
|
4
|
+
${ON} ${pseudo}`;
|
|
1
5
|
export function generateCustomScrollbarCSS(theme) {
|
|
2
6
|
const scrollbar = theme.customScrollbar;
|
|
3
7
|
if (!scrollbar || !scrollbar.enabled) return "";
|
|
@@ -19,32 +23,82 @@ export function generateCustomScrollbarCSS(theme) {
|
|
|
19
23
|
css += "/* Custom Scrollbar */\n";
|
|
20
24
|
css += "/* ============================================ */\n";
|
|
21
25
|
css += `
|
|
22
|
-
::-webkit-scrollbar {
|
|
26
|
+
${on("::-webkit-scrollbar")} {
|
|
23
27
|
width: ${width};
|
|
24
28
|
height: ${width};
|
|
25
29
|
}
|
|
26
30
|
`;
|
|
27
31
|
css += `
|
|
28
|
-
::-webkit-scrollbar-track {
|
|
32
|
+
${on("::-webkit-scrollbar-track")} {
|
|
29
33
|
background: ${track};
|
|
30
34
|
}
|
|
31
35
|
`;
|
|
32
36
|
css += `
|
|
33
|
-
::-webkit-scrollbar-thumb {
|
|
37
|
+
${on("::-webkit-scrollbar-thumb")} {
|
|
34
38
|
background: ${thumb};
|
|
35
39
|
border-radius: ${borderRadius};
|
|
36
40
|
border: ${borderWidth} solid ${border};
|
|
41
|
+
/* The custom pointer: Chromium draws a styled scrollbar as part of the
|
|
42
|
+
page and shows its cursor there. The arrow without the cursor module. */
|
|
43
|
+
cursor: var(--cursor-pointer, default);
|
|
37
44
|
}
|
|
38
45
|
`;
|
|
39
46
|
css += `
|
|
40
|
-
::-webkit-scrollbar-thumb:hover {
|
|
47
|
+
${on("::-webkit-scrollbar-thumb:hover")} {
|
|
41
48
|
background: ${thumbHover};
|
|
42
49
|
}
|
|
43
50
|
`;
|
|
44
51
|
css += `
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
52
|
+
${on("::-webkit-scrollbar-corner")} {
|
|
53
|
+
background: ${track};
|
|
54
|
+
}
|
|
55
|
+
`;
|
|
56
|
+
css += `
|
|
57
|
+
@supports not selector(::-webkit-scrollbar) {
|
|
58
|
+
${ON} {
|
|
59
|
+
scrollbar-width: ${width === "auto" ? "auto" : "thin"};
|
|
60
|
+
scrollbar-color: ${thumb} ${track};
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
`;
|
|
64
|
+
if (scrollbar.overlay === true) css += generateOverlayScrollbarCSS({ width, borderRadius, thumb, thumbHover, track });
|
|
65
|
+
return css;
|
|
66
|
+
}
|
|
67
|
+
function generateOverlayScrollbarCSS(o) {
|
|
68
|
+
let css = "\n/* Overlay scrollbar (OverlayScrollbars): page elements, so the custom cursor applies over them */\n";
|
|
69
|
+
css += `.${OVERLAY_SCROLLBAR_THEME} {
|
|
70
|
+
--os-size: ${o.width === "auto" ? "10px" : o.width};
|
|
71
|
+
--os-padding-perpendicular: 2px;
|
|
72
|
+
--os-padding-axis: 2px;
|
|
73
|
+
--os-track-border-radius: ${o.borderRadius};
|
|
74
|
+
--os-handle-border-radius: ${o.borderRadius};
|
|
75
|
+
--os-track-bg: ${o.track};
|
|
76
|
+
--os-handle-bg: ${o.thumb};
|
|
77
|
+
--os-handle-bg-hover: ${o.thumbHover};
|
|
78
|
+
--os-handle-bg-active: ${o.thumbHover};
|
|
79
|
+
}
|
|
80
|
+
`;
|
|
81
|
+
css += `
|
|
82
|
+
.${OVERLAY_SCROLLBAR_THEME}.os-scrollbar:hover {
|
|
83
|
+
--os-handle-bg: ${o.thumbHover};
|
|
84
|
+
}
|
|
85
|
+
`;
|
|
86
|
+
css += `
|
|
87
|
+
.v-table > .os-scrollbar {
|
|
88
|
+
z-index: 3;
|
|
89
|
+
}
|
|
90
|
+
`;
|
|
91
|
+
css += `
|
|
92
|
+
html[data-overlayscrollbars].v-overlay-scroll-blocked {
|
|
93
|
+
top: auto;
|
|
94
|
+
left: auto;
|
|
95
|
+
}
|
|
96
|
+
`;
|
|
97
|
+
css += `
|
|
98
|
+
@media (scripting: enabled) {
|
|
99
|
+
${ON}:not([data-overlayscrollbars]) {
|
|
100
|
+
scrollbar-width: none;
|
|
101
|
+
}
|
|
48
102
|
}
|
|
49
103
|
`;
|
|
50
104
|
return css;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { FONT_ATTRIBUTE } from "../constants.js";
|
|
1
2
|
export function generateFontFaces(theme) {
|
|
2
3
|
if (!theme.typography?.customFonts) return "";
|
|
3
4
|
const uniqueFonts = /* @__PURE__ */ new Map();
|
|
@@ -58,5 +59,17 @@ export function generateRootVars(theme) {
|
|
|
58
59
|
`;
|
|
59
60
|
}
|
|
60
61
|
vars += "}\n";
|
|
62
|
+
if (theme.typography?.customFonts?.length) {
|
|
63
|
+
const fallback = theme.typography.defaultFonts || "initial";
|
|
64
|
+
vars += `:root[${FONT_ATTRIBUTE}='off'] {
|
|
65
|
+
`;
|
|
66
|
+
vars += ` --font-family-base: ${fallback};
|
|
67
|
+
`;
|
|
68
|
+
vars += ` --v-font-body: ${fallback};
|
|
69
|
+
`;
|
|
70
|
+
vars += ` --v-font-heading: ${fallback};
|
|
71
|
+
`;
|
|
72
|
+
vars += "}\n";
|
|
73
|
+
}
|
|
61
74
|
return vars;
|
|
62
75
|
}
|
package/dist/shared/theme.json
CHANGED
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
},
|
|
19
19
|
"customScrollbar": {
|
|
20
20
|
"enabled": true,
|
|
21
|
+
"overlay": false,
|
|
21
22
|
"width": "auto",
|
|
22
23
|
"borderRadius": "8px",
|
|
23
24
|
"borderWidth": "3px",
|
|
@@ -30,7 +31,8 @@
|
|
|
30
31
|
},
|
|
31
32
|
"customCursor": {
|
|
32
33
|
"enabled": false,
|
|
33
|
-
"
|
|
34
|
+
"themed": true,
|
|
35
|
+
"defaultCursors": {
|
|
34
36
|
"default": {
|
|
35
37
|
"path": "/images/ui/cursor/cursor.png",
|
|
36
38
|
"hotspot": "4 0"
|
|
@@ -44,7 +46,11 @@
|
|
|
44
46
|
"hotspot": "12 12"
|
|
45
47
|
}
|
|
46
48
|
},
|
|
47
|
-
"
|
|
49
|
+
"themeCursors": {
|
|
50
|
+
"venix": "base"
|
|
51
|
+
},
|
|
52
|
+
"_comment": "defaultCursors: default | pointer | text --- themeCursors: <themename>: themed | base | none | { default, pointer, text }",
|
|
53
|
+
"_deprecated": "DEPRECATED: the fire images in defaultCursors (src/runtime/public/images/ui/cursor) are removed in 2.0.0, with no warning to users. See docs/v2.0.0.md."
|
|
48
54
|
},
|
|
49
55
|
"colors": {
|
|
50
56
|
"enabled": true,
|
|
@@ -99,8 +105,8 @@
|
|
|
99
105
|
},
|
|
100
106
|
"venix": {
|
|
101
107
|
"translations": {
|
|
102
|
-
"pt-BR": "Venix
|
|
103
|
-
"en-US": "Venix
|
|
108
|
+
"pt-BR": "Venix",
|
|
109
|
+
"en-US": "Venix"
|
|
104
110
|
},
|
|
105
111
|
"icon": {
|
|
106
112
|
"emote": "💎",
|
|
@@ -232,8 +238,8 @@
|
|
|
232
238
|
},
|
|
233
239
|
"dark": {
|
|
234
240
|
"id": "natal",
|
|
235
|
-
"primary": "#
|
|
236
|
-
"secondary": "#
|
|
241
|
+
"primary": "#6FCF7F",
|
|
242
|
+
"secondary": "#FF6B6B",
|
|
237
243
|
"accent": "#FFD54F",
|
|
238
244
|
"error": "#FF6161",
|
|
239
245
|
"info": "#64B5F6",
|
|
@@ -244,8 +250,8 @@
|
|
|
244
250
|
"background3": "#172C23"
|
|
245
251
|
},
|
|
246
252
|
"light": {
|
|
247
|
-
"primary": "#
|
|
248
|
-
"secondary": "#
|
|
253
|
+
"primary": "#2E7D32",
|
|
254
|
+
"secondary": "#C62828",
|
|
249
255
|
"accent": "#B8860B",
|
|
250
256
|
"error": "#D32F2F",
|
|
251
257
|
"info": "#1976D2",
|
|
@@ -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
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
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';
|
|
4
|
+
export type { CursorConfig, CursorType, CursorImage, ThemeCursor } from './cursor.js';
|
|
5
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';
|
|
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';
|
|
@@ -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,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();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ResolvedTheme, ThemeEntry } from '../types/index.js';
|
|
2
2
|
export interface VenixRuntimeThemeConfig {
|
|
3
3
|
defaultTheme?: string;
|
|
4
4
|
colorThemes?: Record<string, Partial<ThemeEntry>>;
|
|
@@ -8,7 +8,7 @@ export interface VenixRuntimeThemeConfig {
|
|
|
8
8
|
/** The theme entries bundled with the module, in config format. */
|
|
9
9
|
export declare function getBaseThemeEntries(): Record<string, ThemeEntry>;
|
|
10
10
|
/**
|
|
11
|
-
* Rebuilds the
|
|
11
|
+
* Rebuilds the color themes at runtime, layering `theme.json`
|
|
12
12
|
* (bundled with the module, with the "base" themes) with the customizations
|
|
13
13
|
* from `runtimeConfig.public.venixTheme` (resolved at build time from the
|
|
14
14
|
* module options in `nuxt.config`, see `module.ts`). Single implementation —
|
|
@@ -20,4 +20,4 @@ export declare function getBaseThemeEntries(): Record<string, ThemeEntry>;
|
|
|
20
20
|
* (merge + normalization of every theme) each time was wasted work. The
|
|
21
21
|
* result is shared, so callers must treat it as read-only.
|
|
22
22
|
*/
|
|
23
|
-
export declare function buildResolvedTheme(runtimeThemeConfig?: VenixRuntimeThemeConfig):
|
|
23
|
+
export declare function buildResolvedTheme(runtimeThemeConfig?: VenixRuntimeThemeConfig): ResolvedTheme;
|
|
@@ -1,12 +1,21 @@
|
|
|
1
|
-
import type { ThemeColors } from '../types/index.js';
|
|
1
|
+
import type { ThemeColors, ThemeMeta } from '../types/index.js';
|
|
2
2
|
import type { ColorModel } from './theme-resolver.js';
|
|
3
3
|
export type { ColorModel, ThemeSelection } from './theme-resolver.js';
|
|
4
|
-
export declare const isColorTheme: (themeConfig: ThemeColors | undefined) => boolean, getEasterSunday: (year: number) => Date, isModePreference: (value: unknown) => value is import("../types/index.js").ThemeModePreference, isSelectableGroup: (colors: ColorModel, name: string) => boolean, findVariantOwner: (colors: ColorModel, id: string) => {
|
|
4
|
+
export declare const isColorTheme: (themeConfig: ThemeColors | undefined) => boolean, getEasterSunday: (year: number) => Date, parseDatePart: (value: string, year: number) => number | null, isModePreference: (value: unknown) => value is import("../types/index.js").ThemeModePreference, isSelectableGroup: (colors: ColorModel, name: string) => boolean, findVariantOwner: (colors: ColorModel, id: string) => {
|
|
5
5
|
theme: string;
|
|
6
6
|
mode: import("../types/index.js").ThemeMode;
|
|
7
7
|
} | null, getDefaultSelection: (colors: ColorModel) => import("./theme-resolver.js").ThemeSelection & {
|
|
8
8
|
fallbackTheme: string;
|
|
9
9
|
}, normalizeThemeSelection: (themePreference: string | null | undefined, modePreference: string | null | undefined, colors: ColorModel) => import("./theme-resolver.js").ThemeSelection, getActiveSeasonalTheme: (groups: Record<string, import("../types/index.js").ResolvedThemeGroup>, mode?: import("../types/index.js").ThemeMode, now?: Date) => string | null, resolveMode: (mode: import("../types/index.js").ThemeModePreference, prefersDark: boolean) => import("../types/index.js").ThemeMode, resolveThemeSelection: (selection: import("./theme-resolver.js").ThemeSelection, colors: ColorModel, prefersDark: boolean, now?: Date) => string, resolveThemePreference: (themePreference: string | null | undefined, modePreference: string | null | undefined, colors: ColorModel, prefersDark: boolean, now?: Date) => string;
|
|
10
|
+
/**
|
|
11
|
+
* When a seasonal theme is on: the occurrence of its `dateRange` that's
|
|
12
|
+
* running or comes next from `now` (next year's once this year's is over,
|
|
13
|
+
* which moves for ranges relative to Easter). `null` without a valid range.
|
|
14
|
+
*/
|
|
15
|
+
export declare function getSeasonDates(meta: ThemeMeta, now?: Date): {
|
|
16
|
+
start: Date;
|
|
17
|
+
end: Date;
|
|
18
|
+
} | null;
|
|
10
19
|
/**
|
|
11
20
|
* The theme's actual color entries (hex values only) — skips metadata like
|
|
12
21
|
* `dark`/`translations`/`icon`. Shared by the CSS generator and the Vuetify
|
|
@@ -3,6 +3,7 @@ import { createThemeResolver } from "./theme-resolver.js";
|
|
|
3
3
|
export const {
|
|
4
4
|
isColorTheme,
|
|
5
5
|
getEasterSunday,
|
|
6
|
+
parseDatePart,
|
|
6
7
|
isModePreference,
|
|
7
8
|
isSelectableGroup,
|
|
8
9
|
findVariantOwner,
|
|
@@ -13,6 +14,23 @@ export const {
|
|
|
13
14
|
resolveThemeSelection,
|
|
14
15
|
resolveThemePreference
|
|
15
16
|
} = createThemeResolver();
|
|
17
|
+
export function getSeasonDates(meta, now = /* @__PURE__ */ new Date()) {
|
|
18
|
+
if (meta.seasonal !== true || !meta.dateRange) return null;
|
|
19
|
+
const { start, end } = meta.dateRange;
|
|
20
|
+
const toDate = (bound, year2) => {
|
|
21
|
+
const value = parseDatePart(bound, year2);
|
|
22
|
+
return value === null ? null : new Date(year2, Math.floor(value / 100) - 1, value % 100);
|
|
23
|
+
};
|
|
24
|
+
const year = now.getFullYear();
|
|
25
|
+
const today = new Date(year, now.getMonth(), now.getDate());
|
|
26
|
+
const startThisYear = toDate(start, year);
|
|
27
|
+
const endThisYear = toDate(end, year);
|
|
28
|
+
if (!startThisYear || !endThisYear) return null;
|
|
29
|
+
if (startThisYear > endThisYear) {
|
|
30
|
+
return today <= endThisYear ? { start: toDate(start, year - 1), end: endThisYear } : { start: startThisYear, end: toDate(end, year + 1) };
|
|
31
|
+
}
|
|
32
|
+
return today <= endThisYear ? { start: startThisYear, end: endThisYear } : { start: toDate(start, year + 1), end: toDate(end, year + 1) };
|
|
33
|
+
}
|
|
16
34
|
export function getThemeHexColors(themeConfig) {
|
|
17
35
|
const result = [];
|
|
18
36
|
for (const [key, value] of Object.entries(themeConfig)) {
|
|
@@ -28,6 +28,7 @@ export declare function createThemeResolver(): {
|
|
|
28
28
|
DEFAULT_THEME: string;
|
|
29
29
|
isColorTheme: (themeConfig: ThemeColors | undefined) => boolean;
|
|
30
30
|
getEasterSunday: (year: number) => Date;
|
|
31
|
+
parseDatePart: (value: string, year: number) => number | null;
|
|
31
32
|
isModePreference: (value: unknown) => value is ThemeModePreference;
|
|
32
33
|
isSelectableGroup: (colors: ColorModel, name: string) => boolean;
|
|
33
34
|
findVariantOwner: (colors: ColorModel, id: string) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@venix-sistemas/jade",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "UI foundation for Nuxt in a single module: color themes (seasonal, SSR, cookie consent), typography, scrollbar, cursor, icons, i18n, plus UnoCSS and Vuetify integrations.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"nuxt",
|
|
@@ -71,6 +71,14 @@
|
|
|
71
71
|
"@nuxt/icon": "^2.5.1",
|
|
72
72
|
"@nuxt/kit": "^4.6.1"
|
|
73
73
|
},
|
|
74
|
+
"peerDependencies": {
|
|
75
|
+
"overlayscrollbars": "^2.17.0"
|
|
76
|
+
},
|
|
77
|
+
"peerDependenciesMeta": {
|
|
78
|
+
"overlayscrollbars": {
|
|
79
|
+
"optional": true
|
|
80
|
+
}
|
|
81
|
+
},
|
|
74
82
|
"devDependencies": {
|
|
75
83
|
"@nuxt/devtools": "4.0.0-beta.5",
|
|
76
84
|
"@nuxt/eslint-config": "^1.17.0",
|
|
@@ -82,6 +90,7 @@
|
|
|
82
90
|
"changelogen": "^0.6.2",
|
|
83
91
|
"eslint": "^10.12.0",
|
|
84
92
|
"nuxt": "^4.6.1",
|
|
93
|
+
"overlayscrollbars": "^2.17.0",
|
|
85
94
|
"typescript": "7.0.2",
|
|
86
95
|
"vitest": "5.0.4",
|
|
87
96
|
"vue-tsc": "^3.3.13"
|