Skip to content

[Typography] Add system props#24496

Merged
mnajdova merged 27 commits into
mui:nextfrom
mnajdova:feat/typography-system-props
Jan 28, 2021
Merged

[Typography] Add system props#24496
mnajdova merged 27 commits into
mui:nextfrom
mnajdova:feat/typography-system-props

Conversation

@mnajdova

@mnajdova mnajdova commented Jan 19, 2021

Copy link
Copy Markdown
Member

BREAKING CHANGES

The following classes and style overrides keys were removed: "colorInherit", "colorPrimary", "colorSecondary", "colorTextPrimary", "colorTextSecondary", "colorError", "displayInline" and "displayBlock". These props are now considered part of the system, not on the Typography component itself. If you still wish to add overrides for them, you can use the theme.components.MuiTypography.variants options. For example

const theme = createMuiTheme({
  components: {
    MuiTypography: {
-     styleOverrides: {
-       colorSecondary: {
-         marginTop: '20px',
-       },
-     },
+     variants: {
+       props: { color: "secondary" },
+       style: {
+         marginTop: '20px',
+       },
+     }],
    },
  },
});

This PR introduces the system props on the Typography component. In order for avoiding breaking changes on the color prop (which existed before on the component and is part of the system), the previous values are still supported in addition to the system values that the color prop can have. The display property was replaced in favor of the display property of the system, as the behavior should be completely identical.

Another iteration on #24485

@mui-pr-bot

mui-pr-bot commented Jan 19, 2021

Copy link
Copy Markdown

@material-ui/core: parsed: -0.09% 😍, gzip: -0.07% 😍
@material-ui/lab: parsed: -0.10% 😍, gzip: -0.06% 😍

Details of bundle changes

Generated by 🚫 dangerJS against a030c46

[propertiesName: string]: CSSInterpolation;
}

export type SystemProps = PropsFor<

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extracted so that the typings can be used in both the Box, Typogrpahy and the other CSS components we'll introduce.

Comment thread packages/material-ui/src/Typography/Typography.js
Comment thread docs/src/pages/guides/migration-v4/migration-v4.md Outdated
@oliviertassinari oliviertassinari added the scope: typography Changes related to typography. label Jan 19, 2021
Comment thread docs/src/pages/guides/migration-v4/migration-v4.md Outdated
Comment thread packages/material-ui/src/Typography/Typography.js
Comment thread docs/src/pages/guides/migration-v4/migration-v4.md Outdated
<DialogContentText align="inherit" color="textPrimary" />
<DialogContentText align="inherit" color="textSecondary" />
<DialogContentText align="inherit" color="error" />
{/* @ts-expect-error */}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like the system props are a bit too relaxed and cannot catch these errors :\

@mnajdova
mnajdova marked this pull request as ready for review January 19, 2021 16:32
@oliviertassinari oliviertassinari added the breaking change Introduces changes that are not backward compatible. label Jan 19, 2021

@oliviertassinari oliviertassinari left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we can migrate the usages of the component in the codebase in a different iteration? (Both for Box and Typography)

Comment thread docs/src/pages/guides/migration-v4/migration-v4.md Outdated
@oliviertassinari oliviertassinari added the type: new feature Expand the scope of the product to solve a new problem. label Jan 19, 2021
Comment thread docs/src/pages/guides/migration-v4/migration-v4.md Outdated
@mnajdova

Copy link
Copy Markdown
Member Author

I guess we can migrate the usages of the component in the codebase in a different iteration? (Both for Box and Typography)

Definitelly, didn't want to do all those changes in just one PR :)

Comment thread packages/material-ui/src/CardHeader/CardHeader.test.js Outdated
Comment thread packages/material-ui/src/CardHeader/CardHeader.test.js Outdated
@mnajdova
mnajdova requested a review from eps1lon January 20, 2021 10:23
'textPrimary',
'textSecondary',
]),
color: PropTypes /* @typescript-to-proptypes-ignore */.any,

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mnajdova

Copy link
Copy Markdown
Member Author

I don't understand why this started failing now - https://app.circleci.com/pipelines/github/mui-org/material-ui/36615/workflows/0ea8cae7-7ee2-4350-881b-06df6d568b69/jobs/217634 it's related to the typings of the LinkProps. As far as I understand the OverrideProps should add the component prop.

@mnajdova

Copy link
Copy Markdown
Member Author

I don't understand why this started failing now - https://app.circleci.com/pipelines/github/mui-org/material-ui/36615/workflows/0ea8cae7-7ee2-4350-881b-06df6d568b69/jobs/217634 it's related to the typings of the LinkProps. As far as I understand the OverrideProps should add the component prop.

@oliviertassinari @eps1lon I could use some help here. I spend 40 mins trying to understand what is happening but with no success 😞

@eps1lon

eps1lon commented Jan 20, 2021

Copy link
Copy Markdown
Member

Looking at it right now

@eps1lon

eps1lon commented Jan 20, 2021

Copy link
Copy Markdown
Member

I can't find any mention of what the plan for the color prop is. You're saying your just adding the system props but you didn't explain what happens with the props that already exist on Typography and are implemented differently in the system props. For reviewability please use PR descriptions to summarize your work.

Typography is extended by a lot of other components so just changing how color works isn't trivial. At least not for me and considering CI is failing it's not trivial for you either.

@mnajdova

Copy link
Copy Markdown
Member Author

I can't find any mention of what the plan for the color prop is. You're saying your just adding the system props but you didn't explain what happens with the props that already exist on Typography and are implemented differently in the system props. For reviewability please use PR descriptions to summarize your work.

Typography is extended by a lot of other components so just changing how color works isn't trivial. At least not for me and considering CI is failing it's not trivial for you either.

I should have explained the breaking changes for the classes in the PR description, my bad will do it. Regarding the color prop, with https://github.com/mui-org/material-ui/pull/24496/files#diff-e28433586a43ba335e74439005786b53bce7291ed0e5062a5a13d8254775c9ebR79 I've added backward compatibility for the colors we had before. The plan is to keep this working as it was before and in the next major version v5.x deprecate the support for these custom colors and remove the transformation in v6, so basically this change regarding the color prop should not be breaking at this moment (typings should be just relaxed in terms of changes).

@github-actions github-actions Bot added the PR: out-of-date The pull request has merge conflicts and can't be merged. label Jan 21, 2021
@github-actions github-actions Bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged. label Jan 21, 2021
@eps1lon

eps1lon commented Jan 21, 2021

Copy link
Copy Markdown
Member

The autocomplete for the previously known color values is lost at the moment. Are unknown values for color currently accepted? That creates two problems:

  • no static safety against wrong values
  • worse migration story in the future when we change these values

@oliviertassinari
oliviertassinari force-pushed the feat/typography-system-props branch from 50a84c3 to 659b8ea Compare January 27, 2021 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking change Introduces changes that are not backward compatible. scope: typography Changes related to typography. type: new feature Expand the scope of the product to solve a new problem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants