Skip to content

Commit 7accad9

Browse files
Add postMessage listener for SGIWorld theme sync
Listen for 'sgiworld-theme' messages from parent window and update the app theme accordingly. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 01ecd21 commit 7accad9

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

src/App.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,18 @@ export default function App() {
4747
window.localStorage.setItem(THEME_STORAGE_KEY, theme);
4848
}, [theme]);
4949

50+
// Listen for theme changes from parent SGIWorld
51+
useEffect(() => {
52+
const handleMessage = (event: MessageEvent) => {
53+
if (event.data && event.data.type === 'sgiworld-theme') {
54+
const newTheme = event.data.theme as ThemeMode;
55+
setTheme(newTheme);
56+
}
57+
};
58+
window.addEventListener('message', handleMessage);
59+
return () => window.removeEventListener('message', handleMessage);
60+
}, []);
61+
5062
return (
5163
<HashRouter>
5264
<AuthProvider>

0 commit comments

Comments
 (0)