Skip to content

Commit

Permalink
✨feat: add navbar
Browse files Browse the repository at this point in the history
  • Loading branch information
autofix-ci[bot] authored and Marukome0743 committed Feb 26, 2024
1 parent 62790c6 commit ae1049c
Show file tree
Hide file tree
Showing 5 changed files with 133 additions and 10 deletions.
6 changes: 5 additions & 1 deletion app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Navbar } from '@/components/navbar'
import type { Metadata } from 'next'
import { Sawarabi_Gothic } from 'next/font/google'
import type React from 'react'
Expand All @@ -20,7 +21,10 @@ export default function RootLayout({
}) {
return (
<html lang="ja">
<body className={inter.className}>{children}</body>
<body className={inter.className}>
<Navbar />
{children}
</body>
</html>
)
}
9 changes: 4 additions & 5 deletions app/page.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@ render(<Home />)

test('p test', () => {
const p = document.querySelectorAll('p')
expect(p[0]?.innerText).toEqual('Get started by editing\u00A0app/page.tsx')
expect(p[1]?.innerText).toEqual(
expect(p[0]?.innerText).toEqual(
'Find in-depth information about Next.js features and API.',
)
expect(p[2]?.innerText).toEqual(
expect(p[1]?.innerText).toEqual(
'Learn about Next.js in an interactive course with\u00A0quizzes!',
)
expect(p[3]?.innerText).toEqual('Explore starter templates for Next.js.')
expect(p[4]?.innerText).toEqual(
expect(p[2]?.innerText).toEqual('Explore starter templates for Next.js.')
expect(p[3]?.innerText).toEqual(
'Instantly deploy your Next.js site to a shareable URL with Vercel.',
)
})
Expand Down
4 changes: 0 additions & 4 deletions app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ export default function Home() {
return (
<main className="flex min-h-screen flex-col items-center justify-between p-24">
<div className="z-10 max-w-5xl w-full items-center justify-between font-mono text-sm lg:flex">
<p className="fixed left-0 top-0 flex w-full justify-center border-b border-gray-300 bg-gradient-to-b from-zinc-200 pb-6 pt-8 backdrop-blur-2xl dark:border-neutral-800 dark:bg-zinc-800/30 dark:from-inherit lg:static lg:w-auto lg:rounded-xl lg:border lg:bg-gray-200 lg:p-4 lg:dark:bg-zinc-800/30">
Get started by editing&nbsp;
<code className="font-mono font-bold">app/page.tsx</code>
</p>
<div className="fixed bottom-0 left-0 flex h-48 w-full items-end justify-center bg-gradient-to-t from-white via-white dark:from-black dark:via-black lg:static lg:h-auto lg:w-auto lg:bg-none">
<a
className="pointer-events-none flex place-items-center gap-2 p-8 lg:pointer-events-auto lg:p-0"
Expand Down
122 changes: 122 additions & 0 deletions components/navbar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
'use client'

import favicon from '@/public/favicon.png'
import { Dialog } from '@headlessui/react'
import { Bars3Icon, XMarkIcon } from '@heroicons/react/24/outline'
import Image from 'next/image'
import Link from 'next/link'
import { useState } from 'react'

export function Navbar() {
const [mobileMenuOpen, setMobileMenuOpen] = useState(false)

return (
<>
<nav
className="mx-auto flex max-w-2xl items-center justify-between p-6 lg:px-8"
aria-label="Global"
>
<div className="flex lg:flex-1">
<Link href="/" className="-m-1.5 p-1.5">
<span className="sr-only">Your Company</span>
<Image className="h-8 w-auto" src={favicon} alt="" />
</Link>
</div>
<div className="flex lg:hidden">
<button
type="button"
className="-m-2.5 inline-flex items-center justify-center rounded-md p-2.5 text-gray-700"
onClick={() => setMobileMenuOpen(true)}
>
<span className="sr-only">Open main menu</span>
<Bars3Icon className="h-6 w-6" aria-hidden="true" />
</button>
</div>
<div className="hidden lg:flex lg:gap-x-12">
<Link
href="/"
className="text-sm font-semibold leading-6 text-gray-900"
>
Product
</Link>
<Link
href="/"
className="text-sm font-semibold leading-6 text-gray-900"
>
Features
</Link>
<Link
href="/"
className="text-sm font-semibold leading-6 text-gray-900"
>
Marketplace
</Link>
<Link
href="/"
className="text-sm font-semibold leading-6 text-gray-900"
>
Company
</Link>
</div>
</nav>
<Dialog
as="div"
className="lg:hidden"
open={mobileMenuOpen}
onClose={setMobileMenuOpen}
>
<div className="fixed inset-0 z-10" />
<Dialog.Panel className="fixed inset-y-0 right-0 z-10 w-full overflow-y-auto bg-white px-6 py-6 sm:max-w-sm sm:ring-1 sm:ring-gray-900/10">
<div className="flex items-center justify-between">
<Link href="/" className="-m-1.5 p-1.5">
<span className="sr-only">Your Company</span>
<img
className="h-8 w-auto"
src="https://tailwindui.com/img/logos/mark.svg?color=indigo&shade=600"
alt=""
/>
</Link>
<button
type="button"
className="-m-2.5 rounded-md p-2.5 text-gray-700"
onClick={() => setMobileMenuOpen(false)}
>
<span className="sr-only">Close menu</span>
<XMarkIcon className="h-6 w-6" aria-hidden="true" />
</button>
</div>
<div className="mt-6 flow-root">
<div className="-my-6 divide-y divide-gray-500/10">
<div className="space-y-2 py-6">
<Link
href="/"
className="-mx-3 block rounded-lg px-3 py-2 text-base font-semibold leading-7 text-gray-900 hover:bg-gray-50"
>
Product
</Link>
<Link
href="/"
className="-mx-3 block rounded-lg px-3 py-2 text-base font-semibold leading-7 text-gray-900 hover:bg-gray-50"
>
Features
</Link>
<Link
href="/"
className="-mx-3 block rounded-lg px-3 py-2 text-base font-semibold leading-7 text-gray-900 hover:bg-gray-50"
>
Marketplace
</Link>
<Link
href="/"
className="-mx-3 block rounded-lg px-3 py-2 text-base font-semibold leading-7 text-gray-900 hover:bg-gray-50"
>
Company
</Link>
</div>
</div>
</div>
</Dialog.Panel>
</Dialog>
</>
)
}
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
"lint": "bunx @biomejs/biome check --apply ."
},
"dependencies": {
"@headlessui/react": "^1.7.18",
"@heroicons/react": "^2.1.1",
"next": "canary",
"react": "canary",
"react-dom": "canary"
Expand Down

0 comments on commit ae1049c

Please sign in to comment.