From d5821645acf1deebb51faa0b3282d32456c85faf Mon Sep 17 00:00:00 2001 From: ZeeshanTamboli Date: Sun, 23 Jul 2023 17:20:10 +0530 Subject: [PATCH 01/12] remove logic from theme typography --- packages/mui-material/src/Typography/Typography.js | 7 +++++-- packages/mui-material/src/styles/CssVarsProvider.test.js | 2 +- packages/mui-material/src/styles/createTypography.js | 7 ------- .../mui-material/src/styles/createTypography.test.js | 9 --------- .../mui-system/src/styleFunctionSx/styleFunctionSx.js | 4 ---- 5 files changed, 6 insertions(+), 23 deletions(-) diff --git a/packages/mui-material/src/Typography/Typography.js b/packages/mui-material/src/Typography/Typography.js index 1de18d23f78cc0..967b21adab9a6f 100644 --- a/packages/mui-material/src/Typography/Typography.js +++ b/packages/mui-material/src/Typography/Typography.js @@ -34,7 +34,7 @@ export const TypographyRoot = styled('span', { return [ styles.root, - ownerState.variant && styles[ownerState.variant], + ownerState&& styles[ownerState.variant], ownerState.align !== 'inherit' && styles[`align${capitalize(ownerState.align)}`], ownerState.noWrap && styles.noWrap, ownerState.gutterBottom && styles.gutterBottom, @@ -43,7 +43,10 @@ export const TypographyRoot = styled('span', { }, })(({ theme, ownerState }) => ({ margin: 0, - ...(ownerState.variant && theme.typography[ownerState.variant]), + ...(ownerState.variant === 'inherit' && { + font: 'inherit' + }), + ...(ownerState.variant !== 'inherit' && theme.typography[ownerState.variant]), ...(ownerState.align !== 'inherit' && { textAlign: ownerState.align, }), diff --git a/packages/mui-material/src/styles/CssVarsProvider.test.js b/packages/mui-material/src/styles/CssVarsProvider.test.js index b12643e48eb087..a99e6eb0b7b855 100644 --- a/packages/mui-material/src/styles/CssVarsProvider.test.js +++ b/packages/mui-material/src/styles/CssVarsProvider.test.js @@ -246,7 +246,7 @@ describe('[Material UI] CssVarsProvider', () => { ); expect(container.firstChild?.textContent).to.equal( - 'htmlFontSize,pxToRem,fontFamily,fontSize,fontWeightLight,fontWeightRegular,fontWeightMedium,fontWeightBold,h1,h2,h3,h4,h5,h6,subtitle1,subtitle2,body1,body2,button,caption,overline,inherit', + 'htmlFontSize,pxToRem,fontFamily,fontSize,fontWeightLight,fontWeightRegular,fontWeightMedium,fontWeightBold,h1,h2,h3,h4,h5,h6,subtitle1,subtitle2,body1,body2,button,caption,overline', ); }); }); diff --git a/packages/mui-material/src/styles/createTypography.js b/packages/mui-material/src/styles/createTypography.js index 78775e5ce5e1c5..ca52ce80c25179 100644 --- a/packages/mui-material/src/styles/createTypography.js +++ b/packages/mui-material/src/styles/createTypography.js @@ -72,13 +72,6 @@ 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( diff --git a/packages/mui-material/src/styles/createTypography.test.js b/packages/mui-material/src/styles/createTypography.test.js index 2f2fbc07c6e076..db14cdd166e6a7 100644 --- a/packages/mui-material/src/styles/createTypography.test.js +++ b/packages/mui-material/src/styles/createTypography.test.js @@ -74,15 +74,6 @@ 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(() => { diff --git a/packages/mui-system/src/styleFunctionSx/styleFunctionSx.js b/packages/mui-system/src/styleFunctionSx/styleFunctionSx.js index ef66e3001929a9..c675671f7abc0b 100644 --- a/packages/mui-system/src/styleFunctionSx/styleFunctionSx.js +++ b/packages/mui-system/src/styleFunctionSx/styleFunctionSx.js @@ -38,10 +38,6 @@ export function unstable_createStyleFunctionSx() { return null; } - if (themeKey === 'typography' && val === 'inherit') { - return { [prop]: val }; - } - const themeMapping = getPath(theme, themeKey) || {}; if (style) { From 3f534b54ffec84f5a22cd2671a4c9b51bedf1ce0 Mon Sep 17 00:00:00 2001 From: ZeeshanTamboli Date: Sun, 23 Jul 2023 18:01:42 +0530 Subject: [PATCH 02/12] prettier --- packages/mui-material/src/Typography/Typography.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/mui-material/src/Typography/Typography.js b/packages/mui-material/src/Typography/Typography.js index 967b21adab9a6f..625dbdfdb9a6e9 100644 --- a/packages/mui-material/src/Typography/Typography.js +++ b/packages/mui-material/src/Typography/Typography.js @@ -34,7 +34,7 @@ export const TypographyRoot = styled('span', { return [ styles.root, - ownerState&& styles[ownerState.variant], + ownerState && styles[ownerState.variant], ownerState.align !== 'inherit' && styles[`align${capitalize(ownerState.align)}`], ownerState.noWrap && styles.noWrap, ownerState.gutterBottom && styles.gutterBottom, @@ -44,7 +44,7 @@ export const TypographyRoot = styled('span', { })(({ theme, ownerState }) => ({ margin: 0, ...(ownerState.variant === 'inherit' && { - font: 'inherit' + font: 'inherit', }), ...(ownerState.variant !== 'inherit' && theme.typography[ownerState.variant]), ...(ownerState.align !== 'inherit' && { From 3b17f2574ca4a33f2ed813d9e643af42d07d99c1 Mon Sep 17 00:00:00 2001 From: ZeeshanTamboli Date: Sun, 23 Jul 2023 18:16:02 +0530 Subject: [PATCH 03/12] fix ownerState.variant --- packages/mui-material/src/Typography/Typography.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/mui-material/src/Typography/Typography.js b/packages/mui-material/src/Typography/Typography.js index 625dbdfdb9a6e9..8094e66534cbe4 100644 --- a/packages/mui-material/src/Typography/Typography.js +++ b/packages/mui-material/src/Typography/Typography.js @@ -34,7 +34,7 @@ export const TypographyRoot = styled('span', { return [ styles.root, - ownerState && styles[ownerState.variant], + ownerState.variant && styles[ownerState.variant], ownerState.align !== 'inherit' && styles[`align${capitalize(ownerState.align)}`], ownerState.noWrap && styles.noWrap, ownerState.gutterBottom && styles.gutterBottom, From 0e50e0d5fd511124bfac042de806b7b97059cdba Mon Sep 17 00:00:00 2001 From: Zeeshan Tamboli Date: Sun, 23 Jul 2023 19:49:54 +0530 Subject: [PATCH 04/12] Update packages/mui-material/src/Typography/Typography.js Co-authored-by: Olivier Tassinari Signed-off-by: Zeeshan Tamboli --- packages/mui-material/src/Typography/Typography.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/mui-material/src/Typography/Typography.js b/packages/mui-material/src/Typography/Typography.js index 8094e66534cbe4..679c343cf5fe56 100644 --- a/packages/mui-material/src/Typography/Typography.js +++ b/packages/mui-material/src/Typography/Typography.js @@ -44,6 +44,7 @@ export const TypographyRoot = styled('span', { })(({ theme, ownerState }) => ({ margin: 0, ...(ownerState.variant === 'inherit' && { + // Some elements, like