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

CustomGradientPicker: Update Type and Angle controls #23802

Merged
merged 13 commits into from
Aug 31, 2020

Conversation

ItsJonQ
Copy link

@ItsJonQ ItsJonQ commented Jul 8, 2020

Screen Shot 2020-07-08 at 3 59 49 PM

This update improves the UI for the Linear/Gradient selector and angle controls for the <CustomGradientPicker /> component from @wordpress/components (which is featured in the Cover block).

This helps partially resolve some of the suggestions proposed #21269 by folks like @pablohoneyhoney, @jasmussen, and @mapk.

Linear/Radial select

The internal <SelectControl /> has been updated with the new Gutenberg styles. The component functionality (that is the component API) remains the same. Since the UI of the new <SelectControl /> matches that of <InputControl />, some of the internals were refactored so that they could be shared.

Angle control

These have also received a UI update to match Gutenberg styles. The functionality remains mostly the same, with some minor improvements to the drag interaction. Also, the input that appears next to the circle is updated with our new NumberControl.

86052782-84a23280-ba25-11ea-9161-7b3ed1a07320

How has this been tested?

  • Tested locally in Storybook and Gutenberg
  • Run npm run dev
  • Add a Cover block
  • Select a background color
  • Change it to Gradient
  • Play with the Gradient controls

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.
  • [n/a] I've updated all React Native files affected by any refactorings/renamings in this PR.

@ItsJonQ ItsJonQ added [Feature] UI Components Impacts or related to the UI component system [Feature] Design Tools Tools that impact the appearance of blocks both to expand the number of tools and improve the experi labels Jul 8, 2020
@ItsJonQ ItsJonQ self-assigned this Jul 8, 2020
@ItsJonQ
Copy link
Author

ItsJonQ commented Jul 8, 2020

Note: On the original issue, there were some interaction suggestions, such as...

Worth looking at proportions (perhaps taller dragging area so it becomes hierarchically more prominent with a bigger area of interaction) and more distance between the slider and the controls below.

from @pablohoneyhoney

Can we allow this? It seems like a fair use case. Or even if I wanted to flip the gradient entirely, move the orange color all the way to the right past the red color?

from @jasmussen

I took a look. It looks like it would involve some extensive refactors in the gradient slider portion of the component.

For now, I think it would be easier (at least to start) to focus on the controls that appear on the bottom

@github-actions
Copy link

github-actions bot commented Jul 8, 2020

Size Change: +13.5 kB (1%)

Total Size: 1.17 MB

Filename Size Change
build/annotations/index.js 3.67 kB +5 B (0%)
build/api-fetch/index.js 3.44 kB +50 B (1%)
build/autop/index.js 2.82 kB +1 B
build/block-directory/index.js 7.99 kB +312 B (3%)
build/block-directory/style-rtl.css 953 B +9 B (0%)
build/block-directory/style.css 952 B +7 B (0%)
build/block-editor/index.js 126 kB +1.84 kB (1%)
build/block-editor/style-rtl.css 10.8 kB -35 B (0%)
build/block-editor/style.css 10.8 kB -27 B (0%)
build/block-library/editor-rtl.css 8.52 kB +925 B (10%) ⚠️
build/block-library/editor.css 8.52 kB +927 B (10%) ⚠️
build/block-library/index.js 136 kB +3.87 kB (2%)
build/block-library/style-rtl.css 7.45 kB -316 B (4%)
build/block-library/style.css 7.46 kB -317 B (4%)
build/block-library/theme-rtl.css 729 B +1 B
build/block-library/theme.css 730 B +1 B
build/block-serialization-default-parser/index.js 1.88 kB +1 B
build/blocks/index.js 47.7 kB -586 B (1%)
build/components/index.js 200 kB +349 B (0%)
build/components/style-rtl.css 15.5 kB -85 B (0%)
build/components/style.css 15.5 kB -90 B (0%)
build/compose/index.js 9.67 kB +1 B
build/core-data/index.js 12.3 kB +872 B (7%) 🔍
build/data-controls/index.js 1.29 kB +1 B
build/data/index.js 8.55 kB +98 B (1%)
build/date/index.js 5.38 kB +2 B (0%)
build/dom/index.js 4.48 kB +1.24 kB (27%) 🚨
build/edit-navigation/index.js 11.6 kB +815 B (6%) 🔍
build/edit-navigation/style-rtl.css 1.16 kB +85 B (7%) 🔍
build/edit-navigation/style.css 1.16 kB +86 B (7%) 🔍
build/edit-post/index.js 304 kB +417 B (0%)
build/edit-post/style-rtl.css 5.61 kB +2 B (0%)
build/edit-post/style.css 5.61 kB +1 B
build/edit-site/index.js 17 kB +209 B (1%)
build/edit-site/style-rtl.css 3.06 kB +21 B (0%)
build/edit-site/style.css 3.06 kB +22 B (0%)
build/edit-widgets/index.js 11.9 kB +2.54 kB (21%) 🚨
build/editor/index.js 45.3 kB +166 B (0%)
build/editor/style-rtl.css 3.8 kB +17 B (0%)
build/editor/style.css 3.79 kB +16 B (0%)
build/element/index.js 4.65 kB +2 B (0%)
build/format-library/index.js 7.71 kB -10 B (0%)
build/is-shallow-equal/index.js 710 B -1 B
build/keyboard-shortcuts/index.js 2.52 kB +7 B (0%)
build/keycodes/index.js 1.94 kB +2 B (0%)
build/list-reusable-blocks/index.js 3.12 kB -3 B (0%)
build/media-utils/index.js 5.32 kB -4 B (0%)
build/nux/index.js 3.4 kB -3 B (0%)
build/plugins/index.js 2.56 kB -2 B (0%)
build/primitives/index.js 1.41 kB +4 B (0%)
build/rich-text/index.js 13.9 kB +15 B (0%)
build/server-side-render/index.js 2.77 kB +59 B (2%)
build/shortcode/index.js 1.7 kB +1 B
build/url/index.js 4.06 kB +1 B
ℹ️ View Unchanged
Filename Size Change
build/a11y/index.js 1.14 kB 0 B
build/blob/index.js 620 B 0 B
build/block-serialization-spec-parser/index.js 3.1 kB 0 B
build/deprecated/index.js 772 B 0 B
build/dom-ready/index.js 568 B 0 B
build/edit-widgets/style-rtl.css 2.45 kB 0 B
build/edit-widgets/style.css 2.45 kB 0 B
build/editor/editor-styles-rtl.css 537 B 0 B
build/editor/editor-styles.css 539 B 0 B
build/escape-html/index.js 733 B 0 B
build/format-library/style-rtl.css 547 B 0 B
build/format-library/style.css 548 B 0 B
build/hooks/index.js 2.13 kB 0 B
build/html-entities/index.js 621 B 0 B
build/i18n/index.js 3.56 kB 0 B
build/list-reusable-blocks/style-rtl.css 476 B 0 B
build/list-reusable-blocks/style.css 476 B 0 B
build/notices/index.js 1.79 kB 0 B
build/nux/style-rtl.css 671 B 0 B
build/nux/style.css 668 B 0 B
build/priority-queue/index.js 789 B 0 B
build/redux-routine/index.js 2.85 kB 0 B
build/token-list/index.js 1.27 kB 0 B
build/viewport/index.js 1.85 kB 0 B
build/warning/index.js 1.14 kB 0 B
build/wordcount/index.js 1.17 kB 0 B

compressed-size-action

@jasmussen
Copy link
Contributor

It looks like it would involve some extensive refactors in the gradient slider portion of the component.
For now, I think it would be easier (at least to start) to focus on the controls that appear on the bottom

All good. I just saw some really sharp diagonal gradients that Kjell made, where there's no gradation because both colors are at the same position — so I ticketed it in #23816. Thank you for looking!

Looking at this PR, here's a before:

Screenshot 2020-07-09 at 10 13 13

And here's after:

after

This is night and day, it is profoundly better. It is such an improvement. 👏 Well done.

There are a number of little followups I'd like to do separately, like putting all color swatches into a collapsible line line, revisit the clear buttons in a systematic way, and overall refine the sidebar. That is ongoing work, not forgotten:

Color controls, opens inline

... but something I will help with and which should not block this.

In other words, this is good to ship, Q, just needs a code sanity check! 👍 👍 — Thanks again.

@ItsJonQ
Copy link
Author

ItsJonQ commented Jul 13, 2020

There are a number of little followups I'd like to do separately, like putting all color swatches into a collapsible line line, revisit the clear buttons in a systematic way, and overall refine the sidebar

@jasmussen Ah yes! I submitted a proposal to handle grouping/collapsing of like-controls:
#23486

Thank you for your review + testing!

@munirkamal
Copy link
Contributor

Hi @ItsJonQ

As you are working on this component, what do you think about my proposal #24049 to add a radial direction option as well? That would enable some more design possibilities.

@ItsJonQ
Copy link
Author

ItsJonQ commented Jul 20, 2020

@munirkamal Hiya! Thanks for reaching out! I'll reply in your issue 🙏

@richtabor
Copy link
Member

Love this 👏

Copy link
Contributor

@ntsekouras ntsekouras left a comment

Choose a reason for hiding this comment

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

Cool stuff here @ItsJonQ ! 💯 - I've left some small comments but most importantly I'd like you to share your opinion about css-in-js.

I had to read a bit about this to review your code :), so I'm just trying to better understand the trade offs and I know you've taken a deep dive in styles.

My first concerns are:

  • if we're adding a new way of styling ( emotion css-in-js ) and it's trade offs have been considered, is it the way to go for other components ( new ones or refactored) as well?
  • Should we use it only in complex scenarios? That means for example state based styles etc..

Thanks!

@@ -0,0 +1,53 @@
/**
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you think we should have a new styles folder? Even though you're using css-in-js it's still the equivalent of style.scss which in many components I checked ( didn't check them all :) ) are in the root folder. So it seems to me we could keep it consistent. What do you think?

Copy link
Author

Choose a reason for hiding this comment

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

Good point! It may no longer be necessary. I originally introduced this structure to make it distinctly different from the style.scss during the early proposal/experimental phase.

I'm happy to keep the style.js files at the root level. It's the same convention I've followed in another React component library project:

https://github.com/ItsJonQ/g2/tree/master/packages/components/src/Button

@@ -0,0 +1,12 @@
/**
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment as above about styles folder.

@aristath
Copy link
Member

I just saw #23816 and was trying some things locally before coming here.
Changing the value of MINIMUM_DISTANCE_BETWEEN_POINTS in constants.js from 9 to 1 allows points to overlap 👍

@ItsJonQ
Copy link
Author

ItsJonQ commented Aug 11, 2020

@aristath Oo! Thanks for that suggestion. I just gave it a shot.

It definitely allows for the points to be brought closer. However, the UI controls feel awfully cramped when this happens 🙈

Screen Shot 2020-08-11 at 1 10 57 PM

This feels especially cramped when there's the (+) inserted that appears on hover:

2020-08-11 13-11-40 2020-08-11 13_11_59

@jasmussen What do you think?

@jasmussen
Copy link
Contributor

Changing the value of MINIMUM_DISTANCE_BETWEEN_POINTS in constants.js from 9 to 1 allows points to overlap 👍

@jasmussen What do you think?

Here's what I see.

gradient

I LOVE the ability to make those sharp gradients.

However in the above I actually set MINIMUM_DISTANCE_BETWEEN_POINTS = 0;, without that you can't make perfectly sharp lines like in the GIF. That, as you note, also makes the + behave a little funkily.

Which all is to say, I think it's a followup PR that should not block this PR from happening, and in that followup we could probably also make it so the plus button does not appear when you mouse-over one of the existing handles. Maybe?

@mtias
Copy link
Member

mtias commented Aug 26, 2020

Great to see the progress here!

@jasmussen
Copy link
Contributor

Screenshot 2020-08-27 at 12 13 02

Fixed size of bar to match mockups.

@jasmussen
Copy link
Contributor

Harmonized spacing, and improved focus.

Screenshot 2020-08-27 at 12 28 19

@jasmussen
Copy link
Contributor

Fixed so the swatches align on the right side with the gradient creator below.

Screenshot 2020-08-27 at 12 33 12

@jasmussen jasmussen self-requested a review August 27, 2020 10:34
Copy link
Contributor

@jasmussen jasmussen left a comment

Choose a reason for hiding this comment

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

This is a vast improvement over what's shipping. And after the recent polish, this is good enough to ship from a design point of view.

I would love to get this in soon, so all it needs now is a final code review. @ntsekouras if you have the bandwidth, would appreciate you could take a look so we can get this in!

@ZebulanStanphill ZebulanStanphill added the Needs Accessibility Feedback Need input from accessibility label Aug 28, 2020
Copy link
Contributor

@ntsekouras ntsekouras left a comment

Choose a reason for hiding this comment

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

Great work here @ItsJonQ and the polishing from @jasmussen 💯

@mtias
Copy link
Member

mtias commented Aug 31, 2020

Should we move the "type" label to above now or later?

image

@ItsJonQ
Copy link
Author

ItsJonQ commented Aug 31, 2020

Thanks for the feedback + enhancements all! I'll merge this up 🎉

@ItsJonQ ItsJonQ merged commit be09692 into master Aug 31, 2020
@ItsJonQ ItsJonQ deleted the update/gradient-controls branch August 31, 2020 14:29
@github-actions github-actions bot added this to the Gutenberg 8.9 milestone Aug 31, 2020
@talldan talldan added the [Type] Breaking Change For PRs that introduce a change that will break existing functionality label Jun 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Design Tools Tools that impact the appearance of blocks both to expand the number of tools and improve the experi [Feature] UI Components Impacts or related to the UI component system Needs Accessibility Feedback Need input from accessibility [Type] Breaking Change For PRs that introduce a change that will break existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants