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

[Mobile] Create cover block with custom colour (without an image) #23870

Merged
merged 52 commits into from
Jul 24, 2020

Conversation

antonis
Copy link
Member

@antonis antonis commented Jul 10, 2020

Fixes #23868 (parent wordpress-mobile/gutenberg-mobile#2275)

Related PRs:

Description

Additionally to the palette with four default colours a Custom Colour Swatch has been added. When the user taps it, the custom colour picker UI shows. The user can tap "Cancel" to go back, or "Apply" to proceed with applying the colour.

How has this been tested?

Cover block creation with custom colour

  • Add a cover block
  • Press the one custom colour from the palette
  • Verify that the custom colour picker appears
  • Select a colour and press apply
  • Verify that a new cover block with only colour is created

Canceling the cover block creation

  • Add a cover block
  • Press the one custom colour from the palette
  • Verify that the custom colour picker appears
  • Select a colour and press cancel
  • Verify that the block remains in the original state

Screenshots

Empty cover block Cover block with only colour
Simulator Screen Shot - iPhone 11 - 2020-07-10 at 15 17 28 cust2

Types of changes

Enhancement

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.

@antonis
Copy link
Member Author

antonis commented Jul 10, 2020

Hello @iamthomasbishop 👋
You can check an implementation of the cover flow creation with custom colour at the screenshots above.
The creation of a cover block by selecting from a set of default colours is implemented with #23833.
Wdyt?

@antonis antonis force-pushed the rnmobile/Cover_with_custom_color branch from 6b538b2 to 8c13787 Compare July 10, 2020 14:01
@antonis antonis marked this pull request as ready for review July 10, 2020 16:01
@iamthomasbishop
Copy link

@antonis Excited to see this in action! I have a few minor requests. I don't know how accurate my Figma file is in terms of margins and padding at the top/bottom of the background cell on the placeholder, but here's what I have in mind:

  • Can we move the swatches up a line so that the action button ("add image or video") sits below them?
  • Swatches can be ~32px, with 10px gutters

Here's a visual of what I'm imagining:

Mockup Metrics
  • The transition is a bit jarring/abrupt when you apply a color. Is there any way we can apply a smooth transition when a color is chosen so it's not so jarring? (And bonus points if we can also do the next bullet point in tandem)

  • Another thing that might help smooth the rough edges is to apply the default height to the placeholder as well, so when the background is set, it's not a large jump from ~140px to 300px (our default height). That would look like this:

This is looking pretty solid already. Nice work!

@antonis antonis added the Mobile App - i.e. Android or iOS Native mobile impl of the block editor. (Note: used in scripts, ping mobile folks to change) label Jul 14, 2020
@antonis antonis self-assigned this Jul 14, 2020
@antonis antonis added [Block] Cover Affects the Cover Block - used to display content laid over a background image [Type] Enhancement A suggestion for improvement. labels Jul 14, 2020
@antonis
Copy link
Member Author

antonis commented Jul 14, 2020

Hello @iamthomasbishop 👋
Thank you for the detailed feedback on this. I've worked on this and I'd like to share some draft screens (not pixel perfect yet dimension wise).

Default color selection Custom color selection Other blocks
default custom all

To create the above I needed to customise the Media Placeholder component also used in other blocks (e.g. Image, MediaText). Related to this I have the following questions:

  • Should I use the new metrics (e.g. the distance-4 between the cover icon and the cover label) in all blocks using the Media Placeholder?
  • Should I use the increased placeholder height (~140px to 300px) in all places or just the cover block?

@iamthomasbishop
Copy link

@antonis The dynamic background color looks great, but I think it causes some friction with the content that is over it. I think we should keep the dynamic adjustment, so can we try either dimming (to something like ~30-50%, perhaps?) or hiding the contents of the placeholder (block icon, title, swatches, action) -- temporarily, while the user is selecting a custom color. Then when they cancel or apply, the contents would re-appear fully.

Note: this should only apply to the starter state of the Cover block. I can't think of any other blocks off the top of my head that this would affect.

@iamthomasbishop
Copy link

@antonis One more tiny thing -- Can we use the same text style as the footer label on the "Text Color" setting (on a Button, for example):

@antonis
Copy link
Member Author

antonis commented Jul 22, 2020

Hello @iamthomasbishop 👋 ,

I updated the PR with the suggested changes. Please let me know wdyt :)

Light mode Dark mode
light dark

@iamthomasbishop
Copy link

Looks great! I think we can ship this! :shipit:

@@ -30,7 +39,9 @@ const FillWithSettingsButton = ( { children, ...props } ) => {
</BottomSheetConsumer>
}
</Fill>
{ React.Children.count( children ) > 0 && <BlockSettingsButton /> }
{ React.Children.toArray( children ).filter(
( child ) => child.props.dontCount !== true
Copy link
Contributor

Choose a reason for hiding this comment

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

@antonis Thank you for adding the comment above on dontCount. To be honest, though I still had to reread that a few times to understand what the setting was meant to do. I wonder if we can rename it to something like excludeFromSettings or excludeFromCount something along those lines. WDYT?

Suggested change
( child ) => child.props.dontCount !== true
( child ) => child.props.excludeFromSettings !== true

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree with you @chipsnyder and made the change. I still find this implementation a bit dirty but I couldn't find a better way to achieve this :|

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.

Hey @antonis 👋 this is looking great! I left a couple of comments, let me know what you think.

packages/block-library/src/cover/edit.native.js Outdated Show resolved Hide resolved
packages/block-library/src/cover/edit.native.js Outdated Show resolved Hide resolved
packages/components/src/color-picker/style.native.scss Outdated Show resolved Hide resolved
Copy link
Member

@lukewalczak lukewalczak 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 @antonis 🎉 left some small comments!

Comment on lines 405 to 410
onCustomPress={ () => {
if ( isParentSelected ) {
openGeneralSidebar();
setCustomColorPickerShowing( true );
}
} }
Copy link
Member

Choose a reason for hiding this comment

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

Could you please extract it to named function?

Comment on lines 93 to 94
width: 32px;
height: 32px;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
width: 32px;
height: 32px;
width: $grid-unit-40;
height: $grid-unit-40;

Comment on lines 243 to 244
styles.customIndicatorWrapper,
customIndicatorWrapperStyles,
Copy link
Member

Choose a reason for hiding this comment

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

Can we move it to the const since the same styles are used also in other View?

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 reviewing this @lukewalczak :)
I agree with all your suggestions and submitted the changes

Comment on lines 434 to 436
customVerticalSeparatorStyles={
styles.paletteVerticalSeparator
}
Copy link
Member

Choose a reason for hiding this comment

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

I think this is not being used, should we remove it or is there something that we need to add?

Copy link
Member Author

Choose a reason for hiding this comment

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

You are right @geriux ! This was used at some point during the development but not any more.
I updated the PR

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.

This is working great! Thank you for the changes, just left one minor comment.

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! Nice work Antonis!! 🎉 Tested it on both iOS and Android.

@antonis antonis merged commit bd4a6b7 into WordPress:master Jul 24, 2020
@github-actions github-actions bot added this to the Gutenberg 8.7 milestone Jul 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Cover Affects the Cover Block - used to display content laid over a background image Mobile App - i.e. Android or iOS Native mobile impl of the block editor. (Note: used in scripts, ping mobile folks to change) [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Mobile] Cover: Allow creating the block with custom colour (without an image)
5 participants