-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Typography] Improve custom component types support (#18868)
- Loading branch information
1 parent
c77c2e8
commit b6ff4f5
Showing
2 changed files
with
67 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import React, { FC } from 'react'; | ||
import { Typography } from '@material-ui/core'; | ||
|
||
const TypographyTest = () => { | ||
const CustomComponent: React.FC<{ prop1: string; prop2: number }> = () => <div />; | ||
return ( | ||
<div> | ||
<Typography /> | ||
<Typography align="inherit" color="inherit" display="block" /> | ||
<Typography align="left" color="initial" display="inline" /> | ||
<Typography align="right" color="primary" display="initial" /> | ||
<Typography align="justify" color="secondary" display="initial" /> | ||
<Typography align="inherit" color="textPrimary" /> | ||
<Typography align="inherit" color="textSecondary" /> | ||
<Typography align="inherit" color="error" /> | ||
// $ExpectError | ||
<Typography display="incorrectValue" /> | ||
<Typography component="a" href="url" display="block" /> | ||
<Typography component="label" htmlFor="html" display="block" /> | ||
// $ExpectError | ||
<Typography component="a" href="url" display="incorrectValue" /> | ||
// $ExpectError | ||
<Typography component="a" incorrectAttribute="url" /> | ||
// $ExpectError | ||
<Typography component="incorrectComponent" href="url" /> | ||
// $ExpectError | ||
<Typography component="div" href="url" /> | ||
// $ExpectError | ||
<Typography href="url" /> | ||
<Typography component={CustomComponent} prop1="1" prop2={12} /> | ||
// $ExpectError | ||
<Typography component={CustomComponent} prop1="1" prop2={12} id="1" /> | ||
// $ExpectError | ||
<Typography component={CustomComponent} prop1="1" /> | ||
// $ExpectError | ||
<Typography component={CustomComponent} prop1="1" prop2="12" /> | ||
</div> | ||
); | ||
}; |
b6ff4f5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fyodore82 @oliviertassinari this change is not in the docs, took quite a while to find the change.
b6ff4f5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@edgarjrg , please take a look here.
It is pretty well described.
b6ff4f5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fyodore82 @oliviertassinari in version v4.7.2, the below used to work:
Somewhere after (4.8.3 o 4.9.5), it broke due to this PR removing the component as an explicit prop of Typography.
Was that a planned breaking change?
I reckon we'd need to do something like below to get that back to working. Happy to submit a PR if you guys think that's the right approach; otherwise, can you please suggest how to use
component
prop for Typography on the CardHeader? Also, is there any other component that has the typography props that would need to get updated?To speed up things, I went ahead and opened a PR
b6ff4f5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rart , this is related to all components which depends on
TypographyProps
. About a month ago I've opened the pull request to fix this forListItemText
. But it is still under review.If it will be merged, the same solution can be applied to all other components (including
CardHeader