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

Implemented color class mechanism in button. #6422

Merged
merged 1 commit into from
Apr 27, 2018

Conversation

jorgefilipecosta
Copy link
Member

@jorgefilipecosta jorgefilipecosta commented Apr 25, 2018

Description

This PR makes button block use classes for colors that are pre-specified in the palette. No visual changes should be expected.

How has this been tested?

Test the following actions in a theme that does not set the color palette (Gutenberg default is used):

  1. Add a button block, change colors of background and or text to colors from the palette.
  2. Add a button block, change colors of background and or text to custom colors.
  3. Verify in the code view that for the first case classes were used to set the color and in the second case inline styles were used to set the color.
  4. Save the post see and see it display correctly on the frontend.

Test the following actions in a theme that sets the color palette in the old mechanism without names and classes:

  1. Add a button block, change colors of background and or text to colors from the palette.
  2. Add a button block, change colors of background and or text to custom colors.
  3. Verify in the code view that for both cases inline styles were used.
  4. Save the post see and see it display correctly on the frontend.

@jorgefilipecosta jorgefilipecosta added the [Type] Enhancement A suggestion for improvement. label Apr 25, 2018
@jorgefilipecosta jorgefilipecosta self-assigned this Apr 25, 2018
@jorgefilipecosta jorgefilipecosta requested a review from a team April 26, 2018 11:44
@jorgefilipecosta jorgefilipecosta added this to the 2.8 milestone Apr 26, 2018
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.

This works as expected but I admit I have a small issue with the initializeColor prop.

clear,
} = attributes;

const textColor = initializeColor( {
Copy link
Contributor

Choose a reason for hiding this comment

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

This intiailizeColor calls are bothering me a bit. It seems too magic to me. I wonder if it's not better to transform the withColors HoC to something like

withColors( ( getColor, { attributes } ) => ( {
   backgroundColor: getColor( attributes.backgroundColor, attributes.customBackgroundColor, 'background-color' )
} )

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 for the review and for the feedback @youknowriad. I like your suggestion, I will give it a try in a separate PR.
Regarding the setters (the logic to set the name attribute or the custom one) do you think we should pass a getColor to retrieve the data and a setColor to build the setter, or getColor returns the setter inside similar to what initiailizeColor does?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd lean towards a separate setColor

@jorgefilipecosta jorgefilipecosta force-pushed the update/implemente-color-classes-in-button branch from 0ac9f13 to b8ee131 Compare April 27, 2018 18:54
@jorgefilipecosta jorgefilipecosta merged commit 41594cd into master Apr 27, 2018
@jorgefilipecosta jorgefilipecosta deleted the update/implemente-color-classes-in-button branch April 27, 2018 19:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants