@arcblock/ux 1.16.60 → 1.16.61

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.
@@ -29,6 +29,49 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
29
29
 
30
30
  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; }
31
31
 
32
+ const extendedColors = {
33
+ danger: {
34
+ contained: {
35
+ backgroundColor: _Colors.default.error.main,
36
+ color: _Colors.default.common.white
37
+ },
38
+ outlined: {
39
+ borderColor: _Colors.default.error.main,
40
+ color: _Colors.default.error.main
41
+ }
42
+ },
43
+ warning: {
44
+ contained: {
45
+ backgroundColor: _Colors.default.warning.main,
46
+ color: _Colors.default.common.white
47
+ },
48
+ outlined: {
49
+ borderColor: _Colors.default.warning.main,
50
+ color: _Colors.default.warning.main
51
+ }
52
+ },
53
+ did: {
54
+ contained: {
55
+ backgroundColor: _Colors.default.did.primary,
56
+ color: _Colors.default.common.white
57
+ },
58
+ outlined: {
59
+ borderColor: _Colors.default.did.primary,
60
+ color: _Colors.default.did.primary
61
+ }
62
+ },
63
+ reverse: {
64
+ contained: {
65
+ backgroundColor: 'rgba(255, 255, 255, 0.9)',
66
+ color: _Colors.default.grey[900]
67
+ },
68
+ outlined: {
69
+ borderColor: _Colors.default.grey[900],
70
+ color: _Colors.default.grey[900]
71
+ }
72
+ }
73
+ };
74
+
32
75
  function _default(BaseComponent) {
33
76
  function WrappedComponent(props) {
34
77
  const newProps = (0, _Util.mergeProps)(props, WrappedComponent, ['style']);
@@ -57,64 +100,22 @@ function _default(BaseComponent) {
57
100
  break;
58
101
 
59
102
  default:
60
- }
103
+ } // mui 只支持 4 种 color 值: default/inherit/primary/secondary (传入这 4 种之外的值会报 warning),
104
+ // 这里扩展 danger/warning/reverse/did 四种 color
105
+
61
106
 
62
- const styles = Object.assign({}, style, {
107
+ const matched = extendedColors[color] && extendedColors[color][rest.variant];
108
+ const styles = Object.assign({}, style, _objectSpread({
63
109
  boxShadow: 'none',
64
110
  textTransform: 'capitalize'
65
- }); // mui 只支持 4 种 color 值: default/inherit/primary/secondary (传入这 4 种之外的值会报 warning),
66
- // 这里扩展 danger/warning/reverse 三种 color
67
-
111
+ }, matched));
68
112
  let _rest = rest;
69
113
 
70
- switch (color) {
71
- case 'error':
72
- case 'danger':
73
- {
74
- if (rest.variant === 'contained') {
75
- styles.backgroundColor = _Colors.default.error.main;
76
- styles.color = _Colors.default.common.white;
77
- } else {
78
- styles.borderColor = _Colors.default.error.main;
79
- styles.color = _Colors.default.error.main;
80
- }
81
-
82
- break;
83
- }
84
-
85
- case 'warning':
86
- {
87
- if (rest.variant === 'contained') {
88
- styles.backgroundColor = _Colors.default.warning.main;
89
- styles.color = _Colors.default.common.white;
90
- } else {
91
- styles.borderColor = _Colors.default.warning.main;
92
- styles.color = _Colors.default.warning.main;
93
- }
94
-
95
- break;
96
- }
97
-
98
- case 'reverse':
99
- {
100
- if (rest.variant === 'contained') {
101
- styles.backgroundColor = 'rgba(255, 255, 255, 0.9)';
102
- styles.color = _Colors.default.grey[900];
103
- } else {
104
- styles.borderColor = _Colors.default.grey[900];
105
- styles.color = _Colors.default.grey[900];
106
- }
107
-
108
- break;
109
- }
110
- // 除扩展的几种 color 外, 由 mui button 自己处理 color
111
-
112
- default:
113
- {
114
- _rest = _objectSpread(_objectSpread({}, _rest), {}, {
115
- color
116
- });
117
- }
114
+ if (!matched) {
115
+ // mui button 本身支持的 color 交由 mui 处理
116
+ _rest = _objectSpread(_objectSpread({}, _rest), {}, {
117
+ color
118
+ });
118
119
  }
119
120
 
120
121
  if (rounded) {
@@ -110,7 +110,7 @@ const gradient = 'linear-gradient(32deg, rgba(144, 255, 230, 0.1), rgba(144, 255
110
110
  const MenuItem = (0, _styledComponents.default)(_Button.default).withConfig({
111
111
  displayName: "sidebar__MenuItem",
112
112
  componentId: "sc-gaosgy-1"
113
- })(["&&{display:block;width:100%;transition:all 200ms ease-in-out;background:", ";padding:24px 0;border-left:2px solid ", ";&:hover{background:", ";border-left-color:", ";}.menu-title{margin-top:8px;font-size:12px;font-weight:500;text-align:center;text-transform:capitalize;letter-spacing:normal;width:80%;}.MuiButton-label{display:flex;flex-direction:column;justify-content:center;align-items:center;}}"], props => props.selected ? gradient : '', props => props.selected ? _teal.default.A700 : 'transparent', gradient, _teal.default.A700);
113
+ })(["&&{display:block;width:100%;transition:all 200ms ease-in-out;background:", ";padding:24px 0;border-left:2px solid ", ";border-radius:0;&:hover{background:", ";border-left-color:", ";}.menu-title{margin-top:8px;font-size:12px;font-weight:500;text-align:center;text-transform:capitalize;letter-spacing:normal;width:80%;}.MuiButton-label{display:flex;flex-direction:column;justify-content:center;align-items:center;}}"], props => props.selected ? gradient : '', props => props.selected ? _teal.default.A700 : 'transparent', gradient, _teal.default.A700);
114
114
 
115
115
  var _default = (0, _reactRouterDom.withRouter)((0, _withTheme.default)(Sidebar));
116
116
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcblock/ux",
3
- "version": "1.16.60",
3
+ "version": "1.16.61",
4
4
  "description": "Common used react components for arcblock products",
5
5
  "keywords": [
6
6
  "react",
@@ -53,10 +53,10 @@
53
53
  "react": ">=16.12.0",
54
54
  "react-ga": "^2.7.0"
55
55
  },
56
- "gitHead": "7747d27c27d53c64a05209031851e02d70f3dae0",
56
+ "gitHead": "7fea6393d63b83059873613993172a6dc98508ce",
57
57
  "dependencies": {
58
- "@arcblock/icons": "^1.16.60",
59
- "@arcblock/react-hooks": "^1.16.60",
58
+ "@arcblock/icons": "^1.16.61",
59
+ "@arcblock/react-hooks": "^1.16.61",
60
60
  "@babel/plugin-syntax-dynamic-import": "^7.8.3",
61
61
  "@fontsource/lato": "^4.5.3",
62
62
  "@material-ui/core": "^4.12.3",
@@ -7,6 +7,25 @@ import Spinner from '../Spinner';
7
7
  import colors from '../Colors';
8
8
  import { mergeProps } from '../Util';
9
9
 
10
+ const extendedColors = {
11
+ danger: {
12
+ contained: { backgroundColor: colors.error.main, color: colors.common.white },
13
+ outlined: { borderColor: colors.error.main, color: colors.error.main },
14
+ },
15
+ warning: {
16
+ contained: { backgroundColor: colors.warning.main, color: colors.common.white },
17
+ outlined: { borderColor: colors.warning.main, color: colors.warning.main },
18
+ },
19
+ did: {
20
+ contained: { backgroundColor: colors.did.primary, color: colors.common.white },
21
+ outlined: { borderColor: colors.did.primary, color: colors.did.primary },
22
+ },
23
+ reverse: {
24
+ contained: { backgroundColor: 'rgba(255, 255, 255, 0.9)', color: colors.grey[900] },
25
+ outlined: { borderColor: colors.grey[900], color: colors.grey[900] },
26
+ },
27
+ };
28
+
10
29
  export default function (BaseComponent) {
11
30
  function WrappedComponent(props) {
12
31
  const newProps = mergeProps(props, WrappedComponent, ['style']);
@@ -24,50 +43,19 @@ export default function (BaseComponent) {
24
43
  break;
25
44
  default:
26
45
  }
46
+
47
+ // mui 只支持 4 种 color 值: default/inherit/primary/secondary (传入这 4 种之外的值会报 warning),
48
+ // 这里扩展 danger/warning/reverse/did 四种 color
49
+ const matched = extendedColors[color] && extendedColors[color][rest.variant];
27
50
  const styles = Object.assign({}, style, {
28
51
  boxShadow: 'none',
29
52
  textTransform: 'capitalize',
53
+ ...matched,
30
54
  });
31
-
32
- // mui 只支持 4 种 color 值: default/inherit/primary/secondary (传入这 4 种之外的值会报 warning),
33
- // 这里扩展 danger/warning/reverse 三种 color
34
55
  let _rest = rest;
35
- switch (color) {
36
- case 'error':
37
- case 'danger': {
38
- if (rest.variant === 'contained') {
39
- styles.backgroundColor = colors.error.main;
40
- styles.color = colors.common.white;
41
- } else {
42
- styles.borderColor = colors.error.main;
43
- styles.color = colors.error.main;
44
- }
45
- break;
46
- }
47
- case 'warning': {
48
- if (rest.variant === 'contained') {
49
- styles.backgroundColor = colors.warning.main;
50
- styles.color = colors.common.white;
51
- } else {
52
- styles.borderColor = colors.warning.main;
53
- styles.color = colors.warning.main;
54
- }
55
- break;
56
- }
57
- case 'reverse': {
58
- if (rest.variant === 'contained') {
59
- styles.backgroundColor = 'rgba(255, 255, 255, 0.9)';
60
- styles.color = colors.grey[900];
61
- } else {
62
- styles.borderColor = colors.grey[900];
63
- styles.color = colors.grey[900];
64
- }
65
- break;
66
- }
67
- // 除扩展的几种 color 外, 由 mui button 自己处理 color
68
- default: {
69
- _rest = { ..._rest, color };
70
- }
56
+ if (!matched) {
57
+ // mui button 本身支持的 color 交由 mui 处理
58
+ _rest = { ..._rest, color };
71
59
  }
72
60
  if (rounded) {
73
61
  // styles.borderRadius = { small: 16, medium: 18, large: 20 }[rest.size];
@@ -94,6 +94,7 @@ const MenuItem = styled(Button)`
94
94
  background: ${props => (props.selected ? gradient : '')};
95
95
  padding: 24px 0;
96
96
  border-left: 2px solid ${props => (props.selected ? teal.A700 : 'transparent')};
97
+ border-radius: 0;
97
98
 
98
99
  &:hover {
99
100
  background: ${gradient};