Skip to content

Allow supplying a custom stylesheet for the dApp SDK's wallet picker popup - #2323

Open
ayushsingh82 wants to merge 1 commit into
canton-network:mainfrom
ayushsingh82:ayush/dapp-sdk-custom-stylesheet-1151
Open

Allow supplying a custom stylesheet for the dApp SDK's wallet picker popup#2323
ayushsingh82 wants to merge 1 commit into
canton-network:mainfrom
ayushsingh82:ayush/dapp-sdk-custom-stylesheet-1151

Conversation

@ayushsingh82

Copy link
Copy Markdown
Contributor

Summary

The wallet picker popup (opened via `pickWallet`, the default `walletPicker` for `DappSDK`) renders as a Lit custom element inside an isolated popup window, themed entirely through `--wg-theme-*` CSS custom properties (`themes/default.css`). Since it's a separate browsing context, a dApp implementer had no way to affect that theming -- setting those properties on their own page has no effect on a completely separate window/document.

Added an optional `stylesheet` to `PopupOptions` (`core/wallet-ui-components/src/windows/popup.ts`), injected as CSS text into the popup document's own ``, outside the component's shadow root. Custom properties inherit through the shadow boundary by spec, so a `:root { --wg-theme-primary-color: ... }` rule there re-themes the component without needing to know its internal selectors.

Threaded through the existing call chain:

  • `popup.open(component, { stylesheet })`
  • `pickWallet(entries, { stylesheet })` (new `PickWalletOptions`)
  • `new DappSDK({ walletPickerStylesheet })` (ignored if a custom `walletPicker` is supplied, since that bypasses the default popup entirely)

Related to #609. Fixes #1151

Test plan

  • `tsc --noEmit` in `core/wallet-ui-components` and `sdk/dapp-sdk`: same pre-existing error count before/after (32 and 62 respectively -- both from unbuilt workspace deps, unrelated to this change), confirmed via before/after `git stash` comparison
  • `eslint` / `prettier --check` clean on all 5 changed files
  • Existing `popup.test.ts` / `wallet-picker.test.ts` suites (10 tests) pass unchanged
  • Added 2 new tests to `popup.test.ts`: one fetches the generated popup blob and confirms the custom stylesheet text actually lands in the document, the other confirms a literal `</style` in caller-supplied CSS can't break out of the `<style>` tag it's injected into
  • Added a `PopupWithCustomStylesheet` story to `wallet-picker.stories.ts` demonstrating a dark custom theme

…popup

The wallet picker popup (opened via pickWallet, the default walletPicker
for DappSDK) renders as a Lit custom element in an isolated popup window,
themed entirely through --wg-theme-* CSS custom properties (see
themes/default.css). Since it's a separate browsing context, a dApp
implementer had no way to affect that theming -- setting those properties
on their own page has no effect on a totally separate window/document.

Add an optional `stylesheet` to PopupOptions, injected as CSS text into
the popup document's own <head> (outside the component's shadow root).
Custom properties inherit through the shadow boundary by spec, so a
`:root { --wg-theme-primary-color: ... }` rule there re-themes the
component without needing to know its internal selectors.

Threaded through: popup.open's stylesheet option -> pickWallet's new
PickWalletOptions -> DappSDK's new constructor option
`walletPickerStylesheet` (ignored if a custom walletPicker is supplied,
since that bypasses the default popup entirely).

Related to canton-network#609. Fixes canton-network#1151

Also added a Storybook story and two tests: one confirming the
stylesheet actually reaches the popup document, and one confirming a
literal `</style` in caller-supplied CSS can't break out of the <style>
tag it's injected into.

Signed-off-by: ayushsingh82 <[email protected]>
@ayushsingh82
ayushsingh82 requested a review from a team as a code owner August 19, 2026 04:22
@ayushsingh82

Copy link
Copy Markdown
Contributor Author

@mjuchli-da whenever you have a chance, would appreciate a look at this one.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow dApp SDK implementers to supply their own stylesheet

1 participant