theme: remove new V4 methods, deprecate all existing methods
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
committed by
Philipp Hugenroth
parent
1b7f112452
commit
daa9125e4d
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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,
|
||||
});
|
||||
|
||||
@@ -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<string, PageTheme>;
|
||||
|
||||
Reference in New Issue
Block a user