import Image from 'next/image'; import { Container } from './Container'; import logo from '../public/logo.svg'; import Link from 'next/link'; import { useRouter } from 'next/router'; import { Bars3Icon } from '@heroicons/react/24/outline'; import { useState } from 'react'; import { Fragment } from 'react'; import { Menu, Transition } from '@headlessui/react'; import { ChevronDownIcon } from '@heroicons/react/20/solid'; export function Header() { const [menuOpen, setMenuOpen] = useState(false); const router = useRouter(); const isActive = (navLink) => { return router.asPath.split('?')[0] == navLink.href; }; const navLinks = [ { title: 'Datasets', href: '/#datasets', }, { title: 'Data Stories', href: '/stories', }, { title: 'Blog', href: '/blog', }, { title: 'About', href: '/about', children: [ { title: 'Fiscal Data Package', href: '/about/fiscaldatapackage/', }, { title: 'Tools', href: '/about/tools/', }, { title: 'Funders', href: '/about/funders/', }, { title: 'Presentations', href: '/about/presentations/', }, ], }, { title: 'Resources', href: '/resources', children: [ { title: 'Follow the money', href: '/resources/journo', }, { title: 'Map of Spending Projects', href: '/resources/map-of-spending-projects/', }, { title: 'Working Group On Open Spending Data', href: '/resources/wg/', }, ], }, ]; return (
OpenSpending
    {navLinks.map((link, i) => (
  • ))}
{menuOpen && (
    {navLinks.map((link, i) => (
  • {link.title}
  • ))}
)}
); } function classNames(...classes) { return classes.filter(Boolean).join(' '); } function Dropdown({ navItem }: { navItem: any }) { const [showDropDown, setShowDropDown] = useState(false); return ( {({ open }) => ( <>
setShowDropDown(true)} onMouseLeave={() => setShowDropDown(false)} className="text-emerald-900 hover:text-emerald-600 inline-flex w-full justify-center gap-x-1.5 px-3 py-2 text-sm font-semibold" > {navItem.title} {navItem.children && (
{navItem.children && (
setShowDropDown(true)} onMouseLeave={() => setShowDropDown(false)} className="absolute right-0 z-10 w-56 origin-top-right rounded-md bg-white shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none" >
{navItem.children.map((item) => ( {({ active }) => ( {item.title} )} ))}
)} )}
); }