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

[docs] Update custom Typography variants example #36185

Merged
merged 3 commits into from Feb 17, 2023

Conversation

mj12albert
Copy link
Member

@mj12albert mj12albert commented Feb 14, 2023

Follow up to: #36005 (comment)

Preview: https://deploy-preview-36185--material-ui.netlify.app/material-ui/customization/typography/#adding-amp-disabling-variants

This PR expands a little more on how to add custom Typography variants to material-ui.

I am assuming that its very likely a user would want to (or want to know how to) specify the default HTML element for custom Typography variants if they are on this part of the docs, and it's not obvious (at least I completely missed it 🀦 ) that this is the way to do it until Jun pointed it out.

The most related existing doc about this is here but it's not linked to from that page, and doesn't directly address using variantMapping and custom variants together – also I think a page called "Customization/Typography" should be a one-stop shop for all of this instead of having to hop to another page!

@mj12albert mj12albert added docs Improvements or additions to the documentation component: Typography The React component. labels Feb 14, 2023
@mui-bot
Copy link

mui-bot commented Feb 14, 2023

@mj12albert mj12albert force-pushed the docs/material-ui-typography branch 5 times, most recently from cec67ed to e628a79 Compare February 14, 2023 17:48
@mj12albert mj12albert marked this pull request as ready for review February 14, 2023 18:33
Copy link
Member

@samuelsycamore samuelsycamore left a comment

Choose a reason for hiding this comment

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

I love to see improvements to the docs like this! 🀩 Keep them coming @mj12albert ! My review is all related to style. Let me know if you have any questions about style rules and best practices. :)

@mj12albert mj12albert force-pushed the docs/material-ui-typography branch 2 times, most recently from e31d02b to 126a111 Compare February 15, 2023 19:30
@mj12albert
Copy link
Member Author

Updated – thanks for the suggestions @samuelsycamore !

Comment on lines 20 to 32
// we have to provide the default variantMapping first because currently
// custom entries will replace this whole object instead of being merged
h1: 'h1',
h2: 'h2',
h3: 'h3',
h4: 'h4',
h5: 'h5',
h6: 'h6',
subtitle1: 'h6',
subtitle2: 'h6',
body1: 'p',
body2: 'p',
inherit: 'p',
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// we have to provide the default variantMapping first because currently
// custom entries will replace this whole object instead of being merged
h1: 'h1',
h2: 'h2',
h3: 'h3',
h4: 'h4',
h5: 'h5',
h6: 'h6',
subtitle1: 'h6',
subtitle2: 'h6',
body1: 'p',
body2: 'p',
inherit: 'p',

After checking the implementation, these lines are not needed.

Here is the proof: https://codesandbox.io/s/naughty-ives-5vorcl?file=/demo.tsx

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for double checking ~ I see it falls back to the default variantMapping here

Copy link
Member

@samuelsycamore samuelsycamore left a comment

Choose a reason for hiding this comment

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

Text looks good! πŸ‘

Copy link
Member

@siriwatknp siriwatknp left a comment

Choose a reason for hiding this comment

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

πŸ‘ Love to see docs improvement!

@mj12albert mj12albert merged commit 4a93ec7 into mui:master Feb 17, 2023
@mj12albert mj12albert deleted the docs/material-ui-typography branch February 17, 2023 04:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: Typography The React component. docs Improvements or additions to the documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants