-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
[docs] Add Joy default theme viewer #35554
Conversation
|
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.
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.
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'; | ||
} |
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.
Is there a way we could abstract https://github.com/mui/material-ui/blob/defd28e6dc56b136e7af38331c129a3d15006f43/docs/data/material/customization/default-theme/DefaultTheme.js so we don't duplicate the logic?
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.
Sure, it can be extracted.
test/regressions/index.js
Outdated
'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', |
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.
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.
'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', |
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.
I don't see a value in having visual regression for the theme tokens. I will add comments on them.
Agree! |
@siriwatknp What's your take on pushing this direction a few extra steps? We could imagine that:
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. |
No objection. @oliviertassinari For the |
…default-theme-explorer
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. |
…default-theme-explorer
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.
Very cool 👍
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.
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?
Sounds good to me.
Feel free to tweak the colors.
Got it, will update them.
I think |
…default-theme-explorer
…terial-ui into joy/default-theme-explorer
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.
Great job @siriwatknp! My comments are mostly all small grammar stuff.
Co-authored-by: Sam Sycamore <[email protected]> Signed-off-by: Siriwat K <[email protected]>
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.
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"}} |
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.
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
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.
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.
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.
Text content looks great! 👍
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.
…default-theme-explorer
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
light
anddark
previews at the same time.