-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathSidenavi.tsx
91 lines (85 loc) · 2.43 KB
/
Sidenavi.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import { List } from "@material-ui/core"
import { createStyles, makeStyles, Theme } from "@material-ui/core/styles"
import SvgIcon from "@material-ui/core/SvgIcon"
import React from "react"
import { Page, SiteInfo } from "../../constants"
import { usePage } from "../../hooks"
import { NextListItem } from "../molecules"
const useStyles = makeStyles((theme: Theme) =>
createStyles({
root: {
backgroundColor: theme.palette.primary.main,
},
siteNameContainer: {
fontSize: "30px",
display: "flex",
justifyContent: "center",
alignItems: "center",
backgroundColor: theme.palette.primary.main,
color: theme.palette.primary.contrastText,
fontWeight: "bold",
boxShadow: theme.shadows[4],
zIndex: theme.zIndex.drawer + 1,
},
toolbar: theme.mixins.toolbar,
list: {
padding: 0,
border: 0,
},
listItem: {
border: 0,
boxShadow: theme.shadows[3],
},
deactive: {
transition: "background-color 1.2s", // mouse out
"&:hover": {
backgroundColor: theme.palette.primary.light,
transition: "background-color 0.4s", // mouse over
},
},
active: {
backgroundColor: theme.palette.primary.light,
},
})
)
type Props = {}
/**
* Side navigation component
* @param props Props
*/
export const Sidenavi = function (props: Props) {
const classes = useStyles(props)
const { selectedPage, changePage } = usePage()
const handleChangePage = (id: number) => () => changePage(id)
return (
<div className={classes.root}>
<div className={`${classes.siteNameContainer} ${classes.toolbar}`}>
{SiteInfo.SITE_NAME}
</div>
<List className={classes.list}>
{Page.values.map((page) => {
const Icon = page.icon
return (
<NextListItem
key={page.id}
className={
page.id === selectedPage.id
? `${classes.listItem} ${classes.active}`
: `${classes.listItem} ${classes.deactive}`
}
href={page.relativeUrl}
primary={page.pageTitle}
secondary={page.pageDescription}
icon={
<SvgIcon style={{ color: page.iconColor[600] }}>
<Icon />
</SvgIcon>
}
onClick={handleChangePage(page.id)}
/>
)
})}
</List>
</div>
)
}