chore: initial commit of HouseholdBudgetBook (backend, frontend, desktop)

This commit is contained in:
mapleferry committed 2026-11-29 21:29:06 +08:00
commit 4a5db3f1f9
167 files changed
+21732

No files matched your search

+41
View File
@@ -0,0 +1,41 @@
import { Card } from '@/components/ui/card'
import { formatCents } from '@/lib/utils'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faChartLine, faArrowTrendUp, faArrowTrendDown } from '@fortawesome/free-solid-svg-icons'
import type { DashboardSummary } from '@/lib/api'
interface Props {
summary: DashboardSummary | null
loading: boolean
}
export function SummaryCards({ summary, loading }: Props) {
const cards = [
{ label: '本月结余', amount: summary?.balance ?? 0, color: 'text-foreground', icon: faChartLine, tone: 'bg-primary/12 text-primary' },
{ label: '本月收入', amount: summary?.income ?? 0, color: 'text-income', icon: faArrowTrendUp, tone: 'bg-income/12 text-income' },
{ label: '本月支出', amount: summary?.expense ?? 0, color: 'text-expense', icon: faArrowTrendDown, tone: 'bg-expense/12 text-expense' },
]
return (
<div className="summary-grid">
{cards.map(card => (
<Card key={card.label} className="relative overflow-hidden p-5">
<div className="summary-card-glow" />
<div className="mb-4 flex items-center justify-between">
<p className="text-xs text-muted">{card.label}</p>
<span className={`metric-icon ${card.tone}`}>
<FontAwesomeIcon icon={card.icon} className="h-4 w-4" />
</span>
</div>
{loading ? (
<div className="h-8 w-28 rounded bg-white/10 animate-pulse" />
) : (
<p className={`text-2xl font-semibold tabular-nums ${card.color}`}>
{formatCents(card.amount)}
</p>
)}
</Card>
))}
</div>
)
}