@arcblock/ux 2.12.64 → 2.12.71
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/Config/config-provider.js +9 -0
- package/lib/Config/index.d.ts +1 -0
- package/lib/Config/index.js +1 -0
- package/lib/Datatable/index.d.ts +2 -2
- package/lib/Datatable/index.js +2 -2
- package/lib/Header/header.js +6 -2
- package/lib/Img/index.js +4 -4
- package/lib/Locale/selector.js +8 -18
- package/lib/NavMenu/style.js +10 -8
- package/lib/NavMenu/sub-item-group.js +6 -2
- package/lib/SessionBlocklet/index.js +7 -15
- package/lib/SessionUser/components/logged-in.js +4 -8
- package/lib/Theme/theme.d.ts +2 -0
- package/lib/Theme/theme.js +2 -1
- package/lib/UserCard/Cards/avatar-only.d.ts +8 -0
- package/lib/UserCard/Cards/avatar-only.js +34 -0
- package/lib/UserCard/Cards/basic-info.d.ts +9 -0
- package/lib/UserCard/Cards/basic-info.js +51 -0
- package/lib/UserCard/Cards/index.d.ts +8 -0
- package/lib/UserCard/Cards/index.js +24 -0
- package/lib/UserCard/Cards/name-only.d.ts +3 -0
- package/lib/UserCard/Cards/name-only.js +18 -0
- package/lib/UserCard/Container/card.d.ts +13 -0
- package/lib/UserCard/Container/card.js +46 -0
- package/lib/UserCard/Container/dialog.d.ts +9 -0
- package/lib/UserCard/Container/dialog.js +25 -0
- package/lib/UserCard/Content/basic.d.ts +7 -0
- package/lib/UserCard/Content/basic.js +139 -0
- package/lib/UserCard/Content/clock.d.ts +4 -0
- package/lib/UserCard/Content/clock.js +68 -0
- package/lib/UserCard/Content/left-layout.d.ts +16 -0
- package/lib/UserCard/Content/left-layout.js +33 -0
- package/lib/UserCard/Content/minimal.d.ts +15 -0
- package/lib/UserCard/Content/minimal.js +61 -0
- package/lib/UserCard/Content/tooltip-avatar.d.ts +15 -0
- package/lib/UserCard/Content/tooltip-avatar.js +61 -0
- package/lib/UserCard/components.d.ts +4 -0
- package/lib/UserCard/components.js +45 -0
- package/lib/UserCard/index.d.ts +5 -0
- package/lib/UserCard/index.js +74 -0
- package/lib/UserCard/types.d.ts +107 -0
- package/lib/UserCard/types.js +42 -0
- package/lib/UserCard/utils.d.ts +2 -0
- package/lib/UserCard/utils.js +19 -0
- package/lib/hooks/use-clock.d.ts +10 -0
- package/lib/hooks/use-clock.js +71 -0
- package/package.json +5 -5
- package/src/Config/config-provider.tsx +7 -0
- package/src/Config/index.ts +1 -0
- package/src/Datatable/index.jsx +2 -2
- package/src/Header/header.tsx +2 -2
- package/src/Img/index.jsx +35 -32
- package/src/Locale/selector.tsx +7 -14
- package/src/NavMenu/style.ts +8 -8
- package/src/NavMenu/sub-item-group.tsx +2 -2
- package/src/SessionBlocklet/index.tsx +7 -20
- package/src/SessionUser/components/logged-in.tsx +4 -6
- package/src/Theme/theme.ts +1 -0
- package/src/UserCard/Cards/avatar-only.tsx +38 -0
- package/src/UserCard/Cards/basic-info.tsx +50 -0
- package/src/UserCard/Cards/index.tsx +24 -0
- package/src/UserCard/Cards/name-only.tsx +17 -0
- package/src/UserCard/Container/card.tsx +52 -0
- package/src/UserCard/Container/dialog.tsx +30 -0
- package/src/UserCard/Content/basic.tsx +134 -0
- package/src/UserCard/Content/clock.tsx +63 -0
- package/src/UserCard/Content/left-layout.tsx +40 -0
- package/src/UserCard/Content/minimal.tsx +60 -0
- package/src/UserCard/Content/tooltip-avatar.tsx +55 -0
- package/src/UserCard/components.tsx +49 -0
- package/src/UserCard/index.tsx +63 -0
- package/src/UserCard/types.ts +129 -0
- package/src/UserCard/utils.ts +22 -0
- package/src/hooks/use-clock.tsx +61 -0
@@ -0,0 +1,42 @@
|
|
1
|
+
export let DurationEnum = /*#__PURE__*/function (DurationEnum) {
|
2
|
+
DurationEnum["NoClear"] = "no_clear";
|
3
|
+
DurationEnum["ThirtyMinutes"] = "30_minutes";
|
4
|
+
DurationEnum["OneHour"] = "1_hour";
|
5
|
+
DurationEnum["FourHours"] = "4_hours";
|
6
|
+
DurationEnum["Today"] = "today";
|
7
|
+
DurationEnum["ThisWeek"] = "this_week";
|
8
|
+
DurationEnum["Custom"] = "custom";
|
9
|
+
return DurationEnum;
|
10
|
+
}({});
|
11
|
+
export let StatusEnum = /*#__PURE__*/function (StatusEnum) {
|
12
|
+
StatusEnum["Meeting"] = "meeting";
|
13
|
+
StatusEnum["Community"] = "community";
|
14
|
+
StatusEnum["Holiday"] = "holiday";
|
15
|
+
StatusEnum["OffSick"] = "off_sick";
|
16
|
+
StatusEnum["WorkingRemotely"] = "working_remotely";
|
17
|
+
return StatusEnum;
|
18
|
+
}({});
|
19
|
+
// 头像大小
|
20
|
+
export const AvatarSize = {
|
21
|
+
small: 32,
|
22
|
+
medium: 40,
|
23
|
+
large: 48,
|
24
|
+
xlarge: 64
|
25
|
+
};
|
26
|
+
|
27
|
+
// 卡片类型
|
28
|
+
export let CardType = /*#__PURE__*/function (CardType) {
|
29
|
+
CardType["AvatarOnly"] = "AvatarOnly";
|
30
|
+
CardType["Detailed"] = "Detailed";
|
31
|
+
return CardType;
|
32
|
+
}({}); // 详细卡片
|
33
|
+
|
34
|
+
// 信息类型
|
35
|
+
export let InfoType = /*#__PURE__*/function (InfoType) {
|
36
|
+
InfoType["NameOnly"] = "NameOnly";
|
37
|
+
InfoType["Minimal"] = "Minimal";
|
38
|
+
InfoType["Basic"] = "Basic";
|
39
|
+
return InfoType;
|
40
|
+
}({}); // 基本信息模式
|
41
|
+
|
42
|
+
// 定义UserCard属性接口
|
@@ -0,0 +1,19 @@
|
|
1
|
+
// 创建仅显示名称首字母的头像
|
2
|
+
// eslint-disable-next-line import/prefer-default-export
|
3
|
+
export function createNameOnlyAvatar(user) {
|
4
|
+
if (!user) return null;
|
5
|
+
|
6
|
+
// 使用全名或邮箱前缀作为显示内容
|
7
|
+
let content = '';
|
8
|
+
if (user.fullName) {
|
9
|
+
// 提取名称首字母
|
10
|
+
content = user.fullName.charAt(0).toUpperCase();
|
11
|
+
} else if (user.email) {
|
12
|
+
// 使用邮箱前缀首字母
|
13
|
+
content = user.email.split('@')[0].charAt(0).toUpperCase();
|
14
|
+
} else {
|
15
|
+
// 如果都没有,使用DID的第一个字符
|
16
|
+
content = user.did ? user.did.charAt(0).toUpperCase() : '?';
|
17
|
+
}
|
18
|
+
return content;
|
19
|
+
}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import dayjs from 'dayjs';
|
2
|
+
import 'dayjs/locale/zh-cn';
|
3
|
+
import 'dayjs/locale/en';
|
4
|
+
export default function useClock(timezone?: string, locale?: string): {
|
5
|
+
formattedTime: string;
|
6
|
+
fullDateTime: any;
|
7
|
+
phase: string;
|
8
|
+
icon: string;
|
9
|
+
rawTime: dayjs.Dayjs;
|
10
|
+
};
|
@@ -0,0 +1,71 @@
|
|
1
|
+
import { useState, useEffect, useCallback } from 'react';
|
2
|
+
import dayjs from 'dayjs';
|
3
|
+
import utc from 'dayjs/plugin/utc';
|
4
|
+
import timezonePlugin from 'dayjs/plugin/timezone';
|
5
|
+
import localizedFormat from 'dayjs/plugin/localizedFormat';
|
6
|
+
import { formatToDatetime } from '@arcblock/ux/lib/Util';
|
7
|
+
import 'dayjs/locale/zh-cn';
|
8
|
+
import 'dayjs/locale/en';
|
9
|
+
dayjs.extend(utc);
|
10
|
+
dayjs.extend(timezonePlugin);
|
11
|
+
dayjs.extend(localizedFormat);
|
12
|
+
const currentTimezone = dayjs.tz.guess();
|
13
|
+
|
14
|
+
// 获取时间段
|
15
|
+
const getTimePhase = hour => {
|
16
|
+
if (hour >= 0 && hour < 6) return {
|
17
|
+
phase: 'dawn',
|
18
|
+
icon: '🌒'
|
19
|
+
}; // 凌晨 00:00-05:59
|
20
|
+
if (hour >= 6 && hour < 12) return {
|
21
|
+
phase: 'morning',
|
22
|
+
icon: '🌞'
|
23
|
+
}; // 上午 06:00-11:59
|
24
|
+
if (hour >= 12 && hour < 18) return {
|
25
|
+
phase: 'afternoon',
|
26
|
+
icon: '🌞'
|
27
|
+
}; // 下午 12:00-17:59
|
28
|
+
return {
|
29
|
+
phase: 'night',
|
30
|
+
icon: '🌒'
|
31
|
+
}; // 晚上 18:00-23:59
|
32
|
+
};
|
33
|
+
export default function useClock(timezone = currentTimezone, locale = 'zh') {
|
34
|
+
const getLatestTimeInfo = useCallback(() => {
|
35
|
+
const currentLocale = locale === 'zh' ? 'zh-cn' : 'en';
|
36
|
+
const localeOption = locale === 'zh' ? 'zh-cn' : 'en-us';
|
37
|
+
dayjs.locale(currentLocale);
|
38
|
+
const now = dayjs().tz(timezone);
|
39
|
+
const hour = now.hour();
|
40
|
+
const {
|
41
|
+
phase,
|
42
|
+
icon
|
43
|
+
} = getTimePhase(hour);
|
44
|
+
return {
|
45
|
+
formattedTime: now.format('LT'),
|
46
|
+
fullDateTime: formatToDatetime(now.toDate(), {
|
47
|
+
tz: timezone,
|
48
|
+
locale: localeOption
|
49
|
+
}),
|
50
|
+
phase,
|
51
|
+
icon,
|
52
|
+
rawTime: now
|
53
|
+
};
|
54
|
+
}, [timezone, locale]);
|
55
|
+
const [timeInfo, setTimeInfo] = useState(getLatestTimeInfo());
|
56
|
+
useEffect(() => {
|
57
|
+
// 立即更新一次,确保初始状态是最新的
|
58
|
+
setTimeInfo(getLatestTimeInfo());
|
59
|
+
|
60
|
+
// 设置定时器
|
61
|
+
const timerId = setInterval(() => {
|
62
|
+
setTimeInfo(getLatestTimeInfo());
|
63
|
+
}, 6000);
|
64
|
+
|
65
|
+
// 清理函数
|
66
|
+
return () => {
|
67
|
+
clearInterval(timerId);
|
68
|
+
};
|
69
|
+
}, [timezone, locale, getLatestTimeInfo]);
|
70
|
+
return timeInfo;
|
71
|
+
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@arcblock/ux",
|
3
|
-
"version": "2.12.
|
3
|
+
"version": "2.12.71",
|
4
4
|
"description": "Common used react components for arcblock products",
|
5
5
|
"keywords": [
|
6
6
|
"react",
|
@@ -70,12 +70,12 @@
|
|
70
70
|
"react": ">=18.2.0",
|
71
71
|
"react-router-dom": ">=6.22.3"
|
72
72
|
},
|
73
|
-
"gitHead": "
|
73
|
+
"gitHead": "12e8ad0b88c0d3e9ee9cbd84634e0778044cf494",
|
74
74
|
"dependencies": {
|
75
75
|
"@arcblock/did-motif": "^1.1.13",
|
76
|
-
"@arcblock/icons": "^2.12.
|
77
|
-
"@arcblock/nft-display": "^2.12.
|
78
|
-
"@arcblock/react-hooks": "^2.12.
|
76
|
+
"@arcblock/icons": "^2.12.71",
|
77
|
+
"@arcblock/nft-display": "^2.12.71",
|
78
|
+
"@arcblock/react-hooks": "^2.12.71",
|
79
79
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
80
80
|
"@fontsource/roboto": "^5.2.5",
|
81
81
|
"@fontsource/ubuntu-mono": "^5.0.18",
|
@@ -54,11 +54,18 @@ export function ConfigProvider({
|
|
54
54
|
return prefer;
|
55
55
|
}
|
56
56
|
|
57
|
+
// 未启用暗色主题
|
58
|
+
if (!window.blocklet?.USE_DARK_THEME) {
|
59
|
+
return 'light';
|
60
|
+
}
|
61
|
+
|
62
|
+
// 本地缓存
|
57
63
|
const localPrefer = localStorage.getItem(preferThemeModeKey) as ThemeMode;
|
58
64
|
if (localPrefer && (localPrefer === 'light' || localPrefer === 'dark')) {
|
59
65
|
return localPrefer;
|
60
66
|
}
|
61
67
|
|
68
|
+
// 系统偏好
|
62
69
|
return prefersDarkMode ? 'dark' : 'light';
|
63
70
|
});
|
64
71
|
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './config-provider';
|
package/src/Datatable/index.jsx
CHANGED
@@ -16,7 +16,7 @@ import { styled } from '../Theme';
|
|
16
16
|
/**
|
17
17
|
* @typedef {{
|
18
18
|
* icon: import('react').ReactElement,
|
19
|
-
* title: string,
|
19
|
+
* title: import('react').ReactElement | string,
|
20
20
|
* onClick?: () => void
|
21
21
|
* }} DataTableCustomButton
|
22
22
|
*/
|
@@ -35,7 +35,7 @@ import { styled } from '../Theme';
|
|
35
35
|
|
36
36
|
/**
|
37
37
|
* @typedef {{
|
38
|
-
* title?: string, // The title of the table (optional)
|
38
|
+
* title?: import('react').ReactElement | string, // The title of the table (optional)
|
39
39
|
* } & Omit<import('mui-datatables').MUIDataTableProps, 'title'>} ModifiedMUIDataTableProps
|
40
40
|
*/
|
41
41
|
|
package/src/Header/header.tsx
CHANGED
@@ -100,8 +100,8 @@ function Header({
|
|
100
100
|
const Root = styled(Box)`
|
101
101
|
position: relative;
|
102
102
|
font-size: 14px;
|
103
|
-
z-index: ${(
|
104
|
-
background: ${(
|
103
|
+
z-index: ${({ theme }) => theme.zIndex.appBar};
|
104
|
+
background: ${({ theme }) => theme.palette.background.default};
|
105
105
|
.header-container {
|
106
106
|
display: flex;
|
107
107
|
align-items: center;
|
package/src/Img/index.jsx
CHANGED
@@ -6,6 +6,7 @@ import ImageRoundedIcon from '@iconify-icons/material-symbols/image-rounded';
|
|
6
6
|
import { Icon } from '@iconify/react';
|
7
7
|
import { Box } from '@mui/material';
|
8
8
|
import noop from 'lodash/noop';
|
9
|
+
import { mergeSx } from '../Util/style';
|
9
10
|
|
10
11
|
/**
|
11
12
|
* @typedef {Object} ImgExProps
|
@@ -127,40 +128,42 @@ function Img({
|
|
127
128
|
ref={ref}
|
128
129
|
style={outerStyle}
|
129
130
|
{...rest}
|
130
|
-
sx={
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
131
|
+
sx={mergeSx(
|
132
|
+
{
|
133
|
+
[`& .${classes.root}`]: {
|
134
|
+
position: 'relative',
|
135
|
+
overflow: 'hidden',
|
136
|
+
'& .image--state, & .image--img': {
|
137
|
+
minWidth: '100%',
|
138
|
+
minHeight: '100%',
|
139
|
+
position: 'absolute',
|
140
|
+
top: 0,
|
141
|
+
left: '50%',
|
142
|
+
transform: 'translateX(-50%)',
|
143
|
+
},
|
144
|
+
'& .image--state': {
|
145
|
+
display: 'flex',
|
146
|
+
flexDirection: 'column',
|
147
|
+
justifyContent: 'center',
|
148
|
+
alignItems: 'center',
|
149
|
+
color: '#999',
|
150
|
+
background: '#eee',
|
151
|
+
width: '100%',
|
152
|
+
height: '100%',
|
153
|
+
},
|
154
|
+
'& .image--img': {
|
155
|
+
opacity: 0,
|
156
|
+
visibility: 'hidden',
|
157
|
+
},
|
158
|
+
'& .image--icon': {
|
159
|
+
fontSize: 30,
|
160
|
+
maxWidth: '80%',
|
161
|
+
maxHeight: '80%',
|
162
|
+
},
|
160
163
|
},
|
161
164
|
},
|
162
|
-
|
163
|
-
}
|
165
|
+
rest.sx
|
166
|
+
)}>
|
164
167
|
<div className={`image ${className} ${classes.root}`} style={mergedStyle}>
|
165
168
|
{!fallback && imgState === 'error' && (
|
166
169
|
<div className="image--state" title="loading image">
|
package/src/Locale/selector.tsx
CHANGED
@@ -6,7 +6,6 @@ import CheckIcon from '@iconify-icons/material-symbols/check';
|
|
6
6
|
import LanguageIcon from 'iconify-icons-material-symbols-400/language';
|
7
7
|
import noop from 'lodash/noop';
|
8
8
|
|
9
|
-
import { getColor, getBackground } from '../Util';
|
10
9
|
import { temp as colors } from '../Colors';
|
11
10
|
import { LocaleContext } from './context';
|
12
11
|
import { styled, useTheme } from '../Theme';
|
@@ -80,7 +79,7 @@ export default function LocaleSelector(props: LocaleSelectorProps) {
|
|
80
79
|
}, [Icon, size]);
|
81
80
|
|
82
81
|
return (
|
83
|
-
<
|
82
|
+
<Wrapper {...rest} {...handleEventProps}>
|
84
83
|
<ButtonComponent ref={anchorEl} className="trigger" role="button" aria-label="Locale selector button">
|
85
84
|
<Box display="flex" alignItems="center">
|
86
85
|
{renderIcon}
|
@@ -109,8 +108,8 @@ export default function LocaleSelector(props: LocaleSelectorProps) {
|
|
109
108
|
<Box
|
110
109
|
className="locales"
|
111
110
|
sx={{
|
112
|
-
|
113
|
-
boxShadow:
|
111
|
+
backgroundColor: 'background.default',
|
112
|
+
boxShadow: 2,
|
114
113
|
borderRadius: 2,
|
115
114
|
}}>
|
116
115
|
<ClickAwayListener onClickAway={onClose}>
|
@@ -128,7 +127,7 @@ export default function LocaleSelector(props: LocaleSelectorProps) {
|
|
128
127
|
lineHeight: 'normal',
|
129
128
|
letterSpacing: '2px',
|
130
129
|
textAlign: 'center',
|
131
|
-
color:
|
130
|
+
color: 'text.primary',
|
132
131
|
cursor: 'pointer',
|
133
132
|
display: 'flex',
|
134
133
|
padding: '16px',
|
@@ -151,17 +150,11 @@ export default function LocaleSelector(props: LocaleSelectorProps) {
|
|
151
150
|
</ClickAwayListener>
|
152
151
|
</Box>
|
153
152
|
</Popper>
|
154
|
-
</
|
153
|
+
</Wrapper>
|
155
154
|
);
|
156
155
|
}
|
157
156
|
|
158
|
-
|
159
|
-
dark: boolean;
|
160
|
-
};
|
161
|
-
|
162
|
-
const Div = styled('div', {
|
163
|
-
shouldForwardProp: (prop) => prop !== 'dark',
|
164
|
-
})<DivProps>`
|
157
|
+
const Wrapper = styled(Box)`
|
165
158
|
display: inline-block;
|
166
159
|
|
167
160
|
.trigger {
|
@@ -174,7 +167,7 @@ const Div = styled('div', {
|
|
174
167
|
.trigger-text {
|
175
168
|
margin-left: 5px;
|
176
169
|
font-size: 14px;
|
177
|
-
color: ${(
|
170
|
+
color: ${({ theme }) => theme.palette.text.primary};
|
178
171
|
}
|
179
172
|
}
|
180
173
|
`;
|
package/src/NavMenu/style.ts
CHANGED
@@ -128,20 +128,20 @@ export const NavMenuItem = styled('li', {
|
|
128
128
|
marginRight: '16px',
|
129
129
|
border: '1px solid #eff1f5',
|
130
130
|
borderRadius: '4px',
|
131
|
-
color:
|
131
|
+
color: theme.palette.grey[500],
|
132
132
|
},
|
133
133
|
'.navmenu-item__label': {
|
134
134
|
fontSize: '14px',
|
135
135
|
lineHeight: 1,
|
136
|
-
color:
|
136
|
+
color: theme.palette.text.primary,
|
137
137
|
},
|
138
138
|
'.navmenu-item__desc': {
|
139
139
|
fontSize: '12px',
|
140
140
|
lineHeight: 1,
|
141
|
-
color:
|
141
|
+
color: theme.palette.grey[500],
|
142
142
|
},
|
143
143
|
'&:hover': {
|
144
|
-
background:
|
144
|
+
background: theme.palette.action.hover,
|
145
145
|
transition: theme.transitions.create('background', {
|
146
146
|
duration: theme.transitions.duration.standard,
|
147
147
|
}),
|
@@ -149,14 +149,14 @@ export const NavMenuItem = styled('li', {
|
|
149
149
|
opacity: 1,
|
150
150
|
},
|
151
151
|
'.navmenu-item__desc': {
|
152
|
-
color:
|
152
|
+
color: theme.palette.text.primary,
|
153
153
|
transition: theme.transitions.create('color', {
|
154
154
|
duration: theme.transitions.duration.standard,
|
155
155
|
}),
|
156
156
|
},
|
157
157
|
},
|
158
158
|
'&.navmenu-item--active': {
|
159
|
-
background:
|
159
|
+
background: theme.palette.action.hover,
|
160
160
|
},
|
161
161
|
},
|
162
162
|
// inline 布局中
|
@@ -237,11 +237,11 @@ export const NavMenuSub = styled(NavMenuItem)(({ theme }) => ({
|
|
237
237
|
}));
|
238
238
|
|
239
239
|
// 下拉子菜单 .navmenu-sub__list
|
240
|
-
export const NavMenuSubList = styled('ul')(() => ({
|
240
|
+
export const NavMenuSubList = styled('ul')(({ theme }) => ({
|
241
241
|
margin: 0,
|
242
242
|
padding: '16px',
|
243
243
|
borderRadius: '4px',
|
244
|
-
background:
|
244
|
+
background: theme.palette.background.default,
|
245
245
|
'& .navmenu-item + .navmenu-item': {
|
246
246
|
marginTop: '8px',
|
247
247
|
},
|
@@ -4,12 +4,12 @@ import { styled } from '../Theme';
|
|
4
4
|
const Group = styled(Box)`
|
5
5
|
padding: 16px 24px;
|
6
6
|
border-radius: 8px;
|
7
|
-
background-color:
|
7
|
+
background-color: ${({ theme }) => theme.palette.background.default};
|
8
8
|
cursor: auto;
|
9
9
|
|
10
10
|
.group-label {
|
11
11
|
margin-bottom: 8px;
|
12
|
-
color:
|
12
|
+
color: ${({ theme }) => theme.palette.grey[600]};
|
13
13
|
font-size: 12px;
|
14
14
|
}
|
15
15
|
|
@@ -11,6 +11,7 @@ import {
|
|
11
11
|
Paper,
|
12
12
|
Popper,
|
13
13
|
Typography,
|
14
|
+
useTheme,
|
14
15
|
} from '@mui/material';
|
15
16
|
import { Icon } from '@iconify/react';
|
16
17
|
import DashboardOutlineRoundedIcon from 'iconify-icons-material-symbols-400/dashboard-outline-rounded';
|
@@ -18,7 +19,6 @@ import WidgetsOutlineRoundedIcon from '@iconify-icons/material-symbols/widgets-o
|
|
18
19
|
import { useMemoizedFn, useReactive } from 'ahooks';
|
19
20
|
|
20
21
|
import Button from '../Button';
|
21
|
-
import { temp as colors } from '../Colors';
|
22
22
|
import { BLOCKLET_SERVICE_PATH_PREFIX, NAVIGATION_URL } from '../Util/constant';
|
23
23
|
import SessionPermission from '../SessionPermission';
|
24
24
|
import { getTranslation } from '../Util';
|
@@ -56,6 +56,7 @@ export default function SessionBlocklet({
|
|
56
56
|
component,
|
57
57
|
};
|
58
58
|
});
|
59
|
+
const theme = useTheme();
|
59
60
|
const popperAnchorRef = useRef(null);
|
60
61
|
const currentState = useReactive({
|
61
62
|
open: false,
|
@@ -100,10 +101,9 @@ export default function SessionBlocklet({
|
|
100
101
|
borderRadius: 3,
|
101
102
|
width: 350,
|
102
103
|
maxWidth: '90vw',
|
103
|
-
borderColor: colors.lineStep,
|
104
104
|
p: 2,
|
105
105
|
border: '0 !important',
|
106
|
-
boxShadow:
|
106
|
+
boxShadow: 2,
|
107
107
|
}}>
|
108
108
|
<List
|
109
109
|
sx={{
|
@@ -129,7 +129,7 @@ export default function SessionBlocklet({
|
|
129
129
|
height: '100%',
|
130
130
|
borderRadius: 2,
|
131
131
|
'&:hover': {
|
132
|
-
backgroundColor:
|
132
|
+
backgroundColor: 'action.hover',
|
133
133
|
},
|
134
134
|
}}>
|
135
135
|
{item?.component?.did ? (
|
@@ -148,14 +148,14 @@ export default function SessionBlocklet({
|
|
148
148
|
<Icon
|
149
149
|
fontSize={50}
|
150
150
|
icon={item.icon || WidgetsOutlineRoundedIcon}
|
151
|
-
color={
|
151
|
+
color={theme.palette.text.secondary}
|
152
152
|
/>
|
153
153
|
)}
|
154
154
|
|
155
155
|
<Typography
|
156
156
|
sx={{
|
157
157
|
fontSize: '12px',
|
158
|
-
color:
|
158
|
+
color: 'text.primary',
|
159
159
|
textAlign: 'center',
|
160
160
|
lineHeight: 'normal',
|
161
161
|
}}>
|
@@ -166,20 +166,7 @@ export default function SessionBlocklet({
|
|
166
166
|
))}
|
167
167
|
</List>
|
168
168
|
<SessionPermission session={session}>
|
169
|
-
<Button
|
170
|
-
variant="outlined"
|
171
|
-
fullWidth
|
172
|
-
href={NAVIGATION_URL}
|
173
|
-
sx={{
|
174
|
-
mt: 1,
|
175
|
-
borderRadius: 2,
|
176
|
-
color: colors.textBase,
|
177
|
-
borderColor: colors.lineBorderStrong,
|
178
|
-
'&:hover': {
|
179
|
-
color: colors.primaryBase,
|
180
|
-
borderColor: colors.primaryBase,
|
181
|
-
},
|
182
|
-
}}>
|
169
|
+
<Button variant="outlined" fullWidth href={NAVIGATION_URL} sx={{ mt: 1 }}>
|
183
170
|
{locale === 'zh' ? '管理' : 'Manage'}
|
184
171
|
</Button>
|
185
172
|
</SessionPermission>
|
@@ -24,7 +24,6 @@ import Toast from '../../Toast';
|
|
24
24
|
import DidAvatar from '../../Avatar';
|
25
25
|
import { getUserAvatar } from '../../Util';
|
26
26
|
import UserInfo from './user-info';
|
27
|
-
import { temp as colors } from '../../Colors';
|
28
27
|
import { DASHBOARD_URL, PROFILE_URL } from '../../Util/constant';
|
29
28
|
import SessionPermission from '../../SessionPermission';
|
30
29
|
import { translations } from '../libs/translation';
|
@@ -179,9 +178,8 @@ export default function LoggedIn({
|
|
179
178
|
borderRadius: 3,
|
180
179
|
width: 350,
|
181
180
|
maxWidth: '90vw',
|
182
|
-
borderColor: colors.lineStep,
|
183
181
|
border: '0 !important',
|
184
|
-
boxShadow:
|
182
|
+
boxShadow: 2,
|
185
183
|
}}>
|
186
184
|
<UserInfo
|
187
185
|
locale={locale}
|
@@ -192,7 +190,7 @@ export default function LoggedIn({
|
|
192
190
|
onSwitchProfile={handleSwitchProfile}
|
193
191
|
onBindWallet={handleBindWallet}
|
194
192
|
/>
|
195
|
-
<Divider sx={{ m: '0!important'
|
193
|
+
<Divider sx={{ m: '0 !important' }} />
|
196
194
|
<MenuList sx={{ p: 0 }}>
|
197
195
|
{isBlocklet ? (
|
198
196
|
<>
|
@@ -221,7 +219,7 @@ export default function LoggedIn({
|
|
221
219
|
sx={{ display: 'block', color: 'inherit' }}
|
222
220
|
/>
|
223
221
|
)}
|
224
|
-
<Divider sx={{ m: '0!important'
|
222
|
+
<Divider sx={{ m: '0 !important' }} />
|
225
223
|
<DidSpace session={session} locale={locale} />
|
226
224
|
</>
|
227
225
|
) : null}
|
@@ -263,7 +261,7 @@ function SessionMenuItem<C extends ElementType>({
|
|
263
261
|
alignItems: 'center',
|
264
262
|
borderRadius: 2,
|
265
263
|
'&:hover': {
|
266
|
-
backgroundColor:
|
264
|
+
backgroundColor: 'action.hover',
|
267
265
|
},
|
268
266
|
py: 1,
|
269
267
|
}}>
|
package/src/Theme/theme.ts
CHANGED
@@ -0,0 +1,38 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { UserCardProps, InfoType } from '../types';
|
3
|
+
import TooltipAvatar from '../Content/tooltip-avatar';
|
4
|
+
|
5
|
+
interface AvatarOnlyCardProps extends UserCardProps {
|
6
|
+
renderCardContent: () => React.ReactNode;
|
7
|
+
shouldShowHoverCard: boolean;
|
8
|
+
}
|
9
|
+
|
10
|
+
// AvatarOnly卡片组件,处理仅头像模式的渲染
|
11
|
+
function AvatarOnlyCard(props: AvatarOnlyCardProps) {
|
12
|
+
const { user, infoType, avatarSize = 48, shouldShowHoverCard = false, renderCardContent } = props;
|
13
|
+
|
14
|
+
// 对于NameOnly类型使用普通Tooltip
|
15
|
+
if (infoType === InfoType.NameOnly) {
|
16
|
+
return (
|
17
|
+
<TooltipAvatar
|
18
|
+
user={user}
|
19
|
+
avatarSize={avatarSize}
|
20
|
+
shouldShowHoverCard={false}
|
21
|
+
renderCardContent={renderCardContent}
|
22
|
+
tooltipTitle={user.fullName || user.email || user.did}
|
23
|
+
/>
|
24
|
+
);
|
25
|
+
}
|
26
|
+
|
27
|
+
// 其他类型使用自定义Tooltip或无Tooltip
|
28
|
+
return (
|
29
|
+
<TooltipAvatar
|
30
|
+
user={user}
|
31
|
+
avatarSize={avatarSize}
|
32
|
+
shouldShowHoverCard={shouldShowHoverCard}
|
33
|
+
renderCardContent={renderCardContent}
|
34
|
+
/>
|
35
|
+
);
|
36
|
+
}
|
37
|
+
|
38
|
+
export default AvatarOnlyCard;
|