Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(flat-components): remove rollup and add alias #870

Merged
merged 7 commits into from
Aug 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/storybook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
if: steps.yarn-cache.outputs.cache-hit == 'true'

- name: Build Storybook
run: yarn workspace flat-components build-storybook
run: yarn workspace flat-components build

- name: Deploy Storybook
uses: peaceiris/actions-gh-pages@v3
Expand Down
2 changes: 1 addition & 1 deletion README-zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ yarn run start

部分 Flat 组件 UI 可通过 Storybook 快速查看与开发([线上地址][flat-storybook])。

- 项目根执行 `yarn --cwd packages/flat-components storybook` 可在本地运行 Storybook。
- 项目根执行 `yarn run storybook` 可在本地运行 Storybook。

## 环境变量值参考

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ yarn run start

Many Flat components UI can be quickly viewed and developed via Storybook ([Online address][flat-storybook]).

- Run `yarn --cwd packages/flat-components storybook` at project root to run Storybook locally.
- Run `yarn run storybook` at project root to run Storybook locally.

## Environment Variables Reference

Expand Down
2 changes: 2 additions & 0 deletions cspell.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ module.exports = {
"Variatio",
"Clav",
"webfonts",
"browserslist",
"estree",
],
flagWords: ["fuck", "bitch", "asshole", "bullshit", "crap", "suck", "wtf"],
dictionaries: [
Expand Down
4 changes: 4 additions & 0 deletions desktop/renderer-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,11 @@
"lint-staged": "^11.0.0",
"minimist": "^1.2.5",
"prettier": "^2.3.0",
"pretty-bytes": "^5.6.0",
"rc-picker": "^2.5.15",
"react-refresh": "^0.10.0",
"react-resize-detector": "^6.7.5",
"react-transition-group": "^4.4.2",
"style-loader": "^2.0.0",
"terser-webpack-plugin": "^5.1.2",
"thread-loader": "^3.0.4",
Expand Down
6 changes: 3 additions & 3 deletions desktop/renderer-app/src/components/RoomInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@ export interface RoomInfoProps {
}

export class RoomInfo extends React.PureComponent<RoomInfoProps> {
roomStatusLocale = {
public roomStatusLocale = {
[RoomStatus.Idle]: "待开始",
[RoomStatus.Started]: "进行中",
[RoomStatus.Paused]: "已暂停",
[RoomStatus.Stopped]: "已结束",
};

roomInfoLocale = {
public roomInfoLocale = {
[RoomType.BigClass]: "大班课",
[RoomType.SmallClass]: "小班课",
[RoomType.OneToOne]: "一对一",
};

render(): React.ReactNode {
public render(): React.ReactNode {
const { roomStatus, roomType } = this.props;

return (
Expand Down
3 changes: 2 additions & 1 deletion desktop/renderer-app/src/stores/GlobalStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ export class GlobalStore {
for (const key of keys) {
const value = config[key];
if (value !== null && value !== undefined) {
this[key] = value as any;
// @ts-ignore
this[key] = value;
}
}
};
Expand Down
2 changes: 1 addition & 1 deletion desktop/renderer-app/src/tasks/Init-ui.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import "flat-components/build/style.css";
import "flat-components/theme/index.less";
import "../theme.less";

import { ConfigProvider } from "antd";
Expand Down
3 changes: 2 additions & 1 deletion desktop/renderer-app/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
"baseUrl": ".",
"paths": {
"flat-types": ["../../packages/flat-types/src"],
"flat-i18n": ["../../packages/flat-i18n/locales"]
"flat-i18n": ["../../packages/flat-i18n/locales"],
"flat-components": ["../../packages/flat-components/src"]
}
},
"exclude": ["node_modules"],
Expand Down
1 change: 1 addition & 0 deletions desktop/renderer-app/webpack/webpack.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ module.exports = {
alias: {
"flat-types": paths.resolvePath("..", "..", "packages", "flat-types", "src"),
"flat-i18n": paths.resolvePath("..", "..", "packages", "flat-i18n", "locales"),
"flat-components": paths.resolvePath("..", "..", "packages", "flat-components", "src"),
},
},
};
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
"scripts": {
"preinstall": "node ./scripts/preinstall",
"postinstall": "husky install",
"bootstrap": "yarn install --frozen-lockfile && node ./scripts/bootstrap/build-packages.js",
"bootstrap": "yarn install --frozen-lockfile",
"lint": "yarn workspaces run lint",
"check-spelling": "cspell --no-progress \"**/*.{md,ts,tsx,js,css,less,json,yml,yaml,html,sh}\"",
"storybook": "yarn workspace flat-components storybook",
"storybook": "yarn workspace flat-components start",
"start": "node scripts/launch/index.js",
"preship": "rimraf desktop/renderer-app/dist desktop/main-app/dist desktop/main-app/release desktop/main-app/static",
"ship": "yarn workspace renderer-app build && yarn workspace flat ship",
Expand All @@ -20,6 +20,9 @@
"packages/*",
"desktop/*",
"web/*"
],
"nohoist": [
"flat-components/@pmmmwh/react-refresh-webpack-plugin/**"
]
},
"license": "MIT",
Expand Down
3 changes: 2 additions & 1 deletion packages/flat-components/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ module.exports = {
],
plugins: ["jsx-a11y", "react", "@netless", "prettier", "@typescript-eslint"],
parserOptions: {
ecmaVersion: 2018,
project: "tsconfig.json",
tsconfigRootDir: __dirname,
ecmaVersion: 7,
ecmaFeatures: {
jsx: true,
},
Expand Down Expand Up @@ -260,6 +260,7 @@ module.exports = {
"@typescript-eslint/no-misused-promises": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/restrict-plus-operands": "off",
},

overrides: [
Expand Down
2 changes: 1 addition & 1 deletion packages/flat-components/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
storybook-static
/storybook-static
52 changes: 0 additions & 52 deletions packages/flat-components/.storybook/i18n.js

This file was deleted.

30 changes: 30 additions & 0 deletions packages/flat-components/.storybook/i18next.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { initReactI18next } from 'react-i18next';
import i18next from 'i18next';
import LanguageDetector from 'i18next-browser-languagedetector';
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
BlackHole1 marked this conversation as resolved.
Show resolved Hide resolved
.use(LanguageDetector)
.use(initReactI18next)
.init({
resources: messages,
fallbackLng: "en",
interpolation: {
escapeValue: false, // react already safes from xss
},
});

export const i18n = i18next;

export const languages = ["en", "zh-CN"];

export const languagesWithName = [
{ lang: "en", name: "English" },
{ lang: "zh-CN", name: "简体中文" },
];
133 changes: 39 additions & 94 deletions packages/flat-components/.storybook/main.js
Original file line number Diff line number Diff line change
@@ -1,101 +1,46 @@
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.@(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;
"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"],
}
}
},
};

/** 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(
"storybook-react-i18next",
"@storybook/addon-viewport",
],
"webpackFinal": (config) => {
config.module.rules.unshift({
test: /\.less$/,
sideEffects: true,
use: [
{
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: "style-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: "css-loader",
},
);
}
{
loader: "less-loader",
options: {
lessOptions: {
javascriptEnabled: true,
},
},
},
],
});

return config;
}
}
3 changes: 0 additions & 3 deletions packages/flat-components/.storybook/package.json

This file was deleted.

Loading