From 8f46acd4b3d97c35375299e7b8bab29f878df19d Mon Sep 17 00:00:00 2001 From: Alejandro Rosales Date: Thu, 21 Aug 2025 16:10:09 -0600 Subject: [PATCH] feat: enhance RouteComponent with facultades color and improve StatCard UI --- src/routes/_authenticated/plan/$planId.tsx | 76 +++++++++++++++++++--- 1 file changed, 66 insertions(+), 10 deletions(-) diff --git a/src/routes/_authenticated/plan/$planId.tsx b/src/routes/_authenticated/plan/$planId.tsx index 19b9eb6..4da3ea6 100644 --- a/src/routes/_authenticated/plan/$planId.tsx +++ b/src/routes/_authenticated/plan/$planId.tsx @@ -165,6 +165,7 @@ function RouteComponent() { return () => ctx.revert() } }, []) + const facColor = plan.carreras?.facultades?.color ?? null return (
@@ -217,13 +218,22 @@ function RouteComponent() { {/* stats */} - - - - - - + + + + + + + @@ -231,12 +241,58 @@ function RouteComponent() { ) } +function hexToRgbA(hex?: string | null, a = .25) { + if (!hex) return `rgba(37,99,235,${a})` + const h = hex.replace("#", "") + const v = h.length === 3 ? h.split("").map(c => c + c).join("") : h + const n = parseInt(v, 16) + const r = (n >> 16) & 255, g = (n >> 8) & 255, b = n & 255 + return `rgba(${r},${g},${b},${a})` +} + +const fmt = (n?: number | null) => (n !== null && n !== undefined) ? Intl.NumberFormat().format(n) : "—" /* ===== UI bits ===== */ -function KV({ label, value, className = '' }: { label: string; value?: string | number | null; className?: string }) { +type StatProps = { + label: string + value?: React.ReactNode + Icon?: React.ComponentType> + accent?: string | null // color de facultad (hex) opcional + className?: string + title?: string +} +function StatCard({ label, value = "—", Icon = Icons.Info, accent, className = "", title }: StatProps) { + const border = hexToRgbA(accent, .28) + const chipBg = hexToRgbA(accent, .08) + const glow = hexToRgbA(accent, .14) + return ( -
-
{label}
-
{value ?? '—'}
+
+
+
{label}
+ + + +
+ +
+ {value} +
+ + {/* glow sutil en hover */} +
) }