@blocklet/ui-react 2.9.17 → 2.9.18
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/es/Dashboard/index.js +1 -1
- package/es/UserCenter/components/user-basic-info.d.ts +3 -1
- package/es/UserCenter/components/user-basic-info.js +133 -46
- package/es/UserCenter/components/user-center.d.ts +9 -6
- package/es/UserCenter/components/user-center.js +39 -138
- package/es/UserCenter/components/user-info-item.d.ts +2 -1
- package/es/UserCenter/components/user-info-item.js +4 -2
- package/es/UserCenter/components/user-info.js +6 -2
- package/es/UserCenter/libs/locales.d.ts +4 -0
- package/es/UserCenter/libs/locales.js +6 -2
- package/lib/Dashboard/index.js +2 -0
- package/lib/UserCenter/components/user-basic-info.d.ts +3 -1
- package/lib/UserCenter/components/user-basic-info.js +81 -4
- package/lib/UserCenter/components/user-center.d.ts +9 -6
- package/lib/UserCenter/components/user-center.js +36 -95
- package/lib/UserCenter/components/user-info-item.d.ts +2 -1
- package/lib/UserCenter/components/user-info-item.js +5 -2
- package/lib/UserCenter/components/user-info.js +9 -2
- package/lib/UserCenter/libs/locales.d.ts +4 -0
- package/lib/UserCenter/libs/locales.js +6 -2
- package/package.json +4 -4
- package/src/Dashboard/index.jsx +1 -1
- package/src/UserCenter/components/user-basic-info.tsx +88 -5
- package/src/UserCenter/components/user-center.tsx +35 -114
- package/src/UserCenter/components/user-info-item.tsx +4 -2
- package/src/UserCenter/components/user-info.tsx +6 -2
- package/src/UserCenter/libs/locales.ts +4 -0
- package/babel.config.es.js +0 -8
|
@@ -8,27 +8,82 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
8
8
|
var _material = require("@mui/material");
|
|
9
9
|
var _react = require("@iconify/react");
|
|
10
10
|
var _swapHorizRounded = _interopRequireDefault(require("@iconify-icons/material-symbols/swap-horiz-rounded"));
|
|
11
|
+
var _settingsOutlineRounded = _interopRequireDefault(require("@iconify-icons/material-symbols/settings-outline-rounded"));
|
|
12
|
+
var _Avatar = _interopRequireDefault(require("@arcblock/ux/lib/Avatar"));
|
|
11
13
|
var _Colors = require("@arcblock/ux/lib/Colors");
|
|
14
|
+
var _Theme = require("@arcblock/ux/lib/Theme");
|
|
12
15
|
var _DID = _interopRequireDefault(require("@arcblock/ux/lib/DID"));
|
|
13
16
|
var _ahooks = require("ahooks");
|
|
17
|
+
var _util = require("@arcblock/ux/lib/Locale/util");
|
|
18
|
+
var _context = require("@arcblock/ux/lib/Locale/context");
|
|
19
|
+
var _noop = _interopRequireDefault(require("lodash/noop"));
|
|
20
|
+
var _locales = require("../libs/locales");
|
|
14
21
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
22
|
function UserBasicInfo({
|
|
16
23
|
user,
|
|
17
24
|
isMyself = true,
|
|
18
25
|
switchPassport,
|
|
26
|
+
switchProfile,
|
|
27
|
+
openSettings,
|
|
19
28
|
...rest
|
|
20
29
|
}) {
|
|
30
|
+
const {
|
|
31
|
+
locale
|
|
32
|
+
} = (0, _context.useLocaleContext)();
|
|
33
|
+
const t = (0, _ahooks.useMemoizedFn)((key, data = {}) => {
|
|
34
|
+
return (0, _util.translate)(_locales.translations, key, locale, "en", data);
|
|
35
|
+
});
|
|
21
36
|
const currentRole = (0, _ahooks.useCreation)(() => (user?.passports || [])?.find(item => item.name === user.role), [user?.passports, user?.role]);
|
|
37
|
+
const theme = (0, _Theme.useTheme)();
|
|
38
|
+
const isSmallView = theme.breakpoints.down("md");
|
|
22
39
|
return /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
23
40
|
...rest,
|
|
24
|
-
|
|
25
|
-
|
|
41
|
+
sx: {
|
|
42
|
+
position: "relative",
|
|
43
|
+
...rest.sx
|
|
44
|
+
},
|
|
45
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_Avatar.default, {
|
|
46
|
+
src: user?.avatar,
|
|
47
|
+
did: user?.did,
|
|
48
|
+
size: isSmallView ? 64 : 80,
|
|
49
|
+
variant: "circle",
|
|
50
|
+
shape: "circle",
|
|
51
|
+
sx: {
|
|
52
|
+
borderRadius: "100%",
|
|
53
|
+
backgroundColor: "#fff",
|
|
54
|
+
position: "relative",
|
|
55
|
+
overflow: "hidden",
|
|
56
|
+
...(isMyself ? {
|
|
57
|
+
cursor: "pointer",
|
|
58
|
+
"&:hover": {
|
|
59
|
+
"&::after": {
|
|
60
|
+
content: `"${t("switchProfile")}"`
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
"&::after": {
|
|
64
|
+
color: "white",
|
|
65
|
+
position: "absolute",
|
|
66
|
+
fontSize: "12px",
|
|
67
|
+
bottom: 0,
|
|
68
|
+
left: 0,
|
|
69
|
+
right: 0,
|
|
70
|
+
height: "50%",
|
|
71
|
+
backgroundColor: "rgba(0, 0, 0, 0.3)",
|
|
72
|
+
display: "flex",
|
|
73
|
+
justifyContent: "center",
|
|
74
|
+
alignItems: "center"
|
|
75
|
+
}
|
|
76
|
+
} : {})
|
|
77
|
+
},
|
|
78
|
+
onClick: isMyself ? switchProfile : _noop.default
|
|
79
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Typography, {
|
|
80
|
+
variant: "h5",
|
|
26
81
|
sx: {
|
|
27
82
|
fontWeight: "bold",
|
|
28
83
|
display: "flex",
|
|
29
84
|
alignItems: "center",
|
|
30
85
|
gap: 1,
|
|
31
|
-
|
|
86
|
+
fontSize: "24px !important"
|
|
32
87
|
},
|
|
33
88
|
children: [user?.fullName, isMyself ? /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Chip, {
|
|
34
89
|
label: currentRole?.title || user?.role || "Guest",
|
|
@@ -62,6 +117,28 @@ function UserBasicInfo({
|
|
|
62
117
|
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_DID.default, {
|
|
63
118
|
did: user.did,
|
|
64
119
|
copyable: false
|
|
65
|
-
})
|
|
120
|
+
}), isMyself ? /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.IconButton, {
|
|
121
|
+
sx: {
|
|
122
|
+
borderRadius: 2,
|
|
123
|
+
color: _Colors.temp.textBase,
|
|
124
|
+
backgroundColor: "white",
|
|
125
|
+
border: `1px solid ${_Colors.temp.strokeBorderBase}`,
|
|
126
|
+
position: "absolute",
|
|
127
|
+
bottom: {
|
|
128
|
+
xs: "unset",
|
|
129
|
+
md: 0
|
|
130
|
+
},
|
|
131
|
+
top: {
|
|
132
|
+
xs: 0,
|
|
133
|
+
md: "unset"
|
|
134
|
+
},
|
|
135
|
+
right: 0
|
|
136
|
+
},
|
|
137
|
+
disableFocusRipple: true,
|
|
138
|
+
onClick: openSettings,
|
|
139
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_react.Icon, {
|
|
140
|
+
icon: _settingsOutlineRounded.default
|
|
141
|
+
})
|
|
142
|
+
}) : null]
|
|
66
143
|
});
|
|
67
144
|
}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { PaperProps } from '@mui/material';
|
|
3
|
-
export default function UserCenter({ children, currentTab, contentProps, disableAutoRedirect, autoPopupSetting, }: {
|
|
4
|
-
children: any;
|
|
5
|
-
currentTab: string;
|
|
6
|
-
contentProps?: PaperProps;
|
|
7
|
-
disableAutoRedirect?: boolean;
|
|
8
|
-
autoPopupSetting?: boolean;
|
|
3
|
+
export default function UserCenter({ children, currentTab, contentProps, disableAutoRedirect, autoPopupSetting, hideFooter, headerProps, footerProps, }: {
|
|
4
|
+
readonly children: any;
|
|
5
|
+
readonly currentTab: string;
|
|
6
|
+
readonly contentProps?: PaperProps;
|
|
7
|
+
readonly disableAutoRedirect?: boolean;
|
|
8
|
+
readonly autoPopupSetting?: boolean;
|
|
9
|
+
readonly hideFooter?: boolean;
|
|
10
|
+
readonly headerProps?: object;
|
|
11
|
+
readonly footerProps?: object;
|
|
9
12
|
}): import("react").JSX.Element | null;
|
|
@@ -8,10 +8,7 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
8
8
|
var _react = require("react");
|
|
9
9
|
var _material = require("@mui/material");
|
|
10
10
|
var _ahooks = require("ahooks");
|
|
11
|
-
var _react2 = require("@iconify/react");
|
|
12
|
-
var _settingsOutlineRounded = _interopRequireDefault(require("@iconify-icons/material-symbols/settings-outline-rounded"));
|
|
13
11
|
var _Session = require("@arcblock/did-connect/lib/Session");
|
|
14
|
-
var _Avatar = _interopRequireDefault(require("@arcblock/ux/lib/Avatar"));
|
|
15
12
|
var _Tabs = _interopRequireDefault(require("@arcblock/ux/lib/Tabs"));
|
|
16
13
|
var _Empty = _interopRequireDefault(require("@arcblock/ux/lib/Empty"));
|
|
17
14
|
var _Colors = require("@arcblock/ux/lib/Colors");
|
|
@@ -21,9 +18,8 @@ var _context = require("@arcblock/ux/lib/Locale/context");
|
|
|
21
18
|
var _ErrorBoundary = require("@arcblock/ux/lib/ErrorBoundary");
|
|
22
19
|
var _cloneDeep = _interopRequireDefault(require("lodash/cloneDeep"));
|
|
23
20
|
var _ufo = require("ufo");
|
|
24
|
-
var
|
|
21
|
+
var _ = require("../../");
|
|
25
22
|
var _locales = require("../libs/locales");
|
|
26
|
-
var _banner = _interopRequireDefault(require("../assets/banner.png"));
|
|
27
23
|
var _userInfo = _interopRequireDefault(require("./user-info"));
|
|
28
24
|
var _userBasicInfo = _interopRequireDefault(require("./user-basic-info"));
|
|
29
25
|
var _blocklets = require("../../blocklets");
|
|
@@ -36,7 +32,10 @@ function UserCenter({
|
|
|
36
32
|
currentTab,
|
|
37
33
|
contentProps = {},
|
|
38
34
|
disableAutoRedirect = false,
|
|
39
|
-
autoPopupSetting = false
|
|
35
|
+
autoPopupSetting = false,
|
|
36
|
+
hideFooter = false,
|
|
37
|
+
headerProps = {},
|
|
38
|
+
footerProps = {}
|
|
40
39
|
}) {
|
|
41
40
|
const {
|
|
42
41
|
locale
|
|
@@ -144,15 +143,6 @@ function UserCenter({
|
|
|
144
143
|
});
|
|
145
144
|
}
|
|
146
145
|
});
|
|
147
|
-
const xsGridTemplateAreas = (0, _ahooks.useCreation)(() => {
|
|
148
|
-
return ['"avatar settings"', '"basicInfo basicInfo"', userCenterTabs.length > 0 || !isMyself ? '"tabs tabs"' : null, isMyself ? '"passport passport"' : null, isMyself ? '"extraInfo extraInfo"' : null];
|
|
149
|
-
}, [userCenterTabs, isMyself]);
|
|
150
|
-
const mdGridTemplateAreas = (0, _ahooks.useCreation)(() => {
|
|
151
|
-
if (!isMyself) {
|
|
152
|
-
return ['"avatar"', '"basicInfo"', '"tabs"'];
|
|
153
|
-
}
|
|
154
|
-
return ['"avatar settings"', '"basicInfo extraInfo"', userCenterTabs.length > 0 ? '"tabs extraInfo"' : null, '"passport extraInfo"'];
|
|
155
|
-
}, [userCenterTabs, isMyself]);
|
|
156
146
|
const openSettings = (0, _ahooks.useMemoizedFn)(() => {
|
|
157
147
|
confirmApi.open({
|
|
158
148
|
title: t("settings"),
|
|
@@ -194,67 +184,19 @@ function UserCenter({
|
|
|
194
184
|
}
|
|
195
185
|
return /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
196
186
|
sx: {
|
|
197
|
-
maxWidth:
|
|
187
|
+
maxWidth: 880,
|
|
198
188
|
margin: "0 auto",
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
display: "grid",
|
|
189
|
+
p: 3,
|
|
190
|
+
display: "flex",
|
|
202
191
|
gap: 2.5,
|
|
203
|
-
|
|
204
|
-
xs: xsGridTemplateAreas.filter(Boolean).join(" "),
|
|
205
|
-
md: mdGridTemplateAreas.filter(Boolean).join(" ")
|
|
206
|
-
},
|
|
207
|
-
gridTemplateRows: {
|
|
208
|
-
xs: "64px auto auto auto",
|
|
209
|
-
md: "64px auto 1fr"
|
|
210
|
-
},
|
|
211
|
-
gridTemplateColumns: {
|
|
212
|
-
xs: "1fr",
|
|
213
|
-
md: isMyself ? "1fr 300px" : "1fr"
|
|
214
|
-
}
|
|
192
|
+
flexDirection: "column"
|
|
215
193
|
},
|
|
216
|
-
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(
|
|
217
|
-
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_Avatar.default, {
|
|
218
|
-
src: userState.data?.avatar,
|
|
219
|
-
did: userState.data?.did,
|
|
220
|
-
size: 120,
|
|
221
|
-
variant: "circle",
|
|
222
|
-
shape: "circle",
|
|
223
|
-
style: {
|
|
224
|
-
border: "4px solid #fff",
|
|
225
|
-
transform: "translateY(-50%)",
|
|
226
|
-
borderRadius: "100%",
|
|
227
|
-
gridArea: "avatar",
|
|
228
|
-
backgroundColor: "#fff"
|
|
229
|
-
}
|
|
230
|
-
})
|
|
231
|
-
}), isMyself ? /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
|
|
232
|
-
sx: {
|
|
233
|
-
gridArea: "settings",
|
|
234
|
-
display: "flex",
|
|
235
|
-
justifyContent: "flex-end",
|
|
236
|
-
alignItems: "center"
|
|
237
|
-
},
|
|
238
|
-
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.IconButton, {
|
|
239
|
-
sx: {
|
|
240
|
-
borderRadius: 2,
|
|
241
|
-
color: _Colors.temp.textBase,
|
|
242
|
-
backgroundColor: "white",
|
|
243
|
-
border: `1px solid ${_Colors.temp.strokeBorderBase}`
|
|
244
|
-
},
|
|
245
|
-
disableFocusRipple: true,
|
|
246
|
-
onClick: openSettings,
|
|
247
|
-
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_react2.Icon, {
|
|
248
|
-
icon: _settingsOutlineRounded.default
|
|
249
|
-
})
|
|
250
|
-
})
|
|
251
|
-
}) : null, /* @__PURE__ */(0, _jsxRuntime.jsx)(_userBasicInfo.default, {
|
|
194
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_userBasicInfo.default, {
|
|
252
195
|
isMyself,
|
|
253
196
|
switchPassport: session.switchPassport,
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
}
|
|
197
|
+
switchProfile: session.switchProfile,
|
|
198
|
+
openSettings,
|
|
199
|
+
user: userState.data
|
|
258
200
|
}), userCenterTabs.length > 0 && currentTab ? /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
259
201
|
sx: {
|
|
260
202
|
gridArea: "tabs",
|
|
@@ -323,34 +265,35 @@ function UserCenter({
|
|
|
323
265
|
})
|
|
324
266
|
}) : null, isMyself ? /* @__PURE__ */(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
325
267
|
children: [/* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
326
|
-
sx: {
|
|
327
|
-
gridArea: "passport"
|
|
328
|
-
},
|
|
329
268
|
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
330
269
|
variant: "h5",
|
|
331
270
|
sx: {
|
|
332
271
|
fontWeight: "bold",
|
|
333
272
|
mb: 1.5
|
|
334
273
|
},
|
|
335
|
-
children: "
|
|
274
|
+
children: t("passport")
|
|
336
275
|
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_passport.default, {
|
|
337
276
|
user: userState.data
|
|
338
277
|
})]
|
|
339
|
-
}), /* @__PURE__ */(0, _jsxRuntime.
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
278
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
279
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
280
|
+
variant: "h5",
|
|
281
|
+
sx: {
|
|
282
|
+
fontWeight: "bold",
|
|
283
|
+
mb: 1.5
|
|
284
|
+
},
|
|
285
|
+
children: t("userInfo")
|
|
286
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_userInfo.default, {
|
|
344
287
|
user: userState.data,
|
|
345
288
|
sx: {
|
|
346
289
|
padding: 3,
|
|
347
290
|
borderRadius: 3
|
|
348
291
|
}
|
|
349
|
-
})
|
|
292
|
+
})]
|
|
350
293
|
})]
|
|
351
294
|
}) : null]
|
|
352
295
|
});
|
|
353
|
-
}, [userState, userCenterTabs
|
|
296
|
+
}, [userState, userCenterTabs]);
|
|
354
297
|
if (!disableAutoRedirect && !currentTab && formattedBlocklet?.navigation?.userCenter?.length > 0) {
|
|
355
298
|
window.location.replace(formattedBlocklet?.navigation?.userCenter[0]?.link);
|
|
356
299
|
return null;
|
|
@@ -358,19 +301,17 @@ function UserCenter({
|
|
|
358
301
|
return /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
359
302
|
sx: {
|
|
360
303
|
backgroundColor: _Colors.temp.backgroundsBgSubtitle,
|
|
361
|
-
minHeight: "100vh"
|
|
304
|
+
minHeight: "100vh",
|
|
305
|
+
display: "flex",
|
|
306
|
+
flexDirection: "column"
|
|
362
307
|
},
|
|
363
|
-
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
backgroundSize: "cover",
|
|
372
|
-
minHeight: "60px"
|
|
373
|
-
}
|
|
374
|
-
}), content, confirmHolder]
|
|
308
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_.Header, {
|
|
309
|
+
...headerProps
|
|
310
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
311
|
+
flex: 1,
|
|
312
|
+
children: [content, confirmHolder]
|
|
313
|
+
}), hideFooter ? null : /* @__PURE__ */(0, _jsxRuntime.jsx)(_.Footer, {
|
|
314
|
+
...footerProps
|
|
315
|
+
})]
|
|
375
316
|
});
|
|
376
317
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import { BoxProps } from '@mui/material';
|
|
2
3
|
type TUserInfoItemProps = {
|
|
3
4
|
data: {
|
|
4
5
|
icon: any;
|
|
@@ -6,5 +7,5 @@ type TUserInfoItemProps = {
|
|
|
6
7
|
content: any;
|
|
7
8
|
};
|
|
8
9
|
};
|
|
9
|
-
export default function UserInfoItem({ data }: TUserInfoItemProps): import("react").JSX.Element;
|
|
10
|
+
export default function UserInfoItem({ data, ...rest }: TUserInfoItemProps & BoxProps): import("react").JSX.Element;
|
|
10
11
|
export {};
|
|
@@ -8,16 +8,19 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
8
8
|
var _material = require("@mui/material");
|
|
9
9
|
var _Colors = require("@arcblock/ux/lib/Colors");
|
|
10
10
|
function UserInfoItem({
|
|
11
|
-
data
|
|
11
|
+
data,
|
|
12
|
+
...rest
|
|
12
13
|
}) {
|
|
13
14
|
return /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
15
|
+
...rest,
|
|
14
16
|
sx: {
|
|
15
17
|
display: "grid",
|
|
16
18
|
gridTemplateColumns: "auto 1fr",
|
|
17
19
|
gridTemplateAreas: `"icon title" ". content"`,
|
|
18
20
|
alignItems: "center",
|
|
19
21
|
rowGap: 0.75,
|
|
20
|
-
columnGap: 1
|
|
22
|
+
columnGap: 1,
|
|
23
|
+
...rest.sx
|
|
21
24
|
},
|
|
22
25
|
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
|
|
23
26
|
sx: {
|
|
@@ -83,12 +83,19 @@ function UserInfo({
|
|
|
83
83
|
...rest,
|
|
84
84
|
sx: {
|
|
85
85
|
display: "flex",
|
|
86
|
-
flexDirection:
|
|
86
|
+
flexDirection: {
|
|
87
|
+
xs: "column",
|
|
88
|
+
md: "row"
|
|
89
|
+
},
|
|
90
|
+
alignItems: "flex-start",
|
|
87
91
|
gap: 3,
|
|
88
92
|
...rest?.sx
|
|
89
93
|
},
|
|
90
94
|
children: userInfoListData.map(item => /* @__PURE__ */(0, _jsxRuntime.jsx)(_userInfoItem.default, {
|
|
91
|
-
data: item
|
|
95
|
+
data: item,
|
|
96
|
+
sx: {
|
|
97
|
+
flex: 1
|
|
98
|
+
}
|
|
92
99
|
}, item.title))
|
|
93
100
|
});
|
|
94
101
|
}
|
|
@@ -33,6 +33,8 @@ export declare const translations: {
|
|
|
33
33
|
};
|
|
34
34
|
toPublic: string;
|
|
35
35
|
currentPassport: string;
|
|
36
|
+
switchProfile: string;
|
|
37
|
+
userInfo: string;
|
|
36
38
|
};
|
|
37
39
|
en: {
|
|
38
40
|
settings: string;
|
|
@@ -68,5 +70,7 @@ export declare const translations: {
|
|
|
68
70
|
};
|
|
69
71
|
toPublic: string;
|
|
70
72
|
currentPassport: string;
|
|
73
|
+
switchProfile: string;
|
|
74
|
+
userInfo: string;
|
|
71
75
|
};
|
|
72
76
|
};
|
|
@@ -38,7 +38,9 @@ const translations = exports.translations = {
|
|
|
38
38
|
invalid: "\u65E0\u6548"
|
|
39
39
|
},
|
|
40
40
|
toPublic: "\u516C\u5F00 \u201C{name}\u201D \u9875\u9762",
|
|
41
|
-
currentPassport: "\u5F53\u524D\u4F7F\u7528\u7684\u901A\u884C\u8BC1"
|
|
41
|
+
currentPassport: "\u5F53\u524D\u4F7F\u7528\u7684\u901A\u884C\u8BC1",
|
|
42
|
+
switchProfile: "\u5207\u6362",
|
|
43
|
+
userInfo: "\u4E2A\u4EBA\u4FE1\u606F"
|
|
42
44
|
},
|
|
43
45
|
en: {
|
|
44
46
|
settings: "Settings",
|
|
@@ -73,6 +75,8 @@ const translations = exports.translations = {
|
|
|
73
75
|
invalid: "Invalid"
|
|
74
76
|
},
|
|
75
77
|
toPublic: 'Public "{name}" page',
|
|
76
|
-
currentPassport: "Passport currently in use"
|
|
78
|
+
currentPassport: "Passport currently in use",
|
|
79
|
+
switchProfile: "Switch",
|
|
80
|
+
userInfo: "User Info"
|
|
77
81
|
}
|
|
78
82
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/ui-react",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.18",
|
|
4
4
|
"description": "Some useful front-end web components that can be used in Blocklets.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -63,8 +63,8 @@
|
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
65
|
"@abtnode/constant": "1.16.23-beta-aeb9f5bd",
|
|
66
|
-
"@arcblock/did-connect": "^2.9.
|
|
67
|
-
"@arcblock/ux": "^2.9.
|
|
66
|
+
"@arcblock/did-connect": "^2.9.18",
|
|
67
|
+
"@arcblock/ux": "^2.9.18",
|
|
68
68
|
"@blocklet/js-sdk": "1.16.23-beta-aeb9f5bd",
|
|
69
69
|
"@emotion/react": "^11.10.4",
|
|
70
70
|
"@emotion/styled": "^11.10.4",
|
|
@@ -96,5 +96,5 @@
|
|
|
96
96
|
"jest": "^28.1.3",
|
|
97
97
|
"unbuild": "^2.0.0"
|
|
98
98
|
},
|
|
99
|
-
"gitHead": "
|
|
99
|
+
"gitHead": "435fbdda42f68b81af5b09ce49fc874142d17e74"
|
|
100
100
|
}
|
package/src/Dashboard/index.jsx
CHANGED
|
@@ -41,7 +41,7 @@ function Dashboard({ meta, fallbackUrl, invalidPathFallback, headerAddons, sessi
|
|
|
41
41
|
(item) => ({
|
|
42
42
|
title: item.title,
|
|
43
43
|
url: item.link,
|
|
44
|
-
icon: item.icon ? <iconify-icon icon={item.icon} /> : null,
|
|
44
|
+
icon: item.icon ? <iconify-icon height="100%" width="100%" icon={item.icon} /> : null,
|
|
45
45
|
// https://github.com/ArcBlock/ux/issues/755#issuecomment-1208692620
|
|
46
46
|
external: true,
|
|
47
47
|
children: item.items,
|
|
@@ -1,38 +1,98 @@
|
|
|
1
|
-
import { Box, Chip, Typography } from '@mui/material';
|
|
1
|
+
import { Box, Chip, IconButton, Typography } from '@mui/material';
|
|
2
2
|
import type { BoxProps } from '@mui/material';
|
|
3
3
|
import { Icon } from '@iconify/react';
|
|
4
4
|
import SwapHorizRoundedIcon from '@iconify-icons/material-symbols/swap-horiz-rounded';
|
|
5
|
+
import SettingsOutlineRoundedIcon from '@iconify-icons/material-symbols/settings-outline-rounded';
|
|
6
|
+
import Avatar from '@arcblock/ux/lib/Avatar';
|
|
5
7
|
import { temp as colors } from '@arcblock/ux/lib/Colors';
|
|
8
|
+
import { useTheme } from '@arcblock/ux/lib/Theme';
|
|
6
9
|
import DID from '@arcblock/ux/lib/DID';
|
|
7
|
-
import { useCreation } from 'ahooks';
|
|
10
|
+
import { useCreation, useMemoizedFn } from 'ahooks';
|
|
11
|
+
import { translate } from '@arcblock/ux/lib/Locale/util';
|
|
12
|
+
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
13
|
+
import noop from 'lodash/noop';
|
|
8
14
|
|
|
15
|
+
import { translations } from '../libs/locales';
|
|
9
16
|
import type { User } from '../../@types';
|
|
10
17
|
|
|
11
18
|
export default function UserBasicInfo({
|
|
12
19
|
user,
|
|
13
20
|
isMyself = true,
|
|
14
21
|
switchPassport,
|
|
22
|
+
switchProfile,
|
|
23
|
+
openSettings,
|
|
15
24
|
...rest
|
|
16
25
|
}: {
|
|
17
26
|
user: User;
|
|
18
27
|
isMyself: boolean;
|
|
19
28
|
switchPassport: () => void;
|
|
29
|
+
switchProfile: () => void;
|
|
30
|
+
openSettings: () => void;
|
|
20
31
|
} & BoxProps) {
|
|
32
|
+
const { locale } = useLocaleContext();
|
|
33
|
+
const t = useMemoizedFn((key, data = {}) => {
|
|
34
|
+
return translate(translations, key, locale, 'en', data);
|
|
35
|
+
});
|
|
21
36
|
const currentRole = useCreation(
|
|
22
37
|
() => (user?.passports || [])?.find((item) => item.name === user.role),
|
|
23
38
|
[user?.passports, user?.role]
|
|
24
39
|
);
|
|
40
|
+
const theme = useTheme();
|
|
41
|
+
|
|
42
|
+
const isSmallView = theme.breakpoints.down('md');
|
|
25
43
|
|
|
26
44
|
return (
|
|
27
|
-
<Box
|
|
45
|
+
<Box
|
|
46
|
+
{...rest}
|
|
47
|
+
sx={{
|
|
48
|
+
position: 'relative',
|
|
49
|
+
...rest.sx,
|
|
50
|
+
}}>
|
|
51
|
+
<Avatar
|
|
52
|
+
src={user?.avatar}
|
|
53
|
+
did={user?.did}
|
|
54
|
+
size={isSmallView ? 64 : 80}
|
|
55
|
+
variant="circle"
|
|
56
|
+
shape="circle"
|
|
57
|
+
sx={{
|
|
58
|
+
borderRadius: '100%',
|
|
59
|
+
backgroundColor: '#fff',
|
|
60
|
+
position: 'relative',
|
|
61
|
+
overflow: 'hidden',
|
|
62
|
+
...(isMyself
|
|
63
|
+
? {
|
|
64
|
+
cursor: 'pointer',
|
|
65
|
+
'&:hover': {
|
|
66
|
+
'&::after': {
|
|
67
|
+
content: `"${t('switchProfile')}"`,
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
'&::after': {
|
|
71
|
+
color: 'white',
|
|
72
|
+
position: 'absolute',
|
|
73
|
+
fontSize: '12px',
|
|
74
|
+
bottom: 0,
|
|
75
|
+
left: 0,
|
|
76
|
+
right: 0,
|
|
77
|
+
height: '50%',
|
|
78
|
+
backgroundColor: 'rgba(0, 0, 0, 0.3)',
|
|
79
|
+
display: 'flex',
|
|
80
|
+
justifyContent: 'center',
|
|
81
|
+
alignItems: 'center',
|
|
82
|
+
},
|
|
83
|
+
}
|
|
84
|
+
: {}),
|
|
85
|
+
}}
|
|
86
|
+
onClick={isMyself ? switchProfile : noop}
|
|
87
|
+
/>
|
|
28
88
|
<Typography
|
|
29
|
-
variant="
|
|
89
|
+
variant="h5"
|
|
30
90
|
sx={{
|
|
31
91
|
fontWeight: 'bold',
|
|
32
92
|
display: 'flex',
|
|
33
93
|
alignItems: 'center',
|
|
34
94
|
gap: 1,
|
|
35
|
-
|
|
95
|
+
fontSize: '24px !important',
|
|
36
96
|
}}>
|
|
37
97
|
{user?.fullName}
|
|
38
98
|
{isMyself ? (
|
|
@@ -65,6 +125,29 @@ export default function UserBasicInfo({
|
|
|
65
125
|
) : null}
|
|
66
126
|
</Typography>
|
|
67
127
|
<DID did={user.did} copyable={false} />
|
|
128
|
+
{isMyself ? (
|
|
129
|
+
<IconButton
|
|
130
|
+
sx={{
|
|
131
|
+
borderRadius: 2,
|
|
132
|
+
color: colors.textBase,
|
|
133
|
+
backgroundColor: 'white',
|
|
134
|
+
border: `1px solid ${colors.strokeBorderBase}`,
|
|
135
|
+
position: 'absolute',
|
|
136
|
+
bottom: {
|
|
137
|
+
xs: 'unset',
|
|
138
|
+
md: 0,
|
|
139
|
+
},
|
|
140
|
+
top: {
|
|
141
|
+
xs: 0,
|
|
142
|
+
md: 'unset',
|
|
143
|
+
},
|
|
144
|
+
right: 0,
|
|
145
|
+
}}
|
|
146
|
+
disableFocusRipple
|
|
147
|
+
onClick={openSettings}>
|
|
148
|
+
<Icon icon={SettingsOutlineRoundedIcon} />
|
|
149
|
+
</IconButton>
|
|
150
|
+
) : null}
|
|
68
151
|
</Box>
|
|
69
152
|
);
|
|
70
153
|
}
|