From f9a67ea9211a55185a6799fb652d958e25817da7 Mon Sep 17 00:00:00 2001 From: bender Date: Wed, 4 Mar 2026 00:29:34 +0000 Subject: [PATCH] Switch to version 1: modified src/components/shared/Dashboard.tsx --- src/components/shared/Dashboard.tsx | 340 +++++++++++++++++++++++++++- 1 file changed, 328 insertions(+), 12 deletions(-) diff --git a/src/components/shared/Dashboard.tsx b/src/components/shared/Dashboard.tsx index 8a2f28d..cf91f20 100644 --- a/src/components/shared/Dashboard.tsx +++ b/src/components/shared/Dashboard.tsx @@ -1,15 +1,331 @@ -import { useCardAnimation } from '@/components/cardStack/CardStack'; +"use client"; -export function Dashboard() { - const { animate, itemRefs } = useCardAnimation(); +import React, { useState, useEffect } from "react"; +import { cls } from "@/lib/utils"; +import type { LucideIcon } from "lucide-react"; +import { + ArrowUpRight, + Bell, + ChevronLeft, + ChevronRight, + Plus, + Search, +} from "lucide-react"; +import AnimationContainer from "@/components/sections/AnimationContainer"; +import Button from "@/components/button/Button"; +import { getButtonProps } from "@/lib/buttonUtils"; +import { useTheme } from "@/providers/themeProvider/ThemeProvider"; +import MediaContent from "@/components/shared/MediaContent"; +import BentoLineChart from "@/components/bento/BentoLineChart/BentoLineChart"; +import type { ChartDataItem } from "@/components/bento/BentoLineChart/utils"; +import type { ButtonConfig } from "@/types/button"; +import { useCardAnimation } from "@/components/cardStack/hooks/useCardAnimation"; +import TextNumberCount from "@/components/text/TextNumberCount"; - const handleAnimate = () => { - animate(0); - }; - - return ( -
- -
- ); +export interface DashboardSidebarItem { + icon: LucideIcon; + active?: boolean; } + +export interface DashboardStat { + title: string; + titleMobile?: string; + values: [number, number, number]; + valuePrefix?: string; + valueSuffix?: string; + valueFormat?: Omit & { + notation?: Exclude; + }; + description: string; +} + +export interface DashboardListItem { + icon: LucideIcon; + title: string; + status: string; +} + +interface DashboardProps { + title: string; + stats: [DashboardStat, DashboardStat, DashboardStat]; + logoIcon: LucideIcon; + sidebarItems: DashboardSidebarItem[]; + searchPlaceholder?: string; + buttons: ButtonConfig[]; + chartTitle?: string; + chartData?: ChartDataItem[]; + listItems: DashboardListItem[]; + listTitle?: string; + imageSrc: string; + videoSrc?: string; + imageAlt?: string; + videoAriaLabel?: string; + className?: string; + containerClassName?: string; + sidebarClassName?: string; + statClassName?: string; + chartClassName?: string; + listClassName?: string; +} + +const Dashboard = ({ + title, + stats, + logoIcon: LogoIcon, + sidebarItems, + searchPlaceholder = "Search", + buttons, + chartTitle = "Revenue Overview", + chartData, + listItems, + listTitle = "Recent Transfers", + imageSrc, + videoSrc, + imageAlt = "", + videoAriaLabel = "Avatar video", + className = "", + containerClassName = "", + sidebarClassName = "", + statClassName = "", + chartClassName = "", + listClassName = "", +}: DashboardProps) => { + const theme = useTheme(); + const [activeStatIndex, setActiveStatIndex] = useState(0); + const [statValueIndex, setStatValueIndex] = useState(0); + const { itemRefs: statRefs } = useCardAnimation({ + animationType: "slide-up", + itemCount: 3, + }); + + useEffect(() => { + const interval = setInterval(() => { + setStatValueIndex((prev) => (prev + 1) % 3); + }, 3000); + return () => clearInterval(interval); + }, []); + + const statCard = (stat: DashboardStat, index: number, withRef = false) => ( +
{ statRefs.current[index] = el; } : undefined} + className={cls( + "group rounded-theme-capped p-5 flex flex-col justify-between h-40 md:h-50 card shadow", + statClassName + )} + > +
+

+ {stat.title} +

+
+ +
+
+
+ +

+ {stat.description} +

+
+
+ ); + + return ( +
+
+
+
+ +
+ +
+
+
+
+
+
+ +

+ {searchPlaceholder} +

+
+
+
+ +
+
+ +
+
+
+
+
+

+ {title} +

+
+ {buttons.slice(0, 2).map((button, index) => ( +
+
+
+ {stats.map((stat, index) => statCard(stat, index, true))} +
+
+ + {statCard(stats[activeStatIndex], activeStatIndex)} + +
+ + +
+
+
+
+
+

+ {chartTitle} +

+
+ +
+
+
+ +
+
+
+
+

+ {listTitle} +

+
+ +
+
+
+
+ {[...listItems, ...listItems, ...listItems, ...listItems].map((item, index) => { + const ItemIcon = item.icon; + return ( +
+
+ +
+
+

+ {item.title} +

+

+ {item.status} +

+
+ +
+ ); + })} +
+
+
+
+
+
+ ); +}; + +Dashboard.displayName = "Dashboard"; + +export default React.memo(Dashboard);