@arcblock/ux 2.6.8 → 2.7.0

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 (164) hide show
  1. package/babel.config.es.js +12 -0
  2. package/es/ActionButton/index.js +99 -0
  3. package/es/ActivityIndicator/index.js +180 -0
  4. package/es/Address/compact-text.js +105 -0
  5. package/es/Address/did-address.js +211 -0
  6. package/es/Address/index.js +23 -0
  7. package/es/Address/responsive-did-address.js +88 -0
  8. package/es/Alert/index.js +134 -0
  9. package/es/AnimationWaiter/default-animation.json +1 -0
  10. package/es/AnimationWaiter/index.js +239 -0
  11. package/es/Async/index.js +38 -0
  12. package/es/Avatar/did-motif.js +64 -0
  13. package/es/Avatar/etherscan-blockies.js +83 -0
  14. package/es/Avatar/index.js +176 -0
  15. package/es/Badge/index.js +98 -0
  16. package/es/Blocklet/blocklet.js +298 -0
  17. package/es/Blocklet/index.js +4 -0
  18. package/es/Blocklet/utils.js +52 -0
  19. package/es/BlockletNFT/index.js +412 -0
  20. package/es/Button/index.js +8 -0
  21. package/es/Button/wrap.js +140 -0
  22. package/es/ButtonGroup/index.js +6 -0
  23. package/es/CardSelector/index.js +131 -0
  24. package/es/Center/index.js +41 -0
  25. package/es/ClickToCopy/copy-button.js +72 -0
  26. package/es/ClickToCopy/hook.js +39 -0
  27. package/es/ClickToCopy/index.js +93 -0
  28. package/es/CodeBlock/LightBox.js +85 -0
  29. package/es/CodeBlock/index.js +226 -0
  30. package/es/Colors/index.js +2 -0
  31. package/es/Colors/themes/default.js +78 -0
  32. package/es/ContactForm/index.js +230 -0
  33. package/es/CookieConsent/index.js +113 -0
  34. package/es/CountDown/index.js +178 -0
  35. package/es/DID/index.js +105 -0
  36. package/es/Datatable/CustomToolbar.js +396 -0
  37. package/es/Datatable/DatatableContext.js +34 -0
  38. package/es/Datatable/TableSearch.js +165 -0
  39. package/es/Datatable/index.js +627 -0
  40. package/es/Datatable/utils.js +132 -0
  41. package/es/Dialog/confirm.js +90 -0
  42. package/es/Dialog/dialog.js +192 -0
  43. package/es/Dialog/index.js +3 -0
  44. package/es/DidLogo/index.js +31 -0
  45. package/es/DriftBot/index.js +70 -0
  46. package/es/Earth/countries.json +8057 -0
  47. package/es/Earth/index.js +521 -0
  48. package/es/Earth/util.js +51 -0
  49. package/es/Empty/index.js +64 -0
  50. package/es/ErrorBoundary/fallback.js +73 -0
  51. package/es/ErrorBoundary/index.js +1 -0
  52. package/es/Footer/index.js +172 -0
  53. package/es/Header/auto-hidden.js +35 -0
  54. package/es/Header/header.js +211 -0
  55. package/es/Header/index.js +2 -0
  56. package/es/Header/responsive-header.js +111 -0
  57. package/es/Icon/image.js +65 -0
  58. package/es/Icon/index.js +84 -0
  59. package/es/Img/index.js +217 -0
  60. package/es/InfoRow/index.js +87 -0
  61. package/es/Layout/dashboard/external-link.js +58 -0
  62. package/es/Layout/dashboard/full-page.js +53 -0
  63. package/es/Layout/dashboard/index.js +275 -0
  64. package/es/Layout/dashboard/sidebar.js +209 -0
  65. package/es/Layout/dashboard-legacy/header.js +174 -0
  66. package/es/Layout/dashboard-legacy/index.js +149 -0
  67. package/es/Layout/dashboard-legacy/sidebar.js +129 -0
  68. package/es/Layout/index.js +335 -0
  69. package/es/Locale/browser-lang.js +52 -0
  70. package/es/Locale/context.js +114 -0
  71. package/es/Locale/languages.js +60 -0
  72. package/es/Locale/selector.js +180 -0
  73. package/es/Locale/util.js +13 -0
  74. package/es/Logo/images/logo-dark-text.svg +3 -0
  75. package/es/Logo/images/logo-dark-top.svg +6 -0
  76. package/es/Logo/images/logo-light-text.svg +3 -0
  77. package/es/Logo/images/logo-light-top.svg +6 -0
  78. package/es/Logo/index.js +136 -0
  79. package/es/Metric/index.js +132 -0
  80. package/es/NFTDisplay/README.md +59 -0
  81. package/es/NFTDisplay/aspect-ratio-container.js +39 -0
  82. package/es/NFTDisplay/broken.js +18 -0
  83. package/es/NFTDisplay/demo/data/asset-state-display-url.json +7 -0
  84. package/es/NFTDisplay/demo/data/asset-state-gzipped-svg-1-1.json +10 -0
  85. package/es/NFTDisplay/demo/data/asset-state-gzipped-svg-374-130.json +10 -0
  86. package/es/NFTDisplay/demo/data/asset-state-gzipped-svg-with-foreign-object.json +20 -0
  87. package/es/NFTDisplay/demo/data/asset-state-svg.json +29 -0
  88. package/es/NFTDisplay/demo/data/asset-state-url.json +10 -0
  89. package/es/NFTDisplay/index.js +323 -0
  90. package/es/NFTDisplay/loading.js +18 -0
  91. package/es/NFTDisplay/svg-embedder/img.js +45 -0
  92. package/es/NFTDisplay/svg-embedder/inline-svg.js +39 -0
  93. package/es/NavMenu/index.js +2 -0
  94. package/es/NavMenu/nav-menu.js +286 -0
  95. package/es/NavMenu/style.js +176 -0
  96. package/es/PageScroller/index.js +286 -0
  97. package/es/PageScroller/story/FifthComponent.js +9 -0
  98. package/es/PageScroller/story/FirstComponent.js +9 -0
  99. package/es/PageScroller/story/FourthComponent.js +12 -0
  100. package/es/PageScroller/story/FullPage.js +47 -0
  101. package/es/PageScroller/story/PageContain.js +59 -0
  102. package/es/PageScroller/story/SecondComponent.js +9 -0
  103. package/es/PageScroller/story/ThirdComponent.js +9 -0
  104. package/es/PageScroller/story/index.css +115 -0
  105. package/es/PageScroller/usePrevValue.js +9 -0
  106. package/es/PricingTable/PricingPlan.js +124 -0
  107. package/es/PricingTable/index.js +53 -0
  108. package/es/QRCode/index.js +72 -0
  109. package/es/RelativeTime/index.js +98 -0
  110. package/es/Result/common.js +140 -0
  111. package/es/Result/demo/fixtures/result-image-404.svg +1 -0
  112. package/es/Result/index.js +33 -0
  113. package/es/Result/result.js +59 -0
  114. package/es/Result/translations.js +54 -0
  115. package/es/Screenshot/BaseScreenshot/index.js +91 -0
  116. package/es/Screenshot/BaseScreenshot/shells/Macbook.js +51 -0
  117. package/es/Screenshot/BaseScreenshot/shells/Phone.js +36 -0
  118. package/es/Screenshot/demo/images/bg-00.jpg +0 -0
  119. package/es/Screenshot/demo/images/bg-01.jpg +0 -0
  120. package/es/Screenshot/demo/images/bg-02.jpg +0 -0
  121. package/es/Screenshot/demo/images/bg-03.jpg +0 -0
  122. package/es/Screenshot/demo/images/bg-04.jpg +0 -0
  123. package/es/Screenshot/demo/images/bg-05.jpg +0 -0
  124. package/es/Screenshot/demo/images/bg-06.jpg +0 -0
  125. package/es/Screenshot/demo/images/bg-07.jpg +0 -0
  126. package/es/Screenshot/demo/images/bg-08.jpg +0 -0
  127. package/es/Screenshot/demo/images/bg-09.jpg +0 -0
  128. package/es/Screenshot/devices.css +1366 -0
  129. package/es/Screenshot/index.js +299 -0
  130. package/es/SessionManager/federated-login-detecter.js +166 -0
  131. package/es/SessionManager/index.js +468 -0
  132. package/es/SessionManager/user-popper.js +132 -0
  133. package/es/Sparkline/index.js +193 -0
  134. package/es/Spinner/index.js +28 -0
  135. package/es/SplitButton/index.js +144 -0
  136. package/es/Switch/index.js +96 -0
  137. package/es/Tabs/index.js +48 -0
  138. package/es/Tag/index.js +108 -0
  139. package/es/TextCollapse/index.js +92 -0
  140. package/es/Theme/index.js +16 -0
  141. package/es/Theme/theme-provider.js +39 -0
  142. package/es/Theme/theme.js +133 -0
  143. package/es/Toast/index.js +95 -0
  144. package/es/Util/deprecate.js +28 -0
  145. package/es/Util/index.js +298 -0
  146. package/es/Util/wallet.js +32 -0
  147. package/es/Video/index.js +89 -0
  148. package/es/Wallet/Action.js +119 -0
  149. package/es/Wallet/Download.js +331 -0
  150. package/es/Wallet/Open.js +45 -0
  151. package/es/Wallet/images/abtwallet.png +0 -0
  152. package/es/Wallet/images/android_download.svg +23 -0
  153. package/es/Wallet/images/app-store.svg +20 -0
  154. package/es/Wallet/images/google-play.svg +70 -0
  155. package/es/WebWalletSWKeeper/index.js +115 -0
  156. package/es/WechatPrompt/images/android.png +0 -0
  157. package/es/WechatPrompt/images/ios.png +0 -0
  158. package/es/WechatPrompt/index.js +88 -0
  159. package/es/index.js +38 -0
  160. package/es/withTheme/index.js +69 -0
  161. package/es/withTracker/README.md +34 -0
  162. package/es/withTracker/error_boundary.js +34 -0
  163. package/es/withTracker/index.js +56 -0
  164. package/package.json +272 -5
@@ -0,0 +1,180 @@
1
+ /* eslint-disable react/jsx-no-bind */
2
+ import { useState, useContext, useRef, useMemo } from 'react';
3
+ import PropTypes from 'prop-types';
4
+ import Button from '@mui/material/Button';
5
+ import Typography from '@mui/material/Typography';
6
+ import IconButton from '@mui/material/IconButton';
7
+ import ClickAwayListener from '@mui/material/ClickAwayListener';
8
+ import Popper from '@mui/material/Popper';
9
+ import MenuItem from '@mui/material/MenuItem';
10
+ import MenuList from '@mui/material/MenuList';
11
+ import Box from '@mui/material/Box';
12
+ import CheckIcon from '@mui/icons-material/Check';
13
+ import GlobeIcon from '@arcblock/icons/lib/Globe';
14
+ import { getColor, getBackground } from '../Util';
15
+ import { LocaleContext } from './context';
16
+ import { styled, useTheme } from '../Theme';
17
+ import { jsx as _jsx } from "react/jsx-runtime";
18
+ import { jsxs as _jsxs } from "react/jsx-runtime";
19
+ export default function LocaleSelector(props) {
20
+ const {
21
+ showText,
22
+ popperProps,
23
+ popperType,
24
+ icon: Icon,
25
+ size,
26
+ ...rest
27
+ } = props;
28
+ const {
29
+ locale,
30
+ changeLocale,
31
+ languages
32
+ } = useContext(LocaleContext);
33
+ const anchorEl = useRef(null);
34
+ const [open, setOpen] = useState(false);
35
+ const theme = useTheme();
36
+ const dark = theme?.palette?.mode === 'dark';
37
+ const onSelect = newLocale => {
38
+ changeLocale(newLocale);
39
+ setOpen(false);
40
+ if (typeof props.onChange === 'function') {
41
+ props.onChange(newLocale);
42
+ }
43
+ };
44
+ const onClose = e => {
45
+ if (anchorEl.current?.contains(e.target)) {
46
+ return;
47
+ }
48
+ setOpen(false);
49
+ };
50
+ const ButtonComponent = showText ? Button : IconButton;
51
+ const handleEventProps = popperType === 'hover' ? {
52
+ onMouseEnter: () => {
53
+ setOpen(true);
54
+ },
55
+ onMouseLeave: () => {
56
+ setOpen(false);
57
+ }
58
+ } : {
59
+ onClick: () => {
60
+ setOpen(!open);
61
+ }
62
+ };
63
+ const renderIcon = useMemo(() => {
64
+ if (Icon) {
65
+ return /*#__PURE__*/_jsx(Icon, {});
66
+ }
67
+ return /*#__PURE__*/_jsx(GlobeIcon, {
68
+ style: {
69
+ width: 'auto',
70
+ height: size,
71
+ color: theme.palette.text.secondary
72
+ }
73
+ });
74
+ }, [Icon, theme?.palette?.text?.secondary, size]);
75
+ return /*#__PURE__*/_jsxs(Div, {
76
+ component: "div",
77
+ dark: dark,
78
+ theme: theme,
79
+ ...rest,
80
+ ...handleEventProps,
81
+ children: [/*#__PURE__*/_jsx(ButtonComponent, {
82
+ ref: anchorEl,
83
+ className: "trigger",
84
+ children: /*#__PURE__*/_jsxs(Box, {
85
+ display: "flex",
86
+ alignItems: "center",
87
+ children: [renderIcon, showText ? /*#__PURE__*/_jsx(Typography, {
88
+ component: "strong",
89
+ className: "trigger-text",
90
+ children: languages.find(x => x.code === locale).name
91
+ }) : '']
92
+ })
93
+ }), /*#__PURE__*/_jsx(Popper, {
94
+ open: open,
95
+ anchorEl: anchorEl.current,
96
+ ...popperProps,
97
+ disablePortal: true,
98
+ children: /*#__PURE__*/_jsx("div", {
99
+ className: "locales",
100
+ children: /*#__PURE__*/_jsx(ClickAwayListener, {
101
+ onClickAway: onClose,
102
+ children: /*#__PURE__*/_jsx(MenuList, {
103
+ children: languages.map(({
104
+ code,
105
+ name
106
+ }) => /*#__PURE__*/_jsxs(MenuItem, {
107
+ className: "locale-item",
108
+ onClick: () => onSelect(code, name),
109
+ children: [/*#__PURE__*/_jsx(CheckIcon, {
110
+ className: code === locale ? 'check-icon check-icon-visible' : 'check-icon',
111
+ fontSize: "small"
112
+ }), name]
113
+ }, code))
114
+ })
115
+ })
116
+ })
117
+ })]
118
+ });
119
+ }
120
+ LocaleSelector.propTypes = {
121
+ size: PropTypes.number,
122
+ showText: PropTypes.bool,
123
+ popperProps: PropTypes.object,
124
+ onChange: PropTypes.func,
125
+ popperType: PropTypes.oneOf(['hover', 'click']),
126
+ icon: PropTypes.any
127
+ };
128
+ LocaleSelector.defaultProps = {
129
+ showText: true,
130
+ size: 24,
131
+ popperProps: {},
132
+ onChange: () => {},
133
+ popperType: 'click',
134
+ icon: null
135
+ };
136
+ const Div = styled('div', {
137
+ shouldForwardProp: prop => prop !== 'dark'
138
+ })`
139
+ display: inline-block;
140
+
141
+ .trigger {
142
+ display: flex;
143
+ flex-direction: column;
144
+ justify-content: center;
145
+ font-size: 14px;
146
+ white-space: nowrap;
147
+
148
+ .trigger-text {
149
+ margin-left: 5px;
150
+ font-size: 14px;
151
+ color: ${props => getColor(props)};
152
+ }
153
+ }
154
+
155
+ .locales {
156
+ background: ${props => getBackground(props)};
157
+ box-shadow: 0 0 8px rgba(0, 0, 0, 0.2);
158
+ }
159
+
160
+ .locale-item {
161
+ font-size: 16px;
162
+ font-style: normal;
163
+ font-stretch: normal;
164
+ line-height: normal;
165
+ letter-spacing: 2px;
166
+ text-align: center;
167
+ color: ${props => getColor(props)};
168
+ cursor: pointer;
169
+ display: flex;
170
+ padding: 16px;
171
+ align-items: center;
172
+ .check-icon {
173
+ visibility: hidden;
174
+ margin-right: 4px;
175
+ }
176
+ .check-icon-visible {
177
+ visibility: visible;
178
+ }
179
+ }
180
+ `;
@@ -0,0 +1,13 @@
1
+ /* eslint-disable no-prototype-builtins */
2
+ export const replace = (template, data) => template.replace(/{(\w*)}/g, (m, key) => data.hasOwnProperty(key) ? data[key] : '');
3
+ export const translate = (translations, key, locale, fallbackLocale = 'en', data = {}) => {
4
+ if (!translations[locale] || !translations[locale][key]) {
5
+ console.warn(`Warning: no ${key} translation of ${locale}`);
6
+ if (fallbackLocale && translations[fallbackLocale]?.[key]) {
7
+ return replace(translations[fallbackLocale]?.[key], data);
8
+ }
9
+ return key;
10
+ }
11
+ return replace(translations[locale][key], data);
12
+ };
13
+ export const t = translate;
@@ -0,0 +1,3 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="99" height="18" viewBox="0 0 99 18">
2
+ <path fill="#000" fill-rule="evenodd" d="M6.5.053h2.864L16.028 18h-2.114l-1.391-3.795H3.504L2.14 18H0L6.5.053zm1.474 1.481L4.04 12.563h7.895L7.975 1.534zm14.44 3.542c1.27 0 2.198.296 2.78.892.58.597.871 1.52.871 2.765v.36c0 .117-.008.245-.026.385h-1.826c.018-.14.027-.292.027-.452v-.48c0-.766-.186-1.283-.551-1.55-.367-.266-.916-.4-1.65-.4-.968 0-1.698.24-2.189.723-.493.48-.738 1.208-.738 2.187v8.308h-1.88V5.341h1.824l-.079 1.443c.376-.614.863-1.053 1.463-1.316a4.868 4.868 0 0 1 1.974-.392zM35.95 15.903c.501-.328.752-1.205.752-2.63h1.852c0 1.924-.403 3.178-1.208 3.765-.806.589-2.158.882-4.055.882-2.65 0-4.24-.538-4.766-1.616-.529-1.076-.793-2.781-.793-5.114 0-2.118.367-3.645 1.102-4.581.732-.934 2.209-1.401 4.43-1.401 1.378 0 2.569.221 3.572.665 1.002.446 1.503 1.497 1.503 3.153v.188a.234.234 0 0 0-.027.106v.106h-1.826c0-1.12-.228-1.851-.685-2.188-.455-.34-1.23-.507-2.322-.507-1.665 0-2.713.259-3.142.782-.43.524-.646 1.67-.646 3.44V12.2c0 1.4.161 2.448.485 3.15.322.7 1.297 1.048 2.926 1.048 1.397 0 2.346-.165 2.848-.495zm15.87-.318c.606-.328.912-1.263.912-2.805 0-.924-.147-1.69-.444-2.302-.294-.611-1.007-.917-2.133-.917H43.065v6.516h5.528c1.543 0 2.617-.165 3.226-.492zm-8.754-13.85v6.036h5.665c1.325 0 2.239-.214 2.737-.643.503-.428.755-1.288.755-2.575 0-1.09-.192-1.834-.577-2.226-.385-.394-1.116-.591-2.19-.591h-6.39zM52 8.466c1.185.322 1.956.816 2.314 1.482.359.67.54 1.581.54 2.739 0 1.6-.325 2.858-.97 3.764-.647.909-1.874 1.363-3.686 1.363H41.05V0h8.62c1.592 0 2.759.312 3.503.934.744.624 1.115 1.78 1.115 3.473 0 1.014-.129 1.855-.386 2.522-.258.669-.89 1.181-1.903 1.536zm5.43 9.348V.001h1.907v17.812H57.43zm13.374-6.168v-.708c0-1.539-.141-2.636-.426-3.297-.284-.658-1.191-.99-2.718-.99h-.401c-1.617 0-2.625.25-3.025.75-.399.5-.599 1.632-.599 3.4V12.822c0 .206.008.407.024.602a9.48 9.48 0 0 0 .216 1.474c.106.465.275.822.505 1.072.196.179.435.302.72.373.283.072.586.116.905.135h1.254c1.083 0 1.914-.151 2.492-.456.577-.302.9-1.043.972-2.22a18.338 18.338 0 0 0 .054-1.447c.015-.233.027-.47.027-.71zm-3.786-6.518c2.399 0 3.956.414 4.672 1.243.717.828 1.074 2.418 1.074 4.766 0 2.048-.219 3.704-.657 4.966C71.668 17.367 70.16 18 67.581 18c-2.237 0-3.782-.347-4.632-1.042-.85-.694-1.275-2.205-1.275-4.54v-1.174c0-2.12.318-3.669.954-4.646.635-.98 2.099-1.471 4.39-1.471zm16.434 10.776c.501-.328.752-1.205.752-2.63h1.853c0 1.924-.403 3.178-1.209 3.765-.804.589-2.157.882-4.054.882-2.648 0-4.24-.538-4.767-1.616-.528-1.076-.79-2.781-.79-5.114 0-2.118.365-3.645 1.1-4.581.732-.934 2.21-1.401 4.43-1.401 1.377 0 2.568.221 3.571.665 1.003.446 1.504 1.497 1.504 3.153v.188a.232.232 0 0 0-.026.106v.106H83.99c0-1.12-.229-1.851-.686-2.188-.455-.34-1.23-.507-2.323-.507-1.665 0-2.712.259-3.142.782-.43.524-.643 1.67-.643 3.44V12.2c0 1.4.16 2.448.482 3.15.324.7 1.298 1.048 2.927 1.048 1.397 0 2.346-.165 2.847-.495zm9.236-4.82L99 17.813h-2.47l-5.317-6.01h-.752v6.01h-1.907V0h1.907v10.362h.752l4.512-5.02h2.309l-5.346 5.741z"/>
3
+ </svg>
@@ -0,0 +1,6 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="45" height="52" viewBox="0 0 45 52">
2
+ <g fill="none" fill-rule="evenodd" stroke="#000">
3
+ <path d="M.5 13.077L22.15.577l21.651 12.5v25l-21.65 12.5L.5 38.077zM22.15.577v50M.5 13.077l43.301 25M.5 38.077l43.301-25"/>
4
+ <path d="M22.15 38.077l10.826-6.25-10.825-18.75-10.825 18.75z"/>
5
+ </g>
6
+ </svg>
@@ -0,0 +1,3 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="99" height="18" viewBox="0 0 99 18">
2
+ <path fill="#FFF" fill-rule="evenodd" d="M6.5.053h2.864L16.028 18h-2.114l-1.391-3.795H3.504L2.14 18H0L6.5.053zm1.474 1.481L4.04 12.563h7.895L7.975 1.534zm14.44 3.542c1.27 0 2.198.296 2.78.892.58.597.871 1.52.871 2.765v.36c0 .117-.008.245-.026.385h-1.826c.018-.14.027-.292.027-.452v-.48c0-.766-.186-1.283-.551-1.55-.367-.266-.916-.4-1.65-.4-.968 0-1.698.24-2.189.723-.493.48-.738 1.208-.738 2.187v8.308h-1.88V5.341h1.824l-.079 1.443c.376-.614.863-1.053 1.463-1.316a4.868 4.868 0 0 1 1.974-.392zM35.95 15.903c.501-.328.752-1.205.752-2.63h1.852c0 1.924-.403 3.178-1.208 3.765-.806.589-2.158.882-4.055.882-2.65 0-4.24-.538-4.766-1.616-.529-1.076-.793-2.781-.793-5.114 0-2.118.367-3.645 1.102-4.581.732-.934 2.209-1.401 4.43-1.401 1.378 0 2.569.221 3.572.665 1.002.446 1.503 1.497 1.503 3.153v.188a.234.234 0 0 0-.027.106v.106h-1.826c0-1.12-.228-1.851-.685-2.188-.455-.34-1.23-.507-2.322-.507-1.665 0-2.713.259-3.142.782-.43.524-.646 1.67-.646 3.44V12.2c0 1.4.161 2.448.485 3.15.322.7 1.297 1.048 2.926 1.048 1.397 0 2.346-.165 2.848-.495zm15.87-.318c.606-.328.912-1.263.912-2.805 0-.924-.147-1.69-.444-2.302-.294-.611-1.007-.917-2.133-.917H43.065v6.516h5.528c1.543 0 2.617-.165 3.226-.492zm-8.754-13.85v6.036h5.665c1.325 0 2.239-.214 2.737-.643.503-.428.755-1.288.755-2.575 0-1.09-.192-1.834-.577-2.226-.385-.394-1.116-.591-2.19-.591h-6.39zM52 8.466c1.185.322 1.956.816 2.314 1.482.359.67.54 1.581.54 2.739 0 1.6-.325 2.858-.97 3.764-.647.909-1.874 1.363-3.686 1.363H41.05V0h8.62c1.592 0 2.759.312 3.503.934.744.624 1.115 1.78 1.115 3.473 0 1.014-.129 1.855-.386 2.522-.258.669-.89 1.181-1.903 1.536zm5.43 9.348V.001h1.907v17.812H57.43zm13.374-6.168v-.708c0-1.539-.141-2.636-.426-3.297-.284-.658-1.191-.99-2.718-.99h-.401c-1.617 0-2.625.25-3.025.75-.399.5-.599 1.632-.599 3.4V12.822c0 .206.008.407.024.602a9.48 9.48 0 0 0 .216 1.474c.106.465.275.822.505 1.072.196.179.435.302.72.373.283.072.586.116.905.135h1.254c1.083 0 1.914-.151 2.492-.456.577-.302.9-1.043.972-2.22a18.338 18.338 0 0 0 .054-1.447c.015-.233.027-.47.027-.71zm-3.786-6.518c2.399 0 3.956.414 4.672 1.243.717.828 1.074 2.418 1.074 4.766 0 2.048-.219 3.704-.657 4.966C71.668 17.367 70.16 18 67.581 18c-2.237 0-3.782-.347-4.632-1.042-.85-.694-1.275-2.205-1.275-4.54v-1.174c0-2.12.318-3.669.954-4.646.635-.98 2.099-1.471 4.39-1.471zm16.434 10.776c.501-.328.752-1.205.752-2.63h1.853c0 1.924-.403 3.178-1.209 3.765-.804.589-2.157.882-4.054.882-2.648 0-4.24-.538-4.767-1.616-.528-1.076-.79-2.781-.79-5.114 0-2.118.365-3.645 1.1-4.581.732-.934 2.21-1.401 4.43-1.401 1.377 0 2.568.221 3.571.665 1.003.446 1.504 1.497 1.504 3.153v.188a.232.232 0 0 0-.026.106v.106H83.99c0-1.12-.229-1.851-.686-2.188-.455-.34-1.23-.507-2.323-.507-1.665 0-2.712.259-3.142.782-.43.524-.643 1.67-.643 3.44V12.2c0 1.4.16 2.448.482 3.15.324.7 1.298 1.048 2.927 1.048 1.397 0 2.346-.165 2.847-.495zm9.236-4.82L99 17.813h-2.47l-5.317-6.01h-.752v6.01h-1.907V0h1.907v10.362h.752l4.512-5.02h2.309l-5.346 5.741z"/>
3
+ </svg>
@@ -0,0 +1,6 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="45" height="52" viewBox="0 0 45 52">
2
+ <g fill="none" fill-rule="evenodd" stroke="#FFF">
3
+ <path d="M.5 13.077L22.15.577l21.651 12.5v25l-21.65 12.5L.5 38.077zM22.15.577v50M.5 13.077l43.301 25M.5 38.077l43.301-25"/>
4
+ <path d="M22.15 38.077l10.826-6.25-10.825-18.75-10.825 18.75z"/>
5
+ </g>
6
+ </svg>
@@ -0,0 +1,136 @@
1
+ import React from "react";
2
+ import PropTypes from 'prop-types';
3
+ import { styled } from '../Theme';
4
+ import { jsx as _jsx } from "react/jsx-runtime";
5
+ import { jsxs as _jsxs } from "react/jsx-runtime";
6
+ var LightLogo = function LightLogo(props) {
7
+ return /*#__PURE__*/_jsx("svg", {
8
+ ...props,
9
+ children: /*#__PURE__*/_jsxs("g", {
10
+ fill: "none",
11
+ fillRule: "evenodd",
12
+ stroke: "#FFF",
13
+ children: [/*#__PURE__*/_jsx("path", {
14
+ d: "M.5 13.077L22.15.577l21.651 12.5v25l-21.65 12.5L.5 38.077zM22.15.577v50M.5 13.077l43.301 25m-43.301 0l43.301-25"
15
+ }), /*#__PURE__*/_jsx("path", {
16
+ d: "M22.15 38.077l10.826-6.25-10.825-18.75-10.825 18.75z"
17
+ })]
18
+ })
19
+ });
20
+ };
21
+ LightLogo.defaultProps = {
22
+ xmlns: "http://www.w3.org/2000/svg",
23
+ width: "45",
24
+ height: "52",
25
+ viewBox: "0 0 45 52"
26
+ };
27
+ var LightText = function LightText(props) {
28
+ return /*#__PURE__*/_jsx("svg", {
29
+ ...props,
30
+ children: /*#__PURE__*/_jsx("path", {
31
+ fill: "#FFF",
32
+ fillRule: "evenodd",
33
+ d: "M6.5.053h2.864L16.028 18h-2.114l-1.391-3.795H3.504L2.14 18H0L6.5.053zm1.474 1.481L4.04 12.563h7.895L7.975 1.534zm14.44 3.542c1.27 0 2.198.296 2.78.892.58.597.871 1.52.871 2.765v.36c0 .117-.008.245-.026.385h-1.826c.018-.14.027-.292.027-.452v-.48c0-.766-.186-1.283-.551-1.55-.367-.266-.916-.4-1.65-.4-.968 0-1.698.24-2.189.723-.493.48-.738 1.208-.738 2.187v8.308h-1.88V5.341h1.824l-.079 1.443c.376-.614.863-1.053 1.463-1.316a4.868 4.868 0 0 1 1.974-.392zM35.95 15.903c.501-.328.752-1.205.752-2.63h1.852c0 1.924-.403 3.178-1.208 3.765-.806.589-2.158.882-4.055.882-2.65 0-4.24-.538-4.766-1.616-.529-1.076-.793-2.781-.793-5.114 0-2.118.367-3.645 1.102-4.581.732-.934 2.209-1.401 4.43-1.401 1.378 0 2.569.221 3.572.665 1.002.446 1.503 1.497 1.503 3.153v.188a.234.234 0 0 0-.027.106v.106h-1.826c0-1.12-.228-1.851-.685-2.188-.455-.34-1.23-.507-2.322-.507-1.665 0-2.713.259-3.142.782-.43.524-.646 1.67-.646 3.44V12.2c0 1.4.161 2.448.485 3.15.322.7 1.297 1.048 2.926 1.048 1.397 0 2.346-.165 2.848-.495zm15.87-.318c.606-.328.912-1.263.912-2.805 0-.924-.147-1.69-.444-2.302-.294-.611-1.007-.917-2.133-.917h-7.09v6.516h5.528c1.543 0 2.617-.165 3.226-.492zm-8.754-13.85v6.036h5.665c1.325 0 2.239-.214 2.737-.643.503-.428.755-1.288.755-2.575 0-1.09-.192-1.834-.577-2.226-.385-.394-1.116-.591-2.19-.591h-6.39zM52 8.466c1.185.322 1.956.816 2.314 1.482.359.67.54 1.581.54 2.739 0 1.6-.325 2.858-.97 3.764-.647.909-1.874 1.363-3.686 1.363H41.05V0h8.62c1.592 0 2.759.312 3.503.934.744.624 1.115 1.78 1.115 3.473 0 1.014-.129 1.855-.386 2.522-.258.669-.89 1.181-1.903 1.536zm5.43 9.348V.001h1.907v17.812H57.43zm13.374-6.168v-.708c0-1.539-.141-2.636-.426-3.297-.284-.658-1.191-.99-2.718-.99h-.401c-1.617 0-2.625.25-3.025.75-.399.5-.599 1.632-.599 3.4v2.021c0 .206.008.407.024.602a9.48 9.48 0 0 0 .216 1.474c.106.465.275.822.505 1.072.196.179.435.302.72.373.283.072.586.116.905.135h1.254c1.083 0 1.914-.151 2.492-.456.577-.302.9-1.043.972-2.22a18.338 18.338 0 0 0 .054-1.447c.015-.233.027-.47.027-.71zm-3.786-6.518c2.399 0 3.956.414 4.672 1.243.717.828 1.074 2.418 1.074 4.766 0 2.048-.219 3.704-.657 4.966C71.668 17.367 70.16 18 67.581 18c-2.237 0-3.782-.347-4.632-1.042-.85-.694-1.275-2.205-1.275-4.54v-1.174c0-2.12.318-3.669.954-4.646.635-.98 2.099-1.471 4.39-1.471zm16.434 10.776c.501-.328.752-1.205.752-2.63h1.853c0 1.924-.403 3.178-1.209 3.765-.804.589-2.157.882-4.054.882-2.648 0-4.24-.538-4.767-1.616-.528-1.076-.79-2.781-.79-5.114 0-2.118.365-3.645 1.1-4.581.732-.934 2.21-1.401 4.43-1.401 1.377 0 2.568.221 3.571.665 1.003.446 1.504 1.497 1.504 3.153v.188a.232.232 0 0 0-.026.106v.106H83.99c0-1.12-.229-1.851-.686-2.188-.455-.34-1.23-.507-2.323-.507-1.665 0-2.712.259-3.142.782-.43.524-.643 1.67-.643 3.44V12.2c0 1.4.16 2.448.482 3.15.324.7 1.298 1.048 2.927 1.048 1.397 0 2.346-.165 2.847-.495zm9.236-4.82L99 17.813h-2.47l-5.317-6.01h-.752v6.01h-1.907V0h1.907v10.362h.752l4.512-5.02h2.309l-5.346 5.741z"
34
+ })
35
+ });
36
+ };
37
+ LightText.defaultProps = {
38
+ xmlns: "http://www.w3.org/2000/svg",
39
+ width: "99",
40
+ height: "18",
41
+ viewBox: "0 0 99 18"
42
+ };
43
+ var DarkLogo = function DarkLogo(props) {
44
+ return /*#__PURE__*/_jsx("svg", {
45
+ ...props,
46
+ children: /*#__PURE__*/_jsxs("g", {
47
+ fill: "none",
48
+ fillRule: "evenodd",
49
+ stroke: "#000",
50
+ children: [/*#__PURE__*/_jsx("path", {
51
+ d: "M.5 13.077L22.15.577l21.651 12.5v25l-21.65 12.5L.5 38.077zM22.15.577v50M.5 13.077l43.301 25m-43.301 0l43.301-25"
52
+ }), /*#__PURE__*/_jsx("path", {
53
+ d: "M22.15 38.077l10.826-6.25-10.825-18.75-10.825 18.75z"
54
+ })]
55
+ })
56
+ });
57
+ };
58
+ DarkLogo.defaultProps = {
59
+ xmlns: "http://www.w3.org/2000/svg",
60
+ width: "45",
61
+ height: "52",
62
+ viewBox: "0 0 45 52"
63
+ };
64
+ var DarkText = function DarkText(props) {
65
+ return /*#__PURE__*/_jsx("svg", {
66
+ ...props,
67
+ children: /*#__PURE__*/_jsx("path", {
68
+ fillRule: "evenodd",
69
+ d: "M6.5.053h2.864L16.028 18h-2.114l-1.391-3.795H3.504L2.14 18H0L6.5.053zm1.474 1.481L4.04 12.563h7.895L7.975 1.534zm14.44 3.542c1.27 0 2.198.296 2.78.892.58.597.871 1.52.871 2.765v.36c0 .117-.008.245-.026.385h-1.826c.018-.14.027-.292.027-.452v-.48c0-.766-.186-1.283-.551-1.55-.367-.266-.916-.4-1.65-.4-.968 0-1.698.24-2.189.723-.493.48-.738 1.208-.738 2.187v8.308h-1.88V5.341h1.824l-.079 1.443c.376-.614.863-1.053 1.463-1.316a4.868 4.868 0 0 1 1.974-.392zM35.95 15.903c.501-.328.752-1.205.752-2.63h1.852c0 1.924-.403 3.178-1.208 3.765-.806.589-2.158.882-4.055.882-2.65 0-4.24-.538-4.766-1.616-.529-1.076-.793-2.781-.793-5.114 0-2.118.367-3.645 1.102-4.581.732-.934 2.209-1.401 4.43-1.401 1.378 0 2.569.221 3.572.665 1.002.446 1.503 1.497 1.503 3.153v.188a.234.234 0 0 0-.027.106v.106h-1.826c0-1.12-.228-1.851-.685-2.188-.455-.34-1.23-.507-2.322-.507-1.665 0-2.713.259-3.142.782-.43.524-.646 1.67-.646 3.44V12.2c0 1.4.161 2.448.485 3.15.322.7 1.297 1.048 2.926 1.048 1.397 0 2.346-.165 2.848-.495zm15.87-.318c.606-.328.912-1.263.912-2.805 0-.924-.147-1.69-.444-2.302-.294-.611-1.007-.917-2.133-.917h-7.09v6.516h5.528c1.543 0 2.617-.165 3.226-.492zm-8.754-13.85v6.036h5.665c1.325 0 2.239-.214 2.737-.643.503-.428.755-1.288.755-2.575 0-1.09-.192-1.834-.577-2.226-.385-.394-1.116-.591-2.19-.591h-6.39zM52 8.466c1.185.322 1.956.816 2.314 1.482.359.67.54 1.581.54 2.739 0 1.6-.325 2.858-.97 3.764-.647.909-1.874 1.363-3.686 1.363H41.05V0h8.62c1.592 0 2.759.312 3.503.934.744.624 1.115 1.78 1.115 3.473 0 1.014-.129 1.855-.386 2.522-.258.669-.89 1.181-1.903 1.536zm5.43 9.348V.001h1.907v17.812H57.43zm13.374-6.168v-.708c0-1.539-.141-2.636-.426-3.297-.284-.658-1.191-.99-2.718-.99h-.401c-1.617 0-2.625.25-3.025.75-.399.5-.599 1.632-.599 3.4v2.021c0 .206.008.407.024.602a9.48 9.48 0 0 0 .216 1.474c.106.465.275.822.505 1.072.196.179.435.302.72.373.283.072.586.116.905.135h1.254c1.083 0 1.914-.151 2.492-.456.577-.302.9-1.043.972-2.22a18.338 18.338 0 0 0 .054-1.447c.015-.233.027-.47.027-.71zm-3.786-6.518c2.399 0 3.956.414 4.672 1.243.717.828 1.074 2.418 1.074 4.766 0 2.048-.219 3.704-.657 4.966C71.668 17.367 70.16 18 67.581 18c-2.237 0-3.782-.347-4.632-1.042-.85-.694-1.275-2.205-1.275-4.54v-1.174c0-2.12.318-3.669.954-4.646.635-.98 2.099-1.471 4.39-1.471zm16.434 10.776c.501-.328.752-1.205.752-2.63h1.853c0 1.924-.403 3.178-1.209 3.765-.804.589-2.157.882-4.054.882-2.648 0-4.24-.538-4.767-1.616-.528-1.076-.79-2.781-.79-5.114 0-2.118.365-3.645 1.1-4.581.732-.934 2.21-1.401 4.43-1.401 1.377 0 2.568.221 3.571.665 1.003.446 1.504 1.497 1.504 3.153v.188a.232.232 0 0 0-.026.106v.106H83.99c0-1.12-.229-1.851-.686-2.188-.455-.34-1.23-.507-2.323-.507-1.665 0-2.712.259-3.142.782-.43.524-.643 1.67-.643 3.44V12.2c0 1.4.16 2.448.482 3.15.324.7 1.298 1.048 2.927 1.048 1.397 0 2.346-.165 2.847-.495zm9.236-4.82L99 17.813h-2.47l-5.317-6.01h-.752v6.01h-1.907V0h1.907v10.362h.752l4.512-5.02h2.309l-5.346 5.741z"
70
+ })
71
+ });
72
+ };
73
+ DarkText.defaultProps = {
74
+ xmlns: "http://www.w3.org/2000/svg",
75
+ width: "99",
76
+ height: "18",
77
+ viewBox: "0 0 99 18"
78
+ };
79
+ /**
80
+ @typedef {import('react').HTMLAttributes<HTMLSpanElement> & {
81
+ mode?: 'light' | 'dark',
82
+ layout?: 'vertical' | 'horizontal',
83
+ showText?: boolean,
84
+ showLogo?: boolean,
85
+ }} LogoProps
86
+ */
87
+ /**
88
+ * @description
89
+ * @export
90
+ * @param {LogoProps} props
91
+ * @return {React.ReactComponentElement}
92
+ */
93
+ export default function Logo({
94
+ showText,
95
+ showLogo,
96
+ mode,
97
+ layout,
98
+ ...rest
99
+ }) {
100
+ const logo = mode === 'light' ? /*#__PURE__*/_jsx(LightLogo, {}) : /*#__PURE__*/_jsx(DarkLogo, {});
101
+ const text = mode === 'light' ? /*#__PURE__*/_jsx(LightText, {
102
+ className: "logo-text"
103
+ }) : /*#__PURE__*/_jsx(DarkText, {
104
+ className: "logo-text"
105
+ });
106
+ return /*#__PURE__*/_jsxs(Container, {
107
+ layout: layout,
108
+ ...rest,
109
+ children: [showLogo && logo, showText && text]
110
+ });
111
+ }
112
+ Logo.propTypes = {
113
+ mode: PropTypes.oneOf(['light', 'dark']),
114
+ layout: PropTypes.oneOf(['vertical', 'horizontal']),
115
+ showText: PropTypes.bool,
116
+ showLogo: PropTypes.bool
117
+ };
118
+ Logo.defaultProps = {
119
+ mode: 'dark',
120
+ layout: 'vertical',
121
+ showText: true,
122
+ showLogo: true
123
+ };
124
+
125
+ /** @type {import('@emotion/styled').StyledComponent<HTMLSpanElement, {}, { ref?: React.Ref<any> | undefined;}>} */
126
+ const Container = styled('span')`
127
+ display: inline-flex;
128
+ flex-direction: ${props => props.layout === 'horizontal' ? 'row' : 'column'};
129
+ justify-content: center;
130
+ align-items: center;
131
+
132
+ .logo-text {
133
+ ${props => props.layout === 'vertical' ? 'margin-top: 8px;' : ''}
134
+ ${props => props.layout === 'vertical' ? '' : 'margin-left: 8px;'};
135
+ }
136
+ `;
@@ -0,0 +1,132 @@
1
+ /* eslint-disable react/no-danger */
2
+ import PropTypes from 'prop-types';
3
+ import ImageIcon from '../Icon/image';
4
+ import { styled } from '../Theme';
5
+ import { jsx as _jsx } from "react/jsx-runtime";
6
+ import { jsxs as _jsxs } from "react/jsx-runtime";
7
+ import { Fragment as _Fragment } from "react/jsx-runtime";
8
+ export default function Metric({
9
+ icon,
10
+ value,
11
+ name,
12
+ url,
13
+ animated,
14
+ LinkComponent,
15
+ prefix
16
+ }) {
17
+ const metric = /*#__PURE__*/_jsxs(_Fragment, {
18
+ children: [/*#__PURE__*/_jsx("div", {
19
+ className: "metric__image",
20
+ children: /*#__PURE__*/_jsx(ImageIcon, {
21
+ name: icon,
22
+ alt: typeof name === 'string' ? name : '',
23
+ size: 30,
24
+ prefix: prefix,
25
+ color: "#222222"
26
+ })
27
+ }), /*#__PURE__*/_jsxs("div", {
28
+ children: [/*#__PURE__*/_jsx("div", {
29
+ className: `metric__number ${animated ? 'metric__number--animated' : ''}`,
30
+ dangerouslySetInnerHTML: {
31
+ __html: value
32
+ }
33
+ }), /*#__PURE__*/_jsx("div", {
34
+ className: "metric__name",
35
+ children: name
36
+ })]
37
+ })]
38
+ });
39
+ return /*#__PURE__*/_jsx(Container, {
40
+ children: url ? /*#__PURE__*/_jsx(LinkComponent, {
41
+ to: url,
42
+ children: metric
43
+ }) : metric
44
+ });
45
+ }
46
+ Metric.propTypes = {
47
+ icon: PropTypes.string.isRequired,
48
+ value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
49
+ name: PropTypes.node.isRequired,
50
+ animated: PropTypes.bool,
51
+ url: PropTypes.string,
52
+ LinkComponent: PropTypes.any,
53
+ prefix: PropTypes.string
54
+ };
55
+ Metric.defaultProps = {
56
+ animated: false,
57
+ url: '',
58
+ LinkComponent: null,
59
+ prefix: '/images'
60
+ };
61
+ const Container = styled('div')`
62
+ border-left: 1px solid ${props => props.theme.typography.color.main};
63
+ padding: 10px 0 10px 16px;
64
+ @media (max-width: ${props => props.theme.breakpoints.values.sm}px) {
65
+ padding: 0 0 0 8px;
66
+ }
67
+
68
+ display: flex;
69
+ justify-items: center;
70
+ align-items: flex-start;
71
+
72
+ a {
73
+ display: flex;
74
+ justify-items: center;
75
+ align-items: flex-start;
76
+ }
77
+
78
+ .metric__image {
79
+ margin-right: 8px;
80
+ }
81
+
82
+ .metric__number {
83
+ margin-bottom: 8px;
84
+ font-size: ${props => props.size === 'small' ? 32 : 36}px;
85
+ font-weight: 600;
86
+ line-height: 36px;
87
+ color: ${props => props.theme.typography.color.main};
88
+
89
+ small {
90
+ font-size: 12px;
91
+ line-height: 12px;
92
+ }
93
+
94
+ @media (max-width: ${props => props.theme.breakpoints.values.sm}px) {
95
+ font-size: ${props => props.size === 'small' ? 24 : 28}px;
96
+ line-height: ${props => props.size === 'small' ? 24 : 28}px;
97
+ margin-bottom: 2px;
98
+ }
99
+ }
100
+
101
+ .metric__number--animated {
102
+ animation-name: blink-opacity;
103
+ animation-duration: 250ms;
104
+ animation-timing-function: linear;
105
+ animation-iteration-count: 1;
106
+ background-color: transparent !important;
107
+ }
108
+
109
+ .metric__name {
110
+ font-size: 14px;
111
+ text-transform: capitalize;
112
+ line-height: 1.2;
113
+ font-weight: 500;
114
+ color: ${props => props.theme.typography.color.main};
115
+ @media (max-width: ${props => props.theme.breakpoints.values.sm}px) {
116
+ font-size: 10px;
117
+ line-height: 1;
118
+ }
119
+ }
120
+
121
+ @keyframes blink-opacity {
122
+ 0% {
123
+ opacity: 1;
124
+ }
125
+ 50% {
126
+ opacity: 0.3;
127
+ }
128
+ 100% {
129
+ opacity: 1;
130
+ }
131
+ }
132
+ `;
@@ -0,0 +1,59 @@
1
+ # NFTDisplay
2
+
3
+ ## 01 使用
4
+
5
+ ### 01.01 默认样式
6
+
7
+ NFTDisplay 组件默认尺寸为 *150x150*, 可以通过 css 设置 width/height. 固定尺寸的使用场景感觉比较少, 多数情况应该都需要将 NFTDisplay 应用于响应式布局中.
8
+
9
+ ### 01.02 aspect ratio
10
+
11
+ 可以使用 aspect prop 设置 NFTDisplay 的宽高比, NFTDisplay 包裹一两层 div/span 标签 (用来控制布局, 没有直接把 img 标签渲染出来), 所以这里说的长宽比指的不是 img 的长宽比, 图片的尺寸大小不一, 长宽比也是既定的, aspect prop 控制的是包裹 img 容器的长宽比.
12
+
13
+ NFTDisplay 宽高比的计算是根据父容器的 width 来确定的 (NFTDisplay 会填充整个宽度), 所以可以通过控制父容器的 width 来控制 NFTDisplay 的大小.
14
+
15
+ ### 01.03 inset
16
+
17
+ inset 设置为 true 时 NFTDisplay 会镶嵌/填满父容器 (并垂直+水平居中显示图片), 所以父容器必须有明确的宽高 (尤其是高度). 响应式布局中应该会比较常用.
18
+
19
+ 注: inset 比 aspect ratio 优先级高, 如果同时设置了 inset 和 aspect, 则后者不生效.
20
+
21
+ ### 01.04 asset data (prop)
22
+
23
+ 可以为 asset data prop 传入 raw data 或 parsed data, 避免多次解析 asset data.
24
+
25
+ ### 01.05 broken image & error handling
26
+
27
+ * display 加载失败时会显示一个 broken-image, 可以从外部覆盖 `.nft-display--broken` 的样式来调整尺寸/颜色等样式
28
+ * error handling, 这部分感觉出错原因可能性会很多, 有 json 解析错误、某字段缺失、某 object 指定路径的值缺失、nft type 不支持等等, 暂时没想到如何更合理的捕获和处理这些错误.
29
+
30
+ ### 02 svg 加载
31
+
32
+ 基于 `img` 标签加载 NFT Display. 几种 nft type 的加载:
33
+
34
+ - url
35
+ 直接使用 `<img>`
36
+ - svg_gzipped
37
+ content => ungzip => svgToImgUrl => `<img>`
38
+ - svg (未测试, 需要测试数据)
39
+ content => svgToImgUrl => `<img>`
40
+ - html (TODO)
41
+ 基于 `<img>` 的加载方式不适用, 目前没有发现这种 nft type 的测试数据
42
+
43
+ 基于 `<img>` 标签的加载方式没有样式污染问题, 加载、尺寸控制也比较方便, 不过据说有些情况下 svg 可能无法正确显示 (比如 svg 加载了 font|image 资源), 目前没有发现问题, 还需要更多的观察
44
+
45
+ ## 03 iframe 第三方嵌入 (TODO)
46
+
47
+ 需要设计 iframe 的 API (iframe#src 查询参数), 目前想到的参数:
48
+
49
+ - address : asset address
50
+ 调用 getAssetState 接口获取 display 数据进行展示
51
+ - 样式控制相关的参数 ?
52
+
53
+ ## 04 参考
54
+
55
+ * [提供一个 NFT display 组件 · Issue #199 · ArcBlock/ux](https://github.com/ArcBlock/ux/issues/199)
56
+ * [2021徽章出现奇怪的渲染 · Issue #230 · blocklet/nft-marketplace](https://github.com/blocklet/nft-marketplace/issues/230)
57
+ * [Adding vector graphics to the Web - Learn web development | MDN](https://developer.mozilla.org/en-US/docs/Learn/HTML/Multimedia_and_embedding/Adding_vector_graphics_to_the_Web)
58
+ * [The Best Way to Embed SVG on HTML (2021)](https://vecta.io/blog/best-way-to-embed-svg)
59
+ * [javascript - Do I always need to call URL.revokeObjectURL() explicitly? - Stack Overflow](https://stackoverflow.com/questions/49209756/do-i-always-need-to-call-url-revokeobjecturl-explicitly)
@@ -0,0 +1,39 @@
1
+ import PropTypes from 'prop-types';
2
+ import { styled } from '../Theme';
3
+ import { jsx as _jsx } from "react/jsx-runtime";
4
+ function AspectRatioContainer({
5
+ aspect,
6
+ children,
7
+ ...rest
8
+ }) {
9
+ return /*#__PURE__*/_jsx(Root, {
10
+ aspect: aspect,
11
+ ...rest,
12
+ children: /*#__PURE__*/_jsx("span", {
13
+ className: "aspect-ratio-container__inner",
14
+ children: children
15
+ })
16
+ });
17
+ }
18
+ AspectRatioContainer.propTypes = {
19
+ aspect: PropTypes.number.isRequired,
20
+ children: PropTypes.node.isRequired
21
+ };
22
+ const Root = styled('span')`
23
+ display: block;
24
+ position: relative;
25
+ width: 100%;
26
+ height: 0;
27
+ padding-bottom: ${({
28
+ aspect
29
+ }) => 1 / aspect * 100}%;
30
+
31
+ .aspect-ratio-container__inner {
32
+ position: absolute;
33
+ top: 0;
34
+ bottom: 0;
35
+ left: 0;
36
+ right: 0;
37
+ }
38
+ `;
39
+ export default AspectRatioContainer;
@@ -0,0 +1,18 @@
1
+ import BrokenImage from '@mui/icons-material/BrokenImage';
2
+ import { styled } from '../Theme';
3
+ import { jsx as _jsx } from "react/jsx-runtime";
4
+ export default function Broken() {
5
+ return /*#__PURE__*/_jsx(Root, {
6
+ className: "nft-display-broken"
7
+ });
8
+ }
9
+ const Root = styled(BrokenImage)`
10
+ && {
11
+ width: 100%;
12
+ max-width: 200px;
13
+ height: auto;
14
+ max-width: 100%;
15
+ max-height: 100%;
16
+ fill: #ddd;
17
+ }
18
+ `;
@@ -0,0 +1,7 @@
1
+ {
2
+ "address": "zjdoYZePuT84nbvNkVtwgzxeXWYaAn5wojay",
3
+ "display": {
4
+ "content": "http://ffd25853-znkjt5vbgnezh4p6v4dsaye61e7pxxn3vk4j.did.abtnet.io/uploads/tIfhUg4OKbi786Y-uT4rG.png",
5
+ "type": "url"
6
+ }
7
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "address": "zjdpnLYRLWGyzcaHjet5gKBGuGHoDqxT9YUt",
3
+ "moniker": "Badge ",
4
+ "owner": "zNKeLKixvCM32TkVM1zmRDdAU3bvm3dTtAcM",
5
+ "context": {},
6
+ "data": {
7
+ "typeUrl": "vc",
8
+ "value": "{\"proof\":{\"type\":\"Ed25519Signature\",\"created\":\"2021-07-12T07:56:32.514Z\",\"proofPurpose\":\"assertionMethod\",\"jws\":\"euS8o6b82U7x8Y609tHkLmnGIxWbk8gkyb6f3XFxlksmoMqCxRNHTAlJMYTXIyQmhmMGTjuxGWdrnyUoOCrZCQ\"},\"@context\":\"https://schema.arcblock.io/v0.1/context.jsonld\",\"id\":\"z2iU9z8uGuoHBy52c2YW8QkYDRzTvdzbuP7Nz\",\"type\":[\"NFTBadge\",\"VerifiableCredential\"],\"issuer\":{\"id\":\"zNKeLKixvCM32TkVM1zmRDdAU3bvm3dTtAcM\",\"pk\":\"zGph57aL5bz85oMuY9nW2PFjPTa9FvSGvS761TJk15XWe\",\"name\":\"ArcBlock\"},\"issuanceDate\":\"2021-07-12T07:56:32.514Z\",\"credentialSubject\":{\"id\":\"z1cbNRZHrCdH3C2Q7ML2sAKFhB88Ptfh7Et\",\"name\":\"Badge \",\"description\":\"This is a test badge that is on local chain\",\"display\":{\"type\":\"svg_gzipped\",\"content\":\"H4sIAAAAAAAA/7VX227jNhB9br9CUF8pmndSTpyFItvoQ/oNhVdRYzVa25BUO95F/71DitTaDVtsgCSBRfnw8MzMGeri208vX9rkWHd9s98tUopJmny6u+2PT0nzuEgfNue6+52mST+c23qR1rvN57bOPm+q56du/9fucb6rTwmBf8qM/dykl2Kw8NjUp/v9yyK9IKUJBJ33h00Fkoeu7uvuWDtw1y/S7TAc5rPZ6XTCJ4733dOMEUJmkJKnzF/aZvccI9I8z2duNoUabMrJcD5AkKF+GWZV36d3P/+E+4F8+6Np2/kv3DCl+c3fDqQeFJoTQzzIPEiIvi+VB7kHl0IUeWAKDxaa5ZOm9OCayiJfeVB920PpzXCeEyxuvH5ZrFfGE/QFQd5EUjXfIqvyAN7nZDkVRS60+Ki12+/qm37o9s81ZOb+/Nfs1DwO2zkLX8HJutoc5q7Vl+Cf+2Z3jX5phrprGxjmNFhCg6VmLc09C2jwVK1EWUzcYOqaa1ksAxpcXa+XK54HdLJ1VSo+6aqA5oUWwWyqQ7MKVbBJNziYr5bLvAjoZCEpWRGiMTKhhTRlQENthOtShR6wUFtelGR5H9CpttFsj4qL1rBYm5mM7JTr7Xm5l2hUw9f/r6Y7N6+aDl17n64zE4s49uQqonivgHks4Lg1PiQgJ5GAfnd8yIXEaSSgv/tcBeTvFZBFK3T3wOsKMRPfd1JUise6M94P35B7VDpyBV2F8VfCx/RE/mBd/x8wKq1+8Ap6t1riN4m3Phmi0iZyD5vuULcz95S+u62aroKnddVuengFgCd0mlTw0qAEjOdx7GAg6ew1l0a50nG7uhoumDJNtnXztB0WKQOaK2qRcjgFAaHT5Oy+xYKI6yhauSicYxmlyyidacws/bAZthdkmISXrd+4xhppjU1FMioRhYsrsyuQPbizisJTHBFEc0AlsBnHBlGBaWkEFkhKOGiJhAFYCTcmSSnyEeHKwnQctaoIEqBBQcvqcVhLOUhxgxUyEg4uI0Pt0pDb1ze4wxhWkS6o713g/9UE89omxkeboC4olrUK55CzqiiC1yRkzbLmsIxi2cKBZ5ByC1VkYEpFsIFpA1SRjVQDo2gtCci0zaD8TCdJBVMyoxmzH9AlbgZpxwSvaGXpoGMDKQCU07Va1jFpNSE4AraVYnYJogiaCGfywSf/9XV5vjroDbSeYPUAXeNyy8mDgqYgUUrYa9AwOBVwYmkTNyInvFkUXBK2Pmo3CDNelukW0oEK8yCvGNQnEAzcDn5dRJl6aUPsOvKr0DivrKmIgFU5VG/cCJ8jOEBhNzPng4ORn9pyBlNulYWQ22Tj9BEWwa41AsFOZMhYkiDIx4tlNCZkE4GN6joIuRAIZNs9jlMubnKEkZ8ac3ETaISFH30ulcVl5vGw1FUeSUf6dHz/WriQwWmwv8pMBp5mVGfKQgo2jwqddkL2Z87dP93PaliVDQAA\"}},\"signature\":\"z5m2NgRF3gnew9o6vqwCdgsYYN8qTszf6g8fF27QoUmnNWEHuUiLyUCDNS8TFDETq9n2SNac25vUmPrt3LKJwdF7R\"}"
9
+ }
10
+ }