Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 | 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 4x 4x 4x 4x 20x 20x 20x 20x 4x | import React from 'react';
import { menu } from '@/constants/navMenu';
import Icon from '@/components/Dock/Icon';
import { useRouter } from 'next/router';
import { useDialog } from '@/context/dialog';
import Link from 'next/link';
import styles from './dock.module.css';
import { clx } from '@/helpers';
import { useIntl } from 'react-intl';
/**
* @description This component is the dock that appears on the bottom of the screen
* @returns JSX.Element
*/
const Dock = () => {
const { pathname, locale } = useRouter();
const { formatMessage: f } = useIntl();
const { dispatch } = useDialog();
const clickHandler = () => dispatch({ type: 'open' });
return (
<>
<nav className={styles.dock} data-testid="dock" aria-label={f({ id: 'nav.applications' })}>
<ul>
{menu.map(({ link, img, alt, testId }, index) => {
const path = pathname.split('/')[1];
const term =
typeof link === 'object'
? link[locale as keyof typeof link]?.split('/')[1]
: link.split('/')[1];
const check = term ? path.includes(term) : false;
return (
/**
* SDD-L05: `onClick` moved off the <li> and onto the <Link>. It was not a
* keyboard failure — Enter on the inner <a> dispatches a click that bubbles —
* but a list item is not an interaction target, and the handler fired for
* clicks in the row's padding where no link exists, so the hit area did not
* match what the user could see.
*/
<li
key={index}
className={clx(pathname === link || check ? styles.selected : '')}
data-testid={testId}
>
<Link
href={link?.[locale as keyof typeof link] ?? link}
title={alt}
onClick={clickHandler}
>
<Icon src={img} alt={alt} />
</Link>
</li>
);
})}
</ul>
</nav>
</>
);
};
export default Dock;
|