diff --git a/plugins/bui-themer/src/components/BuiThemerPage/BuiThemerPage.tsx b/plugins/bui-themer/src/components/BuiThemerPage/BuiThemerPage.tsx
index 90e7d21902..a65c35d665 100644
--- a/plugins/bui-themer/src/components/BuiThemerPage/BuiThemerPage.tsx
+++ b/plugins/bui-themer/src/components/BuiThemerPage/BuiThemerPage.tsx
@@ -31,6 +31,13 @@ import {
TabList,
Tab,
TabPanel,
+ TextField,
+ Select,
+ Checkbox,
+ Radio,
+ RadioGroup,
+ CardHeader,
+ CardBody,
} from '@backstage/ui';
import { convertMuiToBuiTheme } from './convertMuiToBuiTheme';
@@ -41,6 +48,128 @@ interface ThemeContentProps {
muiTheme: Theme;
}
+interface IsolatedPreviewProps {
+ mode: 'light' | 'dark';
+ css: string;
+}
+
+function BuiThemePreview({ mode, css }: IsolatedPreviewProps) {
+ return (
+
line.trim().startsWith('--bui-'))
+ .map(line => {
+ const [key, value] = line.trim().split(':');
+ return [key?.trim(), value?.replace(';', '').trim()];
+ })
+ .filter(([key, value]) => key && value),
+ ),
+ width: '100%',
+ backgroundColor: 'var(--bui-bg-surface-2)',
+ padding: 'var(--bui-space-3)',
+ borderRadius: 'var(--bui-radius-2)',
+ }}
+ >
+
+
+ Theme Preview
+
+
+ This preview shows how your theme will look with various Backstage
+ UI components
+
+
+
+
+
+ Button Variants
+
+
+
+
+
+
+
+
+
+
+ Form Inputs
+
+
+
+
+
+
+
+ Option 1
+
+ Option 2
+
+ Option 3
+
+
+
+
+
+
+ Surface Variations
+
+
+
+ Surface 1
+
+
+ Surface 2
+
+
+ Solid
+
+
+
+
+
+
+ );
+}
+
function ThemeContent({
themeId,
themeTitle,
@@ -48,7 +177,6 @@ function ThemeContent({
muiTheme,
}: ThemeContentProps) {
const [generatedCss, setGeneratedCss] = useState('');
- const [isPreviewMode, setIsPreviewMode] = useState(false);
const [includeThemeId, setIncludeThemeId] = useState(false);
const [activeTab, setActiveTab] = useState('css');
@@ -79,29 +207,6 @@ function ThemeContent({
URL.revokeObjectURL(url);
}, [generatedCss, themeId]);
- const handlePreviewToggle = useCallback(() => {
- setIsPreviewMode(!isPreviewMode);
- if (!isPreviewMode) {
- // Apply the generated CSS to a style element
- const styleId = `bui-theme-preview-${themeId}`;
- let styleElement = document.getElementById(styleId);
- if (!styleElement) {
- styleElement = document.createElement('style');
- styleElement.id = styleId;
- document.head.appendChild(styleElement);
- }
- styleElement.textContent = generatedCss;
- } else {
- // Remove the preview styles
- const styleElement = document.getElementById(
- `bui-theme-preview-${themeId}`,
- );
- if (styleElement) {
- styleElement.remove();
- }
- }
- }, [isPreviewMode, generatedCss, themeId]);
-
return (
@@ -153,7 +258,7 @@ function ThemeContent({
fontFamily: 'monospace',
fontSize: '14px',
lineHeight: '1.5',
- maxHeight: '400px',
+ height: '600px',
overflow: 'auto',
whiteSpace: 'pre-wrap',
wordBreak: 'break-all',
@@ -165,75 +270,9 @@ function ThemeContent({
-
-
-
-
-
- {isPreviewMode ? (
-
-
- Live Preview:
-
-
-
-
- Solid Button
-
-
- Tint Button
-
-
- Surface Card
-
-
-
-
- ) : (
-
-
- Click "Start Preview" to see the theme applied to sample
- components.
-
-
- )}
-
+
+
+