From 906d94e140de1512aed1ab39fc4e85c0da947517 Mon Sep 17 00:00:00 2001 From: ken Date: Mon, 17 Jun 2024 08:53:03 +0700 Subject: [PATCH 1/2] chore: update icon --- app/components/Icons.tsx | 37 ++++++++++++++++++++++++++++++++ app/modules/Drawer.tsx | 7 +++--- app/modules/menu/DesktopMenu.tsx | 33 ++++++++++++++++++++-------- app/modules/menu/MobileMenu.tsx | 14 +++++++----- 4 files changed, 74 insertions(+), 17 deletions(-) diff --git a/app/components/Icons.tsx b/app/components/Icons.tsx index 0e6344fa..2d414be1 100644 --- a/app/components/Icons.tsx +++ b/app/components/Icons.tsx @@ -1,3 +1,5 @@ +import clsx from "clsx"; + type IconProps = JSX.IntrinsicElements["svg"]; // Using icons from https://phosphoricons.com/ @@ -61,3 +63,38 @@ export function IconTag(props: IconProps) { ); } + +export function IconCaret(props: IconProps) { + let { className, direction = "right", ...rest } = props; + let rotate; + + switch (direction) { + case "down": + rotate = "rotate-0"; + break; + case "up": + rotate = "rotate-180"; + break; + case "right": + rotate = "-rotate-90"; + break; + case "left": + rotate = "rotate-90"; + break; + default: + rotate = "rotate-0"; + } + return ( + + + + ); +} diff --git a/app/modules/Drawer.tsx b/app/modules/Drawer.tsx index 0b4c6bb9..c78421d5 100644 --- a/app/modules/Drawer.tsx +++ b/app/modules/Drawer.tsx @@ -1,9 +1,10 @@ import { Fragment, useState } from "react"; import { Dialog, Transition } from "@headlessui/react"; -import { Heading, IconCaret, IconClose } from "~/modules"; +import { Heading, IconClose } from "~/modules"; import { cn } from "~/lib/cn"; import clsx from "clsx"; +import { IconCaret } from "~/components/Icons"; /** * Drawer component that opens on user click. @@ -88,11 +89,11 @@ export function Drawer({ {isBackMenu && ( )} {heading !== null && ( diff --git a/app/modules/menu/DesktopMenu.tsx b/app/modules/menu/DesktopMenu.tsx index 5834967f..c45b1c74 100644 --- a/app/modules/menu/DesktopMenu.tsx +++ b/app/modules/menu/DesktopMenu.tsx @@ -1,11 +1,12 @@ import { Link } from "@remix-run/react"; import { Image } from "@shopify/hydrogen"; -import{ +import { Nav_Items, type ImageMenuProps, type MultiMenuProps, type SingleMenuProps, } from "./defines"; +import clsx from "clsx"; const MenuByType = { multi: MultiMenu, @@ -13,6 +14,9 @@ const MenuByType = { single: SingleMenu, }; +const commonAnimatedClass = + "absolute h-0 opacity-0 overflow-hidden bg-white shadow-md transition-all ease-out group-hover:opacity-100 group-hover:border-t duration-500 group-hover:duration-300 group-hover:z-50 "; + export function DesktopMenu() { return (