From 9b5c59c61d1fbe2c902c4a15d859157dd09bfef3 Mon Sep 17 00:00:00 2001 From: Matt Date: Wed, 1 Jan 2025 14:22:26 -0500 Subject: [PATCH] Add statcard variants --- .../components/dashboard/MiniStatCards.jsx | 36 ++-- .../src/components/dashboard/StatCards.jsx | 154 ++++++++++-------- 2 files changed, 106 insertions(+), 84 deletions(-) diff --git a/dashboard/src/components/dashboard/MiniStatCards.jsx b/dashboard/src/components/dashboard/MiniStatCards.jsx index 8f02268..63f92fa 100644 --- a/dashboard/src/components/dashboard/MiniStatCards.jsx +++ b/dashboard/src/components/dashboard/MiniStatCards.jsx @@ -351,8 +351,8 @@ const MiniStatCards = ({ if (loading && !stats) { return ( - -
+ +
{[...Array(4)].map((_, i) => ( ))} @@ -387,7 +387,7 @@ const MiniStatCards = ({ description={ stats?.periodProgress < 100 ? (
- Proj: + Projected: {projectionLoading ? ( ) : ( @@ -398,44 +398,38 @@ const MiniStatCards = ({
) : null } - progress={ - stats?.periodProgress < 100 ? stats.periodProgress : undefined - } - trend={ - projectionLoading && stats?.periodProgress < 100 - ? undefined - : revenueTrend?.trend - } - trendValue={ - revenueTrend?.value ? formatPercentage(revenueTrend.value) : null - } + progress={stats?.periodProgress < 100 ? stats.periodProgress : undefined} + trend={projectionLoading && stats?.periodProgress < 100 ? undefined : revenueTrend?.trend} + trendValue={revenueTrend?.value ? formatPercentage(revenueTrend.value) : null} colorClass="text-green-600 dark:text-green-400" icon={DollarSign} iconColor="text-green-500" onDetailsClick={() => setSelectedMetric("revenue")} isLoading={loading || !stats} + variant="mini" + background="bg-gradient-to-br from-emerald-700/90 to-green-700/90 backdrop-blur-md hover:from-emerald-900 hover:to-green-800" /> setSelectedMetric("orders")} isLoading={loading || !stats} + variant="mini" + background="bg-gradient-to-br from-blue-700/90 to-indigo-700/90 backdrop-blur-md hover:from-blue-900 hover:to-indigo-800" /> setSelectedMetric("average_order")} isLoading={loading || !stats} + variant="mini" + background="bg-gradient-to-br from-purple-700/90 to-violet-700/90 backdrop-blur-md hover:from-purple-900 hover:to-violet-800" /> setSelectedMetric("shipping")} isLoading={loading || !stats} + variant="mini" + background="bg-gradient-to-br from-teal-700/90 to-cyan-700/90 backdrop-blur-md hover:from-teal-900 hover:to-cyan-800" />
diff --git a/dashboard/src/components/dashboard/StatCards.jsx b/dashboard/src/components/dashboard/StatCards.jsx index 9e6190d..7bc5bd1 100644 --- a/dashboard/src/components/dashboard/StatCards.jsx +++ b/dashboard/src/components/dashboard/StatCards.jsx @@ -979,72 +979,96 @@ const StatCard = ({ onDetailsClick, isLoading = false, progress, -}) => ( - - -
- - {title} - - {info && ( - - )} -
- {Icon && } -
- - {isLoading ? ( - <> - - - - ) : ( -
-
-
- {valuePrefix} - {value} - {valueSuffix} -
- {description && ( -
- {description} - {trend && ( - - {trend === "up" ? ( - - ) : ( - - )} - {trendPrefix} - {trendValue} - {trendSuffix} - - )} -
- )} -
+ variant = "default", + background +}) => { + const variants = { + default: "bg-white dark:bg-gray-900/60", + mini: background || "bg-gradient-to-br from-gray-900/90 to-gray-800/90 backdrop-blur-md hover:from-gray-900 hover:to-gray-800" + }; + + const titleVariants = { + default: "text-sm font-medium text-gray-600 dark:text-gray-300", + mini: "text-sm font-bold text-gray-100" + }; + + const valueVariants = { + default: "text-2xl font-bold", + mini: "text-2xl font-extrabold text-white" + }; + + const descriptionVariants = { + default: "text-sm text-muted-foreground", + mini: "text-sm font-semibold text-gray-200" + }; + + return ( + + +
+ + {title} + + {info && ( + + )}
- )} - -
-); + {Icon && } + + + {isLoading ? ( + <> + + + + ) : ( +
+
+
+ {valuePrefix} + {value} + {valueSuffix} +
+ {description && ( +
+ {description} + {trend && ( + + {trend === "up" ? ( + + ) : ( + + )} + {trendPrefix} + {trendValue} + {trendSuffix} + + )} +
+ )} +
+
+ )} +
+ + ); +}; // Add this before the StatCards component const useDataCache = () => {