runloopable / web /src /sheet /SheetStatusBar.tsx
fsanyoto's picture
Deploy AIOS web (React glide grid + FastAPI slice)
816fa8a verified
Raw History Blame Contribute Delete
1.79 kB
// ---------------------------------------------------------------------------------------------
// 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>
);
}