From 4095247ca6f18d781a3e78807142243426e64923 Mon Sep 17 00:00:00 2001 From: Luccas Mateus de Medeiros Gomes Date: Tue, 30 May 2023 13:16:28 -0300 Subject: [PATCH] [examples/openspending][m] - fix requested by demenech --- examples/openspending/components/Header.tsx | 145 +++++++++++++++--- .../components/_shared/Footer.tsx | 16 +- .../content/about/presentations.md | 13 +- .../content/resources/journo/index.md | 4 +- examples/openspending/pages/blog.tsx | 23 ++- 5 files changed, 162 insertions(+), 39 deletions(-) diff --git a/examples/openspending/components/Header.tsx b/examples/openspending/components/Header.tsx index 55a1b03a..c1a47d5c 100644 --- a/examples/openspending/components/Header.tsx +++ b/examples/openspending/components/Header.tsx @@ -5,6 +5,9 @@ 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); @@ -21,41 +24,72 @@ export function Header() { href: '/#datasets', }, { - title: "Blog", - href: "/blog" + title: 'Blog', + href: '/blog', }, { - title: "About", - href: "/about" + 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" - } + title: 'Resources', + href: '/resources', + children: [ + { + title: 'IATI', + href: '/resources/iati', + }, + { + title: 'Follow the money', + href: '/resources/journo', + }, + { + title: 'OpenSpending.Mobi', + href: '/resources/mobi/', + }, + { + 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) => (
  • - - {link.title} - +
  • ))}
-
); } + +function classNames(...classes) { + return classes.filter(Boolean).join(' '); +} + +function Dropdown({ navItem }: { navItem: any }) { + const [showDropDown, setShowDropDown] = useState(false); + console.log(showDropDown); + 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} + + )} + + ))} +
+
+
+
+ )} + + )} +
+ ); +} diff --git a/examples/openspending/components/_shared/Footer.tsx b/examples/openspending/components/_shared/Footer.tsx index cc2d411b..ab06e7d6 100644 --- a/examples/openspending/components/_shared/Footer.tsx +++ b/examples/openspending/components/_shared/Footer.tsx @@ -1,9 +1,21 @@ -import Image from 'next/image' +import Image from 'next/image'; +import Link from 'next/link'; export default function Footer() { return (