-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* mv breadcrumbs * wip * refactor * story * fix * rm storybook from nextjs * dep * waitfor check
- Loading branch information
Showing
49 changed files
with
467 additions
and
381 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,48 @@ | ||
import * as React from "react"; | ||
import Link from "next/link"; | ||
import classNames from "classnames"; | ||
import { Cart, CartContent, Button, useCart } from "shared-ui"; | ||
import { Button, useCart, Header as BaseHeader, useMobileNav } from "shared-ui"; | ||
import { Search } from "components/Search"; | ||
import { MobileHeaderItems } from "./MobileHeaderItems"; | ||
import { NAV_ITEMS } from "./NavItems"; | ||
import { MobileNavMenu } from "./MobileNavMenu"; | ||
import { DesktopNavItem } from "./DesktopNavItem"; | ||
import { Logo } from "./Logo"; | ||
import { useRouter } from "next/router"; | ||
import { NAV_ITEMS } from "shared-ui"; | ||
import { DesktopNavItem } from "shared-ui"; | ||
import { Cart } from "shared-ui"; | ||
import { CartContent } from "shared-ui"; | ||
import { Logo } from "shared-ui"; | ||
import { MobileNavMenu } from "shared-ui"; | ||
|
||
export const Header = () => { | ||
const [isNavOpen, setIsNavOpen] = React.useState(false); | ||
const { toggleCartOpen } = useCart(); | ||
|
||
const onMobileNavClick = () => setIsNavOpen((prev) => !prev); | ||
const onMobileNavClose = () => setIsNavOpen(false); | ||
|
||
React.useEffect(() => { | ||
document.body.classList[isNavOpen ? "add" : "remove"]("overflow-hidden"); | ||
}, [isNavOpen]); | ||
const { pathname } = useRouter(); | ||
const { onMobileNavClose } = useMobileNav(); | ||
|
||
return ( | ||
<header className={classNames("sticky top-0 z-10 flex flex-col", isNavOpen && "h-screen")}> | ||
<nav className="h-[66px] sm:h-[110px] border-b-2 border-b-primary bg-secondary shadow transition-all text-primary"> | ||
<div className="h-full container flex items-center justify-between px-6"> | ||
<div className="flex items-center"> | ||
<Link href="/" onClick={onMobileNavClose}> | ||
<Logo className="w-24" /> | ||
</Link> | ||
<ul className="ml-8 hidden sm:flex sm:flex-1"> | ||
{/* Desktop Nav */} | ||
{NAV_ITEMS.map(({ href, label }) => ( | ||
<DesktopNavItem key={`${href}-${label}`} href={href} label={label} /> | ||
))} | ||
</ul> | ||
</div> | ||
<div className="flex items-center"> | ||
<Search /> | ||
<Cart onMobileNavClose={onMobileNavClose}> | ||
<CartContent | ||
ProductListLink={ | ||
<Link href="/products" passHref legacyBehavior> | ||
<Button as="a" variant="secondary" onClick={() => toggleCartOpen(false)}> | ||
View Products | ||
</Button> | ||
</Link> | ||
} | ||
/> | ||
</Cart> | ||
<MobileNavMenu navOpen={isNavOpen} onMobileNavClick={onMobileNavClick} /> | ||
</div> | ||
</div> | ||
</nav> | ||
<MobileHeaderItems navOpen={isNavOpen} onMobileNavClose={onMobileNavClose} /> | ||
</header> | ||
<BaseHeader LinkElement={Link} currentRoute={pathname}> | ||
<div className="flex items-center"> | ||
<Link href="/" onClick={onMobileNavClose}> | ||
<Logo className="w-24" /> | ||
</Link> | ||
<ul className="ml-8 hidden sm:flex sm:flex-1"> | ||
{/* Desktop Nav */} | ||
{NAV_ITEMS.map(({ href, label }) => ( | ||
<DesktopNavItem as={Link} isActive={pathname === href} key={`${href}-${label}`} href={href} label={label} /> | ||
))} | ||
</ul> | ||
</div> | ||
<div className="flex items-center"> | ||
<Search /> | ||
<Cart onMobileNavClose={onMobileNavClose}> | ||
<CartContent | ||
ProductListLink={ | ||
<Link href="/products" passHref legacyBehavior> | ||
<Button as="a" variant="secondary" onClick={() => toggleCartOpen(false)}> | ||
View Products | ||
</Button> | ||
</Link> | ||
} | ||
/> | ||
</Cart> | ||
<MobileNavMenu /> | ||
</div> | ||
</BaseHeader> | ||
); | ||
}; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
82e89ea
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
nextjs-sanity-fe – ./
nextjs-sanity-fe.vercel.app
nextjs-sanity-fe-git-main-formidable-labs.vercel.app
nextjs-sanity-fe-formidable-labs.vercel.app