@arcblock/ux 2.1.70 → 2.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,155 +3,30 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.create = void 0;
7
-
8
- var _styles = require("@mui/material/styles");
9
-
10
- require("@fontsource/lato/400.css");
11
-
12
- require("@fontsource/lato/700.css");
13
-
14
- var _Colors = _interopRequireDefault(require("../Colors"));
15
-
16
- const _excluded = ["mode", "pageWidth", "palette", "typography", "overrides"];
17
-
18
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
-
20
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
21
-
22
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
23
-
24
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
25
-
26
- function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
27
-
28
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
29
-
30
- const muiDarkTheme = (0, _styles.createTheme)({
31
- palette: {
32
- mode: 'dark'
6
+ var _exportNames = {
7
+ ThemeProvider: true
8
+ };
9
+ Object.defineProperty(exports, "ThemeProvider", {
10
+ enumerable: true,
11
+ get: function get() {
12
+ return _themeProvider.default;
33
13
  }
34
- }); // https://material-ui.com/customization/default-theme/
35
- // eslint-disable-next-line import/prefer-default-export
36
-
37
- const create = function create() {
38
- let _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
39
- {
40
- mode = 'light',
41
- pageWidth = 'md',
42
- palette,
43
- typography,
44
- overrides
45
- } = _ref,
46
- rest = _objectWithoutProperties(_ref, _excluded);
47
-
48
- // palette 考虑 light & dark mode, dark mode 需要持续完善
49
- // - 能配合 ColorModeContext 使用
50
- // - 为 dark mode 系统的设计整个 palette, 不要单个 color 设置
51
- const _palette = mode === 'light' ? Object.assign(_objectSpread(_objectSpread({}, _Colors.default), {}, {
52
- background: {
53
- paper: _Colors.default.common.white,
54
- default: _Colors.default.background.default
55
- },
56
- mode
57
- }), palette || {}) : Object.assign(_objectSpread(_objectSpread({}, muiDarkTheme.palette), {}, {
58
- background: {
59
- paper: _Colors.default.grey[900],
60
- default: _Colors.default.grey[900]
61
- },
62
- mode
63
- }), palette || {});
14
+ });
64
15
 
65
- const theme = (0, _styles.createTheme)(_objectSpread({
66
- themeName: 'ArcBlock',
67
- palette: _palette,
68
- typography: Object.assign({
69
- useNextVariants: true,
70
- color: {
71
- // 此处 #222222 必须硬编码, layout/sidebar.js -> Icon/image 加载图片时 color 会影响加载路径
72
- // TODO: 此处硬编码的色值后面需要改为 colors.grey[900],
73
- // 或者如果可以的话直接删掉 typography#color, 文本颜色建议使用 theme.palette.text 中的色值?
74
- // layout 组件建议重构, sidebar 中建议使用 icon 替换 img (#366)
75
- main: mode === 'light' ? '#222222' : _Colors.default.common.white,
76
- gray: mode === 'light' ? _Colors.default.grey[500] : _Colors.default.grey[300]
77
- },
78
- fontFamily: ['Lato', 'Avenir', '-apple-system', 'BlinkMacSystemFont', '"Segoe UI"', 'Roboto', '"Helvetica Neue"', 'Arial', 'sans-serif', '"Apple Color Emoji"', '"Segoe UI Emoji"', '"Segoe UI Symbol"'].join(','),
79
- // 按最新设计规范, 只使用 400/700
80
- fontWeightLight: 400,
81
- fontWeightRegular: 400,
82
- fontWeightMedium: 700,
83
- fontWeightBold: 700,
84
- // button 默认使用粗体
85
- button: {
86
- fontWeight: 700
87
- }
88
- }, typography || {}),
89
- components: _objectSpread({
90
- MuiButton: {
91
- styleOverrides: {
92
- root: {
93
- boxShadow: 'none'
94
- }
95
- }
96
- },
97
- MuiButtonGroup: {
98
- styleOverrides: {
99
- root: {
100
- boxShadow: 'none'
101
- }
102
- }
103
- },
104
- MuiTableCell: {
105
- styleOverrides: {
106
- root: {
107
- borderBottomWidth: '0',
108
- paddingTop: '14px',
109
- paddingBottom: '14px',
110
- paddingLeft: 0,
111
- paddingRight: '30px'
112
- },
113
- head: {
114
- textTransform: 'uppercase',
115
- color: mode === 'light' ? _Colors.default.grey[900] : _Colors.default.grey[300]
116
- },
117
- body: {
118
- color: mode === 'light' ? _Colors.default.grey[900] : _Colors.default.grey[300]
119
- }
120
- }
121
- }
122
- }, overrides),
123
- pageWidth,
124
- // TODO: 过时的 colors, 需要各项目负责人检查项目中是否使用 "theme.colors", 如果有需要清除,
125
- // 可以从 Colors 模块/theme.palette/mui colors 中取值
126
- colors: {
127
- white: '#FFFFFF',
128
- dark: '#4A707C',
129
- gray: '#222222',
130
- minor: '#9B9B9B',
131
- darkText: '#DCDCDC',
132
- background: '#F7F8F8',
133
- yellow: '#FFCF71',
134
- green: '#44cdc6',
135
- red: '#D0021B',
136
- blue: '#4E6AF6',
137
- primary: '#222222',
138
- black: '#222222',
139
- secondary: '#44cdc6',
140
- mint: '#44cdc6',
141
- textSecondary: '#4A4A4A',
142
- active: '#5b9025',
143
- danger: '#D0021B',
144
- lightGrey: '#BCBCBC'
145
- },
146
- mode
147
- }, rest));
148
- const enhanced = (0, _styles.responsiveFontSizes)(theme, {
149
- breakpoints: ['xs', 'sm', 'md', 'lg'],
150
- disableAlign: false,
151
- factor: 3,
152
- variants: ['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'subtitle1', 'subtitle2', 'body1', 'body2', 'caption', 'button', 'overline']
16
+ var _theme = require("./theme");
17
+
18
+ Object.keys(_theme).forEach(function (key) {
19
+ if (key === "default" || key === "__esModule") return;
20
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
21
+ if (key in exports && exports[key] === _theme[key]) return;
22
+ Object.defineProperty(exports, key, {
23
+ enumerable: true,
24
+ get: function get() {
25
+ return _theme[key];
26
+ }
153
27
  });
154
- return enhanced;
155
- };
28
+ });
29
+
30
+ var _themeProvider = _interopRequireDefault(require("./theme-provider"));
156
31
 
157
- exports.create = create;
32
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = ThemeProvider;
7
+
8
+ var _propTypes = _interopRequireDefault(require("prop-types"));
9
+
10
+ var _styledComponents = require("styled-components");
11
+
12
+ var _styles = require("@mui/material/styles");
13
+
14
+ var _StyledEngineProvider = _interopRequireDefault(require("@mui/material/StyledEngineProvider"));
15
+
16
+ var _CssBaseline = _interopRequireDefault(require("@mui/material/CssBaseline"));
17
+
18
+ var _theme = require("./theme");
19
+
20
+ var _jsxRuntime = require("react/jsx-runtime");
21
+
22
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
+
24
+ const defaultTheme = (0, _theme.create)();
25
+ /**
26
+ * 默认的 theme provider, 可以为 webapp/blocklet 快捷的配置好 mui theme provider
27
+ * 注: 目前 UX 依赖 styled-components, 所以该组件也内置了一个 StyledThemeProvider
28
+ */
29
+
30
+ function ThemeProvider(_ref) {
31
+ let {
32
+ children,
33
+ theme
34
+ } = _ref;
35
+ return (
36
+ /*#__PURE__*/
37
+ // injectFirst 会影响 makeStyles 自定义样式和 mui styles 覆盖问题
38
+ (0, _jsxRuntime.jsx)(_StyledEngineProvider.default, {
39
+ injectFirst: true,
40
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_styles.ThemeProvider, {
41
+ theme: theme,
42
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_styledComponents.ThemeProvider, {
43
+ theme: theme,
44
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_CssBaseline.default, {}), children]
45
+ })
46
+ })
47
+ })
48
+ );
49
+ }
50
+
51
+ ThemeProvider.propTypes = {
52
+ children: _propTypes.default.any,
53
+ theme: _propTypes.default.any
54
+ };
55
+ ThemeProvider.defaultProps = {
56
+ children: null,
57
+ theme: defaultTheme
58
+ };
@@ -0,0 +1,157 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.create = void 0;
7
+
8
+ var _styles = require("@mui/material/styles");
9
+
10
+ require("@fontsource/lato/400.css");
11
+
12
+ require("@fontsource/lato/700.css");
13
+
14
+ var _Colors = _interopRequireDefault(require("../Colors"));
15
+
16
+ const _excluded = ["mode", "pageWidth", "palette", "typography", "overrides"];
17
+
18
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
+
20
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
21
+
22
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
23
+
24
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
25
+
26
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
27
+
28
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
29
+
30
+ const muiDarkTheme = (0, _styles.createTheme)({
31
+ palette: {
32
+ mode: 'dark'
33
+ }
34
+ }); // https://material-ui.com/customization/default-theme/
35
+ // eslint-disable-next-line import/prefer-default-export
36
+
37
+ const create = function create() {
38
+ let _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
39
+ {
40
+ mode = 'light',
41
+ pageWidth = 'md',
42
+ palette,
43
+ typography,
44
+ overrides
45
+ } = _ref,
46
+ rest = _objectWithoutProperties(_ref, _excluded);
47
+
48
+ // palette 考虑 light & dark mode, dark mode 需要持续完善
49
+ // - 能配合 ColorModeContext 使用
50
+ // - 为 dark mode 系统的设计整个 palette, 不要单个 color 设置
51
+ const _palette = mode === 'light' ? Object.assign(_objectSpread(_objectSpread({}, _Colors.default), {}, {
52
+ background: {
53
+ paper: _Colors.default.common.white,
54
+ default: _Colors.default.background.default
55
+ },
56
+ mode
57
+ }), palette || {}) : Object.assign(_objectSpread(_objectSpread({}, muiDarkTheme.palette), {}, {
58
+ background: {
59
+ paper: _Colors.default.grey[900],
60
+ default: _Colors.default.grey[900]
61
+ },
62
+ mode
63
+ }), palette || {});
64
+
65
+ const theme = (0, _styles.createTheme)(_objectSpread({
66
+ themeName: 'ArcBlock',
67
+ palette: _palette,
68
+ typography: Object.assign({
69
+ useNextVariants: true,
70
+ color: {
71
+ // 此处 #222222 必须硬编码, layout/sidebar.js -> Icon/image 加载图片时 color 会影响加载路径
72
+ // TODO: 此处硬编码的色值后面需要改为 colors.grey[900],
73
+ // 或者如果可以的话直接删掉 typography#color, 文本颜色建议使用 theme.palette.text 中的色值?
74
+ // layout 组件建议重构, sidebar 中建议使用 icon 替换 img (#366)
75
+ main: mode === 'light' ? '#222222' : _Colors.default.common.white,
76
+ gray: mode === 'light' ? _Colors.default.grey[500] : _Colors.default.grey[300]
77
+ },
78
+ fontFamily: ['Lato', 'Avenir', '-apple-system', 'BlinkMacSystemFont', '"Segoe UI"', 'Roboto', '"Helvetica Neue"', 'Arial', 'sans-serif', '"Apple Color Emoji"', '"Segoe UI Emoji"', '"Segoe UI Symbol"'].join(','),
79
+ // 按最新设计规范, 只使用 400/700
80
+ fontWeightLight: 400,
81
+ fontWeightRegular: 400,
82
+ fontWeightMedium: 700,
83
+ fontWeightBold: 700,
84
+ // button 默认使用粗体
85
+ button: {
86
+ fontWeight: 700
87
+ }
88
+ }, typography || {}),
89
+ components: _objectSpread({
90
+ MuiButton: {
91
+ styleOverrides: {
92
+ root: {
93
+ boxShadow: 'none'
94
+ }
95
+ }
96
+ },
97
+ MuiButtonGroup: {
98
+ styleOverrides: {
99
+ root: {
100
+ boxShadow: 'none'
101
+ }
102
+ }
103
+ },
104
+ MuiTableCell: {
105
+ styleOverrides: {
106
+ root: {
107
+ borderBottomWidth: '0',
108
+ paddingTop: '14px',
109
+ paddingBottom: '14px',
110
+ paddingLeft: 0,
111
+ paddingRight: '30px'
112
+ },
113
+ head: {
114
+ textTransform: 'uppercase',
115
+ color: mode === 'light' ? _Colors.default.grey[900] : _Colors.default.grey[300]
116
+ },
117
+ body: {
118
+ color: mode === 'light' ? _Colors.default.grey[900] : _Colors.default.grey[300]
119
+ }
120
+ }
121
+ }
122
+ }, overrides),
123
+ pageWidth,
124
+ // TODO: 过时的 colors, 需要各项目负责人检查项目中是否使用 "theme.colors", 如果有需要清除,
125
+ // 可以从 Colors 模块/theme.palette/mui colors 中取值
126
+ colors: {
127
+ white: '#FFFFFF',
128
+ dark: '#4A707C',
129
+ gray: '#222222',
130
+ minor: '#9B9B9B',
131
+ darkText: '#DCDCDC',
132
+ background: '#F7F8F8',
133
+ yellow: '#FFCF71',
134
+ green: '#44cdc6',
135
+ red: '#D0021B',
136
+ blue: '#4E6AF6',
137
+ primary: '#222222',
138
+ black: '#222222',
139
+ secondary: '#44cdc6',
140
+ mint: '#44cdc6',
141
+ textSecondary: '#4A4A4A',
142
+ active: '#5b9025',
143
+ danger: '#D0021B',
144
+ lightGrey: '#BCBCBC'
145
+ },
146
+ mode
147
+ }, rest));
148
+ const enhanced = (0, _styles.responsiveFontSizes)(theme, {
149
+ breakpoints: ['xs', 'sm', 'md', 'lg'],
150
+ disableAlign: false,
151
+ factor: 3,
152
+ variants: ['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'subtitle1', 'subtitle2', 'body1', 'body2', 'caption', 'button', 'overline']
153
+ });
154
+ return enhanced;
155
+ };
156
+
157
+ exports.create = create;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcblock/ux",
3
- "version": "2.1.70",
3
+ "version": "2.2.1",
4
4
  "description": "Common used react components for arcblock products",
5
5
  "keywords": [
6
6
  "react",
@@ -32,59 +32,59 @@
32
32
  "access": "public"
33
33
  },
34
34
  "devDependencies": {
35
- "@babel/cli": "^7.8.4",
36
- "@babel/core": "^7.8.4",
37
- "@babel/plugin-proposal-class-properties": "^7.8.3",
38
- "@babel/preset-env": "^7.8.4",
39
- "@babel/preset-react": "^7.8.3",
40
- "babel-plugin-inline-react-svg": "^1.1.1",
41
- "babel-plugin-styled-components": "^1.10.7",
42
- "eslint-plugin-react-hooks": "^4.2.0",
43
- "jest": "^24.1.0",
44
- "moment-timezone": "^0.5.33"
35
+ "@babel/cli": "^7.18.10",
36
+ "@babel/core": "^7.18.10",
37
+ "@babel/plugin-proposal-class-properties": "^7.18.6",
38
+ "@babel/preset-env": "^7.18.10",
39
+ "@babel/preset-react": "^7.18.6",
40
+ "babel-plugin-inline-react-svg": "^1.1.2",
41
+ "babel-plugin-styled-components": "^1.13.3",
42
+ "eslint-plugin-react-hooks": "^4.6.0",
43
+ "jest": "^24.9.0",
44
+ "moment-timezone": "^0.5.34"
45
45
  },
46
46
  "peerDependencies": {
47
47
  "@sentry/browser": "^5.0.8",
48
48
  "react": ">=18.1.0",
49
49
  "react-ga": "^2.7.0"
50
50
  },
51
- "gitHead": "f8a19c44fc1814f7c191023297b38ef9af21efc6",
51
+ "gitHead": "7fd063875d78f056aadea005b21b48c8c3bfb6c7",
52
52
  "dependencies": {
53
- "@arcblock/icons": "^2.1.70",
54
- "@arcblock/react-hooks": "^2.1.70",
53
+ "@arcblock/icons": "^2.2.1",
54
+ "@arcblock/react-hooks": "^2.2.1",
55
55
  "@babel/plugin-syntax-dynamic-import": "^7.8.3",
56
- "@emotion/react": "^11.9.0",
57
- "@emotion/styled": "^11.8.1",
58
- "@fontsource/lato": "^4.5.3",
59
- "@mui/icons-material": "^5.6.2",
60
- "@mui/material": "^5.6.4",
56
+ "@emotion/react": "^11.10.0",
57
+ "@emotion/styled": "^11.10.0",
58
+ "@fontsource/lato": "^4.5.8",
59
+ "@mui/icons-material": "^5.8.4",
60
+ "@mui/material": "^5.9.3",
61
61
  "@solana/qr-code-styling": "^1.6.0-beta.0",
62
- "axios": "^0.21.2",
62
+ "axios": "^0.21.4",
63
63
  "base64-url": "^2.3.3",
64
- "copy-to-clipboard": "^3.2.0",
65
- "core-js": "^3.6.4",
66
- "d3-geo": "^1.11.6",
67
- "dayjs": "^1.11.2",
64
+ "copy-to-clipboard": "^3.3.1",
65
+ "core-js": "^3.24.1",
66
+ "d3-geo": "^1.12.1",
67
+ "dayjs": "^1.11.4",
68
68
  "devices.css": "^0.1.15",
69
69
  "highlight.js": "^11.6.0",
70
- "is-svg": "^4.3.1",
71
- "js-cookie": "^2.2.0",
70
+ "is-svg": "^4.3.2",
71
+ "js-cookie": "^2.2.1",
72
72
  "lodash": "^4.17.21",
73
- "mdi-material-ui": "^7.2.0",
73
+ "mdi-material-ui": "^7.4.0",
74
74
  "mui-datatables": "^4.2.2",
75
75
  "notistack": "^2.0.5",
76
76
  "react-cookie-consent": "^6.4.1",
77
77
  "react-error-boundary": "^3.1.4",
78
78
  "react-helmet": "^6.1.0",
79
- "react-intersection-observer": "^8.31.1",
80
- "react-lottie-player": "^1.4.2",
81
- "react-player": "^1.15.2",
82
- "react-router-dom": "^5.1.2",
83
- "react-shadow": "^19.0.2",
84
- "react-use": "^17.2.4",
79
+ "react-intersection-observer": "^8.34.0",
80
+ "react-lottie-player": "^1.4.3",
81
+ "react-player": "^1.15.3",
82
+ "react-router-dom": "^5.3.3",
83
+ "react-shadow": "^19.0.3",
84
+ "react-use": "^17.4.0",
85
85
  "rebound": "^0.1.0",
86
- "styled-components": "^5.0.0",
87
- "topojson-client": "^3.0.0",
86
+ "styled-components": "^5.3.5",
87
+ "topojson-client": "^3.1.0",
88
88
  "versor": "^0.0.4"
89
89
  }
90
90
  }
@@ -1,164 +1,2 @@
1
- // https://app.zeplin.io/styleguide/5d1436f1e97c2156f49c0725/colors
2
- import { createTheme, responsiveFontSizes } from '@mui/material/styles';
3
- import '@fontsource/lato/400.css';
4
- import '@fontsource/lato/700.css';
5
- import colors from '../Colors';
6
-
7
- const muiDarkTheme = createTheme({ palette: { mode: 'dark' } });
8
-
9
- // https://material-ui.com/customization/default-theme/
10
- // eslint-disable-next-line import/prefer-default-export
11
- export const create = ({ mode = 'light', pageWidth = 'md', palette, typography, overrides, ...rest } = {}) => {
12
- // palette 考虑 light & dark mode, dark mode 需要持续完善
13
- // - 能配合 ColorModeContext 使用
14
- // - 为 dark mode 系统的设计整个 palette, 不要单个 color 设置
15
- const _palette =
16
- mode === 'light'
17
- ? Object.assign(
18
- {
19
- ...colors,
20
- background: {
21
- paper: colors.common.white,
22
- default: colors.background.default,
23
- },
24
- mode,
25
- },
26
- palette || {}
27
- )
28
- : Object.assign(
29
- {
30
- ...muiDarkTheme.palette,
31
- background: {
32
- paper: colors.grey[900],
33
- default: colors.grey[900],
34
- },
35
- mode,
36
- },
37
- palette || {}
38
- );
39
-
40
- const theme = createTheme({
41
- themeName: 'ArcBlock',
42
- palette: _palette,
43
- typography: Object.assign(
44
- {
45
- useNextVariants: true,
46
- color: {
47
- // 此处 #222222 必须硬编码, layout/sidebar.js -> Icon/image 加载图片时 color 会影响加载路径
48
- // TODO: 此处硬编码的色值后面需要改为 colors.grey[900],
49
- // 或者如果可以的话直接删掉 typography#color, 文本颜色建议使用 theme.palette.text 中的色值?
50
- // layout 组件建议重构, sidebar 中建议使用 icon 替换 img (#366)
51
- main: mode === 'light' ? '#222222' : colors.common.white,
52
- gray: mode === 'light' ? colors.grey[500] : colors.grey[300],
53
- },
54
- fontFamily: [
55
- 'Lato',
56
- 'Avenir',
57
- '-apple-system',
58
- 'BlinkMacSystemFont',
59
- '"Segoe UI"',
60
- 'Roboto',
61
- '"Helvetica Neue"',
62
- 'Arial',
63
- 'sans-serif',
64
- '"Apple Color Emoji"',
65
- '"Segoe UI Emoji"',
66
- '"Segoe UI Symbol"',
67
- ].join(','),
68
- // 按最新设计规范, 只使用 400/700
69
- fontWeightLight: 400,
70
- fontWeightRegular: 400,
71
- fontWeightMedium: 700,
72
- fontWeightBold: 700,
73
- // button 默认使用粗体
74
- button: {
75
- fontWeight: 700,
76
- },
77
- },
78
- typography || {}
79
- ),
80
- components: {
81
- MuiButton: {
82
- styleOverrides: {
83
- root: {
84
- boxShadow: 'none',
85
- },
86
- },
87
- },
88
- MuiButtonGroup: {
89
- styleOverrides: {
90
- root: {
91
- boxShadow: 'none',
92
- },
93
- },
94
- },
95
- MuiTableCell: {
96
- styleOverrides: {
97
- root: {
98
- borderBottomWidth: '0',
99
- paddingTop: '14px',
100
- paddingBottom: '14px',
101
- paddingLeft: 0,
102
- paddingRight: '30px',
103
- },
104
- head: {
105
- textTransform: 'uppercase',
106
- color: mode === 'light' ? colors.grey[900] : colors.grey[300],
107
- },
108
- body: {
109
- color: mode === 'light' ? colors.grey[900] : colors.grey[300],
110
- },
111
- },
112
- },
113
- ...overrides,
114
- },
115
- pageWidth,
116
- // TODO: 过时的 colors, 需要各项目负责人检查项目中是否使用 "theme.colors", 如果有需要清除,
117
- // 可以从 Colors 模块/theme.palette/mui colors 中取值
118
- colors: {
119
- white: '#FFFFFF',
120
- dark: '#4A707C',
121
- gray: '#222222',
122
- minor: '#9B9B9B',
123
- darkText: '#DCDCDC',
124
- background: '#F7F8F8',
125
- yellow: '#FFCF71',
126
- green: '#44cdc6',
127
- red: '#D0021B',
128
- blue: '#4E6AF6',
129
- primary: '#222222',
130
- black: '#222222',
131
- secondary: '#44cdc6',
132
- mint: '#44cdc6',
133
- textSecondary: '#4A4A4A',
134
- active: '#5b9025',
135
- danger: '#D0021B',
136
- lightGrey: '#BCBCBC',
137
- },
138
- mode,
139
- ...rest,
140
- });
141
-
142
- const enhanced = responsiveFontSizes(theme, {
143
- breakpoints: ['xs', 'sm', 'md', 'lg'],
144
- disableAlign: false,
145
- factor: 3,
146
- variants: [
147
- 'h1',
148
- 'h2',
149
- 'h3',
150
- 'h4',
151
- 'h5',
152
- 'h6',
153
- 'subtitle1',
154
- 'subtitle2',
155
- 'body1',
156
- 'body2',
157
- 'caption',
158
- 'button',
159
- 'overline',
160
- ],
161
- });
162
-
163
- return enhanced;
164
- };
1
+ export * from './theme';
2
+ export { default as ThemeProvider } from './theme-provider';
@@ -0,0 +1,36 @@
1
+ import PropTypes from 'prop-types';
2
+ import { ThemeProvider as StyledThemeProvider } from 'styled-components';
3
+ import { ThemeProvider as MuiThemeProvider } from '@mui/material/styles';
4
+ import StyledEngineProvider from '@mui/material/StyledEngineProvider';
5
+ import CssBaseline from '@mui/material/CssBaseline';
6
+ import { create } from './theme';
7
+
8
+ const defaultTheme = create();
9
+
10
+ /**
11
+ * 默认的 theme provider, 可以为 webapp/blocklet 快捷的配置好 mui theme provider
12
+ * 注: 目前 UX 依赖 styled-components, 所以该组件也内置了一个 StyledThemeProvider
13
+ */
14
+ export default function ThemeProvider({ children, theme }) {
15
+ return (
16
+ // injectFirst 会影响 makeStyles 自定义样式和 mui styles 覆盖问题
17
+ <StyledEngineProvider injectFirst>
18
+ <MuiThemeProvider theme={theme}>
19
+ <StyledThemeProvider theme={theme}>
20
+ <CssBaseline />
21
+ {children}
22
+ </StyledThemeProvider>
23
+ </MuiThemeProvider>
24
+ </StyledEngineProvider>
25
+ );
26
+ }
27
+
28
+ ThemeProvider.propTypes = {
29
+ children: PropTypes.any,
30
+ theme: PropTypes.any,
31
+ };
32
+
33
+ ThemeProvider.defaultProps = {
34
+ children: null,
35
+ theme: defaultTheme,
36
+ };
@@ -0,0 +1,164 @@
1
+ // https://app.zeplin.io/styleguide/5d1436f1e97c2156f49c0725/colors
2
+ import { createTheme, responsiveFontSizes } from '@mui/material/styles';
3
+ import '@fontsource/lato/400.css';
4
+ import '@fontsource/lato/700.css';
5
+ import colors from '../Colors';
6
+
7
+ const muiDarkTheme = createTheme({ palette: { mode: 'dark' } });
8
+
9
+ // https://material-ui.com/customization/default-theme/
10
+ // eslint-disable-next-line import/prefer-default-export
11
+ export const create = ({ mode = 'light', pageWidth = 'md', palette, typography, overrides, ...rest } = {}) => {
12
+ // palette 考虑 light & dark mode, dark mode 需要持续完善
13
+ // - 能配合 ColorModeContext 使用
14
+ // - 为 dark mode 系统的设计整个 palette, 不要单个 color 设置
15
+ const _palette =
16
+ mode === 'light'
17
+ ? Object.assign(
18
+ {
19
+ ...colors,
20
+ background: {
21
+ paper: colors.common.white,
22
+ default: colors.background.default,
23
+ },
24
+ mode,
25
+ },
26
+ palette || {}
27
+ )
28
+ : Object.assign(
29
+ {
30
+ ...muiDarkTheme.palette,
31
+ background: {
32
+ paper: colors.grey[900],
33
+ default: colors.grey[900],
34
+ },
35
+ mode,
36
+ },
37
+ palette || {}
38
+ );
39
+
40
+ const theme = createTheme({
41
+ themeName: 'ArcBlock',
42
+ palette: _palette,
43
+ typography: Object.assign(
44
+ {
45
+ useNextVariants: true,
46
+ color: {
47
+ // 此处 #222222 必须硬编码, layout/sidebar.js -> Icon/image 加载图片时 color 会影响加载路径
48
+ // TODO: 此处硬编码的色值后面需要改为 colors.grey[900],
49
+ // 或者如果可以的话直接删掉 typography#color, 文本颜色建议使用 theme.palette.text 中的色值?
50
+ // layout 组件建议重构, sidebar 中建议使用 icon 替换 img (#366)
51
+ main: mode === 'light' ? '#222222' : colors.common.white,
52
+ gray: mode === 'light' ? colors.grey[500] : colors.grey[300],
53
+ },
54
+ fontFamily: [
55
+ 'Lato',
56
+ 'Avenir',
57
+ '-apple-system',
58
+ 'BlinkMacSystemFont',
59
+ '"Segoe UI"',
60
+ 'Roboto',
61
+ '"Helvetica Neue"',
62
+ 'Arial',
63
+ 'sans-serif',
64
+ '"Apple Color Emoji"',
65
+ '"Segoe UI Emoji"',
66
+ '"Segoe UI Symbol"',
67
+ ].join(','),
68
+ // 按最新设计规范, 只使用 400/700
69
+ fontWeightLight: 400,
70
+ fontWeightRegular: 400,
71
+ fontWeightMedium: 700,
72
+ fontWeightBold: 700,
73
+ // button 默认使用粗体
74
+ button: {
75
+ fontWeight: 700,
76
+ },
77
+ },
78
+ typography || {}
79
+ ),
80
+ components: {
81
+ MuiButton: {
82
+ styleOverrides: {
83
+ root: {
84
+ boxShadow: 'none',
85
+ },
86
+ },
87
+ },
88
+ MuiButtonGroup: {
89
+ styleOverrides: {
90
+ root: {
91
+ boxShadow: 'none',
92
+ },
93
+ },
94
+ },
95
+ MuiTableCell: {
96
+ styleOverrides: {
97
+ root: {
98
+ borderBottomWidth: '0',
99
+ paddingTop: '14px',
100
+ paddingBottom: '14px',
101
+ paddingLeft: 0,
102
+ paddingRight: '30px',
103
+ },
104
+ head: {
105
+ textTransform: 'uppercase',
106
+ color: mode === 'light' ? colors.grey[900] : colors.grey[300],
107
+ },
108
+ body: {
109
+ color: mode === 'light' ? colors.grey[900] : colors.grey[300],
110
+ },
111
+ },
112
+ },
113
+ ...overrides,
114
+ },
115
+ pageWidth,
116
+ // TODO: 过时的 colors, 需要各项目负责人检查项目中是否使用 "theme.colors", 如果有需要清除,
117
+ // 可以从 Colors 模块/theme.palette/mui colors 中取值
118
+ colors: {
119
+ white: '#FFFFFF',
120
+ dark: '#4A707C',
121
+ gray: '#222222',
122
+ minor: '#9B9B9B',
123
+ darkText: '#DCDCDC',
124
+ background: '#F7F8F8',
125
+ yellow: '#FFCF71',
126
+ green: '#44cdc6',
127
+ red: '#D0021B',
128
+ blue: '#4E6AF6',
129
+ primary: '#222222',
130
+ black: '#222222',
131
+ secondary: '#44cdc6',
132
+ mint: '#44cdc6',
133
+ textSecondary: '#4A4A4A',
134
+ active: '#5b9025',
135
+ danger: '#D0021B',
136
+ lightGrey: '#BCBCBC',
137
+ },
138
+ mode,
139
+ ...rest,
140
+ });
141
+
142
+ const enhanced = responsiveFontSizes(theme, {
143
+ breakpoints: ['xs', 'sm', 'md', 'lg'],
144
+ disableAlign: false,
145
+ factor: 3,
146
+ variants: [
147
+ 'h1',
148
+ 'h2',
149
+ 'h3',
150
+ 'h4',
151
+ 'h5',
152
+ 'h6',
153
+ 'subtitle1',
154
+ 'subtitle2',
155
+ 'body1',
156
+ 'body2',
157
+ 'caption',
158
+ 'button',
159
+ 'overline',
160
+ ],
161
+ });
162
+
163
+ return enhanced;
164
+ };