Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: responsive navigation bar #9

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
feat(navbar.tsx): remove collapse id
volt1c committed Oct 17, 2023
commit be25bc617a8dc7c3fac41348ced2ca5c6d9a25cb
29 changes: 23 additions & 6 deletions src/components/navbar.tsx
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ import NavLink, { NavLinkProps } from "./nav-link";
import { useState } from "react";

export default function Navbar() {
const [show, setShow] = useState(false)
const [show, setShow] = useState(false);

const links: NavLinkProps[] = [
{
@@ -21,7 +21,6 @@ export default function Navbar() {
];

return (

<nav className="bg-white border-gray-200 w-full">
<div className="max-w-screen-xl flex flex-wrap items-center justify-between mx-auto p-4">
<a href="https://flowbite.com/" className="flex items-center">
@@ -34,13 +33,31 @@ export default function Navbar() {
/>
<span className="self-center hidden">Openapps</span>
</a>
<button onClick={() => setShow(!show)} data-collapse-toggle="navbar-default" type="button" className="inline-flex items-center p-2 w-10 h-10 justify-center text-sm rounded-lg md:hidden hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-gray-200 dark:text-gray-400 dark:hover:bg-gray-700 dark:focus:ring-gray-600" aria-controls="navbar-default" aria-expanded="false">
<button
onClick={() => setShow(!show)}
type="button"
className="inline-flex items-center p-2 w-10 h-10 justify-center text-sm rounded-lg md:hidden hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-gray-200 dark:text-gray-400 dark:hover:bg-gray-700 dark:focus:ring-gray-600"
aria-controls="navbar-default"
aria-expanded="false"
>
<span className="sr-only">Open main menu</span>
<svg className="w-5 h-5" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 17 14">
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M1 1h15M1 7h15M1 13h15" />
<svg
className="w-5 h-5"
aria-hidden="true"
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 17 14"
>
<path
stroke="currentColor"
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M1 1h15M1 7h15M1 13h15"
/>
</svg>
</button>
<div className={"md:w-auto w-full md:block" + (!show && " hidden")} id="navbar-default">
<div className={"md:w-auto w-full md:block" + (!show && " hidden")}>
<ul className="font-medium flex flex-col p-4 md:p-0 mt-4 md:flex-row md:space-x-8 md:mt-0 border rounded-lg md:border-none">
{links.map((link, index) => (
<li key={index}>