srcdev-nuxt-components 9.0.13 → 9.0.15
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/modules/colour-scheme.ts +27 -0
- package/nuxt.config.ts +4 -1
- package/package.json +2 -1
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { defineNuxtModule } from "@nuxt/kit";
|
|
2
|
+
|
|
3
|
+
export default defineNuxtModule({
|
|
4
|
+
meta: {
|
|
5
|
+
name: "colour-scheme",
|
|
6
|
+
configKey: "colourScheme",
|
|
7
|
+
},
|
|
8
|
+
setup(_, nuxt) {
|
|
9
|
+
const enabled = (nuxt.options.runtimeConfig.public?.colourScheme as { enabled?: boolean } | undefined)?.enabled ?? true;
|
|
10
|
+
|
|
11
|
+
if (!enabled) return;
|
|
12
|
+
|
|
13
|
+
nuxt.options.app.head.script ||= [];
|
|
14
|
+
nuxt.options.app.head.script.push({
|
|
15
|
+
innerHTML: `
|
|
16
|
+
(function() {
|
|
17
|
+
var saved = localStorage.getItem('colourScheme');
|
|
18
|
+
var valid = ['auto', 'dark', 'light'];
|
|
19
|
+
var scheme = valid.includes(saved) ? saved : 'auto';
|
|
20
|
+
document.documentElement.dataset.colorScheme = scheme;
|
|
21
|
+
})();
|
|
22
|
+
`,
|
|
23
|
+
tagPosition: "head",
|
|
24
|
+
tagPriority: "critical",
|
|
25
|
+
} as Parameters<typeof nuxt.options.app.head.script.push>[0]);
|
|
26
|
+
},
|
|
27
|
+
});
|
package/nuxt.config.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
// https://nuxt.com/docs/api/configuration/nuxt-config
|
|
2
|
+
import { createResolver } from "@nuxt/kit";
|
|
3
|
+
|
|
4
|
+
const { resolve } = createResolver(import.meta.url);
|
|
2
5
|
const isStandalone = !!process.env.SRCDEV_STANDALONE;
|
|
3
6
|
|
|
4
7
|
export default defineNuxtConfig({
|
|
@@ -22,7 +25,7 @@ export default defineNuxtConfig({
|
|
|
22
25
|
css: ["./app/assets/styles/main.css"],
|
|
23
26
|
modules: [
|
|
24
27
|
// Required by consumers — always included
|
|
25
|
-
"./modules/colour-scheme",
|
|
28
|
+
resolve("./modules/colour-scheme"),
|
|
26
29
|
"@nuxt/icon",
|
|
27
30
|
...(process.env.STORYBOOK ? [] : ["@nuxt/fonts"]),
|
|
28
31
|
"@nuxt/image",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "srcdev-nuxt-components",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "9.0.
|
|
4
|
+
"version": "9.0.15",
|
|
5
5
|
"main": "nuxt.config.ts",
|
|
6
6
|
"types": "types.d.ts",
|
|
7
7
|
"license": "MIT",
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
"files": [
|
|
36
36
|
".claude/",
|
|
37
37
|
"app/",
|
|
38
|
+
"modules/",
|
|
38
39
|
"nuxt.config.ts",
|
|
39
40
|
"types.d.ts"
|
|
40
41
|
],
|