diff --git a/webapp/src/components/Page/index.tsx b/webapp/src/components/Page/index.tsx index ab2b3ec..b4f1928 100644 --- a/webapp/src/components/Page/index.tsx +++ b/webapp/src/components/Page/index.tsx @@ -1,11 +1,18 @@ import "./index.css"; import { createRef, FC, ReactNode, useEffect, useRef } from "react"; -import { createTheme, ThemeProvider, useTheme } from "@mui/material/styles"; +import { + createTheme, + Palette, + PaletteColor, + ThemeProvider, + useTheme, +} from "@mui/material/styles"; import { VersionBox } from "components/VersionBox"; import { SnackbarKey, SnackbarProvider, useSnackbar } from "notistack"; import Button from "@mui/material/Button"; import { useHAConnection } from "haService/connection"; import { ConfirmProvider } from "material-ui-confirm"; +import { Color } from "@mui/material"; const theme = createTheme({ palette: { @@ -66,30 +73,11 @@ export const InternalPage: FC<{ background: theme.palette.background.default, }} > - {/* */} + {children} @@ -124,3 +112,26 @@ export const Page: FC<{ ); }; + +export const convertPaletteToCss = (p: Palette): string => { + let out = ``; + for (const k of [ + "primary", + "secondary", + "error", + "warning", + "info", + "success", + "grey", + "text", + "action", + "background", + "common", + ]) { + const pc = p[k as keyof Palette] as PaletteColor | Color; + Object.entries(pc).forEach(([n, v]) => { + out += `\n --mui-${k}-${n}: ${v};`; + }); + } + return out; +};