Skip to content

Commit bdd9acf

Browse files
authored
Merge branch 'dev' into energy_consumption_june_2023
2 parents ac4f4ad + 6c6d80c commit bdd9acf

File tree

2,404 files changed

+253807
-56965
lines changed

Some content is hidden

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

2,404 files changed

+253807
-56965
lines changed

.all-contributorsrc

Lines changed: 441 additions & 2 deletions
Large diffs are not rendered by default.
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Update Crowdin Contributors
2+
3+
on:
4+
schedule:
5+
- cron: "0 0 * * SUN" # Runs every Sunday at midnight
6+
workflow_dispatch:
7+
8+
jobs:
9+
create_pr:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Check out code
13+
uses: actions/checkout@v3
14+
15+
- name: Set up Node.js
16+
uses: actions/setup-node@v3
17+
with:
18+
node-version: 18
19+
20+
- name: Install dependencies
21+
run: yarn install
22+
23+
- name: Install ts-node
24+
run: yarn global add ts-node
25+
26+
- name: Set up git
27+
run: |
28+
git config --global user.email "actions@github.com"
29+
git config --global user.name "GitHub Action"
30+
31+
- name: Generate timestamp and readable date
32+
id: date
33+
run: |
34+
echo "TIMESTAMP=$(date +'%Y%m%d%H%M%S')" >> $GITHUB_ENV
35+
echo "READABLE_DATE=$(date +'%B %-d')" >> $GITHUB_ENV
36+
37+
- name: Fetch latest dev and create new branch
38+
run: |
39+
git fetch origin dev
40+
git checkout -b "automated-update-${{ env.TIMESTAMP }}" origin/dev
41+
42+
- name: Run script
43+
run: npx ts-node -O '{"module":"commonjs"}' ./src/scripts/crowdin/getCrowdinContributors.ts
44+
env:
45+
CROWDIN_API_KEY: ${{ secrets.CROWDIN_API_KEY }}
46+
47+
- name: Commit and push
48+
run: |
49+
git add -A
50+
git commit -m "Update Crowdin contributors"
51+
git push origin "automated-update-${{ env.TIMESTAMP }}"
52+
53+
- name: Create PR body
54+
run: |
55+
echo "This PR was automatically created to update Crowdin contributors." > pr_body.txt
56+
echo "This workflows runs every Sunday at 00:00 (UTC)." >> pr_body.txt
57+
echo "" >> pr_body.txt
58+
echo "Thank you to everyone contributing to translate ethereum.org ❤️" >> pr_body.txt
59+
60+
- name: Create Pull Request
61+
run: |
62+
gh auth login --with-token <<< ${{ secrets.GITHUB_TOKEN }}
63+
gh pr create --base dev --head "automated-update-${{ env.TIMESTAMP }}" --title "Update translation contributors from Crowdin - ${{ env.READABLE_DATE }}" --body-file pr_body.txt

.storybook/babel-storybook-config.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
export const babelConfig = {
1+
import { TransformOptions } from "@babel/core"
2+
3+
export const babelConfig: TransformOptions = {
24
sourceType: "unambiguous",
35
presets: [
46
[

.storybook/i18next.ts

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

.storybook/main.js renamed to .storybook/main.ts

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
const { propNames } = require("@chakra-ui/react")
1+
import { StorybookConfig } from "@storybook/react-webpack5"
2+
import { propNames } from "@chakra-ui/react"
3+
import { babelConfig } from "./babel-storybook-config"
24

3-
const { babelConfig } = require("./babel-storybook-config")
4-
5-
module.exports = {
5+
const config: StorybookConfig = {
66
stories: ["../src/components/**/*.stories.tsx"],
77
addons: [
88
"@storybook/addon-links",
@@ -11,9 +11,10 @@ module.exports = {
1111
// https://storybook.js.org/addons/@storybook/addon-a11y/
1212
"@storybook/addon-a11y",
1313
"@chakra-ui/storybook-addon",
14+
"storybook-react-i18next",
1415
],
1516
staticDirs: ["../static"],
16-
babel: async (options) => ({
17+
babel: async () => ({
1718
...babelConfig,
1819
}),
1920
framework: {
@@ -27,30 +28,30 @@ module.exports = {
2728
},
2829
features: {},
2930
webpackFinal: async (config) => {
30-
const isRuleExist =
31-
config.module && config.module.rules && config.module.rules.length
32-
if (isRuleExist) {
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-
38-
// Remove core-js to prevent issues with Storybook
39-
config.module.rules[0].exclude = [/core-js/]
40-
}
41-
4231
if (
43-
isRuleExist &&
44-
config.module.rules[0].use &&
45-
config.module.rules[0].use.length
32+
config.module != undefined &&
33+
config.module.rules != undefined &&
34+
config.module.rules[0] !== "..."
4635
) {
47-
// Use babel-plugin-remove-graphql-queries to remove static queries from components when rendering in storybook
48-
config.module.rules[0].use[0].options.plugins.push(
49-
require.resolve("babel-plugin-remove-graphql-queries")
50-
)
36+
config.module.rules[0].exclude = [/node_modules\/(?!(gatsby)\/)/]
37+
config.module.rules[0].use = [
38+
{
39+
loader: require.resolve("babel-loader"),
40+
options: {
41+
presets: [
42+
// use @babel/preset-react for JSX and env (instead of staged presets)
43+
require.resolve("@babel/preset-react"),
44+
require.resolve("@babel/preset-env"),
45+
],
46+
plugins: [
47+
// use babel-plugin-remove-graphql-queries to remove static queries from components when rendering in storybook
48+
require.resolve("babel-plugin-remove-graphql-queries"),
49+
],
50+
},
51+
},
52+
]
5153
}
5254

53-
config.resolve.mainFields = ["browser", "module", "main"]
5455
return config
5556
},
5657
typescript: {
@@ -83,3 +84,5 @@ module.exports = {
8384
},
8485
},
8586
}
87+
88+
export default config
Lines changed: 41 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
import { Preview } from "@storybook/react"
12
import { action } from "@storybook/addon-actions"
23

4+
import i18n, { baseLocales } from "./i18next"
35
import theme from "../src/@chakra-ui/gatsby-plugin/theme"
4-
56
import "../static/fonts/inter-font-face.css"
6-
import "../static/fonts/ibm-plex-font-face.css"
77

88
const chakraBreakpointArray = Object.entries(theme.breakpoints)
99

@@ -26,39 +26,48 @@ window.___navigate = (pathname) => {
2626
action("NavigateTo:")(pathname)
2727
}
2828

29-
export const parameters = {
30-
actions: { argTypesRegex: "^on[A-Z].*" },
31-
controls: {
32-
matchers: {
33-
color: /(background|color)$/i,
34-
date: /Date$/,
35-
},
36-
},
37-
backgrounds: {
38-
disable: true,
29+
const preview: Preview = {
30+
globals: {
31+
locale: "en",
32+
locales: baseLocales,
3933
},
40-
chakra: {
41-
theme,
42-
},
43-
layout: "centered",
44-
// Modify viewport selection to match Chakra breakpoints (or custom breakpoints)
45-
viewport: {
46-
viewports: chakraBreakpointArray.reduce((prevVal, currVal) => {
47-
const [token, key] = currVal
34+
parameters: {
35+
i18n,
36+
actions: { argTypesRegex: "^on[A-Z].*" },
37+
controls: {
38+
matchers: {
39+
color: /(background|color)$/i,
40+
date: /Date$/,
41+
},
42+
},
43+
backgrounds: {
44+
disable: true,
45+
},
46+
chakra: {
47+
theme,
48+
},
49+
layout: "centered",
50+
// Modify viewport selection to match Chakra breakpoints (or custom breakpoints)
51+
viewport: {
52+
viewports: chakraBreakpointArray.reduce((prevVal, currVal) => {
53+
const [token, key] = currVal
4854

49-
// Unnecessary breakpoint
50-
if (token === "base") return { ...prevVal }
55+
// Unnecessary breakpoint
56+
if (token === "base") return { ...prevVal }
5157

52-
return {
53-
...prevVal,
54-
[token]: {
55-
name: token,
56-
styles: {
57-
width: key,
58-
height: "600px",
58+
return {
59+
...prevVal,
60+
[token]: {
61+
name: token,
62+
styles: {
63+
width: key,
64+
height: "600px",
65+
},
5966
},
60-
},
61-
}
62-
}, {}),
67+
}
68+
}, {}),
69+
},
6370
},
6471
}
72+
73+
export default preview

0 commit comments

Comments
 (0)