Skip to content

Commit 87cc258

Browse files
authored
fix: update storybook defaults and TypeScript config (#9)
- Add @storybook/addon-docs with autodocs support - Use expanded framework config format in .storybook/main.js - Add skipLibCheck to tsconfig (fixes @types/mdx JSX errors from addon-docs) - Convert stories to TypeScript with proper Meta/StoryObj types - Add tags: ['autodocs'] to story meta for auto-generated docs
1 parent 28d6a68 commit 87cc258

File tree

6 files changed

+171
-32
lines changed

6 files changed

+171
-32
lines changed

.storybook/main.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
export default {
2-
stories: ['../stories/**/*.stories.@(js|jsx|ts|tsx|mdx)'],
3-
addons: [],
4-
framework: '@storybook/web-components-vite',
2+
stories: ['../stories/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
3+
addons: ['@storybook/addon-docs'],
4+
framework: {
5+
name: '@storybook/web-components-vite',
6+
options: {},
7+
},
8+
docs: {
9+
autodocs: 'tag',
10+
},
511
};

package-lock.json

Lines changed: 121 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
"@open-wc/testing": "^4.0.0",
7171
"@semantic-release/changelog": "^6.0.0",
7272
"@semantic-release/git": "^10.0.0",
73+
"@storybook/addon-docs": "^10.0.0",
7374
"@storybook/web-components-vite": "^10.0.0",
7475
"@types/mocha": "^10.0.6",
7576
"@types/node": "^24.0.0",

stories/component.stories.js

Lines changed: 0 additions & 25 deletions
This file was deleted.

stories/component.stories.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { html } from '@pionjs/pion';
2+
import type { Meta, StoryObj } from '@storybook/web-components';
3+
import '../src/component';
4+
5+
interface StoryArgs {
6+
greeting: string;
7+
}
8+
9+
const meta: Meta<StoryArgs> = {
10+
title: 'CosmozComponent',
11+
component: 'cosmoz-component',
12+
tags: ['autodocs'],
13+
argTypes: {
14+
greeting: { control: 'text', description: 'Greeting text' },
15+
},
16+
args: {
17+
greeting: 'Hello',
18+
},
19+
};
20+
21+
export default meta;
22+
23+
type Story = StoryObj<StoryArgs>;
24+
25+
export const Default: Story = {
26+
render: (args) =>
27+
html`<cosmoz-component
28+
greeting=${args.greeting}
29+
></cosmoz-component>`,
30+
};
31+
32+
export const CustomGreeting: Story = {
33+
args: { greeting: 'Hi there' },
34+
};
35+
36+
export const NoGreeting: Story = {
37+
args: { greeting: '' },
38+
};

tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"strict": true,
88
"target": "esnext",
99
"allowJs": true,
10-
"baseUrl": "."
10+
"baseUrl": ".",
11+
"skipLibCheck": true
1112
},
1213
"exclude": ["node_modules", "dist", "coverage", "storybook-static", "stories"]
1314
}

0 commit comments

Comments
 (0)