vueless 1.2.12 → 1.2.13-beta.5
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 +18 -24
- package/bin/constants.d.ts +1 -1
- package/bin/constants.js +1 -0
- package/constants.d.ts +2 -0
- package/constants.js +2 -0
- package/index.d.ts +1 -0
- package/index.ts +1 -0
- package/package.json +1 -1
- package/tailwind.css +3 -0
- package/types.ts +6 -1
- package/utils/theme.ts +34 -3
package/README.md
CHANGED
|
@@ -1,43 +1,35 @@
|
|
|
1
|
-

|
|
2
2
|
|
|
3
3
|
# Vueless UI
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
A UI library with Open Architecture for Vue.js 3 and Nuxt.js 3 / 4, powered by [Storybook v9](https://storybook.js.org) and [Tailwind CSS v4](https://tailwindcss.com).
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
**With Vueless UI, you’re free to:**
|
|
8
|
+
- 🪄️ Customize any component
|
|
9
|
+
- 📋 Copy and extend existing ones
|
|
10
|
+
- 🧱 Build your own from scratch
|
|
11
|
+
- 📕 Document it all seamlessly in Storybook
|
|
10
12
|
|
|
11
13
|
[Documentation](https://docs.vueless.com/) | [UI Components](https://ui.vueless.com/) | [Website](http://vueless.com/)
|
|
12
14
|
|
|
13
15
|
### Key features
|
|
14
16
|
|
|
15
|
-
- 🧩 65+ UI components (including range date picker, multi-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
- 🌈 Beautiful
|
|
19
|
-
- 🌗 Light and dark mode support
|
|
17
|
+
- 🧩 65+ crafted UI components (including range date picker, multi-select, and nested table)
|
|
18
|
+
- ✨ Open Architecture lets you customize, copy, extend, and create your own components
|
|
19
|
+
- 📕 Built-in Storybook support
|
|
20
|
+
- 🌈 Beautiful default UI theme
|
|
20
21
|
- 🌀 Unstyled mode
|
|
21
|
-
-
|
|
22
|
-
- 🎛️ Runtime theme and color switching
|
|
22
|
+
- 🌗 Light and dark mode
|
|
23
23
|
- 🧬 Design tokens powered by CSS variables
|
|
24
|
-
-
|
|
24
|
+
- ⚙️ Server-side rendering (SSR)
|
|
25
25
|
- 🌍 Internationalization (i18n)
|
|
26
26
|
- ♿️ Accessibility (a11y)
|
|
27
|
-
-
|
|
28
|
-
-
|
|
27
|
+
- 🖼️ Inline SVG icons
|
|
28
|
+
- 🪄 Auto component imports (as you use them)
|
|
29
|
+
- 🧿 Uncompiled source in npm for better DX
|
|
29
30
|
- 🧪️ 1300+ unit tests ensuring consistent logic
|
|
30
31
|
- 🛡️ Full TypeScript support with type safety
|
|
31
32
|
|
|
32
|
-
### Advanced Features
|
|
33
|
-
|
|
34
|
-
- 🧰 Copy and extend existing components
|
|
35
|
-
- 🧱 Create your own components
|
|
36
|
-
- 🔧️ Define default values for props
|
|
37
|
-
- 🔩️ Add or hide props to components
|
|
38
|
-
- 🧿 `npm` package ships full source without TypeScript transpilation for better DX.
|
|
39
|
-
|
|
40
|
-
|
|
41
33
|
## Quick Start (Vue)
|
|
42
34
|
|
|
43
35
|
### New project
|
|
@@ -50,6 +42,8 @@ npm create vueless@latest
|
|
|
50
42
|
|
|
51
43
|
This command guides you through a few setup options, then generates a new scaffolded Vue + Vueless UI project with the complete application structure.
|
|
52
44
|
|
|
45
|
+
---
|
|
46
|
+
|
|
53
47
|
### Existing project
|
|
54
48
|
|
|
55
49
|
1. Install `vueless` UI library packages.
|
package/bin/constants.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const DEFAULT_VUELESS_CONFIG_CONTENT: "import { componentConfigs } from \"./.vueless\";\n\nexport default {\n /**\n * Global settings.\n */\n primary: \"grayscale\",\n neutral: \"gray\",\n text: 14,\n outline: 2,\n rounding: 8,\n letterSpacing: 0,\n disabledOpacity: 50,\n colorMode: \"auto\",\n\n /**\n * Component settings.\n */\n components: /*tw*/ {\n ...componentConfigs,\n },\n\n /**\n * Directive settings.\n */\n directives: {},\n\n /**\n * Light theme CSS variable settings.\n */\n lightTheme: {\n /* Primary colors */\n \"--vl-primary\": \"--vl-primary-600\",\n \"--vl-primary-lifted\": \"--vl-primary-700\",\n \"--vl-primary-accented\": \"--vl-primary-800\",\n\n /* Secondary colors */\n \"--vl-secondary\": \"--vl-neutral-500\",\n \"--vl-secondary-lifted\": \"--vl-neutral-600\",\n \"--vl-secondary-accented\": \"--vl-neutral-700\",\n\n /* Success colors */\n \"--vl-success\": \"--color-green-600\",\n \"--vl-success-lifted\": \"--color-green-700\",\n \"--vl-success-accented\": \"--color-green-800\",\n\n /* Info colors */\n \"--vl-info\": \"--color-blue-600\",\n \"--vl-info-lifted\": \"--color-blue-700\",\n \"--vl-info-accented\": \"--color-blue-800\",\n\n /* Notice colors */\n \"--vl-notice\": \"--color-violet-600\",\n \"--vl-notice-lifted\": \"--color-violet-700\",\n \"--vl-notice-accented\": \"--color-violet-800\",\n\n /* Warning colors */\n \"--vl-warning\": \"--color-orange-600\",\n \"--vl-warning-lifted\": \"--color-orange-700\",\n \"--vl-warning-accented\": \"--color-orange-800\",\n\n /* Error colors */\n \"--vl-error\": \"--color-red-600\",\n \"--vl-error-lifted\": \"--color-red-700\",\n \"--vl-error-accented\": \"--color-red-800\",\n\n /* Grayscale colors */\n \"--vl-grayscale\": \"--vl-neutral-900\",\n \"--vl-grayscale-lifted\": \"--vl-neutral-800\",\n \"--vl-grayscale-accented\": \"--vl-neutral-700\",\n\n /* Neutral colors */\n \"--vl-neutral\": \"--vl-neutral-500\",\n \"--vl-neutral-lifted\": \"--vl-neutral-600\",\n \"--vl-neutral-accented\": \"--vl-neutral-700\",\n\n /* Text neutral colors */\n \"--vl-text-inverted\": \"--color-white\",\n \"--vl-text-muted\": \"--vl-neutral-400\",\n \"--vl-text-lifted\": \"--vl-neutral-500\",\n \"--vl-text-accented\": \"--vl-neutral-600\",\n \"--vl-text\": \"--vl-neutral-900\",\n\n /* Border neutral colors */\n \"--vl-border-muted\": \"--vl-neutral-200\",\n \"--vl-border\": \"--vl-neutral-300\",\n \"--vl-border-lifted\": \"--vl-neutral-400\",\n \"--vl-border-accented\": \"--vl-neutral-600\",\n\n /* Background neutral colors */\n \"--vl-bg\": \"--color-white\",\n \"--vl-bg-muted\": \"--vl-neutral-50\",\n \"--vl-bg-lifted\": \"--vl-neutral-100\",\n \"--vl-bg-accented\": \"--vl-neutral-200\",\n \"--vl-bg-inverted\": \"--vl-neutral-900\",\n },\n\n /**\n * Dark theme CSS variable settings.\n */\n darkTheme: {\n /* Primary colors */\n \"--vl-primary\": \"--vl-primary-400\",\n \"--vl-primary-lifted\": \"--vl-primary-500\",\n \"--vl-primary-accented\": \"--vl-primary-600\",\n\n /* Secondary colors */\n \"--vl-secondary\": \"--vl-neutral-300\",\n \"--vl-secondary-lifted\": \"--vl-neutral-400\",\n \"--vl-secondary-accented\": \"--vl-neutral-500\",\n\n /* Success colors */\n \"--vl-success\": \"--color-green-400\",\n \"--vl-success-lifted\": \"--color-green-500\",\n \"--vl-success-accented\": \"--color-green-600\",\n\n /* Info colors */\n \"--vl-info\": \"--color-blue-400\",\n \"--vl-info-lifted\": \"--color-blue-500\",\n \"--vl-info-accented\": \"--color-blue-600\",\n\n /* Notice colors */\n \"--vl-notice\": \"--color-violet-400\",\n \"--vl-notice-lifted\": \"--color-violet-500\",\n \"--vl-notice-accented\": \"--color-violet-600\",\n\n /* Warning colors */\n \"--vl-warning\": \"--color-orange-400\",\n \"--vl-warning-lifted\": \"--color-orange-500\",\n \"--vl-warning-accented\": \"--color-orange-600\",\n\n /* Error colors */\n \"--vl-error\": \"--color-red-400\",\n \"--vl-error-lifted\": \"--color-red-500\",\n \"--vl-error-accented\": \"--color-red-600\",\n\n /* Grayscale colors */\n \"--vl-grayscale\": \"--vl-neutral-100\",\n \"--vl-grayscale-lifted\": \"--vl-neutral-200\",\n \"--vl-grayscale-accented\": \"--vl-neutral-300\",\n\n /* Neutral colors */\n \"--vl-neutral\": \"--vl-neutral-300\",\n \"--vl-neutral-lifted\": \"--vl-neutral-400\",\n \"--vl-neutral-accented\": \"--vl-neutral-500\",\n\n /* Text neutral colors */\n \"--vl-text-inverted\": \"--vl-neutral-900\",\n \"--vl-text-muted\": \"--vl-neutral-600\",\n \"--vl-text-lifted\": \"--vl-neutral-400\",\n \"--vl-text-accented\": \"--vl-neutral-300\",\n \"--vl-text\": \"--vl-neutral-100\",\n\n /* Border neutral colors */\n \"--vl-border-muted\": \"--vl-neutral-800\",\n \"--vl-border\": \"--vl-neutral-700\",\n \"--vl-border-lifted\": \"--vl-neutral-600\",\n \"--vl-border-accented\": \"--vl-neutral-400\",\n\n /* Background neutral colors */\n \"--vl-bg\": \"--vl-neutral-900\",\n \"--vl-bg-muted\": \"--vl-neutral-800\",\n \"--vl-bg-lifted\": \"--vl-neutral-800\",\n \"--vl-bg-accented\": \"--vl-neutral-700\",\n \"--vl-bg-inverted\": \"--vl-neutral-100\",\n },\n};\n";
|
|
1
|
+
export const DEFAULT_VUELESS_CONFIG_CONTENT: "import { componentConfigs } from \"./.vueless\";\n\nexport default {\n /**\n * Global settings.\n */\n primary: \"grayscale\",\n neutral: \"gray\",\n text: 14,\n outline: 2,\n rounding: 8,\n spacing: 8,\n letterSpacing: 0,\n disabledOpacity: 50,\n colorMode: \"auto\",\n\n /**\n * Component settings.\n */\n components: /*tw*/ {\n ...componentConfigs,\n },\n\n /**\n * Directive settings.\n */\n directives: {},\n\n /**\n * Light theme CSS variable settings.\n */\n lightTheme: {\n /* Primary colors */\n \"--vl-primary\": \"--vl-primary-600\",\n \"--vl-primary-lifted\": \"--vl-primary-700\",\n \"--vl-primary-accented\": \"--vl-primary-800\",\n\n /* Secondary colors */\n \"--vl-secondary\": \"--vl-neutral-500\",\n \"--vl-secondary-lifted\": \"--vl-neutral-600\",\n \"--vl-secondary-accented\": \"--vl-neutral-700\",\n\n /* Success colors */\n \"--vl-success\": \"--color-green-600\",\n \"--vl-success-lifted\": \"--color-green-700\",\n \"--vl-success-accented\": \"--color-green-800\",\n\n /* Info colors */\n \"--vl-info\": \"--color-blue-600\",\n \"--vl-info-lifted\": \"--color-blue-700\",\n \"--vl-info-accented\": \"--color-blue-800\",\n\n /* Notice colors */\n \"--vl-notice\": \"--color-violet-600\",\n \"--vl-notice-lifted\": \"--color-violet-700\",\n \"--vl-notice-accented\": \"--color-violet-800\",\n\n /* Warning colors */\n \"--vl-warning\": \"--color-orange-600\",\n \"--vl-warning-lifted\": \"--color-orange-700\",\n \"--vl-warning-accented\": \"--color-orange-800\",\n\n /* Error colors */\n \"--vl-error\": \"--color-red-600\",\n \"--vl-error-lifted\": \"--color-red-700\",\n \"--vl-error-accented\": \"--color-red-800\",\n\n /* Grayscale colors */\n \"--vl-grayscale\": \"--vl-neutral-900\",\n \"--vl-grayscale-lifted\": \"--vl-neutral-800\",\n \"--vl-grayscale-accented\": \"--vl-neutral-700\",\n\n /* Neutral colors */\n \"--vl-neutral\": \"--vl-neutral-500\",\n \"--vl-neutral-lifted\": \"--vl-neutral-600\",\n \"--vl-neutral-accented\": \"--vl-neutral-700\",\n\n /* Text neutral colors */\n \"--vl-text-inverted\": \"--color-white\",\n \"--vl-text-muted\": \"--vl-neutral-400\",\n \"--vl-text-lifted\": \"--vl-neutral-500\",\n \"--vl-text-accented\": \"--vl-neutral-600\",\n \"--vl-text\": \"--vl-neutral-900\",\n\n /* Border neutral colors */\n \"--vl-border-muted\": \"--vl-neutral-200\",\n \"--vl-border\": \"--vl-neutral-300\",\n \"--vl-border-lifted\": \"--vl-neutral-400\",\n \"--vl-border-accented\": \"--vl-neutral-600\",\n\n /* Background neutral colors */\n \"--vl-bg\": \"--color-white\",\n \"--vl-bg-muted\": \"--vl-neutral-50\",\n \"--vl-bg-lifted\": \"--vl-neutral-100\",\n \"--vl-bg-accented\": \"--vl-neutral-200\",\n \"--vl-bg-inverted\": \"--vl-neutral-900\",\n },\n\n /**\n * Dark theme CSS variable settings.\n */\n darkTheme: {\n /* Primary colors */\n \"--vl-primary\": \"--vl-primary-400\",\n \"--vl-primary-lifted\": \"--vl-primary-500\",\n \"--vl-primary-accented\": \"--vl-primary-600\",\n\n /* Secondary colors */\n \"--vl-secondary\": \"--vl-neutral-300\",\n \"--vl-secondary-lifted\": \"--vl-neutral-400\",\n \"--vl-secondary-accented\": \"--vl-neutral-500\",\n\n /* Success colors */\n \"--vl-success\": \"--color-green-400\",\n \"--vl-success-lifted\": \"--color-green-500\",\n \"--vl-success-accented\": \"--color-green-600\",\n\n /* Info colors */\n \"--vl-info\": \"--color-blue-400\",\n \"--vl-info-lifted\": \"--color-blue-500\",\n \"--vl-info-accented\": \"--color-blue-600\",\n\n /* Notice colors */\n \"--vl-notice\": \"--color-violet-400\",\n \"--vl-notice-lifted\": \"--color-violet-500\",\n \"--vl-notice-accented\": \"--color-violet-600\",\n\n /* Warning colors */\n \"--vl-warning\": \"--color-orange-400\",\n \"--vl-warning-lifted\": \"--color-orange-500\",\n \"--vl-warning-accented\": \"--color-orange-600\",\n\n /* Error colors */\n \"--vl-error\": \"--color-red-400\",\n \"--vl-error-lifted\": \"--color-red-500\",\n \"--vl-error-accented\": \"--color-red-600\",\n\n /* Grayscale colors */\n \"--vl-grayscale\": \"--vl-neutral-100\",\n \"--vl-grayscale-lifted\": \"--vl-neutral-200\",\n \"--vl-grayscale-accented\": \"--vl-neutral-300\",\n\n /* Neutral colors */\n \"--vl-neutral\": \"--vl-neutral-300\",\n \"--vl-neutral-lifted\": \"--vl-neutral-400\",\n \"--vl-neutral-accented\": \"--vl-neutral-500\",\n\n /* Text neutral colors */\n \"--vl-text-inverted\": \"--vl-neutral-900\",\n \"--vl-text-muted\": \"--vl-neutral-600\",\n \"--vl-text-lifted\": \"--vl-neutral-400\",\n \"--vl-text-accented\": \"--vl-neutral-300\",\n \"--vl-text\": \"--vl-neutral-100\",\n\n /* Border neutral colors */\n \"--vl-border-muted\": \"--vl-neutral-800\",\n \"--vl-border\": \"--vl-neutral-700\",\n \"--vl-border-lifted\": \"--vl-neutral-600\",\n \"--vl-border-accented\": \"--vl-neutral-400\",\n\n /* Background neutral colors */\n \"--vl-bg\": \"--vl-neutral-900\",\n \"--vl-bg-muted\": \"--vl-neutral-800\",\n \"--vl-bg-lifted\": \"--vl-neutral-800\",\n \"--vl-bg-accented\": \"--vl-neutral-700\",\n \"--vl-bg-inverted\": \"--vl-neutral-100\",\n },\n};\n";
|
package/bin/constants.js
CHANGED
package/constants.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export const TEXT: "text";
|
|
|
8
8
|
export const OUTLINE: "outline";
|
|
9
9
|
export const ROUNDING: "rounding";
|
|
10
10
|
export const DISABLED_OPACITY: "disabled-opacity";
|
|
11
|
+
export const SPACING: "spacing";
|
|
11
12
|
export const LETTER_SPACING: "letter-spacing";
|
|
12
13
|
export const LIGHT_THEME: "light-theme";
|
|
13
14
|
export const DARK_THEME: "dark-theme";
|
|
@@ -26,6 +27,7 @@ export const OUTLINE_INCREMENT: 1;
|
|
|
26
27
|
export const DEFAULT_ROUNDING: 8;
|
|
27
28
|
export const ROUNDING_DECREMENT: 4;
|
|
28
29
|
export const ROUNDING_INCREMENT: 6;
|
|
30
|
+
export const DEFAULT_SPACING: 4;
|
|
29
31
|
export const DEFAULT_DISABLED_OPACITY: 50;
|
|
30
32
|
export const DEFAULT_LETTER_SPACING: 0;
|
|
31
33
|
export const PRIMARY_COLORS: string[];
|
package/constants.js
CHANGED
|
@@ -16,6 +16,7 @@ export const TEXT = "text";
|
|
|
16
16
|
export const OUTLINE = "outline";
|
|
17
17
|
export const ROUNDING = "rounding";
|
|
18
18
|
export const DISABLED_OPACITY = "disabled-opacity";
|
|
19
|
+
export const SPACING = "spacing";
|
|
19
20
|
export const LETTER_SPACING = "letter-spacing";
|
|
20
21
|
export const LIGHT_THEME = "light-theme";
|
|
21
22
|
export const DARK_THEME = "dark-theme";
|
|
@@ -38,6 +39,7 @@ export const OUTLINE_INCREMENT = 1; /* pixels */
|
|
|
38
39
|
export const DEFAULT_ROUNDING = 8; /* pixels */
|
|
39
40
|
export const ROUNDING_DECREMENT = 4; /* pixels */
|
|
40
41
|
export const ROUNDING_INCREMENT = 6; /* pixels */
|
|
42
|
+
export const DEFAULT_SPACING = 4; /* pixels */
|
|
41
43
|
export const DEFAULT_DISABLED_OPACITY = 50; /* presents */
|
|
42
44
|
export const DEFAULT_LETTER_SPACING = 0; /* em */
|
|
43
45
|
|
package/index.d.ts
CHANGED
|
@@ -29,6 +29,7 @@ export { useLocale } from "./composables/useLocale";
|
|
|
29
29
|
export { default as useUI } from "./composables/useUI";
|
|
30
30
|
export { useDarkMode } from "./composables/useDarkMode";
|
|
31
31
|
export { useRequestQueue } from "./composables/useRequestQueue";
|
|
32
|
+
export { default as useBreakpoint } from "./composables/useBreakpoint";
|
|
32
33
|
export { useLoaderOverlay } from "./ui.loader-overlay/useLoaderOverlay";
|
|
33
34
|
export { useLoaderProgress } from "./ui.loader-progress/useLoaderProgress";
|
|
34
35
|
export { useMutationObserver } from "./composables/useMutationObserver";
|
package/index.ts
CHANGED
|
@@ -35,6 +35,7 @@ export { useLocale } from "./composables/useLocale";
|
|
|
35
35
|
export { default as useUI } from "./composables/useUI";
|
|
36
36
|
export { useDarkMode } from "./composables/useDarkMode";
|
|
37
37
|
export { useRequestQueue } from "./composables/useRequestQueue";
|
|
38
|
+
export { default as useBreakpoint } from "./composables/useBreakpoint";
|
|
38
39
|
export { useLoaderOverlay } from "./ui.loader-overlay/useLoaderOverlay";
|
|
39
40
|
export { useLoaderProgress } from "./ui.loader-progress/useLoaderProgress";
|
|
40
41
|
export { useMutationObserver } from "./composables/useMutationObserver";
|
package/package.json
CHANGED
package/tailwind.css
CHANGED
|
@@ -113,6 +113,9 @@
|
|
|
113
113
|
--radius-medium: var(--vl-rounding-md);
|
|
114
114
|
--radius-large: var(--vl-rounding-lg);
|
|
115
115
|
|
|
116
|
+
/* Spacing value */
|
|
117
|
+
--spacing: var(--vl-spacing);
|
|
118
|
+
|
|
116
119
|
/* Mobile safe area spaceing. */
|
|
117
120
|
--spacing-safe-top: "env(safe-area-inset-top)";
|
|
118
121
|
--spacing-safe-bottom: "env(safe-area-inset-bottom)";
|
package/types.ts
CHANGED
|
@@ -115,6 +115,11 @@ export interface ThemeConfig {
|
|
|
115
115
|
*/
|
|
116
116
|
outline?: number | Partial<ThemeConfigOutline>;
|
|
117
117
|
|
|
118
|
+
/**
|
|
119
|
+
* Default components spacing.
|
|
120
|
+
*/
|
|
121
|
+
spacing?: number;
|
|
122
|
+
|
|
118
123
|
/**
|
|
119
124
|
* Default components letter spacing.
|
|
120
125
|
*/
|
|
@@ -497,7 +502,7 @@ export interface VuelessCssVariables {
|
|
|
497
502
|
"--vl-bg-accented": string;
|
|
498
503
|
"--vl-bg-muted": string;
|
|
499
504
|
"--vl-bg-inverted": string;
|
|
500
|
-
/*
|
|
505
|
+
/* Any other design system CSS variables */
|
|
501
506
|
[key: string]: string;
|
|
502
507
|
}
|
|
503
508
|
|
package/utils/theme.ts
CHANGED
|
@@ -37,6 +37,8 @@ import {
|
|
|
37
37
|
DEFAULT_LETTER_SPACING,
|
|
38
38
|
LIGHT_THEME,
|
|
39
39
|
DARK_THEME,
|
|
40
|
+
SPACING,
|
|
41
|
+
DEFAULT_SPACING,
|
|
40
42
|
} from "../constants";
|
|
41
43
|
|
|
42
44
|
import type {
|
|
@@ -62,13 +64,17 @@ const prefersColorSchemeDark = isCSR && window.matchMedia("(prefers-color-scheme
|
|
|
62
64
|
function toggleColorModeClass() {
|
|
63
65
|
if (!prefersColorSchemeDark) return;
|
|
64
66
|
|
|
65
|
-
const
|
|
67
|
+
const isDarkMode = prefersColorSchemeDark.matches;
|
|
68
|
+
const colorMode = isDarkMode ? ColorMode.Dark : ColorMode.Light;
|
|
66
69
|
|
|
67
70
|
setCookie(COLOR_MODE_KEY, colorMode);
|
|
68
71
|
setCookie(AUTO_MODE_KEY, String(Number(true)));
|
|
69
72
|
|
|
70
|
-
document.documentElement.classList.toggle(DARK_MODE_CLASS,
|
|
71
|
-
document.documentElement.classList.toggle(LIGHT_MODE_CLASS, !
|
|
73
|
+
document.documentElement.classList.toggle(DARK_MODE_CLASS, isDarkMode);
|
|
74
|
+
document.documentElement.classList.toggle(LIGHT_MODE_CLASS, !isDarkMode);
|
|
75
|
+
|
|
76
|
+
/* Dispatching custom event for the useDarkMode composable. */
|
|
77
|
+
window.dispatchEvent(new CustomEvent("darkModeChange", { detail: isDarkMode }));
|
|
72
78
|
}
|
|
73
79
|
|
|
74
80
|
/**
|
|
@@ -179,6 +185,7 @@ export function resetTheme() {
|
|
|
179
185
|
`vl-${ROUNDING}-sm`,
|
|
180
186
|
`vl-${ROUNDING}-md`,
|
|
181
187
|
`vl-${ROUNDING}-lg`,
|
|
188
|
+
`vl-${SPACING}`,
|
|
182
189
|
`vl-${LETTER_SPACING}`,
|
|
183
190
|
`vl-${DISABLED_OPACITY}`,
|
|
184
191
|
`vl-${LIGHT_THEME}`,
|
|
@@ -206,6 +213,7 @@ export function getTheme(config?: ThemeConfig): MergedThemeConfig {
|
|
|
206
213
|
const text = getText(config?.text);
|
|
207
214
|
const outline = getOutlines(config?.outline);
|
|
208
215
|
const rounding = getRoundings(config?.rounding);
|
|
216
|
+
const spacing = getSpacing(config?.spacing);
|
|
209
217
|
const letterSpacing = getLetterSpacing(config?.letterSpacing);
|
|
210
218
|
const disabledOpacity = getDisabledOpacity(config?.disabledOpacity);
|
|
211
219
|
|
|
@@ -220,6 +228,7 @@ export function getTheme(config?: ThemeConfig): MergedThemeConfig {
|
|
|
220
228
|
text,
|
|
221
229
|
outline,
|
|
222
230
|
rounding,
|
|
231
|
+
spacing,
|
|
223
232
|
letterSpacing,
|
|
224
233
|
disabledOpacity,
|
|
225
234
|
lightTheme,
|
|
@@ -240,6 +249,7 @@ export function setTheme(config: ThemeConfig = {}) {
|
|
|
240
249
|
const text = getText(config.text);
|
|
241
250
|
const outline = getOutlines(config.outline);
|
|
242
251
|
const rounding = getRoundings(config.rounding);
|
|
252
|
+
const spacing = getSpacing(config.spacing);
|
|
243
253
|
const letterSpacing = getLetterSpacing(config.letterSpacing);
|
|
244
254
|
const disabledOpacity = getDisabledOpacity(config.disabledOpacity);
|
|
245
255
|
|
|
@@ -306,6 +316,7 @@ export function setTheme(config: ThemeConfig = {}) {
|
|
|
306
316
|
text,
|
|
307
317
|
outline,
|
|
308
318
|
rounding,
|
|
319
|
+
spacing,
|
|
309
320
|
letterSpacing,
|
|
310
321
|
disabledOpacity,
|
|
311
322
|
lightTheme,
|
|
@@ -342,6 +353,7 @@ export function normalizeThemeConfig(theme: any): MergedThemeConfig {
|
|
|
342
353
|
md: toNumber(theme.rounding?.md),
|
|
343
354
|
lg: toNumber(theme.rounding?.lg),
|
|
344
355
|
},
|
|
356
|
+
spacing: toNumber(theme.spacing),
|
|
345
357
|
letterSpacing: toNumber(theme.letterSpacing),
|
|
346
358
|
disabledOpacity: toNumber(theme.disabledOpacity),
|
|
347
359
|
};
|
|
@@ -592,6 +604,24 @@ function getRoundings(rounding?: ThemeConfig["rounding"]) {
|
|
|
592
604
|
return mergedRounding;
|
|
593
605
|
}
|
|
594
606
|
|
|
607
|
+
/**
|
|
608
|
+
* Retrieve spacing value and save them to cookie and localStorage.
|
|
609
|
+
* @return number - spacing value.
|
|
610
|
+
*/
|
|
611
|
+
function getSpacing(spacing?: ThemeConfig["spacing"]) {
|
|
612
|
+
const storageKey = `vl-${SPACING}`;
|
|
613
|
+
|
|
614
|
+
const storedSpacing = spacing ?? getStored(storageKey) ?? vuelessConfig.spacing;
|
|
615
|
+
const mergedSpacing = Number(storedSpacing ?? DEFAULT_SPACING);
|
|
616
|
+
|
|
617
|
+
if (isCSR && spacing !== undefined) {
|
|
618
|
+
setCookie(storageKey, String(mergedSpacing));
|
|
619
|
+
localStorage.setItem(storageKey, String(mergedSpacing));
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
return mergedSpacing;
|
|
623
|
+
}
|
|
624
|
+
|
|
595
625
|
/**
|
|
596
626
|
* Retrieve letter spacing value and save them to cookie and localStorage.
|
|
597
627
|
* @return number - letter spacing value.
|
|
@@ -698,6 +728,7 @@ export function setRootCSSVariables(vars: MergedThemeConfig) {
|
|
|
698
728
|
"--vl-rounding-sm": `${Number(vars.rounding.sm ?? 0) / PX_IN_REM}rem`,
|
|
699
729
|
"--vl-rounding-md": `${Number(vars.rounding.md ?? 0) / PX_IN_REM}rem`,
|
|
700
730
|
"--vl-rounding-lg": `${Number(vars.rounding.lg ?? 0) / PX_IN_REM}rem`,
|
|
731
|
+
"--vl-spacing": `${Number(vars.spacing ?? 0) / PX_IN_REM}rem`,
|
|
701
732
|
"--vl-letter-spacing": `${vars.letterSpacing}em`,
|
|
702
733
|
"--vl-disabled-opacity": `${vars.disabledOpacity}%`,
|
|
703
734
|
};
|