mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2026-01-22 19:23:22 +00:00
29 lines
838 B
TypeScript
29 lines
838 B
TypeScript
import { FluentProvider, webDarkTheme, webLightTheme } from "@fluentui/react-components";
|
|
import React from "react";
|
|
import { ErrorBoundary } from "../Explorer/ErrorBoundary";
|
|
import { useThemeStore } from "../hooks/useTheme";
|
|
import App from "./App";
|
|
|
|
const Root: React.FC = () => {
|
|
// Use React state to track isDarkMode and subscribe to changes
|
|
const [isDarkMode, setIsDarkMode] = React.useState(useThemeStore.getState().isDarkMode);
|
|
const currentTheme = isDarkMode ? webDarkTheme : webLightTheme;
|
|
|
|
// Subscribe to theme changes
|
|
React.useEffect(() => {
|
|
return useThemeStore.subscribe((state) => {
|
|
setIsDarkMode(state.isDarkMode);
|
|
});
|
|
}, []);
|
|
|
|
return (
|
|
<ErrorBoundary>
|
|
<FluentProvider theme={currentTheme}>
|
|
<App />
|
|
</FluentProvider>
|
|
</ErrorBoundary>
|
|
);
|
|
};
|
|
|
|
export default Root;
|