- 重写 styles.css:CSS 变量化可用率色阶、状态色类、工具类、安全选择器 - 组件改造:StatusDot/StatusBar/TargetDetailDrawer/GroupHeader 等改用 CSS 类和 Typography - color-threshold 移除 getLatencyColor 死代码,保留 getAvailabilityProgressColor 返回 CSS 变量 - target-table-columns 状态列和延迟列切换为 CSS 类 - 新增 css-utility-classes spec,更新 4 个 main specs(probe/card/table/drawer) - README 和 config.yaml 写入前端样式开发规范
38 lines
1.1 KiB
TypeScript
38 lines
1.1 KiB
TypeScript
import type { TargetStatus } from "../../shared/api";
|
|
import { GroupHeader } from "./GroupHeader";
|
|
import { PrimaryTable } from "tdesign-react";
|
|
import { TARGET_TABLE_COLUMNS } from "../constants/target-table-columns";
|
|
|
|
interface TargetGroupProps {
|
|
name: string;
|
|
targets: TargetStatus[];
|
|
onTargetClick: (target: TargetStatus) => void;
|
|
}
|
|
|
|
export function TargetGroup({ name, targets, onTargetClick }: TargetGroupProps) {
|
|
const up = targets.filter((t) => t.latestCheck?.matched).length;
|
|
const down = targets.length - up;
|
|
|
|
return (
|
|
<div>
|
|
<GroupHeader name={name} total={targets.length} up={up} down={down} />
|
|
<PrimaryTable
|
|
columns={TARGET_TABLE_COLUMNS}
|
|
data={targets}
|
|
rowKey="id"
|
|
size="small"
|
|
stripe
|
|
hover
|
|
bordered
|
|
defaultSort={[{ sortBy: "latestCheck.matched", descending: true }]}
|
|
onRowClick={({ row }) => onTargetClick(row as TargetStatus)}
|
|
rowClassName={({ row }) => {
|
|
const target = row as TargetStatus;
|
|
return target.latestCheck?.matched === false ? "row-down" : "";
|
|
}}
|
|
className="clickable-table"
|
|
/>
|
|
</div>
|
|
);
|
|
}
|