@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
|
@@ -15,6 +15,22 @@ export declare const THEME_COOKIE_OPTIONS: {
|
|
|
15
15
|
readonly path: "/";
|
|
16
16
|
readonly sameSite: "lax";
|
|
17
17
|
};
|
|
18
|
+
/** `'off'` when the visitor turned the custom scrollbar off (`scrollbar.set(false)`); missing or `'on'` keeps it. Same consent rule as the theme cookies. */
|
|
19
|
+
export declare const SCROLLBAR_COOKIE = "venix-scrollbar";
|
|
20
|
+
/** Same as `SCROLLBAR_COOKIE`, for the custom cursor (`cursor.set(false)`). */
|
|
21
|
+
export declare const CURSOR_COOKIE = "venix-cursor";
|
|
22
|
+
/** Same as `SCROLLBAR_COOKIE`, for the custom font (`font.set(false)`). */
|
|
23
|
+
export declare const FONT_COOKIE = "venix-font";
|
|
24
|
+
/** `'off'` on `<html>` switches the custom scrollbar off: its CSS only applies without it (see shared/css/scrollbar.ts). */
|
|
25
|
+
export declare const SCROLLBAR_ATTRIBUTE = "data-venix-scrollbar";
|
|
26
|
+
/** On any element that scrolls, gets it the overlay scrollbar too (see runtime/plugins/overlay-scrollbars.client.ts). */
|
|
27
|
+
export declare const SCROLL_CONTAINER_ATTRIBUTE = "data-venix-scroll";
|
|
28
|
+
/** The OverlayScrollbars theme the module styles (see shared/css/scrollbar.ts). */
|
|
29
|
+
export declare const OVERLAY_SCROLLBAR_THEME = "os-theme-jade";
|
|
30
|
+
/** `'off'` on `<html>` puts the browser's own cursors back (see shared/css/cursor.ts). */
|
|
31
|
+
export declare const CURSOR_ATTRIBUTE = "data-venix-cursor";
|
|
32
|
+
/** `'off'` on `<html>` leaves only the `defaultFonts` in the font variables (see shared/css/typography.ts). */
|
|
33
|
+
export declare const FONT_ATTRIBUTE = "data-venix-font";
|
|
18
34
|
export declare const COOKIE_PREFERENCES_UPDATED_EVENT = "venix-cookie-preferences-updated";
|
|
19
35
|
/**
|
|
20
36
|
* Dispatched synchronously by `apply()` (useVenixTheme.ts), inside the same
|
|
@@ -39,5 +55,43 @@ export declare const LOCALE_MAP: Record<string, string>;
|
|
|
39
55
|
export declare const DEFAULT_THEME = "dark";
|
|
40
56
|
export declare const SYSTEM_THEME = "system";
|
|
41
57
|
export declare const THEME_MODES: readonly ["light", "dark"];
|
|
58
|
+
/**
|
|
59
|
+
* The icons of <VenixThemeSwitcher>'s own controls, in the same formats as a
|
|
60
|
+
* theme's icon. Listed here so `setup/register-icon.ts` bundles them along
|
|
61
|
+
* with the themes' (line-md has no save, scroll, cursor or font icon, hence `mdi`).
|
|
62
|
+
*/
|
|
63
|
+
export declare const SWITCHER_ICONS: {
|
|
64
|
+
readonly settings: {
|
|
65
|
+
readonly emote: "⚙️";
|
|
66
|
+
readonly css: "mdi:cog-outline";
|
|
67
|
+
readonly svg: "line-md:cog";
|
|
68
|
+
};
|
|
69
|
+
readonly back: {
|
|
70
|
+
readonly emote: "⬅️";
|
|
71
|
+
readonly css: "mdi:arrow-left";
|
|
72
|
+
readonly svg: "line-md:arrow-left";
|
|
73
|
+
};
|
|
74
|
+
readonly save: {
|
|
75
|
+
readonly emote: "💾";
|
|
76
|
+
readonly css: "mdi:content-save-outline";
|
|
77
|
+
};
|
|
78
|
+
readonly scrollbar: {
|
|
79
|
+
readonly emote: "↕️";
|
|
80
|
+
readonly css: "mdi:mouse-scroll-wheel";
|
|
81
|
+
};
|
|
82
|
+
readonly cursor: {
|
|
83
|
+
readonly emote: "🖱️";
|
|
84
|
+
readonly css: "mdi:cursor-default-outline";
|
|
85
|
+
};
|
|
86
|
+
readonly font: {
|
|
87
|
+
readonly emote: "🔤";
|
|
88
|
+
readonly css: "mdi:format-font";
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
/** The credit at the bottom of <VenixThemeSwitcher>'s settings. */
|
|
92
|
+
export declare const SWITCHER_CREDIT: {
|
|
93
|
+
readonly name: "@venix-sistemas/jade";
|
|
94
|
+
readonly url: "https://github.com/Venix-Sistemas/jade";
|
|
95
|
+
};
|
|
42
96
|
export declare const COLOR_PROPERTIES: readonly ["primary", "secondary", "accent", "error", "info", "success", "warning", "background", "background2", "background3"];
|
|
43
|
-
export declare const NON_COLOR_PROPERTIES: readonly ["id", "dark", "light", "seasonal", "dateRange", "translations", "icon"];
|
|
97
|
+
export declare const NON_COLOR_PROPERTIES: readonly ["id", "dark", "light", "seasonal", "dateRange", "translations", "icon", "tokens", "neutralTint"];
|
package/dist/shared/constants.js
CHANGED
|
@@ -3,6 +3,14 @@ export const THEME_RESOLVED_COOKIE = "venix-theme-resolved";
|
|
|
3
3
|
export const THEME_MODE_COOKIE = "venix-theme-mode";
|
|
4
4
|
export const THEME_COOKIE_MAX_AGE = 60 * 60 * 24 * 365;
|
|
5
5
|
export const THEME_COOKIE_OPTIONS = { maxAge: THEME_COOKIE_MAX_AGE, path: "/", sameSite: "lax" };
|
|
6
|
+
export const SCROLLBAR_COOKIE = "venix-scrollbar";
|
|
7
|
+
export const CURSOR_COOKIE = "venix-cursor";
|
|
8
|
+
export const FONT_COOKIE = "venix-font";
|
|
9
|
+
export const SCROLLBAR_ATTRIBUTE = "data-venix-scrollbar";
|
|
10
|
+
export const SCROLL_CONTAINER_ATTRIBUTE = "data-venix-scroll";
|
|
11
|
+
export const OVERLAY_SCROLLBAR_THEME = "os-theme-jade";
|
|
12
|
+
export const CURSOR_ATTRIBUTE = "data-venix-cursor";
|
|
13
|
+
export const FONT_ATTRIBUTE = "data-venix-font";
|
|
6
14
|
export const COOKIE_PREFERENCES_UPDATED_EVENT = "venix-cookie-preferences-updated";
|
|
7
15
|
export const THEME_APPLIED_EVENT = "venix-theme-applied";
|
|
8
16
|
export const COOKIE_CONSENT_STORAGE_KEY = "venix-cookie-consent";
|
|
@@ -22,6 +30,18 @@ export const LOCALE_MAP = {
|
|
|
22
30
|
export const DEFAULT_THEME = "dark";
|
|
23
31
|
export const SYSTEM_THEME = "system";
|
|
24
32
|
export const THEME_MODES = ["light", "dark"];
|
|
33
|
+
export const SWITCHER_ICONS = {
|
|
34
|
+
settings: { emote: "\u2699\uFE0F", css: "mdi:cog-outline", svg: "line-md:cog" },
|
|
35
|
+
back: { emote: "\u2B05\uFE0F", css: "mdi:arrow-left", svg: "line-md:arrow-left" },
|
|
36
|
+
save: { emote: "\u{1F4BE}", css: "mdi:content-save-outline" },
|
|
37
|
+
scrollbar: { emote: "\u2195\uFE0F", css: "mdi:mouse-scroll-wheel" },
|
|
38
|
+
cursor: { emote: "\u{1F5B1}\uFE0F", css: "mdi:cursor-default-outline" },
|
|
39
|
+
font: { emote: "\u{1F524}", css: "mdi:format-font" }
|
|
40
|
+
};
|
|
41
|
+
export const SWITCHER_CREDIT = {
|
|
42
|
+
name: "@venix-sistemas/jade",
|
|
43
|
+
url: "https://github.com/Venix-Sistemas/jade"
|
|
44
|
+
};
|
|
25
45
|
export const COLOR_PROPERTIES = [
|
|
26
46
|
"primary",
|
|
27
47
|
"secondary",
|
|
@@ -41,5 +61,7 @@ export const NON_COLOR_PROPERTIES = [
|
|
|
41
61
|
"seasonal",
|
|
42
62
|
"dateRange",
|
|
43
63
|
"translations",
|
|
44
|
-
"icon"
|
|
64
|
+
"icon",
|
|
65
|
+
"tokens",
|
|
66
|
+
"neutralTint"
|
|
45
67
|
];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { ThemeColors } from '../types/index.js';
|
|
2
|
-
export declare function generateThemeVars(mode: string, colors: ThemeColors): string;
|
|
1
|
+
import type { ContrastLevel, ThemeColors } from '../types/index.js';
|
|
2
|
+
export declare function generateThemeVars(mode: string, colors: ThemeColors, contrast?: ContrastLevel): string;
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { getThemeHexColors } from "../utils/theme-resolve.js";
|
|
2
|
-
|
|
2
|
+
import { tokensEnabled } from "../token-names.js";
|
|
3
|
+
import { generateTokenVars } from "./tokens.js";
|
|
4
|
+
export function generateThemeVars(mode, colors, contrast) {
|
|
3
5
|
const colorVars = getThemeHexColors(colors).map(([key, value]) => ` --color-${key}: ${value};`).join("\n");
|
|
6
|
+
const tokenVars = tokensEnabled(colors) ? `
|
|
7
|
+
/* Semantic tokens */
|
|
8
|
+
${generateTokenVars(colors, contrast)}` : "";
|
|
4
9
|
const isDark = colors.dark === true;
|
|
5
10
|
const colorScheme = isDark ? "dark" : "light";
|
|
6
11
|
const inverseColor = isDark ? "#FFFFFF" : "#000000";
|
|
@@ -13,7 +18,7 @@ export function generateThemeVars(mode, colors) {
|
|
|
13
18
|
color-scheme: ${colorScheme};
|
|
14
19
|
--color-scheme: ${colorScheme === "dark" ? "#000000" : "#FFFFFF"};
|
|
15
20
|
--color-inverse: ${inverseColor};
|
|
16
|
-
` + colorVars + `
|
|
21
|
+
` + colorVars + tokenVars + `
|
|
17
22
|
}
|
|
18
23
|
`;
|
|
19
24
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CursorType } from '../types/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* A cursor drawn in a theme's color, as a `data:` URI ready for `url()`:
|
|
4
|
+
* a black outline, so it reads on light and dark backgrounds alike, and a
|
|
5
|
+
* soft highlight on the upper half that keeps flat colors from looking dull.
|
|
6
|
+
*/
|
|
7
|
+
export declare function generateCursorSVG(type: CursorType, color: string): {
|
|
8
|
+
url: string;
|
|
9
|
+
hotspot: string;
|
|
10
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const SHAPES = {
|
|
2
|
+
default: {
|
|
3
|
+
hotspot: "3 2",
|
|
4
|
+
shape: `<path d='M3 2v22l5.5-5 4 9.5 3.5-1.5-4-9h7.5z'/>`
|
|
5
|
+
},
|
|
6
|
+
// Traced from a high-resolution render of the module's fire hand
|
|
7
|
+
// (cursor-hand.png): index finger up, the other three stepping down to the
|
|
8
|
+
// right, the thumb out to the left. The gaps between fingers are deepened a
|
|
9
|
+
// little, or the outline would fill them at cursor size, and the index finger is
|
|
10
|
+
// slimmer (4px), so its tip doesn't look swollen inside the outline.
|
|
11
|
+
pointer: {
|
|
12
|
+
hotspot: "11 1",
|
|
13
|
+
shape: `<path d='M9 4.4C9 3.1 9.9 2.2 11 2.2s2 .9 2 2.2v4.2l.5.1c1-.7 3.8-.8 3.8 1.4.2-.9 3.9-1.2 4 1.3.2-.6 4.2-.6 4.2 2.2V21c0 2.5-.7 4.5-2 5.8C22 28.5 19 29 16 29c-2.5 0-4.6-.8-5.7-2.5l-2.8-5.2-3.2-3.7c-1-1.2-.7-3 .3-3.6 1-.7 2.4-.4 3.2.3l1.2.9z'/>`,
|
|
14
|
+
details: `<path d='M13.1 8.8v3.7M17.3 10.1l-.2 3.4M21.3 11.3l-.2 3.2'/>`
|
|
15
|
+
},
|
|
16
|
+
text: {
|
|
17
|
+
hotspot: "16 16",
|
|
18
|
+
shape: `<path d='M11 3h10a1 1 0 0 1 0 3h-3.5v20H21a1 1 0 0 1 0 3H11a1 1 0 0 1 0-3h3.5V6H11a1 1 0 0 1 0-3z'/>`
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
const SIZE = 28;
|
|
22
|
+
const scaleHotspot = (hotspot) => hotspot.split(" ").map((n) => Math.round(Number(n) * SIZE / 32)).join(" ");
|
|
23
|
+
const encodeSVG = (svg) => svg.replace(/[%#<>]/g, (char) => encodeURIComponent(char));
|
|
24
|
+
export function generateCursorSVG(type, color) {
|
|
25
|
+
const { hotspot, shape, details } = SHAPES[type];
|
|
26
|
+
const svg = `<svg xmlns='http://www.w3.org/2000/svg' width='${SIZE}' height='${SIZE}' viewBox='0 0 32 32'><defs><g id='c'>${shape}</g><linearGradient id='s' x2='0' y2='1'><stop stop-color='white' stop-opacity='.45'/><stop offset='.6' stop-color='white' stop-opacity='0'/></linearGradient></defs><use href='#c' stroke='black' stroke-width='3' stroke-linejoin='round'/><use href='#c' fill='${color}'/><use href='#c' fill='url(#s)'/>` + (details ? `<g fill='none' stroke='black' stroke-opacity='.5' stroke-linecap='round'>${details}</g>` : "") + `</svg>`;
|
|
27
|
+
return { url: `data:image/svg+xml,${encodeSVG(svg)}`, hotspot: scaleHotspot(hotspot) };
|
|
28
|
+
}
|
|
@@ -1,21 +1,125 @@
|
|
|
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 VUETIFY_DEFAULT = [
|
|
6
|
+
".v-text-field__prefix, .v-text-field__suffix",
|
|
7
|
+
".v-slider .v-slider__container input",
|
|
8
|
+
".v-time-picker-clock__item",
|
|
9
|
+
".v-file-upload-dropzone--has-files:not(.v-file-upload-dropzone--clickable), .v-file-upload-dropzone--readonly"
|
|
10
|
+
];
|
|
11
|
+
const VUETIFY_POINTER = [
|
|
12
|
+
// Clickable components Vuetify marks with a class (a plain `.v-icon` or
|
|
13
|
+
// `.v-list-item` is often just decoration or text)
|
|
14
|
+
".v-btn:not(.v-btn--disabled)",
|
|
15
|
+
".v-icon--clickable",
|
|
16
|
+
".v-icon-btn",
|
|
17
|
+
".v-list-item--link",
|
|
18
|
+
".v-chip--link",
|
|
19
|
+
".v-chip__close",
|
|
20
|
+
".v-tab",
|
|
21
|
+
".v-card--link",
|
|
22
|
+
".v-card--hover",
|
|
23
|
+
".v-breadcrumbs-item--link",
|
|
24
|
+
".v-pagination__item",
|
|
25
|
+
".v-slide-group__next, .v-slide-group__prev",
|
|
26
|
+
".v-avatar-group--hoverable .v-avatar",
|
|
27
|
+
// Menu activators and the like
|
|
28
|
+
"[aria-controls]",
|
|
29
|
+
// Tables
|
|
30
|
+
".v-data-table__tr--clickable",
|
|
31
|
+
".v-data-table__th--sortable",
|
|
32
|
+
// Form controls
|
|
33
|
+
".v-field__clearable",
|
|
34
|
+
".v-select .v-field .v-text-field__prefix, .v-select .v-field .v-text-field__suffix, .v-select .v-field .v-field__input, .v-select .v-field.v-field",
|
|
35
|
+
".v-label--clickable",
|
|
36
|
+
".v-selection-control__input input",
|
|
37
|
+
".v-switch__track",
|
|
38
|
+
".v-slider__container",
|
|
39
|
+
".v-slider-thumb__surface",
|
|
40
|
+
".v-rating__item label",
|
|
41
|
+
".v-file-upload-dropzone--clickable:not(.v-file-upload-dropzone--readonly)",
|
|
42
|
+
".v-file-upload-dropzone input[type=file]",
|
|
43
|
+
// Pickers
|
|
44
|
+
".v-date-picker-header--clickable .v-date-picker-header__content",
|
|
45
|
+
".v-color-picker-swatches__color",
|
|
46
|
+
// Calendar
|
|
47
|
+
".v-calendar .v-event, .v-calendar .v-event-more, .v-calendar .v-event-timed",
|
|
48
|
+
".v-calendar-weekly__day-label",
|
|
49
|
+
".v-calendar-daily_head-day-label",
|
|
50
|
+
".v-calendar-daily .v-calendar-daily__day-interval--hover",
|
|
51
|
+
// Labs
|
|
52
|
+
".v-heatmap--hover .v-heatmap__cell",
|
|
53
|
+
".v-heatmap-legend > .v-heatmap-legend__cell",
|
|
54
|
+
".v-media-progress-bar--interactive",
|
|
55
|
+
".v-video:not(.v-video--error) .v-video__content"
|
|
56
|
+
];
|
|
57
|
+
const VUETIFY_TEXT = [
|
|
58
|
+
".v-text-field .v-field",
|
|
59
|
+
".v-autocomplete .v-field .v-text-field__prefix, .v-autocomplete .v-field .v-text-field__suffix, .v-autocomplete .v-field .v-field__input, .v-autocomplete .v-field.v-field",
|
|
60
|
+
".v-combobox .v-field .v-text-field__prefix, .v-combobox .v-field .v-text-field__suffix, .v-combobox .v-field .v-field__input, .v-combobox .v-field.v-field"
|
|
61
|
+
];
|
|
62
|
+
const rule = (selectors, type) => `${selectors.join(",\n")} {
|
|
63
|
+
cursor: var(--cursor-${type});
|
|
64
|
+
}
|
|
65
|
+
`;
|
|
66
|
+
const imageValue = (image, type) => `url('${image.path}')${image.hotspot ? ` ${image.hotspot}` : ""}, ${type}`;
|
|
1
67
|
export function generateCustomCursorCSS(theme) {
|
|
2
68
|
const cursor = theme.customCursor;
|
|
3
|
-
if (!cursor || !cursor.enabled
|
|
4
|
-
const
|
|
69
|
+
if (!cursor || !cursor.enabled) return "";
|
|
70
|
+
const images = cursor.defaultCursors ?? {};
|
|
71
|
+
const fallback = (type) => images[type] ? imageValue(images[type], type) : type;
|
|
72
|
+
const owners = {};
|
|
73
|
+
for (const [name, group] of Object.entries(theme.colors?.groups ?? {})) {
|
|
74
|
+
for (const id of Object.values(group.variants)) if (id) owners[id] = name;
|
|
75
|
+
}
|
|
76
|
+
const variants = [];
|
|
77
|
+
if (theme.colors?.enabled !== false) {
|
|
78
|
+
for (const [id, colors] of Object.entries(theme.colors?.themes ?? {})) {
|
|
79
|
+
if (id === "system" || !isColorTheme(colors)) continue;
|
|
80
|
+
const entry = cursor.themeCursors?.[id] ?? (owners[id] ? cursor.themeCursors?.[owners[id]] : void 0);
|
|
81
|
+
const own = typeof entry === "object" ? entry : {};
|
|
82
|
+
const mode = typeof entry === "string" ? entry : cursor.themed === false ? "base" : "themed";
|
|
83
|
+
const values = {};
|
|
84
|
+
for (const type of CURSOR_TYPES) {
|
|
85
|
+
const image = own[type];
|
|
86
|
+
if (image) {
|
|
87
|
+
values[type] = imageValue(image, type);
|
|
88
|
+
} else if (mode === "none") {
|
|
89
|
+
values[type] = type;
|
|
90
|
+
} else if (mode === "themed" && colors.primary?.startsWith("#")) {
|
|
91
|
+
const { url, hotspot } = generateCursorSVG(type, colors.primary);
|
|
92
|
+
values[type] = `url("${url}") ${hotspot}, ${fallback(type)}`;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (Object.keys(values).length) variants.push([id, values]);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
const types = CURSOR_TYPES.filter((type) => images[type] || variants.some(([, values]) => values[type]));
|
|
99
|
+
if (!types.length) return "";
|
|
5
100
|
let css = "\n/* ============================================ */\n";
|
|
6
101
|
css += "/* Custom Cursor */\n";
|
|
7
102
|
css += "/* ============================================ */\n";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
103
|
+
css += "\n/* 0. Cursor values: the default cursors, then each theme's own (drawn in its color, its images or the system's) */\n";
|
|
104
|
+
css += `:root {
|
|
105
|
+
${types.map((type) => ` --cursor-${type}: ${fallback(type)};`).join("\n")}
|
|
106
|
+
}
|
|
107
|
+
`;
|
|
108
|
+
for (const [id, values] of variants) {
|
|
109
|
+
const vars = types.filter((type) => values[type]).map((type) => ` --cursor-${type}: ${values[type]};`);
|
|
110
|
+
css += `:root[data-theme='${id}'] {
|
|
111
|
+
${vars.join("\n")}
|
|
112
|
+
}
|
|
113
|
+
`;
|
|
114
|
+
}
|
|
115
|
+
css += `:root[${CURSOR_ATTRIBUTE}='off'] {
|
|
116
|
+
${types.map((type) => ` --cursor-${type}: ${type};`).join("\n")}
|
|
117
|
+
}
|
|
118
|
+
`;
|
|
119
|
+
if (types.includes("default")) {
|
|
16
120
|
css += "\n/* 1. Default cursor on everything */\n";
|
|
17
121
|
css += `html {
|
|
18
|
-
cursor:
|
|
122
|
+
cursor: var(--cursor-default);
|
|
19
123
|
}
|
|
20
124
|
`;
|
|
21
125
|
css += "\n/* 1b. Elements the browser stylesheet sets to `cursor: default`, which would show the system arrow instead of inheriting */\n";
|
|
@@ -23,33 +127,30 @@ export function generateCustomCursorCSS(theme) {
|
|
|
23
127
|
select,
|
|
24
128
|
input[type="checkbox"], input[type="radio"],
|
|
25
129
|
input[type="range"], input[type="color"], input[type="file"] {
|
|
26
|
-
cursor:
|
|
130
|
+
cursor: var(--cursor-default);
|
|
27
131
|
}
|
|
28
132
|
`;
|
|
133
|
+
css += "\n/* 1c. Vuetify elements with a fixed `cursor: default` */\n";
|
|
134
|
+
css += rule(VUETIFY_DEFAULT, "default");
|
|
29
135
|
}
|
|
30
|
-
if (
|
|
31
|
-
const value = cursorValue("pointer");
|
|
136
|
+
if (types.includes("pointer")) {
|
|
32
137
|
css += "\n/* 2. Pointer cursor for clickable elements */\n";
|
|
33
|
-
css += `a, a *,
|
|
138
|
+
css += `a[href], a[href] *,
|
|
34
139
|
button, button *,
|
|
35
|
-
|
|
140
|
+
summary,
|
|
141
|
+
[role="button"], [role="link"], [role="tab"],
|
|
36
142
|
input[type="button"], input[type="submit"], input[type="reset"],
|
|
37
|
-
.
|
|
38
|
-
|
|
39
|
-
.v-icon,
|
|
40
|
-
.v-tab,
|
|
41
|
-
.v-chip,
|
|
42
|
-
.v-card--link,
|
|
43
|
-
.v-breadcrumbs-item--link,
|
|
44
|
-
.v-pagination__item {
|
|
45
|
-
cursor: ${value} !important;
|
|
143
|
+
.os-scrollbar, .os-scrollbar * {
|
|
144
|
+
cursor: var(--cursor-pointer) !important;
|
|
46
145
|
}
|
|
47
146
|
`;
|
|
147
|
+
css += "\n/* 2b. Vuetify elements with a fixed `cursor: pointer` */\n";
|
|
148
|
+
css += rule(VUETIFY_POINTER, "pointer");
|
|
48
149
|
}
|
|
49
|
-
if (
|
|
50
|
-
const value = cursorValue("text");
|
|
150
|
+
if (types.includes("text")) {
|
|
51
151
|
css += "\n/* 3. Text cursor (i-beam) for editable fields only */\n";
|
|
52
|
-
css += `input[type
|
|
152
|
+
css += `input:not([type]),
|
|
153
|
+
input[type="text"],
|
|
53
154
|
input[type="email"],
|
|
54
155
|
input[type="password"],
|
|
55
156
|
input[type="number"],
|
|
@@ -62,18 +163,26 @@ input[type="month"],
|
|
|
62
163
|
input[type="week"],
|
|
63
164
|
input[type="time"],
|
|
64
165
|
textarea,
|
|
65
|
-
[contenteditable="true"] {
|
|
66
|
-
cursor:
|
|
166
|
+
[contenteditable=""], [contenteditable="true"], [contenteditable="plaintext-only"] {
|
|
167
|
+
cursor: var(--cursor-text) !important;
|
|
67
168
|
}
|
|
68
169
|
`;
|
|
170
|
+
css += "\n/* 3b. Vuetify elements with a fixed `cursor: text` (the field around the input) */\n";
|
|
171
|
+
css += rule(VUETIFY_TEXT, "text");
|
|
69
172
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
.
|
|
76
|
-
|
|
173
|
+
css += "\n/* 4. Cursor utility classes */\n";
|
|
174
|
+
css += types.map((type) => `html .cursor-${type} {
|
|
175
|
+
cursor: var(--cursor-${type});
|
|
176
|
+
}
|
|
177
|
+
`).join("");
|
|
178
|
+
if (types.includes("default")) {
|
|
179
|
+
css += "\n/* 5. Disabled elements, and what they contain */\n";
|
|
180
|
+
css += `html :disabled, html :disabled *,
|
|
181
|
+
html [disabled], html [disabled] *,
|
|
182
|
+
html [aria-disabled="true"], html [aria-disabled="true"] *,
|
|
183
|
+
html .disabled,
|
|
184
|
+
html .v-btn--disabled, html .v-btn--disabled * {
|
|
185
|
+
cursor: var(--cursor-default) !important;
|
|
77
186
|
}
|
|
78
187
|
`;
|
|
79
188
|
}
|
package/dist/shared/css/index.js
CHANGED
|
@@ -15,7 +15,7 @@ export function processTheme(theme) {
|
|
|
15
15
|
output.push(generateThemeTransitionCSS());
|
|
16
16
|
for (const [themeName, themeColors] of Object.entries(theme.colors.themes)) {
|
|
17
17
|
if (themeName === "system" || !isColorTheme(themeColors)) continue;
|
|
18
|
-
output.push(generateThemeVars(themeName, themeColors));
|
|
18
|
+
output.push(generateThemeVars(themeName, themeColors, theme.colors.contrast || void 0));
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
}
|
|
@@ -1,3 +1,12 @@
|
|
|
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}`;
|
|
5
|
+
const SURFACE_TOKENS = {
|
|
6
|
+
background: "bg",
|
|
7
|
+
background2: "bg-subtle",
|
|
8
|
+
background3: "bg-muted"
|
|
9
|
+
};
|
|
1
10
|
export function generateCustomScrollbarCSS(theme) {
|
|
2
11
|
const scrollbar = theme.customScrollbar;
|
|
3
12
|
if (!scrollbar || !scrollbar.enabled) return "";
|
|
@@ -9,7 +18,8 @@ export function generateCustomScrollbarCSS(theme) {
|
|
|
9
18
|
if (value.startsWith("var(--") || value.startsWith("#") || value.startsWith("rgb")) {
|
|
10
19
|
return value;
|
|
11
20
|
}
|
|
12
|
-
|
|
21
|
+
const token = SURFACE_TOKENS[value];
|
|
22
|
+
return token ? `var(--color-${value}, var(--jade-${token}))` : `var(--color-${value})`;
|
|
13
23
|
};
|
|
14
24
|
const thumb = colorVar("thumb", "primary");
|
|
15
25
|
const thumbHover = colorVar("thumbHover", "secondary");
|
|
@@ -19,32 +29,82 @@ export function generateCustomScrollbarCSS(theme) {
|
|
|
19
29
|
css += "/* Custom Scrollbar */\n";
|
|
20
30
|
css += "/* ============================================ */\n";
|
|
21
31
|
css += `
|
|
22
|
-
::-webkit-scrollbar {
|
|
32
|
+
${on("::-webkit-scrollbar")} {
|
|
23
33
|
width: ${width};
|
|
24
34
|
height: ${width};
|
|
25
35
|
}
|
|
26
36
|
`;
|
|
27
37
|
css += `
|
|
28
|
-
::-webkit-scrollbar-track {
|
|
38
|
+
${on("::-webkit-scrollbar-track")} {
|
|
29
39
|
background: ${track};
|
|
30
40
|
}
|
|
31
41
|
`;
|
|
32
42
|
css += `
|
|
33
|
-
::-webkit-scrollbar-thumb {
|
|
43
|
+
${on("::-webkit-scrollbar-thumb")} {
|
|
34
44
|
background: ${thumb};
|
|
35
45
|
border-radius: ${borderRadius};
|
|
36
46
|
border: ${borderWidth} solid ${border};
|
|
47
|
+
/* The custom pointer: Chromium draws a styled scrollbar as part of the
|
|
48
|
+
page and shows its cursor there. The arrow without the cursor module. */
|
|
49
|
+
cursor: var(--cursor-pointer, default);
|
|
37
50
|
}
|
|
38
51
|
`;
|
|
39
52
|
css += `
|
|
40
|
-
::-webkit-scrollbar-thumb:hover {
|
|
53
|
+
${on("::-webkit-scrollbar-thumb:hover")} {
|
|
41
54
|
background: ${thumbHover};
|
|
42
55
|
}
|
|
43
56
|
`;
|
|
44
57
|
css += `
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
58
|
+
${on("::-webkit-scrollbar-corner")} {
|
|
59
|
+
background: ${track};
|
|
60
|
+
}
|
|
61
|
+
`;
|
|
62
|
+
css += `
|
|
63
|
+
@supports not selector(::-webkit-scrollbar) {
|
|
64
|
+
${ON} {
|
|
65
|
+
scrollbar-width: ${width === "auto" ? "auto" : "thin"};
|
|
66
|
+
scrollbar-color: ${thumb} ${track};
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
`;
|
|
70
|
+
if (scrollbar.overlay === true) css += generateOverlayScrollbarCSS({ width, borderRadius, thumb, thumbHover, track });
|
|
71
|
+
return css;
|
|
72
|
+
}
|
|
73
|
+
function generateOverlayScrollbarCSS(o) {
|
|
74
|
+
let css = "\n/* Overlay scrollbar (OverlayScrollbars): page elements, so the custom cursor applies over them */\n";
|
|
75
|
+
css += `.${OVERLAY_SCROLLBAR_THEME} {
|
|
76
|
+
--os-size: ${o.width === "auto" ? "10px" : o.width};
|
|
77
|
+
--os-padding-perpendicular: 2px;
|
|
78
|
+
--os-padding-axis: 2px;
|
|
79
|
+
--os-track-border-radius: ${o.borderRadius};
|
|
80
|
+
--os-handle-border-radius: ${o.borderRadius};
|
|
81
|
+
--os-track-bg: ${o.track};
|
|
82
|
+
--os-handle-bg: ${o.thumb};
|
|
83
|
+
--os-handle-bg-hover: ${o.thumbHover};
|
|
84
|
+
--os-handle-bg-active: ${o.thumbHover};
|
|
85
|
+
}
|
|
86
|
+
`;
|
|
87
|
+
css += `
|
|
88
|
+
.${OVERLAY_SCROLLBAR_THEME}.os-scrollbar:hover {
|
|
89
|
+
--os-handle-bg: ${o.thumbHover};
|
|
90
|
+
}
|
|
91
|
+
`;
|
|
92
|
+
css += `
|
|
93
|
+
.v-table > .os-scrollbar {
|
|
94
|
+
z-index: 3;
|
|
95
|
+
}
|
|
96
|
+
`;
|
|
97
|
+
css += `
|
|
98
|
+
html[data-overlayscrollbars].v-overlay-scroll-blocked {
|
|
99
|
+
top: auto;
|
|
100
|
+
left: auto;
|
|
101
|
+
}
|
|
102
|
+
`;
|
|
103
|
+
css += `
|
|
104
|
+
@media (scripting: enabled) {
|
|
105
|
+
${ON}:not([data-overlayscrollbars]) {
|
|
106
|
+
scrollbar-width: none;
|
|
107
|
+
}
|
|
48
108
|
}
|
|
49
109
|
`;
|
|
50
110
|
return css;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { ContrastLevel, ThemeColors } from '../types/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* `[name, hex]` pairs, without the `--jade-` prefix, in the order they are
|
|
4
|
+
* written. Memoized: the CSS and the build check ask for the same variant.
|
|
5
|
+
*/
|
|
6
|
+
export declare function generateTokens(colors: ThemeColors, level?: ContrastLevel): Array<[string, string]>;
|
|
7
|
+
/** The `--jade-*` declarations for `generateTokens`, one per line, indented for a theme block. */
|
|
8
|
+
export declare function generateTokenVars(colors: ThemeColors, level?: ContrastLevel): string;
|
|
9
|
+
/**
|
|
10
|
+
* The tokens of every variant with `tokens: true`, by variant id and token
|
|
11
|
+
* name, as plain hex values — what the runtime config carries so the client
|
|
12
|
+
* can read them without the color engine.
|
|
13
|
+
*/
|
|
14
|
+
export declare function collectTokens(themes: Record<string, ThemeColors>, level?: ContrastLevel): Record<string, Record<string, string>>;
|
|
15
|
+
export interface TokenContrastIssue {
|
|
16
|
+
/** The token used as text or outline. */
|
|
17
|
+
text: string;
|
|
18
|
+
/** The token it sits on. */
|
|
19
|
+
surface: string;
|
|
20
|
+
ratio: number;
|
|
21
|
+
min: number;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The pairs that fall short of `level`: text 4.5:1 (7:1 for AAA), outlines
|
|
25
|
+
* 3:1. A pair is skipped when either token doesn't exist (a theme without
|
|
26
|
+
* `secondary` has no `text-secondary`).
|
|
27
|
+
*/
|
|
28
|
+
export declare function checkTokenContrast(tokens: Array<[string, string]>, level: ContrastLevel): TokenContrastIssue[];
|
|
29
|
+
/**
|
|
30
|
+
* One build warning per token theme variant with pairs below `level`, or an
|
|
31
|
+
* empty list when everything passes. Variants without tokens are skipped.
|
|
32
|
+
*/
|
|
33
|
+
export declare function findTokenContrastIssues(themes: Record<string, ThemeColors>, level: ContrastLevel): string[];
|
|
34
|
+
/**
|
|
35
|
+
* One build warning per token theme variant whose `tokens` overrides name an
|
|
36
|
+
* unknown token (or `on-<role>`), a step that doesn't exist, or a role the
|
|
37
|
+
* variant has no seed for. Those entries are ignored, so the warning is the
|
|
38
|
+
* only sign.
|
|
39
|
+
*/
|
|
40
|
+
export declare function findTokenOverrideIssues(themes: Record<string, ThemeColors>): string[];
|