vueless 1.2.8-beta.7 → 1.2.8-beta.8
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/constants.d.ts +3 -0
- package/constants.js +3 -0
- package/package.json +1 -1
- package/utils/theme.ts +60 -4
package/constants.d.ts
CHANGED
|
@@ -9,6 +9,8 @@ export const OUTLINE: "outline";
|
|
|
9
9
|
export const ROUNDING: "rounding";
|
|
10
10
|
export const DISABLED_OPACITY: "disabled-opacity";
|
|
11
11
|
export const LETTER_SPACING: "letter-spacing";
|
|
12
|
+
export const LIGHT_THEME: "light-theme";
|
|
13
|
+
export const DARK_THEME: "dark-theme";
|
|
12
14
|
export const COLOR_MODE_KEY: "vl-color-mode";
|
|
13
15
|
export const AUTO_MODE_KEY: "vl-auto-mode";
|
|
14
16
|
export const DARK_MODE_CLASS: "vl-dark";
|
|
@@ -28,6 +30,7 @@ export const DEFAULT_DISABLED_OPACITY: 50;
|
|
|
28
30
|
export const DEFAULT_LETTER_SPACING: 0;
|
|
29
31
|
export const PRIMARY_COLORS: string[];
|
|
30
32
|
export const STATE_COLORS: string[];
|
|
33
|
+
export const LAYOUT_COLORS: string[];
|
|
31
34
|
export const NEUTRAL_COLORS: string[];
|
|
32
35
|
export const COLOR_SHADES: number[];
|
|
33
36
|
export const DEFAULT_LIGHT_THEME: {
|
package/constants.js
CHANGED
|
@@ -17,6 +17,8 @@ export const OUTLINE = "outline";
|
|
|
17
17
|
export const ROUNDING = "rounding";
|
|
18
18
|
export const DISABLED_OPACITY = "disabled-opacity";
|
|
19
19
|
export const LETTER_SPACING = "letter-spacing";
|
|
20
|
+
export const LIGHT_THEME = "light-theme";
|
|
21
|
+
export const DARK_THEME = "dark-theme";
|
|
20
22
|
|
|
21
23
|
/* Vueless color mode keys */
|
|
22
24
|
export const COLOR_MODE_KEY = "vl-color-mode";
|
|
@@ -70,6 +72,7 @@ export const STATE_COLORS = [
|
|
|
70
72
|
NEUTRAL_COLOR,
|
|
71
73
|
GRAYSCALE_COLOR,
|
|
72
74
|
];
|
|
75
|
+
export const LAYOUT_COLORS = ["text", "border", "bg"];
|
|
73
76
|
export const NEUTRAL_COLORS = ["slate", "gray", "zinc", "neutral", "stone"];
|
|
74
77
|
export const COLOR_SHADES = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950];
|
|
75
78
|
|
package/package.json
CHANGED
package/utils/theme.ts
CHANGED
|
@@ -35,6 +35,8 @@ import {
|
|
|
35
35
|
DEFAULT_DISABLED_OPACITY,
|
|
36
36
|
LETTER_SPACING,
|
|
37
37
|
DEFAULT_LETTER_SPACING,
|
|
38
|
+
LIGHT_THEME,
|
|
39
|
+
DARK_THEME,
|
|
38
40
|
} from "../constants";
|
|
39
41
|
|
|
40
42
|
import type {
|
|
@@ -191,6 +193,8 @@ export function resetTheme() {
|
|
|
191
193
|
`vl-${ROUNDING}-lg`,
|
|
192
194
|
`vl-${LETTER_SPACING}`,
|
|
193
195
|
`vl-${DISABLED_OPACITY}`,
|
|
196
|
+
`vl-${LIGHT_THEME}`,
|
|
197
|
+
`vl-${DARK_THEME}`,
|
|
194
198
|
];
|
|
195
199
|
|
|
196
200
|
themeKeys.forEach((key) => {
|
|
@@ -217,8 +221,8 @@ export function getTheme(config?: ThemeConfig): MergedThemeConfig {
|
|
|
217
221
|
const letterSpacing = getLetterSpacing(config?.letterSpacing);
|
|
218
222
|
const disabledOpacity = getDisabledOpacity(config?.disabledOpacity);
|
|
219
223
|
|
|
220
|
-
const lightTheme =
|
|
221
|
-
const darkTheme =
|
|
224
|
+
const lightTheme = getLightTheme(config?.lightTheme);
|
|
225
|
+
const darkTheme = getDarkTheme(config?.darkTheme);
|
|
222
226
|
|
|
223
227
|
return {
|
|
224
228
|
colorMode,
|
|
@@ -254,8 +258,8 @@ export function setTheme(config: ThemeConfig = {}) {
|
|
|
254
258
|
let primary = getPrimaryColor(config.primary);
|
|
255
259
|
const neutral = getNeutralColor(config.neutral);
|
|
256
260
|
|
|
257
|
-
const lightTheme =
|
|
258
|
-
const darkTheme =
|
|
261
|
+
const lightTheme = getLightTheme(config.lightTheme);
|
|
262
|
+
const darkTheme = getDarkTheme(config.darkTheme);
|
|
259
263
|
|
|
260
264
|
/* Redeclare primary color if grayscale color set as default */
|
|
261
265
|
if (primary === GRAYSCALE_COLOR) {
|
|
@@ -636,6 +640,58 @@ function getDisabledOpacity(disabledOpacity?: ThemeConfig["disabledOpacity"]) {
|
|
|
636
640
|
return mergedOpacity;
|
|
637
641
|
}
|
|
638
642
|
|
|
643
|
+
/**
|
|
644
|
+
* Retrieve light theme configuration and save them to cookie and localStorage.
|
|
645
|
+
* @return Partial<VuelessCssVariables> - light theme configuration.
|
|
646
|
+
*/
|
|
647
|
+
function getLightTheme(lightTheme?: Partial<VuelessCssVariables>) {
|
|
648
|
+
const storageKey = `vl-${LIGHT_THEME}`;
|
|
649
|
+
|
|
650
|
+
const storedLightTheme: Partial<VuelessCssVariables> = JSON.parse(getStored(storageKey) ?? "{}");
|
|
651
|
+
|
|
652
|
+
const mergedLightTheme = merge(
|
|
653
|
+
{},
|
|
654
|
+
DEFAULT_LIGHT_THEME,
|
|
655
|
+
vuelessConfig.lightTheme,
|
|
656
|
+
storedLightTheme,
|
|
657
|
+
lightTheme,
|
|
658
|
+
);
|
|
659
|
+
|
|
660
|
+
if (isCSR && lightTheme !== undefined) {
|
|
661
|
+
const themeString = JSON.stringify(mergedLightTheme);
|
|
662
|
+
|
|
663
|
+
localStorage.setItem(storageKey, themeString);
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
return mergedLightTheme;
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
/**
|
|
670
|
+
* Retrieve dark theme configuration and save them to cookie and localStorage.
|
|
671
|
+
* @return Partial<VuelessCssVariables> - dark theme configuration.
|
|
672
|
+
*/
|
|
673
|
+
function getDarkTheme(darkTheme?: Partial<VuelessCssVariables>) {
|
|
674
|
+
const storageKey = `vl-${DARK_THEME}`;
|
|
675
|
+
|
|
676
|
+
const storedDarkTheme: Partial<VuelessCssVariables> = JSON.parse(getStored(storageKey) ?? "{}");
|
|
677
|
+
|
|
678
|
+
const mergedDarkTheme = merge(
|
|
679
|
+
{},
|
|
680
|
+
DEFAULT_DARK_THEME,
|
|
681
|
+
vuelessConfig.darkTheme,
|
|
682
|
+
storedDarkTheme,
|
|
683
|
+
darkTheme,
|
|
684
|
+
);
|
|
685
|
+
|
|
686
|
+
if (isCSR && darkTheme !== undefined) {
|
|
687
|
+
const themeString = JSON.stringify(mergedDarkTheme);
|
|
688
|
+
|
|
689
|
+
localStorage.setItem(storageKey, themeString);
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
return mergedDarkTheme;
|
|
693
|
+
}
|
|
694
|
+
|
|
639
695
|
/**
|
|
640
696
|
* Generate and apply Vueless CSS variables.
|
|
641
697
|
* @return string - Vueless CSS variables string.
|