From ac35daf8b34f53df5c734d5c2ef7dae073ac596f Mon Sep 17 00:00:00 2001 From: bender Date: Fri, 27 Feb 2026 12:35:21 +0000 Subject: [PATCH] Update src/components/sections/feature/FeatureCardTwentyOne.tsx --- .../sections/feature/FeatureCardTwentyOne.tsx | 331 ++++++------------ 1 file changed, 108 insertions(+), 223 deletions(-) diff --git a/src/components/sections/feature/FeatureCardTwentyOne.tsx b/src/components/sections/feature/FeatureCardTwentyOne.tsx index 4eb956b..9c87b5c 100644 --- a/src/components/sections/feature/FeatureCardTwentyOne.tsx +++ b/src/components/sections/feature/FeatureCardTwentyOne.tsx @@ -1,235 +1,120 @@ "use client"; -import { useState } from "react"; -import TextBox from "@/components/Textbox"; -import Accordion from "@/components/Accordion"; -import MediaContent from "@/components/shared/MediaContent"; -import { useButtonAnimation } from "@/components/hooks/useButtonAnimation"; -import { cls } from "@/lib/utils"; -import type { LucideIcon } from "lucide-react"; -import type { ButtonConfig, ButtonAnimationType, TitleSegment } from "@/components/cardStack/types"; -import type { InvertedBackground } from "@/providers/themeProvider/config/constants"; +import React, { useState } from "react"; +import { LucideIcon } from "lucide-react"; -type MediaProps = - | { - imageSrc: string; - imageAlt?: string; - videoSrc?: never; - videoAriaLabel?: never; - } - | { - videoSrc: string; - videoAriaLabel?: string; - imageSrc?: never; - imageAlt?: never; - }; +interface AccordionItem { + id: string; + title: string; + content: string; +} -type AccordionItem = { - id: string; - title: string; - content: string; -}; +interface FeatureCardTwentyOneProps { + title: string; + description: string; + tag: string; + tagIcon: LucideIcon; + tagAnimation?: string; + accordionItems: AccordionItem[]; +} -type FeatureCardTwentyOneProps = MediaProps & { - title: string; - titleSegments?: TitleSegment[]; - description: string; - tag?: string; - tagIcon?: LucideIcon; - tagAnimation?: ButtonAnimationType; - buttons?: ButtonConfig[]; - buttonAnimation?: ButtonAnimationType; - mediaAnimation: ButtonAnimationType; - accordionItems: AccordionItem[]; - useInvertedBackground: InvertedBackground; - mediaPosition?: "left" | "right"; - ariaLabel?: string; - className?: string; - containerClassName?: string; - mediaWrapperClassName?: string; - mediaClassName?: string; - contentClassName?: string; - textBoxClassName?: string; - titleClassName?: string; - descriptionClassName?: string; - tagClassName?: string; - buttonContainerClassName?: string; - buttonClassName?: string; - buttonTextClassName?: string; - titleImageWrapperClassName?: string; - titleImageClassName?: string; - accordionContainerClassName?: string; - accordionClassName?: string; - accordionTitleClassName?: string; - accordionContentClassName?: string; - accordionIconContainerClassName?: string; - accordionIconClassName?: string; -}; +export default function FeatureCardTwentyOne({ + title, + description, + tag, + tagIcon: TagIcon, + accordionItems, +}: FeatureCardTwentyOneProps) { + const [flipped, setFlipped] = useState<{ [key: string]: boolean }>({}); -const FeatureCardTwentyOne = ({ - title, - titleSegments, - description, - tag, - tagIcon, - tagAnimation, - buttons, - buttonAnimation, - mediaAnimation, - accordionItems, - imageSrc, - imageAlt, - videoSrc, - videoAriaLabel, - useInvertedBackground, - mediaPosition = "left", - ariaLabel = "Feature section", - className = "", - containerClassName = "", - mediaWrapperClassName = "", - mediaClassName = "", - contentClassName = "", - textBoxClassName = "", - titleClassName = "", - descriptionClassName = "", - tagClassName = "", - buttonContainerClassName = "", - buttonClassName = "", - buttonTextClassName = "", - titleImageWrapperClassName = "", - titleImageClassName = "", - accordionContainerClassName = "", - accordionClassName = "", - accordionTitleClassName = "", - accordionContentClassName = "", - accordionIconContainerClassName = "", - accordionIconClassName = "", -}: FeatureCardTwentyOneProps) => { - const [activeAccordion, setActiveAccordion] = useState(0); - const { containerRef: mediaContainerRef } = useButtonAnimation({ animationType: mediaAnimation }); + const toggleFlip = (id: string) => { + setFlipped((prev) => ({ + ...prev, + [id]: !prev[id], + })); + }; - const handleAccordionToggle = (index: number) => { - setActiveAccordion(activeAccordion === index ? -1 : index); - }; - - const mediaElement = ( -
- + return ( +
+
+ {/* Header Section */} +
+
+ + {tag} +
+

+ {title} +

+

+ {description} +

- ); - const contentElement = ( -
- {/* Mobile */} - - {/* Desktop */} - + {/* Flip Cards Grid */} +
+ {accordionItems.map((item) => ( +
toggleFlip(item.id)} + > +
+ {/* Front Side */} +
+
+

+ {item.title} +

+

+ Click to read more +

+
+
+ + {item.id} + +
+
-
- {accordionItems.map((item, index) => ( - - ))} + {/* Back Side */} +
+
+

+ {item.title} +

+

+ {item.content} +

+
+

+ Click to flip back +

+
+
+ ))}
- ); - - return ( -
-
- {mediaPosition === "left" ? ( - <> - {mediaElement} - {contentElement} - - ) : ( - <> - {contentElement} - {mediaElement} - - )} -
-
- ); -}; - -FeatureCardTwentyOne.displayName = "FeatureCardTwentyOne"; - -export default FeatureCardTwentyOne; \ No newline at end of file +
+
+ ); +} \ No newline at end of file