91 lines
3.9 KiB
TypeScript
91 lines
3.9 KiB
TypeScript
import React from 'react';
|
|
import { Disclosure } from '@headlessui/react';
|
|
import { MenuIcon, XIcon } from '@heroicons/react/outline';
|
|
import clsx from 'clsx';
|
|
import { Link, useLocation } from 'react-router-dom';
|
|
|
|
const navigation = [
|
|
{ name: 'Dashboard', to: '/dashboard', requiresAdmin: false },
|
|
{ name: 'Dateiablage', to: '/files', requiresAdmin: false },
|
|
{ name: 'Projekte', to: '/projects', requiresAdmin: false },
|
|
];
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
interface HeaderProps {}
|
|
|
|
const Header: React.FC<HeaderProps> = () => {
|
|
const { pathname } = useLocation();
|
|
|
|
return (
|
|
<>
|
|
<Disclosure as="nav" className="bg-white shadow relative z-10">
|
|
{({ open }) => (
|
|
<div className="relative">
|
|
<div className="max-w-7xl mx-auto px-2 sm:px-6 lg:px-8">
|
|
<div className="relative flex justify-between h-16">
|
|
<div className="absolute inset-y-0 left-0 flex items-center sm:hidden">
|
|
{/* Mobile menu button */}
|
|
<Disclosure.Button className="inline-flex items-center justify-center p-2 rounded-md text-gray-400 hover:text-gray-500 hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-inset focus:ring-primary-500">
|
|
<span className="sr-only">Open main menu</span>
|
|
{open ? (
|
|
<XIcon className="block h-6 w-6" aria-hidden="true" />
|
|
) : (
|
|
<MenuIcon className="block h-6 w-6" aria-hidden="true" />
|
|
)}
|
|
</Disclosure.Button>
|
|
</div>
|
|
<div className="flex-1 flex items-center justify-center sm:items-stretch sm:justify-start">
|
|
<Link to="/" className="flex-shrink-0 flex items-center">
|
|
<img className="block lg:hidden" src="/assets/logo-small.svg" alt="Stackspin" />
|
|
<img className="hidden lg:block" src="/assets/logo.svg" alt="Stackspin" />
|
|
</Link>
|
|
<div className="hidden sm:ml-6 sm:flex sm:space-x-8">
|
|
{/* Current: "border-primary-500 text-gray-900", Default: "border-transparent text-gray-500 hover:border-gray-300 hover:text-gray-700" */}
|
|
{navigation.map((item) => (
|
|
<Link
|
|
key={item.name}
|
|
to={item.to}
|
|
className={clsx(
|
|
'border-primary-50 text-gray-900 inline-flex items-center px-1 pt-1 border-b-2 text-sm font-medium',
|
|
{
|
|
'border-primary-500 text-gray-500 hover:border-gray-300 hover:text-gray-700 inline-flex items-center px-1 pt-1 text-sm font-medium':
|
|
pathname.includes(item.to),
|
|
},
|
|
)}
|
|
>
|
|
{item.name}
|
|
</Link>
|
|
))}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<Disclosure.Panel className="sm:hidden">
|
|
<div className="pt-2 pb-4 space-y-1">
|
|
{navigation.map((item) => (
|
|
<Link
|
|
key={item.name}
|
|
to={item.to}
|
|
className={clsx(
|
|
'border-transparent text-gray-500 hover:text-gray-700 block pl-3 pr-4 py-2 border-l-4 text-base font-medium',
|
|
{
|
|
'bg-primary-50 border-primary-400 text-primary-700 block pl-3 pr-4 py-2': pathname.includes(
|
|
item.to,
|
|
),
|
|
},
|
|
)}
|
|
>
|
|
{item.name}
|
|
</Link>
|
|
))}
|
|
</div>
|
|
</Disclosure.Panel>
|
|
</div>
|
|
)}
|
|
</Disclosure>
|
|
</>
|
|
);
|
|
};
|
|
|
|
export default Header;
|