From 0956fe906906a854d357b32f2699aa2a812bc3ad Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Sun, 14 Sep 2025 12:15:53 +0200 Subject: [PATCH] bui-themer: tweak conversion logic Signed-off-by: Patrik Oldsberg --- .../BuiThemerPage/convertMuiToBuiTheme.ts | 38 +++++++++---------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/plugins/bui-themer/src/components/BuiThemerPage/convertMuiToBuiTheme.ts b/plugins/bui-themer/src/components/BuiThemerPage/convertMuiToBuiTheme.ts index 3f602c295d..11877bb564 100644 --- a/plugins/bui-themer/src/components/BuiThemerPage/convertMuiToBuiTheme.ts +++ b/plugins/bui-themer/src/components/BuiThemerPage/convertMuiToBuiTheme.ts @@ -55,12 +55,16 @@ function generateBuiVariables(theme: Mui5Theme): Record { } // Font weights - styleObject['--bui-font-weight-regular'] = String( - theme.typography.fontWeightRegular || 400, - ); - styleObject['--bui-font-weight-bold'] = String( - theme.typography.fontWeightBold || 600, - ); + if (theme.typography.fontWeightRegular) { + styleObject['--bui-font-weight-regular'] = String( + theme.typography.fontWeightRegular, + ); + } + if (theme.typography.fontWeightBold) { + styleObject['--bui-font-weight-bold'] = String( + theme.typography.fontWeightBold, + ); + } const spacing = theme.spacing(1); // Skip spacing if the theme is using the default @@ -83,12 +87,8 @@ function generateBuiVariables(theme: Mui5Theme): Record { Partial; // Base colors - if (palette.common?.black) { - styleObject['--bui-black'] = palette.common.black; - } - if (palette.common?.white) { - styleObject['--bui-white'] = palette.common.white; - } + styleObject['--bui-black'] = palette.common.black; + styleObject['--bui-white'] = palette.common.white; // Generate foreground colors Object.entries({ @@ -138,17 +138,13 @@ function generateBuiVariables(theme: Mui5Theme): Record { }); // Base border color if available - if (palette.border || palette.divider) { - styleObject['--bui-border'] = palette.border || palette.divider; - styleObject['--bui-border-danger'] = palette.error.main; - styleObject['--bui-border-warning'] = palette.warning.main; - styleObject['--bui-border-success'] = palette.success.main; - } + styleObject['--bui-border'] = palette.border || palette.divider; + styleObject['--bui-border-danger'] = palette.error.main; + styleObject['--bui-border-warning'] = palette.warning.main; + styleObject['--bui-border-success'] = palette.success.main; // Special colors - if (palette.highlight || palette.primary?.main) { - styleObject['--bui-ring'] = palette.highlight || palette.primary.main; - } + styleObject['--bui-ring'] = palette.highlight || palette.primary.main; return styleObject; }