import React, { Fragment } from 'react'; import { Disclosure, Menu, Transition } from '@headlessui/react'; import { MenuIcon, XIcon } from '@heroicons/react/outline'; import { Link, RouteComponentProps } from '@reach/router'; import { useAuth } from 'src/services/auth'; const navigation = [ { name: 'Dashboard', to: '/dashboard' }, { name: 'Apps', to: '/apps' }, { name: 'Users', to: '/users' }, ]; function classNames(...classes: any[]) { return classes.filter(Boolean).join(' '); } type HeaderProps = RouteComponentProps; const Header: React.FC = () => { const { logOut } = useAuth(); return ( {({ open }) => ( <>
{/* Mobile menu button */} Open main menu {open ? (
Stackspin Stackspin
{/* Current: "border-primary-500 text-gray-900", Default: "border-transparent text-gray-500 hover:border-gray-300 hover:text-gray-700" */} {navigation.map((item) => ( { // the object returned here is passed to the // anchor element's props return { className: isCurrent ? 'border-primary-400 text-gray-900 inline-flex items-center px-1 pt-1 border-b-2 text-sm font-medium' : 'border-transparent text-gray-500 hover:border-gray-300 hover:text-gray-700 inline-flex items-center px-1 pt-1 border-b-2 text-sm font-medium', 'aria-current': isCurrent ? 'page' : undefined, }; }} > {item.name} ))}
{/* Profile dropdown */}
Open user menu
{({ active }) => ( logOut()} className={classNames(active ? 'bg-gray-100' : '', 'block px-4 py-2 text-sm text-gray-700')} > Sign out )}
{navigation.map((item) => ( { // the object returned here is passed to the // anchor element's props return { className: isCurrent ? 'bg-primary-50 border-primary-400 text-primary-700 block pl-3 pr-4 py-2 border-l-4 text-base font-medium' : 'border-transparent text-gray-500 hover:bg-gray-50 hover:border-gray-300 hover:text-gray-700 block pl-3 pr-4 py-2 border-l-4 text-base font-medium', 'aria-current': isCurrent ? 'page' : undefined, }; }} > {item.name} ))}
)}
); }; export default Header;