Update statcard variants

This commit is contained in:
2025-01-01 15:16:31 -05:00
parent 9b5c59c61d
commit f5d20f92b8
2 changed files with 53 additions and 26 deletions

View File

@@ -401,13 +401,15 @@ const MiniStatCards = ({
progress={stats?.periodProgress < 100 ? stats.periodProgress : undefined} progress={stats?.periodProgress < 100 ? stats.periodProgress : undefined}
trend={projectionLoading && stats?.periodProgress < 100 ? undefined : revenueTrend?.trend} trend={projectionLoading && stats?.periodProgress < 100 ? undefined : revenueTrend?.trend}
trendValue={revenueTrend?.value ? formatPercentage(revenueTrend.value) : null} trendValue={revenueTrend?.value ? formatPercentage(revenueTrend.value) : null}
colorClass="text-green-600 dark:text-green-400" colorClass="text-green-200"
icon={DollarSign} icon={DollarSign}
iconColor="text-green-500" iconColor="text-green-200"
titleColor="text-green-200"
descriptionColor="text-green-200"
onDetailsClick={() => setSelectedMetric("revenue")} onDetailsClick={() => setSelectedMetric("revenue")}
isLoading={loading || !stats} isLoading={loading || !stats}
variant="mini" 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" background="bg-gradient-to-br from-green-950 to-green-900 backdrop-blur-md"
/> />
<StatCard <StatCard
@@ -416,13 +418,15 @@ const MiniStatCards = ({
description={`${stats?.itemCount} total items`} description={`${stats?.itemCount} total items`}
trend={orderTrend?.trend} trend={orderTrend?.trend}
trendValue={orderTrend?.value ? formatPercentage(orderTrend.value) : null} trendValue={orderTrend?.value ? formatPercentage(orderTrend.value) : null}
colorClass="text-blue-600 dark:text-blue-400" colorClass="text-blue-200"
icon={ShoppingCart} icon={ShoppingCart}
iconColor="text-blue-500" iconColor="text-blue-200"
titleColor="text-blue-200"
descriptionColor="text-blue-200"
onDetailsClick={() => setSelectedMetric("orders")} onDetailsClick={() => setSelectedMetric("orders")}
isLoading={loading || !stats} isLoading={loading || !stats}
variant="mini" 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" background="bg-gradient-to-br from-blue-950 to-blue-900 backdrop-blur-md"
/> />
<StatCard <StatCard
@@ -432,26 +436,30 @@ const MiniStatCards = ({
description={`${stats?.averageItemsPerOrder?.toFixed(1)} items per order`} description={`${stats?.averageItemsPerOrder?.toFixed(1)} items per order`}
trend={aovTrend?.trend} trend={aovTrend?.trend}
trendValue={aovTrend?.value ? formatPercentage(aovTrend.value) : null} trendValue={aovTrend?.value ? formatPercentage(aovTrend.value) : null}
colorClass="text-purple-600 dark:text-purple-400" colorClass="text-violet-200"
icon={CircleDollarSign} icon={CircleDollarSign}
iconColor="text-purple-500" iconColor="text-violet-200"
titleColor="text-violet-200"
descriptionColor="text-violet-200"
onDetailsClick={() => setSelectedMetric("average_order")} onDetailsClick={() => setSelectedMetric("average_order")}
isLoading={loading || !stats} isLoading={loading || !stats}
variant="mini" 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" background="bg-gradient-to-br from-violet-950 to-violet-900 backdrop-blur-md"
/> />
<StatCard <StatCard
title="Shipped" title="Shipped"
value={stats?.shipping?.shippedCount || 0} value={stats?.shipping?.shippedCount || 0}
description={`${stats?.shipping?.locations?.total || 0} locations`} description={`${stats?.shipping?.locations?.total || 0} locations`}
colorClass="text-teal-600 dark:text-teal-400" colorClass="text-orange-200"
icon={Package} icon={Package}
iconColor="text-teal-500" iconColor="text-orange-200"
titleColor="text-orange-200"
descriptionColor="text-orange-200"
onDetailsClick={() => setSelectedMetric("shipping")} onDetailsClick={() => setSelectedMetric("shipping")}
isLoading={loading || !stats} isLoading={loading || !stats}
variant="mini" 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" background="bg-gradient-to-br from-orange-950 to-orange-900 backdrop-blur-md"
/> />
</div> </div>

View File

@@ -233,7 +233,8 @@ const OrdersDetails = ({ data }) => {
dataKey="orders" dataKey="orders"
name="Orders" name="Orders"
type="bar" type="bar"
color="hsl(221.2 83.2% 53.3%)" color="
"
/> />
</div> </div>
)} )}
@@ -974,6 +975,12 @@ const StatCard = ({
colorClass = "text-gray-900 dark:text-gray-100", colorClass = "text-gray-900 dark:text-gray-100",
icon: Icon, icon: Icon,
iconColor = "text-gray-500", iconColor = "text-gray-500",
titleColor = "text-gray-600 dark:text-gray-300",
descriptionColor = "text-gray-200",
trendColor = {
up: "text-emerald-300",
down: "text-rose-300"
},
onClick, onClick,
info, info,
onDetailsClick, onDetailsClick,
@@ -984,22 +991,38 @@ const StatCard = ({
}) => { }) => {
const variants = { const variants = {
default: "bg-white dark:bg-gray-900/60", 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" mini: background || "bg-gradient-to-br from-gray-800 to-gray-900 backdrop-blur-md"
}; };
const titleVariants = { const titleVariants = {
default: "text-sm font-medium text-gray-600 dark:text-gray-300", default: "text-sm font-medium text-gray-600 dark:text-gray-300",
mini: "text-sm font-bold text-gray-100" mini: `text-sm font-bold ${titleColor || "text-gray-100"}`
}; };
const valueVariants = { const valueVariants = {
default: "text-2xl font-bold", default: "text-2xl font-bold",
mini: "text-2xl font-extrabold text-white" mini: `text-2xl font-extrabold ${colorClass || "text-white"}`
}; };
const descriptionVariants = { const descriptionVariants = {
default: "text-sm text-muted-foreground", default: "text-sm text-muted-foreground",
mini: "text-sm font-semibold text-gray-200" mini: `text-sm font-semibold ${descriptionColor || "text-gray-200"}`
};
const trendColorVariants = {
default: {
up: "text-emerald-600 dark:text-emerald-400",
down: "text-rose-600 dark:text-rose-400"
},
mini: {
up: trendColor?.up || "text-emerald-300",
down: trendColor?.down || "text-rose-300"
}
};
const iconVariants = {
default: iconColor,
mini: iconColor || "text-white"
}; };
return ( return (
@@ -1018,12 +1041,12 @@ const StatCard = ({
</CardTitle> </CardTitle>
{info && ( {info && (
<Info <Info
className={`w-4 h-4 ${variant === 'mini' ? 'text-gray-300' : 'text-muted-foreground'} cursor-help`} className={`w-4 h-4 ${variant === 'mini' ? 'text-gray-200' : 'text-muted-foreground'} cursor-help`}
title={info} title={info}
/> />
)} )}
</div> </div>
{Icon && <Icon className={`h-4 w-4 ${variant === 'mini' ? 'text-gray-100' : iconColor}`} />} {Icon && <Icon className={`h-4 w-4 ${iconVariants[variant]}`} />}
</CardHeader> </CardHeader>
<CardContent className="p-4 pt-0"> <CardContent className="p-4 pt-0">
{isLoading ? ( {isLoading ? (
@@ -1034,7 +1057,7 @@ const StatCard = ({
) : ( ) : (
<div className="space-y-2"> <div className="space-y-2">
<div> <div>
<div className={`${valueVariants[variant]} ${colorClass}`}> <div className={valueVariants[variant]}>
{valuePrefix} {valuePrefix}
{value} {value}
{valueSuffix} {valueSuffix}
@@ -1044,11 +1067,7 @@ const StatCard = ({
{description} {description}
{trend && ( {trend && (
<span <span
className={`flex items-center gap-0 ${ className={`flex items-center gap-0 ${trendColorVariants[variant][trend]}`}
trend === "up"
? "text-emerald-600 dark:text-emerald-400"
: "text-rose-600 dark:text-rose-400"
}`}
> >
{trend === "up" ? ( {trend === "up" ? (
<ArrowUp className="w-4 h-4" /> <ArrowUp className="w-4 h-4" />