diff --git a/examples/catalog/components/home/Nav.tsx b/examples/catalog/components/home/Nav.tsx index ddaf3ca6..534eab7b 100644 --- a/examples/catalog/components/home/Nav.tsx +++ b/examples/catalog/components/home/Nav.tsx @@ -1,4 +1,4 @@ -import { Nav } from 'portal'; +import Template from './NavTemplate'; const NavBar: React.FC = () => { const navMenu = [ @@ -8,7 +8,7 @@ const NavBar: React.FC = () => { { title: 'GitHub', path: 'https://github.com/datopian/portal.js' }, ]; - return ; + return ; }; export default NavBar; diff --git a/examples/catalog/components/home/NavTemplate.tsx b/examples/catalog/components/home/NavTemplate.tsx new file mode 100644 index 00000000..217ee377 --- /dev/null +++ b/examples/catalog/components/home/NavTemplate.tsx @@ -0,0 +1,118 @@ +import { useState } from 'react'; +import { useRouter } from 'next/router'; +import { Disclosure } from '@headlessui/react'; +import { SearchIcon } from '@heroicons/react/solid'; +import { MenuIcon, XIcon } from '@heroicons/react/outline'; + +const NavBar: React.FC<{ menu: any; logo: string }> = ({ menu, logo }) => { + const router = useRouter(); + const [searchQuery, setSearchQuery] = useState(''); + + const handleSubmit = (e) => { + e.preventDefault(); + router.push({ + pathname: '/search', + query: { q: searchQuery }, + }); + }; + + return ( + + {({ open }) => ( + <> + + + + + + + + + + + {/* Current: "border-indigo-500 text-gray-900", Default: "border-transparent text-gray-500 hover:border-gray-300 hover:text-gray-700" */} + {menu.map((item, index) => ( + + {item.title} + + ))} + + + + + + Search + + + + + + handleSubmit(e)} + className="items-center" + > + { + setSearchQuery(e.target.value); + }} + placeholder="Search" + aria-label="Search" + className="block w-full pl-10 pr-3 py-2 border border-gray-300 rounded-md leading-5 bg-white placeholder-gray-500 focus:outline-none focus:placeholder-gray-400 focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm" + /> + + + + + + {/* Mobile menu button */} + + Open main menu + {open ? ( + + ) : ( + + )} + + + + + + + + {/* Current: "bg-indigo-50 border-indigo-500 text-indigo-700", Default: "border-transparent text-gray-600 hover:bg-gray-50 hover:border-gray-300 hover:text-gray-800" */} + {menu.map((item, index) => ( + + {item.title} + + ))} + + + > + )} + + ); +}; + +export default NavBar;