@arcblock/ux 0.78.25 → 1.6.59

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.
Files changed (172) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +0 -56
  3. package/lib/ActionButton/index.js +6 -4
  4. package/lib/ActivityIndicator/index.js +75 -23
  5. package/lib/Alert/index.js +15 -11
  6. package/lib/Async/index.js +1 -1
  7. package/lib/Badge/index.js +17 -15
  8. package/lib/Blocklet/index.js +261 -0
  9. package/lib/Button/wrap.js +96 -43
  10. package/lib/ButtonGroup/index.js +3 -16
  11. package/lib/Center/index.js +30 -4
  12. package/lib/ClickToCopy/index.js +10 -8
  13. package/lib/CodeBlock/index.js +40 -13
  14. package/lib/Colors/index.js +15 -0
  15. package/lib/Colors/themes/default.js +85 -0
  16. package/lib/ContactForm/index.js +9 -10
  17. package/lib/CookieConsent/index.js +98 -0
  18. package/lib/CountDown/index.js +18 -14
  19. package/lib/Dialog/confirm.js +84 -0
  20. package/lib/Dialog/dialog.js +137 -0
  21. package/lib/Dialog/index.js +23 -0
  22. package/lib/Earth/index.js +33 -33
  23. package/lib/Empty/index.js +61 -0
  24. package/lib/Footer/index.js +16 -18
  25. package/lib/Icon/image.js +10 -13
  26. package/lib/Icon/index.js +10 -8
  27. package/lib/Img/index.js +212 -0
  28. package/lib/InfoRow/index.js +7 -6
  29. package/lib/Layout/dashboard/header.js +60 -42
  30. package/lib/Layout/dashboard/index.js +72 -60
  31. package/lib/Layout/dashboard/sidebar.js +41 -25
  32. package/lib/Layout/index.js +113 -51
  33. package/lib/Locale/browser-lang.js +0 -2
  34. package/lib/Locale/context.js +85 -61
  35. package/lib/Locale/selector.js +33 -20
  36. package/lib/Logo/index.js +15 -13
  37. package/lib/Metric/index.js +5 -6
  38. package/lib/NFTDisplay/README.md +59 -0
  39. package/lib/NFTDisplay/aspect-ratio-container.js +52 -0
  40. package/lib/NFTDisplay/broken.js +25 -0
  41. package/lib/NFTDisplay/index.js +317 -0
  42. package/lib/NFTDisplay/loading.js +23 -0
  43. package/lib/NFTDisplay/svg-embedder/img.js +68 -0
  44. package/lib/NFTDisplay/svg-embedder/inline-svg.js +54 -0
  45. package/lib/PageScroller/index.js +10 -11
  46. package/lib/PageScroller/usePrevValue.js +2 -2
  47. package/lib/PricingTable/PricingPlan.js +12 -15
  48. package/lib/PricingTable/index.js +5 -5
  49. package/lib/Result/common.js +176 -0
  50. package/lib/Result/index.js +61 -0
  51. package/lib/Result/result.js +69 -0
  52. package/lib/Result/translations.js +61 -0
  53. package/lib/Screenshot/index.js +14 -13
  54. package/lib/Spinner/index.js +37 -0
  55. package/lib/SplitButton/index.js +126 -0
  56. package/lib/Switch/index.js +107 -0
  57. package/lib/Tabs/index.js +24 -47
  58. package/lib/Tag/index.js +15 -13
  59. package/lib/Terminal/Player.js +43 -45
  60. package/lib/Terminal/index.js +3 -1
  61. package/lib/Terminal/util.js +2 -3
  62. package/lib/TextCollapse/index.js +21 -14
  63. package/lib/Theme/index.js +79 -63
  64. package/lib/Theme/responsiveFontSizes.js +8 -8
  65. package/lib/Toast/index.js +12 -11
  66. package/lib/Util/index.js +197 -26
  67. package/lib/Video/index.js +8 -11
  68. package/lib/Wallet/Action.js +15 -13
  69. package/lib/Wallet/Download.js +60 -58
  70. package/lib/Wallet/Open.js +2 -2
  71. package/lib/WechatPrompt/index.js +10 -10
  72. package/lib/index.js +6 -6
  73. package/lib/withTheme/index.js +5 -17
  74. package/lib/withTracker/error_boundary.js +3 -3
  75. package/lib/withTracker/index.js +6 -7
  76. package/package.json +22 -17
  77. package/src/ActionButton/index.js +65 -0
  78. package/src/ActivityIndicator/index.js +141 -0
  79. package/src/Alert/index.js +104 -0
  80. package/src/Async/index.js +39 -0
  81. package/src/Badge/index.js +71 -0
  82. package/src/Blocklet/index.js +424 -0
  83. package/src/Button/index.js +4 -0
  84. package/src/Button/wrap.js +101 -0
  85. package/src/ButtonGroup/index.js +6 -0
  86. package/src/Center/index.js +40 -0
  87. package/src/ClickToCopy/index.js +90 -0
  88. package/src/CodeBlock/index.js +160 -0
  89. package/src/Colors/index.js +1 -0
  90. package/src/Colors/themes/default.js +54 -0
  91. package/src/ContactForm/index.js +240 -0
  92. package/src/CookieConsent/index.js +90 -0
  93. package/src/CountDown/index.js +151 -0
  94. package/src/Dialog/confirm.js +76 -0
  95. package/src/Dialog/dialog.js +162 -0
  96. package/src/Dialog/index.js +2 -0
  97. package/src/DriftBot/index.js +81 -0
  98. package/src/Earth/countries.json +8057 -0
  99. package/src/Earth/index.js +511 -0
  100. package/src/Earth/util.js +69 -0
  101. package/src/Empty/index.js +41 -0
  102. package/src/Footer/index.js +110 -0
  103. package/src/Icon/image.js +55 -0
  104. package/src/Icon/index.js +69 -0
  105. package/src/Img/index.js +172 -0
  106. package/src/InfoRow/index.js +83 -0
  107. package/src/Layout/dashboard/header.js +157 -0
  108. package/src/Layout/dashboard/index.js +150 -0
  109. package/src/Layout/dashboard/sidebar.js +122 -0
  110. package/src/Layout/index.js +318 -0
  111. package/src/Locale/browser-lang.js +63 -0
  112. package/src/Locale/context.js +94 -0
  113. package/src/Locale/images/globe-dark.png +0 -0
  114. package/src/Locale/images/globe-light.png +0 -0
  115. package/src/Locale/selector.js +135 -0
  116. package/src/Logo/images/logo-dark-text.svg +3 -0
  117. package/src/Logo/images/logo-dark-top.svg +6 -0
  118. package/src/Logo/images/logo-light-text.svg +3 -0
  119. package/src/Logo/images/logo-light-top.svg +6 -0
  120. package/src/Logo/index.js +47 -0
  121. package/src/Metric/index.js +115 -0
  122. package/src/NFTDisplay/README.md +59 -0
  123. package/src/NFTDisplay/aspect-ratio-container.js +34 -0
  124. package/src/NFTDisplay/broken.js +18 -0
  125. package/src/NFTDisplay/index.js +257 -0
  126. package/src/NFTDisplay/loading.js +17 -0
  127. package/src/NFTDisplay/svg-embedder/img.js +36 -0
  128. package/src/NFTDisplay/svg-embedder/inline-svg.js +37 -0
  129. package/src/PageScroller/index.js +342 -0
  130. package/src/PageScroller/usePrevValue.js +12 -0
  131. package/src/PricingTable/PricingPlan.js +112 -0
  132. package/src/PricingTable/index.js +43 -0
  133. package/src/Result/common.js +116 -0
  134. package/src/Result/index.js +31 -0
  135. package/src/Result/result.js +57 -0
  136. package/src/Result/translations.js +56 -0
  137. package/src/Screenshot/devices.css +1366 -0
  138. package/src/Screenshot/index.js +181 -0
  139. package/src/Spinner/index.js +19 -0
  140. package/src/SplitButton/index.js +112 -0
  141. package/src/Switch/index.js +78 -0
  142. package/src/Tabs/index.js +46 -0
  143. package/src/Tag/index.js +73 -0
  144. package/src/Terminal/Player.js +364 -0
  145. package/src/Terminal/index.js +150 -0
  146. package/src/Terminal/player.css +378 -0
  147. package/src/Terminal/util.js +167 -0
  148. package/src/Terminal/xterm.css +171 -0
  149. package/src/TextCollapse/index.js +92 -0
  150. package/src/Theme/index.js +184 -0
  151. package/src/Theme/responsiveFontSizes.js +94 -0
  152. package/src/Toast/index.js +118 -0
  153. package/src/Util/index.js +281 -0
  154. package/src/Video/index.js +72 -0
  155. package/src/Wallet/Action.js +105 -0
  156. package/src/Wallet/Download.js +130 -0
  157. package/src/Wallet/Open.js +50 -0
  158. package/src/Wallet/images/abtwallet.png +0 -0
  159. package/src/Wallet/images/android_download.svg +23 -0
  160. package/src/Wallet/images/app-store.svg +20 -0
  161. package/src/Wallet/images/google-play.svg +70 -0
  162. package/src/WechatPrompt/images/android.png +0 -0
  163. package/src/WechatPrompt/images/ios.png +0 -0
  164. package/src/WechatPrompt/index.js +81 -0
  165. package/src/index.js +63 -0
  166. package/src/withTheme/index.js +72 -0
  167. package/src/withTracker/README.md +34 -0
  168. package/src/withTracker/error_boundary.js +34 -0
  169. package/src/withTracker/index.js +70 -0
  170. package/lib/GraphQLPlayground/graphiql.css +0 -1850
  171. package/lib/GraphQLPlayground/index.js +0 -302
  172. package/lib/GraphQLPlayground/util.js +0 -55
@@ -19,19 +19,18 @@ var _error_boundary = _interopRequireDefault(require("./error_boundary"));
19
19
 
20
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
21
 
22
- function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
22
+ 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); }
23
23
 
24
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (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; }
24
+ 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; }
25
25
 
26
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
26
+ 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; }
27
27
 
28
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
28
+ 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; }
29
29
 
30
30
  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; }
31
31
 
32
32
  var _default = function _default(WrappedComponent) {
33
33
  let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
34
- // eslint-disable-next-line object-curly-newline
35
34
  const {
36
35
  appVersion,
37
36
  gaAccount,
@@ -81,10 +80,10 @@ var _default = function _default(WrappedComponent) {
81
80
 
82
81
  render() {
83
82
  if (process.env.NODE_ENV === 'production') {
84
- return _react.default.createElement(_error_boundary.default, null, _react.default.createElement(WrappedComponent, this.props));
83
+ return /*#__PURE__*/_react.default.createElement(_error_boundary.default, null, /*#__PURE__*/_react.default.createElement(WrappedComponent, this.props));
85
84
  }
86
85
 
87
- return _react.default.createElement(WrappedComponent, this.props);
86
+ return /*#__PURE__*/_react.default.createElement(WrappedComponent, this.props);
88
87
  }
89
88
 
90
89
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcblock/ux",
3
- "version": "0.78.25",
3
+ "version": "1.6.59",
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",
@@ -42,38 +43,42 @@
42
43
  "@babel/preset-react": "^7.8.3",
43
44
  "babel-plugin-inline-react-svg": "^1.1.1",
44
45
  "babel-plugin-styled-components": "^1.10.7",
46
+ "dayjs": "^1.10.6",
45
47
  "eslint-plugin-react-hooks": "^4.2.0",
46
- "jest": "^24.1.0"
48
+ "jest": "^24.1.0",
49
+ "moment-timezone": "^0.5.33"
47
50
  },
48
51
  "peerDependencies": {
49
52
  "@sentry/browser": "^5.0.8",
50
53
  "react": ">=16.12.0",
51
54
  "react-ga": "^2.7.0"
52
55
  },
53
- "gitHead": "ab75b1a03c6021b4cdeafc4f98100345854eabd9",
56
+ "gitHead": "0cafb36ee900f1f8f90790d77d88bd23624c30fd",
54
57
  "dependencies": {
55
- "@arcblock/react-hooks": "^0.78.25",
58
+ "@arcblock/icons": "^1.6.59",
59
+ "@arcblock/react-hooks": "^1.6.59",
56
60
  "@babel/plugin-syntax-dynamic-import": "^7.8.3",
57
- "@material-ui/core": "^4.10.1",
58
- "@material-ui/icons": "4.5.1",
59
- "axios": "^0.19.2",
61
+ "@fontsource/lato": "^4.5.3",
62
+ "@material-ui/core": "^4.12.3",
63
+ "@material-ui/icons": "4.11.2",
64
+ "axios": "^0.21.1",
65
+ "base64-url": "^2.3.3",
60
66
  "copy-to-clipboard": "^3.2.0",
61
67
  "core-js": "^3.6.4",
62
68
  "d3-geo": "^1.11.6",
63
69
  "devices.css": "^0.1.15",
64
- "graphiql": "^0.13.2",
65
- "graphiql-code-exporter": "^2.0.5",
66
- "graphiql-explorer": "^0.4.3",
67
- "graphql": "^14.6.0",
68
70
  "highlight.js": "^9.15.8",
71
+ "is-svg": "^4.3.1",
69
72
  "js-cookie": "^2.2.0",
70
- "lodash": "^4.17.15",
71
- "react-helmet": "^5.2.1",
72
- "react-image": "^4.0.3",
73
- "react-load-script": "^0.0.6",
73
+ "lodash": "^4.17.21",
74
+ "mdi-material-ui": "^6.22.1",
75
+ "react-cookie-consent": "^6.4.1",
76
+ "react-helmet": "^6.1.0",
77
+ "react-intersection-observer": "^8.31.1",
74
78
  "react-player": "^1.15.2",
75
79
  "react-router-dom": "^5.1.2",
76
- "react-use": "^13.22.4",
80
+ "react-shadow": "^19.0.2",
81
+ "react-use": "^17.2.4",
77
82
  "rebound": "^0.1.0",
78
83
  "styled-components": "^5.0.0",
79
84
  "topojson-client": "^3.0.0",
@@ -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,141 @@
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
+ <Orbit size={56} orbitColor={green[500]} atomColor={green[500]} duration={1} />
33
+ <Orbit size={80} orbitColor={blue[800]} atomColor={blue[800]} duration={1.5} />
34
+ <Orbit size={100} orbitColor={colors.grey[900]} atomColor={colors.grey[900]} />
35
+ </div>
36
+ </div>
37
+ </Div>
38
+ );
39
+ }
40
+
41
+ ActivityIndicator.propTypes = {
42
+ interval: PropTypes.number,
43
+ messages: PropTypes.arrayOf(PropTypes.string.isRequired),
44
+ };
45
+
46
+ ActivityIndicator.defaultProps = {
47
+ interval: 3000,
48
+ messages: ['Loading data...'],
49
+ };
50
+
51
+ const Div = styled.div`
52
+ && {
53
+ box-sizing: border-box;
54
+ padding: 20px;
55
+ width: 100%;
56
+ height: 100%;
57
+ min-height: 360px;
58
+ z-index: 100;
59
+ transition: opacity 0.5s linear;
60
+ display: flex;
61
+ align-items: center;
62
+ flex-direction: column;
63
+ justify-content: center;
64
+ }
65
+
66
+ .pm-loader-text {
67
+ color: ${colors.grey[900]};
68
+ font-size: 14px;
69
+ text-align: center;
70
+ position: relative;
71
+ height: 70px;
72
+ -webkit-user-select: none;
73
+ }
74
+
75
+ .pm-loader-container {
76
+ width: 100%;
77
+ height: 100%;
78
+ display: flex;
79
+ align-items: center;
80
+ flex-direction: column;
81
+ justify-content: center;
82
+ flex: 1;
83
+ }
84
+
85
+ .pm-loader-atoms {
86
+ width: 100px;
87
+ height: 100px;
88
+ display: flex;
89
+ position: relative;
90
+ align-items: center;
91
+ justify-content: center;
92
+ }
93
+ `;
94
+
95
+ const Orbit = ({ size, orbitColor, atomColor, duration, ...rest }) => {
96
+ return (
97
+ <OrbitRoot
98
+ $duration={duration}
99
+ style={{ width: size, height: size, border: `1px solid ${orbitColor}` }}
100
+ {...rest}>
101
+ <div style={{ background: atomColor }} />
102
+ </OrbitRoot>
103
+ );
104
+ };
105
+
106
+ Orbit.propTypes = {
107
+ size: PropTypes.number.isRequired,
108
+ orbitColor: PropTypes.string.isRequired,
109
+ atomColor: PropTypes.string.isRequired,
110
+ duration: PropTypes.number,
111
+ };
112
+
113
+ Orbit.defaultProps = {
114
+ duration: 2,
115
+ };
116
+
117
+ const OrbitRoot = styled.div`
118
+ @keyframes orbit {
119
+ 0% {
120
+ transform: rotate(0deg);
121
+ }
122
+ 100% {
123
+ transform: rotate(360deg);
124
+ }
125
+ }
126
+
127
+ position: absolute;
128
+ border-radius: 50%;
129
+ animation: orbit ${({ $duration }) => $duration}s infinite;
130
+ animation-timing-function: linear;
131
+ transform-origin: center;
132
+
133
+ > div {
134
+ position: absolute;
135
+ top: 50%;
136
+ width: 6px;
137
+ height: 6px;
138
+ transform: translateX(-50%);
139
+ border-radius: 50%;
140
+ }
141
+ `;
@@ -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
+ `;