@arcblock/ux 1.16.1 → 1.16.5
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/Blocklet/index.js +17 -4
- package/lib/CodeBlock/index.js +3 -1
- package/package.json +6 -5
- package/src/ActionButton/index.js +65 -0
- package/src/ActivityIndicator/index.js +186 -0
- package/src/Alert/index.js +104 -0
- package/src/Async/index.js +39 -0
- package/src/Badge/index.js +71 -0
- package/src/Blocklet/index.js +348 -0
- package/src/Button/index.js +4 -0
- package/src/Button/wrap.js +88 -0
- package/src/ButtonGroup/index.js +19 -0
- package/src/Center/index.js +17 -0
- package/src/ClickToCopy/index.js +90 -0
- package/src/CodeBlock/index.js +160 -0
- package/src/Colors/index.js +1 -0
- package/src/Colors/themes/default.js +53 -0
- package/src/ContactForm/index.js +240 -0
- package/src/CookieConsent/index.js +90 -0
- package/src/CountDown/index.js +151 -0
- package/src/Dialog/confirm.js +76 -0
- package/src/Dialog/dialog.js +162 -0
- package/src/Dialog/index.js +2 -0
- package/src/DriftBot/index.js +81 -0
- package/src/Earth/countries.json +8057 -0
- package/src/Earth/index.js +511 -0
- package/src/Earth/util.js +69 -0
- package/src/Empty/index.js +41 -0
- package/src/Footer/index.js +84 -0
- package/src/Icon/image.js +55 -0
- package/src/Icon/index.js +69 -0
- package/src/Img/index.js +172 -0
- package/src/InfoRow/index.js +83 -0
- package/src/Layout/dashboard/header.js +145 -0
- package/src/Layout/dashboard/index.js +140 -0
- package/src/Layout/dashboard/sidebar.js +120 -0
- package/src/Layout/index.js +318 -0
- package/src/Locale/browser-lang.js +63 -0
- package/src/Locale/context.js +88 -0
- package/src/Locale/images/globe-dark.png +0 -0
- package/src/Locale/images/globe-light.png +0 -0
- package/src/Locale/selector.js +138 -0
- package/src/Logo/images/logo-dark-text.svg +3 -0
- package/src/Logo/images/logo-dark-top.svg +6 -0
- package/src/Logo/images/logo-light-text.svg +3 -0
- package/src/Logo/images/logo-light-top.svg +6 -0
- package/src/Logo/index.js +47 -0
- package/src/Metric/index.js +115 -0
- package/src/NFTDisplay/README.md +59 -0
- package/src/NFTDisplay/aspect-ratio-container.js +34 -0
- package/src/NFTDisplay/broken.js +18 -0
- package/src/NFTDisplay/index.js +230 -0
- package/src/NFTDisplay/loading.js +17 -0
- package/src/NFTDisplay/svg-embedder/img.js +36 -0
- package/src/NFTDisplay/svg-embedder/inline-svg.js +37 -0
- package/src/PageScroller/index.js +342 -0
- package/src/PageScroller/usePrevValue.js +12 -0
- package/src/PricingTable/PricingPlan.js +112 -0
- package/src/PricingTable/index.js +43 -0
- package/src/Screenshot/devices.css +1366 -0
- package/src/Screenshot/index.js +181 -0
- package/src/Spinner/index.js +33 -0
- package/src/Switch/index.js +78 -0
- package/src/Tabs/index.js +46 -0
- package/src/Tag/index.js +73 -0
- package/src/Terminal/Player.js +364 -0
- package/src/Terminal/index.js +150 -0
- package/src/Terminal/player.css +378 -0
- package/src/Terminal/util.js +167 -0
- package/src/Terminal/xterm.css +171 -0
- package/src/TextCollapse/index.js +92 -0
- package/src/Theme/index.js +169 -0
- package/src/Theme/responsiveFontSizes.js +94 -0
- package/src/Toast/index.js +118 -0
- package/src/Util/index.js +264 -0
- package/src/Video/index.js +72 -0
- package/src/Wallet/Action.js +105 -0
- package/src/Wallet/Download.js +130 -0
- package/src/Wallet/Open.js +50 -0
- package/src/Wallet/images/abtwallet.png +0 -0
- package/src/Wallet/images/android_download.svg +23 -0
- package/src/Wallet/images/app-store.svg +20 -0
- package/src/Wallet/images/google-play.svg +70 -0
- package/src/WechatPrompt/images/android.png +0 -0
- package/src/WechatPrompt/images/ios.png +0 -0
- package/src/WechatPrompt/index.js +81 -0
- package/src/index.js +63 -0
- package/src/withTheme/index.js +72 -0
- package/src/withTracker/README.md +34 -0
- package/src/withTracker/error_boundary.js +34 -0
- package/src/withTracker/index.js +70 -0
package/lib/Blocklet/index.js
CHANGED
|
@@ -21,13 +21,15 @@ var _useMediaQuery = _interopRequireDefault(require("@material-ui/core/useMediaQ
|
|
|
21
21
|
|
|
22
22
|
var _useTheme = _interopRequireDefault(require("@material-ui/core/styles/useTheme"));
|
|
23
23
|
|
|
24
|
+
var _Avatar = _interopRequireDefault(require("@arcblock/did-connect/lib/Avatar"));
|
|
25
|
+
|
|
24
26
|
var _Icon = _interopRequireDefault(require("../Icon"));
|
|
25
27
|
|
|
26
28
|
var _Button = _interopRequireDefault(require("../Button"));
|
|
27
29
|
|
|
28
30
|
var _Img = _interopRequireDefault(require("../Img"));
|
|
29
31
|
|
|
30
|
-
const _excluded = ["title", "description", "cover", "type", "size", "addons", "button", "buttonText", "buttonDisabled", "buttonLoading", "isStickyButton", "onButtonClick", "onMainClick", "onTagClick", "className", "scaleClickZone"];
|
|
32
|
+
const _excluded = ["title", "did", "description", "cover", "type", "size", "addons", "button", "buttonText", "buttonDisabled", "buttonLoading", "isStickyButton", "onButtonClick", "onMainClick", "onTagClick", "className", "scaleClickZone"];
|
|
31
33
|
|
|
32
34
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
33
35
|
|
|
@@ -78,6 +80,7 @@ function prettySize(_size) {
|
|
|
78
80
|
function Blocklet(_ref2) {
|
|
79
81
|
let {
|
|
80
82
|
title,
|
|
83
|
+
did,
|
|
81
84
|
description,
|
|
82
85
|
cover,
|
|
83
86
|
type,
|
|
@@ -128,10 +131,13 @@ function Blocklet(_ref2) {
|
|
|
128
131
|
|
|
129
132
|
const theme = (0, _useTheme.default)();
|
|
130
133
|
const isDownSm = (0, _useMediaQuery.default)(theme.breakpoints.down('sm'));
|
|
131
|
-
const isDownMd = (0, _useMediaQuery.default)(theme.breakpoints.down('md'));
|
|
134
|
+
const isDownMd = (0, _useMediaQuery.default)(theme.breakpoints.down('md'));
|
|
135
|
+
const isUPLg = (0, _useMediaQuery.default)(theme.breakpoints.up('lg')); // If size is auto, need calculate actual size according to screen size
|
|
132
136
|
// eslint-disable-next-line no-nested-ternary
|
|
133
137
|
|
|
134
|
-
const actualSize = size === 'auto' ? isDownSm ? 'xs' : isDownMd ? 'sm' : 'md' : size;
|
|
138
|
+
const actualSize = size === 'auto' ? isDownSm ? 'xs' : isDownMd ? 'sm' : 'md' : size; // eslint-disable-next-line no-nested-ternary
|
|
139
|
+
|
|
140
|
+
const didAvatarSize = size === 'auto' ? isUPLg ? 100 : 48 : size === 'md' ? 100 : 48;
|
|
135
141
|
const container = (0, _react.useRef)(null);
|
|
136
142
|
return /*#__PURE__*/_react.default.createElement(Div, Object.assign({}, rest, {
|
|
137
143
|
scaleClickZone: scaleClickZone,
|
|
@@ -144,10 +150,15 @@ function Blocklet(_ref2) {
|
|
|
144
150
|
ref: container
|
|
145
151
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
146
152
|
className: "arcblock-blocklet__content--body"
|
|
147
|
-
}, cover
|
|
153
|
+
}, cover ? /*#__PURE__*/_react.default.createElement("div", {
|
|
148
154
|
className: "arcblock-blocklet__cover"
|
|
149
155
|
}, /*#__PURE__*/_react.default.createElement(_Img.default, {
|
|
150
156
|
src: cover
|
|
157
|
+
})) : did && /*#__PURE__*/_react.default.createElement("div", {
|
|
158
|
+
className: "arcblock-blocklet__cover"
|
|
159
|
+
}, /*#__PURE__*/_react.default.createElement(_Avatar.default, {
|
|
160
|
+
did: did,
|
|
161
|
+
size: didAvatarSize
|
|
151
162
|
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
152
163
|
className: "arcblock-blocklet__info"
|
|
153
164
|
}, /*#__PURE__*/_react.default.createElement(_Typography.default, {
|
|
@@ -205,6 +216,7 @@ function Blocklet(_ref2) {
|
|
|
205
216
|
|
|
206
217
|
Blocklet.propTypes = {
|
|
207
218
|
title: _propTypes.default.string.isRequired,
|
|
219
|
+
did: _propTypes.default.string,
|
|
208
220
|
isStickyButton: _propTypes.default.bool,
|
|
209
221
|
description: _propTypes.default.string,
|
|
210
222
|
cover: _propTypes.default.string,
|
|
@@ -224,6 +236,7 @@ Blocklet.propTypes = {
|
|
|
224
236
|
Blocklet.defaultProps = {
|
|
225
237
|
description: null,
|
|
226
238
|
cover: null,
|
|
239
|
+
did: null,
|
|
227
240
|
isStickyButton: false,
|
|
228
241
|
buttonText: 'Install',
|
|
229
242
|
buttonDisabled: false,
|
package/lib/CodeBlock/index.js
CHANGED
|
@@ -51,6 +51,8 @@ var _FileCopy = _interopRequireDefault(require("@material-ui/icons/FileCopy"));
|
|
|
51
51
|
|
|
52
52
|
var _Check = _interopRequireDefault(require("@material-ui/icons/Check"));
|
|
53
53
|
|
|
54
|
+
var _Colors = _interopRequireDefault(require("../Colors"));
|
|
55
|
+
|
|
54
56
|
const _excluded = ["code", "language", "children"];
|
|
55
57
|
|
|
56
58
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -171,4 +173,4 @@ const fontFamily = 'source-code-pro, Menlo, Monaco, Consolas, Courier New, monos
|
|
|
171
173
|
const Pre = _styledComponents.default.pre.withConfig({
|
|
172
174
|
displayName: "CodeBlock__Pre",
|
|
173
175
|
componentId: "sc-1bpapaq-0"
|
|
174
|
-
})(["font-family:", ";display:block;font-size:14px;line-height:1.42857143;margin:0 0 32px;word-break:break-word;word-wrap:break-word;text-align:left;border-radius:5px;border:1px solid #dedede;background:#222;color:#fff;position:relative;.codeblock__inner{display:block;width:100%;max-height:46.25rem;overflow:scroll;}.copy-button{display:none;position:absolute;top:8px;right:24px;}&:hover{.copy-button{display:block;}}code{counter-reset:line;counter-increment:line;padding:16px;font-family:", ";color:#fff;*{font-family:", ";}}.hljs *{white-space:normal;}"], fontFamily, fontFamily, fontFamily);
|
|
176
|
+
})(["font-family:", ";display:block;font-size:14px;line-height:1.42857143;margin:0 0 32px;word-break:break-word;word-wrap:break-word;text-align:left;border-radius:5px;border:1px solid #dedede;background:#222;color:#fff;position:relative;.codeblock__inner{display:block;width:100%;max-height:46.25rem;overflow:scroll;}.copy-button{display:none;position:absolute;top:8px;right:24px;padding:4px;border-radius:4px;&,&:hover,&.Mui-disabled{background:", ";}}&:hover{.copy-button{display:block;}}code{counter-reset:line;counter-increment:line;padding:16px;font-family:", ";color:#fff;*{font-family:", ";}}.hljs *{white-space:normal;}"], fontFamily, _Colors.default.primary.main, fontFamily, fontFamily);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcblock/ux",
|
|
3
|
-
"version": "1.16.
|
|
3
|
+
"version": "1.16.5",
|
|
4
4
|
"description": "Common used react components for arcblock products",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
"license": "Apache-2.0",
|
|
13
13
|
"main": "lib/index.js",
|
|
14
14
|
"files": [
|
|
15
|
-
"lib"
|
|
15
|
+
"lib",
|
|
16
|
+
"src"
|
|
16
17
|
],
|
|
17
18
|
"repository": {
|
|
18
19
|
"type": "git",
|
|
@@ -52,10 +53,10 @@
|
|
|
52
53
|
"react": ">=16.12.0",
|
|
53
54
|
"react-ga": "^2.7.0"
|
|
54
55
|
},
|
|
55
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "15f756e061f6cf2f8bbaea06ffaed0bff3b3ed33",
|
|
56
57
|
"dependencies": {
|
|
57
|
-
"@arcblock/icons": "^1.16.
|
|
58
|
-
"@arcblock/react-hooks": "^1.16.
|
|
58
|
+
"@arcblock/icons": "^1.16.5",
|
|
59
|
+
"@arcblock/react-hooks": "^1.16.5",
|
|
59
60
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
60
61
|
"@material-ui/core": "^4.12.3",
|
|
61
62
|
"@material-ui/icons": "4.11.2",
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
|
|
4
|
+
import Button from '../Button';
|
|
5
|
+
import { mergeProps } from '../Util';
|
|
6
|
+
|
|
7
|
+
const ActionButton = props => {
|
|
8
|
+
const newProps = mergeProps(props, ActionButton);
|
|
9
|
+
const { href, icon, size, color, theme, variant, gradient, children, text, ...rest } = newProps;
|
|
10
|
+
const styles = {};
|
|
11
|
+
if (gradient) {
|
|
12
|
+
styles.backgroundImage = gradient;
|
|
13
|
+
styles.borderColor = 'transparent';
|
|
14
|
+
}
|
|
15
|
+
const attrs = ['color', 'border', 'width'];
|
|
16
|
+
attrs.forEach(x => {
|
|
17
|
+
if (newProps[x]) {
|
|
18
|
+
styles[x] = newProps[x];
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<Button
|
|
24
|
+
color={theme}
|
|
25
|
+
href={href}
|
|
26
|
+
target="_blank"
|
|
27
|
+
variant={variant}
|
|
28
|
+
style={styles}
|
|
29
|
+
size={size}
|
|
30
|
+
className="action-button"
|
|
31
|
+
{...rest}>
|
|
32
|
+
{!!icon && <i className={icon} />}
|
|
33
|
+
{text || children}
|
|
34
|
+
</Button>
|
|
35
|
+
);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
ActionButton.propTypes = {
|
|
39
|
+
href: PropTypes.string.isRequired,
|
|
40
|
+
children: PropTypes.any,
|
|
41
|
+
gradient: PropTypes.string,
|
|
42
|
+
color: PropTypes.string,
|
|
43
|
+
icon: PropTypes.string,
|
|
44
|
+
border: PropTypes.string,
|
|
45
|
+
text: PropTypes.string,
|
|
46
|
+
theme: PropTypes.string,
|
|
47
|
+
variant: PropTypes.string,
|
|
48
|
+
size: PropTypes.string,
|
|
49
|
+
width: PropTypes.string,
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
ActionButton.defaultProps = {
|
|
53
|
+
gradient: '',
|
|
54
|
+
icon: '',
|
|
55
|
+
text: '',
|
|
56
|
+
color: '',
|
|
57
|
+
border: '',
|
|
58
|
+
width: '',
|
|
59
|
+
theme: 'default',
|
|
60
|
+
variant: 'outlined',
|
|
61
|
+
size: 'large',
|
|
62
|
+
children: null,
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export default ActionButton;
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
import green from '@material-ui/core/colors/green';
|
|
5
|
+
import blue from '@material-ui/core/colors/blue';
|
|
6
|
+
|
|
7
|
+
import Logo from '../Logo';
|
|
8
|
+
import colors from '../Colors';
|
|
9
|
+
|
|
10
|
+
// inspired by: https://codepen.io/wangshijun/pen/oQvwdX?editors=1100
|
|
11
|
+
export default function ActivityIndicator({ messages, interval, ...rest }) {
|
|
12
|
+
const [index, setIndex] = useState(0);
|
|
13
|
+
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
const timer = setInterval(() => {
|
|
16
|
+
setIndex((index + 1) % messages.length);
|
|
17
|
+
}, interval);
|
|
18
|
+
|
|
19
|
+
return () => {
|
|
20
|
+
clearTimeout(timer);
|
|
21
|
+
};
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<Div {...rest}>
|
|
26
|
+
<div className="pm-loader-container">
|
|
27
|
+
<div className="pm-loader-text">
|
|
28
|
+
<p>{messages[index]}</p>
|
|
29
|
+
</div>
|
|
30
|
+
<div className="pm-loader-atoms">
|
|
31
|
+
<Logo style={{ transform: 'scale(0.6)' }} showText={false} />
|
|
32
|
+
<div className="pm-loader-orbit-1">
|
|
33
|
+
<div className="pm-loader-atom-1" />
|
|
34
|
+
</div>
|
|
35
|
+
<div className="pm-loader-orbit-2">
|
|
36
|
+
<div className="pm-loader-atom-2" />
|
|
37
|
+
</div>
|
|
38
|
+
<div className="pm-loader-orbit-3">
|
|
39
|
+
<div className="pm-loader-atom-3" />
|
|
40
|
+
</div>
|
|
41
|
+
</div>
|
|
42
|
+
</div>
|
|
43
|
+
</Div>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
ActivityIndicator.propTypes = {
|
|
48
|
+
interval: PropTypes.number,
|
|
49
|
+
messages: PropTypes.arrayOf(PropTypes.string.isRequired),
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
ActivityIndicator.defaultProps = {
|
|
53
|
+
interval: 3000,
|
|
54
|
+
messages: ['Loading data...'],
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const Div = styled.div`
|
|
58
|
+
&& {
|
|
59
|
+
padding: 20px;
|
|
60
|
+
width: 100%;
|
|
61
|
+
height: 100%;
|
|
62
|
+
min-height: 360px;
|
|
63
|
+
z-index: 100;
|
|
64
|
+
transition: opacity 0.5s linear;
|
|
65
|
+
display: flex;
|
|
66
|
+
align-items: center;
|
|
67
|
+
flex-direction: column;
|
|
68
|
+
justify-content: center;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
@keyframes orbit {
|
|
72
|
+
0% {
|
|
73
|
+
transform: rotate(0deg);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
100% {
|
|
77
|
+
transform: rotate(360deg);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.pm-loader-text {
|
|
82
|
+
color: ${colors.grey[900]};
|
|
83
|
+
font-size: 14px;
|
|
84
|
+
text-align: center;
|
|
85
|
+
position: relative;
|
|
86
|
+
height: 70px;
|
|
87
|
+
-webkit-user-select: none;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.pm-loader-container {
|
|
91
|
+
width: 100%;
|
|
92
|
+
height: 100%;
|
|
93
|
+
display: flex;
|
|
94
|
+
align-items: center;
|
|
95
|
+
flex-direction: column;
|
|
96
|
+
justify-content: center;
|
|
97
|
+
flex: 1;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.pm-loader-atoms {
|
|
101
|
+
width: 100px;
|
|
102
|
+
height: 100px;
|
|
103
|
+
display: flex;
|
|
104
|
+
position: relative;
|
|
105
|
+
align-items: center;
|
|
106
|
+
justify-content: center;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.pm-loader-center-atom {
|
|
110
|
+
top: 32px;
|
|
111
|
+
left: 32px;
|
|
112
|
+
width: 32px;
|
|
113
|
+
height: 32px;
|
|
114
|
+
position: absolute;
|
|
115
|
+
border-radius: 50%;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.pm-loader-orbit-1 {
|
|
119
|
+
top: 20px;
|
|
120
|
+
left: 20px;
|
|
121
|
+
width: 56px;
|
|
122
|
+
height: 56px;
|
|
123
|
+
position: absolute;
|
|
124
|
+
border-radius: 50%;
|
|
125
|
+
border: 1px solid ${green[500]};
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.pm-loader-orbit-2 {
|
|
129
|
+
top: 8px;
|
|
130
|
+
left: 8px;
|
|
131
|
+
width: 80px;
|
|
132
|
+
height: 80px;
|
|
133
|
+
border-radius: 50%;
|
|
134
|
+
position: absolute;
|
|
135
|
+
border: 1px solid ${blue[800]};
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.pm-loader-orbit-3 {
|
|
139
|
+
top: -4px;
|
|
140
|
+
left: -4px;
|
|
141
|
+
width: 104px;
|
|
142
|
+
height: 104px;
|
|
143
|
+
position: absolute;
|
|
144
|
+
border-radius: 50%;
|
|
145
|
+
border: 1px solid ${colors.grey[900]};
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.pm-loader-atom-1 {
|
|
149
|
+
width: 7px;
|
|
150
|
+
height: 7px;
|
|
151
|
+
margin-top: 4px;
|
|
152
|
+
margin-left: 4px;
|
|
153
|
+
border-radius: 50%;
|
|
154
|
+
background-color: ${green[500]};
|
|
155
|
+
transform-origin: 24px 24px;
|
|
156
|
+
animation: orbit 1s infinite;
|
|
157
|
+
animation-timing-function: linear;
|
|
158
|
+
-webkit-transform-origin: 24px 24px;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.pm-loader-atom-2 {
|
|
162
|
+
width: 7px;
|
|
163
|
+
height: 7px;
|
|
164
|
+
margin-top: 8px;
|
|
165
|
+
margin-left: 8px;
|
|
166
|
+
border-radius: 50%;
|
|
167
|
+
background-color: ${blue[800]};
|
|
168
|
+
transform-origin: 32px 32px;
|
|
169
|
+
animation: orbit 2s infinite;
|
|
170
|
+
animation-timing-function: linear;
|
|
171
|
+
-webkit-transform-origin: 32px 32px;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
.pm-loader-atom-3 {
|
|
175
|
+
width: 7px;
|
|
176
|
+
height: 7px;
|
|
177
|
+
margin-top: 11px;
|
|
178
|
+
margin-left: 11px;
|
|
179
|
+
border-radius: 50%;
|
|
180
|
+
background-color: ${colors.grey[900]};
|
|
181
|
+
transform-origin: 41px 41px;
|
|
182
|
+
animation: orbit 3s infinite;
|
|
183
|
+
animation-timing-function: linear;
|
|
184
|
+
-webkit-transform-origin: 41px 41px;
|
|
185
|
+
}
|
|
186
|
+
`;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
import Typography from '@material-ui/core/Typography';
|
|
5
|
+
import blueGrey from '@material-ui/core/colors/blueGrey';
|
|
6
|
+
|
|
7
|
+
import Icon from '../Icon';
|
|
8
|
+
import { mergeProps } from '../Util';
|
|
9
|
+
import colors from '../Colors';
|
|
10
|
+
|
|
11
|
+
const types = {
|
|
12
|
+
error: {
|
|
13
|
+
icon: 'exclamation-circle',
|
|
14
|
+
color: colors.error.main,
|
|
15
|
+
borderColor: '#e35b54',
|
|
16
|
+
backgroundColor: 'rgba(227, 91, 84, 0.2)',
|
|
17
|
+
},
|
|
18
|
+
warning: {
|
|
19
|
+
icon: 'exclamation-triangle',
|
|
20
|
+
color: colors.warning.main,
|
|
21
|
+
borderColor: '#f7d040',
|
|
22
|
+
backgroundColor: 'rgba(247, 208, 64, 0.2)',
|
|
23
|
+
},
|
|
24
|
+
success: {
|
|
25
|
+
icon: 'check-circle',
|
|
26
|
+
color: colors.success.main,
|
|
27
|
+
borderColor: '#89ddd9',
|
|
28
|
+
backgroundColor: 'rgba(137, 221, 217, 0.2)',
|
|
29
|
+
},
|
|
30
|
+
tip: {
|
|
31
|
+
icon: 'info-circle',
|
|
32
|
+
color: colors.grey[500],
|
|
33
|
+
borderColor: '#222222',
|
|
34
|
+
backgroundColor: '#EEEEEE',
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const Alert = props => {
|
|
39
|
+
const newProps = mergeProps(props, Alert, ['style']);
|
|
40
|
+
const { type, children, style, className, variant, ...rest } = newProps;
|
|
41
|
+
const { icon, color, backgroundColor, borderColor } = types[type] || types.success;
|
|
42
|
+
const styles = Object.assign(
|
|
43
|
+
{
|
|
44
|
+
color: blueGrey[500],
|
|
45
|
+
backgroundColor: variant === 'border' ? backgroundColor : 'transparent',
|
|
46
|
+
borderLeft: variant === 'border' ? `5px solid ${borderColor}` : 'none',
|
|
47
|
+
},
|
|
48
|
+
style
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<Container
|
|
53
|
+
{...rest}
|
|
54
|
+
className={`alert alert--${type} alert--${variant} ${className}`.trim()}
|
|
55
|
+
style={styles}>
|
|
56
|
+
{variant === 'icon' && (
|
|
57
|
+
<Icon className="alert-icon" name={icon} size={24} style={{ color }} />
|
|
58
|
+
)}
|
|
59
|
+
<Typography component="div" className="alert-content">
|
|
60
|
+
{children}
|
|
61
|
+
</Typography>
|
|
62
|
+
</Container>
|
|
63
|
+
);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
Alert.propTypes = {
|
|
67
|
+
type: PropTypes.oneOf(Object.keys(types)),
|
|
68
|
+
children: PropTypes.any.isRequired,
|
|
69
|
+
className: PropTypes.string,
|
|
70
|
+
style: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
|
|
71
|
+
variant: PropTypes.oneOf(['border', 'icon']),
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
Alert.defaultProps = {
|
|
75
|
+
type: 'tip',
|
|
76
|
+
className: '',
|
|
77
|
+
style: '{}',
|
|
78
|
+
variant: 'border',
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export default Alert;
|
|
82
|
+
|
|
83
|
+
const Container = styled.div`
|
|
84
|
+
display: flex;
|
|
85
|
+
align-items: center;
|
|
86
|
+
font-size: 16px;
|
|
87
|
+
margin: 0;
|
|
88
|
+
padding: 16px;
|
|
89
|
+
margin: 16px 0;
|
|
90
|
+
|
|
91
|
+
strong {
|
|
92
|
+
margin: 0 5px;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.alert-icon {
|
|
96
|
+
margin-right: 16px;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.alert-content {
|
|
100
|
+
flex: 1;
|
|
101
|
+
display: flex;
|
|
102
|
+
flex-direction: column;
|
|
103
|
+
}
|
|
104
|
+
`;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import CircularProgress from '@material-ui/core/CircularProgress';
|
|
4
|
+
|
|
5
|
+
export default function LoadAsyncComponent(importComponent, key = 'default', showProgress = true) {
|
|
6
|
+
class AsyncComponent extends React.Component {
|
|
7
|
+
constructor(props) {
|
|
8
|
+
super(props);
|
|
9
|
+
|
|
10
|
+
this.state = {
|
|
11
|
+
Component: null,
|
|
12
|
+
error: null,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
componentDidMount() {
|
|
17
|
+
importComponent()
|
|
18
|
+
.then(asyncModule => this.setState({ Component: asyncModule[key] }))
|
|
19
|
+
.catch(err => this.setState({ error: `Failed to load async component: ${err.message}` }));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
render() {
|
|
23
|
+
const { Component, error } = this.state;
|
|
24
|
+
|
|
25
|
+
if (error) {
|
|
26
|
+
return error;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// eslint-disable-next-line no-nested-ternary
|
|
30
|
+
return Component ? (
|
|
31
|
+
<Component {...this.props} />
|
|
32
|
+
) : showProgress ? (
|
|
33
|
+
<CircularProgress color="primary" />
|
|
34
|
+
) : null;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return AsyncComponent;
|
|
39
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
|
|
5
|
+
import Typography from '@material-ui/core/Typography';
|
|
6
|
+
|
|
7
|
+
import colors from '../Colors';
|
|
8
|
+
import { mergeProps } from '../Util';
|
|
9
|
+
|
|
10
|
+
const types = {
|
|
11
|
+
error: {
|
|
12
|
+
color: colors.common.white,
|
|
13
|
+
backgroundColor: colors.error.main,
|
|
14
|
+
},
|
|
15
|
+
warning: {
|
|
16
|
+
color: colors.common.white,
|
|
17
|
+
backgroundColor: colors.warning.main,
|
|
18
|
+
},
|
|
19
|
+
success: {
|
|
20
|
+
color: colors.common.white,
|
|
21
|
+
backgroundColor: colors.success.main,
|
|
22
|
+
},
|
|
23
|
+
primary: {
|
|
24
|
+
color: colors.common.white,
|
|
25
|
+
backgroundColor: colors.primary.main,
|
|
26
|
+
},
|
|
27
|
+
reverse: {
|
|
28
|
+
color: colors.common.white,
|
|
29
|
+
backgroundColor: colors.grey[900],
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
function Badge(props) {
|
|
34
|
+
const newProps = mergeProps(props, Badge, ['style']);
|
|
35
|
+
const { type, content, children, style, className, forwardedRef, ...rest } = newProps;
|
|
36
|
+
const styles = Object.assign(types[type] || types.primary, style);
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<Span ref={forwardedRef} component="span" className={className} style={styles} {...rest}>
|
|
40
|
+
{content || children}
|
|
41
|
+
</Span>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
Badge.propTypes = {
|
|
46
|
+
children: PropTypes.any.isRequired,
|
|
47
|
+
content: PropTypes.string,
|
|
48
|
+
type: PropTypes.oneOf(Object.keys(types)),
|
|
49
|
+
className: PropTypes.string,
|
|
50
|
+
style: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
Badge.defaultProps = {
|
|
54
|
+
type: 'primary',
|
|
55
|
+
content: '',
|
|
56
|
+
className: '',
|
|
57
|
+
style: '{}',
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export default React.forwardRef((props, ref) => <Badge {...props} forwardedRef={ref} />);
|
|
61
|
+
|
|
62
|
+
const Span = styled(Typography)`
|
|
63
|
+
&& {
|
|
64
|
+
display: inline-flex;
|
|
65
|
+
justify-content: center;
|
|
66
|
+
align-items: center;
|
|
67
|
+
padding: 2px 10px;
|
|
68
|
+
height: 24px;
|
|
69
|
+
line-height: 24px;
|
|
70
|
+
}
|
|
71
|
+
`;
|