@arcblock/ux 1.16.58 → 1.16.62
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.
- package/lib/Button/wrap.js +54 -53
- package/lib/Layout/dashboard/header.js +15 -2
- package/lib/Layout/dashboard/index.js +2 -2
- package/lib/Layout/dashboard/sidebar.js +2 -2
- package/lib/Layout/index.js +1 -1
- package/lib/QRCode/index.js +89 -0
- package/package.json +5 -4
- package/src/Button/wrap.js +27 -39
- package/src/Layout/dashboard/header.js +14 -14
- package/src/Layout/dashboard/index.js +2 -2
- package/src/Layout/dashboard/sidebar.js +2 -1
- package/src/Layout/index.js +2 -2
- package/src/QRCode/index.js +56 -0
package/lib/Button/wrap.js
CHANGED
|
@@ -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
|
|
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
|
-
});
|
|
66
|
-
// 这里扩展 danger/warning/reverse 三种 color
|
|
67
|
-
|
|
111
|
+
}, matched));
|
|
68
112
|
let _rest = rest;
|
|
69
113
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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) {
|
|
@@ -21,6 +21,8 @@ var _Box = _interopRequireDefault(require("@material-ui/core/Box"));
|
|
|
21
21
|
|
|
22
22
|
var _Typography = _interopRequireDefault(require("@material-ui/core/Typography"));
|
|
23
23
|
|
|
24
|
+
var _Hidden = _interopRequireDefault(require("@material-ui/core/Hidden"));
|
|
25
|
+
|
|
24
26
|
var _Menu = _interopRequireDefault(require("@material-ui/icons/Menu"));
|
|
25
27
|
|
|
26
28
|
var _reactRouterDom = require("react-router-dom");
|
|
@@ -38,7 +40,16 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
38
40
|
const StyledAppBar = (0, _styledComponents.default)(_AppBar.default).withConfig({
|
|
39
41
|
displayName: "header__StyledAppBar",
|
|
40
42
|
componentId: "sc-yt81c4-0"
|
|
41
|
-
})(["&&{z-index:", ";background:", ";box-shadow:none;top:0;height:auto;}.header-toolbar{background:", ";color:", ";margin:", "px 0;}.header-link{display:flex;text-decoration:none;flex-shrink:1;overflow:hidden;}.header-logo{margin-right:20px;}.header-title{display:flex;flex-direction:column;justify-content:center;align-items:flex-start;}.header-title__primary{font-size:24px;font-weight:800;color:", ";text-transform:uppercase;display:flex;align-items:center;}.header-title__secondary{font-size:14px;line-height:1.71;color:", ";}.header-addons{display:flex;justify-content:center;align-items:center;flex-shrink:9999999;.user-addon{.header-avatar{width:32px;border-radius:16px;height:auto;}}}.header-menu{display:none;}
|
|
43
|
+
})(["&&{z-index:", ";background:", ";box-shadow:none;top:0;height:auto;}.header-toolbar{background:", ";color:", ";margin:", "px 0;}.header-link{display:flex;text-decoration:none;flex-shrink:1;overflow:hidden;}.header-logo{margin-right:20px;}.header-title{display:flex;flex-direction:column;justify-content:center;align-items:flex-start;}.header-title__primary{font-size:24px;font-weight:800;color:", ";text-transform:uppercase;display:flex;align-items:center;}.header-title__secondary{font-size:14px;line-height:1.71;color:", ";}.header-addons{display:flex;justify-content:center;align-items:center;flex-shrink:9999999;.user-addon{.header-avatar{width:32px;border-radius:16px;height:auto;}}}.header-menu{display:none;}", "{.header-title{display:none;}.header-title__primary{font-size:20px;}.header-menu{display:block;}}"], props => props.theme.zIndex.drawer + 1, props => props.theme.palette.background.default, props => props.theme.palette.background.default, props => props.theme.palette.text.primary, props => props.theme.spacing(1), props => props.theme.typography.color.main, props => props.theme.typography.color.gray, props => props.theme.breakpoints.down('sm'));
|
|
44
|
+
/*
|
|
45
|
+
自定义 logo 相关:
|
|
46
|
+
如果为 logo prop 传入一个自定义的 svg, 并且 svg 中的元素通过 id 引用了 defs 中的元素 (比如 linearGradient),
|
|
47
|
+
这种情况下因为 header 和 sidebar 中会各有一个相同的 svg, defs 中元素的 id 会出现冲突,
|
|
48
|
+
当屏幕较窄时, header 会通过设置 display:none 将 svg logo 隐藏,
|
|
49
|
+
这会导致 svg defs 中的元素不能被正常引用 (比如 fill 引用的 color 失效), 这会进一步导致 sidebar 中的 logo 不能正常显示.
|
|
50
|
+
考虑到上述问题, 目前使用 Hidden 组件控制 logo 的显示/隐藏
|
|
51
|
+
参考: https://blog.patw.me/archives/1820/inline-svg-same-id-and-display-none-issue/
|
|
52
|
+
*/
|
|
42
53
|
|
|
43
54
|
function Header(_ref) {
|
|
44
55
|
let {
|
|
@@ -68,11 +79,13 @@ function Header(_ref) {
|
|
|
68
79
|
}, /*#__PURE__*/_react.default.createElement(_Menu.default, null)), /*#__PURE__*/_react.default.createElement(_reactRouterDom.Link, {
|
|
69
80
|
to: homeUrl,
|
|
70
81
|
className: "header-link"
|
|
82
|
+
}, /*#__PURE__*/_react.default.createElement(_Hidden.default, {
|
|
83
|
+
smDown: true
|
|
71
84
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
72
85
|
className: "header-logo"
|
|
73
86
|
}, logo || /*#__PURE__*/_react.default.createElement(_Logo.default, {
|
|
74
87
|
showText: false
|
|
75
|
-
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
88
|
+
}))), /*#__PURE__*/_react.default.createElement("div", {
|
|
76
89
|
className: "header-title"
|
|
77
90
|
}, /*#__PURE__*/_react.default.createElement(_Typography.default, {
|
|
78
91
|
component: "h2",
|
|
@@ -67,10 +67,10 @@ function Dashboard(_ref) {
|
|
|
67
67
|
const {
|
|
68
68
|
width
|
|
69
69
|
} = (0, _useWindowSize.default)();
|
|
70
|
-
const [drawerMode, setDrawerMode] = (0, _react.useState)(width
|
|
70
|
+
const [drawerMode, setDrawerMode] = (0, _react.useState)(width >= breakpoint ? 'permanent' : 'temporary');
|
|
71
71
|
const [drawerOpen, setDrawerOpen] = (0, _react.useState)(drawerMode === 'permanent');
|
|
72
72
|
(0, _react.useEffect)(() => {
|
|
73
|
-
const newMode = width
|
|
73
|
+
const newMode = width >= breakpoint ? 'permanent' : 'temporary';
|
|
74
74
|
setDrawerMode(newMode);
|
|
75
75
|
setDrawerOpen(newMode !== 'temporary');
|
|
76
76
|
}, [width]);
|
|
@@ -104,13 +104,13 @@ Sidebar.defaultProps = {
|
|
|
104
104
|
const MenuItems = /*#__PURE__*/_react.default.memo(_styledComponents.default.div.withConfig({
|
|
105
105
|
displayName: "sidebar__MenuItems",
|
|
106
106
|
componentId: "sc-gaosgy-0"
|
|
107
|
-
})(["flex:1;display:flex;flex-direction:column;&& .sidebar-logo{display:none;border-bottom:1px solid #eee;background:", ";position:sticky;top:0;z-index:1;padding:10px 0;text-align:center;font-size:0;}
|
|
107
|
+
})(["flex:1;display:flex;flex-direction:column;&& .sidebar-logo{display:none;border-bottom:1px solid #eee;background:", ";position:sticky;top:0;z-index:1;padding:10px 0;text-align:center;font-size:0;}", "{&& .sidebar-logo{display:block;}}"], props => props.theme.palette.background.default, props => props.theme.breakpoints.down('sm')));
|
|
108
108
|
|
|
109
109
|
const gradient = 'linear-gradient(32deg, rgba(144, 255, 230, 0.1), rgba(144, 255, 230, 0))';
|
|
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/lib/Layout/index.js
CHANGED
|
@@ -232,7 +232,7 @@ Layout.defaultProps = {
|
|
|
232
232
|
const Div = _styledComponents.default.div.withConfig({
|
|
233
233
|
displayName: "Layout__Div",
|
|
234
234
|
componentId: "sc-12bllvc-0"
|
|
235
|
-
})(["width:100%;min-height:100vh;display:flex;flex-direction:column;.appbar{&.appbar--border{box-shadow:none;&::before{content:'';position:absolute;left:0;right:0;height:1px;bottom:-1px;display:block;background-color:rgba(0,0,0,0.12);}}}.toolbar{min-height:56px;background:inherit;white-space:nowrap;.menu-logo{font-size:0;margin-right:8px;}.nav-links{display:flex;align-items:center;.nav-link{margin:8px 12px;font-size:16px;display:flex;align-items:center;}.highlight-nav{font-weight:bolder;}}.brand{cursor:pointer;text-decoration:none;overflow:hidden;text-overflow:ellipsis;flex-shrink:1;}.description{color:#999;font-size:15px;margin-left:10px;font-weight:normal;flex-shrink:999999;}}
|
|
235
|
+
})(["width:100%;min-height:100vh;display:flex;flex-direction:column;.appbar{&.appbar--border{box-shadow:none;&::before{content:'';position:absolute;left:0;right:0;height:1px;bottom:-1px;display:block;background-color:rgba(0,0,0,0.12);}}}.toolbar{min-height:56px;background:inherit;white-space:nowrap;.menu-logo{font-size:0;margin-right:8px;}.nav-links{display:flex;align-items:center;.nav-link{margin:8px 12px;font-size:16px;display:flex;align-items:center;}.highlight-nav{font-weight:bolder;}}.brand{cursor:pointer;text-decoration:none;overflow:hidden;text-overflow:ellipsis;flex-shrink:1;}.description{color:#999;font-size:15px;margin-left:10px;font-weight:normal;flex-shrink:999999;}}", "{.toolbar{.menu-button{display:none;}.menu-logo{& + .brand{padding-left:45px;margin-left:-45px;}}}}", "{.toolbar{.nav-links,.menu-logo,.description{display:none;}}}"], props => props.theme.breakpoints.up('md'), props => props.theme.breakpoints.down('sm'));
|
|
236
236
|
|
|
237
237
|
const DrawerDiv = _styledComponents.default.nav.withConfig({
|
|
238
238
|
displayName: "Layout__DrawerDiv",
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
|
|
12
|
+
var _qrCodeStyling = _interopRequireDefault(require("@solana/qr-code-styling"));
|
|
13
|
+
|
|
14
|
+
const _excluded = ["data", "size", "image", "config"];
|
|
15
|
+
|
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
+
|
|
18
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
19
|
+
|
|
20
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
21
|
+
|
|
22
|
+
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; }
|
|
23
|
+
|
|
24
|
+
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; }
|
|
25
|
+
|
|
26
|
+
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; }
|
|
27
|
+
|
|
28
|
+
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; }
|
|
29
|
+
|
|
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
|
+
|
|
32
|
+
const defaults = {
|
|
33
|
+
margin: 0,
|
|
34
|
+
dotsOptions: {
|
|
35
|
+
type: 'dots'
|
|
36
|
+
},
|
|
37
|
+
cornersSquareOptions: {
|
|
38
|
+
type: 'extra-rounded'
|
|
39
|
+
},
|
|
40
|
+
cornersDotOptions: {
|
|
41
|
+
type: 'dot'
|
|
42
|
+
}
|
|
43
|
+
}; // 该组件用于生成与 android wallet 样式风格相似的 qrcode
|
|
44
|
+
// 注意: 依赖的 @solana/qr-code-styling 是一份 fork 版本, 原版本的 margin 配置存在 bug
|
|
45
|
+
|
|
46
|
+
function QRCode(_ref) {
|
|
47
|
+
let {
|
|
48
|
+
data,
|
|
49
|
+
size,
|
|
50
|
+
image,
|
|
51
|
+
config
|
|
52
|
+
} = _ref,
|
|
53
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
54
|
+
|
|
55
|
+
const ref = _react.default.useRef(null);
|
|
56
|
+
|
|
57
|
+
(0, _react.useEffect)(() => {
|
|
58
|
+
const qrCode = new _qrCodeStyling.default(_objectSpread(_objectSpread(_objectSpread({}, defaults), {}, {
|
|
59
|
+
data,
|
|
60
|
+
width: size,
|
|
61
|
+
height: size
|
|
62
|
+
}, image && {
|
|
63
|
+
image,
|
|
64
|
+
imageOptions: {
|
|
65
|
+
crossOrigin: 'anonymous',
|
|
66
|
+
margin: 0
|
|
67
|
+
}
|
|
68
|
+
}), config));
|
|
69
|
+
qrCode.append(ref.current);
|
|
70
|
+
}, [data, size]);
|
|
71
|
+
return /*#__PURE__*/_react.default.createElement("div", Object.assign({
|
|
72
|
+
ref: ref
|
|
73
|
+
}, rest));
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
QRCode.propTypes = {
|
|
77
|
+
// 一般情况下仅使用 data/size/image 即可
|
|
78
|
+
data: _propTypes.default.string.isRequired,
|
|
79
|
+
size: _propTypes.default.number.isRequired,
|
|
80
|
+
image: _propTypes.default.string,
|
|
81
|
+
// 覆盖 qr-code-styling 配置
|
|
82
|
+
config: _propTypes.default.object
|
|
83
|
+
};
|
|
84
|
+
QRCode.defaultProps = {
|
|
85
|
+
image: null,
|
|
86
|
+
config: {}
|
|
87
|
+
};
|
|
88
|
+
var _default = QRCode;
|
|
89
|
+
exports.default = _default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcblock/ux",
|
|
3
|
-
"version": "1.16.
|
|
3
|
+
"version": "1.16.62",
|
|
4
4
|
"description": "Common used react components for arcblock products",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -53,14 +53,15 @@
|
|
|
53
53
|
"react": ">=16.12.0",
|
|
54
54
|
"react-ga": "^2.7.0"
|
|
55
55
|
},
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "2c6b82d4b6ccdd21ea910734c00fce236f9e260a",
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@arcblock/icons": "^1.16.
|
|
59
|
-
"@arcblock/react-hooks": "^1.16.
|
|
58
|
+
"@arcblock/icons": "^1.16.62",
|
|
59
|
+
"@arcblock/react-hooks": "^1.16.62",
|
|
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",
|
|
63
63
|
"@material-ui/icons": "4.11.2",
|
|
64
|
+
"@solana/qr-code-styling": "^1.6.0-beta.0",
|
|
64
65
|
"axios": "^0.21.1",
|
|
65
66
|
"base64-url": "^2.3.3",
|
|
66
67
|
"copy-to-clipboard": "^3.2.0",
|
package/src/Button/wrap.js
CHANGED
|
@@ -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
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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];
|
|
@@ -6,6 +6,7 @@ import AppBar from '@material-ui/core/AppBar';
|
|
|
6
6
|
import Toolbar from '@material-ui/core/Toolbar';
|
|
7
7
|
import Box from '@material-ui/core/Box';
|
|
8
8
|
import Typography from '@material-ui/core/Typography';
|
|
9
|
+
import Hidden from '@material-ui/core/Hidden';
|
|
9
10
|
import MenuIcon from '@material-ui/icons/Menu';
|
|
10
11
|
import { Link } from 'react-router-dom';
|
|
11
12
|
|
|
@@ -70,19 +71,7 @@ const StyledAppBar = styled(AppBar)`
|
|
|
70
71
|
.header-menu {
|
|
71
72
|
display: none;
|
|
72
73
|
}
|
|
73
|
-
|
|
74
|
-
/*
|
|
75
|
-
以下样式用来替代 display:none, 如果为 logo prop 传入一个自定义的 svg, 并且 svg 中的元素通过 id 引用了 defs 中的元素 (比如 linearGradient),
|
|
76
|
-
这种情况下因为 header 和 sidebar 中会各有一个相同的 svg, defs 中元素的 id 会出现冲突,
|
|
77
|
-
当屏幕很窄的情况, header 会通过设置 display:none 将 svg logo 隐藏,
|
|
78
|
-
这会导致 svg defs 中的元素不能被正常引用 (比如 fill 引用的 color 失效), 这会进一步导致 sidebar 中的 logo 不能正常显示
|
|
79
|
-
*/
|
|
80
|
-
.header-logo {
|
|
81
|
-
position: absolute;
|
|
82
|
-
width: 0;
|
|
83
|
-
height: 0;
|
|
84
|
-
overflow: hidden;
|
|
85
|
-
}
|
|
74
|
+
${props => props.theme.breakpoints.down('sm')} {
|
|
86
75
|
.header-title {
|
|
87
76
|
display: none;
|
|
88
77
|
}
|
|
@@ -95,6 +84,15 @@ const StyledAppBar = styled(AppBar)`
|
|
|
95
84
|
}
|
|
96
85
|
`;
|
|
97
86
|
|
|
87
|
+
/*
|
|
88
|
+
自定义 logo 相关:
|
|
89
|
+
如果为 logo prop 传入一个自定义的 svg, 并且 svg 中的元素通过 id 引用了 defs 中的元素 (比如 linearGradient),
|
|
90
|
+
这种情况下因为 header 和 sidebar 中会各有一个相同的 svg, defs 中元素的 id 会出现冲突,
|
|
91
|
+
当屏幕较窄时, header 会通过设置 display:none 将 svg logo 隐藏,
|
|
92
|
+
这会导致 svg defs 中的元素不能被正常引用 (比如 fill 引用的 color 失效), 这会进一步导致 sidebar 中的 logo 不能正常显示.
|
|
93
|
+
考虑到上述问题, 目前使用 Hidden 组件控制 logo 的显示/隐藏
|
|
94
|
+
参考: https://blog.patw.me/archives/1820/inline-svg-same-id-and-display-none-issue/
|
|
95
|
+
*/
|
|
98
96
|
export default function Header({
|
|
99
97
|
children,
|
|
100
98
|
brand,
|
|
@@ -118,7 +116,9 @@ export default function Header({
|
|
|
118
116
|
<MenuIcon />
|
|
119
117
|
</Button>
|
|
120
118
|
<Link to={homeUrl} className="header-link">
|
|
121
|
-
<
|
|
119
|
+
<Hidden smDown>
|
|
120
|
+
<div className="header-logo">{logo || <Logo showText={false} />}</div>
|
|
121
|
+
</Hidden>
|
|
122
122
|
<div className="header-title">
|
|
123
123
|
<Typography component="h2" noWrap className="header-title__primary">
|
|
124
124
|
{brand}
|
|
@@ -64,11 +64,11 @@ export default function Dashboard({
|
|
|
64
64
|
}) {
|
|
65
65
|
const breakpoint = 960;
|
|
66
66
|
const { width } = useWindowSize();
|
|
67
|
-
const [drawerMode, setDrawerMode] = useState(width
|
|
67
|
+
const [drawerMode, setDrawerMode] = useState(width >= breakpoint ? 'permanent' : 'temporary');
|
|
68
68
|
const [drawerOpen, setDrawerOpen] = useState(drawerMode === 'permanent');
|
|
69
69
|
|
|
70
70
|
useEffect(() => {
|
|
71
|
-
const newMode = width
|
|
71
|
+
const newMode = width >= breakpoint ? 'permanent' : 'temporary';
|
|
72
72
|
setDrawerMode(newMode);
|
|
73
73
|
setDrawerOpen(newMode !== 'temporary');
|
|
74
74
|
}, [width]);
|
|
@@ -77,7 +77,7 @@ const MenuItems = React.memo(styled.div`
|
|
|
77
77
|
text-align: center;
|
|
78
78
|
font-size: 0;
|
|
79
79
|
}
|
|
80
|
-
|
|
80
|
+
${props => props.theme.breakpoints.down('sm')} {
|
|
81
81
|
&& .sidebar-logo {
|
|
82
82
|
display: block;
|
|
83
83
|
}
|
|
@@ -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};
|
package/src/Layout/index.js
CHANGED
|
@@ -264,7 +264,7 @@ const Div = styled.div`
|
|
|
264
264
|
}
|
|
265
265
|
}
|
|
266
266
|
|
|
267
|
-
|
|
267
|
+
${props => props.theme.breakpoints.up('md')} {
|
|
268
268
|
.toolbar {
|
|
269
269
|
.menu-button {
|
|
270
270
|
display: none;
|
|
@@ -278,7 +278,7 @@ const Div = styled.div`
|
|
|
278
278
|
}
|
|
279
279
|
}
|
|
280
280
|
|
|
281
|
-
|
|
281
|
+
${props => props.theme.breakpoints.down('sm')} {
|
|
282
282
|
.toolbar {
|
|
283
283
|
.nav-links,
|
|
284
284
|
.menu-logo,
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import QRCodeStyling from '@solana/qr-code-styling';
|
|
4
|
+
|
|
5
|
+
const defaults = {
|
|
6
|
+
margin: 0,
|
|
7
|
+
dotsOptions: {
|
|
8
|
+
type: 'dots',
|
|
9
|
+
},
|
|
10
|
+
cornersSquareOptions: {
|
|
11
|
+
type: 'extra-rounded',
|
|
12
|
+
},
|
|
13
|
+
cornersDotOptions: {
|
|
14
|
+
type: 'dot',
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
// 该组件用于生成与 android wallet 样式风格相似的 qrcode
|
|
19
|
+
// 注意: 依赖的 @solana/qr-code-styling 是一份 fork 版本, 原版本的 margin 配置存在 bug
|
|
20
|
+
function QRCode({ data, size, image, config, ...rest }) {
|
|
21
|
+
const ref = React.useRef(null);
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
const qrCode = new QRCodeStyling({
|
|
24
|
+
...defaults,
|
|
25
|
+
data,
|
|
26
|
+
width: size,
|
|
27
|
+
height: size,
|
|
28
|
+
...(image && {
|
|
29
|
+
image,
|
|
30
|
+
imageOptions: {
|
|
31
|
+
crossOrigin: 'anonymous',
|
|
32
|
+
margin: 0,
|
|
33
|
+
},
|
|
34
|
+
}),
|
|
35
|
+
...config,
|
|
36
|
+
});
|
|
37
|
+
qrCode.append(ref.current);
|
|
38
|
+
}, [data, size]);
|
|
39
|
+
return <div ref={ref} {...rest} />;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
QRCode.propTypes = {
|
|
43
|
+
// 一般情况下仅使用 data/size/image 即可
|
|
44
|
+
data: PropTypes.string.isRequired,
|
|
45
|
+
size: PropTypes.number.isRequired,
|
|
46
|
+
image: PropTypes.string,
|
|
47
|
+
// 覆盖 qr-code-styling 配置
|
|
48
|
+
config: PropTypes.object,
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
QRCode.defaultProps = {
|
|
52
|
+
image: null,
|
|
53
|
+
config: {},
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export default QRCode;
|