Skip to content

Commit 5e3bf53

Browse files
authored
Merge pull request #18 from enjoy-hack/feat/storybook
Feat/storybook
2 parents 00fa3c0 + c50a9aa commit 5e3bf53

13 files changed

Lines changed: 3106 additions & 187 deletions

File tree

.github/workflows/chromatic.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# .github/workflows/chromatic.yml
2+
name: 'Chromatic Deployment'
3+
4+
on:
5+
pull_request:
6+
types: [opened, synchronize, reopened]
7+
branches:
8+
- main
9+
10+
jobs:
11+
test:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout repository
15+
uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
19+
- name: Setup Node.js
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: '20'
23+
cache: 'npm'
24+
25+
- name: Install dependencies
26+
run: npm install
27+
28+
- name: Publish to Chromatic
29+
uses: chromaui/action@v1
30+
with:
31+
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
32+
token: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,6 @@ dist-ssr
2222
*.njsproj
2323
*.sln
2424
*.sw?
25+
26+
*storybook.log
27+
storybook-static

.storybook/main.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/** @type { import('@storybook/react-vite').StorybookConfig } */
2+
const config = {
3+
"stories": [
4+
"../src/**/*.mdx",
5+
"../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"
6+
],
7+
"addons": [
8+
"@chromatic-com/storybook",
9+
"@storybook/addon-docs",
10+
"@storybook/addon-onboarding",
11+
"@storybook/addon-a11y",
12+
"@storybook/addon-vitest"
13+
],
14+
"framework": {
15+
"name": "@storybook/react-vite",
16+
"options": {}
17+
}
18+
};
19+
export default config;

.storybook/preview.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/** @type { import('@storybook/react-vite').Preview } */
2+
const preview = {
3+
parameters: {
4+
controls: {
5+
matchers: {
6+
color: /(background|color)$/i,
7+
date: /Date$/i,
8+
},
9+
},
10+
11+
a11y: {
12+
// 'todo' - show a11y violations in the test UI only
13+
// 'error' - fail CI on a11y violations
14+
// 'off' - skip a11y checks entirely
15+
test: 'todo',
16+
},
17+
},
18+
};
19+
20+
export default preview;

.storybook/vitest.setup.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import * as a11yAddonAnnotations from "@storybook/addon-a11y/preview";
2+
import { setProjectAnnotations } from '@storybook/react-vite';
3+
import * as projectAnnotations from './preview';
4+
5+
// This is an important step to apply the right configuration when testing your stories.
6+
// More info at: https://storybook.js.org/docs/api/portable-stories/portable-stories-vitest#setprojectannotations
7+
setProjectAnnotations([a11yAddonAnnotations, projectAnnotations]);

eslint.config.js

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
1+
// For more info, see https://github.com/storybookjs/eslint-plugin-storybook#configuration-flat-config-format
2+
import storybook from "eslint-plugin-storybook";
3+
14
import js from "@eslint/js";
25
import globals from "globals";
36
import reactHooks from "eslint-plugin-react-hooks";
47
import reactRefresh from "eslint-plugin-react-refresh";
58

6-
export default [
7-
{ ignores: ["dist", "build"] },
8-
{
9-
files: ["**/*.{js,jsx}"],
10-
languageOptions: {
11-
ecmaVersion: 2020,
12-
globals: globals.browser,
13-
parserOptions: {
14-
ecmaVersion: "latest",
15-
ecmaFeatures: { jsx: true },
16-
sourceType: "module",
17-
},
18-
},
19-
plugins: {
20-
"react-hooks": reactHooks,
21-
"react-refresh": reactRefresh,
22-
},
23-
rules: {
24-
...js.configs.recommended.rules,
25-
...reactHooks.configs.recommended.rules,
26-
"no-unused-vars": ["error", { varsIgnorePattern: "^[A-Z_]" }],
27-
"react-refresh/only-export-components": [
28-
"warn",
29-
{ allowConstantExport: true },
30-
],
9+
export default [{ ignores: ["dist", "build"] }, {
10+
files: ["**/*.{js,jsx}"],
11+
languageOptions: {
12+
ecmaVersion: 2020,
13+
globals: globals.browser,
14+
parserOptions: {
15+
ecmaVersion: "latest",
16+
ecmaFeatures: { jsx: true },
17+
sourceType: "module",
3118
},
3219
},
33-
];
20+
plugins: {
21+
"react-hooks": reactHooks,
22+
"react-refresh": reactRefresh,
23+
},
24+
rules: {
25+
...js.configs.recommended.rules,
26+
...reactHooks.configs.recommended.rules,
27+
"no-unused-vars": ["error", { varsIgnorePattern: "^[A-Z_]" }],
28+
"react-refresh/only-export-components": [
29+
"warn",
30+
{ allowConstantExport: true },
31+
],
32+
},
33+
}, ...storybook.configs["flat/recommended"]];

0 commit comments

Comments
 (0)