diff --git a/.jules/palette.md b/.jules/palette.md new file mode 100644 index 0000000..d7c3c92 --- /dev/null +++ b/.jules/palette.md @@ -0,0 +1,4 @@ +## 2024-07-07 - Add definition lists to Fit Report metric cards + +**Learning:** Key-value pairs for metrics and statistics in HTML reports must use semantic `
`, `
`, and `
` elements to properly associate the label with its value for screen readers. Using generic `
` or `
` with `` and `` separates the semantic relationship. Additionally, default `
` styling varies across browsers, so explicit `font-weight` resets are necessary to maintain cross-browser visual consistency while improving semantics. Also, relying purely on mouse interactions for focused tables (`:focus`) impacts mouse users visually - `:focus-visible` ensures focus outlines appear only during keyboard navigation. Purely visual charting elements (like horizontal bar tracks) inside HTML need `aria-hidden="true"` to prevent redundant, noisy announcements for screen reader users. +**Action:** Always prefer definition lists (`
`) over generic markup for metric pairs, and explicitly reset their font-weight in CSS. Use `:focus-visible` instead of `:focus` for generic focus styles, and add `aria-hidden="true"` to decorative/visual chart tracks. diff --git a/python/fast_mlsirm/report.py b/python/fast_mlsirm/report.py index 9d70dcb..12a4f20 100644 --- a/python/fast_mlsirm/report.py +++ b/python/fast_mlsirm/report.py @@ -69,7 +69,7 @@ def _render_html(payload: dict[str, Any], report_type: str, title: str, source_n "
", '
', '
', - f"

fast-mlsirm diagnostics

", + "

fast-mlsirm diagnostics

", f"

{escape(title)}

", f"Source: {escape(source_name)}", "
", @@ -165,10 +165,10 @@ def _metric_section(heading: str, metrics: dict[str, Any]) -> str | None: cards.append( "\n".join( [ - '
', - f"{escape(_label(key))}", - f"{escape(_format_value(value))}", - "
", + '
', + f"
{escape(_label(key))}
", + f"
{escape(_format_value(value))}
", + "
", ] ) ) @@ -179,9 +179,9 @@ def _metric_section(heading: str, metrics: dict[str, Any]) -> str | None: [ '
', f"

{escape(heading)}

", - '
', + '
', *cards, - "
", + "
", "", ] ) @@ -265,7 +265,7 @@ def _bar_chart(rows: list[dict[str, Any]], value_key: str | None) -> str: [ '
', f'{escape(_row_label(row, index))}', - '
', + '", f'{escape(_format_value(value))}', @@ -279,7 +279,7 @@ def _bar_chart(rows: list[dict[str, Any]], value_key: str | None) -> str: return "\n".join( [ - '