Skip to content

feat(widget): add AppearanceChanged event for theme persistence#778

Open
effie-ms wants to merge 3 commits into
mainfrom
fix/playground-theme-persistence
Open

feat(widget): add AppearanceChanged event for theme persistence#778
effie-ms wants to merge 3 commits into
mainfrom
fix/playground-theme-persistence

Conversation

@effie-ms

@effie-ms effie-ms commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Which Linear task is linked to this PR?

N/A — discovered during playground testing.

Why was it implemented this way?

NB: to be discussed

When users toggle light/dark/system in the widget's settings page, only MUI's internal setMode() was called. The playground (host app) had no way to know the theme changed, so its persisted config kept the old appearance value and overwrote the user's choice on reload.

This PR adds a new WidgetEvent.AppearanceChanged event emitted from ThemeSettings after setMode(). The playground subscribes in WidgetView and syncs its config store via setAppearance(), which persists through Zustand's persist middleware.

Alternative considered: reading MUI's li.fi-widget-mode localStorage key during playground store rehydration. Rejected because the rehydration timing made it unreliable and it coupled the playground to the widget's internal MUI storage key.

The event approach is cleaner — it works for any host app, not just the playground, and follows the existing widget event pattern.

Visual showcase (Screenshots or Videos)

N/A — behavior change: theme toggle in widget settings now persists across page reloads.

Checklist before requesting a review

  • I have performed a self-review and testing of my code.
  • This pull request is focused and addresses a single problem.
  • If this PR modifies the Widget API or adds new features that require documentation, I have updated the documentation in the public-docs repository.

@changeset-bot

changeset-bot Bot commented Jun 11, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: ce0c3ab

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 6 packages
Name Type
@lifi/widget Minor
@lifi/widget-light Minor
nft-checkout Patch
tanstack-router-example Patch
vite-iframe-wagmi Patch
vite-iframe Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@effie-ms effie-ms self-assigned this Jun 11, 2026
Base automatically changed from fix/playground-theme-switch-height-reset to main June 15, 2026 09:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant