Skip to content

Commit 62d0c0f

Browse files
authored
Merge pull request #9324 from MrJithil/upgrage-storybook-version
Upgrade storybook version to 7.0.0-beta.51
2 parents cd1e432 + 7b49b62 commit 62d0c0f

File tree

10 files changed

+2499
-2345
lines changed

10 files changed

+2499
-2345
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,6 @@ src/gatsby-types.d.ts
8484

8585
# vscode workplace configuration
8686
.vscode
87+
88+
# storybook static files
89+
storybook-static/

.storybook/babel-storybook-config.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
export const babelConfig = {
2+
sourceType: "unambiguous",
3+
presets: [
4+
[
5+
"@babel/preset-env",
6+
{
7+
targets: {
8+
chrome: 100,
9+
},
10+
},
11+
],
12+
"@babel/preset-typescript",
13+
"@babel/preset-react",
14+
],
15+
plugins: [],
16+
}

.storybook/main.js

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
const { propNames } = require("@chakra-ui/react")
22

3+
const { babelConfig } = require("./babel-storybook-config")
4+
35
module.exports = {
46
stories: [
57
{
@@ -16,30 +18,43 @@ module.exports = {
1618
"@storybook/addon-a11y",
1719
"@chakra-ui/storybook-addon",
1820
],
19-
framework: "@storybook/react",
21+
babel: async (options) => ({
22+
...babelConfig,
23+
}),
24+
framework: {
25+
name: "@storybook/react-webpack5",
26+
options: {},
27+
},
2028
refs: {
2129
"@chakra-ui/react": {
2230
disable: true,
2331
},
2432
},
25-
core: {
26-
builder: "webpack5",
27-
},
28-
features: {
29-
storyStoreV7: true,
30-
emotionAlias: false,
31-
},
33+
features: {},
3234
webpackFinal: async (config) => {
33-
// Transpile Gatsby module because Gatsby includes un-transpiled ES6 code.
34-
config.module.rules[0].exclude = [
35-
/node_modules\/(?!(gatsby|gatsby-script)\/)/,
36-
]
37-
// Remove core-js to prevent issues with Storybook
38-
config.module.rules[0].exclude = [/core-js/]
39-
// Use babel-plugin-remove-graphql-queries to remove static queries from components when rendering in storybook
40-
config.module.rules[0].use[0].options.plugins.push(
41-
require.resolve("babel-plugin-remove-graphql-queries")
42-
)
35+
const isRuleExist =
36+
config.module && config.module.rules && config.module.rules.length
37+
if (isRuleExist) {
38+
// Transpile Gatsby module because Gatsby includes un-transpiled ES6 code.
39+
config.module.rules[0].exclude = [
40+
/node_modules\/(?!(gatsby|gatsby-script)\/)/,
41+
]
42+
43+
// Remove core-js to prevent issues with Storybook
44+
config.module.rules[0].exclude = [/core-js/]
45+
}
46+
47+
if (
48+
isRuleExist &&
49+
config.module.rules[0].use &&
50+
config.module.rules[0].use.length
51+
) {
52+
// Use babel-plugin-remove-graphql-queries to remove static queries from components when rendering in storybook
53+
config.module.rules[0].use[0].options.plugins.push(
54+
require.resolve("babel-plugin-remove-graphql-queries")
55+
)
56+
}
57+
4358
config.resolve.mainFields = ["browser", "module", "main"]
4459
return config
4560
},
@@ -72,4 +87,7 @@ module.exports = {
7287
},
7388
},
7489
},
90+
docs: {
91+
autodocs: true,
92+
},
7593
}

.storybook/preview.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { action } from "@storybook/addon-actions"
2+
23
import theme from "../src/@chakra-ui/gatsby-plugin/theme"
3-
import { theme as DefaultChakraTheme } from "@chakra-ui/react"
44

5-
const chakraBreakpointArray = Object.entries(DefaultChakraTheme.breakpoints)
5+
const chakraBreakpointArray = Object.entries(theme.breakpoints)
66

77
// Gatsby's Link overrides:
88
// Gatsby Link calls the `enqueue` & `hovering` methods on the global variable ___loader.

package.json

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -76,17 +76,19 @@
7676
},
7777
"devDependencies": {
7878
"@babel/core": "^7.19.6",
79+
"@babel/preset-env": "^7.20.2",
80+
"@babel/preset-react": "^7.18.6",
81+
"@babel/preset-typescript": "^7.18.6",
7982
"@chakra-ui/storybook-addon": "^4.0.12",
8083
"@netlify/functions": "^1.2.0",
81-
"@storybook/addon-a11y": "^6.5.13",
82-
"@storybook/addon-actions": "^6.5.13",
83-
"@storybook/addon-essentials": "^6.5.13",
84-
"@storybook/addon-interactions": "^6.5.13",
85-
"@storybook/addon-links": "^6.5.13",
86-
"@storybook/builder-webpack5": "^6.5.13",
87-
"@storybook/manager-webpack5": "^6.5.13",
88-
"@storybook/react": "^6.5.13",
89-
"@storybook/testing-library": "^0.0.13",
84+
"@storybook/addon-a11y": "^7.0.0-beta.51",
85+
"@storybook/addon-actions": "^7.0.0-beta.51",
86+
"@storybook/addon-essentials": "^7.0.0-beta.51",
87+
"@storybook/addon-interactions": "^7.0.0-beta.51",
88+
"@storybook/addon-links": "^7.0.0-beta.51",
89+
"@storybook/react": "^7.0.0-beta.51",
90+
"@storybook/react-webpack5": "^7.0.0-beta.51",
91+
"@storybook/testing-library": "^0.0.14-next.1",
9092
"@types/browser-lang": "^0.1.0",
9193
"@types/github-slugger": "^1.3.0",
9294
"@types/luxon": "^2.3.2",
@@ -105,6 +107,7 @@
105107
"minimist": "^1.2.6",
106108
"prettier": "^2.2.1",
107109
"pretty-quick": "^3.1.0",
110+
"storybook": "^7.0.0-beta.51",
108111
"ts-node": "^10.9.1",
109112
"typescript": "^4.6.3"
110113
},
@@ -123,8 +126,8 @@
123126
"start:static": "gatsby build && gatsby serve",
124127
"serve": "gatsby serve",
125128
"type-check": "tsc --noEmit",
126-
"storybook": "start-storybook -p 6006",
127-
"build-storybook": "build-storybook"
129+
"storybook": "storybook dev -p 6006 -c .storybook",
130+
"build-storybook": "storybook build"
128131
},
129132
"husky": {
130133
"hooks": {
Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,35 @@
1-
import { ComponentMeta, ComponentStory } from "@storybook/react"
1+
import { Meta, StoryObj } from "@storybook/react"
22
import React from "react"
33
import BannerNotification from "."
44

55
export default {
66
component: BannerNotification,
7-
} as ComponentMeta<typeof BannerNotification>
7+
} as Meta<typeof BannerNotification>
88

99
/**
1010
* Story taken from PostMergeBanner component
1111
* and content from `../../content/developers/tutorials/hello-world-smart-contract-fullstack/index.md`
1212
*/
13-
export const PostMergeBanner: ComponentStory<typeof BannerNotification> = (
14-
args
15-
) => <BannerNotification {...args} />
16-
17-
PostMergeBanner.args = {
18-
shouldShow: true,
19-
justify: "center",
20-
textAlign: "center",
21-
sx: {
22-
"& p": {
23-
maxWidth: "100ch",
24-
m: 0,
25-
p: 0,
26-
},
27-
"& a": {
28-
textDecor: "underline",
13+
export const PostMergeBanner: StoryObj<typeof BannerNotification> = {
14+
args: {
15+
shouldShow: true,
16+
justify: "center",
17+
textAlign: "center",
18+
sx: {
19+
"& p": {
20+
maxWidth: "100ch",
21+
m: 0,
22+
p: 0,
23+
},
24+
"& a": {
25+
textDecor: "underline",
26+
},
2927
},
28+
children: (
29+
<p>
30+
This tutorial is out of date after the merge and may not work. Please
31+
raise a PR if you would like to contribute.
32+
</p>
33+
),
3034
},
31-
children: (
32-
<p>
33-
This tutorial is out of date after the merge and may not work. Please
34-
raise a PR if you would like to contribute.
35-
</p>
36-
),
3735
}
Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,33 @@
1-
import { ComponentMeta, ComponentStory } from "@storybook/react"
2-
import React from "react"
1+
import { Meta, StoryObj } from "@storybook/react"
32
import Button from "."
43

54
export default {
65
component: Button,
7-
} as ComponentMeta<typeof Button>
6+
} as Meta<typeof Button>
87

9-
const Template: ComponentStory<typeof Button> = (args) => <Button {...args} />
10-
11-
export const Solid = Template.bind({})
12-
Solid.args = {
13-
children: "What is Ethereum?",
8+
export const Solid: StoryObj<typeof Button> = {
9+
args: {
10+
children: "What is Ethereum?",
11+
},
1412
}
1513

16-
export const Outline = Template.bind({})
17-
Outline.args = {
18-
children: "More on digital money",
19-
variant: "outline",
14+
export const Outline: StoryObj<typeof Button> = {
15+
args: {
16+
children: "More on digital money",
17+
variant: "outline",
18+
},
2019
}
2120

22-
export const OutlineColor = Template.bind({})
23-
OutlineColor.args = {
24-
children: "More on digital money",
25-
variant: "outline-color",
21+
export const OutlineColor: StoryObj<typeof Button> = {
22+
args: {
23+
children: "More on digital money",
24+
variant: "outline-color",
25+
},
2626
}
2727

28-
export const Disabled = Template.bind({})
29-
Disabled.args = {
30-
children: "I am disabled",
31-
disabled: true,
28+
export const Disabled: StoryObj<typeof Button> = {
29+
args: {
30+
children: "I am disabled",
31+
disabled: true,
32+
},
3233
}

src/components/Card/Card.stories.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Box } from "@chakra-ui/react"
2-
import { ComponentMeta, ComponentStory } from "@storybook/react"
2+
import { Meta, StoryFn } from "@storybook/react"
33
import React from "react"
44
import Card, { IProps } from "."
55
import Button from "../Button"
@@ -15,15 +15,15 @@ export default {
1515
</Box>
1616
),
1717
],
18-
} as ComponentMeta<typeof Component>
18+
} as Meta<typeof Component>
1919

2020
const defaultProps: IProps = {
2121
emoji: ":woman_student:",
2222
title: "Learn Ethereum development",
2323
description: "Read up on core concepts and the Ethereum stack with our docs",
2424
}
2525

26-
export const Default: ComponentStory<typeof Component> = (args) => (
26+
export const Default: StoryFn<typeof Component> = (args) => (
2727
<Component {...defaultProps} {...args}>
2828
<Button>Read the docs</Button>
2929
</Component>

src/components/Slider/Slider.stories.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ComponentMeta, ComponentStory } from "@storybook/react"
1+
import { Meta, StoryFn } from "@storybook/react"
22
import React from "react"
33
import Slider, { EmblaSlide } from "."
44

@@ -13,7 +13,7 @@ export default {
1313
handles: ["click"],
1414
},
1515
},
16-
} as ComponentMeta<typeof Component>
16+
} as Meta<typeof Component>
1717

1818
const ComponentSlides = () => (
1919
<>
@@ -85,7 +85,7 @@ const ComponentSlides = () => (
8585
</>
8686
)
8787

88-
export const Basic: ComponentStory<typeof Component> = (args) => (
88+
export const Basic: StoryFn<typeof Component> = (args) => (
8989
<Component {...args}>
9090
<ComponentSlides />
9191
</Component>

0 commit comments

Comments
 (0)