Skip to content

Conversation

@drichar
Copy link
Contributor

@drichar drichar commented Jan 20, 2026

Summary

Refactors the CSS scoping architecture to use two separate data attributes, fixing utility class leakage and enabling easier CSS variable overrides.

Problem: The previous architecture used [data-wallet-ui] on the provider wrapper for both CSS variable definitions and utility class scoping. This caused:

  1. Utility classes (.hidden, etc.) to leak to consumer app elements inside the provider
  2. CSS variables couldn't be overridden via ancestor selectors due to specificity

Solution: Split concerns between two attributes:

  • [data-wallet-theme] — Provider-level wrapper for CSS variable definitions (inherits to descendants)
  • [data-wallet-ui] — Component-level attribute for utility class scoping (on buttons and portal wrappers)

Key Changes

Provider and Components

  • WalletUIProvider wrapper uses data-wallet-theme for CSS variables
  • Button components (ConnectWalletButton, ConnectedWalletButton) add data-wallet-ui directly
  • Portal wrappers (ConnectWalletMenu, ConnectedWalletMenu) use both attributes

CSS Structure

  • Variable definitions now use [data-wallet-theme] selectors
  • Button resets use same-element selector [data-wallet-ui][data-wallet-button]
  • Portal content uses descendant selector [data-wallet-ui] [role="dialog"]

Post-process Script

  • Generates dual selector patterns for utility classes:
    • [data-wallet-ui].class — elements with attribute directly (buttons)
    • [data-wallet-ui] .class — descendants (portal content)

Documentation

  • Updated README customization examples to use [data-wallet-theme]
  • Updated migration guide with new selector guidance

Test Plan

  • Unit tests pass (pnpm test)
  • Lint passes (pnpm lint)
  • Build succeeds (pnpm build)
  • E2E tests pass in Docker (pnpm e2e:docker)
  • Manual testing of example apps

Split CSS concerns between two data attributes to fix utility class
leakage and enable easier CSS variable overrides.

## Architecture

- `[data-wallet-theme]`: Provider-level wrapper for CSS variable
  definitions. Variables inherit to all descendants.
- `[data-wallet-ui]`: Component-level attribute for utility class
  scoping. Applied to buttons and portal wrappers.

## Key Changes

**Provider and Components**
- WalletUIProvider wrapper uses `data-wallet-theme` for variables
- Button components add `data-wallet-ui` directly on the element
- Portal wrappers use both attributes for full functionality

**CSS Structure**
- Variable definitions now use `[data-wallet-theme]` selectors
- Button resets use same-element selector `[data-wallet-ui][data-wallet-button]`
- Portal content uses descendant selector `[data-wallet-ui] [role="dialog"]`

**Post-process Script**
- Generate dual selector patterns for utility classes:
  - `[data-wallet-ui].class` for elements with attribute directly
  - `[data-wallet-ui] .class` for descendants

## Benefits

- Utility classes no longer leak to consumer app elements
- CSS variables can be overridden via ancestor selectors
- Consumers target `[data-wallet-theme]` for variable overrides
@drichar drichar merged commit c181aa7 into beta Jan 20, 2026
2 checks passed
@drichar drichar deleted the refactor/separate-theme-attribute branch January 20, 2026 21:11
@txnlab-release-bot
Copy link
Contributor

🎉 This PR is included in version 1.0.0-beta.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

@txnlab-release-bot
Copy link
Contributor

🎉 This PR is included in version 1.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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.

1 participant