From 74fb67db18536497eae3cd1f3b9814b646f05610 Mon Sep 17 00:00:00 2001 From: Matt Date: Thu, 2 Jan 2025 15:36:06 -0500 Subject: [PATCH] Standardize card sizing and spacing --- dashboard/src/App.jsx | 2 +- .../dashboard/MiniRealtimeAnalytics.jsx | 108 +++++++++--------- .../components/dashboard/MiniSalesChart.jsx | 7 +- .../components/dashboard/MiniStatCards.jsx | 2 +- .../dashboard/RealtimeAnalytics.jsx | 22 ++-- 5 files changed, 75 insertions(+), 66 deletions(-) diff --git a/dashboard/src/App.jsx b/dashboard/src/App.jsx index f4ec1c1..ca3cc47 100644 --- a/dashboard/src/App.jsx +++ b/dashboard/src/App.jsx @@ -118,7 +118,7 @@ const SmallLayout = () => { {/* Mini Realtime Analytics */} -
+
{ if (loading && !basicData) { return ( - +
- + Real-Time Analytics - +
@@ -108,7 +108,7 @@ const MiniRealtimeAnalytics = () => { )} -
+
{summaryCard( "Last 30 minutes", "Active users", @@ -117,7 +117,7 @@ const MiniRealtimeAnalytics = () => { colorClass: "text-sky-200", titleClass: "text-sky-100 font-bold text-md", descriptionClass: "text-sky-200 text-md font-semibold", - background: "bg-gradient-to-br from-sky-800 to-sky-700", + background: "h-[150px] bg-gradient-to-br from-sky-900 to-sky-800", icon: Users, iconColor: "text-sky-900", iconBackground: "bg-sky-300" @@ -131,7 +131,7 @@ const MiniRealtimeAnalytics = () => { colorClass: "text-sky-200", titleClass: "text-sky-100 font-bold text-md", descriptionClass: "text-sky-200 text-md font-semibold", - background: "bg-gradient-to-br from-sky-800 to-sky-700", + background: "h-[150px] bg-gradient-to-br from-sky-900 to-sky-800", icon: Activity, iconColor: "text-sky-900", iconBackground: "bg-sky-300" @@ -139,53 +139,55 @@ const MiniRealtimeAnalytics = () => { )}
-
- - - value + "m"} - className="text-xs" - tick={{ fill: "#BAE6FD" }} - /> - - { - if (active && payload && payload.length) { - const timestamp = new Date( - Date.now() + payload[0].payload.minute * 60000 - ); - return ( - - -

- {format(timestamp, "h:mm a")} -

-
- - Active Users: - - - {payload[0].value.toLocaleString()} - -
-
-
- ); - } - return null; - }} - /> - -
-
-
+ + +
+ + + value + "m"} + className="text-xs" + tick={{ fill: "#BAE6FD" }} + /> + + { + if (active && payload && payload.length) { + const timestamp = new Date(payload[0].payload.timestamp); + return ( + + +

+ {format(timestamp, "h:mm a")} +

+
+ + Active Users: + + + {payload[0].value} + +
+
+
+ ); + } + return null; + }} + /> + +
+
+
+
+
); }; diff --git a/dashboard/src/components/dashboard/MiniSalesChart.jsx b/dashboard/src/components/dashboard/MiniSalesChart.jsx index a7a18be..a853f99 100644 --- a/dashboard/src/components/dashboard/MiniSalesChart.jsx +++ b/dashboard/src/components/dashboard/MiniSalesChart.jsx @@ -72,7 +72,7 @@ const MiniStatCard = memo(({ active = true }) => ( { icon={PiggyBank} iconColor="text-emerald-900" iconBackground="bg-emerald-300" - background="bg-gradient-to-br from-emerald-900 to-emerald-800" + background="h-[150px] bg-gradient-to-br from-emerald-900 to-emerald-800" onClick={() => toggleMetric('revenue')} active={visibleMetrics.revenue} /> @@ -257,7 +257,7 @@ const MiniSalesChart = ({ className = "" }) => { icon={Truck} iconColor="text-blue-900" iconBackground="bg-blue-300" - background="bg-gradient-to-br from-blue-900 to-blue-800" + background="h-[150px] bg-gradient-to-br from-blue-900 to-blue-800" onClick={() => toggleMetric('orders')} active={visibleMetrics.orders} /> @@ -305,7 +305,6 @@ const MiniSalesChart = ({ className = "" }) => { value.toLocaleString()} className="text-[10px]" tick={{ fill: "#E9D5FF" }} /> diff --git a/dashboard/src/components/dashboard/MiniStatCards.jsx b/dashboard/src/components/dashboard/MiniStatCards.jsx index c868773..fe5dd9c 100644 --- a/dashboard/src/components/dashboard/MiniStatCards.jsx +++ b/dashboard/src/components/dashboard/MiniStatCards.jsx @@ -410,7 +410,7 @@ const MiniStatCards = ({ onDetailsClick={() => setSelectedMetric("revenue")} isLoading={loading || !stats} variant="mini" - background="bg-gradient-to-br from-emerald-900 to-emerald-800" + background="h-[150px] bg-gradient-to-br from-emerald-900 to-emerald-800" /> { const { colorClass = "text-gray-900 dark:text-gray-100", - titleClass = "text-sm font-medium text-gray-600 dark:text-gray-300", - descriptionClass = "text-sm text-muted-foreground", + titleClass = "text-sm font-medium text-gray-500 dark:text-gray-400", + descriptionClass = "text-sm text-gray-600 dark:text-gray-300", background = "bg-white dark:bg-gray-900/60", icon: Icon, iconColor, @@ -59,9 +59,11 @@ export const summaryCard = (label, sublabel, value, options = {}) => { } = options; return ( - + - {label} + + {label} + {Icon && (
@@ -70,10 +72,16 @@ export const summaryCard = (label, sublabel, value, options = {}) => { )} -
- {value.toLocaleString()} +
+
+
+ {value.toLocaleString()} +
+
+ {sublabel} +
+
-
{sublabel}
);