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

[Typography] Apply font properties to typography inherit variant #33621

Merged
merged 10 commits into from
Mar 14, 2023
7 changes: 7 additions & 0 deletions packages/mui-material/src/styles/createTypography.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ export default function createTypography(palette, typography) {
button: buildVariant(fontWeightMedium, 14, 1.75, 0.4, caseAllCaps),
caption: buildVariant(fontWeightRegular, 12, 1.66, 0.4),
overline: buildVariant(fontWeightRegular, 12, 2.66, 1, caseAllCaps),
inherit: {
fontFamily: 'inherit',
fontWeight: 'inherit',
fontSize: 'inherit',
lineHeight: 'inherit',
letterSpacing: 'inherit',
}
};

return deepmerge(
Expand Down
15 changes: 15 additions & 0 deletions packages/mui-material/src/styles/createTypography.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,21 @@ describe('createTypography', () => {
);
});

it('should apply font CSS properties to inherit variant', () => {
const typography = createTypography(palette, {});
const fontProperties = [
'fontFamily',
'fontWeight',
'fontSize',
'lineHeight',
'letterSpacing',
];

fontProperties.forEach((prop) => {
expect(typography.inherit[prop]).to.equal('inherit');
});
});

describe('warnings', () => {
it('logs an error if `fontSize` is not of type number', () => {
expect(() => {
Expand Down