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

Make possible to overwrite the globally defined colors in PanelColorSettings #10457

Conversation

jorgefilipecosta
Copy link
Member

@jorgefilipecosta jorgefilipecosta commented Oct 9, 2018

This PR makes it possible to overwrite the globally defined colors (colors arrays and disableCustomColors) in PanelColorSettings.

The overwrite can be global for all the color panels of the component or local per each settings panel.

This PR makes sure that we offer all the functionality that the combination of wp.editor.PanelColor and wp.components.PanelColor had. Making it possible to deprecate these components and unify the color UI components. Deprecation PR created by @chrisvanpatten is available in #10391.

How has this been tested?

I checked that the blocks using colors (button, paragraph, pull quote still work as before).
I tried a theme that sets the colors or disables custom colors, and everything worked as before.
I created the test block available in https://gist.github.com/jorgefilipecosta/ac1d68e492869465b054868baac60df2 and checked that the definition overwrites specified were correctly applied.

@jorgefilipecosta jorgefilipecosta added [Type] Enhancement A suggestion for improvement. [Feature] Block API API that allows to express the block paradigm. labels Oct 9, 2018
@chrisvanpatten
Copy link
Contributor

Love love love it! Thanks @jorgefilipecosta!

@jorgefilipecosta jorgefilipecosta force-pushed the update/make-PanelColorSettings-accept-overwrite-of-colors branch 2 times, most recently from 1e8731f to 42b4476 Compare October 12, 2018 09:25
Copy link
Contributor

@talldan talldan left a comment

Choose a reason for hiding this comment

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

Thanks for pointing this out, Jorge! 😄 Looks like some really helpful changes.

`;

exports[`PanelColorSettings should render a color panel if at least one setting specifies some colors to choose 1`] = `
<Component
Copy link
Contributor

Choose a reason for hiding this comment

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

I noticed that the component used in the test is wrapped with ifCondition, which caused the shallow render to not render the children of PanelColorSettings (making the tests a bit obsolete). I found that you can use wrapper.dive() in enzyme to render the children, so I've pushed a commit with some additional snapshots.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thank you!

@@ -17,58 +17,107 @@ import ColorPaletteControl from '../color-palette/control';
import withColorContext from '../color-palette/with-color-context';
import { getColorObjectByColorValue } from '../colors';

const customColorsDisableForSetting = ( disableCustomColors, colorSetting ) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick: the name of this function could start with 'has' like the other two functions, and should probably use the adjective 'disabled' instead of the verb 'disable'.

jorgefilipecosta and others added 3 commits October 17, 2018 11:44
…ed colors settings (colors arrays and disableCustomColors) in PanelColorSettings.

The overwrite can be global for all the color panels of the component or local per each settings panel.
@jorgefilipecosta jorgefilipecosta force-pushed the update/make-PanelColorSettings-accept-overwrite-of-colors branch from 6719168 to 80184f8 Compare October 17, 2018 13:11
@jorgefilipecosta jorgefilipecosta added this to the 4.1 - UI freeze milestone Oct 17, 2018
@jorgefilipecosta jorgefilipecosta merged commit f5daf49 into master Oct 17, 2018
@jorgefilipecosta jorgefilipecosta deleted the update/make-PanelColorSettings-accept-overwrite-of-colors branch October 17, 2018 13:33
@chrisvanpatten
Copy link
Contributor

I'll update my deprecation PR for the correct version numbers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Block API API that allows to express the block paradigm. [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants