theme: update API report + fixes

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2022-12-31 16:42:08 +01:00
committed by Philipp Hugenroth
parent daa9125e4d
commit 2c2e98562c
5 changed files with 215 additions and 42 deletions
+4 -4
View File
@@ -70,9 +70,7 @@ export interface UnifiedThemeOptions {
*
* @public
*/
export function createUnifiedTheme(
options: UnifiedThemeOptions,
): UnifiedThemeHolder {
export function createUnifiedTheme(options: UnifiedThemeOptions): UnifiedTheme {
const themeOptions = createBaseThemeOptions(options);
const components = { ...defaultComponentThemes, ...options.components };
const v5Theme = createV5Theme({ ...themeOptions, components });
@@ -88,7 +86,9 @@ export function createUnifiedTheme(
*
* @public
*/
export function createUnifiedThemeFromV4(options: ThemeOptionsV4) {
export function createUnifiedThemeFromV4(
options: ThemeOptionsV4,
): UnifiedTheme {
const v4Theme = createV4Theme(options);
const v5Theme = adaptV4Theme(options as any);
+4 -1
View File
@@ -14,7 +14,10 @@
* limitations under the License.
*/
export { UnifiedThemeProvider } from './UnifiedThemeProvider';
export { transformV5ComponentThemesToV4 } from './overrides';
export { createUnifiedTheme, createUnifiedThemeFromV4 } from './UnifiedTheme';
export type { UnifiedThemeOptions } from './UnifiedTheme';
export { themes } from './themes';
export { UnifiedThemeProvider } from './UnifiedThemeProvider';
export type { UnifiedThemeProviderProps } from './UnifiedThemeProvider';
export type { UnifiedTheme } from './types';
+5 -1
View File
@@ -43,7 +43,11 @@ function adaptV5Override(theme: Theme, overrides: V5Override): V4Override {
return overrides as V4Override;
}
// Transform v5 theme overrides into a v4 theme, by converting the callback-based overrides
/**
* Transform MUI v5 component themes into a v4 theme props and overrides.
*
* @public
*/
export function transformV5ComponentThemesToV4(
theme: Theme,
components: ThemeOptions['components'] = {},
+5
View File
@@ -17,6 +17,11 @@
import { palettes } from '../base';
import { createUnifiedTheme } from './UnifiedTheme';
/**
* Built-in Backstage MUI themes.
*
* @public
*/
export const themes = {
light: createUnifiedTheme({ palette: palettes.light }),
dark: createUnifiedTheme({ palette: palettes.dark }),