@backstage/theme 0.7.0 → 0.7.1-next.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
package/dist/index.d.ts
CHANGED
|
@@ -236,6 +236,8 @@ declare const themes: {
|
|
|
236
236
|
interface UnifiedThemeProviderProps {
|
|
237
237
|
children: ReactNode;
|
|
238
238
|
theme: UnifiedTheme;
|
|
239
|
+
/** Optional override for the value written to the `data-theme-name` attribute. */
|
|
240
|
+
themeName?: string;
|
|
239
241
|
}
|
|
240
242
|
/**
|
|
241
243
|
* Provides themes for all Material UI versions supported by the provided unified theme.
|
|
@@ -11,13 +11,11 @@ const generateV4ClassName = createGenerateClassName({
|
|
|
11
11
|
productionPrefix: "jss4-"
|
|
12
12
|
});
|
|
13
13
|
function UnifiedThemeProvider(props) {
|
|
14
|
-
const { children, theme } = props;
|
|
14
|
+
const { children, theme, themeName } = props;
|
|
15
15
|
const v4Theme = theme.getTheme("v4");
|
|
16
16
|
const v5Theme = theme.getTheme("v5");
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
"backstage"
|
|
20
|
-
);
|
|
17
|
+
const themeMode = v4Theme ? v4Theme.palette.type : v5Theme?.palette.mode;
|
|
18
|
+
useApplyThemeAttributes(themeMode, themeName ?? "backstage");
|
|
21
19
|
let result = children;
|
|
22
20
|
if (v4Theme) {
|
|
23
21
|
result = /* @__PURE__ */ jsx(StylesProvider, { generateClassName: generateV4ClassName, children: /* @__PURE__ */ jsx(ThemeProvider, { theme: v4Theme, children: result }) });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UnifiedThemeProvider.esm.js","sources":["../../src/unified/UnifiedThemeProvider.tsx"],"sourcesContent":["/*\n * Copyright 2022 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 { ReactNode } from 'react';\nimport {\n ThemeProvider,\n StylesProvider,\n createGenerateClassName,\n Theme as Mui4Theme,\n} from '@material-ui/core/styles';\nimport {\n StyledEngineProvider,\n ThemeProvider as Mui5Provider,\n Theme as Mui5Theme,\n} from '@mui/material/styles';\nimport { UnifiedTheme } from './types';\nimport { unstable_ClassNameGenerator as ClassNameGenerator } from '@mui/material/className';\n\n/**\n * Props for {@link UnifiedThemeProvider}.\n *\n * @public\n */\nexport interface UnifiedThemeProviderProps {\n children: ReactNode;\n theme: UnifiedTheme;\n}\n\n/**\n * This API is introduced in @mui/material (v5.0.5) as a replacement of deprecated createGenerateClassName & only affects v5 Material UI components from `@mui/*`.\n *\n * This call needs to be in the same module as the `UnifiedThemeProvider` to ensure that it doesn't get removed by tree shaking\n */\nClassNameGenerator.configure(componentName => {\n return `v5-${componentName}`;\n});\n\n// Background at https://mui.com/x/migration/migration-data-grid-v4/#using-mui-core-v4-with-v5\n// Rather than disabling globals and custom seed, we instead only set a production prefix that\n// won't collide with Material UI 5 styles. We've already got the separate class name generator\n// for v5 set up in just above, so only the production JSS needs deduplication.\nconst generateV4ClassName = createGenerateClassName({\n productionPrefix: 'jss4-',\n});\n\nimport { useApplyThemeAttributes } from './useApplyThemeAttributes';\n\n/**\n * Provides themes for all Material UI versions supported by the provided unified theme.\n *\n * @public\n */\nexport function UnifiedThemeProvider(\n props: UnifiedThemeProviderProps,\n): JSX.Element {\n const { children, theme } = props;\n\n const v4Theme = theme.getTheme('v4') as Mui4Theme;\n const v5Theme = theme.getTheme('v5') as Mui5Theme;\n\n
|
|
1
|
+
{"version":3,"file":"UnifiedThemeProvider.esm.js","sources":["../../src/unified/UnifiedThemeProvider.tsx"],"sourcesContent":["/*\n * Copyright 2022 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 { ReactNode } from 'react';\nimport {\n ThemeProvider,\n StylesProvider,\n createGenerateClassName,\n Theme as Mui4Theme,\n} from '@material-ui/core/styles';\nimport {\n StyledEngineProvider,\n ThemeProvider as Mui5Provider,\n Theme as Mui5Theme,\n} from '@mui/material/styles';\nimport { UnifiedTheme } from './types';\nimport { unstable_ClassNameGenerator as ClassNameGenerator } from '@mui/material/className';\n\n/**\n * Props for {@link UnifiedThemeProvider}.\n *\n * @public\n */\nexport interface UnifiedThemeProviderProps {\n children: ReactNode;\n theme: UnifiedTheme;\n /** Optional override for the value written to the `data-theme-name` attribute. */\n themeName?: string;\n}\n\n/**\n * This API is introduced in @mui/material (v5.0.5) as a replacement of deprecated createGenerateClassName & only affects v5 Material UI components from `@mui/*`.\n *\n * This call needs to be in the same module as the `UnifiedThemeProvider` to ensure that it doesn't get removed by tree shaking\n */\nClassNameGenerator.configure(componentName => {\n return `v5-${componentName}`;\n});\n\n// Background at https://mui.com/x/migration/migration-data-grid-v4/#using-mui-core-v4-with-v5\n// Rather than disabling globals and custom seed, we instead only set a production prefix that\n// won't collide with Material UI 5 styles. We've already got the separate class name generator\n// for v5 set up in just above, so only the production JSS needs deduplication.\nconst generateV4ClassName = createGenerateClassName({\n productionPrefix: 'jss4-',\n});\n\nimport { useApplyThemeAttributes } from './useApplyThemeAttributes';\n\n/**\n * Provides themes for all Material UI versions supported by the provided unified theme.\n *\n * @public\n */\nexport function UnifiedThemeProvider(\n props: UnifiedThemeProviderProps,\n): JSX.Element {\n const { children, theme, themeName } = props;\n\n const v4Theme = theme.getTheme('v4') as Mui4Theme;\n const v5Theme = theme.getTheme('v5') as Mui5Theme;\n\n const themeMode = v4Theme ? v4Theme.palette.type : v5Theme?.palette.mode;\n\n useApplyThemeAttributes(themeMode, themeName ?? 'backstage');\n\n let result = children as JSX.Element;\n\n if (v4Theme) {\n result = (\n <StylesProvider generateClassName={generateV4ClassName}>\n <ThemeProvider theme={v4Theme}>{result}</ThemeProvider>\n </StylesProvider>\n );\n }\n\n if (v5Theme) {\n result = (\n <StyledEngineProvider injectFirst>\n <Mui5Provider theme={v5Theme}>{result}</Mui5Provider>\n </StyledEngineProvider>\n );\n }\n\n return result;\n}\n"],"names":["ClassNameGenerator","Mui5Provider"],"mappings":";;;;;;AAgDAA,2BAAA,CAAmB,UAAU,CAAA,aAAA,KAAiB;AAC5C,EAAA,OAAO,MAAM,aAAa,CAAA,CAAA;AAC5B,CAAC,CAAA;AAMD,MAAM,sBAAsB,uBAAA,CAAwB;AAAA,EAClD,gBAAA,EAAkB;AACpB,CAAC,CAAA;AASM,SAAS,qBACd,KAAA,EACa;AACb,EAAA,MAAM,EAAE,QAAA,EAAU,KAAA,EAAO,SAAA,EAAU,GAAI,KAAA;AAEvC,EAAA,MAAM,OAAA,GAAU,KAAA,CAAM,QAAA,CAAS,IAAI,CAAA;AACnC,EAAA,MAAM,OAAA,GAAU,KAAA,CAAM,QAAA,CAAS,IAAI,CAAA;AAEnC,EAAA,MAAM,YAAY,OAAA,GAAU,OAAA,CAAQ,OAAA,CAAQ,IAAA,GAAO,SAAS,OAAA,CAAQ,IAAA;AAEpE,EAAA,uBAAA,CAAwB,SAAA,EAAW,aAAa,WAAW,CAAA;AAE3D,EAAA,IAAI,MAAA,GAAS,QAAA;AAEb,EAAA,IAAI,OAAA,EAAS;AACX,IAAA,MAAA,mBACE,GAAA,CAAC,kBAAe,iBAAA,EAAmB,mBAAA,EACjC,8BAAC,aAAA,EAAA,EAAc,KAAA,EAAO,OAAA,EAAU,QAAA,EAAA,MAAA,EAAO,CAAA,EACzC,CAAA;AAAA,EAEJ;AAEA,EAAA,IAAI,OAAA,EAAS;AACX,IAAA,MAAA,mBACE,GAAA,CAAC,wBAAqB,WAAA,EAAW,IAAA,EAC/B,8BAACC,eAAA,EAAA,EAAa,KAAA,EAAO,OAAA,EAAU,QAAA,EAAA,MAAA,EAAO,CAAA,EACxC,CAAA;AAAA,EAEJ;AAEA,EAAA,OAAO,MAAA;AACT;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/theme",
|
|
3
|
-
"version": "0.7.0",
|
|
3
|
+
"version": "0.7.1-next.0",
|
|
4
4
|
"description": "material-ui theme for use with Backstage.",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "web-library"
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"@mui/material": "^5.12.2"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@backstage/cli": "
|
|
44
|
+
"@backstage/cli": "0.34.6-next.0",
|
|
45
45
|
"@mui/styles": "^5.14.18",
|
|
46
46
|
"@testing-library/jest-dom": "^6.0.0",
|
|
47
47
|
"@testing-library/react": "^16.0.0",
|