feat: 添加信息和指标组件以增强充电订单和计量信息的展示

This commit is contained in:
2026-03-13 12:11:33 +08:00
parent 83e6ed2412
commit a6621f975c
5 changed files with 266 additions and 138 deletions

View File

@@ -0,0 +1,15 @@
import type { ReactNode } from "react";
type InfoSectionProps = {
title: string;
children: ReactNode;
};
export default function InfoSection({ title, children }: InfoSectionProps) {
return (
<div className="rounded-xl border border-border bg-surface p-4">
<h2 className="mb-3 text-sm font-semibold text-foreground">{title}</h2>
{children}
</div>
);
}

View File

@@ -0,0 +1,41 @@
import type { ReactNode } from "react";
import { Card } from "@heroui/react";
type MetricIndicatorProps = {
title: string;
value: ReactNode;
hint?: ReactNode;
footer?: ReactNode;
icon?: ReactNode;
color?: string;
valueClassName?: string;
};
export default function MetricIndicator({
title,
value,
hint,
footer,
icon,
color = "border-border",
valueClassName = "text-xl font-semibold text-foreground tabular-nums",
}: MetricIndicatorProps) {
return (
<Card className={`border-t-2 ${color}`}>
<Card.Content className="flex flex-col gap-3">
<div className="flex items-start justify-between gap-2">
<p className="text-xs text-muted">{title}</p>
{icon}
</div>
<p className={valueClassName}>{value}</p>
{footer ? (
<div className="flex flex-wrap items-center gap-x-1.5 gap-y-1 text-xs text-muted">
{footer}
</div>
) : (
hint && <div className="text-xs text-muted">{hint}</div>
)}
</Card.Content>
</Card>
);
}