From a43a14cbd6efa484bdd9fbd476d1fd86dd6e992e Mon Sep 17 00:00:00 2001 From: YoNG-Zaii Date: Sun, 21 May 2023 11:27:34 +0800 Subject: [PATCH] feat(cart): Add cart button component (#95) --- packages/ui/components/merch/CartButton.tsx | 43 ++++++++++++++++++++ packages/ui/components/merch/CartHeader.tsx | 45 --------------------- packages/ui/components/merch/Page.tsx | 6 +-- packages/ui/components/merch/index.tsx | 3 +- packages/ui/components/navbar/MenuItems.tsx | 22 ++++++++-- 5 files changed, 65 insertions(+), 54 deletions(-) create mode 100644 packages/ui/components/merch/CartButton.tsx delete mode 100644 packages/ui/components/merch/CartHeader.tsx diff --git a/packages/ui/components/merch/CartButton.tsx b/packages/ui/components/merch/CartButton.tsx new file mode 100644 index 00000000..fd6104af --- /dev/null +++ b/packages/ui/components/merch/CartButton.tsx @@ -0,0 +1,43 @@ +import Link from "next/link" +import { Icon } from "@chakra-ui/react"; +import routes from "../../../../apps/web/features/merch/constants/routes"; + +const CartButton = () => { + return( + + + + ) +} + +/* +const CartButton = () => { + return( + + + + + + ) +} +*/ + +export default CartButton; \ No newline at end of file diff --git a/packages/ui/components/merch/CartHeader.tsx b/packages/ui/components/merch/CartHeader.tsx deleted file mode 100644 index d0359986..00000000 --- a/packages/ui/components/merch/CartHeader.tsx +++ /dev/null @@ -1,45 +0,0 @@ -import { - Box, - Flex, - HStack, - Spacer, - Show, - Hide, - Icon, -} from "@chakra-ui/react"; -import Link from 'next/link'; -import routes from "../../../../apps/web/features/merch/constants/routes"; - - -export const CartHeader = () => { - return ( - - - - - - - - - - - - - - - - - - - - - - - - - - ); -}; \ No newline at end of file diff --git a/packages/ui/components/merch/Page.tsx b/packages/ui/components/merch/Page.tsx index d6364352..ae488c6b 100644 --- a/packages/ui/components/merch/Page.tsx +++ b/packages/ui/components/merch/Page.tsx @@ -1,6 +1,5 @@ import { ReactNode } from "react"; import { Flex, FlexProps, Box } from "@chakra-ui/react"; -import { CartHeader } from "./CartHeader"; type PageProps = FlexProps & { children: ReactNode; @@ -11,14 +10,13 @@ type PageProps = FlexProps & { export const Page = ({ children, - hideHeader = false, contentWidth = "1400px", contentPadding = [4, 6, 8], ...props }: PageProps) => { return ( - {!hideHeader && } + ); -}; \ No newline at end of file +}; diff --git a/packages/ui/components/merch/index.tsx b/packages/ui/components/merch/index.tsx index 9c62fae3..d0f4edee 100644 --- a/packages/ui/components/merch/index.tsx +++ b/packages/ui/components/merch/index.tsx @@ -1,8 +1,7 @@ export * from "./Card" -export * from "./CartHeader" export * from "./EmptyProductView" export * from "./MerchCarousel" export * from "./Page" export * from "./SizeChartDialog" export * from "./SizeOption" -export * from "./skeleton" \ No newline at end of file +export * from "./skeleton" diff --git a/packages/ui/components/navbar/MenuItems.tsx b/packages/ui/components/navbar/MenuItems.tsx index 5a361375..c4650c4b 100644 --- a/packages/ui/components/navbar/MenuItems.tsx +++ b/packages/ui/components/navbar/MenuItems.tsx @@ -1,6 +1,9 @@ -import React from "react"; import { Box, Link, Stack, Text } from "@chakra-ui/react"; +import { useState, useEffect } from "react"; +import { useRouter } from "next/router"; import { MenuLink, MenuLinkProps } from "./MenuLink"; +import CartButton from "../merch/CartButton"; +import routes from "../../../../apps/web/features/merch/constants/routes"; interface MenuItemProps { isOpen?: boolean; @@ -8,6 +11,17 @@ interface MenuItemProps { } export const MenuItems = ({ isOpen = false, links }: MenuItemProps) => { + + const router = useRouter() + const [route, setRoute] = useState('') + + useEffect(() => { + setRoute(router.pathname), + [] + }) + + const regexp = /\/merch*/; + return ( { {/* CTA Button -> Contact */} + {/* If on merch site, change to Cart */} { w="max-content" display={{ base: "block", xl: "block" }} > - Contact + {route.match(regexp) ? : + Contact} );