-
-
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 color selector #12053
[docs] Add color selector #12053
Conversation
docs/src/pages/style/color/color.md
Outdated
|
||
<a href="https://material.io/tools/color/#!/?view.left=0&view.right=0&primary.color=3F51B5&secondary.color=F44336"> |
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.
Why removing this image? I find it complementary to the demo you added. It's providing context and guidance on how to use the tool.
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.
Because this tool effectively replaces it. We're linking to the general Material Design color section rather than their color tool. We don't need a picture of theirs alongside ours.
I did wonder if I should add something to display all the generated dark and light colors along those lines.
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.
Because this tool effectively replaces it
I don't think that the new tool answers the same problems. I don't see how it can be a replacement. Let me explain what I see.
tools/color provides:
- A official theme color picker
- A tool to help to pick accessible colors
- Force us to keep in sync with their palette model
the new demo provides:
- A way for users to see how the palette impacts all our components: solve [docs] Mapping color to components #2009
Vuetify has been trying to replace the official color picker, I don't think that it execute. I think that it's too much effort for the outcome. They would have been better off showing how to use the official pickers, a better output for less effort: https://vuetifyjs.com/en/theme-generator. At least, it's how I see it from an external point of vue view. @johnleider would you mind sharing your experience with the theme generator? :)
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 prefer to keep developers on the docs as much as possible. Our jobs as framework developers is to bring all the good important stuff to the front. As this is a visual demo, I find it has a lot of value. This is why we are rebuilding ours :)
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.
- So what?
- Wow, that accessibility tab has almost zero discoverability.
- How so?
As you know, I started with the ability to copy the URL from the MD color tool and paste it in a text field, but it was an extremely cumbersome way to try different color schemes with our components, hence the addition of the color pickers, to the point where I dropped the URL text field. I can add it back if you see value in it - but I'd love some analytics to see if it gets used!
Users can always populate the theme from the official color picker if they choose, and we can keep an explanation of that.
@johnleider Thanks for dropping by and sharing your view, you're doing awesome work over there!
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.
but I'd love some analytics to see if it gets used!
Good point, we can add one Google Analytics event.
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.
Users can always populate the theme from the official color picker if they choose, and we can keep an explanation of that.
As long as we have some documentation around how to do such, I'm happy!
@@ -125,7 +125,7 @@ export default function createPalette(palette: Object) { | |||
return contrastText; | |||
} | |||
|
|||
function augmentColor(color, mainShade, lightShade, darkShade) { | |||
function augmentColor(color, mainShade = 500, lightShade = 300, darkShade = 700) { |
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.
👍
@@ -33,7 +33,7 @@ export const style = theme => { | |||
root: { | |||
position: 'relative', | |||
width: '100%', | |||
margin: '10px 0', | |||
margin: '10px', |
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.
Why do we have a margin by default :o.
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 way the thumb is currently constructed, without it, the active thumb would overlap surrounding components. This was a quick fix for the horizontal overlap.
I guess it's tangentially related to #11889.
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.
Should we be using the padding instead? Using the margin is deceptive. One can't override it directly.
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.
Yeah, it's better that way.
docs/src/pages/style/color/color.md
Outdated
main: '#3f50b5', | ||
dark: '#002884', | ||
contrastText: '#fff', |
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.
Do we document this feature somewhere else?
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's covered in detail the "Themes" section, but we could add a note / cross reference here.
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.
Alright, then the only advantage is to illustrate how to use the output of material.io/tools/color/.
|
||
export default compose( | ||
withStyles(styles, { | ||
name: 'ColorChooser', |
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.
We most likely don't need to give the style sheet a name.
|
||
const ColorDemo = props => { | ||
const { classes, primary, theme, secondary } = props; | ||
theme.palette.augmentColor(primary); |
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.
Hum, this is not immutable.
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.
No, and it confused the heck out of me at first. It probably shouldn't have been added to the public API in that form (or written that way in the first place - my bad), but changing it now would be a breaking change.
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.
Yes, I screw up. We will sort that out in the next breaking change release. I'm keeping track of all the breaking changes we might introduce, I have 9 so far.
docs/src/pages/style/color/color.md
Outdated
main: '#3f50b5', | ||
dark: '#002884', | ||
contrastText: '#fff', |
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.
Alright, then the only advantage is to illustrate how to use the output of material.io/tools/color/.
@@ -33,7 +33,7 @@ export const style = theme => { | |||
root: { | |||
position: 'relative', | |||
width: '100%', | |||
margin: '10px 0', | |||
margin: '10px', |
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.
Should we be using the padding instead? Using the margin is deceptive. One can't override it directly.
@@ -1,6 +1,6 @@ | |||
import warning from 'warning'; | |||
import deepmerge from 'deepmerge'; // < 1kb payload overhead when lodash/merge is > 3kb. | |||
import indigo from '../colors/indigo'; | |||
import blue from '../colors/blue'; |
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.
👍
|
||
const shades = [900, 800, 700, 600, 500, 400, 300, 200, 100, 50, 'A700', 'A400', 'A200', 'A100']; | ||
|
||
export const styles = theme => ({ |
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.
No need to export the styles
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.
Oops no - same copypasta as the stylesheet naming :)
import actionTypes from 'docs/src/modules/redux/actionTypes'; | ||
import ColorDemo from './ColorDemo'; | ||
|
||
const hues = [ |
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.
Can you get this list out of Object.keys(colors)
?
secondaryShade: 11, | ||
}; | ||
|
||
hashPrefix = string => (string.charAt(0) === '#' ? string : `#${string}`); |
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.
Why using a class method over a function on the root scope?
|
||
hashPrefix = string => (string.charAt(0) === '#' ? string : `#${string}`); | ||
|
||
isRgb = string => /#?([0-9a-f]{6})/i.test(string); |
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.
Why using a class method over a function on the root scope?
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.
class methods can access the instance. I try to promote the function that doesn't need it to the top level to increase the isolation between the different sections of the code.
}); | ||
}; | ||
|
||
handleChangeDocsColors = values => { |
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.
handleChangeDocsColors = event => {
?
|
||
const ColorDemo = props => { | ||
const { classes, primary, theme, secondary } = props; | ||
theme.palette.augmentColor(primary); |
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.
Yes, I screw up. We will sort that out in the next breaking change release. I'm keeping track of all the breaking changes we might introduce, I have 9 so far.
export default compose( | ||
withStyles(styles, { | ||
name: 'ColorChooser', | ||
withTheme: true, |
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.
Dead code
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 layout of the Color tool demo is off for smaller screens. The new iteration on this pull request is really awesome 😍 !
<Tooltip id="appbar-color" title="Edit docs colors" enterDelay={300}> | ||
<IconButton | ||
color="inherit" | ||
href="/style/color/#color-tool" |
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.
Better use the next.js link. I can do it if you want.
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 tried, but it doesn't seem to respect the hash (or I"m doing it wrong). It links to the page, but not to the section. You have to click twice - once to go to the page, once to go to the section.:
<IconButton
color="inherit"
component={buttonProps => (
<Link variant="button" href="/style/color/#color-tool" {...buttonProps} />
)}
aria-labelledby="appbar-color"
>
}, | ||
}); | ||
|
||
const ColorDemo = props => { |
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 try to use function everywhere in the codebase for react components.
Add color swatches Checkmark for selected colors Fix imports Add shade slider basically working Fix indigo glitch
Does this make the code to dense / hard to read?
* [docs] Add color chooser Add color swatches Checkmark for selected colors Fix imports Add shade slider basically working Fix indigo glitch * Add ColorDemo component * Remove google color tool support * Fix TextField input * Rename ColorChooser to ColorTool * Improve the layout * Address the rest of Olivier's feedback * Add toolbar icon * Add docs-style-color to regression test blacklist * Optimize sample palette * Use MarkdownElement for code sample * Add dark / main / light colorBar * Display hex values in colorBar * fix code layout * Fix size limits * DRY the colorPicker Does this make the code to dense / hard to read? * Hacky fix for layout at small screen size * looking at the PR
Can someone link me to this page on the documentation? Thank you for this :) |
@artivilla You also have a new icon in the docs site Toolbar: |
Just to confirm, this only allows us to modify primary/secondary base colors? Not the entire theme file. |
@artivilla Exactly |
Customise the docs colors, and create palettes for use in
createMuiTheme()
.Closes #2009