Skip to content

Commit 4a718b5

Browse files
Merge pull request #18 from taigakiyokawa/add_storybook
[feat] Add Storybook
2 parents 386509f + f236dba commit 4a718b5

File tree

9 files changed

+9080
-109
lines changed

9 files changed

+9080
-109
lines changed

.eslintrc.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"extends": ["next/core-web-vitals", "prettier"]
2+
"extends": ["next/core-web-vitals", "prettier", "plugin:storybook/recommended"]
33
}

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,6 @@ next-env.d.ts
4949

5050
# Built Visual Studio Code Extensions
5151
*.vsix
52+
53+
# build-storybook
54+
/storybook-static/

.storybook/main.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
const path = require('path')
2+
3+
module.exports = {
4+
stories: ['../src/**/*.stories.tsx'],
5+
addons: ['@storybook/addon-links', '@storybook/addon-essentials', '@storybook/addon-interactions'],
6+
framework: '@storybook/react',
7+
core: {
8+
builder: '@storybook/builder-webpack5'
9+
},
10+
webpackFinal(config) {
11+
config.resolve.modules = [...(config.resolve.modules || []), path.resolve(__dirname, '..')]
12+
13+
delete config.resolve.alias['emotion-theming']
14+
delete config.resolve.alias['@emotion/styled']
15+
delete config.resolve.alias['@emotion/core']
16+
return config
17+
}
18+
}

.storybook/preview.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export const parameters = {
2+
actions: { argTypesRegex: "^on[A-Z].*" },
3+
controls: {
4+
matchers: {
5+
color: /(background|color)$/i,
6+
date: /Date$/,
7+
},
8+
},
9+
}

package.json

+14-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
"start": "next start",
99
"lint": "next lint",
1010
"format": "prettier --ignore-path .gitignore --write \"**/*.{ts,tsx}\"",
11-
"prepare": "husky install"
11+
"prepare": "husky install",
12+
"storybook": "start-storybook -p 6006",
13+
"build-storybook": "build-storybook"
1214
},
1315
"dependencies": {
1416
"@emotion/react": "11.10.0",
@@ -21,12 +23,23 @@
2123
"react-i18next": "11.18.6"
2224
},
2325
"devDependencies": {
26+
"@babel/core": "^7.19.3",
27+
"@storybook/addon-actions": "^6.5.12",
28+
"@storybook/addon-essentials": "^6.5.12",
29+
"@storybook/addon-interactions": "^6.5.12",
30+
"@storybook/addon-links": "^6.5.12",
31+
"@storybook/builder-webpack5": "^6.5.12",
32+
"@storybook/manager-webpack5": "^6.5.12",
33+
"@storybook/react": "^6.5.12",
34+
"@storybook/testing-library": "^0.0.13",
2435
"@types/node": "18.7.13",
2536
"@types/react": "18.0.17",
2637
"@types/react-dom": "18.0.6",
38+
"babel-loader": "^8.2.5",
2739
"eslint": "8.23.0",
2840
"eslint-config-next": "12.3.1",
2941
"eslint-config-prettier": "8.5.0",
42+
"eslint-plugin-storybook": "^0.6.4",
3043
"husky": "8.0.1",
3144
"lint-staged": "13.0.3",
3245
"prettier": "2.7.1",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import type { ComponentMeta, ComponentStory } from '@storybook/react'
2+
import { Button } from '.'
3+
4+
const meta: ComponentMeta<typeof Button> = {
5+
component: Button
6+
}
7+
export default meta
8+
9+
const Template: ComponentStory<typeof Button> = args => <Button {...args} />
10+
11+
export const Default = Template.bind({})
12+
// TODO: Switch languages by using react-i18next (taigakiyokawa)
13+
Default.args = {
14+
text: 'スピーカーに応募する'
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import type { ComponentMeta, ComponentStory } from '@storybook/react'
2+
import { Footer } from '.'
3+
4+
const meta: ComponentMeta<typeof Footer> = {
5+
component: Footer
6+
}
7+
export default meta
8+
9+
const Template: ComponentStory<typeof Footer> = () => <Footer />
10+
11+
export const Default = Template.bind({})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import type { ComponentMeta, ComponentStory } from '@storybook/react'
2+
import { Header } from '.'
3+
4+
const meta: ComponentMeta<typeof Header> = {
5+
component: Header
6+
}
7+
export default meta
8+
9+
const Template: ComponentStory<typeof Header> = () => <Header />
10+
11+
export const Default = Template.bind({})

0 commit comments

Comments
 (0)