Skip to content

Commit 963ac5b

Browse files
committed
enhance(ui): use rounded menu item in drawer
1 parent 5ff53fe commit 963ac5b

File tree

4 files changed

+278
-33
lines changed

4 files changed

+278
-33
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@
102102
"semver": "6.3.0",
103103
"streamsaver": "^2.0.6",
104104
"style-loader": "1.0.0",
105+
"styled-components": "^5.3.6",
105106
"terser-webpack-plugin": "1.4.1",
106107
"timeago-react": "^3.0.0",
107108
"ts-pnp": "1.1.4",

src/component/Navbar/FileTags.js

Lines changed: 42 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import React, { Suspense, useCallback, useState } from "react";
22
import {
33
Divider,
44
List,
5-
ListItem,
65
ListItemIcon,
76
ListItemText,
87
makeStyles,
@@ -21,6 +20,7 @@ import pathHelper from "../../utils/page";
2120
import MuiExpansionPanel from "@material-ui/core/ExpansionPanel";
2221
import MuiExpansionPanelSummary from "@material-ui/core/ExpansionPanelSummary";
2322
import MuiExpansionPanelDetails from "@material-ui/core/ExpansionPanelDetails";
23+
import MuiListItem from "@material-ui/core/ListItem";
2424
import { useDispatch } from "react-redux";
2525
import Auth from "../../middleware/Auth";
2626
import {
@@ -47,6 +47,12 @@ import API from "../../middleware/Api";
4747
import { navigateTo, searchMyFile, toggleSnackbar } from "../../redux/explorer";
4848
import { useTranslation } from "react-i18next";
4949

50+
const ListItem = withStyles((theme) => ({
51+
root: {
52+
borderRadius:theme.shape.borderRadius,
53+
},
54+
}))(MuiListItem);
55+
5056
const ExpansionPanel = withStyles({
5157
root: {
5258
maxWidth: "100%",
@@ -62,11 +68,10 @@ const ExpansionPanel = withStyles({
6268
expanded: {},
6369
})(MuiExpansionPanel);
6470

65-
const ExpansionPanelSummary = withStyles({
71+
const ExpansionPanelSummary = withStyles((theme) =>({
6672
root: {
6773
minHeight: 0,
6874
padding: 0,
69-
7075
"&$expanded": {
7176
minHeight: 0,
7277
},
@@ -80,7 +85,7 @@ const ExpansionPanelSummary = withStyles({
8085
},
8186
},
8287
expanded: {},
83-
})(MuiExpansionPanelSummary);
88+
}))(MuiExpansionPanelSummary);
8489

8590
const ExpansionPanelDetails = withStyles((theme) => ({
8691
root: {
@@ -112,6 +117,13 @@ const useStyles = makeStyles((theme) => ({
112117
overflow: "hidden",
113118
textOverflow: "ellipsis",
114119
},
120+
paddingList:{
121+
padding:theme.spacing(1),
122+
},
123+
paddingSummary:{
124+
paddingLeft:theme.spacing(1),
125+
paddingRight:theme.spacing(1),
126+
}
115127
}));
116128

117129
const icons = {
@@ -223,35 +235,38 @@ export default function FileTag() {
223235
aria-controls="panel1d-content"
224236
id="panel1d-header"
225237
>
226-
<ListItem
227-
button
228-
key="我的文件"
229-
onClick={() =>
230-
!isHomePage && history.push("/home?path=%2F")
231-
}
232-
>
233-
<ListItemIcon>
234-
<KeyboardArrowRight
235-
className={classNames(
236-
{
237-
[classes.expanded]:
238+
<div className={classes.paddingSummary}>
239+
<ListItem
240+
button
241+
key="我的文件"
242+
onClick={() =>
243+
!isHomePage && history.push("/home?path=%2F")
244+
}
245+
>
246+
<ListItemIcon>
247+
<KeyboardArrowRight
248+
className={classNames(
249+
{
250+
[classes.expanded]:
238251
tagOpen && isHomePage,
239-
[classes.iconFix]: true,
240-
},
241-
classes.expand
252+
[classes.iconFix]: true,
253+
},
254+
classes.expand
255+
)}
256+
/>
257+
{!(tagOpen && isHomePage) && (
258+
<FolderShared className={classes.iconFix} />
242259
)}
243-
/>
244-
{!(tagOpen && isHomePage) && (
245-
<FolderShared className={classes.iconFix} />
246-
)}
247-
</ListItemIcon>
248-
<ListItemText primary={t("navbar.myFiles")} />
249-
</ListItem>
260+
</ListItemIcon>
261+
<ListItemText primary={t("navbar.myFiles")} />
262+
</ListItem>
263+
</div>
264+
250265
<Divider />
251266
</ExpansionPanelSummary>
252267

253268
<ExpansionPanelDetails>
254-
<List onMouseLeave={() => setTagHover(null)}>
269+
<List className={classes.paddingList} onMouseLeave={() => setTagHover(null)}>
255270
<ListItem
256271
button
257272
id="pickfiles"

src/component/Navbar/Navbar.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,14 @@ import {
3333
Hidden,
3434
IconButton,
3535
List,
36-
ListItem,
3736
ListItemIcon,
3837
ListItemText,
3938
SwipeableDrawer,
4039
Toolbar,
4140
Tooltip,
4241
Typography,
4342
withStyles,
44-
withTheme,
43+
withTheme
4544
} from "@material-ui/core";
4645
import Auth from "../../middleware/Auth";
4746
import API from "../../middleware/Api";
@@ -74,11 +73,18 @@ import {
7473
startDownload,
7574
} from "../../redux/explorer/action";
7675
import { withTranslation } from "react-i18next";
76+
import MuiListItem from "@material-ui/core/ListItem";
7777

7878
vhCheck();
7979
const drawerWidth = 240;
8080
const drawerWidthMobile = 270;
8181

82+
const ListItem = withStyles((theme) => ({
83+
root: {
84+
borderRadius:theme.shape.borderRadius,
85+
},
86+
}))(MuiListItem);
87+
8288
const mapStateToProps = (state) => {
8389
return {
8490
desktopOpen: state.viewUpdate.open,
@@ -295,6 +301,9 @@ const styles = (theme) => ({
295301
minStickDrawer: {
296302
overflowY: "auto",
297303
},
304+
paddingList:{
305+
padding:theme.spacing(1),
306+
}
298307
});
299308
class NavbarCompoment extends Component {
300309
constructor(props) {
@@ -396,7 +405,7 @@ class NavbarCompoment extends Component {
396405
<>
397406
<div className={classes.minStickDrawer}>
398407
<FileTag />
399-
<List>
408+
<List className={classes.paddingList}>
400409
<ListItem
401410
button
402411
key="我的分享"

0 commit comments

Comments
 (0)