From d0826dc15a843ad468a4603d98d8ae4ff8a4f9e3 Mon Sep 17 00:00:00 2001 From: Pierre Wessman <4029607+pierrewessman@users.noreply.github.com> Date: Fri, 12 Dec 2025 12:21:25 +0100 Subject: [PATCH] ui polish --- app/globals.css | 3 +-- components/charts/bar-chart.tsx | 17 +++++++++------- components/charts/line-chart.tsx | 17 ++++++++++------ components/dashboard/metric-card.tsx | 21 +++++++++++++++----- components/dashboard/revenue-chart.tsx | 15 +++++++++----- components/dashboard/sales-chart.tsx | 27 ++++++++++++++++++++------ lib/mock-data.ts | 4 ++++ types/dashboard.ts | 1 + 8 files changed, 74 insertions(+), 31 deletions(-) diff --git a/app/globals.css b/app/globals.css index c50fb50..1f94d63 100644 --- a/app/globals.css +++ b/app/globals.css @@ -6,8 +6,7 @@ @theme inline { --color-background: var(--background); --color-foreground: var(--foreground); - --font-sans: var(--font-geist-sans); - --font-mono: var(--font-geist-mono); + --font-sans: var(--font-inter); --color-sidebar-ring: var(--sidebar-ring); --color-sidebar-border: var(--sidebar-border); --color-sidebar-accent-foreground: var(--sidebar-accent-foreground); diff --git a/components/charts/bar-chart.tsx b/components/charts/bar-chart.tsx index 3070baf..6008ca1 100644 --- a/components/charts/bar-chart.tsx +++ b/components/charts/bar-chart.tsx @@ -11,14 +11,15 @@ interface BarChartProps { datasets: { label: string data: number[] - backgroundColor?: string + backgroundColor?: string | string[] }[] } options?: ChartOptions<"bar"> height?: number + showGrid?: boolean } -export function BarChart({ data, options, height = 300 }: BarChartProps) { +export function BarChart({ data, options, height = 300, showGrid = true }: BarChartProps) { const { theme } = useTheme() const colors = getChartColors(theme) @@ -27,6 +28,8 @@ export function BarChart({ data, options, height = 300 }: BarChartProps) { datasets: data.datasets.map((dataset) => ({ ...dataset, backgroundColor: dataset.backgroundColor || colors.primary, + borderRadius: 6, + borderSkipped: false, })), } @@ -35,16 +38,19 @@ export function BarChart({ data, options, height = 300 }: BarChartProps) { ...options, scales: { y: { + display: showGrid, grid: { + display: showGrid, color: colors.grid, }, ticks: { + display: showGrid, color: colors.text, }, }, x: { grid: { - color: colors.grid, + display: false, }, ticks: { color: colors.text, @@ -55,10 +61,7 @@ export function BarChart({ data, options, height = 300 }: BarChartProps) { ...defaultChartOptions.plugins, ...options?.plugins, legend: { - ...defaultChartOptions.plugins?.legend, - labels: { - color: colors.text, - }, + display: false, }, }, } diff --git a/components/charts/line-chart.tsx b/components/charts/line-chart.tsx index 81d5895..165ca1e 100644 --- a/components/charts/line-chart.tsx +++ b/components/charts/line-chart.tsx @@ -17,9 +17,11 @@ interface LineChartProps { } options?: ChartOptions<"line"> height?: number + showGrid?: boolean + showPoints?: boolean } -export function LineChart({ data, options, height = 300 }: LineChartProps) { +export function LineChart({ data, options, height = 300, showGrid = true, showPoints = true }: LineChartProps) { const { theme } = useTheme() const colors = getChartColors(theme) @@ -31,6 +33,9 @@ export function LineChart({ data, options, height = 300 }: LineChartProps) { backgroundColor: dataset.backgroundColor || (index === 0 ? `${colors.primary}20` : `${colors.secondary}20`), tension: 0.4, fill: true, + borderWidth: 2, + pointRadius: showPoints ? 3 : 0, + pointHoverRadius: showPoints ? 5 : 0, })), } @@ -39,16 +44,19 @@ export function LineChart({ data, options, height = 300 }: LineChartProps) { ...options, scales: { y: { + display: showGrid, grid: { + display: showGrid, color: colors.grid, }, ticks: { + display: showGrid, color: colors.text, }, }, x: { grid: { - color: colors.grid, + display: false, }, ticks: { color: colors.text, @@ -59,10 +67,7 @@ export function LineChart({ data, options, height = 300 }: LineChartProps) { ...defaultChartOptions.plugins, ...options?.plugins, legend: { - ...defaultChartOptions.plugins?.legend, - labels: { - color: colors.text, - }, + display: false, }, }, } diff --git a/components/dashboard/metric-card.tsx b/components/dashboard/metric-card.tsx index 63697c1..96235d4 100644 --- a/components/dashboard/metric-card.tsx +++ b/components/dashboard/metric-card.tsx @@ -1,17 +1,28 @@ import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card" -import { TrendingUp, TrendingDown } from "lucide-react" +import { TrendingUp, TrendingDown, Users, ShoppingCart, DollarSign, CreditCard, LucideIcon } from "lucide-react" import type { MetricCard as MetricCardType } from "@/types/dashboard" -export function MetricCard({ title, value, change, changeLabel }: MetricCardType) { +const iconMap: Record = { + Users, + ShoppingCart, + DollarSign, + CreditCard, +} + +export function MetricCard({ title, value, change, changeLabel, icon }: MetricCardType) { const isPositive = change >= 0 + const Icon = iconMap[icon] return ( - - {title} + + + {Icon && } + {title} + -
{value}
+
{value}
{isPositive ? ( diff --git a/components/dashboard/revenue-chart.tsx b/components/dashboard/revenue-chart.tsx index eb0233b..cf4a314 100644 --- a/components/dashboard/revenue-chart.tsx +++ b/components/dashboard/revenue-chart.tsx @@ -1,6 +1,6 @@ "use client" -import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card" +import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card" import { LineChart } from "@/components/charts/line-chart" import type { ChartDataPoint } from "@/types/dashboard" @@ -15,21 +15,26 @@ export function RevenueChart({ data }: RevenueChartProps) { { label: "Revenue", data: data.map((d) => d.value), + borderColor: "rgb(244, 114, 182)", + backgroundColor: "rgba(244, 114, 182, 0.2)", }, { label: "Subscriptions", data: data.map((d) => d.secondaryValue || 0), + borderColor: "rgb(94, 234, 212)", + backgroundColor: "rgba(94, 234, 212, 0.2)", }, ], } return ( - - + + Revenue Overview + Showing total revenue for the last 6 months - - + + ) diff --git a/components/dashboard/sales-chart.tsx b/components/dashboard/sales-chart.tsx index d7e5542..c4de32e 100644 --- a/components/dashboard/sales-chart.tsx +++ b/components/dashboard/sales-chart.tsx @@ -1,6 +1,6 @@ "use client" -import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card" +import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card" import { BarChart } from "@/components/charts/bar-chart" import type { ChartDataPoint } from "@/types/dashboard" @@ -9,23 +9,38 @@ interface SalesChartProps { } export function SalesChart({ data }: SalesChartProps) { + // Calculate total and change percentage + const total = data.reduce((sum, d) => sum + d.value, 0) + const lastMonthValue = data[data.length - 2]?.value || 0 + const currentMonthValue = data[data.length - 1]?.value || 0 + const changePercent = lastMonthValue > 0 + ? (((currentMonthValue - lastMonthValue) / lastMonthValue) * 100).toFixed(1) + : "0.0" + + // Alternate colors for bars + const backgroundColors = data.map((_, index) => + index % 2 === 0 ? "rgb(251, 113, 133)" : "rgb(94, 234, 212)" + ) + const chartData = { labels: data.map((d) => d.label), datasets: [ { label: "Sales", data: data.map((d) => d.value), + backgroundColor: backgroundColors, }, ], } return ( - - - Sales Activity + + + Subscriptions + +{changePercent}% from last month - - + + ) diff --git a/lib/mock-data.ts b/lib/mock-data.ts index 92de745..fdb124c 100644 --- a/lib/mock-data.ts +++ b/lib/mock-data.ts @@ -9,6 +9,7 @@ export function getDashboardData(): DashboardData { value: "4,682", change: 15.54, changeLabel: "from last month", + icon: "Users", }, { id: "2", @@ -16,6 +17,7 @@ export function getDashboardData(): DashboardData { value: "1,226", change: 40.2, changeLabel: "from last month", + icon: "ShoppingCart", }, { id: "3", @@ -23,6 +25,7 @@ export function getDashboardData(): DashboardData { value: "$1,080", change: 10.8, changeLabel: "from last month", + icon: "DollarSign", }, { id: "4", @@ -30,6 +33,7 @@ export function getDashboardData(): DashboardData { value: "$15,231.89", change: 20.1, changeLabel: "from last month", + icon: "CreditCard", }, ], revenueData: [ diff --git a/types/dashboard.ts b/types/dashboard.ts index ada8bf1..da626f2 100644 --- a/types/dashboard.ts +++ b/types/dashboard.ts @@ -4,6 +4,7 @@ export interface MetricCard { value: string | number change: number changeLabel: string + icon: string } export interface Payment {