From 63c8f0ba6fae84ad6a287c993f6ef78e806b7329 Mon Sep 17 00:00:00 2001 From: seonghobae <8172694+seonghobae@users.noreply.github.com> Date: Sat, 18 Jul 2026 02:18:12 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Palette:=20Improve=20table=20acc?= =?UTF-8?q?essibility=20and=20alignment?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 💡 What: - Updated HTML table generation in `report.py` to use `` for the first column. - Applied `font-variant-numeric: tabular-nums` to table cells containing numbers. - Targeted `thead th` and `tbody th` appropriately for styling. 🎯 Why: - Using `` provides critical context for screen reader users when navigating data tables. - `tabular-nums` ensures numerical data aligns cleanly, making large tables significantly easier to scan visually. ♿ Accessibility: - Better screen reader support via semantic row headers. --- .jules/palette.md | 3 +++ python/fast_mlsirm/report.py | 25 +++++++++++++++++++------ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/.jules/palette.md b/.jules/palette.md index 74cddb7ad..935f31112 100644 --- a/.jules/palette.md +++ b/.jules/palette.md @@ -19,3 +19,6 @@ ## 2024-07-13 - CLI Debugging Stack Traces **Learning:** Adding a `FAST_MLSIRM_DEBUG` bypass to user-friendly `try/except` blocks is crucial for DX. Otherwise, unexpected runtime errors during development will be swallowed into generic stderr messages, hiding the stack trace needed to actually fix the bug. **Action:** When adding `try-except` blocks to Python CLI subcommands to improve Developer Experience (DX) by preventing raw tracebacks for users, include a debug bypass (e.g., `if os.environ.get("FAST_MLSIRM_DEBUG"): raise`) in *all* catch blocks (including `RuntimeError` and `Exception`) to ensure tracebacks aren't swallowed during local development and debugging. +## 2026-07-18 - Improve Table Accessibility and Alignment +**Learning:** When generating HTML data tables, using `` for the first identifying column improves screen reader accessibility. Additionally, applying `font-variant-numeric: tabular-nums;` to table cells ensures numbers align properly in columns. +**Action:** Use `` for row headers and `font-variant-numeric: tabular-nums` for numeric data cells in tabular data representations. diff --git a/python/fast_mlsirm/report.py b/python/fast_mlsirm/report.py index 30ee4276b..ab50e638d 100644 --- a/python/fast_mlsirm/report.py +++ b/python/fast_mlsirm/report.py @@ -317,10 +317,13 @@ def _table(rows: list[dict[str, Any]], *, label: str, limit: int = 12) -> str: columns = _columns(rows) body_rows = [] for row in rows[:limit]: - cells = "".join( - f"{escape(_format_value(row.get(column, '')))}" - for column in columns - ) + cells = "" + for i, column in enumerate(columns): + val = escape(_format_value(row.get(column, ""))) + if i == 0: + cells += f'{val}' + else: + cells += f"{val}" body_rows.append(f"{cells}") note = "" @@ -687,13 +690,23 @@ def _css() -> str: white-space: nowrap; } -th { +td, +tbody th { + font-variant-numeric: tabular-nums; +} + +thead th { background: #f1f4ef; color: #2f3437; font-size: 0.8rem; } -tr:last-child td { +tbody th { + font-weight: normal; +} + +tr:last-child td, +tr:last-child th { border-bottom: 0; }