Files
no-copy-frontend/src/app/ui/nav-link-dropdown.tsx
T
2025-12-12 11:00:23 +07:00

76 lines
1.8 KiB
TypeScript

import styles from '@/app/styles/ui.module.scss';
import { useState, useRef } from 'react';
import Link from 'next/link';
import clsx from 'clsx';
import { usePathname } from 'next/navigation';
import { useTranslations } from 'next-intl';
export default function DropDownList() {
const pathname = usePathname();
const [dropDownExpanded, setDropDownExpanded] = useState(false);
const t = useTranslations('Global');
function dropDownHandler() {
setDropDownExpanded(!dropDownExpanded);
}
const links = [
{
name: t('photo-marking'),
href: '/pages/marking-photo'
},
{
name: t('video-marking'),
href: '/pages/marking-video'
},
{
name: t('audio-marking'),
href: '/pages/marking-audio'
}
];
return (
<>
<div
className={`
${styles['nav-dropdown']}
${dropDownExpanded ? styles['expanded'] : ''}
`}
onClick={dropDownHandler}
>
<div className={`flex ${styles['nav-link']} cursor-pointer select-none`}>
<svg viewBox="0 0 24 24" fill="currentColor">
<path d="M17.63 5.84C17.27 5.33 16.67 5 16 5L5 5.01C3.9 5.01 3 5.9 3 7v10c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2l-5.37.84z"></path>
</svg>
<p>
{t('marking')}
</p>
<svg className={`${styles['dropdown-arrow']}`} viewBox="0 0 24 24" fill="currentColor">
<path d="M7 10l5 5 5-5z"></path>
</svg>
</div>
</div>
<ul className={`
${styles['sub-menu']}
${dropDownExpanded ? styles['expanded'] : ''}
`}>
{links.map((link) => {
return (
<Link
key={link.name}
href={link.href}
className={clsx(
`flex ${styles['nav-link']} ${styles['sub-link']}`,
{
'bg-[#5659f1]': pathname === link.href,
},
)}
>
<p className="hidden md:block">{link.name}</p>
</Link>
);
})}
</ul>
</>
)
}