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

Add: Preset gradient functionality button block #17169

Merged

Conversation

jorgefilipecosta
Copy link
Member

Description

Implements: #16482
Related: #16662

This PR adds a set of Gradient related functionality and components and uses them to implement gradient functionality in the button block.
For now, we still don't have a custom gradient functionality we just have gradient presets.

Themes will be able to configure gradient presets. But we need a default set of gradients when themes did not pass their own set. I think this set is not very creative and we should look into having an awesome set :)
cc: @mapk, @kjellr

How has this been tested?

I added the button block. I used the gradient panel and I verified the preset gradients work as expected.

Screenshots

image

@jorgefilipecosta jorgefilipecosta added [Type] Enhancement A suggestion for improvement. [Component] Button [Package] Components /packages/components [Package] Block editor /packages/block-editor labels Aug 23, 2019
@jorgefilipecosta jorgefilipecosta force-pushed the update/extact-circular-option-picker-internal-component-containing-color-palette-design branch from efcc261 to 71e4eb4 Compare August 23, 2019 21:49
@senadir
Copy link
Contributor

senadir commented Aug 25, 2019

🎉🎉🎉🎉
Will test today & report back, thank you so much for working on this!

@senadir
Copy link
Contributor

senadir commented Aug 28, 2019

as per today's editor chat, there has been a discussion of whether we should use classes for gradients or directly inline them.

in my point of view, I think classes are the best, most compatible solution in case of updating & or changing the visual identity

@kjellr
Copy link
Contributor

kjellr commented Aug 28, 2019

Regarding the default set of gradients: I think the main use case for this will actually be outside of the button block: for black(or white)-to-transparent gradients above images in the Cover block. If we plan on adding this functionality to that block, we should include those in this default set too.

For color ones, I think we should just choose a few subtle ones that are based on the default set of colors we use. So here's an example set:

  • Pale Pink to Vivid Red
  • Pale Cyan Blue to Vivid Cyan Blue
  • Light Green Cyan to Vivid Green Cyan
  • Black to White
  • Black to Transparent
  • White to Transparent

... each with a left-to-right and top-to-bottom variant. That would result in 12 swatches, which is coincidentally the same number that we include by default for colors today.

@kjellr
Copy link
Contributor

kjellr commented Aug 28, 2019

Also yes, I think these should follow the standard set by colors: so these should be defined by classnames.

If we allow for users to create their own custom gradients later down the road, those would be inlined, just like the custom colors are today.

@mapk
Copy link
Contributor

mapk commented Aug 28, 2019

I think this set is not very creative and we should look into having an awesome set :)

In addition to some of Kjell's example above, I'd like to see a cool gradient and warm gradient if it's not too much. I can see these gradients being used as backgrounds to the Group block and Cover block.

Cool

  • Vivid Green Cyan (# 00d084) to Vivid Cyan Blue (# 0693e3)

Warm

  • Luminous Vivid Amber (# fcb900) to Luminous Vivid Orange (# ff6900)

Screen Shot 2019-08-28 at 4 45 16 PM

as per today's editor chat, there has been a discussion of whether we should use classes for gradients or directly inline them.
in my point of view, I think classes are the best, most compatible solution in case of updating & or changing the visual identity

I'd also agree that classnames would be wonderful here. 👍

@jorgefilipecosta jorgefilipecosta force-pushed the update/extact-circular-option-picker-internal-component-containing-color-palette-design branch from 71e4eb4 to 914631f Compare August 29, 2019 13:53
@jorgefilipecosta jorgefilipecosta force-pushed the add/preset-gradient-functionality-button-block branch from ff41c4b to 0b4f447 Compare August 29, 2019 14:34
@jorgefilipecosta jorgefilipecosta force-pushed the update/extact-circular-option-picker-internal-component-containing-color-palette-design branch 3 times, most recently from ccb0f00 to 89d00c5 Compare August 30, 2019 17:36
@jorgefilipecosta
Copy link
Member Author

Hi @mapk, @kjellr, I updated the PR to use the suggested backgrounds.
We have now many predefined gradients. Should we also include some radial gradients (in that case probably we need to remove some of the current gradients)?
We have a problem right now we can not visually differentiate "Black to White" from
"Black to Transparent" as the background of the gradient picker is also white. Maybe we can try to add small png bellow as background with gray and white squares to indicate transparency?
Regarding the class usage, I update the attribute to be "customGradient" so right now we will always set custom values. This change allows us to quickly right after adding the classes mechanism. I'm not adding it right now because this PR is already huge and if I increase its size, even more, it becomes impossible to review.
This PR depends on #17154 which is pure code refactor I would like a review in that PR first so we can advance with this one :)

@kjellr
Copy link
Contributor

kjellr commented Sep 4, 2019

Hi @mapk, @kjellr, I updated the PR to use the suggested backgrounds.

I think I'm actually still seeing the old colors here?

Screen Shot 2019-09-04 at 1 42 14 PM

We have a problem right now we can not visually differentiate "Black to White" from
"Black to Transparent" as the background of the gradient picker is also white. Maybe we can try to add small png bellow as background with gray and white squares to indicate transparency?

Yeah, that makes sense. Something like this:

Frame 3

We could draw that grid as an SVG behind the gradient. Here's a sample SVG to try.

Trying this out, I'm wondering if it actually makes sense to have these exist in their own panel in the first place? Since these gradients are colors, I'd expect to find them appended to the rest of the color swatches:

Frame 4

@jorgefilipecosta jorgefilipecosta force-pushed the add/preset-gradient-functionality-button-block branch from 0b4f447 to 3256474 Compare September 6, 2019 14:46
@jorgefilipecosta
Copy link
Member Author

Hi @kjellr,

I think I'm still seeing the old colors here?

Sorry, I missed to push my update it should be fixed now.

We have a problem right now we can not visually differentiate "Black to White" from
"Black to Transparent" as the background of the gradient picker is also white. Maybe we can try to add small png bellow as background with gray and white squares to indicate transparency?

Yeah, that makes sense. Something like this:
Frame 3

I will try to add this transparency mark.

Trying this out, I'm wondering if it actually makes sense to have these exist in their own panel in the first place? Since these gradients are colors, I'd expect to find them appended to the rest of the color swatches:

Soon we will have a custom gradients functionality I opted for a separate panel to not make a single panel very huge.
We could open the custom gradients panel in a Popover (although none of the designs proposed suggests that), but if we open in a popover we will need a Custom gradient button and custom color button and I'm not sure if having the two buttons is intuitive.
Having the colors and gradients together means 24 color options by default, I guess it may be too many options for a single panel.

@mapk
Copy link
Contributor

mapk commented Sep 6, 2019

I updated the PR to use the suggested backgrounds.

Looking through, I only see a few. Are we missing the gradients I had suggested earlier?

Here's what I'm seeing right now. I notice the color white by itself is included there. And two of the Black-to-white gradients are duplicated.

btn-grads

@jorgefilipecosta jorgefilipecosta force-pushed the add/preset-gradient-functionality-button-block branch from 3256474 to 6127f7e Compare September 7, 2019 17:43
@jorgefilipecosta
Copy link
Member Author

Looking through, I only see a few. Are we missing the gradients I had suggested earlier?

Hi @mapk the gradients you suggested Vivid Green Cyan (# 00d084) to Vivid Cyan Blue (# 0693e3) and Luminous Vivid Amber (# fcb900) to Luminous Vivid Orange (# ff6900) was there, but I wrongly set one of the transparency values the problem was fixed.

Screenshot 2019-09-07 at 18 40 02

Screenshot 2019-09-07 at 18 40 09

Here's what I'm seeing right now. I notice the color white by itself is included there. And two of the Black-to-white gradients are duplicated.

Hi @mapk the color white is White to Transparent, and one of the Black-to-white gradients is, in fact, a black to transparent. Both white and transparent were suggested as noted before we will need a way to indicate transparency (the typical white and dark squares). I hope to add this functionality very soon.
For now, to test if it gradients work well, we can nest the button inside a group and change the background color of the group.

@jorgefilipecosta
Copy link
Member Author

The transparency indication was added now we can differentiate between white and transparent gradients:
Screenshot 2019-09-07 at 19 43 19

Props to @kjellr for providing the transparency SVG!

@jasmussen
Copy link
Contributor

jasmussen commented Sep 24, 2019

I took the liberty of pushing a rebase, because it went smoothly and fixed some block registration issues that were otherwise present in master. However for some reason Github seems to still think there are conflicts with master, that I don't see in the checked out code.

Any idea what this might be?

@jasmussen
Copy link
Contributor

I'm so excited for gradients to land, I took a stab at making a wider range of presets. The idea being that if we are launching V1 with presets ONLY, and not yet with a UI to customize those presets, it's important we launch with a range of high quality and widely useful gradients right off the bat. So I made these:

Screenshot 2019-09-24 at 13 06 31

  1. There are no duplicates for each direction. They are all top left to bottom right. The reason being that, arguably, these are easier to use. Also, it feels of more value to have a range of different gradients, than a bunch of confusing duplicates each with different orientations.

You could also see this as a bold first step and the next immediate step right after being to let you customize those presets using the UI outlined in #16662.

Props @onuro, as I used some of the gradients they provided in the sketch file on that thread.

  1. There are a range of gradients built using the existing gutenberg palette, and a number of additional ones, some that feature multiple color stops. I also tweaked the capitalization a little bit to match the capitalization of those colors.

  2. It removes the transparent gradients. Those can be cool, but they aren't that useful in the context of just the block. It's nice that the foundations for adding these (gray square pattern below), so let's add some like that, when this feature expands beyond the Button block.

Let me know what you think!

@mapk
Copy link
Contributor

mapk commented Sep 24, 2019

There are no duplicates for each direction. They are all top left to bottom right. The reason being that, arguably, these are easier to use. Also, it feels of more value to have a range of different gradients, than a bunch of confusing duplicates each with different orientations.

Excellent reasoning, @jasmussen! In the future we can add a gradient direction control as you noted.

It removes the transparent gradients.

Nooooo! Alrighty, I get your point. 😉 In context of the Button block, this makes sense.

Copy link
Contributor

@mapk mapk left a comment

Choose a reason for hiding this comment

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

From a design perspective, this looks like a great v.1.

@spacedmonkey
Copy link
Member

It should be possible to define gradient in PHP using add_theme_support similar to editor-color-palette. Could I recommend editor-gradient-presets as a name.

@jorgefilipecosta jorgefilipecosta force-pushed the add/preset-gradient-functionality-button-block branch from babd035 to fdd3f52 Compare September 26, 2019 10:04
@jorgefilipecosta jorgefilipecosta force-pushed the update/extact-circular-option-picker-internal-component-containing-color-palette-design branch from 1c1ebd2 to 72b8a23 Compare September 26, 2019 10:09
@jorgefilipecosta
Copy link
Member Author

It should be possible to define gradient in PHP using add_theme_support similar to editor-color-palette. Could I recommend editor-gradient-presets as a name.

Hi @spacedmonkey, yes the plan is for themes to be able to change the default gradient presents. When this is merged the following step is a custom gradient component and in parallel, we will add the theme API's editor-gradient-presets sounds like a good name to me, thank you for the suggestion 👍

This commit changes a few things. It:

- Removes all duplicate presets and leaves only top left to bottom right gradients. As presets, these are arguably more dynamic when using them, compared to vertical or horizontal.
- It adds a range of gradients built using the stock Gutenberg color palette colors.
- It adds a couple of additional gradients using new colors.
- Removes the transparent gradients for now, as they aren't useful yet on the button. We can add back later on.

Will elaborate in a comment. (+2 squashed commits)
Squashed commits:
[a37cac983] Add transparency indication.
[f7aa9f8a7] Add: Preset gradient functionality button block
@jorgefilipecosta jorgefilipecosta force-pushed the add/preset-gradient-functionality-button-block branch from fdd3f52 to 08fc902 Compare October 3, 2019 11:40
@jorgefilipecosta jorgefilipecosta changed the base branch from update/extact-circular-option-picker-internal-component-containing-color-palette-design to master October 3, 2019 11:41
@jorgefilipecosta jorgefilipecosta force-pushed the add/preset-gradient-functionality-button-block branch from 08fc902 to 2cc4b3d Compare October 3, 2019 11:52
@spacedmonkey
Copy link
Member

Created a follow up issue here. #17774

@swissspidy swissspidy deleted the add/preset-gradient-functionality-button-block branch October 8, 2019 14:36
@youknowriad youknowriad added this to the Gutenberg 6.7 milestone Oct 14, 2019
@mmtr
Copy link
Contributor

mmtr commented Oct 14, 2019

Button blocks with gradients are currently considered invalid blocks when loaded on multisite WordPress install. I created an issue with more context: #17938

@jorgefilipecosta
Copy link
Member Author

Just for the record, a PR that addressed the button invalidation problem on WordPress multisite installs was recently submitted and merged #17940.
Thank you for reporting this issue @mmtr!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Block editor /packages/block-editor [Package] Components /packages/components [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants