@atelier-ui/create-workspace 0.2.42 → 0.2.44
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/CHANGELOG.md +50 -4
- package/package.json +1 -1
- package/src/generators/preset/files/claude/agents/component-review.md +53 -0
- package/src/generators/preset/files/claude/commands/verify.md +24 -0
- package/src/generators/preset/files/claude/hooks/format-edited.sh +77 -0
- package/src/generators/preset/files/claude/skills/atelier-component/SKILL.md +84 -0
- package/src/generators/preset/files/contracts/README.md +29 -0
- package/src/generators/preset/files/contracts/button.contract.ts.template +20 -0
- package/src/generators/preset/files/contracts/types.ts.template +55 -0
- package/src/generators/preset/files/figma/snapshot.json +164 -0
- package/src/generators/preset/files/storybook/angular/atl-button.stories.ts.template +85 -0
- package/src/generators/preset/files/storybook/angular/main.ts.template +39 -0
- package/src/generators/preset/files/storybook/angular/preview.ts.template +30 -0
- package/src/generators/preset/files/storybook/angular/tsconfig.json +16 -0
- package/src/generators/preset/files/storybook/angular/vitest.config.ts.template +40 -0
- package/src/generators/preset/files/storybook/angular/vitest.setup.ts.template +14 -0
- package/src/generators/preset/files/storybook/react/atl-button.stories.tsx +86 -0
- package/src/generators/preset/files/storybook/react/main.ts.template +37 -0
- package/src/generators/preset/files/storybook/react/preview.tsx +29 -0
- package/src/generators/preset/files/storybook/react/vitest.config.ts.template +32 -0
- package/src/generators/preset/files/storybook/react/vitest.setup.ts.template +8 -0
- package/src/generators/preset/files/storybook/vue/atl-button.stories.ts.template +89 -0
- package/src/generators/preset/files/storybook/vue/main.ts.template +38 -0
- package/src/generators/preset/files/storybook/vue/preview.ts.template +29 -0
- package/src/generators/preset/files/storybook/vue/vitest.config.ts.template +32 -0
- package/src/generators/preset/files/storybook/vue/vitest.setup.ts.template +9 -0
- package/src/generators/preset/files/styles/tokens.css +59 -43
- package/src/generators/preset/files/testing/angular/atl-button.spec.ts.template +27 -0
- package/src/generators/preset/files/testing/angular/test-setup.ts.template +6 -0
- package/src/generators/preset/files/testing/angular/vitest.unit.config.ts.template +36 -0
- package/src/generators/preset/files/testing/react/atl-button.spec.tsx +22 -0
- package/src/generators/preset/files/testing/react/test-setup.ts.template +1 -0
- package/src/generators/preset/files/testing/react/vitest.unit.config.ts.template +21 -0
- package/src/generators/preset/files/testing/vue/atl-button.spec.ts.template +25 -0
- package/src/generators/preset/files/testing/vue/test-setup.ts.template +1 -0
- package/src/generators/preset/files/testing/vue/vitest.unit.config.ts.template +50 -0
- package/src/generators/preset/files/tools/scripts/check-contracts.mjs +1644 -0
- package/src/generators/preset/files/tools/scripts/figma-snapshot-contracts.mjs +370 -0
- package/src/generators/preset/files/tools/scripts/lib/docgen.mjs +573 -0
- package/src/generators/preset/files/tools/scripts/lib/ts-eval.js +126 -0
- package/src/generators/preset/files/tools/scripts/preflight.mjs +163 -31
- package/src/generators/preset/files/tools/stylelint-rules/index.js +21 -0
- package/src/generators/preset/files/tools/stylelint-rules/no-primitive-token.js +362 -0
- package/src/generators/preset/files/tools/stylelint-rules/no-raw-color-literal.js +154 -0
- package/src/generators/preset/files/tools/stylelint-rules/no-token-bypass.js +497 -0
- package/src/generators/preset/files/tools/stylelint-rules/no-undeclared-token.js +122 -0
- package/src/generators/preset/files/tools/stylelint-rules/utils.js +71 -0
- package/src/generators/preset/preset.d.ts +1 -0
- package/src/generators/preset/preset.js +1463 -110
- package/src/generators/preset/preset.js.map +1 -1
- package/src/generators/preset/schema.d.ts +3 -1
- package/src/generators/preset/schema.json +23 -3
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/angular-vite';
|
|
2
|
+
import { argsToTemplate } from '@storybook/angular-vite';
|
|
3
|
+
import { expect, userEvent } from 'storybook/test';
|
|
4
|
+
import { AtlButton } from '@atelier-ui/angular';
|
|
5
|
+
|
|
6
|
+
// A working pattern to copy: duplicate this file for another component from
|
|
7
|
+
// @atelier-ui/angular, or add more `args`/`argTypes` below.
|
|
8
|
+
//
|
|
9
|
+
// ADR-0121: the stories are the claims — one story per `variant` value and
|
|
10
|
+
// per Boolean state (`disabled`, `loading`), args-based, plus exactly one
|
|
11
|
+
// `play` function with a real assertion (not a decorative one).
|
|
12
|
+
const meta: Meta<AtlButton> = {
|
|
13
|
+
title: 'AtlButton',
|
|
14
|
+
component: AtlButton,
|
|
15
|
+
tags: ['autodocs'],
|
|
16
|
+
render: (args) => ({
|
|
17
|
+
props: args,
|
|
18
|
+
template: `<atl-button ${argsToTemplate(args)}>Button</atl-button>`,
|
|
19
|
+
}),
|
|
20
|
+
argTypes: {
|
|
21
|
+
variant: {
|
|
22
|
+
control: 'select',
|
|
23
|
+
options: ['primary', 'secondary', 'outline', 'danger'],
|
|
24
|
+
},
|
|
25
|
+
size: {
|
|
26
|
+
control: 'select',
|
|
27
|
+
options: ['sm', 'md', 'lg'],
|
|
28
|
+
},
|
|
29
|
+
disabled: { control: 'boolean' },
|
|
30
|
+
loading: { control: 'boolean' },
|
|
31
|
+
},
|
|
32
|
+
args: {
|
|
33
|
+
variant: 'primary',
|
|
34
|
+
size: 'md',
|
|
35
|
+
disabled: false,
|
|
36
|
+
loading: false,
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export default meta;
|
|
41
|
+
type Story = StoryObj<AtlButton>;
|
|
42
|
+
|
|
43
|
+
// One story per `variant` value.
|
|
44
|
+
//
|
|
45
|
+
// The one `play` function in this file lives here, on an enabled button: it
|
|
46
|
+
// proves the button actually fires its click handler when clicked, not just
|
|
47
|
+
// that it looks clickable.
|
|
48
|
+
export const Primary: Story = {
|
|
49
|
+
args: { variant: 'primary' },
|
|
50
|
+
render: (args) => ({
|
|
51
|
+
props: { ...args, clicked: false },
|
|
52
|
+
template: `
|
|
53
|
+
<div style="display:flex;flex-direction:column;gap:0.5rem;align-items:flex-start">
|
|
54
|
+
<atl-button ${argsToTemplate(args)} (click)="clicked = true">Button</atl-button>
|
|
55
|
+
<span>{{ clicked ? 'clicked' : 'not clicked' }}</span>
|
|
56
|
+
</div>
|
|
57
|
+
`,
|
|
58
|
+
}),
|
|
59
|
+
play: async ({ canvas }) => {
|
|
60
|
+
const button = canvas.getByRole('button');
|
|
61
|
+
await userEvent.click(button);
|
|
62
|
+
await expect(canvas.getByText('clicked')).toBeInTheDocument();
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export const Secondary: Story = {
|
|
67
|
+
args: { variant: 'secondary' },
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export const Outline: Story = {
|
|
71
|
+
args: { variant: 'outline' },
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export const Danger: Story = {
|
|
75
|
+
args: { variant: 'danger' },
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
// One story per Boolean state.
|
|
79
|
+
export const Loading: Story = {
|
|
80
|
+
args: { loading: true },
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export const Disabled: Story = {
|
|
84
|
+
args: { disabled: true },
|
|
85
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { fileURLToPath } from 'node:url';
|
|
2
|
+
import { dirname } from 'node:path';
|
|
3
|
+
import type { StorybookConfig } from '@storybook/angular-vite';
|
|
4
|
+
|
|
5
|
+
const config: StorybookConfig = {
|
|
6
|
+
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
|
|
7
|
+
addons: [
|
|
8
|
+
// Emits manifests/{docs,components}.json, which is what lets the
|
|
9
|
+
// storybookjs/mcp skills' docs-list/docs-show tools and dev tools
|
|
10
|
+
// (stories-preview, get-storybook-story-instructions) work against this
|
|
11
|
+
// workspace's own components. addon-vitest below is what makes the
|
|
12
|
+
// skills' `test-run` tool work too, once a local Storybook is running —
|
|
13
|
+
// see vitest.config.ts and CLAUDE.md's "The contract loop".
|
|
14
|
+
'@storybook/addon-mcp',
|
|
15
|
+
getAbsolutePath('@storybook/addon-vitest'),
|
|
16
|
+
getAbsolutePath('@storybook/addon-a11y'),
|
|
17
|
+
getAbsolutePath('@storybook/addon-docs'),
|
|
18
|
+
],
|
|
19
|
+
framework: {
|
|
20
|
+
name: getAbsolutePath('@storybook/angular-vite'),
|
|
21
|
+
options: {},
|
|
22
|
+
},
|
|
23
|
+
docs: {},
|
|
24
|
+
features: {
|
|
25
|
+
// Read by Storybook's core-server at build time and by addon-mcp's
|
|
26
|
+
// docs-toolset gate on a dev server.
|
|
27
|
+
componentsManifest: true,
|
|
28
|
+
// Angular's docgen server is opt-in until Storybook 11 for some adapters;
|
|
29
|
+
// explicit here so `components.json` carries real prop tables, not just
|
|
30
|
+
// id/name.
|
|
31
|
+
experimentalDocgenServer: true,
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export default config;
|
|
36
|
+
|
|
37
|
+
function getAbsolutePath(value: string): string {
|
|
38
|
+
return dirname(fileURLToPath(import.meta.resolve(`${value}/package.json`)));
|
|
39
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Preview } from '@storybook/angular-vite';
|
|
2
|
+
|
|
3
|
+
// Side-effect import: Vite injects tokens.css globally into the page
|
|
4
|
+
import '../src/styles/tokens.css';
|
|
5
|
+
|
|
6
|
+
const preview: Preview = {
|
|
7
|
+
parameters: {
|
|
8
|
+
a11y: {
|
|
9
|
+
// 'error' - fail CI on a11y violations (chosen — ADR-0121 S0)
|
|
10
|
+
// 'todo' - show a11y violations in the test UI only
|
|
11
|
+
// 'off' - skip a11y checks entirely
|
|
12
|
+
test: 'error',
|
|
13
|
+
},
|
|
14
|
+
controls: {
|
|
15
|
+
matchers: {
|
|
16
|
+
color: /(background|color)$/i,
|
|
17
|
+
date: /Date$/i,
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
backgrounds: {
|
|
21
|
+
options: {
|
|
22
|
+
light: { name: 'light', value: '#ffffff' },
|
|
23
|
+
subtle: { name: 'subtle', value: '#f5f5f5' },
|
|
24
|
+
dark: { name: 'dark', value: '#1a1a2e' },
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export default preview;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"outDir": "",
|
|
5
|
+
"types": ["node"],
|
|
6
|
+
"ignoreDeprecations": "6.0"
|
|
7
|
+
},
|
|
8
|
+
"include": [
|
|
9
|
+
"../src/**/*.stories.ts",
|
|
10
|
+
"../src/**/*.stories.tsx",
|
|
11
|
+
"../src/**/*.mdx",
|
|
12
|
+
"./preview.ts",
|
|
13
|
+
"./main.ts"
|
|
14
|
+
],
|
|
15
|
+
"exclude": ["../src/**/*.spec.ts", "../src/**/*.test.ts"]
|
|
16
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { defineConfig } from 'vitest/config';
|
|
2
|
+
import { storybookTest } from '@storybook/addon-vitest/vitest-plugin';
|
|
3
|
+
// Same plugin libs/angular/vite.config.mts uses in the monorepo. Without it,
|
|
4
|
+
// `@angular/common`'s partially-Ivy-compiled `PlatformLocation` factory has no
|
|
5
|
+
// linker/JIT compiler wired up in this Vite pipeline, and merely importing
|
|
6
|
+
// `@storybook/angular-vite` in vitest.setup.ts throws "The injectable
|
|
7
|
+
// 'PlatformLocation' needs to be compiled using the JIT compiler, but
|
|
8
|
+
// '@angular/compiler' is not available" before a single story loads.
|
|
9
|
+
// React/Vue don't need an equivalent because their frameworks ship no such
|
|
10
|
+
// partially-compiled npm packages.
|
|
11
|
+
import angular from '@analogjs/vite-plugin-angular';
|
|
12
|
+
import { playwright } from '@vitest/browser-playwright';
|
|
13
|
+
|
|
14
|
+
// Named `vitest.config.ts` (not `vitest.storybook.config.ts`, the name the
|
|
15
|
+
// monorepo's own libs/angular uses) so `@storybook/addon-vitest`'s `test-run`
|
|
16
|
+
// tool finds it directly: its VitestManager walks up from a story's
|
|
17
|
+
// `.storybook` directory looking for the nearest vitest/vite config, and
|
|
18
|
+
// this is the standard filename it looks for first. The monorepo needs a
|
|
19
|
+
// root `vitest.config.mjs` with an explicit `projects: [...]` list because
|
|
20
|
+
// each library's own file has a non-standard name; a single-app scaffold
|
|
21
|
+
// doesn't need that indirection.
|
|
22
|
+
export default defineConfig({
|
|
23
|
+
plugins: [
|
|
24
|
+
angular(),
|
|
25
|
+
storybookTest({
|
|
26
|
+
configDir: new URL('./.storybook', import.meta.url).pathname,
|
|
27
|
+
}),
|
|
28
|
+
],
|
|
29
|
+
test: {
|
|
30
|
+
name: 'storybook:angular',
|
|
31
|
+
globals: true,
|
|
32
|
+
browser: {
|
|
33
|
+
enabled: true,
|
|
34
|
+
headless: true,
|
|
35
|
+
provider: playwright(),
|
|
36
|
+
instances: [{ browser: 'chromium' }],
|
|
37
|
+
},
|
|
38
|
+
setupFiles: ['.storybook/vitest.setup.ts'],
|
|
39
|
+
},
|
|
40
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/// <reference types="vitest/globals" />
|
|
2
|
+
// '@storybook/angular-vite', not '@storybook/angular' (which the monorepo's
|
|
3
|
+
// own libs/angular/.storybook/vitest.setup.ts imports): this scaffold
|
|
4
|
+
// deliberately never installs '@storybook/angular' — its peer on
|
|
5
|
+
// @angular-devkit/build-angular collides with a freshly scaffolded Angular
|
|
6
|
+
// app's own build tooling (see the STORYBOOK_FRAMEWORK_PACKAGE comment in
|
|
7
|
+
// preset.ts). '@storybook/angular-vite' re-exports the same
|
|
8
|
+
// setProjectAnnotations.
|
|
9
|
+
import { setProjectAnnotations } from '@storybook/angular-vite';
|
|
10
|
+
import * as projectAnnotations from './preview';
|
|
11
|
+
|
|
12
|
+
const project = setProjectAnnotations([projectAnnotations]);
|
|
13
|
+
|
|
14
|
+
beforeAll(project.beforeAll);
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { expect, userEvent } from 'storybook/test';
|
|
4
|
+
import { AtlButton } from '@atelier-ui/react';
|
|
5
|
+
|
|
6
|
+
// A working pattern to copy: duplicate this file for another component from
|
|
7
|
+
// @atelier-ui/react, or add more `args`/`argTypes` below.
|
|
8
|
+
//
|
|
9
|
+
// ADR-0121: the stories are the claims — one story per `variant` value and
|
|
10
|
+
// per Boolean state (`disabled`, `loading`), args-based, plus exactly one
|
|
11
|
+
// `play` function with a real assertion (not a decorative one).
|
|
12
|
+
const meta: Meta<typeof AtlButton> = {
|
|
13
|
+
title: 'AtlButton',
|
|
14
|
+
component: AtlButton,
|
|
15
|
+
tags: ['autodocs'],
|
|
16
|
+
argTypes: {
|
|
17
|
+
variant: {
|
|
18
|
+
control: 'select',
|
|
19
|
+
options: ['primary', 'secondary', 'outline', 'danger'],
|
|
20
|
+
},
|
|
21
|
+
size: { control: 'select', options: ['sm', 'md', 'lg'] },
|
|
22
|
+
disabled: { control: 'boolean' },
|
|
23
|
+
loading: { control: 'boolean' },
|
|
24
|
+
},
|
|
25
|
+
args: {
|
|
26
|
+
variant: 'primary',
|
|
27
|
+
size: 'md',
|
|
28
|
+
disabled: false,
|
|
29
|
+
loading: false,
|
|
30
|
+
children: 'Button',
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export default meta;
|
|
35
|
+
type Story = StoryObj<typeof AtlButton>;
|
|
36
|
+
|
|
37
|
+
// One story per `variant` value.
|
|
38
|
+
//
|
|
39
|
+
// The one `play` function in this file lives here, on an enabled button: it
|
|
40
|
+
// proves the button actually fires its click handler when clicked, not just
|
|
41
|
+
// that it looks clickable.
|
|
42
|
+
export const Primary: Story = {
|
|
43
|
+
args: { variant: 'primary' },
|
|
44
|
+
render: function PrimaryRender(args) {
|
|
45
|
+
const [clicked, setClicked] = useState(false);
|
|
46
|
+
return (
|
|
47
|
+
<div
|
|
48
|
+
style={{
|
|
49
|
+
display: 'flex',
|
|
50
|
+
flexDirection: 'column',
|
|
51
|
+
gap: '0.5rem',
|
|
52
|
+
alignItems: 'flex-start',
|
|
53
|
+
}}
|
|
54
|
+
>
|
|
55
|
+
<AtlButton {...args} onClick={() => setClicked(true)} />
|
|
56
|
+
<span>{clicked ? 'clicked' : 'not clicked'}</span>
|
|
57
|
+
</div>
|
|
58
|
+
);
|
|
59
|
+
},
|
|
60
|
+
play: async ({ canvas }) => {
|
|
61
|
+
const button = canvas.getByRole('button');
|
|
62
|
+
await userEvent.click(button);
|
|
63
|
+
await expect(canvas.getByText('clicked')).toBeInTheDocument();
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export const Secondary: Story = {
|
|
68
|
+
args: { variant: 'secondary' },
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export const Outline: Story = {
|
|
72
|
+
args: { variant: 'outline' },
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export const Danger: Story = {
|
|
76
|
+
args: { variant: 'danger' },
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
// One story per Boolean state.
|
|
80
|
+
export const Loading: Story = {
|
|
81
|
+
args: { loading: true },
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export const Disabled: Story = {
|
|
85
|
+
args: { disabled: true },
|
|
86
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { fileURLToPath } from 'node:url';
|
|
2
|
+
import { dirname } from 'node:path';
|
|
3
|
+
import type { StorybookConfig } from '@storybook/react-vite';
|
|
4
|
+
|
|
5
|
+
const config: StorybookConfig = {
|
|
6
|
+
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
|
|
7
|
+
addons: [
|
|
8
|
+
// Emits manifests/{docs,components}.json, which is what lets the
|
|
9
|
+
// storybookjs/mcp skills' docs-list/docs-show tools and dev tools
|
|
10
|
+
// (stories-preview, get-storybook-story-instructions) work against this
|
|
11
|
+
// workspace's own components. addon-vitest below is what makes the
|
|
12
|
+
// skills' `test-run` tool work too, once a local Storybook is running —
|
|
13
|
+
// see vitest.config.ts and CLAUDE.md's "The contract loop".
|
|
14
|
+
'@storybook/addon-mcp',
|
|
15
|
+
getAbsolutePath('@storybook/addon-vitest'),
|
|
16
|
+
getAbsolutePath('@storybook/addon-a11y'),
|
|
17
|
+
getAbsolutePath('@storybook/addon-docs'),
|
|
18
|
+
],
|
|
19
|
+
framework: {
|
|
20
|
+
name: getAbsolutePath('@storybook/react-vite'),
|
|
21
|
+
options: {},
|
|
22
|
+
},
|
|
23
|
+
docs: {},
|
|
24
|
+
features: {
|
|
25
|
+
// Read by Storybook's core-server at build time and by addon-mcp's
|
|
26
|
+
// docs-toolset gate on a dev server. React defaults its own docgen server
|
|
27
|
+
// (react-docgen), unlike Angular and Vue — no experimentalDocgenServer
|
|
28
|
+
// flag needed here.
|
|
29
|
+
componentsManifest: true,
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export default config;
|
|
34
|
+
|
|
35
|
+
function getAbsolutePath(value: string): string {
|
|
36
|
+
return dirname(fileURLToPath(import.meta.resolve(`${value}/package.json`)));
|
|
37
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Preview } from '@storybook/react';
|
|
2
|
+
|
|
3
|
+
import '../src/styles/tokens.css';
|
|
4
|
+
|
|
5
|
+
const preview: Preview = {
|
|
6
|
+
parameters: {
|
|
7
|
+
a11y: {
|
|
8
|
+
// 'error' - fail CI on a11y violations (chosen — ADR-0121 S0)
|
|
9
|
+
// 'todo' - show a11y violations in the test UI only
|
|
10
|
+
// 'off' - skip a11y checks entirely
|
|
11
|
+
test: 'error',
|
|
12
|
+
},
|
|
13
|
+
controls: {
|
|
14
|
+
matchers: {
|
|
15
|
+
color: /(background|color)$/i,
|
|
16
|
+
date: /Date$/i,
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
backgrounds: {
|
|
20
|
+
options: {
|
|
21
|
+
light: { name: 'light', value: '#ffffff' },
|
|
22
|
+
subtle: { name: 'subtle', value: '#f5f5f5' },
|
|
23
|
+
dark: { name: 'dark', value: '#1a1a2e' },
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export default preview;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { defineConfig } from 'vitest/config';
|
|
2
|
+
import { storybookTest } from '@storybook/addon-vitest/vitest-plugin';
|
|
3
|
+
import react from '@vitejs/plugin-react';
|
|
4
|
+
import { playwright } from '@vitest/browser-playwright';
|
|
5
|
+
|
|
6
|
+
// Named `vitest.config.ts` (not `vitest.storybook.config.ts`, the name the
|
|
7
|
+
// monorepo's own libs/react uses) so `@storybook/addon-vitest`'s `test-run`
|
|
8
|
+
// tool finds it directly: its VitestManager walks up from a story's
|
|
9
|
+
// `.storybook` directory looking for the nearest vitest/vite config, and
|
|
10
|
+
// this is the standard filename it looks for first. The monorepo needs a
|
|
11
|
+
// root `vitest.config.mjs` with an explicit `projects: [...]` list because
|
|
12
|
+
// each library's own file has a non-standard name; a single-app scaffold
|
|
13
|
+
// doesn't need that indirection.
|
|
14
|
+
export default defineConfig({
|
|
15
|
+
plugins: [
|
|
16
|
+
react(),
|
|
17
|
+
storybookTest({
|
|
18
|
+
configDir: new URL('./.storybook', import.meta.url).pathname,
|
|
19
|
+
}),
|
|
20
|
+
],
|
|
21
|
+
test: {
|
|
22
|
+
name: 'storybook:react',
|
|
23
|
+
globals: true,
|
|
24
|
+
browser: {
|
|
25
|
+
enabled: true,
|
|
26
|
+
headless: true,
|
|
27
|
+
provider: playwright(),
|
|
28
|
+
instances: [{ browser: 'chromium' }],
|
|
29
|
+
},
|
|
30
|
+
setupFiles: ['.storybook/vitest.setup.ts'],
|
|
31
|
+
},
|
|
32
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as a11yAddonAnnotations from '@storybook/addon-a11y/preview';
|
|
2
|
+
/// <reference types="vitest/globals" />
|
|
3
|
+
import { setProjectAnnotations } from '@storybook/react';
|
|
4
|
+
import * as projectAnnotations from './preview';
|
|
5
|
+
|
|
6
|
+
const project = setProjectAnnotations([a11yAddonAnnotations, projectAnnotations]);
|
|
7
|
+
|
|
8
|
+
beforeAll(project.beforeAll);
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/vue3';
|
|
2
|
+
import { ref } from 'vue';
|
|
3
|
+
import { expect, userEvent } from 'storybook/test';
|
|
4
|
+
import { AtlButton } from '@atelier-ui/vue';
|
|
5
|
+
|
|
6
|
+
// A working pattern to copy: duplicate this file for another component from
|
|
7
|
+
// @atelier-ui/vue, or add more `args`/`argTypes` below.
|
|
8
|
+
//
|
|
9
|
+
// ADR-0121: the stories are the claims — one story per `variant` value and
|
|
10
|
+
// per Boolean state (`disabled`, `loading`), args-based, plus exactly one
|
|
11
|
+
// `play` function with a real assertion (not a decorative one).
|
|
12
|
+
const meta: Meta<typeof AtlButton> = {
|
|
13
|
+
title: 'AtlButton',
|
|
14
|
+
component: AtlButton,
|
|
15
|
+
tags: ['autodocs'],
|
|
16
|
+
render: (args) => ({
|
|
17
|
+
components: { AtlButton },
|
|
18
|
+
setup() {
|
|
19
|
+
return { args };
|
|
20
|
+
},
|
|
21
|
+
template: '<AtlButton v-bind="args">Button</AtlButton>',
|
|
22
|
+
}),
|
|
23
|
+
argTypes: {
|
|
24
|
+
variant: {
|
|
25
|
+
control: 'select',
|
|
26
|
+
options: ['primary', 'secondary', 'outline', 'danger'],
|
|
27
|
+
},
|
|
28
|
+
size: { control: 'select', options: ['sm', 'md', 'lg'] },
|
|
29
|
+
disabled: { control: 'boolean' },
|
|
30
|
+
loading: { control: 'boolean' },
|
|
31
|
+
},
|
|
32
|
+
args: {
|
|
33
|
+
variant: 'primary',
|
|
34
|
+
size: 'md',
|
|
35
|
+
disabled: false,
|
|
36
|
+
loading: false,
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export default meta;
|
|
41
|
+
type Story = StoryObj<typeof AtlButton>;
|
|
42
|
+
|
|
43
|
+
// One story per `variant` value.
|
|
44
|
+
//
|
|
45
|
+
// The one `play` function in this file lives here, on an enabled button: it
|
|
46
|
+
// proves the button actually fires its click handler when clicked, not just
|
|
47
|
+
// that it looks clickable.
|
|
48
|
+
export const Primary: Story = {
|
|
49
|
+
args: { variant: 'primary' },
|
|
50
|
+
render: (args) => ({
|
|
51
|
+
components: { AtlButton },
|
|
52
|
+
setup() {
|
|
53
|
+
const clicked = ref(false);
|
|
54
|
+
return { args, clicked };
|
|
55
|
+
},
|
|
56
|
+
template: `
|
|
57
|
+
<div style="display:flex;flex-direction:column;gap:0.5rem;align-items:flex-start">
|
|
58
|
+
<AtlButton v-bind="args" @click="clicked = true">Button</AtlButton>
|
|
59
|
+
<span>{{ clicked ? 'clicked' : 'not clicked' }}</span>
|
|
60
|
+
</div>
|
|
61
|
+
`,
|
|
62
|
+
}),
|
|
63
|
+
play: async ({ canvas }) => {
|
|
64
|
+
const button = canvas.getByRole('button');
|
|
65
|
+
await userEvent.click(button);
|
|
66
|
+
await expect(canvas.getByText('clicked')).toBeInTheDocument();
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export const Secondary: Story = {
|
|
71
|
+
args: { variant: 'secondary' },
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export const Outline: Story = {
|
|
75
|
+
args: { variant: 'outline' },
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export const Danger: Story = {
|
|
79
|
+
args: { variant: 'danger' },
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
// One story per Boolean state.
|
|
83
|
+
export const Loading: Story = {
|
|
84
|
+
args: { loading: true },
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export const Disabled: Story = {
|
|
88
|
+
args: { disabled: true },
|
|
89
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { fileURLToPath } from 'node:url';
|
|
2
|
+
import { dirname } from 'node:path';
|
|
3
|
+
import type { StorybookConfig } from '@storybook/vue3-vite';
|
|
4
|
+
|
|
5
|
+
const config: StorybookConfig = {
|
|
6
|
+
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|ts)'],
|
|
7
|
+
addons: [
|
|
8
|
+
// Emits manifests/{docs,components}.json, which is what lets the
|
|
9
|
+
// storybookjs/mcp skills' docs-list/docs-show tools and dev tools
|
|
10
|
+
// (stories-preview, get-storybook-story-instructions) work against this
|
|
11
|
+
// workspace's own components. addon-vitest below is what makes the
|
|
12
|
+
// skills' `test-run` tool work too, once a local Storybook is running —
|
|
13
|
+
// see vitest.config.ts and CLAUDE.md's "The contract loop".
|
|
14
|
+
'@storybook/addon-mcp',
|
|
15
|
+
getAbsolutePath('@storybook/addon-vitest'),
|
|
16
|
+
getAbsolutePath('@storybook/addon-a11y'),
|
|
17
|
+
getAbsolutePath('@storybook/addon-docs'),
|
|
18
|
+
],
|
|
19
|
+
framework: {
|
|
20
|
+
name: getAbsolutePath('@storybook/vue3-vite'),
|
|
21
|
+
options: {},
|
|
22
|
+
},
|
|
23
|
+
docs: {},
|
|
24
|
+
features: {
|
|
25
|
+
// Read by Storybook's core-server at build time and by addon-mcp's
|
|
26
|
+
// docs-toolset gate on a dev server.
|
|
27
|
+
componentsManifest: true,
|
|
28
|
+
// Vue's docgen server is opt-in under `@storybook/vue3-vite` until
|
|
29
|
+
// Storybook 11 — without this flag components.json has no props.
|
|
30
|
+
experimentalDocgenServer: true,
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export default config;
|
|
35
|
+
|
|
36
|
+
function getAbsolutePath(value: string): string {
|
|
37
|
+
return dirname(fileURLToPath(import.meta.resolve(`${value}/package.json`)));
|
|
38
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Preview } from '@storybook/vue3';
|
|
2
|
+
|
|
3
|
+
import '../src/styles/tokens.css';
|
|
4
|
+
|
|
5
|
+
const preview: Preview = {
|
|
6
|
+
parameters: {
|
|
7
|
+
a11y: {
|
|
8
|
+
// 'error' - fail CI on a11y violations (chosen — ADR-0121 S0)
|
|
9
|
+
// 'todo' - show a11y violations in the test UI only
|
|
10
|
+
// 'off' - skip a11y checks entirely
|
|
11
|
+
test: 'error',
|
|
12
|
+
},
|
|
13
|
+
controls: {
|
|
14
|
+
matchers: {
|
|
15
|
+
color: /(background|color)$/i,
|
|
16
|
+
date: /Date$/i,
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
backgrounds: {
|
|
20
|
+
options: {
|
|
21
|
+
light: { name: 'light', value: '#ffffff' },
|
|
22
|
+
subtle: { name: 'subtle', value: '#f5f5f5' },
|
|
23
|
+
dark: { name: 'dark', value: '#1a1a2e' },
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export default preview;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { defineConfig } from 'vitest/config';
|
|
2
|
+
import { storybookTest } from '@storybook/addon-vitest/vitest-plugin';
|
|
3
|
+
import vue from '@vitejs/plugin-vue';
|
|
4
|
+
import { playwright } from '@vitest/browser-playwright';
|
|
5
|
+
|
|
6
|
+
// Named `vitest.config.ts` (not `vitest.storybook.config.ts`, the name the
|
|
7
|
+
// monorepo's own libs/vue uses) so `@storybook/addon-vitest`'s `test-run`
|
|
8
|
+
// tool finds it directly: its VitestManager walks up from a story's
|
|
9
|
+
// `.storybook` directory looking for the nearest vitest/vite config, and
|
|
10
|
+
// this is the standard filename it looks for first. The monorepo needs a
|
|
11
|
+
// root `vitest.config.mjs` with an explicit `projects: [...]` list because
|
|
12
|
+
// each library's own file has a non-standard name; a single-app scaffold
|
|
13
|
+
// doesn't need that indirection.
|
|
14
|
+
export default defineConfig({
|
|
15
|
+
plugins: [
|
|
16
|
+
vue(),
|
|
17
|
+
storybookTest({
|
|
18
|
+
configDir: new URL('./.storybook', import.meta.url).pathname,
|
|
19
|
+
}),
|
|
20
|
+
],
|
|
21
|
+
test: {
|
|
22
|
+
name: 'storybook:vue',
|
|
23
|
+
globals: true,
|
|
24
|
+
browser: {
|
|
25
|
+
enabled: true,
|
|
26
|
+
headless: true,
|
|
27
|
+
provider: playwright(),
|
|
28
|
+
instances: [{ browser: 'chromium' }],
|
|
29
|
+
},
|
|
30
|
+
setupFiles: ['.storybook/vitest.setup.ts'],
|
|
31
|
+
},
|
|
32
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import '@testing-library/jest-dom/vitest';
|
|
2
|
+
import * as a11yAddonAnnotations from '@storybook/addon-a11y/preview';
|
|
3
|
+
/// <reference types="vitest/globals" />
|
|
4
|
+
import { setProjectAnnotations } from '@storybook/vue3';
|
|
5
|
+
import * as projectAnnotations from './preview';
|
|
6
|
+
|
|
7
|
+
const project = setProjectAnnotations([a11yAddonAnnotations, projectAnnotations]);
|
|
8
|
+
|
|
9
|
+
beforeAll(project.beforeAll);
|