Skip to content

Migrate hand-rolled buttons to Web Awesome#51

Open
bramkragten wants to merge 6 commits into
home-assistant:mainfrom
bramkragten:webawesome-buttons
Open

Migrate hand-rolled buttons to Web Awesome#51
bramkragten wants to merge 6 commits into
home-assistant:mainfrom
bramkragten:webawesome-buttons

Conversation

@bramkragten

Copy link
Copy Markdown
Member

Migrates every hand-rolled <button> to <wa-button> from the @home-assistant/webawesome fork, fulfilling the existing repo convention (contributing.md: prefer <wa-*> components over custom implementations). First of several scoped Web Awesome PRs from the frontend review in #5 / #16.

What changed

  • All buttons → wa-button across the wizard shell, dialogs, welcome view, path/other-options views, device/architecture/drive selection views, and the UTM check view. Variants and states are mapped to WA props: brand/danger × accent/outlined/plain, plus disabled and loading (the drive-refresh button now uses the native loading prop instead of a hand-rolled disabled state).
  • ha-svg-icon — ported from the frontend for rendering inline MDI paths. Icons now live in wa-button's start/end slots (with automatic spacing) instead of custom markup; the arrow/refresh/back glyphs use it too.
  • fab-button — the floating "Open Home Toolbox" button is extracted into its own component built on wa-button + wa-tooltip.
  • Theme mapping — Web Awesome color tokens are mapped onto our --ha-* theme colors in styles.css, so buttons keep the Home Assistant palette (primary #03a9f4, danger #db4437, neutral text) in both light and dark mode.
  • Uses the @home-assistant/webawesome fork (same version as the frontend) and adds vite-env.d.ts for ambient *.css / Vite client types.

Net result removes ~450 lines of duplicated per-component button CSS.

Testing

  • tsc, eslint, and vite build all pass.
  • Manually drove the full wizard flow in the browser (welcome CTA, back/cancel/next, retry, drive refresh + loading state, and the danger "Erase and install" dialog) and verified colors, the FAB tooltip, and icon rendering in both light and dark mode.

Follow-ups (out of scope)

  • Clickable cards (option-card, device-card, drive-card, mini-PC setup-method) → wa-card
  • Link-styled CTAs in *-success-view and the / glyphs inside those cards
  • A fuller --wa-color-* token map (only button-consumed tokens are mapped here) once more WA components (inputs, dialogs, etc.) are adopted

🤖 Generated with Claude Code

Replace every custom <button> element and its per-component CSS with
<wa-button> from the @home-assistant/webawesome fork, fulfilling the
existing repo convention (contributing.md: prefer <wa-*> components).

- Map variants/states: brand/danger + accent/outlined/plain, disabled,
  and loading (drive refresh uses the native loading prop)
- Add ha-svg-icon (ported from the frontend) for inline MDI paths in
  button slots; icons live in start/end slots instead of custom markup
- Extract the toolbox FAB into a fab-button component using wa-tooltip
- Map Web Awesome color tokens onto our --ha-* theme colors in styles.css
  so buttons keep the Home Assistant palette in light and dark
- Add vite-env.d.ts for ambient *.css / vite client types

Removes ~450 lines of duplicated per-component button styles.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 13, 2026 09:33
@codecov-commenter

codecov-commenter commented Jul 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.28507% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.43%. Comparing base (016a565) to head (1c3d771).

Files with missing lines Patch % Lines
src/views/sbc/device-selection-view.ts 14.28% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #51      +/-   ##
==========================================
- Coverage   89.54%   89.43%   -0.11%     
==========================================
  Files          29       31       +2     
  Lines       10910    10838      -72     
  Branches       84       93       +9     
==========================================
- Hits         9769     9693      -76     
- Misses       1141     1145       +4     
Flag Coverage Δ
backend 92.01% <ø> (ø)
frontend 84.46% <97.28%> (-0.41%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR migrates the frontend wizard UI from hand-rolled <button> elements to Web Awesome’s <wa-button> (using the @home-assistant/webawesome fork), introduces a shared ha-svg-icon for MDI path icons, and adds a reusable floating action button component. It also maps Web Awesome color tokens onto the existing Home Assistant theme variables to preserve the HA palette.

Changes:

  • Replace native <button> usage across multiple views/components with <wa-button> (variants/appearances, disabled/loading).
  • Add ha-svg-icon (MDI-path icon renderer) and fab-button (wa-button + tooltip) and wire FAB into app-shell.
  • Switch dependency to @home-assistant/webawesome, load its default theme CSS, and add Vite client type reference.

Reviewed changes

Copilot reviewed 17 out of 19 changed files in this pull request and generated 14 comments.

Show a summary per file
File Description
src/vite-env.d.ts Adds Vite client ambient types reference.
src/views/welcome-view.ts Migrates CTA to <wa-button> and removes bespoke button CSS.
src/views/utm/utm-check-view.ts Migrates UTM actions to <wa-button> and switches icons to ha-svg-icon.
src/views/sbc/drive-selection-view.ts Migrates retry/refresh actions to <wa-button> and attempts to use loading.
src/views/sbc/device-selection-view.ts Migrates retry action to <wa-button>.
src/views/path-selection-view.ts Migrates Back action to <wa-button appearance="plain">.
src/views/other-options-view.ts Migrates Back action to <wa-button appearance="plain">.
src/views/minipc/architecture-selection-view.ts Migrates retry action to <wa-button>.
src/views/ha-hardware/device-selection-view.ts Migrates retry action to <wa-button>.
src/styles.css Adds HA→Web Awesome token mapping (brand/danger/neutral).
src/main.ts Imports Web Awesome default theme CSS.
src/components/wizard-shell.ts Migrates back/cancel/next to <wa-button>, removes bespoke button CSS.
src/components/info-dialog.ts Migrates dialog actions to <wa-button>, removes bespoke button CSS.
src/components/confirm-dialog.ts Migrates dialog actions to <wa-button> (danger confirm), removes bespoke button CSS.
src/components/ha-svg-icon.ts Adds reusable MDI-path icon component.
src/components/fab-button.ts Adds floating action button built on <wa-button> + <wa-tooltip>.
src/components/app-shell.ts Replaces toolbox floating button with <fab-button>.
package.json Replaces @awesome.me/webawesome with @home-assistant/webawesome.
package-lock.json Updates lockfile to match new Web Awesome fork + transitive deps.

Comment thread src/views/welcome-view.ts
Comment thread src/views/path-selection-view.ts
Comment thread src/components/wizard-shell.ts
Comment thread src/components/wizard-shell.ts
Comment thread src/components/wizard-shell.ts
Comment thread src/views/sbc/drive-selection-view.ts Outdated
Comment thread src/views/sbc/drive-selection-view.ts
Comment thread src/components/fab-button.ts Outdated
Comment thread src/components/ha-svg-icon.ts
Comment thread src/components/fab-button.ts
- Retarget unit-test selectors from removed CSS classes (.back-button,
  .dialog-button.*, .lets-go-button, .footer-button.primary) to wa-button
  via stable container/attribute selectors; fixes 29 failing tests
- Remove dead ?loading binding on the drive refresh buttons (they're never
  rendered while _loading is true — the view swaps to the spinner)
- fab-button: make label optional so ifDefined() actually omits aria-label
  for icon-only use (empty-string default would have kept aria-label="")
- Add unit tests for ha-svg-icon and fab-button
- web-test-runner: prefer the "browser" export condition so nanoid (pulled
  in transitively via wa-tooltip) resolves its browser build instead of the
  node:crypto one, which failed to import under the test runner

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 13, 2026 09:59

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 25 out of 27 changed files in this pull request and generated 8 comments.

Comment thread src/views/welcome-view.ts
Comment thread src/views/path-selection-view.ts
Comment thread src/views/other-options-view.ts
Comment thread src/components/wizard-shell.ts
Comment thread src/views/utm/utm-check-view.ts
Comment thread src/views/sbc/drive-selection-view.ts
Comment thread src/components/confirm-dialog.ts
Comment thread src/views/sbc/drive-selection-view.ts
- Migrate all Playwright E2E locators off the removed CSS classes
  (.lets-go-button, .back-button, .cancel-button, .footer-button.primary,
  .dialog-button.*, .download-button, .refresh-button) to wa-button selectors
- Replace toBeDisabled()/toBeEnabled() with toHaveJSProperty("disabled", …);
  Playwright can't read a custom element's disabled state
- Wait for the proxmox configure Next button to enable before clicking (its
  node/storage defaults load async; Playwright no longer auto-waits on
  wa-button), fixing the proxmox flow specs
- drive-selection: show the full-page spinner only on the initial scan; a
  refresh now keeps the list visible and drives the header button's native
  loading prop, matching the PR description
- welcome CTA: size="large" -> size="l" (long form deprecated in the fork)

Full chromium E2E suite passes serially (174/174); unit 178/178.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 13, 2026 10:53

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 31 out of 33 changed files in this pull request and generated 4 comments.

Comment thread test/e2e/utm-flow.spec.ts
Comment thread test/e2e/utm-flow.spec.ts
Comment thread test/e2e/utm-flow.spec.ts
Comment thread test/e2e/utm-flow.spec.ts Outdated
Playwright's isEnabled()/isDisabled() only recognize native/ARIA disabled
state, so on a wa-button host they always report enabled. The UTM flow used
them to branch (skip/throw) and in one tautological assertion, so the checks
were bypassed. Read wa-button's `disabled` JS property directly instead, via
a small buttonDisabled() helper.

UTM e2e spec passes (42/42 chromium).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 13, 2026 11:17

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 31 out of 33 changed files in this pull request and generated 1 comment.

Comment thread src/views/welcome-view.ts
Copilot AI review requested due to automatic review settings July 13, 2026 11:23

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 31 out of 33 changed files in this pull request and generated 1 comment.

Comment thread src/views/welcome-view.ts Outdated
Copilot AI review requested due to automatic review settings July 13, 2026 11:29

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 31 out of 33 changed files in this pull request and generated no new comments.

bramkragten and others added 2 commits July 13, 2026 15:58
A host aria-label isn't forwarded to wa-button's shadow-root <button>, so the
icon-only FAB had no accessible name. Put the label in the button as
visually-hidden text (keeping the tooltip) and assert the name in the test.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Web Awesome's dark tokens are gated on a `wa-dark` class, not
prefers-color-scheme, so unmapped tokens (neutral hover fill, tooltip colors)
stayed light in dark mode. Toggle `wa-dark` on <html> from matchMedia so every
Web Awesome component flips correctly, instead of mapping tokens one by one.
Our --ha-* overrides still pin brand/danger/surface to Home Assistant colors.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 13, 2026 13:59

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 31 out of 33 changed files in this pull request and generated no new comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants