@maz-ui/nuxt 4.0.0-beta.16 → 4.0.0-beta.18
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.d.mts +6 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +3 -1
- package/dist/runtime/plugins/theme.js +20 -19
- package/package.json +5 -5
package/dist/module.d.mts
CHANGED
|
@@ -11,6 +11,12 @@ interface MazUiNuxtThemeOptions extends MazUiThemeOptions {
|
|
|
11
11
|
* @default true
|
|
12
12
|
*/
|
|
13
13
|
injectFullCSSOnServer?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Spa mode
|
|
16
|
+
* @description Enable full CSS injection on client-side for app with SSR disabled on some pages
|
|
17
|
+
* @default false
|
|
18
|
+
*/
|
|
19
|
+
spa?: boolean;
|
|
14
20
|
}
|
|
15
21
|
interface MazUiNuxtOptions {
|
|
16
22
|
/**
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -6,7 +6,10 @@ import { MazUiTheme } from "@maz-ui/themes/plugin";
|
|
|
6
6
|
import { getPreset } from "@maz-ui/themes/utils";
|
|
7
7
|
import { generateCriticalCSS } from "@maz-ui/themes/utils/css-generator";
|
|
8
8
|
import { defineNuxtPlugin, useCookie, useHead, useRequestHeaders } from "nuxt/app";
|
|
9
|
-
function getServerInitialColorMode() {
|
|
9
|
+
function getServerInitialColorMode(colorMode) {
|
|
10
|
+
if (colorMode !== "auto") {
|
|
11
|
+
return colorMode;
|
|
12
|
+
}
|
|
10
13
|
const colorModeCookie = useCookie("maz-color-mode");
|
|
11
14
|
if (colorModeCookie.value && ["light", "dark", "auto"].includes(colorModeCookie.value)) {
|
|
12
15
|
return colorModeCookie.value;
|
|
@@ -23,36 +26,34 @@ function getServerInitialColorMode() {
|
|
|
23
26
|
}
|
|
24
27
|
return "auto";
|
|
25
28
|
}
|
|
26
|
-
function getServerIsDark(colorMode) {
|
|
27
|
-
return colorMode === "dark";
|
|
28
|
-
}
|
|
29
29
|
export default defineNuxtPlugin(async ({ vueApp, $config }) => {
|
|
30
|
-
const
|
|
31
|
-
let preset = await getPreset(
|
|
32
|
-
if (
|
|
33
|
-
preset = mergePresets(preset,
|
|
30
|
+
const options = $config.public.mazUi.theme;
|
|
31
|
+
let preset = await getPreset(options?.preset);
|
|
32
|
+
if (options?.overrides) {
|
|
33
|
+
preset = mergePresets(preset, options.overrides);
|
|
34
34
|
}
|
|
35
35
|
const config = {
|
|
36
36
|
strategy: "hybrid",
|
|
37
37
|
darkModeStrategy: "class",
|
|
38
|
-
colorMode: "auto",
|
|
38
|
+
colorMode: options.mode && options.mode !== "both" ? options.mode : options.colorMode ?? "auto",
|
|
39
|
+
mode: "both",
|
|
39
40
|
injectFullCSSOnServer: true,
|
|
40
|
-
...
|
|
41
|
+
...options,
|
|
41
42
|
preset
|
|
42
43
|
};
|
|
43
|
-
const
|
|
44
|
-
const
|
|
45
|
-
const initialIsDark = initialColorMode === "dark" || initialColorMode === "auto" && serverIsDark;
|
|
44
|
+
const colorMode = config.mode !== "both" ? config.mode : getServerInitialColorMode(config.colorMode);
|
|
45
|
+
const isDark = colorMode === "auto" && config.mode === "both" ? getServerInitialColorMode(config.colorMode) === "dark" : colorMode === "dark" || config.mode === "dark";
|
|
46
46
|
const themeState = {
|
|
47
47
|
currentPreset: config.preset,
|
|
48
|
-
colorMode
|
|
49
|
-
|
|
48
|
+
colorMode,
|
|
49
|
+
mode: config.mode,
|
|
50
|
+
isDark,
|
|
50
51
|
strategy: config.strategy,
|
|
51
52
|
darkModeStrategy: config.darkModeStrategy
|
|
52
53
|
};
|
|
53
54
|
if (import.meta.server) {
|
|
54
55
|
const cssOptions = {
|
|
55
|
-
mode:
|
|
56
|
+
mode: themeState.mode,
|
|
56
57
|
darkSelectorStrategy: config.darkModeStrategy ?? "class",
|
|
57
58
|
prefix: "maz"
|
|
58
59
|
};
|
|
@@ -71,7 +72,7 @@ export default defineNuxtPlugin(async ({ vueApp, $config }) => {
|
|
|
71
72
|
style: [{ innerHTML: fullCSS, id: "maz-theme-full" }]
|
|
72
73
|
});
|
|
73
74
|
}
|
|
74
|
-
if (
|
|
75
|
+
if (isDark && config.darkModeStrategy === "class") {
|
|
75
76
|
useHead({
|
|
76
77
|
htmlAttrs: {
|
|
77
78
|
class: "dark"
|
|
@@ -85,7 +86,7 @@ export default defineNuxtPlugin(async ({ vueApp, $config }) => {
|
|
|
85
86
|
colorMode: themeState.colorMode,
|
|
86
87
|
strategy: themeState.strategy,
|
|
87
88
|
darkModeStrategy: themeState.darkModeStrategy,
|
|
88
|
-
injectFullCSS: !config.injectFullCSSOnServer,
|
|
89
|
-
injectCriticalCSS:
|
|
89
|
+
injectFullCSS: config.spa ? true : !config.injectFullCSSOnServer,
|
|
90
|
+
injectCriticalCSS: !!config.spa
|
|
90
91
|
});
|
|
91
92
|
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maz-ui/nuxt",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.0.0-beta.
|
|
4
|
+
"version": "4.0.0-beta.18",
|
|
5
5
|
"description": "Nuxt module for Maz-UI",
|
|
6
6
|
"author": "Louis Mazel <me@loicmazuel.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -53,11 +53,11 @@
|
|
|
53
53
|
"typecheck": "vue-tsc --noEmit --skipLibCheck"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@maz-ui/themes": "4.0.0-beta.
|
|
57
|
-
"@maz-ui/translations": "4.0.0-beta.
|
|
56
|
+
"@maz-ui/themes": "4.0.0-beta.18",
|
|
57
|
+
"@maz-ui/translations": "4.0.0-beta.18",
|
|
58
58
|
"@nuxt/kit": "^3.17.4",
|
|
59
59
|
"defu": "^6.1.4",
|
|
60
|
-
"maz-ui": "4.0.0-beta.
|
|
60
|
+
"maz-ui": "4.0.0-beta.18"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@nuxt/devtools": "^2.4.1",
|
|
@@ -72,5 +72,5 @@
|
|
|
72
72
|
"lint-staged": {
|
|
73
73
|
"*.{js,ts,mjs,mts,cjs,md,yml,json}": "cross-env NODE_ENV=production eslint --fix"
|
|
74
74
|
},
|
|
75
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "f6939de42eb922cb28b30bdf310ad9d0fec972a8"
|
|
76
76
|
}
|