@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
@@ -0,0 +1,281 @@
1
+ /* eslint-disable no-bitwise */
2
+ import padStart from 'lodash/padStart';
3
+
4
+ let dateTool = null;
5
+
6
+ export function parseQuery(str) {
7
+ return str
8
+ .replace(/^\?/, '')
9
+ .split('&')
10
+ .map(x => x.split('='))
11
+ .filter(([key]) => !!key)
12
+ .reduce((memo, x) => {
13
+ const key = x[0];
14
+ const value = decodeURIComponent(x[1]) || true;
15
+ memo[key] = value;
16
+ return memo;
17
+ }, {});
18
+ }
19
+
20
+ /**
21
+ * @param {number} opts.expireInDays
22
+ * @param {string} opts.path
23
+ * @param {domain} opts.domain
24
+ * @param {boolean} opts.returnDomain if === false, opts.domain will be skipped
25
+ */
26
+ export function getCookieOptions(expireInDays = 1) {
27
+ let opts = { expireInDays };
28
+ if (typeof expireInDays === 'object') {
29
+ opts = expireInDays;
30
+ }
31
+
32
+ if (opts.path === undefined) {
33
+ opts.path = '/';
34
+ }
35
+
36
+ if (!opts.expireInDays) {
37
+ opts.expireInDays = 1;
38
+ }
39
+
40
+ const options = {
41
+ expires: opts.expireInDays,
42
+ path: opts.path,
43
+ domain: opts.domain || '',
44
+ sameSite: opts.sameSite || 'lax',
45
+ };
46
+ if (typeof window === 'undefined' || opts.domain || opts.returnDomain === false) {
47
+ if (opts.returnDomain === false) {
48
+ delete options.domain;
49
+ }
50
+ return options;
51
+ }
52
+
53
+ const { host } = window.location;
54
+ if (/^[.:0-9]+$/.test(host)) {
55
+ options.domain = '';
56
+ } else {
57
+ const parts = host.split('.');
58
+ if (parts.length === 1) {
59
+ options.domain = '';
60
+ } else {
61
+ // Remember the cookie on all sub domains.
62
+ while (parts.length > 2) {
63
+ parts.shift();
64
+ }
65
+ options.domain = `.${parts.join('.')}`;
66
+ }
67
+ }
68
+
69
+ return options;
70
+ }
71
+
72
+ export const getColor = props => {
73
+ if (props.color) {
74
+ return props.color;
75
+ }
76
+
77
+ if (props.dark) {
78
+ return props.theme.palette.common.white;
79
+ }
80
+
81
+ return props.theme.palette.text.primary;
82
+ };
83
+
84
+ export const getBackground = props => {
85
+ if (props.background) {
86
+ return props.background;
87
+ }
88
+
89
+ if (props.dark) {
90
+ return props.theme.palette.common.black;
91
+ }
92
+
93
+ return props.theme.palette.common.white;
94
+ };
95
+
96
+ export function mergeProps(props, component, jsonAttrs = []) {
97
+ const newProps = Object.assign({}, props);
98
+ Object.keys(component.defaultProps || {}).forEach(x => {
99
+ if (typeof newProps[x] === 'string' && newProps[x].indexOf('::prop::') === 0) {
100
+ newProps[x] = component.defaultProps[x];
101
+ }
102
+ });
103
+
104
+ if (Array.isArray(jsonAttrs)) {
105
+ jsonAttrs.forEach(x => {
106
+ if (typeof newProps[x] === 'string') {
107
+ try {
108
+ newProps[x] = JSON.parse(newProps[x]);
109
+ } catch (err) {
110
+ // Do nothing
111
+ }
112
+ }
113
+ });
114
+ }
115
+
116
+ Object.keys(newProps).forEach(x => {
117
+ if (typeof newProps[x] === 'string' && newProps[x].indexOf('::prop::') === 0) {
118
+ newProps[x] = '';
119
+ }
120
+ });
121
+
122
+ return newProps;
123
+ }
124
+
125
+ export function getCopyright(startYear = 2017) {
126
+ const currentYear = new Date().getFullYear();
127
+ return `${currentYear}` === `${startYear}`
128
+ ? `© ArcBlock ${currentYear}`
129
+ : `© ArcBlock ${startYear} - ${currentYear}`;
130
+ }
131
+
132
+ export const getTimezone = () => {
133
+ if (
134
+ typeof Intl === 'object' &&
135
+ typeof Intl.DateTimeFormat === 'function' &&
136
+ typeof Intl.DateTimeFormat().resolvedOptions === 'function'
137
+ ) {
138
+ return Intl.DateTimeFormat().resolvedOptions().timeZone;
139
+ }
140
+
141
+ return '';
142
+ };
143
+
144
+ export const str2color = str => {
145
+ let hash = 0;
146
+ for (let i = 0; i < str.length; i++) {
147
+ hash = str.charCodeAt(i) + ((hash << 5) - hash);
148
+ }
149
+ let colour = '#';
150
+ for (let j = 0; j < 3; j++) {
151
+ const value = (hash >> (j * 8)) & 0xff;
152
+ colour += `00${value.toString(16)}`.substr(-2);
153
+ }
154
+ return colour;
155
+ };
156
+
157
+ export const formatUptime = uptime => {
158
+ const total = Math.round(uptime / 1000);
159
+ const hours = Math.floor(total / 3600);
160
+ const minutes = Math.floor((total - hours * 3600) / 60);
161
+ const seconds = total % 60;
162
+ return `${padStart(hours, 2, '0')}:${padStart(minutes, 2, '0')}:${padStart(seconds, 2, '0')}`;
163
+ };
164
+
165
+ /**
166
+ * Set the date tool library which support for format() and locale() functions,
167
+ * moment and dayjs are recommended.
168
+ * @param {object} the date tool library
169
+ */
170
+ export function setDateTool(tool) {
171
+ dateTool = tool;
172
+ }
173
+
174
+ export function getDateTool() {
175
+ return dateTool;
176
+ }
177
+
178
+ const createDateFormater =
179
+ format =>
180
+ (date, { locale, tz }) => {
181
+ if (dateTool === null) {
182
+ throw new Error('call setDateTool to set the date tool library, such as: setDateTool(dayjs)');
183
+ }
184
+
185
+ if (!date) {
186
+ return '-';
187
+ }
188
+
189
+ let instance = dateTool(date);
190
+
191
+ if (typeof tz !== 'undefined') {
192
+ instance = instance.tz(tz);
193
+ }
194
+
195
+ if (typeof locale !== 'undefined') {
196
+ instance = instance.locale(locale);
197
+ }
198
+
199
+ return instance.format(format);
200
+ };
201
+
202
+ /**
203
+ * Format the time string as `ll` format: MMM D, YYYY
204
+ * Ensure that the setDateTool() function is called first to set the time tool library.
205
+ * @param {string} date date string
206
+ * @param {object} option
207
+ * @param {string} option.locale, default: en
208
+ * @param {string} option.tz, default: timzone
209
+ * @returns formated date string
210
+ */
211
+ export function formatToDate(date, { locale, tz } = {}) {
212
+ return createDateFormater('ll')(date, { locale, tz });
213
+ }
214
+
215
+ /**
216
+ * Format the time string as `lll` format: MMM D, YYYY h:mm A
217
+ * Ensure that the setDateTool() function is called first to set the time tool library.
218
+ * @param {string} date date string
219
+ * @param {object} option
220
+ * @param {string} option.locale, default: en
221
+ * @param {string} option.tz, default: timzone
222
+ * @returns formated date string
223
+ */
224
+ export function formatToDatetime(date, { locale, tz } = {}) {
225
+ return createDateFormater('lll')(date, { locale, tz });
226
+ }
227
+
228
+ export function openWebWallet({
229
+ webWalletUrl,
230
+ action = 'login',
231
+ locale = 'en',
232
+ url,
233
+ windowFeatures,
234
+ }) {
235
+ // web wallet extension
236
+ const webWalletExtension = window?.ABT_DEV || window.ABT;
237
+ if (webWalletExtension && typeof webWalletExtension.open === 'function') {
238
+ webWalletExtension.open({
239
+ action,
240
+ locale,
241
+ url: encodeURIComponent(url),
242
+ });
243
+
244
+ return;
245
+ }
246
+
247
+ const defaultWindowFeatures = {
248
+ toolbar: 'no',
249
+ location: 'no',
250
+ status: 'no',
251
+ menubar: 'no',
252
+ scrollbars: 'yes',
253
+ resizable: 'yes',
254
+ // iphone 8plus size
255
+ width: 414,
256
+ height: 736,
257
+ };
258
+ const windowUrl = `${webWalletUrl}?action=${action}&locale=${locale}&url=${encodeURIComponent(
259
+ url
260
+ )}`;
261
+ const mergedWindowFeatures = Object.assign({}, defaultWindowFeatures, windowFeatures);
262
+ const getWindowWidth = win => {
263
+ return (
264
+ win.innerWidth || win.document.documentElement.clientWidth || win.document.body.clientWidth
265
+ );
266
+ };
267
+ // 默认在浏览器右上角弹出窗口
268
+ if (!('left' in mergedWindowFeatures)) {
269
+ const winWidth = getWindowWidth(window.top || window);
270
+ const winLeft = window.screenLeft || window.screenX;
271
+ mergedWindowFeatures.left = winWidth + winLeft - mergedWindowFeatures.width;
272
+ }
273
+ if (!('top' in mergedWindowFeatures)) {
274
+ const winTop = window.screenTop || window.screenY;
275
+ mergedWindowFeatures.top = winTop;
276
+ }
277
+ const strWindowFeatures = Object.keys(mergedWindowFeatures)
278
+ .map(key => `${key}=${mergedWindowFeatures[key]}`)
279
+ .join(',');
280
+ window.open(windowUrl, 'targetWindow', strWindowFeatures);
281
+ }
@@ -0,0 +1,72 @@
1
+ import React, { useState } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import Player from 'react-player';
4
+ import styled from 'styled-components';
5
+
6
+ import CircularProgress from '@material-ui/core/CircularProgress';
7
+
8
+ import { mergeProps } from '../Util';
9
+
10
+ const { string, number, array, oneOfType, object } = PropTypes;
11
+
12
+ export default function Video(props) {
13
+ const newProps = mergeProps(props, Video, ['style']);
14
+ const { url, width, height, style } = newProps;
15
+ const [loaded, setLoaded] = useState(false);
16
+
17
+ const styles = Object.assign({ border: 'none' }, style, {
18
+ width,
19
+ height,
20
+ visibility: loaded ? 'visible' : 'hidden',
21
+ });
22
+
23
+ if (url.indexOf('v.qq.com') > 0) {
24
+ return (
25
+ <Placeholder style={{ width, height }}>
26
+ <iframe
27
+ title={url}
28
+ style={styles}
29
+ src={url}
30
+ onLoad={() => setLoaded(true)}
31
+ allowFullScreen="true"
32
+ />
33
+ {!loaded && <CircularProgress className="loading-indicator" color="primary" />}
34
+ </Placeholder>
35
+ );
36
+ }
37
+
38
+ return (
39
+ <Placeholder style={{ width, height }}>
40
+ <Player style={styles} {...newProps} onReady={() => setLoaded(true)} />
41
+ {!loaded && <CircularProgress className="loading-indicator" color="primary" />}
42
+ </Placeholder>
43
+ );
44
+ }
45
+
46
+ Video.propTypes = {
47
+ url: oneOfType([string, array, object]).isRequired,
48
+ width: oneOfType([string, number]),
49
+ height: oneOfType([string, number]),
50
+ style: oneOfType([string, object]),
51
+ };
52
+
53
+ Video.defaultProps = {
54
+ width: 640,
55
+ height: 400,
56
+ style: {},
57
+ };
58
+
59
+ const Placeholder = styled.div`
60
+ background-color: #222222;
61
+ display: flex;
62
+ justify-content: center;
63
+ align-items: center;
64
+ position: relative;
65
+
66
+ .loading-indicator {
67
+ position: absolute;
68
+ top: 45%;
69
+ left: 47%;
70
+ z-index: 2;
71
+ }
72
+ `;
@@ -0,0 +1,105 @@
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 logo from './images/abtwallet.png';
8
+ import { mergeProps } from '../Util';
9
+ import colors from '../Colors';
10
+ import Button from '../Button';
11
+
12
+ export default function WalletAction(props) {
13
+ const newProps = mergeProps(props, WalletAction, ['style']);
14
+ const { action, size, textLayout, style = {}, ...rest } = newProps;
15
+ const styles = Object.assign({}, style, { border: 'none', padding: 0 });
16
+
17
+ return (
18
+ <Button style={styles} {...rest} variant="outlined">
19
+ <Content size={size} color={styles.color}>
20
+ <img src={logo} className="wallet-action__logo" alt="DID Wallet" />
21
+ {textLayout === 'vertical' && (
22
+ <Typography className="wallet-action__text" component="div">
23
+ <span className="wallet-action__action">{action} with</span>
24
+ <span className="wallet-action__title">DID Wallet</span>
25
+ </Typography>
26
+ )}
27
+ {textLayout === 'horizontal' && (
28
+ <span className="wallet-action__title" style={{ padding: 8 }}>
29
+ {action} with DID Wallet
30
+ </span>
31
+ )}
32
+ </Content>
33
+ </Button>
34
+ );
35
+ }
36
+
37
+ WalletAction.propTypes = {
38
+ action: PropTypes.string,
39
+ size: PropTypes.oneOf(['large', 'medium', 'small']),
40
+ textLayout: PropTypes.oneOf(['vertical', 'horizontal']),
41
+ style: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
42
+ };
43
+
44
+ WalletAction.defaultProps = {
45
+ action: 'Login',
46
+ textLayout: 'vertical',
47
+ size: 'medium',
48
+ style: {},
49
+ };
50
+
51
+ const sizes = {
52
+ logo: {
53
+ small: 32,
54
+ medium: 44,
55
+ large: 56,
56
+ xlarge: 88,
57
+ },
58
+ font: {
59
+ small: 9,
60
+ medium: 11,
61
+ large: 13,
62
+ xlarge: 18,
63
+ },
64
+ };
65
+
66
+ const Content = styled.div`
67
+ display: flex;
68
+ justify-content: center;
69
+ align-items: center;
70
+
71
+ &:hover {
72
+ opacity: 0.9;
73
+ }
74
+
75
+ .wallet-action__logo {
76
+ width: auto;
77
+ height: auto;
78
+ max-width: ${props => sizes.logo[props.size]}px;
79
+ margin-left: 5px;
80
+ }
81
+
82
+ .wallet-action__text {
83
+ padding: 8px;
84
+ display: flex;
85
+ height: 100%;
86
+ flex-direction: column;
87
+ justify-content: space-between;
88
+ align-items: flex-start;
89
+ }
90
+
91
+ .wallet-action__action {
92
+ font-size: ${props => sizes.font[props.size]}px;
93
+ text-transform: capitalize;
94
+ margin-bottom: 1px;
95
+ color: ${props => props.color || colors.primary.main};
96
+ letter-spacing: 1px;
97
+ }
98
+
99
+ .wallet-action__title {
100
+ font-size: ${props => sizes.font[props.size] * 1.5}px;
101
+ text-transform: capitalize;
102
+ color: ${props => props.color || colors.primary.main};
103
+ letter-spacing: 1px;
104
+ }
105
+ `;
@@ -0,0 +1,130 @@
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
+ import useBrowser from '@arcblock/react-hooks/lib/useBrowser';
7
+
8
+ import { ReactComponent as AppStoreIcon } from './images/app-store.svg';
9
+ import { ReactComponent as GooglePlayIcon } from './images/google-play.svg';
10
+ import { ReactComponent as AndroidDownloadIcon } from './images/android_download.svg';
11
+
12
+ import Button from '../Button';
13
+ import { mergeProps } from '../Util';
14
+
15
+ export default function WalletDownload(props) {
16
+ const browser = useBrowser();
17
+ const newProps = mergeProps(props, WalletDownload, ['style']);
18
+ const { title, children, iosLink, androidLink, androidDownLoadUrl, locale, ...rest } = newProps;
19
+
20
+ const isAndroid = browser.mobile.android.phone || browser.mobile.android.tablet;
21
+ const isIOS = browser.mobile.apple.phone || browser.mobile.apple.tablet;
22
+
23
+ return (
24
+ <Container {...rest}>
25
+ <div className="download-text">
26
+ {!!title && (
27
+ <Typography className="download-title" component="div">
28
+ {title}
29
+ </Typography>
30
+ )}
31
+ {children && (
32
+ <Typography className="download-extra" component="div">
33
+ {children}
34
+ </Typography>
35
+ )}
36
+ </div>
37
+ {!browser.mobile.any && (
38
+ <div className="download-store-list">
39
+ <Button className="download-link" component="a" href={iosLink}>
40
+ <AppStoreIcon />
41
+ </Button>
42
+ {locale === 'zh' && (
43
+ <Button component="a" className="download-link" href={androidDownLoadUrl}>
44
+ <AndroidDownloadIcon />
45
+ </Button>
46
+ )}
47
+ {locale === 'en' && (
48
+ <Button component="a" className="download-link" href={androidLink}>
49
+ <GooglePlayIcon />
50
+ </Button>
51
+ )}
52
+ </div>
53
+ )}
54
+ {isAndroid && (
55
+ <div className="download-store-list">
56
+ {locale === 'zh' && (
57
+ <Button component="a" href={androidDownLoadUrl} variant="outlined" color="primary">
58
+ 本地下载
59
+ </Button>
60
+ )}
61
+ {locale === 'en' && (
62
+ <Button component="a" href={androidLink} variant="outlined" color="primary">
63
+ Download
64
+ </Button>
65
+ )}
66
+ </div>
67
+ )}
68
+ {isIOS && (
69
+ <div className="download-store-list">
70
+ <Button component="a" href={iosLink} variant="outlined" color="primary">
71
+ Download
72
+ </Button>
73
+ </div>
74
+ )}
75
+ </Container>
76
+ );
77
+ }
78
+
79
+ WalletDownload.propTypes = {
80
+ title: PropTypes.string,
81
+ layout: PropTypes.oneOf(['vertical', 'horizontal']),
82
+ storeLayout: PropTypes.oneOf(['vertical', 'horizontal']),
83
+ style: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
84
+ iosLink: PropTypes.string,
85
+ androidLink: PropTypes.string,
86
+ androidDownLoadUrl: PropTypes.string,
87
+ locale: PropTypes.oneOf(['en', 'zh']),
88
+ };
89
+
90
+ WalletDownload.defaultProps = {
91
+ title: 'Download DID Wallet',
92
+ layout: 'vertical',
93
+ storeLayout: 'horizontal',
94
+ iosLink: 'https://itunes.apple.com/app/id1460083542',
95
+ androidLink: 'https://play.google.com/store/apps/details?id=com.arcblock.wallet.app.product',
96
+ androidDownLoadUrl: 'https://releases.arcblockio.cn/arcwallet_android/latest/abtwallet.apk',
97
+ style: {},
98
+ locale: 'zh',
99
+ };
100
+
101
+ const Container = styled.div`
102
+ display: flex;
103
+ flex-direction: ${props => (props.layout === 'vertical' ? 'column' : 'row')};
104
+ align-items: center;
105
+
106
+ .download-title {
107
+ margin-right: ${props => (props.layout === 'vertical' ? '0' : '16px')};
108
+ margin-bottom: ${props => (props.layout === 'vertical' ? '16px' : '0')};
109
+ }
110
+
111
+ .download-store-list {
112
+ display: flex;
113
+ flex-direction: ${props => (props.storeLayout === 'vertical' ? 'column' : 'row')};
114
+ justify-content: space-between;
115
+ align-items: center;
116
+
117
+ .download-link {
118
+ padding: 0;
119
+ margin: 0;
120
+
121
+ margin-right: ${props => (props.storeLayout === 'vertical' ? '0' : '16px')};
122
+ margin-bottom: ${props => (props.storeLayout === 'vertical' ? '16px' : '0')};
123
+
124
+ &:last-of-type {
125
+ margin-right: 0;
126
+ margin-bottom: 0;
127
+ }
128
+ }
129
+ }
130
+ `;
@@ -0,0 +1,50 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import styled from 'styled-components';
4
+ import useBrowser from '@arcblock/react-hooks/lib/useBrowser';
5
+ import Fab from '@material-ui/core/Fab';
6
+
7
+ export default function OpenInWallet({ locale, link }) {
8
+ const buttonText = locale === 'zh' ? '在 ABT 钱包打开' : 'Open in DID Wallet';
9
+ const browser = useBrowser();
10
+
11
+ if (browser.mobile.any && !browser.wallet && !browser.wechat) {
12
+ const deepLink = `abt://abtwallet.io/i?action=requestOpenUrl&url=${encodeURIComponent(link)}`;
13
+
14
+ return (
15
+ <Button
16
+ size="small"
17
+ href={deepLink}
18
+ variant="extended"
19
+ color="primary"
20
+ rounded
21
+ target="_blank"
22
+ className="open-in-wallet-button">
23
+ {buttonText}
24
+ </Button>
25
+ );
26
+ }
27
+ return null;
28
+ }
29
+
30
+ OpenInWallet.propTypes = {
31
+ locale: PropTypes.oneOf(['en', 'zh']),
32
+ link: PropTypes.string.isRequired,
33
+ };
34
+
35
+ OpenInWallet.defaultProps = {
36
+ locale: 'zh',
37
+ };
38
+
39
+ const Button = styled(Fab)`
40
+ && {
41
+ font-size: 12px;
42
+ position: fixed;
43
+ bottom: 24px;
44
+ left: 50%;
45
+ transform-origin: 50% 50%;
46
+ transform: translateX(-50%);
47
+ min-width: 120px;
48
+ z-index: ${props => props.theme.zIndex.tooltip};
49
+ }
50
+ `;
Binary file
@@ -0,0 +1,23 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <svg width="172px" height="50px" viewBox="0 0 172 50" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
3
+ <!-- Generator: Sketch 62 (91390) - https://sketch.com -->
4
+ <title>android</title>
5
+ <desc>Created with Sketch.</desc>
6
+ <g id="android" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
7
+ <path d="M172,44.3280578 C172,47.460585 169.20589,50 165.759181,50 L6.24081931,50 C4.58565112,50 2.99827431,49.4024221 1.82789366,48.3387266 C0.657513004,47.2750311 0,45.8323504 0,44.3280578 L0,5.67194218 C0,2.53941501 2.79410998,0 6.24081931,0 L165.759181,0 C169.20589,0 172,2.53941501 172,5.67194218 L172,44.3280578" id="bg" fill="#100F0D" fill-rule="nonzero"></path>
8
+ <text id="Android" fill="#FFFFFF" font-family="Arial-BoldMT, Arial" font-size="23.4412266" font-weight="bold">
9
+ <tspan x="63.6237138" y="42.1351959">Android</tspan>
10
+ </text>
11
+ <text id="Download-for" fill="#FFFFFF" fill-rule="nonzero" font-family="ArialMT, Arial" font-size="11.7206133" font-weight="normal">
12
+ <tspan x="64" y="19">Download for</tspan>
13
+ </text>
14
+ <g id="Android" transform="translate(13.478705, 3.102215)" fill="#9FC732" fill-rule="nonzero">
15
+ <g id="shapeB" transform="translate(14.000000, 28.229131) scale(-1, 1) rotate(-180.000000) translate(-14.000000, -28.229131) translate(0.000000, 14.729131)">
16
+ <path d="M27.0021559,26.7999654 L6.67361202,26.7999654 C6.22172319,26.7999654 5.85537086,26.4342314 5.85537086,25.9833492 L5.85537086,8.97407348 C5.85537086,8.52300474 6.22153629,8.15719149 6.67361202,8.15686385 L10.2979028,8.15686385 L10.2979028,2.42512051 C10.2979028,1.09475625 11.3786473,0.0164193655 12.711387,0.0164193655 C14.0445233,0.0164193655 15.1250695,1.09475625 15.1250695,2.42512051 L15.1250695,8.15686385 L18.5009338,8.15686385 L18.5009338,2.42512051 C18.5009338,1.09475625 19.5816783,0.0164193655 20.914418,0.0164193655 C22.2475543,0.0164193655 23.3279023,1.09475625 23.3279023,2.42512051 L23.3279023,8.15686385 L27.0021559,8.15686385 C27.2193934,8.15681136 27.4277485,8.24289313 27.5813587,8.39616104 C27.7349688,8.54942896 27.8211902,8.75731992 27.8211902,8.97407348 L27.8211902,25.9833492 C27.8211902,26.4344951 27.4543091,26.7999654 27.0021559,26.7999654 M2.41368249,26.8043175 C1.08094274,26.8043175 0,25.7257828 0,24.396012 L0,14.6142245 C0,13.2846515 1.08054621,12.2065124 2.41368249,12.2065124 C3.74622398,12.2065124 4.82696846,13.2846515 4.82696846,14.6142245 L4.82696846,24.396012 C4.82696846,25.7259806 3.74642224,26.8043175 2.41368249,26.8043175" id="形状"></path>
17
+ </g>
18
+ <g id="shapeA" transform="translate(20.153322, 14.922487) scale(-1, 1) rotate(-180.000000) translate(-20.153322, -14.922487) translate(6.153322, 0.422487)">
19
+ <path d="M25.2453809,14.8645837 C23.9142872,14.8645837 22.835755,13.7735501 22.835755,12.428369 L22.835755,2.53322312 C22.835755,1.18824212 23.9142872,0.0976088161 25.2453809,0.0976088161 C26.5758807,0.0976088161 27.6548088,1.18824212 27.6548088,2.53322312 L27.6548088,12.428369 C27.6548088,13.7737503 26.5758807,14.8645837 25.2453809,14.8645837 M5.80349633,21.6325137 C6.13763097,21.6374522 6.44849574,21.460055 6.61698905,21.1682882 C6.78548236,20.8765215 6.78548236,20.5156183 6.61698905,20.2238515 C6.44849574,19.9320848 6.13763097,19.7546876 5.80349633,19.7596261 C5.29723671,19.7671087 4.89071419,20.1841693 4.89071419,20.6960699 C4.89071419,21.2079705 5.29723671,21.6250311 5.80349633,21.6325137 L5.80349633,21.6325137 Z M16.7639886,20.6959698 C16.7750405,20.3542555 16.6010357,20.033606 16.3100354,19.8594415 C16.0190351,19.6852771 15.657287,19.6852771 15.3662867,19.8594415 C15.0752864,20.033606 14.9012817,20.3542555 14.9123335,20.6959698 C14.928668,21.2010236 15.3383524,21.6019059 15.8381611,21.6019059 C16.3379697,21.6019059 16.7476541,21.2010236 16.7639886,20.6959698 Z M0.862120431,16.0672821 L20.7800318,16.0672821 C21.2992078,16.0672821 21.6869569,16.5509629 21.5798756,17.0654617 C20.9213553,20.239905 18.9224386,22.9154586 16.2093828,24.4611562 L17.9119951,27.5667596 C17.9674152,27.6677193 17.9808653,27.7868122 17.9493827,27.8978044 C17.9179001,28.0087966 17.8440674,28.1025826 17.7441486,28.1585032 C17.6443377,28.2146597 17.5265257,28.2283484 17.4167169,28.1965478 C17.306908,28.1647472 17.2141307,28.0900719 17.1588633,27.9890047 L15.4433854,24.8597877 C13.9950906,25.5385247 12.4175937,25.8891002 10.821274,25.8869841 C9.22481328,25.8892295 7.6471602,25.5386493 6.19876682,24.8597877 L4.48289309,27.989405 C4.36428298,28.1925314 4.10726669,28.2632426 3.9032069,28.1488902 C3.69914712,28.0345378 3.62224629,27.7767039 3.72976129,27.5673599 L5.43237357,24.4611562 C2.71991151,22.9154586 0.720203086,20.239905 0.0616828527,17.0654617 C-0.0452005035,16.551163 0.342548561,16.0672821 0.862120431,16.0672821" id="形状"></path>
20
+ </g>
21
+ </g>
22
+ </g>
23
+ </svg>