@vueless/nuxt 0.0.9-beta.3 → 0.0.9-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/dist/module.json +1 -1
- package/dist/package.json +2 -2
- package/dist/runtime/plugin.js +29 -2
- package/package.json +2 -2
package/dist/module.json
CHANGED
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vueless/nuxt",
|
|
3
|
-
"version": "0.0.9-beta.
|
|
3
|
+
"version": "0.0.9-beta.5",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Nuxt Styleless UI Component Library, powered by Tailwind CSS.",
|
|
6
6
|
"keywords": [
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"@nuxt/kit": "^3.13.1",
|
|
59
59
|
"@tailwindcss/vite": "^4.0.14",
|
|
60
60
|
"tailwindcss": "^4.0.14",
|
|
61
|
-
"vueless": "^0.0.825-beta.
|
|
61
|
+
"vueless": "^0.0.825-beta.21"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
64
|
"@material-symbols/svg-500": "^0.29.1",
|
package/dist/runtime/plugin.js
CHANGED
|
@@ -1,16 +1,43 @@
|
|
|
1
1
|
import { createVueless, setTheme } from "vueless";
|
|
2
|
+
import { COLOR_MODE_KEY, AUTO_MODE_KEY, LIGHT_MODE_SELECTOR, DARK_MODE_SELECTOR, PRIMARY_COLOR_KEY, NEUTRAL_COLOR_KEY, ROUNDING_KEY } from "vueless/constants";
|
|
3
|
+
import { ColorMode } from "vueless/types";
|
|
2
4
|
import vClickOutside from "vueless/directives/clickOutside/vClickOutside";
|
|
3
5
|
import vTooltip from "vueless/directives/tooltip/vTooltip";
|
|
4
6
|
import { defineNuxtPlugin } from "#app";
|
|
7
|
+
function parseCookies(cookieHeader) {
|
|
8
|
+
if (!cookieHeader) return {};
|
|
9
|
+
return cookieHeader.split(";").reduce((acc, cookie) => {
|
|
10
|
+
const [key, value] = cookie.trim().split("=");
|
|
11
|
+
if (key) acc[key] = value;
|
|
12
|
+
return acc;
|
|
13
|
+
}, {});
|
|
14
|
+
}
|
|
5
15
|
export default defineNuxtPlugin((_nuxtApp) => {
|
|
6
16
|
const vueless = createVueless();
|
|
7
17
|
_nuxtApp.vueApp.use(vueless, []);
|
|
8
18
|
_nuxtApp.vueApp.directive("clickOutside", vClickOutside);
|
|
9
19
|
_nuxtApp.vueApp.directive("tooltip", vTooltip);
|
|
10
20
|
if (import.meta.server) {
|
|
11
|
-
const
|
|
21
|
+
const event = _nuxtApp.ssrContext?.event;
|
|
22
|
+
const cookies = parseCookies(event?.node.req.headers.cookie);
|
|
23
|
+
const colorModeCookie = cookies?.[COLOR_MODE_KEY];
|
|
24
|
+
const isAutoModeCookie = cookies?.[AUTO_MODE_KEY];
|
|
25
|
+
const primaryColorCookie = cookies?.[PRIMARY_COLOR_KEY];
|
|
26
|
+
const neutralColorCookie = cookies?.[NEUTRAL_COLOR_KEY];
|
|
27
|
+
const roundingCookie = cookies?.[ROUNDING_KEY];
|
|
28
|
+
const themeRootVariables = setTheme(
|
|
29
|
+
{
|
|
30
|
+
primary: primaryColorCookie,
|
|
31
|
+
neutral: neutralColorCookie,
|
|
32
|
+
rounding: Number(roundingCookie),
|
|
33
|
+
colorMode: colorModeCookie
|
|
34
|
+
},
|
|
35
|
+
Boolean(Number(isAutoModeCookie))
|
|
36
|
+
);
|
|
37
|
+
const colorModeClass = colorModeCookie === ColorMode.Dark ? DARK_MODE_SELECTOR : LIGHT_MODE_SELECTOR;
|
|
12
38
|
_nuxtApp.ssrContext?.head.push({
|
|
13
|
-
style: [{ innerHTML: themeRootVariables }]
|
|
39
|
+
style: [{ innerHTML: themeRootVariables }],
|
|
40
|
+
htmlAttrs: { class: colorModeClass }
|
|
14
41
|
});
|
|
15
42
|
}
|
|
16
43
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vueless/nuxt",
|
|
3
|
-
"version": "0.0.9-beta.
|
|
3
|
+
"version": "0.0.9-beta.5",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Nuxt Styleless UI Component Library, powered by Tailwind CSS.",
|
|
6
6
|
"keywords": [
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"@nuxt/kit": "^3.13.1",
|
|
59
59
|
"@tailwindcss/vite": "^4.0.14",
|
|
60
60
|
"tailwindcss": "^4.0.14",
|
|
61
|
-
"vueless": "^0.0.825-beta.
|
|
61
|
+
"vueless": "^0.0.825-beta.21"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
64
|
"@material-symbols/svg-500": "^0.29.1",
|