From daa9125e4d44f233faea84114b8e977a6eeae74d Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Sat, 31 Dec 2022 16:37:01 +0100 Subject: [PATCH] theme: remove new V4 methods, deprecate all existing methods Signed-off-by: Patrik Oldsberg --- packages/theme/src/index.ts | 28 ---------------------------- packages/theme/src/v4/baseTheme.ts | 25 +++++++++++++------------ packages/theme/src/v4/index.ts | 8 ++++---- packages/theme/src/v4/themes.ts | 6 +++--- packages/theme/src/v4/types.ts | 3 ++- 5 files changed, 22 insertions(+), 48 deletions(-) diff --git a/packages/theme/src/index.ts b/packages/theme/src/index.ts index 8fdb961705..55bcf3beaa 100644 --- a/packages/theme/src/index.ts +++ b/packages/theme/src/index.ts @@ -24,31 +24,3 @@ export * from './compat'; export * from './base'; export * from './v4'; export * from './v5'; - -import { - createV4Theme, - createV4ThemeOptions, - createV4ThemeOverrides, -} from './v4'; -import type { SimpleV4ThemeOptions } from './v4'; - -/** - * @public - * @deprecated Use {@link createV4Theme} instead. - */ -export const createTheme = createV4Theme; -/** - * @public - * @deprecated Use {@link createV4ThemeOptions} instead. - */ -export const createThemeOptions = createV4ThemeOptions; -/** - * @public - * @deprecated Use {@link createV4ThemeOverrides} instead. - */ -export const createThemeOverrides = createV4ThemeOverrides; -/** - * @public - * @deprecated Use {@link SimpleV4ThemeOptions} instead. - */ -export type SimpleThemeOptions = SimpleV4ThemeOptions; diff --git a/packages/theme/src/v4/baseTheme.ts b/packages/theme/src/v4/baseTheme.ts index 9ae8507e9c..2349cfb13b 100644 --- a/packages/theme/src/v4/baseTheme.ts +++ b/packages/theme/src/v4/baseTheme.ts @@ -18,19 +18,18 @@ import { Theme as Mui5Theme } from '@mui/material/styles'; import { createTheme as createMuiTheme } from '@material-ui/core/styles'; import { GridProps, SwitchProps, Theme, ThemeOptions } from '@material-ui/core'; import { Overrides } from '@material-ui/core/styles/overrides'; -import { SimpleV4ThemeOptions } from './types'; +import { SimpleThemeOptions } from './types'; import { createBaseThemeOptions } from '../base'; import { defaultComponentThemes } from '../v5'; import { transformV5ComponentThemesToV4 } from '../compat/overrides'; /** - * A helper for creating theme options. + * An old helper for creating MUI v4 theme options. * * @public + * @deprecated Use {@link createBaseThemeOptions} instead. */ -export function createV4ThemeOptions( - options: SimpleV4ThemeOptions, -): ThemeOptions { +export function createThemeOptions(options: SimpleThemeOptions): ThemeOptions { return { props: { MuiGrid: defaultComponentThemes?.MuiGrid @@ -43,11 +42,12 @@ export function createV4ThemeOptions( } /** - * A helper for creating theme overrides. + * * An old helper for creating MUI v4 theme overrides. * * @public + * @deprecated Use {@link defaultComponentThemes} with {@link transformV5ComponentThemesToV4} instead. */ -export function createV4ThemeOverrides(theme: Theme): Overrides { +export function createThemeOverrides(theme: Theme): Overrides { return transformV5ComponentThemesToV4( // Safe but we have to make sure we don't use mui5 specific stuff in the default component themes theme as unknown as Mui5Theme, @@ -56,15 +56,16 @@ export function createV4ThemeOverrides(theme: Theme): Overrides { } /** - * Creates a Backstage MUI theme using a palette. The theme is created with the - * common Backstage options and component styles. + * The old method to create a Backstage MUI v4 theme using a palette. + * The theme is created with the common Backstage options and component styles. * * @public + * @deprecated Use {@link createUnifiedTheme} instead. */ -export function createV4Theme(options: SimpleV4ThemeOptions): Theme { - const themeOptions = createV4ThemeOptions(options); +export function createTheme(options: SimpleThemeOptions): Theme { + const themeOptions = createThemeOptions(options); const baseTheme = createMuiTheme(themeOptions); - const overrides = createV4ThemeOverrides(baseTheme); + const overrides = createThemeOverrides(baseTheme); const theme = { ...baseTheme, overrides }; return theme; } diff --git a/packages/theme/src/v4/index.ts b/packages/theme/src/v4/index.ts index 331e0e4c1e..fad349b849 100644 --- a/packages/theme/src/v4/index.ts +++ b/packages/theme/src/v4/index.ts @@ -16,14 +16,14 @@ export { darkTheme, lightTheme } from './themes'; export { - createV4Theme, - createV4ThemeOptions, - createV4ThemeOverrides, + createTheme, + createThemeOptions, + createThemeOverrides, } from './baseTheme'; export type { BackstagePalette, BackstagePaletteOptions, BackstageTheme, BackstageThemeOptions, - SimpleV4ThemeOptions, + SimpleThemeOptions, } from './types'; diff --git a/packages/theme/src/v4/themes.ts b/packages/theme/src/v4/themes.ts index e5ce783e0f..488ee58831 100644 --- a/packages/theme/src/v4/themes.ts +++ b/packages/theme/src/v4/themes.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { createV4Theme } from './baseTheme'; +import { createTheme } from './baseTheme'; import { palettes } from '../base'; /** @@ -23,7 +23,7 @@ import { palettes } from '../base'; * @public * @deprecated Use {@link themes.light} instead. */ -export const lightTheme = createV4Theme({ +export const lightTheme = createTheme({ palette: palettes.light, }); @@ -33,6 +33,6 @@ export const lightTheme = createV4Theme({ * @public * @deprecated Use {@link themes.dark} instead. */ -export const darkTheme = createV4Theme({ +export const darkTheme = createTheme({ palette: palettes.dark, }); diff --git a/packages/theme/src/v4/types.ts b/packages/theme/src/v4/types.ts index ded91bec3f..24736e5d88 100644 --- a/packages/theme/src/v4/types.ts +++ b/packages/theme/src/v4/types.ts @@ -78,8 +78,9 @@ export interface BackstageTheme extends Theme { * of the backstage one. * * @public + * @deprecated Use {@link BaseThemeOptionsInput} instead. */ -export type SimpleV4ThemeOptions = { +export type SimpleThemeOptions = { palette: PaletteOptions; defaultPageTheme?: string; pageTheme?: Record;