vueless 1.1.1-beta.0 → 1.1.1-beta.2

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.
Files changed (2) hide show
  1. package/package.json +21 -21
  2. package/utils/theme.ts +41 -2
package/package.json CHANGED
@@ -1,29 +1,13 @@
1
1
  {
2
2
  "name": "vueless",
3
- "version": "1.1.1-beta.0",
4
- "license": "MIT",
3
+ "version": "1.1.1-beta.2",
5
4
  "description": "Vue Styleless UI Component Library, powered by Tailwind CSS.",
6
- "keywords": [
7
- "vueless",
8
- "vue",
9
- "vue.js",
10
- "vue3",
11
- "ui library",
12
- "component library",
13
- "vue framework",
14
- "design system",
15
- "tailwind",
16
- "tailwindcss",
17
- "unstyled",
18
- "styleless",
19
- "headlessui",
20
- "ui"
21
- ],
22
- "homepage": "https://vueless.com",
23
5
  "author": "Johnny Grid <hello@vueless.com> (https://vueless.com)",
6
+ "homepage": "https://vueless.com",
24
7
  "style": "tailwind.css",
25
8
  "main": "index.ts",
26
9
  "type": "module",
10
+ "license": "MIT",
27
11
  "publishConfig": {
28
12
  "access": "public"
29
13
  },
@@ -74,7 +58,7 @@
74
58
  "@vue/eslint-config-typescript": "^14.6.0",
75
59
  "@vue/test-utils": "^2.4.6",
76
60
  "@vue/tsconfig": "^0.7.0",
77
- "@vueless/storybook": "^1.1.0",
61
+ "@vueless/storybook": "^1.1.2",
78
62
  "eslint": "^9.32.0",
79
63
  "eslint-plugin-storybook": "^9.0.18",
80
64
  "eslint-plugin-vue": "^10.3.0",
@@ -102,5 +86,21 @@
102
86
  },
103
87
  "bugs": {
104
88
  "url": "https://github.com/vuelessjs/vueless/issues"
105
- }
89
+ },
90
+ "keywords": [
91
+ "vueless",
92
+ "vue",
93
+ "vue.js",
94
+ "vue3",
95
+ "ui library",
96
+ "component library",
97
+ "vue framework",
98
+ "design system",
99
+ "tailwind",
100
+ "tailwindcss",
101
+ "unstyled",
102
+ "styleless",
103
+ "headlessui",
104
+ "ui"
105
+ ]
106
106
  }
package/utils/theme.ts CHANGED
@@ -170,11 +170,39 @@ export function setTheme(config: ThemeConfig = {}, isCachedAutoMode?: boolean) {
170
170
  ? `--vl-grayscale-${shade}`
171
171
  : "--vl-grayscale";
172
172
 
173
- if (!vuelessConfig.darkTheme?.[primaryShade] && !config.darkTheme?.[primaryShade]) {
173
+ /* Dark theme: if the primary color shade is not defined in global or runtime config, use the grayscale color. */
174
+
175
+ const hasGlobalDarkPrimaryColor = hasPrimaryColor(
176
+ vuelessConfig.darkTheme,
177
+ DEFAULT_DARK_THEME,
178
+ primaryShade,
179
+ );
180
+
181
+ const hasRuntimeDarkPrimaryColor = hasPrimaryColor(
182
+ config.darkTheme,
183
+ DEFAULT_DARK_THEME,
184
+ primaryShade,
185
+ );
186
+
187
+ if (!hasGlobalDarkPrimaryColor && !hasRuntimeDarkPrimaryColor) {
174
188
  darkTheme[primaryShade] = darkTheme[grayscaleShade];
175
189
  }
176
190
 
177
- if (!vuelessConfig.lightTheme?.[primaryShade] && !config.lightTheme?.[primaryShade]) {
191
+ /* Light theme: if the primary color shade is not defined in global or runtime config, use the grayscale color. */
192
+
193
+ const hasGlobalLightPrimaryColor = hasPrimaryColor(
194
+ vuelessConfig.lightTheme,
195
+ DEFAULT_LIGHT_THEME,
196
+ primaryShade,
197
+ );
198
+
199
+ const hasRuntimeLightPrimaryColor = hasPrimaryColor(
200
+ config.lightTheme,
201
+ DEFAULT_LIGHT_THEME,
202
+ primaryShade,
203
+ );
204
+
205
+ if (!hasGlobalLightPrimaryColor && !hasRuntimeLightPrimaryColor) {
178
206
  lightTheme[primaryShade] = lightTheme[grayscaleShade];
179
207
  }
180
208
  });
@@ -192,6 +220,17 @@ export function setTheme(config: ThemeConfig = {}, isCachedAutoMode?: boolean) {
192
220
  });
193
221
  }
194
222
 
223
+ function hasPrimaryColor(
224
+ colorModeConfig: Partial<VuelessCssVariables> | undefined,
225
+ defaultColorModeConfig: Partial<VuelessCssVariables>,
226
+ primaryShade: keyof VuelessCssVariables,
227
+ ) {
228
+ const shade = colorModeConfig?.[primaryShade];
229
+ const defaultShade = defaultColorModeConfig?.[primaryShade];
230
+
231
+ return shade && shade !== defaultShade;
232
+ }
233
+
195
234
  /**
196
235
  * Retrieve primary color value and save them to cookie and localStorage.
197
236
  * @return string - primary color.