Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core] Rename some @mui/material/styles/createTypography exports #45558

Merged
merged 1 commit into from
Mar 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions packages/mui-material/src/Typography/Typography.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { OverridableStringUnion } from '@mui/types';
import { SxProps, SystemProps } from '@mui/system';
import { Theme, TypeText } from '../styles';
import { OverrideProps, OverridableComponent } from '../OverridableComponent';
import { Variant } from '../styles/createTypography';
import { TypographyVariant } from '../styles/createTypography';
import { TypographyClasses } from './typographyClasses';

export interface TypographyPropsVariantOverrides {}
Expand Down Expand Up @@ -68,7 +68,7 @@ export interface TypographyOwnProps extends Omit<SystemProps<Theme>, 'color'> {
* Applies the theme typography styles.
* @default 'body1'
*/
variant?: OverridableStringUnion<Variant | 'inherit', TypographyPropsVariantOverrides>;
variant?: OverridableStringUnion<TypographyVariant | 'inherit', TypographyPropsVariantOverrides>;
/**
* The component maps the variant prop to a range of different HTML element types.
* For instance, subtitle1 to `<h6>`.
Expand All @@ -89,7 +89,10 @@ export interface TypographyOwnProps extends Omit<SystemProps<Theme>, 'color'> {
* }
*/
variantMapping?: Partial<
Record<OverridableStringUnion<Variant | 'inherit', TypographyPropsVariantOverrides>, string>
Record<
OverridableStringUnion<TypographyVariant | 'inherit', TypographyPropsVariantOverrides>,
string
>
>;
}

Expand Down
4 changes: 2 additions & 2 deletions packages/mui-material/src/styles/adaptV4Theme.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { BreakpointsOptions, ShapeOptions, SpacingOptions } from '@mui/system';
import { MixinsOptions } from './createMixins';
import { Palette, PaletteOptions } from './createPalette';
import { TypographyOptions } from './createTypography';
import { TypographyVariantsOptions } from './createTypography';
import { Shadows } from './shadows';
import { TransitionsOptions } from './createTransitions';
import { ZIndexOptions } from './zIndex';
Expand All @@ -23,7 +23,7 @@ export interface DeprecatedThemeOptions {
shadows?: Shadows;
spacing?: SpacingOptions;
transitions?: TransitionsOptions;
typography?: TypographyOptions | ((palette: Palette) => TypographyOptions);
typography?: TypographyVariantsOptions | ((palette: Palette) => TypographyVariantsOptions);
variants?: ComponentsVariants;
zIndex?: ZIndexOptions;
unstable_strictMode?: boolean;
Expand Down
6 changes: 3 additions & 3 deletions packages/mui-material/src/styles/createThemeNoVars.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
} from '@mui/system';
import { Mixins, MixinsOptions } from './createMixins';
import { Palette, PaletteOptions } from './createPalette';
import { Typography, TypographyOptions } from './createTypography';
import { TypographyVariants, TypographyVariantsOptions } from './createTypography';
import { Shadows } from './shadows';
import { Transitions, TransitionsOptions } from './createTransitions';
import { ZIndex, ZIndexOptions } from './zIndex';
Expand Down Expand Up @@ -38,7 +38,7 @@ export interface ThemeOptions extends Omit<SystemThemeOptions, 'zIndex'>, CssVar
palette?: PaletteOptions;
shadows?: Shadows;
transitions?: TransitionsOptions;
typography?: TypographyOptions | ((palette: Palette) => TypographyOptions);
typography?: TypographyVariantsOptions | ((palette: Palette) => TypographyVariantsOptions);
zIndex?: ZIndexOptions;
unstable_strictMode?: boolean;
unstable_sxConfig?: SxConfig;
Expand All @@ -49,7 +49,7 @@ export interface BaseTheme extends SystemTheme {
palette: Palette & (CssThemeVariables extends { enabled: true } ? CssVarsPalette : {});
shadows: Shadows;
transitions: Transitions;
typography: Typography;
typography: TypographyVariants;
zIndex: ZIndex;
unstable_strictMode?: boolean;
}
Expand Down
15 changes: 9 additions & 6 deletions packages/mui-material/src/styles/createTypography.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';
import * as CSS from 'csstype';
import { Palette } from './createPalette';

export type Variant =
export type TypographyVariant =
| 'h1'
| 'h2'
| 'h3'
Expand Down Expand Up @@ -63,12 +63,15 @@ export interface TypographyUtils {
pxToRem: (px: number) => string;
}

export interface Typography extends Record<Variant, TypographyStyle>, FontStyle, TypographyUtils {}
export interface TypographyVariants
extends Record<TypographyVariant, TypographyStyle>,
FontStyle,
TypographyUtils {}

export interface TypographyOptions
extends Partial<Record<Variant, TypographyStyleOptions> & FontStyleOptions> {}
export interface TypographyVariantsOptions
extends Partial<Record<TypographyVariant, TypographyStyleOptions> & FontStyleOptions> {}

export default function createTypography(
palette: Palette,
typography: TypographyOptions | ((palette: Palette) => TypographyOptions),
): Typography;
typography: TypographyVariantsOptions | ((palette: Palette) => TypographyVariantsOptions),
): TypographyVariants;
6 changes: 3 additions & 3 deletions packages/mui-material/src/styles/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ export {
export { default as createColorScheme } from './createColorScheme';
export { default as createStyles } from './createStyles';
export {
Typography as TypographyVariants,
TypographyOptions as TypographyVariantsOptions,
TypographyVariants,
TypographyVariantsOptions,
TypographyStyle,
Variant as TypographyVariant,
TypographyVariant,
} from './createTypography';
export { default as responsiveFontSizes } from './responsiveFontSizes';
export {
Expand Down
6 changes: 3 additions & 3 deletions packages/mui-material/src/styles/responsiveFontSizes.d.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { Breakpoint } from '@mui/system';
import { Typography } from './createTypography';
import { TypographyVariants } from './createTypography';

export interface ResponsiveFontSizesOptions {
breakpoints?: Breakpoint[];
disableAlign?: boolean;
factor?: number;
variants?: Array<keyof Typography>;
variants?: Array<keyof TypographyVariants>;
}

export default function responsiveFontSizes<T extends { typography: Typography }>(
export default function responsiveFontSizes<T extends { typography: TypographyVariants }>(
theme: T,
options?: ResponsiveFontSizesOptions,
): T;