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] Add system props #24496

Merged
merged 27 commits into from
Jan 28, 2021
Merged

Conversation

mnajdova
Copy link
Member

@mnajdova mnajdova commented Jan 19, 2021

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
Copy link

mui-pr-bot commented Jan 19, 2021

@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

@@ -288,6 +288,23 @@ export interface CSSOthersObjectForCSSObject {
[propertiesName: string]: CSSInterpolation;
}

export type SystemProps = PropsFor<
Copy link
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.

@oliviertassinari oliviertassinari added the component: Typography The React component. label Jan 19, 2021
@@ -16,13 +16,9 @@ const DialogContentTextTest = () => {
<DialogContentText align="inherit" color="textPrimary" />
<DialogContentText align="inherit" color="textSecondary" />
<DialogContentText align="inherit" color="error" />
{/* @ts-expect-error */}
Copy link
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
Copy link
Member

@oliviertassinari oliviertassinari left a comment

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)

docs/src/pages/guides/migration-v4/migration-v4.md Outdated Show resolved Hide resolved
@oliviertassinari oliviertassinari added the new feature New feature or request label Jan 19, 2021
@mnajdova
Copy link
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 :)

@mnajdova mnajdova requested a review from eps1lon January 20, 2021 10:23
'textPrimary',
'textSecondary',
]),
color: PropTypes /* @typescript-to-proptypes-ignore */.any,
Copy link
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
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
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
Copy link
Member

eps1lon commented Jan 20, 2021

Looking at it right now

@eps1lon
Copy link
Member

eps1lon commented Jan 20, 2021

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
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
Copy link
Member

eps1lon commented Jan 21, 2021

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 component: Typography The React component. new feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants