25 lines
574 B
TypeScript
25 lines
574 B
TypeScript
![]() |
import { useAppBridge } from "@saleor/app-sdk/app-bridge";
|
||
|
import { useTheme } from "@saleor/macaw-ui/next";
|
||
|
import { useEffect } from "react";
|
||
|
|
||
|
export function ThemeSynchronizer() {
|
||
|
const { appBridgeState } = useAppBridge();
|
||
|
const { setTheme } = useTheme();
|
||
|
|
||
|
useEffect(() => {
|
||
|
if (!setTheme || !appBridgeState?.theme) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if (appBridgeState.theme === "light") {
|
||
|
setTheme("defaultLight");
|
||
|
}
|
||
|
|
||
|
if (appBridgeState.theme === "dark") {
|
||
|
setTheme("defaultDark");
|
||
|
}
|
||
|
}, [appBridgeState?.theme, setTheme]);
|
||
|
|
||
|
return null;
|
||
|
}
|