Skip to content

Commit 06dea54

Browse files
authored
Merge branch 'dev' into feedback-widget
2 parents d7ef2e9 + 583174f commit 06dea54

File tree

11 files changed

+7492
-1891
lines changed

11 files changed

+7492
-1891
lines changed

.eslintrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"extends": ["next/core-web-vitals", "prettier"],
2+
"extends": ["next/core-web-vitals", "prettier", "plugin:storybook/recommended"],
33
"env": { "es6": true },
44
"plugins": ["simple-import-sort"],
55
"rules": {

.storybook/i18next.ts

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import i18n, { Resource } from "i18next"
2+
import { initReactI18next } from "react-i18next"
3+
4+
export const baseLocales = {
5+
en: { title: "English", left: "En" },
6+
zh: { title: "中国人", left: "Zh" },
7+
ru: { title: "Русский", left: "Ru" },
8+
uk: { title: "українська", left: "Uk" },
9+
}
10+
11+
// Only i18n files named in this array are being exposed to Storybook. Add filenames as necessary.
12+
const ns = [
13+
"common",
14+
"glossary",
15+
"page-about",
16+
"page-index",
17+
"page-learn",
18+
"page-upgrades",
19+
"page-developers-index",
20+
]
21+
const supportedLngs = Object.keys(baseLocales)
22+
23+
/**
24+
* Taking the ns array and generating those files for each language available.
25+
*/
26+
const resources: Resource = ns.reduce((acc, n) => {
27+
supportedLngs.forEach((lng) => {
28+
if (!acc[lng]) acc[lng] = {}
29+
30+
try {
31+
acc[lng] = {
32+
...acc[lng],
33+
[n]: {
34+
...acc[lng][n],
35+
...require(`../src/intl/${lng}/${n}.json`),
36+
},
37+
}
38+
} catch {
39+
acc[lng] = {
40+
...acc[lng],
41+
[n]: {
42+
...acc[lng][n],
43+
...require(`../src/intl/en/${n}.json`),
44+
},
45+
}
46+
}
47+
})
48+
49+
return acc
50+
}, {})
51+
52+
i18n.use(initReactI18next).init({
53+
debug: true,
54+
fallbackLng: "en",
55+
interpolation: { escapeValue: false },
56+
react: { useSuspense: false },
57+
supportedLngs,
58+
resources,
59+
})
60+
61+
export default i18n

.storybook/main.ts

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
import path from "path"
2+
3+
import type { StorybookConfig } from "@storybook/nextjs"
4+
import { propNames } from "@chakra-ui/react"
5+
6+
/**
7+
* Note regarding package.json settings related to Storybook:
8+
*
9+
* There is a resolutions option set for the package `jackspeak`. This is related to a
10+
* workaround provided to make sure storybook ( as of v7.5.2) works correctly with
11+
* Yarn v1
12+
*
13+
* Reference: https://github.com/storybookjs/storybook/issues/22431#issuecomment-1630086092
14+
*
15+
* The primary recommendation is to upgrade to Yarn 3 if possible
16+
*/
17+
18+
/**
19+
* Temporary list of allowed stories during migration to NextJS
20+
*/
21+
const tempStoryList = ["../src/components/Buttons/**/*.stories.@(ts|tsx)"]
22+
23+
const config: StorybookConfig = {
24+
stories: tempStoryList,
25+
addons: [
26+
"@storybook/addon-links",
27+
"@storybook/addon-essentials",
28+
"@storybook/addon-onboarding",
29+
"@storybook/addon-interactions",
30+
"@chakra-ui/storybook-addon",
31+
"storybook-react-i18next"
32+
],
33+
staticDirs: ["../public"],
34+
framework: {
35+
name: "@storybook/nextjs",
36+
options: {},
37+
},
38+
docs: {
39+
autodocs: "tag",
40+
},
41+
refs: {
42+
"@chakra-ui/react": {
43+
disable: true,
44+
},
45+
},
46+
webpackFinal: async (config: any) => {
47+
// Add path aliases
48+
config.resolve.alias["@"] = path.resolve(__dirname, "../src")
49+
config.resolve.alias["@/public"] = path.resolve(__dirname, "../public")
50+
51+
return config
52+
},
53+
typescript: {
54+
reactDocgenTypescriptOptions: {
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+
}
76+
export default config

.storybook/manager.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { addons } from "@storybook/manager-api"
2+
import theme from "./theme"
3+
// @ts-ignore
4+
import favicon from "../public/favicon.png"
5+
6+
addons.setConfig({
7+
theme,
8+
})
9+
10+
// In order to override the default favicon, and inject a data hash link to the png
11+
const link = document.createElement("link")
12+
link.setAttribute("rel", "shortcut icon")
13+
link.setAttribute("href", favicon)
14+
document.head.appendChild(link)

.storybook/preview-logo.svg

Lines changed: 9 additions & 0 deletions
Loading

.storybook/preview.ts

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import { extendBaseTheme } from "@chakra-ui/react"
2+
import type { Preview } from "@storybook/react"
3+
4+
import theme from "../src/@chakra-ui/theme"
5+
6+
import i18n, { baseLocales } from "./i18next"
7+
8+
const extendedTheme = extendBaseTheme(theme)
9+
10+
const chakraBreakpointArray = Object.entries(extendedTheme.breakpoints)
11+
12+
const preview: Preview = {
13+
globals: {
14+
locale: 'en',
15+
locales: baseLocales,
16+
},
17+
parameters: {
18+
i18n,
19+
actions: { argTypesRegex: "^on[A-Z].*" },
20+
controls: {
21+
matchers: {
22+
color: /(background|color)$/i,
23+
date: /Date$/i,
24+
},
25+
},
26+
backgrounds: {
27+
disable: true,
28+
},
29+
chakra: {
30+
theme: extendedTheme,
31+
},
32+
layout: "centered",
33+
// Modify viewport selection to match Chakra breakpoints (or custom breakpoints)
34+
viewport: {
35+
viewports: chakraBreakpointArray.reduce((prevVal, currVal) => {
36+
const [token, key] = currVal
37+
38+
// Replace base value
39+
if (token === "base")
40+
return {
41+
...prevVal,
42+
base: {
43+
name: "base",
44+
styles: {
45+
width: "375px", // A popular minimum mobile width
46+
height: "600px",
47+
},
48+
},
49+
}
50+
51+
return {
52+
...prevVal,
53+
[token]: {
54+
name: token,
55+
styles: {
56+
width: key,
57+
height: "600px",
58+
},
59+
},
60+
}
61+
}, {}),
62+
},
63+
},
64+
}
65+
66+
export default preview

.storybook/theme.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { create } from "@storybook/theming"
2+
3+
// @ts-ignore
4+
import brandImage from "./preview-logo.svg"
5+
6+
export default create({
7+
base: "dark",
8+
9+
appBg: "#222222",
10+
appBorderColor: "white",
11+
appBorderRadius: 4,
12+
13+
brandTitle: "Ethereum.org",
14+
brandImage,
15+
brandUrl: "https://www.ethereum.org",
16+
17+
barSelectedColor: "#ff7324",
18+
19+
colorSecondary: "#ff7324",
20+
21+
fontBase: "Inter, sans-serif",
22+
23+
textColor: "#f2f2f2",
24+
textMutedColor: "#b2b2b2",
25+
26+
inputBorder: "#F7F7F7",
27+
inputBorderRadius: 4,
28+
})

package.json

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
"lint": "next lint",
1010
"lint:fix": "next lint --fix",
1111
"preversion": "bash ./src/scripts/updatePublishDate.sh",
12-
"crowdin-contributors": "ts-node -O '{ \"module\": \"commonjs\" }' src/scripts/crowdin/getCrowdinContributors.ts"
12+
"crowdin-contributors": "ts-node -O '{ \"module\": \"commonjs\" }' src/scripts/crowdin/getCrowdinContributors.ts",
13+
"storybook": "storybook dev -p 6006",
14+
"build-storybook": "storybook build"
1315
},
1416
"dependencies": {
1517
"@chakra-ui/next-js": "^2.1.5",
@@ -18,7 +20,6 @@
1820
"@docsearch/react": "^3.5.2",
1921
"@emotion/react": "^11.11.1",
2022
"@emotion/styled": "^11.11.0",
21-
"@storybook/react": "^7.3.2",
2223
"clipboard": "^2.0.11",
2324
"framer-motion": "^10.13.0",
2425
"gray-matter": "^4.0.3",
@@ -43,7 +44,15 @@
4344
"yaml-loader": "^0.8.0"
4445
},
4546
"devDependencies": {
47+
"@chakra-ui/storybook-addon": "5.1.0",
4648
"@netlify/plugin-nextjs": "^4.40.2",
49+
"@storybook/addon-essentials": "7.5.3",
50+
"@storybook/addon-interactions": "7.5.3",
51+
"@storybook/addon-links": "7.5.3",
52+
"@storybook/addon-onboarding": "1.0.8",
53+
"@storybook/nextjs": "7.5.3",
54+
"@storybook/react": "7.5.3",
55+
"@storybook/testing-library": "0.2.2",
4756
"@types/hast": "^3.0.0",
4857
"@types/luxon": "^3.3.2",
4958
"@types/node": "^20.4.2",
@@ -53,13 +62,19 @@
5362
"eslint-config-next": "^14.0.0",
5463
"eslint-config-prettier": "^9.0.0",
5564
"eslint-plugin-simple-import-sort": "^10.0.0",
65+
"eslint-plugin-storybook": "^0.6.15",
5666
"image-size": "^1.0.2",
5767
"mdast-util-toc": "^7.0.0",
5868
"minimist": "^1.2.8",
5969
"polished": "^4.2.2",
70+
"storybook": "7.5.3",
71+
"storybook-react-i18next": "^2.0.9",
6072
"ts-node": "^10.9.1",
6173
"typescript": "^5.1.6",
6274
"unified": "^10.0.0",
6375
"unist-util-visit": "^5.0.0"
76+
},
77+
"resolutions": {
78+
"jackspeak": "2.1.1"
6479
}
6580
}

src/components/Buttons/Button.stories.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ const variants: ThemingProps<"Button">["variant"][] = [
4343
export const StyleVariants: Story = {
4444
argTypes: {
4545
size: {
46-
//@ts-expect-error
4746
...getThemingArgTypes(theme, "Button")?.size,
4847
defaultValue: "md",
4948
},
@@ -130,7 +129,7 @@ export const OverrideStyles: Story = {
130129
</Text>
131130
<VStack>
132131
<IconButton aria-label="toggle" icon={<MdNightlight />} px="1.5" />
133-
<ButtonLink to="#" borderRadius="full" px="0" py="0">
132+
<ButtonLink href="#" borderRadius="full" px="0" py="0">
134133
<Translation id="get-involved" />
135134
</ButtonLink>
136135
</VStack>

src/lib/rehype/remarkInferToc.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { BlockContent, DefinitionContent, ListItem } from "mdast"
22
import { toc } from "mdast-util-toc"
3-
import type { Nodes } from "mdast-util-toc/lib"
3+
import type { List, Nodes } from "mdast-util-toc/lib"
44
import type { Plugin } from "unified"
55
import { visit } from "unist-util-visit"
66

@@ -13,7 +13,7 @@ const remarkInferToc: Plugin<[IRemarkTocOptions]> = (options) => {
1313
}
1414

1515
const processToC = (
16-
node: BlockContent | DefinitionContent | ListItem | null,
16+
node: BlockContent | DefinitionContent | ListItem | List | null,
1717
current: TocNodeType
1818
): TocNodeType => {
1919
if (!node) {

0 commit comments

Comments
 (0)