Skip to content

Commit babb4cf

Browse files
committed
Merge branch 'dev' into gatsby-v5
2 parents d8619b6 + 3939455 commit babb4cf

File tree

217 files changed

+11928
-5145
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

217 files changed

+11928
-5145
lines changed

.all-contributorsrc

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9828,6 +9828,33 @@
98289828
"contributions": [
98299829
"content"
98309830
]
9831+
},
9832+
{
9833+
"login": "danceratopz",
9834+
"name": "Dan",
9835+
"avatar_url": "https://avatars.githubusercontent.com/u/91727015?v=4",
9836+
"profile": "https://github.com/danceratopz",
9837+
"contributions": [
9838+
"content"
9839+
]
9840+
},
9841+
{
9842+
"login": "Dev-Liz",
9843+
"name": "Elizabeth Bassey",
9844+
"avatar_url": "https://avatars.githubusercontent.com/u/40176275?v=4",
9845+
"profile": "https://dribbble.com/Liz-B",
9846+
"contributions": [
9847+
"content"
9848+
]
9849+
},
9850+
{
9851+
"login": "mihaic01",
9852+
"name": "mihaic01",
9853+
"avatar_url": "https://avatars.githubusercontent.com/u/108999659?v=4",
9854+
"profile": "https://github.com/mihaic01",
9855+
"contributions": [
9856+
"content"
9857+
]
98319858
}
98329859
],
98339860
"contributorsPerLine": 7,

.storybook/main.js

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
const { propNames } = require("@chakra-ui/react")
2+
3+
module.exports = {
4+
stories: [
5+
{
6+
directory: "../src/components",
7+
titlePrefix: "Components",
8+
files: "**/*.stories.tsx",
9+
},
10+
],
11+
addons: [
12+
"@storybook/addon-links",
13+
"@storybook/addon-essentials",
14+
"@storybook/addon-interactions",
15+
// https://storybook.js.org/addons/@storybook/addon-a11y/
16+
"@storybook/addon-a11y",
17+
"@chakra-ui/storybook-addon",
18+
],
19+
framework: "@storybook/react",
20+
refs: {
21+
"@chakra-ui/react": {
22+
disable: true,
23+
},
24+
},
25+
core: {
26+
builder: "webpack5",
27+
},
28+
features: {
29+
storyStoreV7: true,
30+
emotionAlias: false,
31+
},
32+
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+
)
43+
config.resolve.mainFields = ["browser", "module", "main"]
44+
return config
45+
},
46+
typescript: {
47+
check: false,
48+
checkOptions: {},
49+
reactDocgen: "react-docgen-typescript",
50+
reactDocgenTypescriptOptions: {
51+
compilerOptions: {
52+
allowSyntheticDefaultImports: false,
53+
esModuleInterop: false,
54+
},
55+
shouldExtractLiteralValuesFromEnum: true,
56+
/**
57+
* For handling bloated controls table of Chakra Props
58+
*
59+
* https://github.com/chakra-ui/chakra-ui/issues/2009#issuecomment-852793946
60+
*/
61+
propFilter: (prop) => {
62+
const excludedPropNames = propNames.concat([
63+
"as",
64+
"apply",
65+
"sx",
66+
"__css",
67+
])
68+
const isStyledSystemProp = excludedPropNames.includes(prop.name)
69+
const isHTMLElementProp =
70+
prop.parent?.fileName.includes("node_modules") ?? false
71+
return !(isStyledSystemProp || isHTMLElementProp)
72+
},
73+
},
74+
},
75+
}

.storybook/preview.js

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import { action } from "@storybook/addon-actions"
2+
import theme from "../src/@chakra-ui/gatsby-plugin/theme"
3+
import { theme as DefaultChakraTheme } from "@chakra-ui/react"
4+
5+
const chakraBreakpointArray = Object.entries(DefaultChakraTheme.breakpoints)
6+
7+
// Gatsby's Link overrides:
8+
// Gatsby Link calls the `enqueue` & `hovering` methods on the global variable ___loader.
9+
// This global object isn't set in storybook context, requiring you to override it to empty functions (no-op),
10+
// so Gatsby Link doesn't throw errors.
11+
global.___loader = {
12+
enqueue: () => {},
13+
hovering: () => {},
14+
}
15+
// This global variable prevents the "__BASE_PATH__ is not defined" error inside Storybook.
16+
global.__BASE_PATH__ = "/"
17+
18+
// Navigating through a gatsby app using gatsby-link or any other gatsby component will use the `___navigate` method.
19+
// In Storybook, it makes more sense to log an action than doing an actual navigate. Check out the actions addon docs for more info: https://storybook.js.org/docs/react/essentials/actions
20+
21+
// @ts-ignore
22+
window.___navigate = (pathname) => {
23+
action("NavigateTo:")(pathname)
24+
}
25+
26+
export const parameters = {
27+
actions: { argTypesRegex: "^on[A-Z].*" },
28+
controls: {
29+
matchers: {
30+
color: /(background|color)$/i,
31+
date: /Date$/,
32+
},
33+
},
34+
chakra: {
35+
theme,
36+
},
37+
// Modify viewport selection to match Chakra breakpoints (or custom breakpoints)
38+
viewport: {
39+
viewports: chakraBreakpointArray.reduce((prevVal, currVal) => {
40+
const [token, key] = currVal
41+
42+
// Unnecessary breakpoint
43+
if (token === "base") return { ...prevVal }
44+
45+
return {
46+
...prevVal,
47+
[token]: {
48+
name: token,
49+
styles: {
50+
width: key,
51+
height: "600px",
52+
},
53+
},
54+
}
55+
}, {}),
56+
},
57+
}

0 commit comments

Comments
 (0)