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

ColorPalette: Make selected color more obvious #20258

Merged

Conversation

johnwatkins0
Copy link
Member

Description

This would resolve #17332. Currently when selecting a color from the ColorPalette it can be hard to tell which color you have selected:

64284216-11c04c00-cf27-11e9-8aaa-2dbbd4e3e398

This is especially true working with the Text Color format, which doesn't have the "Background Color" indicator that appears other places.

This update adds a new selectedIconProps prop to the CircularOptionPicker. This allows extra props to be passed to the check icon that shows over the selected color. We then use this prop to pass down style overrides from the ColorPalette component. The style override uses the tinycolor mostReadable function to determine whether the icon should be white or dark gray.

How has this been tested?

Ran Jest tests, which passed when snapshots were updated. Tested locally in the browser using several components that use the ColorPalette, including the table block and pull quote block.

Screenshots

After:

color-picker

Types of changes

This is a backward-compatible improvement to the display of the color picker.

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR.

@johnwatkins0 johnwatkins0 reopened this Feb 17, 2020
@youknowriad youknowriad added the Needs Design Feedback Needs general design feedback. label Feb 17, 2020
value === color
? {
fill: tinycolor
.mostReadable( color, [ '#111', '#fff' ] )
Copy link
Member

Choose a reason for hiding this comment

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

Should we use #000 instead? cc @jasmussen

Copy link
Contributor

Choose a reason for hiding this comment

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

We should. How much more black could it be? And the answer is none. None more black.

Copy link
Member Author

Choose a reason for hiding this comment

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

👍 Updated.

@mtias mtias added the [Feature] UI Components Impacts or related to the UI component system label Feb 17, 2020
@karmatosed
Copy link
Member

Looks great to me. I will remove the feedback label as this works well. Thanks for this @johnwatkins0. It will need a code review but once gets that let's merge!

@karmatosed karmatosed removed the Needs Design Feedback Needs general design feedback. label Feb 17, 2020
Copy link
Contributor

@youknowriad youknowriad left a comment

Choose a reason for hiding this comment

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

selectedIconProps prop seems like a too specific prop (design prop) that is not very semantic for the component's API. That said, since this is an internal component, it's not that important especially cause I'm having trouble finding a better alternative.

@youknowriad youknowriad merged commit 6d17dea into WordPress:master Feb 18, 2020
@github-actions github-actions bot added this to the Gutenberg 7.6 milestone Feb 18, 2020
@mtias
Copy link
Member

mtias commented Feb 18, 2020

Agree on the prop, also seems like it shouldn't be computed so high up the chain.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] UI Components Impacts or related to the UI component system
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consider revising the color swatch states.
5 participants