@aerogel/cli 0.0.0-next.5953e1862a7c89a8fc80da087467d67d4f4e8c73 → 0.0.0-next.60462e474474f4e52d52d457f9150df63c117214

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.
Files changed (70) hide show
  1. package/bin/gel +4 -0
  2. package/dist/aerogel-cli.d.ts +2 -2
  3. package/dist/aerogel-cli.js +793 -0
  4. package/dist/aerogel-cli.js.map +1 -0
  5. package/package.json +20 -33
  6. package/src/cli.ts +26 -8
  7. package/src/commands/Command.ts +14 -9
  8. package/src/commands/create.test.ts +2 -2
  9. package/src/commands/create.ts +11 -11
  10. package/src/commands/generate-component.test.ts +23 -2
  11. package/src/commands/generate-component.ts +50 -20
  12. package/src/commands/generate-model.test.ts +1 -1
  13. package/src/commands/generate-model.ts +12 -12
  14. package/src/commands/generate-service.test.ts +2 -2
  15. package/src/commands/generate-service.ts +15 -15
  16. package/src/commands/info.ts +15 -0
  17. package/src/commands/install.test.ts +1 -15
  18. package/src/commands/install.ts +11 -12
  19. package/src/lib/App.ts +9 -6
  20. package/src/lib/Editor.ts +3 -4
  21. package/src/lib/File.mock.ts +7 -11
  22. package/src/lib/File.ts +3 -3
  23. package/src/lib/Log.mock.ts +4 -8
  24. package/src/lib/Log.test.ts +4 -4
  25. package/src/lib/Log.ts +7 -7
  26. package/src/lib/Shell.mock.ts +2 -2
  27. package/src/lib/Shell.ts +2 -2
  28. package/src/lib/Template.ts +19 -16
  29. package/src/lib/utils/app.ts +2 -2
  30. package/src/lib/utils/edit.ts +2 -2
  31. package/src/lib/utils/paths.ts +15 -7
  32. package/src/plugins/Plugin.ts +8 -27
  33. package/src/plugins/Solid.ts +15 -22
  34. package/src/plugins/Soukai.ts +4 -4
  35. package/src/testing/setup.ts +30 -31
  36. package/templates/app/.github/workflows/ci.yml +4 -4
  37. package/templates/app/.nvmrc +1 -1
  38. package/templates/app/.vscode/launch.json +1 -0
  39. package/templates/app/cypress/cypress.config.ts +2 -4
  40. package/templates/app/cypress/support/e2e.ts +1 -3
  41. package/templates/app/cypress/tsconfig.json +7 -8
  42. package/templates/app/index.html +2 -2
  43. package/templates/app/package.json +19 -18
  44. package/templates/app/src/App.vue +3 -3
  45. package/templates/app/src/assets/css/main.css +4 -0
  46. package/templates/app/src/main.ts +4 -4
  47. package/templates/app/tsconfig.json +3 -10
  48. package/templates/app/vite.config.ts +6 -4
  49. package/templates/component-button/[component.name].vue +42 -0
  50. package/templates/component-button-story/[component.name].story.vue +77 -0
  51. package/templates/component-checkbox/[component.name].vue +34 -0
  52. package/templates/component-checkbox-story/[component.name].story.vue +63 -0
  53. package/templates/component-input/[component.name].vue +6 -5
  54. package/templates/component-input-story/[component.name].story.vue +4 -4
  55. package/templates/service/[service.name].ts +1 -1
  56. package/bin/ag +0 -4
  57. package/dist/aerogel-cli.cjs.js +0 -2
  58. package/dist/aerogel-cli.cjs.js.map +0 -1
  59. package/dist/aerogel-cli.esm.js +0 -2
  60. package/dist/aerogel-cli.esm.js.map +0 -1
  61. package/src/plugins/Histoire.ts +0 -93
  62. package/templates/app/postcss.config.js +0 -6
  63. package/templates/app/src/assets/css/styles.css +0 -3
  64. package/templates/app/tailwind.config.js +0 -5
  65. package/templates/histoire/histoire.config.ts +0 -7
  66. package/templates/histoire/patches/histoire+0.17.6.patch +0 -13
  67. package/templates/histoire/src/main.histoire.ts +0 -8
  68. package/tsconfig.json +0 -11
  69. package/vite.config.ts +0 -14
  70. /package/src/{main.ts → index.ts} +0 -0
@@ -1,10 +1,8 @@
1
- import File from '@/lib/File';
2
- import Log from '@/lib/Log';
3
- import Plugin from '@/plugins/Plugin';
4
- import Shell from '@/lib/Shell';
5
- import { isLinkedLocalApp } from '@/lib/utils/app';
6
- import { packagePath } from '@/lib/utils/paths';
7
- import type { Editor } from '@/lib/Editor';
1
+ import File from '@aerogel/cli/lib/File';
2
+ import Log from '@aerogel/cli/lib/Log';
3
+ import Plugin from '@aerogel/cli/plugins/Plugin';
4
+ import Shell from '@aerogel/cli/lib/Shell';
5
+ import type { Editor } from '@aerogel/cli/lib/Editor';
8
6
 
9
7
  export class Solid extends Plugin {
10
8
 
@@ -12,21 +10,16 @@ export class Solid extends Plugin {
12
10
  super('solid');
13
11
  }
14
12
 
15
- protected async updateFiles(editor: Editor): Promise<void> {
16
- await this.updateTailwindConfig(editor, {
17
- content: isLinkedLocalApp()
18
- ? `'${packagePath('plugin-solid')}/dist/**/*.js'`
19
- : '\'./node_modules/@aerogel/plugin-solid/dist/**/*.js\'',
20
- });
21
-
13
+ protected override async updateFiles(editor: Editor): Promise<void> {
22
14
  await this.updateNpmScripts(editor);
23
15
  await this.updateGitIgnore();
24
16
  await super.updateFiles(editor);
25
17
  }
26
18
 
27
- protected async installNpmDependencies(): Promise<void> {
19
+ protected override async installNpmDependencies(): Promise<void> {
28
20
  await Shell.run('npm install soukai-solid@next --save-exact');
29
- await Shell.run('npm install @solid/community-server@7 --save');
21
+ await Shell.run('npm install @noeldemartin/solid-utils@next --save-exact');
22
+ await Shell.run('npm install @solid/community-server@7.1.6 --save-dev -E');
30
23
  await super.installNpmDependencies();
31
24
  }
32
25
 
@@ -50,17 +43,17 @@ export class Solid extends Plugin {
50
43
  .replace(
51
44
  '"cy:test": "start-server-and-test test:serve-app http-get://localhost:5001 cy:run",',
52
45
  '"cy:test": "start-server-and-test ' +
53
- 'test:serve-app http-get://localhost:5001 test:serve-pod http-get://localhost:4000 cy:run",',
46
+ 'test:serve-app http-get://localhost:5001 test:serve-pod http-get://localhost:3000 cy:run",',
54
47
  )
55
48
  .replace(
56
49
  '"dev": "vite",',
57
50
  '"dev": "vite",\n' +
58
- '"dev:serve-pod": "community-solid-server -c @css:config/file.json -p 4000 -f ./solid-data",',
51
+ '"dev:serve-pod": "community-solid-server -c @css:config/file.json -f ./solid",',
59
52
  )
60
53
  .replace(
61
- '"test:serve-app": "vite --port 5001"',
62
- '"test:serve-app": "vite --port 5001",\n' +
63
- '"test:serve-pod": "community-solid-server -p 4000 -l warn"',
54
+ '"test:serve-app": "vite --port 5001 --mode testing"',
55
+ '"test:serve-app": "vite --port 5001 --mode testing",\n' +
56
+ '"test:serve-pod": "community-solid-server -l warn"',
64
57
  ),
65
58
  );
66
59
 
@@ -72,7 +65,7 @@ export class Solid extends Plugin {
72
65
 
73
66
  const gitignore = File.read('.gitignore') ?? '';
74
67
 
75
- File.write('.gitignore', `${gitignore}/solid-data\n`);
68
+ File.write('.gitignore', `${gitignore}/solid\n`);
76
69
  }
77
70
 
78
71
  }
@@ -1,5 +1,5 @@
1
- import Plugin from '@/plugins/Plugin';
2
- import Shell from '@/lib/Shell';
1
+ import Plugin from '@aerogel/cli/plugins/Plugin';
2
+ import Shell from '@aerogel/cli/lib/Shell';
3
3
 
4
4
  export class Soukai extends Plugin {
5
5
 
@@ -7,12 +7,12 @@ export class Soukai extends Plugin {
7
7
  super('soukai');
8
8
  }
9
9
 
10
- protected async installNpmDependencies(): Promise<void> {
10
+ protected override async installNpmDependencies(): Promise<void> {
11
11
  await Shell.run('npm install soukai@next --save-exact');
12
12
  await super.installNpmDependencies();
13
13
  }
14
14
 
15
- protected getBootstrapConfig(): string {
15
+ protected override getBootstrapConfig(): string {
16
16
  return 'soukai({ models: import.meta.glob(\'@/models/*\', { eager: true }) })';
17
17
  }
18
18
 
@@ -1,31 +1,36 @@
1
- import { beforeEach, vi } from 'vitest';
2
- import { resolve } from 'path';
3
- import { setTestingNamespace } from '@noeldemartin/utils';
4
-
5
- import File from '@/lib/File';
6
- import FileMock from '@/lib/File.mock';
7
- import Log from '@/lib/Log';
8
- import LogMock from '@/lib/Log.mock';
9
- import Shell from '@/lib/Shell';
10
- import ShellMock from '@/lib/Shell.mock';
11
-
12
- setTestingNamespace(vi);
13
-
14
- File.setMockInstance(FileMock);
15
- Log.setMockInstance(LogMock);
16
- Shell.setMockInstance(ShellMock);
1
+ import { beforeAll, beforeEach, vi } from 'vitest';
2
+ import { resolve } from 'node:path';
3
+ import { setupFacadeMocks } from '@noeldemartin/testing';
4
+
5
+ import ShellMock from '@aerogel/cli/lib/Shell.mock';
6
+ import File from '@aerogel/cli/lib/File';
7
+ import FileMock from '@aerogel/cli/lib/File.mock';
8
+ import Log from '@aerogel/cli/lib/Log';
9
+ import LogMock from '@aerogel/cli/lib/Log.mock';
10
+ import Shell from '@aerogel/cli/lib/Shell';
11
+
12
+ beforeAll(() => {
13
+ File.setMockFacade(FileMock);
14
+ Log.setMockFacade(LogMock);
15
+ Shell.setMockFacade(ShellMock);
16
+ });
17
17
 
18
18
  beforeEach(() => {
19
- FileMock.reset();
20
- LogMock.reset();
21
-
22
19
  File.mock();
23
20
  Log.mock();
24
21
  Shell.mock();
25
22
  });
26
23
 
27
- vi.mock('@/lib/utils/app', async () => {
28
- const original = (await vi.importActual('@/lib/utils/app')) as object;
24
+ vi.mock('@noeldemartin/utils', async () => {
25
+ const original = (await vi.importActual('@noeldemartin/utils')) as object;
26
+
27
+ setupFacadeMocks();
28
+
29
+ return original;
30
+ });
31
+
32
+ vi.mock('@aerogel/cli/lib/utils/app', async () => {
33
+ const original = (await vi.importActual('@aerogel/cli/lib/utils/app')) as object;
29
34
 
30
35
  return {
31
36
  ...original,
@@ -34,8 +39,8 @@ vi.mock('@/lib/utils/app', async () => {
34
39
  };
35
40
  });
36
41
 
37
- vi.mock('@/lib/utils/edit', async () => {
38
- const original = (await vi.importActual('@/lib/utils/edit')) as object;
42
+ vi.mock('@aerogel/cli/lib/utils/edit', async () => {
43
+ const original = (await vi.importActual('@aerogel/cli/lib/utils/edit')) as object;
39
44
 
40
45
  return {
41
46
  ...original,
@@ -44,8 +49,8 @@ vi.mock('@/lib/utils/edit', async () => {
44
49
  });
45
50
 
46
51
  // TODO find out why these need to be mocked
47
- vi.mock('@/lib/utils/paths', async () => {
48
- const original = (await vi.importActual('@/lib/utils/paths')) as object;
52
+ vi.mock('@aerogel/cli/lib/utils/paths', async () => {
53
+ const original = (await vi.importActual('@aerogel/cli/lib/utils/paths')) as object;
49
54
 
50
55
  function basePath(path: string = '') {
51
56
  return resolve(__dirname, '../../', path);
@@ -66,9 +71,3 @@ vi.mock('@/lib/utils/paths', async () => {
66
71
  templatePath,
67
72
  };
68
73
  });
69
-
70
- vi.mock('mustache', async () => {
71
- const mustache = (await vi.importActual('mustache')) as { default: unknown };
72
-
73
- return mustache.default;
74
- });
@@ -6,8 +6,8 @@ jobs:
6
6
  ci:
7
7
  runs-on: ubuntu-latest
8
8
  steps:
9
- - uses: actions/checkout@v3
10
- - uses: actions/setup-node@v3
9
+ - uses: actions/checkout@v4
10
+ - uses: actions/setup-node@v4
11
11
  with:
12
12
  node-version-file: '.nvmrc'
13
13
  - run: npm ci
@@ -16,13 +16,13 @@ jobs:
16
16
  - run: npm run test:ci
17
17
  - run: npm run cy:test-snapshots:ci
18
18
  - name: Upload Cypress screenshots
19
- uses: actions/upload-artifact@v3
19
+ uses: actions/upload-artifact@v4
20
20
  if: ${{ failure() }}
21
21
  with:
22
22
  name: cypress_screenshots
23
23
  path: cypress/screenshots
24
24
  - name: Upload Cypress snapshots
25
- uses: actions/upload-artifact@v3
25
+ uses: actions/upload-artifact@v4
26
26
  if: ${{ failure() }}
27
27
  with:
28
28
  name: cypress_snapshots
@@ -1 +1 @@
1
- lts/hydrogen
1
+ v22.9.0
@@ -3,6 +3,7 @@
3
3
  "configurations": [
4
4
  {
5
5
  "type": "node",
6
+ "runtimeVersion": "22.14.0",
6
7
  "request": "launch",
7
8
  "name": "Debug Current Test File",
8
9
  "autoAttachChildProcesses": true,
@@ -1,4 +1,4 @@
1
- import install from '@aerogel/cypress/dist/plugin';
1
+ import { setupAerogelNodeEvents } from '@aerogel/cypress/config';
2
2
  import { defineConfig } from 'cypress';
3
3
 
4
4
  export default defineConfig({
@@ -9,8 +9,6 @@ export default defineConfig({
9
9
  runMode: 3,
10
10
  openMode: 0,
11
11
  },
12
- setupNodeEvents(on) {
13
- install(on);
14
- },
12
+ setupNodeEvents: setupAerogelNodeEvents,
15
13
  },
16
14
  });
@@ -1,3 +1 @@
1
- import install from '@aerogel/cypress';
2
-
3
- install();
1
+ import '@aerogel/cypress/support';
@@ -1,12 +1,11 @@
1
1
  {
2
+ "extends": "@tsconfig/node22/tsconfig.json",
3
+ "include": ["**/*.ts"],
2
4
  "compilerOptions": {
3
- "target": "es5",
4
- "lib": ["es5", "dom"],
5
- "types": ["cypress", "node"],
6
5
  "baseUrl": ".",
7
- "paths": {
8
- "@cy/*": ["./*"]
9
- }
10
- },
11
- "include": ["**/*.ts"]
6
+ "module": "ESNext",
7
+ "moduleResolution": "Bundler",
8
+ "lib": ["DOM"],
9
+ "types": ["node", "cypress"]
10
+ }
12
11
  }
@@ -1,12 +1,12 @@
1
1
  <!DOCTYPE html>
2
- <html lang="en" class="h-full w-full">
2
+ <html lang="en" class="size-full">
3
3
  <head>
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <title>{{ app.name }}</title>
7
7
  {{ socialMeta() }}
8
8
  </head>
9
- <body class="h-full w-full text-base font-normal leading-tight text-gray-900 antialiased">
9
+ <body class="size-full text-base font-normal leading-tight text-gray-900 antialiased">
10
10
  <div id="app" class="loading h-full"></div>
11
11
  <script type="module" src="./src/main.ts"></script>
12
12
  </body>
@@ -2,6 +2,7 @@
2
2
  "name": "<% app.slug %>",
3
3
  "version": "0.0.0",
4
4
  "private": true,
5
+ "type": "module",
5
6
  "scripts": {
6
7
  "build": "vite build",
7
8
  "cy:dev": "concurrently --kill-others \"npm run test:serve-app\" \"npm run cy:open\"",
@@ -11,23 +12,23 @@
11
12
  "cy:test-snapshots": "docker run -it -u `id -u ${whoami}` -e CYPRESS_SNAPSHOTS=true -v ./:/app -w /app cypress/base:18.16.0 sh -c \"npx cypress install && npm run cy:test\"",
12
13
  "cy:test-snapshots:ci": "docker run -e CYPRESS_SNAPSHOTS=true -v ./:/app -w /app cypress/base:18.16.0 sh -c \"npx cypress install && npm run cy:test\"",
13
14
  "dev": "vite",
14
- "lint": "noeldemartin-lint src",
15
+ "lint": "noeldemartin-lint src cypress",
15
16
  "test": "vitest --run",
16
17
  "test:ci": "vitest --run --reporter verbose",
17
- "test:serve-app": "vite --port 5001"
18
+ "test:serve-app": "vite --port 5001 --mode testing"
18
19
  },
19
20
  "dependencies": {
20
21
  "@aerogel/core": "<% &dependencies.aerogelCore %>",
21
22
  "@aerogel/plugin-i18n": "<% &dependencies.aerogelPluginI18n %>",
22
23
  "@aerogel/plugin-soukai": "<% &dependencies.aerogelPluginSoukai %>",
23
- "@intlify/unplugin-vue-i18n": "^0.12.2",
24
+ "@intlify/unplugin-vue-i18n": "^6.0.5",
24
25
  "@noeldemartin/utils": "next",
25
- "@tailwindcss/forms": "^0.5.3",
26
- "@tailwindcss/typography": "^0.5.9",
26
+ "@tailwindcss/forms": "^0.5.10",
27
+ "@tailwindcss/typography": "^0.5.16",
27
28
  "soukai": "next",
28
- "tailwindcss": "^3.3.2",
29
- "vue": "^3.3.0",
30
- "vue-i18n": "9.3.0-beta.19"
29
+ "tailwindcss": "^4.1.1",
30
+ "vue": "^3.5.13",
31
+ "vue-i18n": "^11.1.2"
31
32
  },
32
33
  "devDependencies": {
33
34
  "@aerogel/cli": "<% &dependencies.aerogelCli %>",
@@ -37,20 +38,20 @@
37
38
  "@noeldemartin/eslint-config-vue": "next",
38
39
  "@noeldemartin/scripts": "next",
39
40
  "@total-typescript/ts-reset": "^0.4.2",
41
+ "@tsconfig/node22": "^22.0.1",
40
42
  "@types/node": "^20.3.1",
43
+ "@vue/tsconfig": "^0.7.0",
41
44
  "autoprefixer": "^10.4.14",
42
45
  "concurrently": "^8.2.0",
43
- "cypress": "^12.17.0",
44
- "eslint": "^8.40.0",
45
- "prettier": "^2.8.8",
46
- "prettier-eslint-cli": "^7.1.0",
47
- "prettier-plugin-tailwindcss": "^0.2.8",
46
+ "cypress": "^14.2.0",
47
+ "prettier-plugin-tailwindcss": "^0.6.11",
48
48
  "start-server-and-test": "^2.0.0",
49
+ "typescript": "^5.8.2",
49
50
  "unplugin-icons": "^0.16.3",
50
51
  "unplugin-vue-components": "^0.24.1",
51
- "vite": "^4.3.0",
52
- "vitest": "^0.33.0",
53
- "vue-tsc": "^1.8.15"
52
+ "vite": "^6.2.2",
53
+ "vitest": "^3.0.9",
54
+ "vue-tsc": "^2.2.8"
54
55
  },
55
56
  "eslintConfig": {
56
57
  "extends": [
@@ -58,9 +59,9 @@
58
59
  ]
59
60
  },
60
61
  "prettier": {
62
+ "printWidth": 120,
61
63
  "plugins": [
62
64
  "prettier-plugin-tailwindcss"
63
- ],
64
- "printWidth": 120
65
+ ]
65
66
  }
66
67
  }
@@ -1,6 +1,6 @@
1
1
  <template>
2
- <AGAppLayout class="bg-blue-50">
3
- <main class="flex flex-grow flex-col items-center justify-center">
2
+ <AppLayout class="bg-blue-50">
3
+ <main class="flex grow flex-col items-center justify-center">
4
4
  <h1 class="text-4xl font-semibold">
5
5
  {{ $t('home.title') }}
6
6
  </h1>
@@ -8,5 +8,5 @@
8
8
  {{ $t('home.getStarted') }}
9
9
  </a>
10
10
  </main>
11
- </AGAppLayout>
11
+ </AppLayout>
12
12
  </template>
@@ -0,0 +1,4 @@
1
+ @import 'tailwindcss';
2
+ @import '@aerogel/core';
3
+ @plugin '@tailwindcss/forms';
4
+ @plugin '@tailwindcss/typography';
@@ -1,13 +1,13 @@
1
1
  import i18n from '@aerogel/plugin-i18n';
2
2
  import soukai from '@aerogel/plugin-soukai';
3
- import { bootstrapApplication } from '@aerogel/core';
3
+ import { bootstrap } from '@aerogel/core';
4
4
 
5
- import './assets/css/styles.css';
5
+ import './assets/css/main.css';
6
6
  import App from './App.vue';
7
7
 
8
- bootstrapApplication(App, {
8
+ bootstrap(App, {
9
9
  plugins: [
10
10
  i18n({ messages: import.meta.glob('@/lang/*.yaml') }),
11
- soukai({ models: import.meta.glob('@/models/*', { eager: true }) }),
11
+ soukai({ models: import.meta.glob(['@/models/*', '!**/*.test.ts'], { eager: true }) }),
12
12
  ],
13
13
  });
@@ -1,16 +1,9 @@
1
1
  {
2
+ "extends": "@vue/tsconfig/tsconfig.dom.json",
2
3
  "compilerOptions": {
3
- "target": "esnext",
4
- "module": "esnext",
5
- "moduleResolution": "node",
6
- "strict": true,
7
- "jsx": "preserve",
8
- "noUncheckedIndexedAccess": true,
9
- "skipLibCheck": true,
10
- "resolveJsonModule": true,
11
- "esModuleInterop": true,
12
- "lib": ["esnext", "dom"],
13
4
  "baseUrl": ".",
5
+ "module": "ESNext",
6
+ "moduleResolution": "Bundler",
14
7
  "paths": {
15
8
  "@/*": ["./src/*"]
16
9
  }
@@ -1,20 +1,22 @@
1
+ import { URL, fileURLToPath } from 'node:url';
2
+
1
3
  import Aerogel, { AerogelResolver } from '@aerogel/vite';
2
4
  import Components from 'unplugin-vue-components/vite';
3
5
  import I18n from '@intlify/unplugin-vue-i18n/vite';
4
6
  import Icons from 'unplugin-icons/vite';
5
7
  import IconsResolver from 'unplugin-icons/resolver';
6
8
  import { defineConfig } from 'vitest/config';
7
- import { resolve } from 'path';
8
9
 
9
10
  export default defineConfig({
10
- publicDir: resolve(__dirname, './src/assets/public/'),
11
+ build: { sourcemap: true },
12
+ publicDir: fileURLToPath(new URL('./src/assets/public/', import.meta.url)),
11
13
  plugins: [
12
14
  Aerogel({ name: '<% app.name %>' }),
13
15
  Components({
14
16
  dts: false,
15
17
  resolvers: [AerogelResolver(), IconsResolver()],
16
18
  }),
17
- I18n({ include: resolve(__dirname, './src/lang/**/*.yaml') }),
19
+ I18n({ include: fileURLToPath(new URL('./src/lang/**/*.yaml', import.meta.url)) }),
18
20
  Icons({
19
21
  iconCustomizer(_, __, props) {
20
22
  props['aria-hidden'] = 'true';
@@ -23,7 +25,7 @@ export default defineConfig({
23
25
  ],
24
26
  resolve: {
25
27
  alias: {
26
- '@': resolve(__dirname, './src'),
28
+ '@': fileURLToPath(new URL('./src', import.meta.url)),
27
29
  },
28
30
  },
29
31
  });
@@ -0,0 +1,42 @@
1
+ <template>
2
+ <HeadlessButton :class="variantClasses" :disabled="disabled">
3
+ <slot />
4
+ </HeadlessButton>
5
+ </template>
6
+
7
+ <script setup lang="ts">
8
+ import { Colors, booleanProp, enumProp, removeInteractiveClasses } from '@aerogel/core';
9
+ import { computed } from 'vue';
10
+
11
+ const props = defineProps({
12
+ color: enumProp(Colors, Colors.Primary),
13
+ disabled: booleanProp(),
14
+ });
15
+
16
+ const colorClasses = computed(() => {
17
+ switch (props.color) {
18
+ case Colors.Secondary:
19
+ // Add your custom color classes here.
20
+ return '';
21
+ case Colors.Clear:
22
+ // Add your custom color classes here.
23
+ return '';
24
+ case Colors.Danger:
25
+ // Add your custom color classes here.
26
+ return '';
27
+ case Colors.Primary:
28
+ default:
29
+ // Add your custom color classes here.
30
+ return '';
31
+ }
32
+ });
33
+
34
+ const variantClasses = computed(() => {
35
+ if (props.disabled) {
36
+ // Add additional classes for disabled state here.
37
+ return removeInteractiveClasses(colorClasses.value);
38
+ }
39
+
40
+ return colorClasses.value;
41
+ });
42
+ </script>
@@ -0,0 +1,77 @@
1
+ <template>
2
+ <Story :layout="{ type: 'grid' }">
3
+ <Variant title="Playground">
4
+ <<% component.name %> :color="color">
5
+ {{ content }}
6
+ </<% component.name %>>
7
+
8
+ <template #controls>
9
+ <HstText v-model="content" title="Content" />
10
+ <HstSelect v-model="color" title="Color" :options="colorOptions" />
11
+ </template>
12
+ </Variant>
13
+
14
+ <Variant title="Default">
15
+ <<% component.name %>>
16
+ Click me!
17
+ </<% component.name %>>
18
+ </Variant>
19
+
20
+ <Variant title="Hover">
21
+ <<% component.name %> class=":hover">
22
+ Click me!
23
+ </<% component.name %>>
24
+ </Variant>
25
+
26
+ <Variant title="Focus">
27
+ <<% component.name %> class=":focus :focus-visible">
28
+ Click me!
29
+ </<% component.name %>>
30
+ </Variant>
31
+
32
+ <Variant title="Disabled">
33
+ <<% component.name %> disabled>
34
+ You can't click me
35
+ </<% component.name %>>
36
+ </Variant>
37
+
38
+ <Variant title="Colors" :layout="{ width: '300px' }">
39
+ <div class="flex items-center gap-2">
40
+ <<% component.name %> color="primary">
41
+ Primary
42
+ </<% component.name %>>
43
+ <<% component.name %> color="secondary">
44
+ Secondary
45
+ </<% component.name %>>
46
+ <<% component.name %> color="danger">
47
+ Danger
48
+ </<% component.name %>>
49
+ <<% component.name %> color="clear">
50
+ Clear
51
+ </<% component.name %>>
52
+ </div>
53
+ </Variant>
54
+ </Story>
55
+ </template>
56
+
57
+ <script setup lang="ts">
58
+ import { Colors } from '@aerogel/core';
59
+ import { invert } from '@noeldemartin/utils';
60
+ import { ref } from 'vue';
61
+ import type { Color } from '@aerogel/core';
62
+
63
+ const content = ref('Click me!');
64
+ const color = ref<Color>(Colors.Primary);
65
+ const colorOptions = invert(Colors);
66
+ </script>
67
+
68
+ <style>
69
+ .story-<% component.slug %> {
70
+ grid-template-columns: repeat(2, 300px) !important;
71
+ }
72
+
73
+ .story-<% component.slug %> .variant-playground,
74
+ .story-<% component.slug %> .variant-colors{
75
+ grid-column: 1 / -1;
76
+ }
77
+ </style>
@@ -0,0 +1,34 @@
1
+ <template>
2
+ <HeadlessInput
3
+ ref="$input"
4
+ :name="name"
5
+ :class="className"
6
+ :label="label"
7
+ >
8
+ <HeadlessInputInput
9
+ v-bind="attrs"
10
+ type="checkbox"
11
+ />
12
+ <div v-if="$slots.default">
13
+ <HeadlessInputLabel>
14
+ <slot />
15
+ </HeadlessInputLabel>
16
+ <HeadlessInputError />
17
+ </div>
18
+ </HeadlessInput>
19
+ </template>
20
+
21
+ <script setup lang="ts">
22
+ import { HeadlessInputLabel, componentRef, stringProp, useInputAttrs } from '@aerogel/core';
23
+ import type { IHeadlessInput } from '@aerogel/core';
24
+
25
+ defineOptions({ inheritAttrs: false });
26
+ defineProps({
27
+ name: stringProp(),
28
+ label: stringProp(),
29
+ inputClass: stringProp(''),
30
+ });
31
+
32
+ const $input = componentRef<IHeadlessInput>();
33
+ const [attrs, className] = useInputAttrs();
34
+ </script>