Skip to content

fix(perf): AssetBadge ASSET_COLORS lookup in render causes new object per render, Badge variants object recreated, Button sizes object recreated #211

Description

@k-deejah

Problem

Three issues in the Button component affect the loading indicator, icon-only usage, and the destructive variant context.

1. Button loading spinner replaces the button label text — users lose context

When loading={true}, the spinner renders and children still render beside it. But if the button label is short (e.g. "Send"), the spinner + "Send" layout shifts the text. A pattern where the spinner overlays the icon position and the label remains visible (like GitHub's buttons) would be less disorienting.

2. No icon-only Button variant or size modifier

Button has no iconOnly prop that removes horizontal padding and makes the button square. Icon-only buttons (like the FeeEstimator refresh button) use raw <button> elements with custom classes instead of the Button primitive, leading to inconsistent focus styles and hover states.

3. destructive variant has no confirm UX pattern built in

The destructive variant is used for dangerous actions (delete, reset). There is no built-in optional two-step confirmation (like the disconnect button proposal in issue #18). An onClickConfirm pattern where the button switches to "Are you sure?" on first click would standardise dangerous action patterns.

Solution

  1. Change the loading state to render the spinner in place of a leading icon slot, keeping the label visible.
  2. Add iconOnly?: boolean prop that applies aspect-square and removes horizontal padding.
  3. Add requireConfirm?: boolean and confirmLabel?: string props to Button that trigger the two-click pattern.

Acceptance Criteria

  • Loading state keeps the button label visible with spinner in icon position
  • iconOnly prop makes button square with no horizontal padding
  • requireConfirm triggers two-click confirmation pattern
  • All existing Button usages work correctly after changes
  • npm run build and tsc --noEmit pass

Note for Contributors: Write a clear PR description. Include before/after screenshots of the loading state and the icon-only button variant.

Metadata

Metadata

Labels

Stellar WaveIssues in the Stellar wave programenhancementNew feature or request

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions