From 74103864715fc13c54443077d1c44e7ff120a2a2 Mon Sep 17 00:00:00 2001 From: Yvonne Tang Date: Mon, 9 Dec 2024 01:52:09 -0800 Subject: [PATCH] Use modal for all breakpoints --- .../ChangemakerCard/ChangemakerCard.tsx | 40 +++---------------- components/Storyblok/SbChangemakerCard.tsx | 2 +- 2 files changed, 6 insertions(+), 36 deletions(-) diff --git a/components/ChangemakerCard/ChangemakerCard.tsx b/components/ChangemakerCard/ChangemakerCard.tsx index ad254f88..ac20832e 100644 --- a/components/ChangemakerCard/ChangemakerCard.tsx +++ b/components/ChangemakerCard/ChangemakerCard.tsx @@ -4,13 +4,12 @@ import { useId, useRef, useState } from 'react'; import { Description, Dialog, DialogPanel, DialogTitle, Transition, TransitionChild, } from '@headlessui/react'; -import { useMediaQuery, useOnClickOutside, useToggle } from 'usehooks-ts'; +import { useOnClickOutside, useToggle } from 'usehooks-ts'; import { AnimateInView, type AnimationType } from '@/components/Animate'; import { Heading, type HeadingType, Text } from '@/components/Typography'; import { FlexBox } from '@/components/FlexBox'; import { HeroIcon } from '@/components/HeroIcon'; import useEscape from '@/hooks/useEscape'; -import { config } from '@/utilities/config'; import { getProcessedImage } from '@/utilities/getProcessedImage'; import * as styles from './ChangemakerCard.styles'; @@ -41,8 +40,6 @@ export const ChangemakerCard = ({ className, ...props }: ChangemakerCardProps) => { - const isNotPhone = useMediaQuery(`(min-width: ${config.breakpoints.sm}px)`); - const cardRef = useRef(null); const buttonRef = useRef(null); const contentRef = useRef(null); @@ -53,19 +50,6 @@ export const ChangemakerCard = ({ // For the mobile modal const [isModalOpen, setIsModalOpen] = useState(false); - const handleClick = () => { - // If it's not XS breakpoint, toggle the card content and if it is shown, focus on contentRef - if (isNotPhone) { - toggle(); - if (!isShown) { - contentRef.current?.focus(); - } - } else { - // Open the modal if it's XS breakpoint - setIsModalOpen(true); - } - }; - // If card content is shown, clicking outside it will dismiss it useOnClickOutside(cardRef, () => { if (isShown) { @@ -164,27 +148,13 @@ export const ChangemakerCard = ({ )} - {/* Content layer */} - {/* Content is displayed on an overlay over the card for all breakpoint except XS */} - -
- {children} -
-