@grundtone/nuxt 2.0.1
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/README.md +50 -0
- package/dist/module.d.mts +15 -0
- package/dist/module.json +12 -0
- package/dist/module.mjs +73 -0
- package/dist/runtime/plugin.d.ts +0 -0
- package/dist/runtime/plugin.js +19 -0
- package/dist/runtime/server/tsconfig.json +3 -0
- package/dist/types.d.mts +3 -0
- package/package.json +62 -0
package/README.md
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# @grundtone/nuxt
|
|
2
|
+
|
|
3
|
+
Nuxt 3 module for the [Grundtone](https://grundtone.com) design system. Auto-imports components from
|
|
4
|
+
`@grundtone/vue`, including components and composables.
|
|
5
|
+
|
|
6
|
+
## Installation
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
npm install -D @grundtone/nuxt
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Setup
|
|
13
|
+
|
|
14
|
+
```ts
|
|
15
|
+
// nuxt.config.ts
|
|
16
|
+
export default defineNuxtConfig({
|
|
17
|
+
modules: ['@grundtone/nuxt'],
|
|
18
|
+
grundtone: {
|
|
19
|
+
prefix: 'Grundtone', // component prefix (default)
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Components and composables are available globally without imports:
|
|
25
|
+
|
|
26
|
+
```vue
|
|
27
|
+
<template>
|
|
28
|
+
<GrundtoneButton variant="primary">Submit</GrundtoneButton>
|
|
29
|
+
</template>
|
|
30
|
+
|
|
31
|
+
<script setup>
|
|
32
|
+
const { theme, isDark } = useTheme();
|
|
33
|
+
</script>
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Options
|
|
37
|
+
|
|
38
|
+
| Option | Type | Default | Description |
|
|
39
|
+
| ------------- | --------- | ------------- | ----------------------- |
|
|
40
|
+
| `components` | `boolean` | `true` | Auto-import components |
|
|
41
|
+
| `composables` | `boolean` | `true` | Auto-import composables |
|
|
42
|
+
| `prefix` | `string` | `'Grundtone'` | Component name prefix |
|
|
43
|
+
|
|
44
|
+
## Documentation
|
|
45
|
+
|
|
46
|
+
See [grundtone.com](https://grundtone.com) for full setup guide and configuration options.
|
|
47
|
+
|
|
48
|
+
## License
|
|
49
|
+
|
|
50
|
+
MIT
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { NuxtModule } from '@nuxt/schema';
|
|
2
|
+
|
|
3
|
+
interface ModuleOptions {
|
|
4
|
+
theme?: {
|
|
5
|
+
light?: Record<string, unknown>;
|
|
6
|
+
dark?: Record<string, unknown>;
|
|
7
|
+
};
|
|
8
|
+
components?: boolean;
|
|
9
|
+
composables?: boolean;
|
|
10
|
+
prefix?: string;
|
|
11
|
+
}
|
|
12
|
+
declare const _default: NuxtModule<ModuleOptions>;
|
|
13
|
+
|
|
14
|
+
export { _default as default };
|
|
15
|
+
export type { ModuleOptions };
|
package/dist/module.json
ADDED
package/dist/module.mjs
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { defineNuxtModule, createResolver, addComponentsDir, addImportsDir, addImports } from '@nuxt/kit';
|
|
2
|
+
|
|
3
|
+
const module$1 = defineNuxtModule({
|
|
4
|
+
meta: {
|
|
5
|
+
name: "@grundtone/nuxt",
|
|
6
|
+
configKey: "grundtone",
|
|
7
|
+
compatibility: {
|
|
8
|
+
nuxt: ">=3.0.0"
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
// Default configuration options of the Nuxt module
|
|
12
|
+
defaults: {
|
|
13
|
+
components: true,
|
|
14
|
+
composables: true,
|
|
15
|
+
prefix: "GT"
|
|
16
|
+
},
|
|
17
|
+
setup(options, nuxt) {
|
|
18
|
+
const resolver = createResolver(import.meta.url);
|
|
19
|
+
nuxt.options.css.push(resolver.resolve("../../vue/dist/index.css"));
|
|
20
|
+
if (options.components) {
|
|
21
|
+
const componentDirs = ["atoms", "molecules", "organisms"];
|
|
22
|
+
for (const dir of componentDirs) {
|
|
23
|
+
addComponentsDir({
|
|
24
|
+
path: resolver.resolve(`../../vue/src/${dir}`),
|
|
25
|
+
pathPrefix: false,
|
|
26
|
+
prefix: options.prefix,
|
|
27
|
+
extensions: [".vue"],
|
|
28
|
+
pattern: "**/[A-Z]*.vue"
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (options.composables) {
|
|
33
|
+
addImportsDir(resolver.resolve("../../vue/src/composables"));
|
|
34
|
+
addImports([
|
|
35
|
+
{
|
|
36
|
+
name: "GT_ICON_REGISTRY_KEY",
|
|
37
|
+
from: "@grundtone/vue"
|
|
38
|
+
}
|
|
39
|
+
]);
|
|
40
|
+
const validators = [
|
|
41
|
+
"required",
|
|
42
|
+
"email",
|
|
43
|
+
"phone",
|
|
44
|
+
"cpr",
|
|
45
|
+
"cvr",
|
|
46
|
+
"minLength",
|
|
47
|
+
"maxLength",
|
|
48
|
+
"pattern",
|
|
49
|
+
"url",
|
|
50
|
+
"composeValidators"
|
|
51
|
+
];
|
|
52
|
+
addImports(
|
|
53
|
+
validators.map((name) => ({
|
|
54
|
+
name,
|
|
55
|
+
from: "@grundtone/utils"
|
|
56
|
+
}))
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
nuxt.options.runtimeConfig.public.grundtone = {
|
|
60
|
+
theme: options.theme,
|
|
61
|
+
components: options.components ?? true,
|
|
62
|
+
composables: options.composables ?? true,
|
|
63
|
+
prefix: options.prefix ?? "GT"
|
|
64
|
+
};
|
|
65
|
+
if (!options.theme && nuxt.options.devtools) {
|
|
66
|
+
console.warn(
|
|
67
|
+
'[Grundtone] Theme not configured. Add theme config to match your brand:\n grundtone: {\n theme: createTheme({ light: { primary: "#..." }, dark: { ... } })\n }\nSee: https://github.com/grundtone/grundtone#theme-configuration'
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
export { module$1 as default };
|
|
File without changes
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { defineNuxtPlugin, useRuntimeConfig } from "#app";
|
|
2
|
+
import { applyThemeToDOM, getSystemThemeMode } from "@grundtone/vue";
|
|
3
|
+
export default defineNuxtPlugin((_nuxtApp) => {
|
|
4
|
+
const config = useRuntimeConfig().public.grundtone;
|
|
5
|
+
if (config?.theme?.light && config?.theme?.dark) {
|
|
6
|
+
const mode = getSystemThemeMode();
|
|
7
|
+
const theme = mode === "dark" ? config.theme.dark : config.theme.light;
|
|
8
|
+
if (theme) {
|
|
9
|
+
applyThemeToDOM(theme);
|
|
10
|
+
}
|
|
11
|
+
if (import.meta.client) {
|
|
12
|
+
window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change", () => {
|
|
13
|
+
const m = getSystemThemeMode();
|
|
14
|
+
const t = m === "dark" ? config.theme.dark : config.theme.light;
|
|
15
|
+
if (t) applyThemeToDOM(t);
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
});
|
package/dist/types.d.mts
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@grundtone/nuxt",
|
|
3
|
+
"version": "2.0.1",
|
|
4
|
+
"description": "Nuxt module for Grundtone",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"private": false,
|
|
7
|
+
"type": "module",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/types.d.mts",
|
|
11
|
+
"import": "./dist/module.mjs"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"main": "./dist/module.mjs",
|
|
15
|
+
"typesVersions": {
|
|
16
|
+
"*": {
|
|
17
|
+
".": [
|
|
18
|
+
"./dist/types.d.mts"
|
|
19
|
+
]
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist"
|
|
24
|
+
],
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "https://github.com/grundtone/grundtone.git",
|
|
28
|
+
"directory": "packages/nuxt"
|
|
29
|
+
},
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"access": "public"
|
|
32
|
+
},
|
|
33
|
+
"scripts": {
|
|
34
|
+
"build": "nuxt-module-build build",
|
|
35
|
+
"build:nuxt": "nuxt-module-build build",
|
|
36
|
+
"dev": "nuxi dev ../../apps/playground/nuxt",
|
|
37
|
+
"dev:build": "nuxi build ../../apps/playground/nuxt",
|
|
38
|
+
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare ../../apps/playground/nuxt",
|
|
39
|
+
"test": "../../node_modules/.bin/vitest run",
|
|
40
|
+
"prepublishOnly": "test -d dist || pnpm run build"
|
|
41
|
+
},
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"@grundtone/core": "workspace:*",
|
|
44
|
+
"@grundtone/design-system": "workspace:*",
|
|
45
|
+
"@grundtone/icons": "workspace:*",
|
|
46
|
+
"@grundtone/vue": "workspace:*",
|
|
47
|
+
"@nuxt/kit": "^4.4.2"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@nuxt/eslint": "1.3.0",
|
|
51
|
+
"@nuxt/eslint-config": "^1.3.0",
|
|
52
|
+
"@nuxt/module-builder": "^1.0.2",
|
|
53
|
+
"@nuxt/schema": "^4.4.2",
|
|
54
|
+
"@nuxt/scripts": "0.11.6",
|
|
55
|
+
"@nuxt/test-utils": "^4.0.0",
|
|
56
|
+
"@types/node": "^20.17.45",
|
|
57
|
+
"@unhead/vue": "^2.0.8",
|
|
58
|
+
"changelogen": "^0.6.1",
|
|
59
|
+
"eslint": "^9.26.0",
|
|
60
|
+
"nuxt": "^4.4.2"
|
|
61
|
+
}
|
|
62
|
+
}
|