Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
File size: 1,788 Bytes
816fa8a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | // ---------------------------------------------------------------------------------------------
// sheet/SheetStatusBar.tsx — S72-T65 (instruction 27, ruling R108 g).
//
// The strip under the grid that shows Average, Count and Sum for two or more selected cells, at
// its right end, in Excel's order. The strip keeps its height when it is empty, so selecting
// cells never resizes the canvas above it. It matches `customer-grid/summary/SummaryBar.tsx`'s
// look (height, type size, muted label, tabular value) and does not import it.
// ---------------------------------------------------------------------------------------------
import { formatStat } from "./sheetSelectionStats";
import type { SelectionStats } from "./sheetSelectionStats";
import "../styles/sdlc72/sheet-status.css";
interface SheetStatusBarProps {
/** Null when fewer than two cells are selected. */
stats: SelectionStats | null;
}
export default function SheetStatusBar({ stats }: SheetStatusBarProps) {
const items: { label: string; value: string }[] = [];
if (stats && stats.count > 0) {
if (stats.average !== null) items.push({ label: "Average", value: formatStat(stats.average, stats.formatCell) });
items.push({ label: "Count", value: formatStat(stats.count, null) });
if (stats.average !== null) items.push({ label: "Sum", value: formatStat(stats.sum, stats.formatCell) });
}
return (
<div className="sheet-status" role="status" aria-label="Selection summary" aria-atomic="true">
{items.map((item) => (
<span key={item.label} className="sheet-status-item" data-stat={item.label}>
<span className="sheet-status-label">{item.label}</span>
<span className="sheet-status-value">{item.value}</span>
</span>
))}
</div>
);
}
|