import * as React from "react"; import { getFullColorThemeCss } from "./themeManager"; import { classList } from "../util"; // Programmatically generate a preview of the theme using theme colors. export const ThemePreview = (props: { theme: pxt.ColorThemeInfo }) => { const { theme } = props; const styleRef = React.useRef(null); const uniqueContainerClassName = `theme-preview-container-${theme.id}`; const uniqueInnerClassName = `theme-preview-${theme.id}`; // Useful for override css adjusting previews const miniLogo = Microsoft MakeCode Logo; React.useEffect(() => { if (styleRef?.current) { const themeCss = getFullColorThemeCss(theme); // Set textContent instead of innerHTML to avoid XSS styleRef.current.textContent = `.${uniqueContainerClassName} { ${themeCss} }`; } }, [theme]); return (