Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix visual issue with Menu items in the MainNav #1121

Merged
merged 3 commits into from
Nov 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/components/layout/nav/DevelopmentMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useTranslation } from 'next-i18next'

import { staticUrls } from 'common/routes'

import GenericMenu from './GenericMenu'
import GenericNavMenu from './GenericNavMenu'
import ExternalLinkMenuItem from 'components/common/ExternalLinkMenuItem'

const PREFIX = 'DevelopmentMenu'
Expand All @@ -16,7 +16,7 @@ const classes = {
dropdownLinkText: `${PREFIX}-dropdownLinkText`,
}

const StyledGenericMenu = styled(GenericMenu)(({ theme }) => ({
const StyledGenericNavMenu = styled(GenericNavMenu)(({ theme }) => ({
[`& .${classes.dropdownLinkButton}`]: {
'&:hover': {
backgroundColor: lighten(theme.palette.primary.main, 0.9),
Expand Down Expand Up @@ -69,7 +69,7 @@ export default function DevelopmentMenu() {
const router = useRouter()

return (
<StyledGenericMenu label={t('nav.dev.index')}>
<StyledGenericNavMenu id="menu-development" label={t('nav.dev.index')}>
{navItems.map(({ href, label, target }, key) => (
<ExternalLinkMenuItem
selected={router.asPath === href}
Expand All @@ -82,6 +82,6 @@ export default function DevelopmentMenu() {
</Typography>
</ExternalLinkMenuItem>
))}
</StyledGenericMenu>
</StyledGenericNavMenu>
)
}
8 changes: 4 additions & 4 deletions src/components/layout/nav/DonationMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { useTranslation } from 'next-i18next'
import { routes } from 'common/routes'
import LinkMenuItem from 'components/common/LinkMenuItem'

import GenericMenu from './GenericMenu'
import GenericNavMenu from './GenericNavMenu'

const PREFIX = 'DonationMenu'

Expand All @@ -16,7 +16,7 @@ const classes = {
dropdownLinkText: `${PREFIX}-dropdownLinkText`,
}

const StyledGenericMenu = styled(GenericMenu)(({ theme }) => ({
const StyledGenericNavMenu = styled(GenericNavMenu)(({ theme }) => ({
[`& .${classes.dropdownLinkButton}`]: {
'&:hover': {
backgroundColor: lighten(theme.palette.primary.main, 0.9),
Expand Down Expand Up @@ -51,7 +51,7 @@ export default function DonationMenu() {
const { t } = useTranslation()
const router = useRouter()
return (
<StyledGenericMenu label={t('nav.donation-menu')}>
<StyledGenericNavMenu id="menu-donation" label={t('nav.donation-menu')}>
{navItems.map(({ href, label }, key) => (
<LinkMenuItem
href={href}
Expand All @@ -63,6 +63,6 @@ export default function DonationMenu() {
</Typography>
</LinkMenuItem>
))}
</StyledGenericMenu>
</StyledGenericNavMenu>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import ArrowDropDownIcon from '@mui/icons-material/ArrowDropDown'
import ArrowDropUpIcon from '@mui/icons-material/ArrowDropUp'

type Props = {
id: string
label: string
children: React.ReactNode
}

export default function GenericMenu({ label, children }: Props) {
export default function GenericNavMenu({ id, label, children }: Props) {
const [anchorEl, setAnchorEl] = useState<Element | null>(null)
const open = Boolean(anchorEl)

Expand All @@ -28,15 +29,16 @@ export default function GenericMenu({ label, children }: Props) {
{label}
</Button>
<Menu
disableScrollLock={true}
keepMounted
id="menu-donation"
disableScrollLock
id={`main-nav-menu--${id}`}
anchorEl={anchorEl}
elevation={6}
onClose={handleClose}
open={Boolean(anchorEl)}
elevation={6}
anchorOrigin={{ vertical: 'bottom', horizontal: 'right' }}
transformOrigin={{ vertical: 'top', horizontal: 'right' }}>
transformOrigin={{ vertical: 'top', horizontal: 'right' }}
PaperProps={{ sx: { mt: 1 } }}>
{children}
</Menu>
</>
Expand Down
8 changes: 4 additions & 4 deletions src/components/layout/nav/ProjectMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useTranslation } from 'next-i18next'

import { routes, staticUrls } from 'common/routes'

import GenericMenu from './GenericMenu'
import GenericNavMenu from './GenericNavMenu'
import ExternalLinkMenuItem from 'components/common/ExternalLinkMenuItem'
import LinkMenuItem from 'components/common/LinkMenuItem'

Expand All @@ -17,7 +17,7 @@ const classes = {
dropdownLinkText: `${PREFIX}-dropdownLinkText`,
}

const StyledGenericMenu = styled(GenericMenu)(({ theme }) => ({
const StyledGenericNavMenu = styled(GenericNavMenu)(({ theme }) => ({
[`& .${classes.dropdownLinkButton}`]: {
'&:hover': {
backgroundColor: lighten(theme.palette.primary.main, 0.9),
Expand Down Expand Up @@ -87,7 +87,7 @@ export default function ProjectMenu() {
const router = useRouter()

return (
<StyledGenericMenu label={t('nav.about.about-us')}>
<StyledGenericNavMenu id="menu-project" label={t('nav.about.about-us')}>
{navItems.map(({ href, label, target }, key) =>
target ? (
<ExternalLinkMenuItem
Expand All @@ -112,6 +112,6 @@ export default function ProjectMenu() {
</LinkMenuItem>
),
)}
</StyledGenericMenu>
</StyledGenericNavMenu>
)
}