Skip to content

Commit 5f8b4d4

Browse files
chore: Migrate Stroybook to v7 (#214)
1 parent 02cdbd6 commit 5f8b4d4

File tree

23 files changed

+2226
-5465
lines changed

23 files changed

+2226
-5465
lines changed

.storybook/main.js

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

.storybook/main.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { StorybookConfig } from '@storybook/nextjs'
2+
const path = require('path')
3+
4+
const config: StorybookConfig = {
5+
stories: ['../src/**/*.stories.tsx'],
6+
framework: { name: '@storybook/nextjs', options: {} },
7+
addons: ['@storybook/addon-links', '@storybook/addon-essentials', '@storybook/addon-interactions'],
8+
staticDirs: ['../public'],
9+
webpackFinal(config) {
10+
if (config.resolve && config.resolve.alias) {
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+
}
17+
return config
18+
}
19+
}
20+
21+
export default config

.storybook/preview.js

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

.storybook/preview.tsx

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import React from 'react'
2+
import { Preview } from '@storybook/react'
3+
import { theme } from '../src/styles/theme'
4+
import { ThemeProvider } from '@mui/material/styles'
5+
import '../src/styles/globals.css'
6+
import { Colors } from '../src/styles/color'
7+
8+
const preview: Preview = {
9+
parameters: {
10+
actions: { argTypesRegex: '^on[A-Z].*' },
11+
controls: {
12+
matchers: {
13+
color: /(background|color)$/i,
14+
date: /Date$/
15+
}
16+
},
17+
backgrounds: {
18+
default: 'primary',
19+
values: [
20+
{ name: 'primary', value: Colors.background.primary },
21+
{ name: 'secondary', value: Colors.background.secondary },
22+
{ name: 'brand color', value: Colors.background.brand_color }
23+
]
24+
}
25+
},
26+
decorators: [
27+
Story => {
28+
return (
29+
<ThemeProvider theme={theme}>
30+
<Story />
31+
</ThemeProvider>
32+
)
33+
}
34+
]
35+
}
36+
37+
export default preview

package.json

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
"lint": "next lint",
1010
"format": "prettier --ignore-path .gitignore --write \"**/*.{ts,tsx}\"",
1111
"prepare": "husky install",
12-
"storybook": "start-storybook -p 6006",
13-
"build-storybook": "build-storybook"
12+
"storybook": "storybook dev -p 6006",
13+
"build-storybook": "storybook build"
1414
},
1515
"dependencies": {
1616
"@emotion/react": "11.10.0",
@@ -30,27 +30,23 @@
3030
"devDependencies": {
3131
"@babel/core": "7.19.3",
3232
"@faker-js/faker": "7.6.0",
33-
"@storybook/addon-actions": "6.5.12",
34-
"@storybook/addon-essentials": "6.5.12",
35-
"@storybook/addon-interactions": "6.5.12",
36-
"@storybook/addon-links": "6.5.12",
37-
"@storybook/builder-webpack5": "6.5.12",
38-
"@storybook/manager-webpack5": "6.5.12",
39-
"@storybook/react": "6.5.12",
40-
"@storybook/testing-library": "0.0.13",
33+
"@storybook/addon-essentials": "7.0.12",
34+
"@storybook/addon-interactions": "7.0.12",
35+
"@storybook/addon-links": "7.0.12",
36+
"@storybook/nextjs": "7.0.12",
37+
"@storybook/react": "7.0.12",
4138
"@types/node": "18.7.13",
4239
"@types/react": "18.0.21",
4340
"@types/react-dom": "18.0.6",
4441
"babel-loader": "8.2.5",
4542
"eslint": "8.28.0",
4643
"eslint-config-next": "13.4.1",
4744
"eslint-config-prettier": "8.5.0",
48-
"eslint-plugin-storybook": "0.6.7",
45+
"eslint-plugin-storybook": "0.6.12",
4946
"husky": "8.0.1",
5047
"lint-staged": "13.0.3",
5148
"prettier": "2.7.1",
52-
"storybook-addon-material-ui5": "1.0.0",
53-
"storybook-addon-next": "1.6.9",
49+
"storybook": "7.0.12",
5450
"typescript": "4.8.2"
5551
},
5652
"lint-staged": {
Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
1-
import type { ComponentMeta, ComponentStory } from '@storybook/react'
1+
import type { Meta, StoryObj } from '@storybook/react'
22
import { Button } from '.'
33

4-
const meta: ComponentMeta<typeof Button> = {
4+
const meta: Meta<typeof Button> = {
55
component: Button
66
}
77
export default meta
88

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: 'スピーカーに応募する'
9+
export const Default: StoryObj<typeof Button> = {
10+
args: {
11+
text: 'スピーカーに応募する'
12+
}
1513
}
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
import type { ComponentMeta, ComponentStory } from '@storybook/react'
1+
import type { Meta, StoryObj } from '@storybook/react'
22
import { IconTwitter } from '.'
33

4-
const meta: ComponentMeta<typeof IconTwitter> = {
4+
const meta: Meta<typeof IconTwitter> = {
55
component: IconTwitter
66
}
77
export default meta
88

9-
const Template: ComponentStory<typeof IconTwitter> = () => <IconTwitter />
10-
11-
export const Default = Template.bind({})
9+
export const Default: StoryObj<typeof IconTwitter> = {}

src/components/atoms/SessionLabel/SessionLabel.stories.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
import { ComponentMeta, ComponentStoryObj } from '@storybook/react'
1+
import { Meta, StoryObj } from '@storybook/react'
22
import { SessionLabel } from '.'
33

4-
const meta: ComponentMeta<typeof SessionLabel> = {
4+
const meta: Meta<typeof SessionLabel> = {
55
component: SessionLabel
66
}
77
export default meta
88

9-
export const RoomA: ComponentStoryObj<typeof SessionLabel> = {
9+
export const RoomA: StoryObj<typeof SessionLabel> = {
1010
args: {
1111
roomName: 'Room A',
1212
sessionId: 'A1-1',
1313
isRoomNameDisplayed: true
1414
}
1515
}
1616

17-
export const RoomB: ComponentStoryObj<typeof SessionLabel> = {
17+
export const RoomB: StoryObj<typeof SessionLabel> = {
1818
args: {
1919
roomName: 'Room B',
2020
sessionId: 'B1-1',

src/components/atoms/SpeakerIcon/SpeakerIcon.stories.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import type { ComponentMeta, ComponentStoryObj } from '@storybook/react'
1+
import type { Meta, StoryObj } from '@storybook/react'
22
import { SpeakerIcon } from '.'
33
import { faker } from '@faker-js/faker'
44

5-
const meta: ComponentMeta<typeof SpeakerIcon> = {
5+
const meta: Meta<typeof SpeakerIcon> = {
66
component: SpeakerIcon
77
}
88
export default meta
99

10-
export const Default: ComponentStoryObj<typeof SpeakerIcon> = {
10+
export const Default: StoryObj<typeof SpeakerIcon> = {
1111
args: {
1212
iconUrl: faker.image.avatar(),
1313
name: 'sample',
Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
1-
import type { ComponentMeta, ComponentStory } from '@storybook/react'
1+
import type { Meta, StoryObj } from '@storybook/react'
22
import { PlenumCard } from '.'
3-
import { Box } from '@mui/material'
43

5-
const meta: ComponentMeta<typeof PlenumCard> = {
4+
const meta: Meta<typeof PlenumCard> = {
65
component: PlenumCard
76
}
87
export default meta
98

10-
const Template: ComponentStory<typeof PlenumCard> = args => (
11-
<Box width="300px">
12-
<PlenumCard {...args} />
13-
</Box>
14-
)
15-
16-
export const Default = Template.bind({})
17-
Default.args = {
18-
title: 'Break'
9+
export const Default: StoryObj<typeof PlenumCard> = {
10+
args: {
11+
title: 'Break'
12+
}
1913
}

0 commit comments

Comments
 (0)