-
Notifications
You must be signed in to change notification settings - Fork 811
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
b91a9b2
commit 8fc00d8
Showing
50 changed files
with
1,949 additions
and
5,748 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
/storybook-static | ||
storybook-static |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import i18next from "i18next"; | ||
import I18nextBrowserLanguageDetector from "i18next-browser-languagedetector"; | ||
import { initReactI18next } from "react-i18next"; | ||
import en from "flat-i18n/locales/en.json"; | ||
import zhCN from "flat-i18n/locales/zh-CN.json"; | ||
|
||
const messages = { | ||
en: { translation: en }, | ||
"zh-CN": { translation: zhCN }, | ||
}; | ||
|
||
i18next | ||
.use(I18nextBrowserLanguageDetector) | ||
.use(initReactI18next) | ||
.init({ | ||
resources: messages, | ||
fallbackLng: "en", | ||
interpolation: { | ||
escapeValue: false, // react already safes from xss | ||
}, | ||
}); | ||
|
||
/** | ||
* i18next 实例 | ||
* ```tsx | ||
* // class component | ||
* import { withTranslation, WithTranslation } from 'react-i18next'; | ||
* class App extends React.Component<WithTranslation> { | ||
* render() { return <div>{this.props.t('hello')}</div> } | ||
* } | ||
* export default withTranslation()(App); | ||
* // function component | ||
* import { useTranslation } from "react-i18next"; | ||
* function App() { | ||
* const { t, i18n } = useTranslation(); | ||
* return <div>{t('hello')}</div> | ||
* } | ||
* ``` | ||
*/ | ||
export const i18n = i18next; | ||
|
||
export const languages = ["en", "zh-CN"]; | ||
|
||
export const languagesWithName = [ | ||
{ lang: "en", name: "English" }, | ||
{ lang: "zh-CN", name: "简体中文" }, | ||
]; | ||
|
||
/** | ||
* NOTE: to use this library, also install https://github.com/antfu/i18n-ally | ||
* to edit translations. open a new vscode window at <path to renderer-app>. | ||
*/ |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,101 @@ | ||
const fs = require("fs"); | ||
const path = require("path"); | ||
const ForkTsCheckerWebpackPlugin = require("fork-ts-checker-webpack-plugin"); | ||
const ESLintPlugin = require("eslint-webpack-plugin"); | ||
|
||
module.exports = { | ||
"stories": [ | ||
"../src/**/*.stories.mdx", | ||
"../src/**/*.stories.@(js|jsx|ts|tsx)" | ||
], | ||
"addons": [ | ||
"@storybook/addon-links", | ||
"@storybook/addon-essentials", | ||
{ | ||
name: "@storybook/preset-create-react-app", | ||
options: { | ||
craOverrides: { | ||
fileLoaderExcludes: ["less"], | ||
} | ||
} | ||
stories: [ | ||
"../src/**/*.stories.mdx", | ||
"../src/**/*.stories.@(ts|tsx)", | ||
"../theme/**/*.stories.@(ts|tsx)", | ||
], | ||
addons: ["@storybook/addon-links", "@storybook/addon-essentials"], | ||
babel: async options => { | ||
return { | ||
...options, | ||
plugins: [ | ||
[require.resolve("@babel/plugin-proposal-class-properties"), { loose: true }], | ||
...(options.plugins || []), | ||
], | ||
}; | ||
}, | ||
webpackFinal: async config => { | ||
setupUrlLoader(config); | ||
|
||
config.plugins.push( | ||
new ESLintPlugin({ | ||
fix: true, | ||
extensions: ["ts", "tsx"], | ||
}), | ||
new ForkTsCheckerWebpackPlugin({ | ||
typescript: { | ||
configFile: path.resolve(__dirname, "..", "tsconfig.json"), | ||
diagnosticOptions: { | ||
semantic: true, | ||
syntactic: true, | ||
declaration: true, | ||
}, | ||
}, | ||
}), | ||
); | ||
|
||
config.module.rules.unshift({ | ||
test: /\.(sass|scss)(\?.*)?$/i, | ||
sideEffects: true, | ||
use: [ | ||
{ loader: require.resolve("style-loader") }, | ||
{ loader: require.resolve("css-loader") }, | ||
{ loader: require.resolve("sass-loader") }, | ||
], | ||
}); | ||
|
||
config.module.rules.unshift({ | ||
test: /\.(less)(\?.*)?$/i, | ||
sideEffects: true, | ||
use: [ | ||
{ loader: require.resolve("style-loader") }, | ||
{ loader: require.resolve("css-loader") }, | ||
{ | ||
loader: require.resolve("less-loader"), | ||
options: { | ||
lessOptions: { | ||
javascriptEnabled: true, | ||
}, | ||
}, | ||
}, | ||
], | ||
}); | ||
|
||
return config; | ||
}, | ||
"storybook-react-i18next", | ||
"@storybook/addon-viewport", | ||
], | ||
"webpackFinal": (config) => { | ||
config.module.rules.unshift({ | ||
test: /\.less$/, | ||
sideEffects: true, | ||
use: [ | ||
}; | ||
|
||
/** Inline image src */ | ||
function setupUrlLoader(config) { | ||
config.module.rules = config.module.rules.filter(rule => { | ||
return !(rule.loader && rule.loader.includes("file-loader")); | ||
}); | ||
|
||
config.module.rules.unshift( | ||
{ | ||
loader: "style-loader", | ||
test: /\.(png|jpg|jpeg|gif|svg|ico|apng)(\?.*)?$/i, | ||
use: [ | ||
{ | ||
loader: require.resolve("url-loader"), | ||
options: { | ||
limit: 14336, | ||
name: "static/media/[name].[hash:8].[ext]", | ||
esModule: false, | ||
}, | ||
}, | ||
], | ||
}, | ||
{ | ||
loader: "css-loader", | ||
test: /\.(eot|otf|webp|ttf|woff|woff2|cur|ani|pdf)(\?.*)?$/i, | ||
loader: require.resolve("file-loader"), | ||
options: { | ||
name: "static/media/[name].[hash:8].[ext]", | ||
esModule: false, | ||
}, | ||
}, | ||
{ | ||
loader: "less-loader", | ||
options: { | ||
lessOptions: { | ||
javascriptEnabled: true, | ||
}, | ||
}, | ||
}, | ||
], | ||
}); | ||
|
||
return config; | ||
} | ||
} | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"type": "commonjs" | ||
} |
Oops, something went wrong.