From c3154e97d66fe52c0b5a8ce709ca9a4e6fcaf205 Mon Sep 17 00:00:00 2001 From: Michael Chus Date: Wed, 4 Nov 2026 10:37:30 +0300 Subject: [PATCH] docs(web-visual-baseline): icon-only buttons, one icon per action, centring and fill reset Co-Authored-By: Claude Sonnet 5.5 --- rules/patterns/web-visual-baseline/README.md | 12 ++++++++++ .../patterns/web-visual-baseline/contract.md | 22 ++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/rules/patterns/web-visual-baseline/README.md b/rules/patterns/web-visual-baseline/README.md index df1bfd1..16bb0de 100644 --- a/rules/patterns/web-visual-baseline/README.md +++ b/rules/patterns/web-visual-baseline/README.md @@ -27,3 +27,15 @@ Render the symbol through the shared icon template, for example: The icon template emits an SVG with a local `use href="#i-scroll"` reference. The sprite, template and CSS ship inside the binary. The browser never fetches Lucide or another asset host. Adding an icon does not add a runtime dependency. + +### Icon-only buttons in table rows + +```css +/* a layout rule that changes display must keep the icon centred */ +.row-actions > .icon-btn { display: inline-flex; justify-content: center; align-items: center; } +/* every container that renders an icon resets fill, otherwise it is solid black */ +.header-primary .icon { fill: none; stroke: currentColor; stroke-width: 2; } +/* fixed action slots keep icons in the same column on every row */ +.task-actions { display: grid; grid-template-columns: repeat(3, 32px); gap: 4px; justify-content: end; } +.icon-slot { display: block; width: 32px; height: 32px; } +``` diff --git a/rules/patterns/web-visual-baseline/contract.md b/rules/patterns/web-visual-baseline/contract.md index 64d980e..9d0e1ee 100644 --- a/rules/patterns/web-visual-baseline/contract.md +++ b/rules/patterns/web-visual-baseline/contract.md @@ -1,6 +1,6 @@ # Contract: Web Visual Baseline -Version: 1.2 +Version: 1.3 ## Scope @@ -74,6 +74,26 @@ Copy `assets/view.css` as the starting stylesheet and adapt tokens; do not rewri round line caps and joins. Size and color come from shared icon/button CSS. - An icon-only action needs both `title` and `aria-label`. Decorative SVGs have `aria-hidden="true"` and must not receive keyboard focus. +- A button that has an icon shows only the icon. The action name lives in + `title` and `aria-label`; do not put a text label next to the icon. Items of + a popup menu (`role="menuitem"`) keep their text, because the menu has no + other way to tell them apart. +- One icon means one action across the whole interface. Restore, refresh, + restart, connection test and similar actions each get their own distinct icon; + never reuse one icon for a different action. Keep the action-to-icon table in + the project documentation. +- The stroke-only rule applies in every container, not only in `.icon-btn`: any + other place that renders an icon (header button, status cell, badge) must set + `fill: none` and `stroke: currentColor` as well. An SVG without them renders as + a filled black blob. +- Centre the icon in its button on both axes. Where a layout rule changes a + button's `display` (for example to `inline-flex` inside a table cell), it must + also set `justify-content: center` and `align-items: center`; otherwise the + icon sticks to the left edge. An action column holds a fixed number of equal + slots (an empty slot where an action does not apply), so icons do not shift + from row to row. +- An icon that depends on data (a status, a kind) is chosen on the server by one + mapping function; the page and live refresh only print its name. - Embed all UI assets in the application binary: templates, scripts, styles, icons, fonts and any third-party UI code. Go applications use `go:embed` and serve these assets themselves. System fonts are allowed without downloads.