Skip to content

feat(*): add theming widget handling - #1093

Open
ChronosSF wants to merge 1 commit into
vnextfrom
sstoychev/react-theming-widget
Open

feat(*): add theming widget handling#1093
ChronosSF wants to merge 1 commit into
vnextfrom
sstoychev/react-theming-widget

Conversation

@ChronosSF

Copy link
Copy Markdown
Member

No description provided.

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

Adds support for remotely re-theming the samples browser when it’s embedded in the docs site, by listening for a trusted postMessage and dynamically swapping Ignite UI theme stylesheets.

Changes:

  • Introduces sample-theme.ts to validate theme messages, resolve light/dark/system mode, and load the corresponding theme CSS via dynamic imports.
  • Initializes the theme message listener during app startup in browser/src/index.tsx so the host can re-post theme selection on iframe load.

Reviewed changes

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

File Description
browser/src/sample-theme.ts Adds message validation + dynamic CSS loading to apply Ignite UI theme/mode inside an embedded iframe.
browser/src/index.tsx Initializes the new theme listener during app entry module evaluation.
Suppressed comments (1)

browser/src/sample-theme.ts:93

  • parseMessage returns null in several branches but its return type doesn’t allow null, and it calls .toLowerCase() on potentially non-string values from postMessage (which can throw and break the message handler). Adjust the signature to return | null and defensively coerce/validate the incoming fields before lowercasing.
function parseMessage(data: any): { theme: ThemeName; mode: ThemeMode } {
    if (!data || typeof data !== 'object') { return null; }
    const msg = data as ThemeMessage;
    if (msg.type !== MESSAGE_TYPE && msg.event !== MESSAGE_TYPE) { return null; }


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +72 to +74
const styleEls: HTMLStyleElement[] = [];
let selected: { theme: ThemeName; mode: ThemeMode } = null;
let latestRequest = 0;
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.

2 participants