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

[RNMobile] Add radial gradient infrastructure #22493

Merged
merged 27 commits into from
Jun 17, 2020

Conversation

lukewalczak
Copy link
Member

@lukewalczak lukewalczak commented May 20, 2020

Description

That PR is adding infrastructure for gradients to switch between both types along with changing a linear gradient angle.

That PR is based on initial radial gradient PR

Ref to gb-mobile: wordpress-mobile/gutenberg-mobile#2277
Testing ios: wordpress-mobile/WordPress-iOS#14154
Testing android: wordpress-mobile/WordPress-Android#11999

How has this been tested?

  1. Open mobile app
  2. Add block with color support (Button / Cover)
  3. Open block settings
  4. Press gradient segment

Expect:

  • Customize Gradient control appeared
  1. Press Customize Gradient
  2. Change Angle

Expect:

  • Gradient angle is changing
  1. Press Radial type

Expect:

  • Gradient changed to radial
  1. Press back button

Expect:

  • Color palette list is scrolled to the end
  • Custom text along with selected and customized gradient appeared
  1. Press solid segment
  2. Press gradient segment

Expect:

  • Color palette is scrolling to the end (to the custom gradient)
  1. Press Custom or selected color swatch

Expect:

  • Customize Gradient subsheet is opened

Screenshots

  • ios
Color Settings Customize Gradient
Screenshot 2020-05-22 at 14 43 08 Screenshot 2020-05-22 at 14 43 11
  • android
Color Settings Customize Gradient
Screenshot 2020-05-22 at 14 42 50 Screenshot 2020-05-22 at 14 42 54

Types of changes

Adding new control in color settings called Customize Gradient which moves into subsheet with controls to change gradient type and linear gradient angle.

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.

@github-actions
Copy link

github-actions bot commented May 20, 2020

Size Change: +18.8 kB (1%)

Total Size: 1.13 MB

Filename Size Change
build/a11y/index.js 1.14 kB +1 B
build/annotations/index.js 3.62 kB +3 B (0%)
build/api-fetch/index.js 3.4 kB +3 B (0%)
build/autop/index.js 2.83 kB +1 B
build/block-directory/index.js 6.77 kB +293 B (4%)
build/block-directory/style-rtl.css 892 B +105 B (11%) ⚠️
build/block-directory/style.css 892 B +105 B (11%) ⚠️
build/block-editor/index.js 106 kB +429 B (0%)
build/block-editor/style-rtl.css 11.8 kB +437 B (3%)
build/block-editor/style.css 11.8 kB +430 B (3%)
build/block-library/editor-rtl.css 7.88 kB +274 B (3%)
build/block-library/editor.css 7.89 kB +275 B (3%)
build/block-library/index.js 127 kB +8.57 kB (6%) 🔍
build/block-library/style-rtl.css 7.72 kB +42 B (0%)
build/block-library/style.css 7.72 kB +43 B (0%)
build/blocks/index.js 48.1 kB +12 B (0%)
build/components/index.js 194 kB +4.41 kB (2%)
build/components/style-rtl.css 19.5 kB +18 B (0%)
build/components/style.css 19.5 kB +16 B (0%)
build/compose/index.js 9.31 kB -1 B
build/core-data/index.js 11.4 kB +10 B (0%)
build/data-controls/index.js 1.29 kB -2 B (0%)
build/data/index.js 8.45 kB +25 B (0%)
build/date/index.js 5.47 kB +3 B (0%)
build/deprecated/index.js 772 B +1 B
build/dom-ready/index.js 569 B +1 B
build/dom/index.js 3.17 kB +54 B (1%)
build/edit-navigation/index.js 8.25 kB +366 B (4%)
build/edit-navigation/style-rtl.css 918 B +61 B (6%) 🔍
build/edit-navigation/style.css 919 B +63 B (6%) 🔍
build/edit-post/index.js 303 kB +269 B (0%)
build/edit-post/style-rtl.css 5.6 kB +168 B (3%)
build/edit-post/style.css 5.6 kB +168 B (3%)
build/edit-site/index.js 15.5 kB +1.41 kB (9%) 🔍
build/edit-widgets/index.js 9.34 kB +464 B (4%)
build/editor/index.js 44.8 kB +197 B (0%)
build/element/index.js 4.65 kB +1 B
build/format-library/index.js 7.72 kB +11 B (0%)
build/hooks/index.js 2.13 kB -3 B (0%)
build/html-entities/index.js 621 B -1 B
build/i18n/index.js 3.56 kB +1 B
build/is-shallow-equal/index.js 710 B -1 B
build/keyboard-shortcuts/index.js 2.52 kB +5 B (0%)
build/keycodes/index.js 1.94 kB +1 B
build/list-reusable-blocks/index.js 3.12 kB -1 B
build/media-utils/index.js 5.3 kB +8 B (0%)
build/notices/index.js 1.79 kB +2 B (0%)
build/nux/index.js 3.41 kB +3 B (0%)
build/plugins/index.js 2.56 kB -5 B (0%)
build/primitives/index.js 1.5 kB +1 B
build/redux-routine/index.js 2.85 kB -3 B (0%)
build/rich-text/index.js 14.8 kB +10 B (0%)
build/server-side-render/index.js 2.68 kB +8 B (0%)
build/url/index.js 4.06 kB +41 B (1%)
build/viewport/index.js 1.85 kB +9 B (0%)
ℹ️ View Unchanged
Filename Size Change
build/blob/index.js 620 B 0 B
build/block-library/theme-rtl.css 684 B 0 B
build/block-library/theme.css 686 B 0 B
build/block-serialization-default-parser/index.js 1.88 kB 0 B
build/block-serialization-spec-parser/index.js 3.1 kB 0 B
build/edit-site/style-rtl.css 2.96 kB 0 B
build/edit-site/style.css 2.96 kB 0 B
build/edit-widgets/style-rtl.css 2.4 kB 0 B
build/edit-widgets/style.css 2.4 kB 0 B
build/editor/editor-styles-rtl.css 425 B 0 B
build/editor/editor-styles.css 428 B 0 B
build/editor/style-rtl.css 4.26 kB 0 B
build/editor/style.css 4.27 kB 0 B
build/escape-html/index.js 733 B 0 B
build/format-library/style-rtl.css 502 B 0 B
build/format-library/style.css 502 B 0 B
build/list-reusable-blocks/style-rtl.css 226 B 0 B
build/list-reusable-blocks/style.css 226 B 0 B
build/nux/style-rtl.css 616 B 0 B
build/nux/style.css 613 B 0 B
build/priority-queue/index.js 789 B 0 B
build/shortcode/index.js 1.7 kB 0 B
build/token-list/index.js 1.28 kB 0 B
build/warning/index.js 1.14 kB 0 B
build/wordcount/index.js 1.17 kB 0 B

compressed-size-action

@lukewalczak
Copy link
Member Author

Generally, I was following web behaviour so please let me know if that's correct or let me know what should be changed and what is desired behaviour:

  1. The opening Customize Gradient subsheet and pressing Gradient Type when solid color is already selected, results in setting default gradient color:
    radial-gradient(rgba(6, 147, 227, 1) 0%, rgb(155, 81, 224) 100%)

GIF:

  1. The default angle is 135 however after changing to radial type and again to linear value changes to 90

GIF:

  1. Currently, I'm not presenting selected icon over gradient swatch, because it was unclear what should be indicated as selected when:
  • gradient color has different type than regular from the palette,
  • gradient color has different angle than regular from the palette,
  • keep in mind that in the nearest future we will add also option to add new color to the gradient

@iamthomasbishop Please, let me know also if you have any other comments about the current solution.

@iamthomasbishop
Copy link

@lukewalczak Just tested out the build and I jotted down some notes:

  • What if we don't show the Customize Gradient button until a gradient swatch is selected? This should solve your first question above, because a gradient swatch will already be selected. If we do this, we could add a Reset button to the header of the Customize Gradient sub-sheet. I know that's slightly different but it could make this part of the flow feel more intuitive.

  • I wonder if on the Customize Gradient sub-sheet, would it feel more natural if the Gradient Type row had a chevron and went to a sub sheet to select the type. I know that's another level of nesting, but tapping to rotate type feels a bit off (I have the same issue w/ Image Size on image blocks but that was sort of a quick fix for an issue and we'd like to move away from that in the long-term).

  • I'm seeing a crash if I change the Angle slider value to zero. This happens both if I drag the handle to zero or manually set the text input to zero.

it was unclear what should be indicated as selected when:
gradient color has different type than regular from the palette,
gradient color has different angle than regular from the palette,

In both of these cases — if we go with my first suggestion above, the selected gradient swatch would change to look like the customized gradient. In other words, the user is just customizing/overriding a default gradient. In the future when we add more custom gradients, we can decide to either keep this "override" behavior or limit it and only let the user create custom ones if they want a customized version of a default one (I think the former makes more sense).

Does all of this make sense? If not, happy to answer questions. And if you have alternatives in mind or suggestions, let me know.

@lukewalczak
Copy link
Member Author

What if we don't show the Customize Gradient button until a gradient swatch is selected? This should solve your first question above, because a gradient swatch will already be selected. If we do this, we could add a Reset button to the header of the Customize Gradient sub-sheet. I know that's slightly different but it could make this part of the flow feel more intuitive

I was thinking about it, good to hear that you're suggesting it!

I wonder if on the Customize Gradient sub-sheet, would it feel more natural if the Gradient Type row had a chevron and went to a sub sheet to select the type. I know that's another level of nesting, but tapping to rotate type feels a bit off (I have the same issue w/ Image Size on image blocks but that was sort of a quick fix for an issue and we'd like to move away from that in the long-term).

I see :| Generally, I would like to avoid another nesting level (it's going to deep from general settings to background color to customize background to choose proper type). Maybe we should have both options available on Customize Gradient subsheet and somehow indicate which is currently enabled?

Otherwise, if we are going to nest gradient type options, how that subsheet look like?

I'm seeing a crash if I change the Angle slider value to zero. This happens both if I drag the handle to zero or manually set the text input to zero.

Thanks for reporting that, will investigate.

In other words, the user is just customizing/overriding a default gradient.

Clear, thanks!

@iamthomasbishop
Copy link

Maybe we should have both options available on Customize Gradient subsheet and somehow indicate which is currently enabled?

I was thinking about how we might do this as well. I also thought about maybe using a segmented control on the right side of that row, but idk. Maybe we can try that and see how it looks? Obviously we could run into long label issues and if we add more types we'd want to pivot, but that might work for now.

@lukewalczak
Copy link
Member Author

Should we keep segmented controls in the same row as label or below:
(sorry for cutting seg control, but prototyping roughly)
image

@iamthomasbishop
Copy link

iamthomasbishop commented May 20, 2020

@lukewalczak I'm sorry, that was a terrible suggestion on my part, definitely looks really weird 🙈. After thinking about it a little bit, I think we could just stack the gradient types in 2 separate table rows and then put the conditional Angle row in a separate section. I prototyped what this might look like really quickly. (Note: I also added the "reset" button I mentioned previously)

@lukewalczak
Copy link
Member Author

Gradient Type

I've implemented your suggestion with stacking gradient types in 2 rows:

ios android
Screenshot 2020-05-21 at 15 26 32 Screenshot 2020-05-21 at 15 28 36

Selecting gradient swatch

  1. Updates about the marking gradient swatch as selected:

base gradient swatch from palette is selected when:

  • gradient color has different type than regular from the palette,
  • gradient color has different angle than regular from the palette,

However, if the user adds on web new custom color into gradient base gradient swatch won't be selected. How would you like to indicate that?

  1. Pressing the already selected button is resetting the value to default gradient base. Is it supposed to be that way?
  • gif

@iamthomasbishop
Copy link

I've implemented your suggestion with stacking gradient types in 2 rows:

Looking pretty good! The switching between linear/radial feels pretty good. My one concern (which I'm not surprised by but wanted to see if it felt this way on a live build) — splitting into sections with section headings does take up a decent amount of space. Can we try removing the "Gradient Angle" section heading and if necessary add ~8px of spacing between the sections to provide some separation without taking up so much space. That would look something like this:

However, if the user adds on web new custom color into gradient base gradient swatch won't be selected. How would you like to indicate that?

Ah that's a good question. I would expect my customized gradient to stay in place. But if I reset a gradient to its default (which we can't currently do unless you tap on the already-selected swatch. More on that topic below 👇 ), it would reset to that "new" version of the base gradient. This makes me wonder if we should (as I suggested earlier) add the customized gradients to the end of the list as a "custom" swatch? It would solve this issue and the next point below.

Note: We also wouldn't need a "reset" button because you'd simply be able to switch "back" to the base gradient by tapping on it.

Pressing the already selected button is resetting the value to default gradient base. Is it supposed to be that way?

I find this odd. I would expect it to stay in its current state, same as happens when you tap on an already-selected solid color or tap twice on a base gradient before customizing.


Some other notes:

  • Can we use our primary blue (blue-50 in light mode, blue-30 in dark, IIRC) for the checkmark icon on the selected gradient type row?
  • I was expecting the selected swatch to show the same gradient as the bottom-left indicator after I customized it. Although the suggestion to add the separate "custom" swatch above would solve this as well.
  • Is it possible to adjust the gradient on the block itself while the slider value is being changed? I think we discussed doing this to the Button block's border-radius too, but I don't think we ever implemented that. (This could be handled separately, but worth documenting)
  • I found another crash 😞 When switching between solid and gradient color segments using the segmented control, I get a crash.

@lukewalczak
Copy link
Member Author

lukewalczak commented May 21, 2020

How "custom" swatch should look like? Should we reuse custom swatch from solid palette? I assume that adding custom swatch is equal with removing Customize Gradient:

image

and pressing the custom swatch will move user to dedicated subsheet?

I think that solution is the best and will solve a lot of concerns ✌️

Is it possible to adjust the gradient on the block itself while the slider value is being changed? I think we discussed doing this to the Button block's border-radius too, but I don't think we ever implemented that. (This could be handled separately, but worth documenting)

It's related to slider behaviour. There is ongoing work on that in separate PR.

@lukewalczak
Copy link
Member Author

Removed the Gradient Angle section header. Do we need that additional space (8px)?

Screenshot 2020-05-21 at 16 49 13

@lukewalczak
Copy link
Member Author

One more question - should that custom swatch be visible only when gradient color is selected or it should be always visible but disabled?

@iamthomasbishop
Copy link

How "custom" swatch should look like?

Can we use the customized gradient as the swatch background? For example if I customize the angle of a base gradient, I would expect that new “custom” swatch to see that new angle w/ the “selected” icon on top of it. Does that make sense?

and pressing the custom swatch will move user to dedicated subsheet?

Yea, if we go with this custom swatch flow, I think so. What we’re essentially doing is allowing the user to “fork” the base gradient into customized version and making it very obvious visually.

Here is how I’m seeing the flow in my head:

image

Just in case the sketch isn’t clear:

  1. No gradient is selected. User taps to select the second base gradient.
  2. “Customize” button appears. User taps it to go to the “Customize Gradient” sub-sheet.
  3. User makes changes (changes linear => radial)
  4. This changes the form of the sub-sheet. User taps back.
  5. When landing back on the top-level sheet, user will see that a new “custom” swatch was added and is selected. If they tap the a base swatch, it re-selects the base. Note: I think it would be nice if that custom swatch stayed when re-selecting a base one.

If we instead wanted to keep the same swatch (position) selected instead of adding a new one at the end of the list, I have a good idea how we might tackle that — I think it’d mostly rely on a “reset” button to make it clear what’s going on.

Removed the Gradient Angle section header. Do we need that additional space (8px)?

I think we might want an additional 8 or 16px spacing — it looks a bit too close there.

@lukewalczak lukewalczak force-pushed the rnmobile/radial-gradient-infrastructur branch from 338a302 to 74bbde9 Compare May 25, 2020 15:36
@lukewalczak lukewalczak self-assigned this Jun 2, 2020
@lukewalczak lukewalczak added [Feature] Blocks Overall functionality of blocks Mobile App - i.e. Android or iOS Native mobile impl of the block editor. (Note: used in scripts, ping mobile folks to change) labels Jun 2, 2020
@lukewalczak lukewalczak requested review from geriux and dratwas June 2, 2020 08:49
@lukewalczak lukewalczak marked this pull request as ready for review June 2, 2020 08:50
Copy link
Member

@geriux geriux left a comment

Choose a reason for hiding this comment

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

Looking good! Tested this on both platforms and it's working correctly, nice work Luke!! I just left a couple of comments.

Copy link
Contributor

@dratwas dratwas left a comment

Choose a reason for hiding this comment

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

Good job Luke! 🎉 I left some small comments but everything works as expected :)

Copy link
Member

@geriux geriux left a comment

Choose a reason for hiding this comment

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

LGTM! Tested it again after the changes. Nice work Luke!

@lukewalczak lukewalczak merged commit ca98385 into master Jun 17, 2020
@lukewalczak lukewalczak deleted the rnmobile/radial-gradient-infrastructur branch June 17, 2020 11:33
@github-actions github-actions bot added this to the Gutenberg 8.4 milestone Jun 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Blocks Overall functionality of blocks Mobile App - i.e. Android or iOS Native mobile impl of the block editor. (Note: used in scripts, ping mobile folks to change)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants