import React from 'react' import { cn } from '../../../utils/cn' /** 平台明细表的一行 */ export interface PlatformTableRow { /** 平台标识,用作 React key */ key: string /** 平台 logo */ logo: string /** 平台名 */ name: string /** 条形填充色 */ color: string /** 条长百分比(相对最大值,0~100) */ barPercent: number /** 数值列,顺序与 `columns` 对应,已格式化为展示文案 */ cells: string[] } /** 平台明细表属性 */ export interface PlatformTableProps { /** 数值列的表头文案 */ columns: string[] /** 数据行 */ rows: PlatformTableRow[] /** 追加到根元素的类名 */ className?: string } /** 数值列宽:够放下 `1,362` 和 `47.6%` */ const CELL_WIDTH = 'w-28' /** * 平台明细表。 * * 环图旁边原来只是一列「logo + 名字 + 次数」,本质是图例; * 这里升级成带表头的表格,能多塞两列数值(人数、人均之类), * 同样的高度装的信息量翻倍 —— 这也是海报里唯一适合「读精确数字」的地方。 * 中间的占比条保留,让读者不读数字也能看出量级差距。 */ export const PlatformTable: React.FC = ({ columns, rows, className }) => (
{/* 表头 */}
平台 {/* 条形列不写表头:占比已经在后面的数值列里给了,重复标一次反而让人以为有两套口径 */} {columns.map((column) => ( {column} ))}
{/* 数据行 */} {rows.map((row) => (
{row.name} {row.name}
{row.cells.map((cell, index) => ( {cell} ))}
))}
) export default PlatformTable