From b890e59fc9358814bb1e58aaf4f629e47cb61804 Mon Sep 17 00:00:00 2001 From: bender Date: Wed, 11 Mar 2026 20:09:10 +0000 Subject: [PATCH] Switch to version 3: modified src/components/sections/metrics/MetricCardTwo.tsx --- .../sections/metrics/MetricCardTwo.tsx | 219 ++++++++++++++---- 1 file changed, 177 insertions(+), 42 deletions(-) diff --git a/src/components/sections/metrics/MetricCardTwo.tsx b/src/components/sections/metrics/MetricCardTwo.tsx index b1e9548..f05289c 100644 --- a/src/components/sections/metrics/MetricCardTwo.tsx +++ b/src/components/sections/metrics/MetricCardTwo.tsx @@ -1,48 +1,183 @@ -import React from 'react'; -import { CardStack } from '@/components/cardStack/CardStack'; +"use client"; -interface MetricCardTwoProps { - metrics: Array<{ +import { memo } from "react"; +import CardStack from "@/components/cardStack/CardStack"; +import { cls, shouldUseInvertedText } from "@/lib/utils"; +import { useTheme } from "@/providers/themeProvider/ThemeProvider"; +import type { LucideIcon } from "lucide-react"; +import type { ButtonConfig, GridVariant, CardAnimationTypeWith3D, TitleSegment, ButtonAnimationType } from "@/components/cardStack/types"; +import type { TextboxLayout, InvertedBackground } from "@/providers/themeProvider/config/constants"; + +type MetricCardTwoGridVariant = Extract; + +type Metric = { id: string; value: string; description: string; - }>; - title: string; - description: string; - gridVariant?: string; - animationType?: string; - useInvertedBackground?: boolean; - [key: string]: any; -} - -const MetricCardTwo: React.FC = ({ - metrics, - title, - description, - gridVariant = 'uniform-all-items-equal', - animationType = 'slide-up', - useInvertedBackground = false, - ...props -}) => { - const metricItems = metrics.map((metric) => ( -
-

{metric.value}

-

{metric.description}

-
- )); - - return ( - - {metricItems} - - ); }; -export default MetricCardTwo; \ No newline at end of file +interface MetricCardTwoProps { + metrics: Metric[]; + carouselMode?: "auto" | "buttons"; + gridVariant: MetricCardTwoGridVariant; + uniformGridCustomHeightClasses?: string; + animationType: CardAnimationTypeWith3D; + title: string; + titleSegments?: TitleSegment[]; + description: string; + tag?: string; + tagIcon?: LucideIcon; + tagAnimation?: ButtonAnimationType; + buttons?: ButtonConfig[]; + buttonAnimation?: ButtonAnimationType; + textboxLayout: TextboxLayout; + useInvertedBackground: InvertedBackground; + ariaLabel?: string; + className?: string; + containerClassName?: string; + cardClassName?: string; + textBoxTitleClassName?: string; + textBoxTitleImageWrapperClassName?: string; + textBoxTitleImageClassName?: string; + textBoxDescriptionClassName?: string; + valueClassName?: string; + metricDescriptionClassName?: string; + gridClassName?: string; + carouselClassName?: string; + controlsClassName?: string; + textBoxClassName?: string; + textBoxTagClassName?: string; + textBoxButtonContainerClassName?: string; + textBoxButtonClassName?: string; + textBoxButtonTextClassName?: string; +} + +interface MetricCardItemProps { + metric: Metric; + shouldUseLightText: boolean; + cardClassName?: string; + valueClassName?: string; + metricDescriptionClassName?: string; +} + +const MetricCardItem = memo(({ + metric, + shouldUseLightText, + cardClassName = "", + valueClassName = "", + metricDescriptionClassName = "", +}: MetricCardItemProps) => { + return ( +
+

+ {metric.value} +

+

+ {metric.description} +

+
+ ); +}); + +MetricCardItem.displayName = "MetricCardItem"; + +const MetricCardTwo = ({ + metrics, + carouselMode = "buttons", + gridVariant, + uniformGridCustomHeightClasses, + animationType, + title, + titleSegments, + description, + tag, + tagIcon, + tagAnimation, + buttons, + buttonAnimation, + textboxLayout, + useInvertedBackground, + ariaLabel = "Metrics section", + className = "", + containerClassName = "", + cardClassName = "", + textBoxTitleClassName = "", + textBoxTitleImageWrapperClassName = "", + textBoxTitleImageClassName = "", + textBoxDescriptionClassName = "", + valueClassName = "", + metricDescriptionClassName = "", + gridClassName = "", + carouselClassName = "", + controlsClassName = "", + textBoxClassName = "", + textBoxTagClassName = "", + textBoxButtonContainerClassName = "", + textBoxButtonClassName = "", + textBoxButtonTextClassName = "", +}: MetricCardTwoProps) => { + const theme = useTheme(); + const shouldUseLightText = shouldUseInvertedText(useInvertedBackground, theme.cardStyle); + + const customUniformHeight = gridVariant === "uniform-all-items-equal" + ? "min-h-70 2xl:min-h-80" + : uniformGridCustomHeightClasses; + + const customGridRows = (gridVariant === "bento-grid" || gridVariant === "bento-grid-inverted") + ? "md:grid-rows-[14rem_14rem] 2xl:grid-rows-[17rem_17rem]" + : undefined; + + return ( + + {metrics.map((metric, index) => ( + + ))} + + ); +}; + +MetricCardTwo.displayName = "MetricCardTwo"; + +export default MetricCardTwo;