@arcblock/ux 1.16.17 → 1.16.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/Blocklet/index.js +2 -1
- package/lib/NFTDisplay/index.js +29 -3
- package/package.json +4 -4
- package/src/Blocklet/index.js +49 -19
- package/src/NFTDisplay/index.js +24 -3
package/lib/Blocklet/index.js
CHANGED
|
@@ -44,7 +44,7 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
44
44
|
const Div = _styledComponents.default.div.withConfig({
|
|
45
45
|
displayName: "Blocklet__Div",
|
|
46
46
|
componentId: "sc-3dga5l-0"
|
|
47
|
-
})(["&.arcblock-blocklet{border:1px solid #f2f2f2;padding:0 16px;border-radius:12px;background
|
|
47
|
+
})(["&.arcblock-blocklet{border:1px solid #f2f2f2;padding:0 16px;border-radius:12px;background:", ";overflow:hidden;&:hover{filter:drop-shadow(0px 4px 12px rgba(92,92,92,0.04));}}.arcblock-blocklet__content{padding:16px 0;}.arcblock-blocklet__content--main{display:flex;align-items:center;cursor:pointer;}.arcblock-blocklet__content--body{overflow:hidden;flex:1;display:flex;align-items:flex-start;}.arcblock-blocklet__addons{padding:16px 0;border-top:1px solid #f2f2f2;}.arcblock-blocklet__cover{width:100px;height:100px;margin-right:16px;overflow:hidden;border-radius:12px;}.arcblock-blocklet__info{flex:1;overflow:hidden;.arcblock-blocklet__button{margin-top:16px;display:inline-block;.button_custom{&:not(.Mui-disabled){position:relative;z-index:1;&::before{content:'';border-radius:100vw;position:absolute;height:100%;width:100%;left:0;top:0;transition:opacity 0.3s;}&:hover::before{opacity:0;}&::after{content:'';position:absolute;height:100%;width:100%;background-color:", ";transform:scale(0.1);opacity:0;z-index:-1;border-radius:100vw;transition:transform 0.3s,opacity 0.3s,background-color 0.3s;}&:hover::after{opacity:1;transform-origin:center;transform:scale(1);}}&:not(.Mui-disabled){background-color:rgba(79,106,246,0.06);color:", ";}&:not(.Mui-disabled){&:hover{color:", ";}}}}}.arcblock-blocklet__title{margin:0;font-size:18px;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}.arcblock-blocklet__describe{margin:2px 0 0;color:#999;font-size:14px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}.arcblock-blocklet__addons{display:flex;justify-content:space-between;color:#999;font-size:14px;position:relative;}.arcblock-blocklet__addons--item{white-space:nowrap;}&.arcblock-blocklet--size-md{&:hover{position:relative;}.arcblock-blocklet__title{margin-bottom:3px;}.arcblock-blocklet__describe{white-space:normal;height:2.86em;}.arcblock-blocklet__button{margin-top:5px;}}&.arcblock-blocklet--size-sm,&.arcblock-blocklet--size-xs{.arcblock-blocklet__content{padding:12px 0;}.arcblock-blocklet__cover{width:48px;height:48px;border-radius:6px;}.arcblock-blocklet__addons{padding:8px 0;.arcblock-blocklet__addons--item{font-size:12px;}}}&.arcblock-blocklet--size-xs{.arcblock-blocklet__addons{display:none !important;}}"], props => props.theme.palette.common.white, props => props.theme.palette.primary.main, props => props.theme.palette.primary.main, props => props.theme.palette.common.white);
|
|
48
48
|
|
|
49
49
|
function BlockletIcon(_ref) {
|
|
50
50
|
let {
|
|
@@ -182,6 +182,7 @@ function Blocklet(_ref2) {
|
|
|
182
182
|
}
|
|
183
183
|
}, button || onButtonClick && /*#__PURE__*/_react.default.createElement(_Button.default, {
|
|
184
184
|
rounded: true,
|
|
185
|
+
className: "button_custom",
|
|
185
186
|
variant: "contained",
|
|
186
187
|
color: "primary",
|
|
187
188
|
size: "small",
|
package/lib/NFTDisplay/index.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.getNFTData = getNFTData;
|
|
6
7
|
exports.default = void 0;
|
|
7
8
|
|
|
8
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
@@ -50,6 +51,17 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
|
50
51
|
|
|
51
52
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
52
53
|
|
|
54
|
+
/**
|
|
55
|
+
* 从 assetState 中获取 nft data, 兼容新旧两种类型的数据结构, 建议将该方法的返回值传入 NFTDisplay 组件的 data prop
|
|
56
|
+
* - 旧: assetState.data.value (.credentialSubject.display)
|
|
57
|
+
* - 新: assetState.display
|
|
58
|
+
*/
|
|
59
|
+
function getNFTData(assetState) {
|
|
60
|
+
var _assetState$data;
|
|
61
|
+
|
|
62
|
+
return (assetState === null || assetState === void 0 ? void 0 : assetState.display) || (assetState === null || assetState === void 0 ? void 0 : (_assetState$data = assetState.data) === null || _assetState$data === void 0 ? void 0 : _assetState$data.value);
|
|
63
|
+
}
|
|
64
|
+
|
|
53
65
|
function fromBase64(v) {
|
|
54
66
|
if (typeof v !== 'string') {
|
|
55
67
|
throw new Error('fromBase64 requires input to be a string');
|
|
@@ -111,8 +123,9 @@ function NFTDisplay(_ref) {
|
|
|
111
123
|
|
|
112
124
|
const {
|
|
113
125
|
vcId
|
|
114
|
-
} = parsed.current;
|
|
115
|
-
|
|
126
|
+
} = parsed.current; // 需要兼容新旧两种类型的数据结构, nft data 有 credentialSubject 属性, 说明是旧 nft data, 否则是新 nft data
|
|
127
|
+
|
|
128
|
+
const display = parsed.current.credentialSubject ? (0, _get.default)(parsed.current, 'credentialSubject.display') : parsed.current;
|
|
116
129
|
const {
|
|
117
130
|
content,
|
|
118
131
|
type
|
|
@@ -150,7 +163,6 @@ function NFTDisplay(_ref) {
|
|
|
150
163
|
if (content) {
|
|
151
164
|
switch (type) {
|
|
152
165
|
case 'url':
|
|
153
|
-
case 'uri':
|
|
154
166
|
{
|
|
155
167
|
const urlObj = new URL(content);
|
|
156
168
|
|
|
@@ -175,6 +187,20 @@ function NFTDisplay(_ref) {
|
|
|
175
187
|
});
|
|
176
188
|
}
|
|
177
189
|
|
|
190
|
+
case 'uri':
|
|
191
|
+
{
|
|
192
|
+
return /*#__PURE__*/_react.default.createElement("img", {
|
|
193
|
+
src: content,
|
|
194
|
+
onError: () => setState(_objectSpread(_objectSpread({}, state), {}, {
|
|
195
|
+
error: true
|
|
196
|
+
})),
|
|
197
|
+
onLoad: () => setState(_objectSpread(_objectSpread({}, state), {}, {
|
|
198
|
+
loading: false
|
|
199
|
+
})),
|
|
200
|
+
alt: "NFT Display"
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
|
|
178
204
|
case 'svg_gzipped':
|
|
179
205
|
{
|
|
180
206
|
const buffer = _pako.default.ungzip(fromBase64(content), {});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcblock/ux",
|
|
3
|
-
"version": "1.16.
|
|
3
|
+
"version": "1.16.21",
|
|
4
4
|
"description": "Common used react components for arcblock products",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -53,10 +53,10 @@
|
|
|
53
53
|
"react": ">=16.12.0",
|
|
54
54
|
"react-ga": "^2.7.0"
|
|
55
55
|
},
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "488de07167702b5fe7c3373bbd47751f8323693a",
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@arcblock/icons": "^1.16.
|
|
59
|
-
"@arcblock/react-hooks": "^1.16.
|
|
58
|
+
"@arcblock/icons": "^1.16.21",
|
|
59
|
+
"@arcblock/react-hooks": "^1.16.21",
|
|
60
60
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
61
61
|
"@material-ui/core": "^4.12.3",
|
|
62
62
|
"@material-ui/icons": "4.11.2",
|
package/src/Blocklet/index.js
CHANGED
|
@@ -17,7 +17,7 @@ const Div = styled.div`
|
|
|
17
17
|
border: 1px solid #f2f2f2;
|
|
18
18
|
padding: 0 16px;
|
|
19
19
|
border-radius: 12px;
|
|
20
|
-
background:
|
|
20
|
+
background: ${props => props.theme.palette.common.white};
|
|
21
21
|
overflow: hidden;
|
|
22
22
|
&:hover {
|
|
23
23
|
filter: drop-shadow(0px 4px 12px rgba(92, 92, 92, 0.04));
|
|
@@ -56,27 +56,56 @@ const Div = styled.div`
|
|
|
56
56
|
.arcblock-blocklet__button {
|
|
57
57
|
margin-top: 16px;
|
|
58
58
|
display: inline-block;
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
59
|
+
// 覆盖 mui-button 的样式 做成 blocklet 内部 button 的专有样式
|
|
60
|
+
.button_custom {
|
|
61
|
+
&:not(.Mui-disabled) {
|
|
62
|
+
position: relative;
|
|
63
|
+
z-index: 1;
|
|
64
|
+
&::before {
|
|
65
|
+
content: '';
|
|
66
|
+
border-radius: 100vw;
|
|
67
|
+
position: absolute;
|
|
68
|
+
height: 100%;
|
|
69
|
+
width: 100%;
|
|
70
|
+
left: 0;
|
|
71
|
+
top: 0;
|
|
72
|
+
transition: opacity 0.3s;
|
|
73
|
+
}
|
|
74
|
+
&:hover::before {
|
|
75
|
+
opacity: 0;
|
|
76
|
+
}
|
|
77
|
+
&::after {
|
|
78
|
+
content: '';
|
|
79
|
+
position: absolute;
|
|
80
|
+
height: 100%;
|
|
81
|
+
width: 100%;
|
|
82
|
+
background-color: ${props => props.theme.palette.primary.main};
|
|
83
|
+
transform: scale(0.1);
|
|
84
|
+
opacity: 0;
|
|
85
|
+
z-index: -1;
|
|
86
|
+
border-radius: 100vw;
|
|
87
|
+
transition: transform 0.3s, opacity 0.3s, background-color 0.3s;
|
|
88
|
+
}
|
|
89
|
+
&:hover::after {
|
|
90
|
+
opacity: 1;
|
|
91
|
+
transform-origin: center;
|
|
92
|
+
transform: scale(1);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
&:not(.Mui-disabled) {
|
|
97
|
+
background-color: rgba(79, 106, 246, 0.06);
|
|
98
|
+
color: ${props => props.theme.palette.primary.main};
|
|
99
|
+
}
|
|
100
|
+
&:not(.Mui-disabled) {
|
|
101
|
+
&:hover {
|
|
102
|
+
color: ${props => props.theme.palette.common.white};
|
|
103
|
+
}
|
|
104
|
+
}
|
|
73
105
|
}
|
|
74
106
|
}
|
|
75
|
-
& > *:not(.Mui-disabled) {
|
|
76
|
-
background-color: rgba(79, 106, 246, 0.06);
|
|
77
|
-
color: ${props => props.theme.palette.primary.main};
|
|
78
|
-
}
|
|
79
107
|
}
|
|
108
|
+
|
|
80
109
|
.arcblock-blocklet__title {
|
|
81
110
|
margin: 0;
|
|
82
111
|
font-size: 18px;
|
|
@@ -261,6 +290,7 @@ export default function Blocklet({
|
|
|
261
290
|
(onButtonClick && (
|
|
262
291
|
<Button
|
|
263
292
|
rounded
|
|
293
|
+
className="button_custom"
|
|
264
294
|
variant="contained"
|
|
265
295
|
color="primary"
|
|
266
296
|
size="small"
|
package/src/NFTDisplay/index.js
CHANGED
|
@@ -12,6 +12,15 @@ import InlineSvgEmbedder from './svg-embedder/inline-svg';
|
|
|
12
12
|
import DefaultLoading from './loading';
|
|
13
13
|
import DefaultBrokenImage from './broken';
|
|
14
14
|
|
|
15
|
+
/**
|
|
16
|
+
* 从 assetState 中获取 nft data, 兼容新旧两种类型的数据结构, 建议将该方法的返回值传入 NFTDisplay 组件的 data prop
|
|
17
|
+
* - 旧: assetState.data.value (.credentialSubject.display)
|
|
18
|
+
* - 新: assetState.display
|
|
19
|
+
*/
|
|
20
|
+
export function getNFTData(assetState) {
|
|
21
|
+
return assetState?.display || assetState?.data?.value;
|
|
22
|
+
}
|
|
23
|
+
|
|
15
24
|
function fromBase64(v) {
|
|
16
25
|
if (typeof v !== 'string') {
|
|
17
26
|
throw new Error('fromBase64 requires input to be a string');
|
|
@@ -66,7 +75,10 @@ function NFTDisplay({
|
|
|
66
75
|
// console.log('[debug] parse data')
|
|
67
76
|
}
|
|
68
77
|
const { vcId } = parsed.current;
|
|
69
|
-
|
|
78
|
+
// 需要兼容新旧两种类型的数据结构, nft data 有 credentialSubject 属性, 说明是旧 nft data, 否则是新 nft data
|
|
79
|
+
const display = parsed.current.credentialSubject
|
|
80
|
+
? get(parsed.current, 'credentialSubject.display')
|
|
81
|
+
: parsed.current;
|
|
70
82
|
const { content, type } = display;
|
|
71
83
|
const isUrlType = type === 'url';
|
|
72
84
|
|
|
@@ -97,8 +109,7 @@ function NFTDisplay({
|
|
|
97
109
|
const renderNFT = () => {
|
|
98
110
|
if (content) {
|
|
99
111
|
switch (type) {
|
|
100
|
-
case 'url':
|
|
101
|
-
case 'uri': {
|
|
112
|
+
case 'url': {
|
|
102
113
|
const urlObj = new URL(content);
|
|
103
114
|
if (!urlObj.searchParams.has('assetId')) {
|
|
104
115
|
urlObj.searchParams.append('assetId', address);
|
|
@@ -118,6 +129,16 @@ function NFTDisplay({
|
|
|
118
129
|
/>
|
|
119
130
|
);
|
|
120
131
|
}
|
|
132
|
+
case 'uri': {
|
|
133
|
+
return (
|
|
134
|
+
<img
|
|
135
|
+
src={content}
|
|
136
|
+
onError={() => setState({ ...state, error: true })}
|
|
137
|
+
onLoad={() => setState({ ...state, loading: false })}
|
|
138
|
+
alt="NFT Display"
|
|
139
|
+
/>
|
|
140
|
+
);
|
|
141
|
+
}
|
|
121
142
|
case 'svg_gzipped': {
|
|
122
143
|
const buffer = pako.ungzip(fromBase64(content), {});
|
|
123
144
|
const svg = Buffer.from(buffer).toString('utf8');
|