Files
no-copy-frontend/src/app/ui/navigation/nav-link-dropdown.tsx
T
2026-03-27 15:27:22 +07:00

78 lines
1.9 KiB
TypeScript

import { useState, useRef } from 'react';
import Link from 'next/link';
import clsx from 'clsx';
import { usePathname } from 'next/navigation';
import { useTranslations } from 'next-intl';
import { useSideMenuStore } from '@/app/stores/sideMenuStore';
export default function DropDownList() {
const pathname = usePathname().replace('/en/', '/').replace('/ru/', '/');
const [dropDownExpanded, setDropDownExpanded] = useState(false);
const t = useTranslations('Global');
const setMenuState = useSideMenuStore(s => s.setValue);
function dropDownHandler() {
setDropDownExpanded(!dropDownExpanded);
}
const links = [
{
name: 'images-few',
href: '/pages/marking-images'
},
{
name: 'videos',
href: '/pages/marking-video'
},
{
name: 'audios',
href: '/pages/marking-audio'
},
{
name: 'documents',
href: '/pages/marking-document'
}
];
return (
<>
<div
className={`nav-dropdown ${dropDownExpanded ? 'expanded' : ''}`}
onClick={dropDownHandler}
>
<div className="flex 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="dropdown-arrow" viewBox="0 0 24 24" fill="currentColor">
<path d="M7 10l5 5 5-5z"></path>
</svg>
</div>
</div>
<ul className={`sub-menu ${dropDownExpanded ? 'expanded' : ''}`}>
{links.map((link) => {
return (
<Link
key={link.name}
href={link.href}
className={clsx(
`flex nav-link sub-link`,
{
'bg-[#5659f1]': pathname === link.href,
},
)}
onClick={() => {
setMenuState(false)
}}
>
<p className="">{t(link.name)}</p>
</Link>
);
})}
</ul>
</>
)
}