@vueless/nuxt 0.0.9-beta.4 → 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 CHANGED
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": ">=3.13.0"
6
6
  },
7
- "version": "0.0.9-beta.4",
7
+ "version": "0.0.9-beta.5",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "0.8.4",
10
10
  "unbuild": "2.0.0"
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vueless/nuxt",
3
- "version": "0.0.9-beta.4",
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": [
@@ -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 themeRootVariables = setTheme();
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.4",
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": [