@arcblock/ux 2.1.15 → 2.1.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/lib/Datatable/TableSearch.js +17 -2
- package/lib/Datatable/index.js +4 -2
- package/lib/Header/header.js +4 -3
- package/lib/Header/responsive-header.js +1 -1
- package/lib/Layout/dashboard/index.js +121 -100
- package/lib/Layout/dashboard/sidebar.js +23 -64
- package/lib/Layout/{dashboard → dashboard-legacy}/header.js +1 -1
- package/lib/Layout/dashboard-legacy/index.js +154 -0
- package/lib/Layout/dashboard-legacy/sidebar.js +117 -0
- package/lib/NavMenu/nav-menu.js +1 -3
- package/package.json +4 -4
- package/src/Datatable/TableSearch.js +16 -3
- package/src/Datatable/index.js +6 -2
- package/src/Header/header.js +9 -3
- package/src/Header/responsive-header.js +1 -1
- package/src/Layout/dashboard/index.js +117 -116
- package/src/Layout/dashboard/sidebar.js +69 -84
- package/src/Layout/{dashboard → dashboard-legacy}/header.js +0 -0
- package/src/Layout/dashboard-legacy/index.js +150 -0
- package/src/Layout/dashboard-legacy/sidebar.js +120 -0
- package/src/NavMenu/nav-menu.js +1 -3
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
import withTheme from '@mui/styles/withTheme';
|
|
5
|
+
|
|
6
|
+
import { withRouter, Link } from 'react-router-dom';
|
|
7
|
+
import Button from '@mui/material/Button';
|
|
8
|
+
import Typography from '@mui/material/Typography';
|
|
9
|
+
import { teal } from '@mui/material/colors';
|
|
10
|
+
|
|
11
|
+
import ImageIcon from '../../Icon/image';
|
|
12
|
+
import Logo from '../../Logo';
|
|
13
|
+
|
|
14
|
+
function Sidebar({ location, theme, images, links, prefix, addons, logo, ...rest }) {
|
|
15
|
+
const isSelected = (url, name) => {
|
|
16
|
+
const pattern = new RegExp(`/${name}`);
|
|
17
|
+
return pattern.test(location.pathname);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<MenuItems {...rest}>
|
|
22
|
+
<Link to="/" className="sidebar-logo">
|
|
23
|
+
{logo || <Logo showText={false} size={20} />}
|
|
24
|
+
</Link>
|
|
25
|
+
{links.map(({ url, name, title, showBadge }) => {
|
|
26
|
+
const selected = isSelected(url, name);
|
|
27
|
+
return (
|
|
28
|
+
<MenuItem component={Link} key={url} selected={selected} to={url}>
|
|
29
|
+
<ImageIcon
|
|
30
|
+
name={images[name]}
|
|
31
|
+
size={36}
|
|
32
|
+
color={selected ? '#00c2c4' : theme.typography.color.main}
|
|
33
|
+
prefix={prefix}
|
|
34
|
+
showBadge={showBadge}
|
|
35
|
+
/>
|
|
36
|
+
<Typography component="span" className="menu-title">
|
|
37
|
+
{title}
|
|
38
|
+
</Typography>
|
|
39
|
+
</MenuItem>
|
|
40
|
+
);
|
|
41
|
+
})}
|
|
42
|
+
<div style={{ flex: 1 }} />
|
|
43
|
+
{addons}
|
|
44
|
+
</MenuItems>
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
Sidebar.propTypes = {
|
|
49
|
+
location: PropTypes.object.isRequired,
|
|
50
|
+
theme: PropTypes.object.isRequired,
|
|
51
|
+
images: PropTypes.object.isRequired,
|
|
52
|
+
links: PropTypes.array.isRequired,
|
|
53
|
+
prefix: PropTypes.string,
|
|
54
|
+
addons: PropTypes.any,
|
|
55
|
+
logo: PropTypes.any,
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
Sidebar.defaultProps = {
|
|
59
|
+
prefix: '/images',
|
|
60
|
+
addons: null,
|
|
61
|
+
logo: null,
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const MenuItems = React.memo(styled.div`
|
|
65
|
+
flex: 1;
|
|
66
|
+
display: flex;
|
|
67
|
+
flex-direction: column;
|
|
68
|
+
|
|
69
|
+
&& .sidebar-logo {
|
|
70
|
+
display: none;
|
|
71
|
+
border-bottom: 1px solid #eee;
|
|
72
|
+
background: ${props => props.theme.palette.background.default};
|
|
73
|
+
position: sticky;
|
|
74
|
+
top: 0;
|
|
75
|
+
z-index: 1;
|
|
76
|
+
padding: 10px 0;
|
|
77
|
+
text-align: center;
|
|
78
|
+
font-size: 0;
|
|
79
|
+
}
|
|
80
|
+
${props => props.theme.breakpoints.down('md')} {
|
|
81
|
+
&& .sidebar-logo {
|
|
82
|
+
display: block;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
`);
|
|
86
|
+
|
|
87
|
+
const gradient = 'linear-gradient(32deg, rgba(144, 255, 230, 0.1), rgba(144, 255, 230, 0))';
|
|
88
|
+
|
|
89
|
+
const MenuItem = styled(Button)`
|
|
90
|
+
&& {
|
|
91
|
+
display: flex;
|
|
92
|
+
flex-direction: column;
|
|
93
|
+
justify-content: center;
|
|
94
|
+
align-items: center;
|
|
95
|
+
width: 100%;
|
|
96
|
+
transition: all 200ms ease-in-out;
|
|
97
|
+
background: ${props => (props.selected ? gradient : '')};
|
|
98
|
+
padding: 24px 0;
|
|
99
|
+
border-left: 2px solid ${props => (props.selected ? teal.A700 : 'transparent')};
|
|
100
|
+
border-radius: 0;
|
|
101
|
+
|
|
102
|
+
&:hover {
|
|
103
|
+
background: ${gradient};
|
|
104
|
+
border-left-color: ${teal.A700};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.menu-title {
|
|
108
|
+
margin-top: 8px;
|
|
109
|
+
font-size: 12px;
|
|
110
|
+
font-weight: 500;
|
|
111
|
+
text-align: center;
|
|
112
|
+
text-transform: capitalize;
|
|
113
|
+
letter-spacing: normal;
|
|
114
|
+
width: 80%;
|
|
115
|
+
color: ${props => props.theme.palette.text.primary};
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
`;
|
|
119
|
+
|
|
120
|
+
export default withRouter(withTheme(Sidebar));
|
package/src/NavMenu/nav-menu.js
CHANGED
|
@@ -120,7 +120,7 @@ function Item({ id: _id, icon, label, active, onClick, ...rest }) {
|
|
|
120
120
|
if (active) {
|
|
121
121
|
activate(id);
|
|
122
122
|
}
|
|
123
|
-
}, []);
|
|
123
|
+
}, [active]);
|
|
124
124
|
const handleClick = () => {
|
|
125
125
|
onClick?.();
|
|
126
126
|
activate(id);
|
|
@@ -138,8 +138,6 @@ Item.propTypes = {
|
|
|
138
138
|
id: PropTypes.string,
|
|
139
139
|
icon: PropTypes.element,
|
|
140
140
|
label: PropTypes.node,
|
|
141
|
-
// 未显式指定各个 item#id 时, 不方便设置 NavMenu#defaultActiveId, 此时可以给 item 指定 active, 表示 nav menu 默认激活该 item
|
|
142
|
-
// (仅在初始化时有效, 后续更新无效)
|
|
143
141
|
active: PropTypes.bool,
|
|
144
142
|
onClick: PropTypes.func,
|
|
145
143
|
};
|