-
Notifications
You must be signed in to change notification settings - Fork 92
/
ProjectMenu.tsx
104 lines (93 loc) · 2.32 KB
/
ProjectMenu.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
92
93
94
95
96
97
98
99
100
101
102
103
104
import React from 'react'
import { styled } from '@mui/material/styles'
import { useRouter } from 'next/router'
import { Typography, lighten } from '@mui/material'
import { useTranslation } from 'next-i18next'
import { routes, staticUrls } from 'common/routes'
import LinkMenuItem from 'components/common/LinkMenuItem'
import GenericMenu from './GenericMenu'
const PREFIX = 'ProjectMenu'
const classes = {
dropdownLinkButton: `${PREFIX}-dropdownLinkButton`,
dropdownLinkText: `${PREFIX}-dropdownLinkText`,
}
const StyledGenericMenu = styled(GenericMenu)(({ theme }) => ({
[`& .${classes.dropdownLinkButton}`]: {
'&:hover': {
backgroundColor: lighten(theme.palette.primary.main, 0.9),
},
},
[`& .${classes.dropdownLinkText}`]: {
color: theme.palette.primary.dark,
width: '100%',
'&:hover': {
color: theme.palette.primary.main,
},
},
}))
type NavItem = {
href: string
label: string
enabled?: boolean
target?: string
}
const allNavItems: NavItem[] = [
{
href: routes.about,
label: 'nav.about.who-are-we',
},
{
href: routes.aboutProject,
label: 'nav.about.about-project',
},
{
href: staticUrls.blog,
label: 'nav.blog',
target: '_blank',
},
{
href: routes.support_us,
label: 'nav.about.support_us',
},
{
href: routes.support,
label: 'nav.about.support-us',
},
{
href: routes.reports,
label: 'nav.about.reports',
},
{
href: routes.contact,
label: 'nav.about.contacts',
},
{
href: routes.termsOfService,
label: 'components.footer.terms-of-service',
},
{
href: routes.faq,
label: 'nav.campaigns.faq',
},
]
export const navItems = allNavItems.filter((el) => typeof el.enabled === 'undefined' ?? el.enabled)
export default function ProjectMenu() {
const { t } = useTranslation()
const router = useRouter()
return (
<StyledGenericMenu label={t('nav.about.about-us')}>
{navItems.map(({ href, label, target }, key) => (
<LinkMenuItem
href={href}
selected={router.asPath === href}
key={key}
target={target}
className={classes.dropdownLinkButton}>
<Typography variant="button" className={classes.dropdownLinkText}>
{t(label)}
</Typography>
</LinkMenuItem>
))}
</StyledGenericMenu>
)
}