diff --git a/app/src/pages/Dashboard.tsx b/app/src/pages/Dashboard.tsx index 8fb4f53..c6f2204 100644 --- a/app/src/pages/Dashboard.tsx +++ b/app/src/pages/Dashboard.tsx @@ -1,6 +1,6 @@ import { useEffect, useState, type ReactNode } from 'react'; import { Link } from 'react-router-dom'; -import { CalendarPlus, Dumbbell, Flame, Megaphone, Minus, Play, TrendingDown, TrendingUp } from 'lucide-react'; +import { CalendarPlus, Dumbbell, Flame, Megaphone, Play } from 'lucide-react'; import type { LucideIcon } from 'lucide-react'; import { useActiveSession, useDashboard, useFeed } from '../api/queries'; import { FeedItemRow } from '../components/FeedItemRow'; @@ -40,18 +40,31 @@ function planWeekNo(startDate: string | null): number | null { } /* Dekoracyjna sparkline (aria-hidden) — kształt deterministyczny od wartości. */ -function Sparkline({ value }: { value: number }) { - const n = Math.max(2, Math.min(12, value)); +/* Kreska trendu pod statystyką: rośnie (up), opada (down) lub płasko (flat). */ +function Sparkline({ + value, + direction = 'up', + color = 'accent', +}: { + value: number; + direction?: 'up' | 'down' | 'flat'; + color?: 'accent' | 'danger'; +}) { + const n = Math.max(2, Math.min(12, Math.abs(value) || 2)); const w = 86; const h = 22; const pts: string[] = []; for (let i = 0; i < n; i++) { - const x = 1 + (i * (w - 6)) / Math.max(1, n - 1); + const t = i / Math.max(1, n - 1); + const x = 1 + t * (w - 6); const drop = Math.sin(i * 1.7 + value) * 3; - const y = h - 4 - (i / Math.max(1, n - 1)) * (h - 9) + drop; + const base = + direction === 'down' ? 4 + t * (h - 9) : direction === 'flat' ? (h - 2) / 2 + drop * 0.3 : h - 4 - t * (h - 9); + const y = direction === 'flat' ? base : base + drop; pts.push(`${x.toFixed(1)},${Math.max(2, Math.min(h - 2, y)).toFixed(1)}`); } const last = pts[pts.length - 1].split(','); + const stroke = color === 'danger' ? 'var(--danger)' : 'var(--accent)'; return ( ); } @@ -116,7 +129,7 @@ function StatCard({ }: { label: string; value: ReactNode; - tone?: 'default' | 'danger' | 'positive'; + tone?: 'default' | 'danger'; children?: ReactNode; }) { return ( @@ -124,7 +137,7 @@ function StatCard({