♿️(frontend) update left nav panel
- the HTML semantic needed improvement: the menu items were button wrapped in a li wrapped in link. - update related tests
This commit is contained in:
committed by
Sebastien Nobour
parent
2967f1bff2
commit
976c955126
@@ -19,6 +19,10 @@ and this project adheres to
|
|||||||
- ✨(frontend) allow group members filtering #363
|
- ✨(frontend) allow group members filtering #363
|
||||||
- ✨(mailbox) send new mailbox confirmation email #397
|
- ✨(mailbox) send new mailbox confirmation email #397
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- ♿️(frontend) fix left nav panel #396
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- ♻️(serializers) move business logic to serializers #414
|
- ♻️(serializers) move business logic to serializers #414
|
||||||
|
|||||||
@@ -9,6 +9,9 @@ import { useConfigStore } from '../config';
|
|||||||
jest.mock('next/navigation', () => ({
|
jest.mock('next/navigation', () => ({
|
||||||
...jest.requireActual('next/navigation'),
|
...jest.requireActual('next/navigation'),
|
||||||
usePathname: () => '/',
|
usePathname: () => '/',
|
||||||
|
useRouter: () => ({
|
||||||
|
push: () => {},
|
||||||
|
}),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
describe('MainLayout', () => {
|
describe('MainLayout', () => {
|
||||||
@@ -20,19 +23,23 @@ describe('MainLayout', () => {
|
|||||||
render(<MainLayout />, { wrapper: AppWrapper });
|
render(<MainLayout />, { wrapper: AppWrapper });
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
screen.getByRole('link', {
|
screen.getByRole('button', {
|
||||||
name: /Teams button/i,
|
name: /Teams button/i,
|
||||||
}),
|
}),
|
||||||
).toBeInTheDocument();
|
).toBeInTheDocument();
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
screen.getByRole('link', {
|
screen.getByRole('button', {
|
||||||
name: /Mail Domains button/i,
|
name: /Mail Domains button/i,
|
||||||
}),
|
}),
|
||||||
).toBeInTheDocument();
|
).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('checks menu rendering without team feature', () => {
|
it('checks menu rendering without team feature', () => {
|
||||||
|
useConfigStore.setState({
|
||||||
|
config: { FEATURES: { TEAMS: false }, LANGUAGES: [] },
|
||||||
|
});
|
||||||
|
|
||||||
render(<MainLayout />, { wrapper: AppWrapper });
|
render(<MainLayout />, { wrapper: AppWrapper });
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { usePathname } from 'next/navigation';
|
import { usePathname, useRouter } from 'next/navigation';
|
||||||
import React, { useRef, useState } from 'react';
|
import React, { useRef, useState } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
import { Box, BoxButton, StyledLink } from '@/components';
|
import { Box, BoxButton } from '@/components';
|
||||||
import { useCunninghamTheme } from '@/cunningham';
|
import { useCunninghamTheme } from '@/cunningham';
|
||||||
import { SVGComponent } from '@/types/components';
|
import { SVGComponent } from '@/types/components';
|
||||||
|
|
||||||
@@ -17,6 +17,7 @@ interface MenuItemProps {
|
|||||||
|
|
||||||
const MenuItem = ({ Icon, label, href, alias }: MenuItemProps) => {
|
const MenuItem = ({ Icon, label, href, alias }: MenuItemProps) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
const router = useRouter();
|
||||||
const pathname = usePathname();
|
const pathname = usePathname();
|
||||||
const { colorsTokens } = useCunninghamTheme();
|
const { colorsTokens } = useCunninghamTheme();
|
||||||
const parentRef = useRef(null);
|
const parentRef = useRef(null);
|
||||||
@@ -43,34 +44,28 @@ const MenuItem = ({ Icon, label, href, alias }: MenuItemProps) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<StyledLink
|
<Box ref={parentRef}>
|
||||||
href={href}
|
|
||||||
aria-current={isActive && 'page'}
|
|
||||||
ref={parentRef}
|
|
||||||
onMouseOver={() => setIsTooltipOpen(true)}
|
|
||||||
onMouseLeave={() => setIsTooltipOpen(false)}
|
|
||||||
style={{ display: 'block' }}
|
|
||||||
$css={`
|
|
||||||
&:focus-visible {
|
|
||||||
outline: #fff solid 2px;
|
|
||||||
}`}
|
|
||||||
>
|
|
||||||
<Box
|
<Box
|
||||||
$margin="xtiny"
|
$margin="xtiny"
|
||||||
$padding="tiny"
|
$padding="tiny"
|
||||||
as="li"
|
as="li"
|
||||||
$justify="center"
|
$justify="center"
|
||||||
$css={`
|
$css="transition: all 0.2s ease-in-out;"
|
||||||
& > button { padding: 0};
|
|
||||||
transition: all 0.2s ease-in-out
|
|
||||||
`}
|
|
||||||
$background={background}
|
$background={background}
|
||||||
$radius="10px"
|
$radius="10px"
|
||||||
>
|
>
|
||||||
<BoxButton
|
<BoxButton
|
||||||
|
aria-current={isActive && 'page'}
|
||||||
|
onMouseOver={() => setIsTooltipOpen(true)}
|
||||||
|
onMouseLeave={() => setIsTooltipOpen(false)}
|
||||||
|
$css={`
|
||||||
|
padding: 0;
|
||||||
|
${isActive ? null : '&:focus-visible {outline: #fff solid 2px;}'}
|
||||||
|
`}
|
||||||
aria-label={t(`{{label}} button`, { label })}
|
aria-label={t(`{{label}} button`, { label })}
|
||||||
$color={color}
|
$color={color}
|
||||||
as="span"
|
as="button"
|
||||||
|
onClick={() => router.push(href)}
|
||||||
>
|
>
|
||||||
<Icon
|
<Icon
|
||||||
width="2.375rem"
|
width="2.375rem"
|
||||||
@@ -81,15 +76,17 @@ const MenuItem = ({ Icon, label, href, alias }: MenuItemProps) => {
|
|||||||
/>
|
/>
|
||||||
</BoxButton>
|
</BoxButton>
|
||||||
</Box>
|
</Box>
|
||||||
{isTooltipOpen && (
|
<Box as="span">
|
||||||
<Tooltip
|
{isTooltipOpen && (
|
||||||
parentRef={parentRef}
|
<Tooltip
|
||||||
label={label}
|
parentRef={parentRef}
|
||||||
backgroundColor={backgroundTooltip}
|
label={label}
|
||||||
textColor={colorTooltip}
|
backgroundColor={backgroundTooltip}
|
||||||
/>
|
textColor={colorTooltip}
|
||||||
)}
|
/>
|
||||||
</StyledLink>
|
)}
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user