mirror of
https://github.com/vercel/commerce.git
synced 2025-05-16 06:26:58 +00:00
New header UI (#1067)
This commit is contained in:
parent
25c91dc590
commit
7bad98965a
@ -33,7 +33,7 @@ const inter = Inter({
|
|||||||
export default async function RootLayout({ children }: { children: ReactNode }) {
|
export default async function RootLayout({ children }: { children: ReactNode }) {
|
||||||
return (
|
return (
|
||||||
<html lang="en" className={inter.variable}>
|
<html lang="en" className={inter.variable}>
|
||||||
<body className="bg-white text-black selection:bg-teal-300 dark:bg-black dark:text-white dark:selection:bg-fuchsia-600 dark:selection:text-white">
|
<body className="bg-gray-50 text-black selection:bg-teal-300 dark:bg-dark dark:text-white dark:selection:bg-fuchsia-600 dark:selection:text-white">
|
||||||
<Navbar />
|
<Navbar />
|
||||||
<Suspense>
|
<Suspense>
|
||||||
<main>{children}</main>
|
<main>{children}</main>
|
||||||
|
@ -1,35 +1,41 @@
|
|||||||
import Link from 'next/link';
|
|
||||||
import { Suspense } from 'react';
|
|
||||||
|
|
||||||
import Cart from 'components/cart';
|
import Cart from 'components/cart';
|
||||||
import CartIcon from 'components/icons/cart';
|
import CartIcon from 'components/icons/cart';
|
||||||
import LogoIcon from 'components/icons/logo';
|
import LogoSquare from 'components/logo-square';
|
||||||
import { getMenu } from 'lib/shopify';
|
import { getMenu } from 'lib/shopify';
|
||||||
import { Menu } from 'lib/shopify/types';
|
import { Menu } from 'lib/shopify/types';
|
||||||
|
import Link from 'next/link';
|
||||||
|
import { Suspense } from 'react';
|
||||||
import MobileMenu from './mobile-menu';
|
import MobileMenu from './mobile-menu';
|
||||||
import Search from './search';
|
import Search from './search';
|
||||||
|
const { SITE_NAME } = process.env;
|
||||||
|
|
||||||
export default async function Navbar() {
|
export default async function Navbar() {
|
||||||
const menu = await getMenu('next-js-frontend-header-menu');
|
const menu = await getMenu('next-js-frontend-header-menu');
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<nav className="relative flex items-center justify-between bg-white p-4 dark:bg-black lg:px-6">
|
<nav className="relative flex items-center justify-between p-4 lg:px-6">
|
||||||
<div className="block w-1/3 md:hidden">
|
<div className="block flex-none md:hidden">
|
||||||
<MobileMenu menu={menu} />
|
<MobileMenu menu={menu} />
|
||||||
</div>
|
</div>
|
||||||
<div className="flex justify-self-center md:w-1/3 md:justify-self-start">
|
<div className="flex w-full items-center">
|
||||||
<div className="md:mr-4">
|
<div className="flex w-full md:w-1/3">
|
||||||
<Link href="/" aria-label="Go back home">
|
<Link
|
||||||
<LogoIcon className="h-8 transition-transform hover:scale-110" />
|
href="/"
|
||||||
</Link>
|
aria-label="Go back home"
|
||||||
|
className="mr-2 flex w-full items-center justify-center md:w-auto lg:mr-6"
|
||||||
|
>
|
||||||
|
<LogoSquare />
|
||||||
|
<div className="ml-2 flex-none text-sm font-medium uppercase md:hidden lg:block">
|
||||||
|
{SITE_NAME}
|
||||||
</div>
|
</div>
|
||||||
|
</Link>
|
||||||
{menu.length ? (
|
{menu.length ? (
|
||||||
<ul className="hidden md:flex md:items-center">
|
<ul className="hidden text-sm md:flex md:items-center">
|
||||||
{menu.map((item: Menu) => (
|
{menu.map((item: Menu) => (
|
||||||
<li key={item.title}>
|
<li key={item.title}>
|
||||||
<Link
|
<Link
|
||||||
href={item.path}
|
href={item.path}
|
||||||
className="rounded-lg px-2 py-1 text-gray-800 hover:text-gray-500 dark:text-gray-200 dark:hover:text-gray-400"
|
className="mr-3 text-gray-500 underline-offset-4 hover:text-black hover:underline dark:hover:text-gray-400 lg:mr-8"
|
||||||
>
|
>
|
||||||
{item.title}
|
{item.title}
|
||||||
</Link>
|
</Link>
|
||||||
@ -38,15 +44,15 @@ export default async function Navbar() {
|
|||||||
</ul>
|
</ul>
|
||||||
) : null}
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
<div className="hidden w-1/3 md:block">
|
<div className="hidden justify-center md:flex md:w-1/3">
|
||||||
<Search />
|
<Search />
|
||||||
</div>
|
</div>
|
||||||
|
<div className="flex justify-end md:w-1/3">
|
||||||
<div className="flex w-1/3 justify-end">
|
|
||||||
<Suspense fallback={<CartIcon className="h-6" />}>
|
<Suspense fallback={<CartIcon className="h-6" />}>
|
||||||
<Cart />
|
<Cart />
|
||||||
</Suspense>
|
</Suspense>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -26,20 +26,17 @@ export default function Search() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<form
|
<form onSubmit={onSubmit} className="relative w-full lg:w-[320px]">
|
||||||
onSubmit={onSubmit}
|
|
||||||
className="relative m-0 flex w-full items-center border border-gray-200 bg-transparent p-0 dark:border-gray-500"
|
|
||||||
>
|
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
name="search"
|
name="search"
|
||||||
placeholder="Search for products..."
|
placeholder="Search for products..."
|
||||||
autoComplete="off"
|
autoComplete="off"
|
||||||
defaultValue={searchParams?.get('q') || ''}
|
defaultValue={searchParams?.get('q') || ''}
|
||||||
className="w-full px-4 py-2 text-black dark:bg-black dark:text-gray-100"
|
className="w-full rounded-lg border bg-white px-4 py-2 text-sm text-black placeholder:text-gray-800 dark:border-gray-800 dark:bg-transparent dark:text-gray-500 dark:placeholder:text-gray-500"
|
||||||
/>
|
/>
|
||||||
<div className="absolute right-0 top-0 mr-3 flex h-full items-center">
|
<div className="absolute right-0 top-0 mr-3 flex h-full items-center">
|
||||||
<MagnifyingGlassIcon className="h-5" />
|
<MagnifyingGlassIcon className="h-4" />
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
);
|
);
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
import clsx from 'clsx';
|
import clsx from 'clsx';
|
||||||
import LogoIcon from './icons/logo';
|
import LogoIcon from './icons/logo';
|
||||||
|
|
||||||
export default function LogoSquare({ size }: { size: 'sm' | undefined }) {
|
export default function LogoSquare({ size }: { size?: 'sm' | undefined }) {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={clsx(
|
className={clsx(
|
||||||
'flex items-center justify-center border border-gray-200 dark:border-gray-700',
|
'flex flex-none items-center justify-center border border-gray-200 dark:border-gray-700',
|
||||||
{
|
{
|
||||||
'h-[40px] w-[40px] rounded-xl': !size,
|
'h-[40px] w-[40px] rounded-xl': !size,
|
||||||
'h-[30px] w-[30px] rounded-lg': size === 'sm'
|
'h-[30px] w-[30px] rounded-lg': size === 'sm'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user