From f9c8ec09a48e6266d9809a4873a7726c68c0889f Mon Sep 17 00:00:00 2001 From: Thomas Cristina de Carvalho Date: Thu, 1 Feb 2024 22:30:47 -0500 Subject: [PATCH] Add mobile nav --- app/components/icons/IconClose.tsx | 9 +- app/components/icons/IconMenu.tsx | 14 ++ app/components/layout/CartCount.tsx | 5 +- app/components/layout/Header.tsx | 54 ++++---- .../{Navigation.tsx => DesktopNavigation.tsx} | 6 +- .../navigation/MobileNavigation.tsx | 122 +++++++++++++++++ .../navigation/NestedNavigation.tsx | 2 +- app/components/ui/MobileNavigationMenu.tsx | 124 ++++++++++++++++++ app/components/ui/NavigationMenu.tsx | 2 +- app/components/ui/Sheet.tsx | 12 +- app/hooks/useBoundedScroll.tsx | 27 ---- app/hooks/useScrollDirection.tsx | 35 +++++ app/root.tsx | 2 +- tailwind.config.ts | 1 + 14 files changed, 341 insertions(+), 74 deletions(-) create mode 100644 app/components/icons/IconMenu.tsx rename app/components/navigation/{Navigation.tsx => DesktopNavigation.tsx} (94%) create mode 100644 app/components/navigation/MobileNavigation.tsx create mode 100644 app/components/ui/MobileNavigationMenu.tsx delete mode 100644 app/hooks/useBoundedScroll.tsx create mode 100644 app/hooks/useScrollDirection.tsx diff --git a/app/components/icons/IconClose.tsx b/app/components/icons/IconClose.tsx index 76fa00c..e2f02e8 100644 --- a/app/components/icons/IconClose.tsx +++ b/app/components/icons/IconClose.tsx @@ -6,15 +6,8 @@ export function IconClose(props: IconProps) { return ( Close + - + Menu + + + + + ); +} diff --git a/app/components/layout/CartCount.tsx b/app/components/layout/CartCount.tsx index f4542ab..7371150 100644 --- a/app/components/layout/CartCount.tsx +++ b/app/components/layout/CartCount.tsx @@ -84,7 +84,10 @@ function Badge(props: {cart?: CartType | null; count: number}) { [count, isHydrated], ); - const buttonClass = cx(['relative flex size-8 items-center justify-center']); + const buttonClass = cx([ + 'relative flex size-8 items-center justify-center', + count > 0 && 'mr-3 md:mr-0', + ]); return isHydrated ? ( diff --git a/app/components/layout/Header.tsx b/app/components/layout/Header.tsx index e4f7839..8c3ef5e 100644 --- a/app/components/layout/Header.tsx +++ b/app/components/layout/Header.tsx @@ -3,15 +3,17 @@ import type {CSSProperties} from 'react'; import {Link} from '@remix-run/react'; import {vercelStegaCleanAll} from '@sanity/client/stega'; import {cx} from 'class-variance-authority'; -import {LazyMotion, m, useTransform} from 'framer-motion'; +import {LazyMotion, m} from 'framer-motion'; +import React from 'react'; -import {useBoundedScroll} from '~/hooks/useBoundedScroll'; import {useLocalePath} from '~/hooks/useLocalePath'; import {useSanityRoot} from '~/hooks/useSanityRoot'; +import {useScrollDirection} from '~/hooks/useScrollDirection'; import {useSettingsCssVars} from '~/hooks/useSettingsCssVars'; import {headerVariants} from '../cva/header'; -import {Navigation} from '../navigation/Navigation'; +import {DesktopNavigation} from '../navigation/DesktopNavigation'; +import {MobileNavigation} from '../navigation/MobileNavigation'; import {CartCount} from './CartCount'; import {Logo} from './Logo'; @@ -30,11 +32,18 @@ export function Header() { return (