69 lines
1.7 KiB
TypeScript
69 lines
1.7 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';
|
|
|
|
export default function DropDownList() {
|
|
const pathname = usePathname().replace('/en/', '/').replace('/ru/', '/');
|
|
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={`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,
|
|
},
|
|
)}
|
|
>
|
|
<p className="">{link.name}</p>
|
|
</Link>
|
|
);
|
|
})}
|
|
</ul>
|
|
</>
|
|
)
|
|
} |