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] Add Joy default theme viewer #35554

Merged
merged 44 commits into from
Jan 24, 2023

Conversation

siriwatknp
Copy link
Member

@siriwatknp siriwatknp commented Dec 21, 2022

close #35707

Preview: https://deploy-preview-35554--material-ui.netlify.app/joy-ui/customization/default-theme-viewer/
Theme colors: https://deploy-preview-35554--material-ui.netlify.app/joy-ui/customization/theme-colors/
Theme shadows: https://deploy-preview-35554--material-ui.netlify.app/joy-ui/customization/theme-shadow/

Got feedback from the community that the table view is better than the tree view.

Some improvements

  • split "theme tokens" into "theme colors" and "theme shadow"
  • able to see light and dark previews at the same time.
  • extra info is added to some tokens via tooltip

@siriwatknp siriwatknp added the docs Improvements or additions to the documentation label Dec 21, 2022
@mui-bot
Copy link

mui-bot commented Dec 21, 2022

Messages
📖 Netlify deploy preview: https://deploy-preview-35554--material-ui.netlify.app/

No bundle size changes

Generated by 🚫 dangerJS against 815a227

@siriwatknp siriwatknp requested a review from a team December 22, 2022 07:06
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.

Comment on lines 1 to 22
import * as React from 'react';
import clsx from 'clsx';
import PropTypes from 'prop-types';
import { extendTheme, styled } from '@mui/joy/styles';
import Box from '@mui/joy/Box';
import ExpandIcon from '@mui/icons-material/ExpandMore';
import CollapseIcon from '@mui/icons-material/ChevronRight';
import TreeView from '@mui/lab/TreeView';
import MuiTreeItem, { treeItemClasses } from '@mui/lab/TreeItem';
import { lighten, ThemeProvider, createTheme } from '@mui/material/styles';

/**
* @param {unknown} value
*/
function getType(value) {
if (Array.isArray(value)) {
return 'array';
}

if (/^(#|rgb|rgba|hsl|hsla)/.test(value)) {
return 'color';
}
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, it can be extracted.

Comment on lines 30 to 34
'docs-joy-getting-started-templates/TemplateCollection.png',
'docs-joy-core-features-automatic-adjustment/ListThemes.png',
'docs-joy-tools/PaletteThemeViewer.png',
'docs-joy-tools/ShadowThemeViewer.png',
'docs-joy-tools/TypographyThemeViewer.png',
Copy link
Member

Choose a reason for hiding this comment

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

It would be great if we add a motive on why we blacklist them. Outside of the first one, the other seems valuable, not sure.

Suggested change
'docs-joy-getting-started-templates/TemplateCollection.png',
'docs-joy-core-features-automatic-adjustment/ListThemes.png',
'docs-joy-tools/PaletteThemeViewer.png',
'docs-joy-tools/ShadowThemeViewer.png',
'docs-joy-tools/TypographyThemeViewer.png',
'docs-joy-getting-started-templates/TemplateCollection.png', // No public components
'docs-joy-core-features-automatic-adjustment/ListThemes.png',
'docs-joy-tools/PaletteThemeViewer.png',
'docs-joy-tools/ShadowThemeViewer.png',
'docs-joy-tools/TypographyThemeViewer.png',

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't see a value in having visual regression for the theme tokens. I will add comments on them.

@oliviertassinari oliviertassinari added the package: joy-ui Specific to @mui/joy label Dec 22, 2022
@siriwatknp
Copy link
Member Author

Nice to see more docs. I wonder if it would make more sense to have https://deploy-preview-35554--material-ui.netlify.app/joy-ui/tools/default-theme-viewer/#typography inside https://deploy-preview-35554--material-ui.netlify.app/joy-ui/customization/theme-typography/ the information seems to duplicate.

Agree!

@oliviertassinari
Copy link
Member

Agree

@siriwatknp What's your take on pushing this direction a few extra steps? We could imagine that:

  1. https://deploy-preview-35554--material-ui.netlify.app/joy-ui/tools/default-theme-viewer/ would only be about the "Explore" header
  2. that "Palette" and "Shadow" could be moved under:

Screenshot 2023-01-01 at 21 09 50

We could also update Material UI sidenav to have clearer title. I like how "Theme typography" is clear. We had many people ask why is there 3 "Typography" pages (theme, component, system) in the past.

@siriwatknp
Copy link
Member Author

that "Palette" and "Shadow" could be moved under:

No objection.

@oliviertassinari For the Default theme viewer, do you think it should live under Customization? I plan to add Theme builder in the next PR, that's why I created the Tools section. cc @samuelsycamore any thoughts on this?

@siriwatknp siriwatknp self-assigned this Jan 3, 2023
@mapache-salvaje
Copy link
Contributor

@oliviertassinari For the Default theme viewer, do you think it should live under Customization? I plan to add Theme builder in the next PR, that's why I created the Tools section. cc @samuelsycamore any thoughts on this?

That is an interesting consideration. From a user's perspective, I think it makes more sense to find these "tools" in the "Customization" section. I do like the idea of a "Tools" section, but I can't think of any examples where I've seen this in other docs. I imagine the difference between a "tool" doc and a "customization" doc could get blurry—the tool is aimed at improving the customization experience, so it fits in both places.

@siriwatknp
Copy link
Member Author

@oliviertassinari For the Default theme viewer, do you think it should live under Customization? I plan to add Theme builder in the next PR, that's why I created the Tools section. cc @samuelsycamore any thoughts on this?

That is an interesting consideration. From a user's perspective, I think it makes more sense to find these "tools" in the "Customization" section. I do like the idea of a "Tools" section, but I can't think of any examples where I've seen this in other docs. I imagine the difference between a "tool" doc and a "customization" doc could get blurry—the tool is aimed at improving the customization experience, so it fits in both places.

👍 Alright, I will go with customization for consistency.

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.

Very cool 👍

Copy link
Contributor

@danilo-leal danilo-leal left a comment

Choose a reason for hiding this comment

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

Ah, sweet! This is very, very cool and for sure a useful tool for folks navigating through Joy! I particularly enjoyed the tooltips on the typography table 👨‍🍳

I'm still looking forward to doing some further design explorations on the tables before merging this PR but to give already some feedback, here are a couple of things I've thought about:

  • Maybe we could create a sub-section within Customization, similar to the "Migration" and "Upgrade to v5" in Material UI?! That's to save the number of repeated "Theme" in the side nav. The page titles could still remain "Theme color".
  • There are some color/interaction improvements to do on the table, such as the gray hover clashing a bit with the blue bg on dark mode (hence the explorations with a subtler dark mode). Also adding some slight background to the table itself.
  • Use a monospace font whenever adding code snippets, such as the token value.
  • Curious to hear thoughts about maintaining both the theme object-specific pages (e.g. shadow, typography, etc) and the "Default theme viewer" one with everything. Does it make sense to have both or should we do one or another?

@siriwatknp
Copy link
Member Author

siriwatknp commented Jan 9, 2023

Maybe we could create a sub-section within Customization, similar to the "Migration" and "Upgrade to v5" in Material UI?! That's to save the number of repeated "Theme" in the side nav. The page titles could still remain "Theme color".

Sounds good to me.

There are some color/interaction improvements to do on the table, such as the gray hover clashing a bit with the blue bg on dark mode (hence the explorations with a subtler dark mode). Also adding some slight background to the table itself.

Feel free to tweak the colors.

Use a monospace font whenever adding code snippets, such as the token value.

Got it, will update them.

Curious to hear thoughts about maintaining both the theme object-specific pages (e.g. shadow, typography, etc) and the "Default theme viewer" one with everything. Does it make sense to have both or should we do one or another?

I think Default theme viewer is useful for me to see the whole thing of what the default theme looks like. Maintaining it should be fine since it is reading values from the source code (no hard-coded).

Copy link
Contributor

@mapache-salvaje mapache-salvaje left a comment

Choose a reason for hiding this comment

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

Great job @siriwatknp! My comments are mostly all small grammar stuff.

docs/data/joy/customization/theme-colors/theme-colors.md Outdated Show resolved Hide resolved
docs/data/joy/customization/theme-colors/theme-colors.md Outdated Show resolved Hide resolved
docs/data/joy/customization/theme-colors/theme-colors.md Outdated Show resolved Hide resolved
docs/data/joy/customization/theme-colors/theme-colors.md Outdated Show resolved Hide resolved
docs/data/joy/customization/theme-colors/theme-colors.md Outdated Show resolved Hide resolved
docs/data/joy/customization/theme-shadow/theme-shadow.md Outdated Show resolved Hide resolved
docs/data/joy/customization/theme-shadow/theme-shadow.md Outdated Show resolved Hide resolved
docs/data/joy/customization/theme-shadow/theme-shadow.md Outdated Show resolved Hide resolved
docs/data/joy/customization/theme-shadow/theme-shadow.md Outdated Show resolved Hide resolved
docs/data/joy/customization/theme-shadow/theme-shadow.md Outdated Show resolved Hide resolved
Copy link
Member

@mnajdova mnajdova left a comment

Choose a reason for hiding this comment

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

Another idea for the palette maybe we can use some illustration closer to how it is done in the Material Design spec, something like:

image

The table below lists all the default tokens and their values in light and dark color schemes.
Some tokens reuse values from other tokens using the [`var(--*)`](https://developer.mozilla.org/en-US/docs/Web/CSS/var) syntax.

{{"demo": "PaletteThemeViewer.js", "bg": "inline"}}
Copy link
Member

Choose a reason for hiding this comment

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

I would recommend using the colors as a background on the cells, and allow copying the token when clicking/hovering over the cell. Once upon a time I was doing something like this for Fluent UI, I managed to find a link to it :D: https://fluentsite.z22.web.core.windows.net/0.65.0/color-schemes

Copy link
Member Author

Choose a reason for hiding this comment

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

I would recommend using the colors as a background on the cells

Honestly, I don't think this would be that much different from the current look and I guess it needs JS to calculate the correct contrast (between white and black text color).

and allow copying the token when clicking/hovering over the cell

Yep, this would be useful.

Copy link
Contributor

@mapache-salvaje mapache-salvaje left a comment

Choose a reason for hiding this comment

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

Text content looks great! 👍

Copy link
Member

@mnajdova mnajdova left a comment

Choose a reason for hiding this comment

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

There is a bug with how the copy button is hidden, which causes showing two scrollbars:

Also, when you click to copy a color there is a layout shift because of the two scrollbars being shown/hidden.

@siriwatknp siriwatknp merged commit 5717d16 into mui:master Jan 24, 2023
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: joy-ui Specific to @mui/joy
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Joy][Colors] Provide (docs on) extendable color system
7 participants