@arcblock/ux 2.6.9 → 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.
- package/babel.config.es.js +12 -0
- package/es/ActionButton/index.js +99 -0
- package/es/ActivityIndicator/index.js +180 -0
- package/es/Address/compact-text.js +105 -0
- package/es/Address/did-address.js +211 -0
- package/es/Address/index.js +23 -0
- package/es/Address/responsive-did-address.js +88 -0
- package/es/Alert/index.js +134 -0
- package/es/AnimationWaiter/default-animation.json +1 -0
- package/es/AnimationWaiter/index.js +239 -0
- package/es/Async/index.js +38 -0
- package/es/Avatar/did-motif.js +64 -0
- package/es/Avatar/etherscan-blockies.js +83 -0
- package/es/Avatar/index.js +176 -0
- package/es/Badge/index.js +98 -0
- package/es/Blocklet/blocklet.js +298 -0
- package/es/Blocklet/index.js +4 -0
- package/es/Blocklet/utils.js +52 -0
- package/es/BlockletNFT/index.js +412 -0
- package/es/Button/index.js +8 -0
- package/es/Button/wrap.js +140 -0
- package/es/ButtonGroup/index.js +6 -0
- package/es/CardSelector/index.js +131 -0
- package/es/Center/index.js +41 -0
- package/es/ClickToCopy/copy-button.js +72 -0
- package/es/ClickToCopy/hook.js +39 -0
- package/es/ClickToCopy/index.js +93 -0
- package/es/CodeBlock/LightBox.js +85 -0
- package/es/CodeBlock/index.js +226 -0
- package/es/Colors/index.js +2 -0
- package/es/Colors/themes/default.js +78 -0
- package/es/ContactForm/index.js +230 -0
- package/es/CookieConsent/index.js +113 -0
- package/es/CountDown/index.js +178 -0
- package/es/DID/index.js +105 -0
- package/es/Datatable/CustomToolbar.js +396 -0
- package/es/Datatable/DatatableContext.js +34 -0
- package/es/Datatable/TableSearch.js +165 -0
- package/es/Datatable/index.js +627 -0
- package/es/Datatable/utils.js +132 -0
- package/es/Dialog/confirm.js +90 -0
- package/es/Dialog/dialog.js +192 -0
- package/es/Dialog/index.js +3 -0
- package/es/DidLogo/index.js +31 -0
- package/es/DriftBot/index.js +70 -0
- package/es/Earth/countries.json +8057 -0
- package/es/Earth/index.js +521 -0
- package/es/Earth/util.js +51 -0
- package/es/Empty/index.js +64 -0
- package/es/ErrorBoundary/fallback.js +73 -0
- package/es/ErrorBoundary/index.js +1 -0
- package/es/Footer/index.js +172 -0
- package/es/Header/auto-hidden.js +35 -0
- package/es/Header/header.js +211 -0
- package/es/Header/index.js +2 -0
- package/es/Header/responsive-header.js +111 -0
- package/es/Icon/image.js +65 -0
- package/es/Icon/index.js +84 -0
- package/es/Img/index.js +217 -0
- package/es/InfoRow/index.js +87 -0
- package/es/Layout/dashboard/external-link.js +58 -0
- package/es/Layout/dashboard/full-page.js +53 -0
- package/es/Layout/dashboard/index.js +275 -0
- package/es/Layout/dashboard/sidebar.js +209 -0
- package/es/Layout/dashboard-legacy/header.js +174 -0
- package/es/Layout/dashboard-legacy/index.js +149 -0
- package/es/Layout/dashboard-legacy/sidebar.js +129 -0
- package/es/Layout/index.js +335 -0
- package/es/Locale/browser-lang.js +52 -0
- package/es/Locale/context.js +114 -0
- package/es/Locale/languages.js +60 -0
- package/es/Locale/selector.js +180 -0
- package/es/Locale/util.js +13 -0
- package/es/Logo/images/logo-dark-text.svg +3 -0
- package/es/Logo/images/logo-dark-top.svg +6 -0
- package/es/Logo/images/logo-light-text.svg +3 -0
- package/es/Logo/images/logo-light-top.svg +6 -0
- package/es/Logo/index.js +136 -0
- package/es/Metric/index.js +132 -0
- package/es/NFTDisplay/README.md +59 -0
- package/es/NFTDisplay/aspect-ratio-container.js +39 -0
- package/es/NFTDisplay/broken.js +18 -0
- package/es/NFTDisplay/demo/data/asset-state-display-url.json +7 -0
- package/es/NFTDisplay/demo/data/asset-state-gzipped-svg-1-1.json +10 -0
- package/es/NFTDisplay/demo/data/asset-state-gzipped-svg-374-130.json +10 -0
- package/es/NFTDisplay/demo/data/asset-state-gzipped-svg-with-foreign-object.json +20 -0
- package/es/NFTDisplay/demo/data/asset-state-svg.json +29 -0
- package/es/NFTDisplay/demo/data/asset-state-url.json +10 -0
- package/es/NFTDisplay/index.js +323 -0
- package/es/NFTDisplay/loading.js +18 -0
- package/es/NFTDisplay/svg-embedder/img.js +45 -0
- package/es/NFTDisplay/svg-embedder/inline-svg.js +39 -0
- package/es/NavMenu/index.js +2 -0
- package/es/NavMenu/nav-menu.js +286 -0
- package/es/NavMenu/style.js +176 -0
- package/es/PageScroller/index.js +286 -0
- package/es/PageScroller/story/FifthComponent.js +9 -0
- package/es/PageScroller/story/FirstComponent.js +9 -0
- package/es/PageScroller/story/FourthComponent.js +12 -0
- package/es/PageScroller/story/FullPage.js +47 -0
- package/es/PageScroller/story/PageContain.js +59 -0
- package/es/PageScroller/story/SecondComponent.js +9 -0
- package/es/PageScroller/story/ThirdComponent.js +9 -0
- package/es/PageScroller/story/index.css +115 -0
- package/es/PageScroller/usePrevValue.js +9 -0
- package/es/PricingTable/PricingPlan.js +124 -0
- package/es/PricingTable/index.js +53 -0
- package/es/QRCode/index.js +72 -0
- package/es/RelativeTime/index.js +98 -0
- package/es/Result/common.js +140 -0
- package/es/Result/demo/fixtures/result-image-404.svg +1 -0
- package/es/Result/index.js +33 -0
- package/es/Result/result.js +59 -0
- package/es/Result/translations.js +54 -0
- package/es/Screenshot/BaseScreenshot/index.js +91 -0
- package/es/Screenshot/BaseScreenshot/shells/Macbook.js +51 -0
- package/es/Screenshot/BaseScreenshot/shells/Phone.js +36 -0
- package/es/Screenshot/demo/images/bg-00.jpg +0 -0
- package/es/Screenshot/demo/images/bg-01.jpg +0 -0
- package/es/Screenshot/demo/images/bg-02.jpg +0 -0
- package/es/Screenshot/demo/images/bg-03.jpg +0 -0
- package/es/Screenshot/demo/images/bg-04.jpg +0 -0
- package/es/Screenshot/demo/images/bg-05.jpg +0 -0
- package/es/Screenshot/demo/images/bg-06.jpg +0 -0
- package/es/Screenshot/demo/images/bg-07.jpg +0 -0
- package/es/Screenshot/demo/images/bg-08.jpg +0 -0
- package/es/Screenshot/demo/images/bg-09.jpg +0 -0
- package/es/Screenshot/devices.css +1366 -0
- package/es/Screenshot/index.js +299 -0
- package/es/SessionManager/federated-login-detecter.js +166 -0
- package/es/SessionManager/index.js +468 -0
- package/es/SessionManager/user-popper.js +132 -0
- package/es/Sparkline/index.js +193 -0
- package/es/Spinner/index.js +28 -0
- package/es/SplitButton/index.js +144 -0
- package/es/Switch/index.js +96 -0
- package/es/Tabs/index.js +48 -0
- package/es/Tag/index.js +108 -0
- package/es/TextCollapse/index.js +92 -0
- package/es/Theme/index.js +16 -0
- package/es/Theme/theme-provider.js +39 -0
- package/es/Theme/theme.js +133 -0
- package/es/Toast/index.js +95 -0
- package/es/Util/deprecate.js +28 -0
- package/es/Util/index.js +298 -0
- package/es/Util/wallet.js +32 -0
- package/es/Video/index.js +89 -0
- package/es/Wallet/Action.js +119 -0
- package/es/Wallet/Download.js +331 -0
- package/es/Wallet/Open.js +45 -0
- package/es/Wallet/images/abtwallet.png +0 -0
- package/es/Wallet/images/android_download.svg +23 -0
- package/es/Wallet/images/app-store.svg +20 -0
- package/es/Wallet/images/google-play.svg +70 -0
- package/es/WebWalletSWKeeper/index.js +115 -0
- package/es/WechatPrompt/images/android.png +0 -0
- package/es/WechatPrompt/images/ios.png +0 -0
- package/es/WechatPrompt/index.js +88 -0
- package/es/index.js +38 -0
- package/es/withTheme/index.js +69 -0
- package/es/withTracker/README.md +34 -0
- package/es/withTracker/error_boundary.js +34 -0
- package/es/withTracker/index.js +56 -0
- package/package.json +272 -5
@@ -0,0 +1,209 @@
|
|
1
|
+
/* eslint-disable react/no-array-index-key */
|
2
|
+
import PropTypes from 'prop-types';
|
3
|
+
import Typography from '@mui/material/Typography';
|
4
|
+
import { teal } from '@mui/material/colors';
|
5
|
+
import clsx from 'clsx';
|
6
|
+
import { styled } from '../../Theme';
|
7
|
+
import { NavLink } from './external-link';
|
8
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
9
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
10
|
+
function renderGroup(item) {
|
11
|
+
return /*#__PURE__*/_jsxs("li", {
|
12
|
+
className: "layout-sidebar-group",
|
13
|
+
children: [/*#__PURE__*/_jsx("span", {
|
14
|
+
className: "layout-sidebar-group-title",
|
15
|
+
children: item.title
|
16
|
+
}), /*#__PURE__*/_jsx("ul", {
|
17
|
+
children: item.children.map(renderItem)
|
18
|
+
})]
|
19
|
+
}, `group-${item.title}`);
|
20
|
+
}
|
21
|
+
function renderItem(item) {
|
22
|
+
if (item.children?.length) {
|
23
|
+
return renderGroup(item);
|
24
|
+
}
|
25
|
+
const {
|
26
|
+
url,
|
27
|
+
icon,
|
28
|
+
title,
|
29
|
+
showBadge,
|
30
|
+
external,
|
31
|
+
active
|
32
|
+
} = item;
|
33
|
+
// external = true 时 link active 状态由传入 links 的调用方决定 (适用于 blocklet ui dashboard 的情况)
|
34
|
+
return /*#__PURE__*/_jsx("li", {
|
35
|
+
className: "layout-sidebar-item",
|
36
|
+
children: /*#__PURE__*/_jsxs(NavLink, {
|
37
|
+
external: external,
|
38
|
+
to: url,
|
39
|
+
className: ({
|
40
|
+
isActive
|
41
|
+
}) => clsx('layout-sidebar-link', {
|
42
|
+
'layout-sidebar-link--active': external ? active : isActive
|
43
|
+
}),
|
44
|
+
children: [icon && /*#__PURE__*/_jsx("span", {
|
45
|
+
className: `layout-sidebar-icon ${showBadge ? 'layout-sidebar-badge' : ''}`,
|
46
|
+
children: icon
|
47
|
+
}), /*#__PURE__*/_jsx(Typography, {
|
48
|
+
component: "span",
|
49
|
+
className: "layout-sidebar-link-text",
|
50
|
+
children: title
|
51
|
+
})]
|
52
|
+
})
|
53
|
+
}, url);
|
54
|
+
}
|
55
|
+
function Sidebar({
|
56
|
+
links,
|
57
|
+
addons,
|
58
|
+
dense,
|
59
|
+
...rest
|
60
|
+
}) {
|
61
|
+
return /*#__PURE__*/_jsxs(Root, {
|
62
|
+
...rest,
|
63
|
+
className: clsx({
|
64
|
+
'layout-sidebar-dense': dense
|
65
|
+
}),
|
66
|
+
children: [/*#__PURE__*/_jsx("ul", {
|
67
|
+
children: links.map(renderItem)
|
68
|
+
}), /*#__PURE__*/_jsx("div", {
|
69
|
+
style: {
|
70
|
+
flex: 1
|
71
|
+
}
|
72
|
+
}), addons]
|
73
|
+
});
|
74
|
+
}
|
75
|
+
Sidebar.propTypes = {
|
76
|
+
links: PropTypes.array.isRequired,
|
77
|
+
addons: PropTypes.any,
|
78
|
+
dense: PropTypes.bool
|
79
|
+
};
|
80
|
+
Sidebar.defaultProps = {
|
81
|
+
addons: null,
|
82
|
+
dense: false
|
83
|
+
};
|
84
|
+
const gradient = 'linear-gradient(32deg, rgba(144, 255, 230, 0.1), rgba(144, 255, 230, 0))';
|
85
|
+
const Root = styled('div')`
|
86
|
+
display: flex;
|
87
|
+
flex-direction: column;
|
88
|
+
ul {
|
89
|
+
list-style: none;
|
90
|
+
margin: 0;
|
91
|
+
padding: 0;
|
92
|
+
}
|
93
|
+
.layout-sidebar-link {
|
94
|
+
display: flex;
|
95
|
+
flex-direction: column;
|
96
|
+
align-items: center;
|
97
|
+
padding: 22px 24px;
|
98
|
+
color: ${props => props.theme.palette.text.secondary};
|
99
|
+
text-decoration: none;
|
100
|
+
|
101
|
+
&:hover,
|
102
|
+
&.layout-sidebar-link--active {
|
103
|
+
color: ${props => props.theme.palette.primary.main};
|
104
|
+
background: ${gradient};
|
105
|
+
border-left-color: ${teal.A700};
|
106
|
+
}
|
107
|
+
}
|
108
|
+
.layout-sidebar-icon {
|
109
|
+
display: inline-block;
|
110
|
+
width: 32px;
|
111
|
+
height: 32px;
|
112
|
+
> img,
|
113
|
+
> svg {
|
114
|
+
width: 32px;
|
115
|
+
height: 32px;
|
116
|
+
}
|
117
|
+
}
|
118
|
+
.layout-sidebar-badge {
|
119
|
+
position: relative;
|
120
|
+
&:after {
|
121
|
+
content: '';
|
122
|
+
position: absolute;
|
123
|
+
width: 10px;
|
124
|
+
height: 10px;
|
125
|
+
border-radius: 10px;
|
126
|
+
background-color: #fe4e44;
|
127
|
+
right: -2px;
|
128
|
+
top: 0;
|
129
|
+
box-shadow: 0px 1px 4px rgba(0, 0, 0, 0.3), 0px 0px 20px rgba(0, 0, 0, 0.1);
|
130
|
+
}
|
131
|
+
}
|
132
|
+
.layout-sidebar-link-text {
|
133
|
+
margin-top: 8px;
|
134
|
+
font-size: 12px;
|
135
|
+
font-weight: 500;
|
136
|
+
text-align: center;
|
137
|
+
text-transform: capitalize;
|
138
|
+
letter-spacing: normal;
|
139
|
+
}
|
140
|
+
/* dense=false 时隐藏 group title */
|
141
|
+
.layout-sidebar-group-title {
|
142
|
+
display: none;
|
143
|
+
}
|
144
|
+
&.layout-sidebar-dense {
|
145
|
+
box-sizing: border-box;
|
146
|
+
padding: 20px 0;
|
147
|
+
font-weight: bold;
|
148
|
+
.layout-sidebar-item {
|
149
|
+
padding: 0 16px;
|
150
|
+
}
|
151
|
+
.layout-sidebar-item + .layout-sidebar-item {
|
152
|
+
margin-top: 1px;
|
153
|
+
}
|
154
|
+
.layout-sidebar-link {
|
155
|
+
box-sizing: border-box;
|
156
|
+
flex-direction: row;
|
157
|
+
align-items: center;
|
158
|
+
width: 100%;
|
159
|
+
padding: 8px;
|
160
|
+
&:hover,
|
161
|
+
&.layout-sidebar-link--active {
|
162
|
+
color: ${props => props.theme.palette.grey[900]};
|
163
|
+
background: ${props => props.theme.palette.grey[100]};
|
164
|
+
border: 0;
|
165
|
+
border-radius: 4px;
|
166
|
+
}
|
167
|
+
}
|
168
|
+
.layout-sidebar-icon {
|
169
|
+
display: inline-block;
|
170
|
+
width: 20px;
|
171
|
+
height: 20px;
|
172
|
+
margin-right: 8px;
|
173
|
+
> img,
|
174
|
+
> svg {
|
175
|
+
width: 20px;
|
176
|
+
height: 20px;
|
177
|
+
}
|
178
|
+
}
|
179
|
+
.layout-sidebar-badge {
|
180
|
+
&:after {
|
181
|
+
width: 6px;
|
182
|
+
height: 6px;
|
183
|
+
border-radius: 6px;
|
184
|
+
right: -2px;
|
185
|
+
top: 0;
|
186
|
+
}
|
187
|
+
}
|
188
|
+
.layout-sidebar-link-text {
|
189
|
+
margin-top: 0;
|
190
|
+
font-size: 14px;
|
191
|
+
line-height: 1;
|
192
|
+
}
|
193
|
+
.layout-sidebar-group {
|
194
|
+
color: ${props => props.theme.palette.text.hint};
|
195
|
+
.layout-sidebar-group-title {
|
196
|
+
display: inline-block;
|
197
|
+
padding: 8px 0 8px 24px;
|
198
|
+
font-size: 13px;
|
199
|
+
text-transform: uppercase;
|
200
|
+
}
|
201
|
+
}
|
202
|
+
.layout-sidebar-group + .layout-sidebar-group,
|
203
|
+
.layout-sidebar-group + .layout-sidebar-item,
|
204
|
+
.layout-sidebar-item + .layout-sidebar-group {
|
205
|
+
margin-top: 16px;
|
206
|
+
}
|
207
|
+
}
|
208
|
+
`;
|
209
|
+
export default Sidebar;
|
@@ -0,0 +1,174 @@
|
|
1
|
+
import PropTypes from 'prop-types';
|
2
|
+
import Button from '@mui/material/IconButton';
|
3
|
+
import AppBar from '@mui/material/AppBar';
|
4
|
+
import Toolbar from '@mui/material/Toolbar';
|
5
|
+
import Box from '@mui/material/Box';
|
6
|
+
import Typography from '@mui/material/Typography';
|
7
|
+
import Hidden from '@mui/material/Hidden';
|
8
|
+
import MenuIcon from '@mui/icons-material/Menu';
|
9
|
+
import { Link } from 'react-router-dom';
|
10
|
+
import Logo from '../../Logo';
|
11
|
+
import { styled } from '../../Theme';
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
13
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
14
|
+
const StyledAppBar = styled(AppBar)`
|
15
|
+
&& {
|
16
|
+
z-index: ${props => props.theme.zIndex.drawer};
|
17
|
+
background: ${props => props.theme.palette.background.default};
|
18
|
+
box-shadow: none;
|
19
|
+
top: 0;
|
20
|
+
height: auto;
|
21
|
+
}
|
22
|
+
.header-toolbar {
|
23
|
+
background: ${props => props.theme.palette.background.default};
|
24
|
+
color: ${props => props.theme.palette.text.primary};
|
25
|
+
margin: ${props => props.theme.spacing(1)}px 0;
|
26
|
+
}
|
27
|
+
.header-link {
|
28
|
+
display: flex;
|
29
|
+
text-decoration: none;
|
30
|
+
flex-shrink: 1;
|
31
|
+
overflow: hidden;
|
32
|
+
}
|
33
|
+
.header-logo {
|
34
|
+
margin-right: 20px;
|
35
|
+
}
|
36
|
+
.header-title {
|
37
|
+
display: flex;
|
38
|
+
flex-direction: column;
|
39
|
+
justify-content: center;
|
40
|
+
align-items: flex-start;
|
41
|
+
}
|
42
|
+
.header-title__primary {
|
43
|
+
font-size: 24px;
|
44
|
+
font-weight: 800;
|
45
|
+
color: ${props => props.theme.typography.color.main};
|
46
|
+
text-transform: uppercase;
|
47
|
+
display: flex;
|
48
|
+
align-items: center;
|
49
|
+
}
|
50
|
+
.header-title__secondary {
|
51
|
+
font-size: 14px;
|
52
|
+
line-height: 1.71;
|
53
|
+
color: ${props => props.theme.typography.color.gray};
|
54
|
+
}
|
55
|
+
|
56
|
+
.header-addons {
|
57
|
+
display: flex;
|
58
|
+
justify-content: center;
|
59
|
+
align-items: center;
|
60
|
+
flex-shrink: 9999999;
|
61
|
+
|
62
|
+
.user-addon {
|
63
|
+
.header-avatar {
|
64
|
+
width: 32px;
|
65
|
+
border-radius: 16px;
|
66
|
+
height: auto;
|
67
|
+
}
|
68
|
+
}
|
69
|
+
}
|
70
|
+
.header-menu {
|
71
|
+
display: none;
|
72
|
+
}
|
73
|
+
${props => props.theme.breakpoints.down('md')} {
|
74
|
+
.header-title {
|
75
|
+
display: none;
|
76
|
+
}
|
77
|
+
.header-title__primary {
|
78
|
+
font-size: 20px;
|
79
|
+
}
|
80
|
+
.header-menu {
|
81
|
+
display: block;
|
82
|
+
}
|
83
|
+
}
|
84
|
+
`;
|
85
|
+
|
86
|
+
/*
|
87
|
+
自定义 logo 相关:
|
88
|
+
如果为 logo prop 传入一个自定义的 svg, 并且 svg 中的元素通过 id 引用了 defs 中的元素 (比如 linearGradient),
|
89
|
+
这种情况下因为 header 和 sidebar 中会各有一个相同的 svg, defs 中元素的 id 会出现冲突,
|
90
|
+
当屏幕较窄时, header 会通过设置 display:none 将 svg logo 隐藏,
|
91
|
+
这会导致 svg defs 中的元素不能被正常引用 (比如 fill 引用的 color 失效), 这会进一步导致 sidebar 中的 logo 不能正常显示.
|
92
|
+
考虑到上述问题, 目前使用 Hidden 组件控制 logo 的显示/隐藏
|
93
|
+
参考: https://blog.patw.me/archives/1820/inline-svg-same-id-and-display-none-issue/
|
94
|
+
*/
|
95
|
+
export default function Header({
|
96
|
+
children,
|
97
|
+
brand,
|
98
|
+
brandAddon,
|
99
|
+
description,
|
100
|
+
addons,
|
101
|
+
onToggleMenu,
|
102
|
+
homeUrl,
|
103
|
+
logo,
|
104
|
+
...rest
|
105
|
+
}) {
|
106
|
+
return /*#__PURE__*/_jsx(StyledAppBar, {
|
107
|
+
position: "sticky",
|
108
|
+
className: "header",
|
109
|
+
...rest,
|
110
|
+
children: /*#__PURE__*/_jsxs(Toolbar, {
|
111
|
+
disableGutters: false,
|
112
|
+
className: "header-toolbar",
|
113
|
+
children: [/*#__PURE__*/_jsx(Button, {
|
114
|
+
color: "inherit",
|
115
|
+
"aria-label": "open drawer",
|
116
|
+
edge: "start",
|
117
|
+
className: "header-menu",
|
118
|
+
"aira-label": "header menu button",
|
119
|
+
onClick: onToggleMenu,
|
120
|
+
children: /*#__PURE__*/_jsx(MenuIcon, {})
|
121
|
+
}), /*#__PURE__*/_jsxs(Link, {
|
122
|
+
to: homeUrl,
|
123
|
+
className: "header-link",
|
124
|
+
children: [/*#__PURE__*/_jsx(Hidden, {
|
125
|
+
mdDown: true,
|
126
|
+
children: /*#__PURE__*/_jsx("div", {
|
127
|
+
className: "header-logo",
|
128
|
+
children: logo || /*#__PURE__*/_jsx(Logo, {
|
129
|
+
showText: false
|
130
|
+
})
|
131
|
+
})
|
132
|
+
}), /*#__PURE__*/_jsxs("div", {
|
133
|
+
className: "header-title",
|
134
|
+
children: [/*#__PURE__*/_jsxs(Typography, {
|
135
|
+
component: "h2",
|
136
|
+
noWrap: true,
|
137
|
+
className: "header-title__primary",
|
138
|
+
children: [brand, brandAddon]
|
139
|
+
}), /*#__PURE__*/_jsx(Typography, {
|
140
|
+
component: "p",
|
141
|
+
noWrap: true,
|
142
|
+
className: "header-title__secondary",
|
143
|
+
children: description
|
144
|
+
})]
|
145
|
+
})]
|
146
|
+
}), /*#__PURE__*/_jsx(Box, {
|
147
|
+
flexGrow: 1
|
148
|
+
}), !!children && /*#__PURE__*/_jsx("div", {
|
149
|
+
className: "header-children",
|
150
|
+
children: children
|
151
|
+
}), /*#__PURE__*/_jsx("div", {
|
152
|
+
className: "header-addons",
|
153
|
+
children: addons
|
154
|
+
})]
|
155
|
+
})
|
156
|
+
});
|
157
|
+
}
|
158
|
+
Header.propTypes = {
|
159
|
+
onToggleMenu: PropTypes.func.isRequired,
|
160
|
+
brand: PropTypes.string.isRequired,
|
161
|
+
brandAddon: PropTypes.object,
|
162
|
+
description: PropTypes.any.isRequired,
|
163
|
+
children: PropTypes.any,
|
164
|
+
addons: PropTypes.any,
|
165
|
+
homeUrl: PropTypes.string,
|
166
|
+
logo: PropTypes.any
|
167
|
+
};
|
168
|
+
Header.defaultProps = {
|
169
|
+
children: null,
|
170
|
+
addons: null,
|
171
|
+
brandAddon: null,
|
172
|
+
homeUrl: '/',
|
173
|
+
logo: null
|
174
|
+
};
|
@@ -0,0 +1,149 @@
|
|
1
|
+
import { useEffect, useState } from 'react';
|
2
|
+
import PropTypes from 'prop-types';
|
3
|
+
import Helmet from 'react-helmet';
|
4
|
+
import Container from '@mui/material/Container';
|
5
|
+
import Box from '@mui/material/Box';
|
6
|
+
import Drawer from '@mui/material/Drawer';
|
7
|
+
import useWindowSize from 'react-use/lib/useWindowSize';
|
8
|
+
import Sidebar from './sidebar';
|
9
|
+
import Header from './header';
|
10
|
+
import Footer from '../../Footer';
|
11
|
+
import { styled } from '../../Theme';
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
13
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
14
|
+
const Wrapper = styled('div')`
|
15
|
+
&.dashboard {
|
16
|
+
display: flex;
|
17
|
+
flex-direction: column;
|
18
|
+
height: 100vh;
|
19
|
+
}
|
20
|
+
.dashboard__body {
|
21
|
+
overflow: hidden;
|
22
|
+
flex: 1;
|
23
|
+
}
|
24
|
+
.dashboard__main {
|
25
|
+
display: flex;
|
26
|
+
flex-direction: column;
|
27
|
+
overflow: auto;
|
28
|
+
flex: 1;
|
29
|
+
}
|
30
|
+
.dashboard__content {
|
31
|
+
flex: 1;
|
32
|
+
}
|
33
|
+
|
34
|
+
.drawerPaper {
|
35
|
+
position: relative;
|
36
|
+
white-space: nowrap;
|
37
|
+
width: 120px;
|
38
|
+
background: ${props => props.theme.palette.background.default};
|
39
|
+
box-shadow: 2px 16px 10px 0 rgba(0, 0, 0, ${props => props.theme.mode === 'light' ? 0.05 : 0.5});
|
40
|
+
border: 0;
|
41
|
+
}
|
42
|
+
`;
|
43
|
+
export default function Dashboard({
|
44
|
+
children,
|
45
|
+
title,
|
46
|
+
brand,
|
47
|
+
description,
|
48
|
+
brandAddon,
|
49
|
+
headerAddon,
|
50
|
+
images,
|
51
|
+
links,
|
52
|
+
prefix,
|
53
|
+
fullWidth,
|
54
|
+
contentLayout,
|
55
|
+
className,
|
56
|
+
homeUrl,
|
57
|
+
logo,
|
58
|
+
...rest
|
59
|
+
}) {
|
60
|
+
const breakpoint = 960;
|
61
|
+
const {
|
62
|
+
width
|
63
|
+
} = useWindowSize();
|
64
|
+
const [drawerMode, setDrawerMode] = useState(width >= breakpoint ? 'permanent' : 'temporary');
|
65
|
+
const [drawerOpen, setDrawerOpen] = useState(drawerMode === 'permanent');
|
66
|
+
useEffect(() => {
|
67
|
+
const newMode = width >= breakpoint ? 'permanent' : 'temporary';
|
68
|
+
setDrawerMode(newMode);
|
69
|
+
setDrawerOpen(newMode !== 'temporary');
|
70
|
+
}, [width]);
|
71
|
+
const onToggleDrawer = () => {
|
72
|
+
setDrawerOpen(!drawerOpen);
|
73
|
+
};
|
74
|
+
const isFullWidth = fullWidth || contentLayout === 'row';
|
75
|
+
return /*#__PURE__*/_jsxs(Wrapper, {
|
76
|
+
className: `dashboard ${className}`,
|
77
|
+
...rest,
|
78
|
+
children: [/*#__PURE__*/_jsx(Helmet, {
|
79
|
+
title: `${title}-${brand}`
|
80
|
+
}), /*#__PURE__*/_jsx(Header, {
|
81
|
+
className: "dashboard__header",
|
82
|
+
onToggleMenu: onToggleDrawer,
|
83
|
+
brand: brand,
|
84
|
+
brandAddon: brandAddon,
|
85
|
+
description: description,
|
86
|
+
addons: headerAddon,
|
87
|
+
homeUrl: homeUrl,
|
88
|
+
logo: logo
|
89
|
+
}), /*#__PURE__*/_jsxs(Box, {
|
90
|
+
display: "flex",
|
91
|
+
className: "dashboard__body",
|
92
|
+
children: [/*#__PURE__*/_jsx(Drawer, {
|
93
|
+
variant: drawerMode,
|
94
|
+
className: "drawer",
|
95
|
+
classes: {
|
96
|
+
paper: 'drawerPaper'
|
97
|
+
},
|
98
|
+
open: drawerOpen,
|
99
|
+
onClose: onToggleDrawer,
|
100
|
+
ModalProps: {
|
101
|
+
disablePortal: true,
|
102
|
+
keepMounted: true
|
103
|
+
},
|
104
|
+
children: /*#__PURE__*/_jsx(Sidebar, {
|
105
|
+
className: "dashboard__sidebar",
|
106
|
+
images: images,
|
107
|
+
links: links,
|
108
|
+
prefix: prefix,
|
109
|
+
logo: logo
|
110
|
+
})
|
111
|
+
}), /*#__PURE__*/_jsxs(Box, {
|
112
|
+
className: "dashboard__main",
|
113
|
+
children: [/*#__PURE__*/_jsx(Container, {
|
114
|
+
maxWidth: isFullWidth ? false : 'lg',
|
115
|
+
className: "dashboard__content",
|
116
|
+
children: children
|
117
|
+
}), /*#__PURE__*/_jsx(Footer, {})]
|
118
|
+
})]
|
119
|
+
})]
|
120
|
+
});
|
121
|
+
}
|
122
|
+
Dashboard.propTypes = {
|
123
|
+
children: PropTypes.any.isRequired,
|
124
|
+
title: PropTypes.string,
|
125
|
+
brand: PropTypes.string.isRequired,
|
126
|
+
links: PropTypes.array.isRequired,
|
127
|
+
images: PropTypes.object.isRequired,
|
128
|
+
brandAddon: PropTypes.object,
|
129
|
+
description: PropTypes.any.isRequired,
|
130
|
+
headerAddon: PropTypes.any,
|
131
|
+
prefix: PropTypes.string,
|
132
|
+
// 兼容旧版的设置,新版使用 fullWidth 进行设置
|
133
|
+
contentLayout: PropTypes.oneOf(['row', 'column']),
|
134
|
+
fullWidth: PropTypes.bool,
|
135
|
+
className: PropTypes.string,
|
136
|
+
homeUrl: PropTypes.string,
|
137
|
+
logo: PropTypes.any
|
138
|
+
};
|
139
|
+
Dashboard.defaultProps = {
|
140
|
+
title: 'Home',
|
141
|
+
contentLayout: 'column',
|
142
|
+
headerAddon: null,
|
143
|
+
brandAddon: null,
|
144
|
+
prefix: '/images',
|
145
|
+
fullWidth: false,
|
146
|
+
className: '',
|
147
|
+
homeUrl: '/',
|
148
|
+
logo: null
|
149
|
+
};
|
@@ -0,0 +1,129 @@
|
|
1
|
+
import { memo } from 'react';
|
2
|
+
import PropTypes from 'prop-types';
|
3
|
+
import { Link, useLocation } from 'react-router-dom';
|
4
|
+
import Button from '@mui/material/Button';
|
5
|
+
import Typography from '@mui/material/Typography';
|
6
|
+
import { teal } from '@mui/material/colors';
|
7
|
+
import ImageIcon from '../../Icon/image';
|
8
|
+
import Logo from '../../Logo';
|
9
|
+
import { styled, useTheme } from '../../Theme';
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
11
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
12
|
+
export default function Sidebar({
|
13
|
+
images,
|
14
|
+
links,
|
15
|
+
prefix,
|
16
|
+
addons,
|
17
|
+
logo,
|
18
|
+
...rest
|
19
|
+
}) {
|
20
|
+
const theme = useTheme();
|
21
|
+
const location = useLocation();
|
22
|
+
const isSelected = (url, name) => {
|
23
|
+
const pattern = new RegExp(`/${name}`);
|
24
|
+
return pattern.test(location.pathname);
|
25
|
+
};
|
26
|
+
return /*#__PURE__*/_jsxs(MenuItems, {
|
27
|
+
...rest,
|
28
|
+
children: [/*#__PURE__*/_jsx(Link, {
|
29
|
+
to: "/",
|
30
|
+
className: "sidebar-logo",
|
31
|
+
children: logo || /*#__PURE__*/_jsx(Logo, {
|
32
|
+
showText: false,
|
33
|
+
size: 20
|
34
|
+
})
|
35
|
+
}), links.map(({
|
36
|
+
url,
|
37
|
+
name,
|
38
|
+
title,
|
39
|
+
showBadge
|
40
|
+
}) => {
|
41
|
+
const selected = isSelected(url, name);
|
42
|
+
return /*#__PURE__*/_jsxs(MenuItem, {
|
43
|
+
component: Link,
|
44
|
+
selected: selected,
|
45
|
+
to: url,
|
46
|
+
children: [/*#__PURE__*/_jsx(ImageIcon, {
|
47
|
+
name: images[name],
|
48
|
+
size: 36,
|
49
|
+
color: selected ? '#00c2c4' : theme.typography.color.main,
|
50
|
+
prefix: prefix,
|
51
|
+
showBadge: showBadge
|
52
|
+
}), /*#__PURE__*/_jsx(Typography, {
|
53
|
+
component: "span",
|
54
|
+
className: "menu-title",
|
55
|
+
children: title
|
56
|
+
})]
|
57
|
+
}, url);
|
58
|
+
}), /*#__PURE__*/_jsx("div", {
|
59
|
+
style: {
|
60
|
+
flex: 1
|
61
|
+
}
|
62
|
+
}), addons]
|
63
|
+
});
|
64
|
+
}
|
65
|
+
Sidebar.propTypes = {
|
66
|
+
images: PropTypes.object.isRequired,
|
67
|
+
links: PropTypes.array.isRequired,
|
68
|
+
prefix: PropTypes.string,
|
69
|
+
addons: PropTypes.any,
|
70
|
+
logo: PropTypes.any
|
71
|
+
};
|
72
|
+
Sidebar.defaultProps = {
|
73
|
+
prefix: '/images',
|
74
|
+
addons: null,
|
75
|
+
logo: null
|
76
|
+
};
|
77
|
+
const MenuItems = /*#__PURE__*/memo(styled('div')`
|
78
|
+
flex: 1;
|
79
|
+
display: flex;
|
80
|
+
flex-direction: column;
|
81
|
+
|
82
|
+
&& .sidebar-logo {
|
83
|
+
display: none;
|
84
|
+
border-bottom: 1px solid #eee;
|
85
|
+
background: ${props => props.theme.palette.background.default};
|
86
|
+
position: sticky;
|
87
|
+
top: 0;
|
88
|
+
z-index: 1;
|
89
|
+
padding: 10px 0;
|
90
|
+
text-align: center;
|
91
|
+
font-size: 0;
|
92
|
+
}
|
93
|
+
${props => props.theme.breakpoints.down('md')} {
|
94
|
+
&& .sidebar-logo {
|
95
|
+
display: block;
|
96
|
+
}
|
97
|
+
}
|
98
|
+
`);
|
99
|
+
const gradient = 'linear-gradient(32deg, rgba(144, 255, 230, 0.1), rgba(144, 255, 230, 0))';
|
100
|
+
const MenuItem = styled(Button)`
|
101
|
+
&& {
|
102
|
+
display: flex;
|
103
|
+
flex-direction: column;
|
104
|
+
justify-content: center;
|
105
|
+
align-items: center;
|
106
|
+
width: 100%;
|
107
|
+
transition: all 200ms ease-in-out;
|
108
|
+
background: ${props => props.selected ? gradient : ''};
|
109
|
+
padding: 24px 0;
|
110
|
+
border-left: 2px solid ${props => props.selected ? teal.A700 : 'transparent'};
|
111
|
+
border-radius: 0;
|
112
|
+
|
113
|
+
&:hover {
|
114
|
+
background: ${gradient};
|
115
|
+
border-left-color: ${teal.A700};
|
116
|
+
}
|
117
|
+
|
118
|
+
.menu-title {
|
119
|
+
margin-top: 8px;
|
120
|
+
font-size: 12px;
|
121
|
+
font-weight: 500;
|
122
|
+
text-align: center;
|
123
|
+
text-transform: capitalize;
|
124
|
+
letter-spacing: normal;
|
125
|
+
width: 80%;
|
126
|
+
color: ${props => props.theme.palette.text.primary};
|
127
|
+
}
|
128
|
+
}
|
129
|
+
`;
|