Files
no-copy-frontend/src/app/ui/navigation/nav-link-dropdown.tsx
T

78 lines
1.9 KiB
TypeScript
Raw Normal View History

2025-12-09 16:35:47 +07:00
import { useState, useRef } from 'react';
2025-11-25 19:20:50 +07:00
import Link from 'next/link';
import clsx from 'clsx';
import { usePathname } from 'next/navigation';
2025-12-12 11:00:23 +07:00
import { useTranslations } from 'next-intl';
2026-01-23 15:43:05 +07:00
import { useSideMenuStore } from '@/app/stores/sideMenuStore';
2025-11-25 19:20:50 +07:00
2026-03-11 10:53:09 +07:00
export default function DropDownList() {
2025-12-17 09:18:18 +07:00
const pathname = usePathname().replace('/en/', '/').replace('/ru/', '/');
2025-11-25 19:20:50 +07:00
const [dropDownExpanded, setDropDownExpanded] = useState(false);
2025-12-12 11:00:23 +07:00
const t = useTranslations('Global');
2026-01-23 15:43:05 +07:00
const setMenuState = useSideMenuStore(s => s.setValue);
2025-11-25 19:20:50 +07:00
function dropDownHandler() {
setDropDownExpanded(!dropDownExpanded);
}
const links = [
{
2026-03-24 18:27:16 +07:00
name: 'images',
2026-01-26 13:26:21 +07:00
href: '/pages/marking-images'
2025-11-25 19:20:50 +07:00
},
{
2026-03-24 18:27:16 +07:00
name: 'videos',
2025-12-09 16:35:47 +07:00
href: '/pages/marking-video'
2025-11-25 19:20:50 +07:00
},
{
2026-03-24 18:27:16 +07:00
name: 'audios',
2025-12-09 16:35:47 +07:00
href: '/pages/marking-audio'
2026-02-07 12:28:07 +07:00
},
{
2026-03-24 18:27:16 +07:00
name: 'documents-few',
2026-02-07 12:28:07 +07:00
href: '/pages/marking-document'
2025-12-09 16:35:47 +07:00
}
2025-11-25 19:20:50 +07:00
];
return (
2025-12-09 16:35:47 +07:00
<>
<div
2025-12-27 11:54:54 +07:00
className={`nav-dropdown ${dropDownExpanded ? 'expanded' : ''}`}
2025-12-09 16:35:47 +07:00
onClick={dropDownHandler}
>
2025-12-27 11:54:54 +07:00
<div className="flex nav-link cursor-pointer select-none">
2025-12-09 16:35:47 +07:00
<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>
2025-12-12 11:00:23 +07:00
<p>
{t('marking')}
</p>
2025-12-27 11:54:54 +07:00
<svg className="dropdown-arrow" viewBox="0 0 24 24" fill="currentColor">
2025-12-09 16:35:47 +07:00
<path d="M7 10l5 5 5-5z"></path>
</svg>
</div>
2025-11-25 19:20:50 +07:00
</div>
2025-12-27 11:54:54 +07:00
<ul className={`sub-menu ${dropDownExpanded ? 'expanded' : ''}`}>
2025-11-25 19:20:50 +07:00
{links.map((link) => {
return (
<Link
key={link.name}
href={link.href}
className={clsx(
2025-12-27 11:54:54 +07:00
`flex nav-link sub-link`,
2025-11-25 19:20:50 +07:00
{
'bg-[#5659f1]': pathname === link.href,
},
)}
2026-01-23 15:43:05 +07:00
onClick={() => {
setMenuState(false)
}}
2025-11-25 19:20:50 +07:00
>
2026-02-09 13:11:25 +07:00
<p className="">{t(link.name)}</p>
2025-11-25 19:20:50 +07:00
</Link>
);
})}
</ul>
2025-12-09 16:35:47 +07:00
</>
2025-11-25 19:20:50 +07:00
)
}