@backstage/plugin-mui-to-bui 0.2.0-next.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @backstage/plugin-mui-to-bui
|
|
2
2
|
|
|
3
|
+
## 0.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- d5cbdba: This is the first release of the Material UI to Backstage UI migration helper plugin. It adds a new page at `/mui-to-bui` that converts an existing MUI v5 theme into Backstage UI (BUI) CSS variables, with live preview and copy/download.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- 28ee81c: Fix invalid conversion for `--bui-bg` variable
|
|
12
|
+
- Updated dependencies
|
|
13
|
+
- @backstage/ui@0.8.0
|
|
14
|
+
- @backstage/frontend-plugin-api@0.12.1
|
|
15
|
+
- @backstage/theme@0.7.0
|
|
16
|
+
- @backstage/core-compat-api@0.5.3
|
|
17
|
+
- @backstage/core-plugin-api@1.11.1
|
|
18
|
+
|
|
3
19
|
## 0.2.0-next.0
|
|
4
20
|
|
|
5
21
|
### Minor Changes
|
|
@@ -70,14 +70,14 @@ function generateBuiVariables(theme) {
|
|
|
70
70
|
warning: palette.warning.light,
|
|
71
71
|
success: palette.success.light
|
|
72
72
|
}).forEach(([key, value]) => {
|
|
73
|
-
styleObject[`--bui-bg
|
|
73
|
+
styleObject[`--bui-bg${key ? `-${key}` : ""}`] = value;
|
|
74
74
|
});
|
|
75
75
|
Object.entries({
|
|
76
76
|
danger: palette.error.main,
|
|
77
77
|
warning: palette.warning.main,
|
|
78
78
|
success: palette.success.main
|
|
79
79
|
}).forEach(([key, value]) => {
|
|
80
|
-
styleObject[`--bui-border
|
|
80
|
+
styleObject[`--bui-border-${key}`] = value;
|
|
81
81
|
});
|
|
82
82
|
styleObject["--bui-border"] = palette.border || palette.divider;
|
|
83
83
|
styleObject["--bui-border-danger"] = palette.error.main;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convertMuiToBuiTheme.esm.js","sources":["../../../src/components/BuiThemerPage/convertMuiToBuiTheme.ts"],"sourcesContent":["/*\n * Copyright 2025 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Theme as Mui5Theme } from '@mui/material/styles';\nimport { BackstagePaletteAdditions } from '@backstage/theme';\nimport { blend, alpha } from '@mui/system/colorManipulator';\n\nexport interface ConvertMuiToBuiThemeResult {\n css: string;\n styleObject: Record<string, string>;\n}\n\n/**\n * Converts a MUI v5 Theme to BUI CSS variables\n * @param theme - The MUI v5 theme to convert\n * @returns Object containing CSS string and style object with BUI variables\n */\nexport function convertMuiToBuiTheme(\n theme: Mui5Theme,\n): ConvertMuiToBuiThemeResult {\n const styleObject = generateBuiVariables(theme);\n\n const selector =\n theme.palette.mode === 'dark' ? \"[data-theme-mode='dark']\" : ':root';\n\n const css = `${selector} {\\n${Object.entries(styleObject)\n .map(([key, value]) => ` ${key}: ${value};`)\n .join('\\n')}\\n}`;\n\n return { css, styleObject };\n}\n\n/**\n * Generates BUI CSS variables from MUI theme\n */\nfunction generateBuiVariables(theme: Mui5Theme): Record<string, string> {\n const styleObject: Record<string, string> = {};\n\n // Font families\n if (theme.typography.fontFamily) {\n styleObject['--bui-font-regular'] = theme.typography.fontFamily;\n }\n\n // Font weights\n if (theme.typography.fontWeightRegular) {\n styleObject['--bui-font-weight-regular'] = String(\n theme.typography.fontWeightRegular,\n );\n }\n if (theme.typography.fontWeightBold) {\n styleObject['--bui-font-weight-bold'] = String(\n theme.typography.fontWeightBold,\n );\n }\n\n const spacing = theme.spacing(1);\n // Skip spacing if the theme is using the default\n if (spacing !== '8px') {\n styleObject['--bui-space'] = `calc(${spacing} * 0.5)`;\n }\n\n // Border radius, only translate a 0 radius\n if (theme.shape.borderRadius === 0) {\n styleObject['--bui-radius-1'] = '0';\n styleObject['--bui-radius-2'] = '0';\n styleObject['--bui-radius-3'] = '0';\n styleObject['--bui-radius-4'] = '0';\n styleObject['--bui-radius-5'] = '0';\n styleObject['--bui-radius-6'] = '0';\n }\n\n // Colors - map MUI palette to BUI color tokens\n const palette = theme.palette as typeof theme.palette &\n Partial<BackstagePaletteAdditions>;\n\n // Base colors\n styleObject['--bui-black'] = palette.common.black;\n styleObject['--bui-white'] = palette.common.white;\n\n // Generate foreground colors\n Object.entries({\n primary: palette.text.primary,\n secondary: palette.textSubtle,\n link: palette.link ?? palette.primary.main,\n 'link-hover': palette.linkHover ?? palette.primary.dark,\n disabled: palette.text.disabled,\n solid: palette.primary.contrastText,\n 'solid-disabled': palette.text.disabled,\n tint: palette.textSubtle,\n 'tint-disabled': palette.textVerySubtle,\n danger: palette.error.dark,\n warning: palette.warning.dark,\n success: palette.success.dark,\n }).forEach(([key, value]) => {\n styleObject[`--bui-fg-${key}`] = value;\n });\n\n // Generate surface colors\n Object.entries({\n '': palette.background.default,\n 'surface-1': palette.background.paper,\n 'surface-2': palette.background.default,\n solid: palette.primary.main,\n 'solid-hover': blend(palette.primary.main, palette.primary.dark, 0.5),\n 'solid-pressed': palette.primary.dark,\n 'solid-disabled': palette.action.disabledBackground,\n tint: 'transparent',\n 'tint-hover': alpha(palette.primary.main, 0.4),\n 'tint-pressed': alpha(palette.primary.main, 0.6),\n 'tint-disabled': palette.action.disabledBackground,\n danger: palette.error.light,\n warning: palette.warning.light,\n success: palette.success.light,\n }).forEach(([key, value]) => {\n styleObject[`--bui-bg
|
|
1
|
+
{"version":3,"file":"convertMuiToBuiTheme.esm.js","sources":["../../../src/components/BuiThemerPage/convertMuiToBuiTheme.ts"],"sourcesContent":["/*\n * Copyright 2025 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Theme as Mui5Theme } from '@mui/material/styles';\nimport { BackstagePaletteAdditions } from '@backstage/theme';\nimport { blend, alpha } from '@mui/system/colorManipulator';\n\nexport interface ConvertMuiToBuiThemeResult {\n css: string;\n styleObject: Record<string, string>;\n}\n\n/**\n * Converts a MUI v5 Theme to BUI CSS variables\n * @param theme - The MUI v5 theme to convert\n * @returns Object containing CSS string and style object with BUI variables\n */\nexport function convertMuiToBuiTheme(\n theme: Mui5Theme,\n): ConvertMuiToBuiThemeResult {\n const styleObject = generateBuiVariables(theme);\n\n const selector =\n theme.palette.mode === 'dark' ? \"[data-theme-mode='dark']\" : ':root';\n\n const css = `${selector} {\\n${Object.entries(styleObject)\n .map(([key, value]) => ` ${key}: ${value};`)\n .join('\\n')}\\n}`;\n\n return { css, styleObject };\n}\n\n/**\n * Generates BUI CSS variables from MUI theme\n */\nfunction generateBuiVariables(theme: Mui5Theme): Record<string, string> {\n const styleObject: Record<string, string> = {};\n\n // Font families\n if (theme.typography.fontFamily) {\n styleObject['--bui-font-regular'] = theme.typography.fontFamily;\n }\n\n // Font weights\n if (theme.typography.fontWeightRegular) {\n styleObject['--bui-font-weight-regular'] = String(\n theme.typography.fontWeightRegular,\n );\n }\n if (theme.typography.fontWeightBold) {\n styleObject['--bui-font-weight-bold'] = String(\n theme.typography.fontWeightBold,\n );\n }\n\n const spacing = theme.spacing(1);\n // Skip spacing if the theme is using the default\n if (spacing !== '8px') {\n styleObject['--bui-space'] = `calc(${spacing} * 0.5)`;\n }\n\n // Border radius, only translate a 0 radius\n if (theme.shape.borderRadius === 0) {\n styleObject['--bui-radius-1'] = '0';\n styleObject['--bui-radius-2'] = '0';\n styleObject['--bui-radius-3'] = '0';\n styleObject['--bui-radius-4'] = '0';\n styleObject['--bui-radius-5'] = '0';\n styleObject['--bui-radius-6'] = '0';\n }\n\n // Colors - map MUI palette to BUI color tokens\n const palette = theme.palette as typeof theme.palette &\n Partial<BackstagePaletteAdditions>;\n\n // Base colors\n styleObject['--bui-black'] = palette.common.black;\n styleObject['--bui-white'] = palette.common.white;\n\n // Generate foreground colors\n Object.entries({\n primary: palette.text.primary,\n secondary: palette.textSubtle,\n link: palette.link ?? palette.primary.main,\n 'link-hover': palette.linkHover ?? palette.primary.dark,\n disabled: palette.text.disabled,\n solid: palette.primary.contrastText,\n 'solid-disabled': palette.text.disabled,\n tint: palette.textSubtle,\n 'tint-disabled': palette.textVerySubtle,\n danger: palette.error.dark,\n warning: palette.warning.dark,\n success: palette.success.dark,\n }).forEach(([key, value]) => {\n styleObject[`--bui-fg-${key}`] = value;\n });\n\n // Generate surface colors\n Object.entries({\n '': palette.background.default,\n 'surface-1': palette.background.paper,\n 'surface-2': palette.background.default,\n solid: palette.primary.main,\n 'solid-hover': blend(palette.primary.main, palette.primary.dark, 0.5),\n 'solid-pressed': palette.primary.dark,\n 'solid-disabled': palette.action.disabledBackground,\n tint: 'transparent',\n 'tint-hover': alpha(palette.primary.main, 0.4),\n 'tint-pressed': alpha(palette.primary.main, 0.6),\n 'tint-disabled': palette.action.disabledBackground,\n danger: palette.error.light,\n warning: palette.warning.light,\n success: palette.success.light,\n }).forEach(([key, value]) => {\n styleObject[`--bui-bg${key ? `-${key}` : ''}`] = value;\n });\n\n // Border colors\n Object.entries({\n danger: palette.error.main,\n warning: palette.warning.main,\n success: palette.success.main,\n }).forEach(([key, value]) => {\n styleObject[`--bui-border-${key}`] = value;\n });\n\n // Base border color if available\n styleObject['--bui-border'] = palette.border || palette.divider;\n styleObject['--bui-border-danger'] = palette.error.main;\n styleObject['--bui-border-warning'] = palette.warning.main;\n styleObject['--bui-border-success'] = palette.success.main;\n\n // Special colors\n styleObject['--bui-ring'] = palette.highlight || palette.primary.main;\n\n return styleObject;\n}\n"],"names":[],"mappings":";;AA8BO,SAAS,qBACd,KAAA,EAC4B;AAC5B,EAAA,MAAM,WAAA,GAAc,qBAAqB,KAAK,CAAA;AAE9C,EAAA,MAAM,QAAA,GACJ,KAAA,CAAM,OAAA,CAAQ,IAAA,KAAS,SAAS,0BAAA,GAA6B,OAAA;AAE/D,EAAA,MAAM,GAAA,GAAM,GAAG,QAAQ,CAAA;AAAA,EAAO,OAAO,OAAA,CAAQ,WAAW,EACrD,GAAA,CAAI,CAAC,CAAC,GAAA,EAAK,KAAK,CAAA,KAAM,CAAA,EAAA,EAAK,GAAG,CAAA,EAAA,EAAK,KAAK,GAAG,CAAA,CAC3C,IAAA,CAAK,IAAI,CAAC;AAAA,CAAA,CAAA;AAEb,EAAA,OAAO,EAAE,KAAK,WAAA,EAAY;AAC5B;AAKA,SAAS,qBAAqB,KAAA,EAA0C;AACtE,EAAA,MAAM,cAAsC,EAAC;AAG7C,EAAA,IAAI,KAAA,CAAM,WAAW,UAAA,EAAY;AAC/B,IAAA,WAAA,CAAY,oBAAoB,CAAA,GAAI,KAAA,CAAM,UAAA,CAAW,UAAA;AAAA,EACvD;AAGA,EAAA,IAAI,KAAA,CAAM,WAAW,iBAAA,EAAmB;AACtC,IAAA,WAAA,CAAY,2BAA2B,CAAA,GAAI,MAAA;AAAA,MACzC,MAAM,UAAA,CAAW;AAAA,KACnB;AAAA,EACF;AACA,EAAA,IAAI,KAAA,CAAM,WAAW,cAAA,EAAgB;AACnC,IAAA,WAAA,CAAY,wBAAwB,CAAA,GAAI,MAAA;AAAA,MACtC,MAAM,UAAA,CAAW;AAAA,KACnB;AAAA,EACF;AAEA,EAAA,MAAM,OAAA,GAAU,KAAA,CAAM,OAAA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|
|
|
19
19
|
"repository": {
|
|
20
20
|
"type": "git",
|
|
21
21
|
"url": "https://github.com/backstage/backstage",
|
|
22
|
-
"directory": "plugins/bui
|
|
22
|
+
"directory": "plugins/mui-to-bui"
|
|
23
23
|
},
|
|
24
24
|
"license": "Apache-2.0",
|
|
25
25
|
"sideEffects": false,
|
|
@@ -38,18 +38,18 @@
|
|
|
38
38
|
"test": "backstage-cli package test"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@backstage/core-compat-api": "0.5.3
|
|
42
|
-
"@backstage/core-plugin-api": "1.11.1
|
|
43
|
-
"@backstage/frontend-plugin-api": "0.12.1
|
|
44
|
-
"@backstage/theme": "0.
|
|
45
|
-
"@backstage/ui": "0.
|
|
41
|
+
"@backstage/core-compat-api": "^0.5.3",
|
|
42
|
+
"@backstage/core-plugin-api": "^1.11.1",
|
|
43
|
+
"@backstage/frontend-plugin-api": "^0.12.1",
|
|
44
|
+
"@backstage/theme": "^0.7.0",
|
|
45
|
+
"@backstage/ui": "^0.8.0",
|
|
46
46
|
"@mui/material": "^5.12.2",
|
|
47
47
|
"@mui/system": "^5.16.14"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@backstage/cli": "0.34.4
|
|
51
|
-
"@backstage/dev-utils": "1.1.15
|
|
52
|
-
"@backstage/test-utils": "1.7.12
|
|
50
|
+
"@backstage/cli": "^0.34.4",
|
|
51
|
+
"@backstage/dev-utils": "^1.1.15",
|
|
52
|
+
"@backstage/test-utils": "^1.7.12",
|
|
53
53
|
"@testing-library/jest-dom": "^6.0.0",
|
|
54
54
|
"@testing-library/react": "^16.0.0",
|
|
55
55
|
"@types/react": "^18.0.0",
|