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][material] Improve documentation about adding custom colors #37743

Merged
merged 22 commits into from
Jul 21, 2023

Conversation

DiegoAndai
Copy link
Member

@DiegoAndai DiegoAndai commented Jun 27, 2023

Closes: #29595

Summary

Improve documentation regarding adding new colors using a color object:

  • Clearly indicate that for custom colors the light, dark, and contrastText tokens are required and not calculated automatically, which differs from default colors.
  • Add an example of how to use the augmentColor function to augment custom colors.
  • Fix examples so custom colors have all the required tokens

Note

I also wanted to improve the warning/error that users would get when using a component that requires light, dark, or contrastText (see the Chip's contrastText issue: #37676). But after a second thought, it seemed very cumbersome and overhead to do given the small use case for which the warning would be helpful.

If you disagree and think it would be worth it, I would love to discuss approaches to adding the warning 😊 cc: @mui/core

@DiegoAndai DiegoAndai self-assigned this Jun 27, 2023
@danilo-leal danilo-leal added docs Improvements or additions to the documentation package: material-ui Specific to @mui/material labels Jun 27, 2023
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.

Great addition @DiegoAndai ! My comments here are mostly about style and structure.

docs/data/material/customization/palette/palette.md Outdated Show resolved Hide resolved
docs/data/material/customization/palette/palette.md Outdated Show resolved Hide resolved
docs/data/material/customization/palette/palette.md Outdated Show resolved Hide resolved
docs/data/material/customization/palette/palette.md Outdated Show resolved Hide resolved
docs/data/material/customization/palette/palette.md Outdated Show resolved Hide resolved
docs/data/material/customization/palette/palette.md Outdated Show resolved Hide resolved
docs/data/material/customization/palette/palette.md Outdated Show resolved Hide resolved
docs/data/material/customization/palette/palette.md Outdated Show resolved Hide resolved
docs/data/material/customization/palette/palette.md Outdated Show resolved Hide resolved
DiegoAndai and others added 7 commits June 29, 2023 17:21
Co-authored-by: Sam Sycamore <71297412+samuelsycamore@users.noreply.github.com>
Signed-off-by: Diego Andai <diego@mui.com>
Co-authored-by: Sam Sycamore <71297412+samuelsycamore@users.noreply.github.com>
Signed-off-by: Diego Andai <diego@mui.com>
Co-authored-by: Sam Sycamore <71297412+samuelsycamore@users.noreply.github.com>
Signed-off-by: Diego Andai <diego@mui.com>
Co-authored-by: Sam Sycamore <71297412+samuelsycamore@users.noreply.github.com>
Signed-off-by: Diego Andai <diego@mui.com>
@DiegoAndai
Copy link
Member Author

After @samuelsycamore's feedback, I started reworking some examples and concluded that the palette docs needed a reorganization. Related information was scattered and the structure wasn't easy-to-follow. Here are the changes I introduced:

  • Add color tokens section
  • Separate default colors and custom colors sections, turn examples into live demos rather than static code and have one atomic example for each piece of information rather than big examples
  • Add explanation and examples for contrast threshold, tonal offset, and adding new color tokens
  • Link non-palette colors to custom variables docs, as the information was duplicated

I was very cautious of not removing anything, but rather reorganizing. Everything that was there is still there, except for the non-palette colors explanation as that was redirected to custom variables.

Notes

  • I recommend checking the deploy preview first when reviewing and comparing it to the actual palette docs
  • The buttons and mui-core-v5 blog changes were due to the removal of the #adding-new-colors section, and were redirected to the #custom-colors section
  • I Disabled formatedTSDemos for the palette page. I did it because it was forcing the preview of the examples to be the examples returned JSX, but for these examples, the theme creation section of the code is the important information.

@mj12albert
Copy link
Member

@DiegoAndai The demos look great!

Screenshot 2023-07-06 at 6 35 30 PM

I noticed that the text lists the colors in the order main, light, dark, but the actual demo code the order is light, main, dark – maybe it would be clearest to label the little color chips as well ~

@DiegoAndai DiegoAndai changed the title [docs] Improve documentation about adding custom colors [Material][docs] Improve documentation about adding custom colors Jul 7, 2023
@DiegoAndai DiegoAndai changed the title [Material][docs] Improve documentation about adding custom colors [docs][material] Improve documentation about adding custom colors Jul 10, 2023
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.

Sorry it took me so long to get to this @DiegoAndai ! This is a major improvement for sure. The vast majority of my suggestions here are for copy editing, style, and grammar. We should make sure that the hierarchy of headers and subheaders makes sense in the final draft.

docs/data/material/customization/palette/palette.md Outdated Show resolved Hide resolved
docs/data/material/customization/palette/palette.md Outdated Show resolved Hide resolved
docs/data/material/customization/palette/palette.md Outdated Show resolved Hide resolved
docs/data/material/customization/palette/palette.md Outdated Show resolved Hide resolved
docs/data/material/customization/palette/palette.md Outdated Show resolved Hide resolved
docs/data/material/customization/palette/palette.md Outdated Show resolved Hide resolved
docs/data/material/customization/palette/palette.md Outdated Show resolved Hide resolved
docs/data/material/customization/palette/palette.md Outdated Show resolved Hide resolved
docs/data/material/customization/palette/palette.md Outdated Show resolved Hide resolved
docs/data/material/customization/palette/palette.md Outdated Show resolved Hide resolved
DiegoAndai and others added 3 commits July 19, 2023 13:37
Co-authored-by: Sam Sycamore <71297412+samuelsycamore@users.noreply.github.com>
Signed-off-by: Diego Andai <diego@mui.com>
Co-authored-by: Sam Sycamore <71297412+samuelsycamore@users.noreply.github.com>
Signed-off-by: Diego Andai <diego@mui.com>
Co-authored-by: Sam Sycamore <71297412+samuelsycamore@users.noreply.github.com>
Signed-off-by: Diego Andai <diego@mui.com>
DiegoAndai and others added 8 commits July 19, 2023 13:39
Co-authored-by: Sam Sycamore <71297412+samuelsycamore@users.noreply.github.com>
Signed-off-by: Diego Andai <diego@mui.com>
Co-authored-by: Sam Sycamore <71297412+samuelsycamore@users.noreply.github.com>
Signed-off-by: Diego Andai <diego@mui.com>
Co-authored-by: Sam Sycamore <71297412+samuelsycamore@users.noreply.github.com>
Signed-off-by: Diego Andai <diego@mui.com>
Co-authored-by: Sam Sycamore <71297412+samuelsycamore@users.noreply.github.com>
Signed-off-by: Diego Andai <diego@mui.com>
Co-authored-by: Sam Sycamore <71297412+samuelsycamore@users.noreply.github.com>
Signed-off-by: Diego Andai <diego@mui.com>
@DiegoAndai
Copy link
Member Author

Hey @samuelsycamore and @mj12albert! thanks for the feedback, I implemented it and it's ready for your re-review

@samuelsycamore regarding this comment, maybe we could just list the colors and then link to Material's Color System for the explanations?

@samuelsycamore
Copy link
Member

@samuelsycamore regarding this comment, maybe we could just list the colors and then link to Material's Color System for the explanations?

That sounds good to me. Go for it! 🤝

@DiegoAndai
Copy link
Member Author

@samuelsycamore I reworded the color's descriptions to be shorter and added a link to Material's Color System, let me know what you think 😊

Copy link
Member

@mj12albert mj12albert left a comment

Choose a reason for hiding this comment

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

Looks great!

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.

LGTM! 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Improvements or additions to the documentation package: material-ui Specific to @mui/material
Projects
Status: Recently completed
Development

Successfully merging this pull request may close these issues.

[Palette] Custom palette with main color provided, other colors is not calculated
5 participants