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] Cover block uploads failure UI #21198

Merged
merged 39 commits into from
Apr 20, 2020

Conversation

mkevins
Copy link
Contributor

@mkevins mkevins commented Mar 27, 2020

Description

This PR adds UI for failed uploads in the Cover block, and also allows cancellation of ongoing uploads.

Related PRs

Testing steps

Upload failure UI

Upload failure UI

  1. Add a cover block to a post
  2. Tap "Add Image or Video"
  3. Tap "Choose from Device"
  4. Turn on airplane mode ✈️
  5. Pick an image to upload

Expected:

A failure indicator icon should appear in the upper-right-hand corner of the block:

Subsequently, tapping the background image should provide an option to retry the upload or remove the media:

Upload cancellation

Upload cancellation

  1. Add a cover block to a post
  2. Tap "Add Image or Video"
  3. Tap "Choose from Device"
  4. Pick an image to upload (observe that the progress bar appears)
  5. Before the upload finishes, tap the background image

Expected:

A dialog should be presented allowing you to cancel the upload:

Types of changes

The renderContent prop

The states in MediaUploadProgress component can utilized by passing a render prop, or via functional props bound to the component's internal state machine. Some of the block's UI (e.g. handling touch) is dependent on the component's internal state. We can wrap all of the dependent code within the renderContent prop to access this state. Alternatively, we can give the block component state, and updated it via the state change functional props (onFinishMediaUploadWithSuccess, etc.). I chose to use the latter implementation because it seemed more versatile. The MediaUploadProgress renderContent prop was made optional.

Failure icon

I did not find the triangle icon used in the design mockup, so instead used the dashicon "warning" icon, which renders as a circle. The exclamation mark in that svg is actually not part of the shape, so to make it white requires setting the background to white in the icon container. I gave the container a border-radius (so it renders as a circle, instead of a square) and this results in a white circle around the icon. cc: @iamthomasbishop 👋 can you let me know if this looks ok?

Upload failed icon

cover-upload-failed-icon

Design mockup

cover-upload-failure-flow

Another notable deviation from the mockup is that the upload retry / remove dialog is not in the bottomsheet, but rather in a parent-app dialog (e.g. AlertDialog in Android). In theory, we could implement a bottomsheet menu for these options, but I believe it might require some changes on the native side. Another thing to consider is that the other media blocks currently all use this same dialog. However, if we try to use the same dialog (the current state of this PR), we are missing the retry message ('Failed to insert media.\nPlease tap for options.').

If not displaying the retry message is a blocker, one simple solution would be to add the retry message in a bottomsheet dialog that subsequently opens the already existing parent-app dialog. But this introduces "yet another tap" to the UX, so may not be desirable.

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.

Gerardo Pacheco and others added 22 commits March 18, 2020 16:46
# Conflicts:
#	packages/block-library/src/cover/edit.native.js
…obile/feature/cover-block-uploads-failure-ui
@mkevins mkevins added [Status] In Progress Tracking issues with work in progress [Feature] Media Anything that impacts the experience of managing media [Block] Cover Affects the Cover Block - used to display content laid over a background image labels Mar 27, 2020
@github-actions
Copy link

github-actions bot commented Mar 27, 2020

Size Change: 0 B

Total Size: 842 kB

ℹ️ View Unchanged
Filename Size Change
build/a11y/index.js 1.02 kB 0 B
build/annotations/index.js 3.62 kB 0 B
build/api-fetch/index.js 4.01 kB 0 B
build/autop/index.js 2.82 kB 0 B
build/blob/index.js 620 B 0 B
build/block-directory/index.js 6.24 kB 0 B
build/block-directory/style-rtl.css 760 B 0 B
build/block-directory/style.css 761 B 0 B
build/block-editor/index.js 105 kB 0 B
build/block-editor/style-rtl.css 10.2 kB 0 B
build/block-editor/style.css 10.2 kB 0 B
build/block-library/editor-rtl.css 7.1 kB 0 B
build/block-library/editor.css 7.1 kB 0 B
build/block-library/index.js 112 kB 0 B
build/block-library/style-rtl.css 7.17 kB 0 B
build/block-library/style.css 7.17 kB 0 B
build/block-library/theme-rtl.css 683 B 0 B
build/block-library/theme.css 685 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/blocks/index.js 57.7 kB 0 B
build/components/index.js 198 kB 0 B
build/components/style-rtl.css 16.9 kB 0 B
build/components/style.css 16.9 kB 0 B
build/compose/index.js 6.66 kB 0 B
build/core-data/index.js 11.4 kB 0 B
build/data-controls/index.js 1.25 kB 0 B
build/data/index.js 8.43 kB 0 B
build/date/index.js 5.47 kB 0 B
build/deprecated/index.js 772 B 0 B
build/dom-ready/index.js 569 B 0 B
build/dom/index.js 3.1 kB 0 B
build/edit-navigation/index.js 3.54 kB 0 B
build/edit-navigation/style-rtl.css 485 B 0 B
build/edit-navigation/style.css 485 B 0 B
build/edit-post/index.js 27.9 kB 0 B
build/edit-post/style-rtl.css 12.3 kB 0 B
build/edit-post/style.css 12.3 kB 0 B
build/edit-site/index.js 10.5 kB 0 B
build/edit-site/style-rtl.css 5.04 kB 0 B
build/edit-site/style.css 5.04 kB 0 B
build/edit-widgets/index.js 7.49 kB 0 B
build/edit-widgets/style-rtl.css 4.66 kB 0 B
build/edit-widgets/style.css 4.66 kB 0 B
build/editor/editor-styles-rtl.css 428 B 0 B
build/editor/editor-styles.css 431 B 0 B
build/editor/index.js 43.3 kB 0 B
build/editor/style-rtl.css 3.48 kB 0 B
build/editor/style.css 3.47 kB 0 B
build/element/index.js 4.65 kB 0 B
build/escape-html/index.js 733 B 0 B
build/format-library/index.js 7.32 kB 0 B
build/format-library/style-rtl.css 502 B 0 B
build/format-library/style.css 502 B 0 B
build/hooks/index.js 2.13 kB 0 B
build/html-entities/index.js 622 B 0 B
build/i18n/index.js 3.56 kB 0 B
build/is-shallow-equal/index.js 711 B 0 B
build/keyboard-shortcuts/index.js 2.51 kB 0 B
build/keycodes/index.js 1.94 kB 0 B
build/list-reusable-blocks/index.js 3.12 kB 0 B
build/list-reusable-blocks/style-rtl.css 226 B 0 B
build/list-reusable-blocks/style.css 226 B 0 B
build/media-utils/index.js 5.29 kB 0 B
build/notices/index.js 1.79 kB 0 B
build/nux/index.js 3.4 kB 0 B
build/nux/style-rtl.css 616 B 0 B
build/nux/style.css 613 B 0 B
build/plugins/index.js 2.67 kB 0 B
build/primitives/index.js 1.49 kB 0 B
build/priority-queue/index.js 789 B 0 B
build/redux-routine/index.js 2.84 kB 0 B
build/rich-text/index.js 14.8 kB 0 B
build/server-side-render/index.js 2.67 kB 0 B
build/shortcode/index.js 1.7 kB 0 B
build/token-list/index.js 1.28 kB 0 B
build/url/index.js 4.02 kB 0 B
build/viewport/index.js 1.84 kB 0 B
build/warning/index.js 1.14 kB 0 B
build/wordcount/index.js 1.17 kB 0 B

compressed-size-action

@mkevins mkevins removed the [Status] In Progress Tracking issues with work in progress label Apr 10, 2020
@mkevins mkevins marked this pull request as ready for review April 10, 2020 11:05
@geriux
Copy link
Member

geriux commented Apr 14, 2020

Hey, @mkevins 👋 Started to review/test but I noticed that on iOS the upload progress bar is not showing (on Android it is) maybe there's a z-index issue?

@mkevins
Copy link
Contributor Author

mkevins commented Apr 14, 2020

Hi @geriux 👋 thanks for taking a look. I did run into that on Android too, but solved it with this: https://github.com/WordPress/gutenberg/pull/21198/files#diff-dbbdd2c3421fbb78e7d6cc0b65c4e8b1R57. So, I wonder now whether something can be different on iOS that would make that view invisible 🤔 . Thanks for the feedback, I'll investigate it 👍

@mkevins
Copy link
Contributor Author

mkevins commented Apr 14, 2020

Hi @geriux, I added a z-index value for the upload progress to address that it was invisible on iOS. I gave a spot check to a few other flows too (image, gallery, etc.) to make sure they'll all still work as expected too. Ready for another test, when you can 😄 . Thanks!

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 both on iOS and Android, also double-checked the other blocks using the MediaUploadProgress were working as expected too.

Approving code and functionality but there's still pending design/UX approval.

Nice work @mkevins!

@iamthomasbishop
Copy link

iamthomasbishop commented Apr 14, 2020

@mkevins I've not been able to test this on a device (I can't see the additional media sources in the Android build here), but looking at the screenshots above, I have some initial feedback.

Subsequently, tapping the background image should provide an option to retry the upload or remove the media:

If there is only 1 failed item on the post, can we remove the Remove All button on this dialog? (might be a separate native thing?)

Warning icon

This looks pretty good. Can you provide the following info:

  • What is the size of icon itself
  • What is the border-width of the white (or size of the container)?
  • What are the margins from the top-right?
  • What red color are you using? (probably should be using $red-50 (light mode) and $red-30 (dark mode) from Color Studio)

@mkevins
Copy link
Contributor Author

mkevins commented Apr 15, 2020

Hi @iamthomasbishop 👋 😄 thanks for the quick feedback!

looking at the screenshots above, I have some initial feedback.

Subsequently, tapping the background image should provide an option to retry the upload or remove the media:

If there is only 1 failed item on the post, can we remove the Remove All button on this dialog? (might be a separate native thing?)

This should be possible, but I believe will be needed on the native side. Since this will also be affecting other media blocks, maybe it's best that I open an issue for that one and address in a separate PR. Wdyt?

Warning icon

This looks pretty good. Can you provide the following info:

  • What is the size of icon itself
  • What is the border-width of the white (or size of the container)?

The icon itself is 20px in svg, but expands to fill its container, which is 24px. The white "border" is actually coming from the svg image, and is 2px:

Warning icon svg image

image

However, that actually becomes slightly larger than 2px since the total 20px svg expands to 24px (so roughly 2.4px).

  • What are the margins from the top-right?

The margins (actually padding in the outer container) are 8px from the top and right.

  • What red color are you using? (probably should be using $red-50 (light mode) and $red-30 (dark mode) from Color Studio)

I just used the eye-drop tool to pick the color from your mockup (#c34629). I'll make this exact though 👍 .

Edit:

There is now an apk for WordPress-Android with Cover upload options enabled in production, which includes the new colors.

@iamthomasbishop
Copy link

Since this will also be affecting other media blocks, maybe it's best that I open an issue for that one and address in a separate PR. Wdyt?

Sounds good to me 👍

Warning icon

Ok, that sounds about right regarding sizing — the frame of the icon should be 24 and it's slightly inset on the grid 2pts on each side from the looks of it). Rather than giving a solid white outline, I'm wondering if we can use a semi-transparent white (about 18% alpha) with only 1px width. That would look like this:

For inspection, I've added this to the design docs here.

The margins (actually padding in the outer container) are 8px from the top and right.

Perfect 👍

I just used the eye-drop tool to pick the color from your mockup (#c34629). I'll make this exact though 👍 .

Upon further inspection, can we use red-40 on both light/dark modes? It sits nicely on both.


One more thing that I'm curious about. We are putting this indicator on the top-right of the cell, which feels fine, but I'm curious (assuming we end up using this same pattern for other errors on other blocks) if there could be a scenario where it conflicts with other actions or UI, such as the image-editing button that sits on the top-right of an image block? If that's the case, I think we can move to the bottom-left or bottom-right of the cell — top-left being reserved for media type badge (like GIFs).

@mkevins
Copy link
Contributor Author

mkevins commented Apr 17, 2020

Hi @iamthomasbishop 👋

Warning icon

Ok, that sounds about right regarding sizing — the frame of the icon should be 24 and it's slightly inset on the grid 2pts on each side from the looks of it). Rather than giving a solid white outline, I'm wondering if we can use a semi-transparent white (about 18% alpha) with only 1px width. That would look like this:

So far, the icons we've used only have 1 color (and a background color of the container). So in previous iterations shown above, the icon was getting it's white color from the background of the container, and the fill color was set to the color-studio reds. That's why we couldn't separate the inner "!" color from the "border" color (i.e. it wasn't really a border, but instead, the background was showing through, since the svg was inset by 2px).

To achieve your designs I've added some paths to the svg to allow independent coloring:

Error icon with semi-transparent border

cover-upload-failed-icon-semi-transparent-border

Ideally, icons will be centralized, but it's not immediately clear what the ideal pattern is for this case (multiple colors), since it seems most (maybe all?) of the "centralized" icons (@wordpress/icons, Dashicon, etc.) are used with only one fill color. So, this icon component is specific to native cover block for now.

I just used the eye-drop tool to pick the color from your mockup (#c34629). I'll make this exact though +1 .

Upon further inspection, can we use red-40 on both light/dark modes? It sits nicely on both.

👍 Sounds good!

One more thing that I'm curious about. We are putting this indicator on the top-right of the cell, which feels fine, but I'm curious (assuming we end up using this same pattern for other errors on other blocks) if there could be a scenario where it conflicts with other actions or UI, such as the image-editing button that sits on the top-right of an image block? If that's the case, I think we can move to the bottom-left or bottom-right of the cell — top-left being reserved for media type badge (like GIFs).

I'm not sure how likely that scenario is that we'll use the same pattern for other media blocks (all the others so far have their failure state in the center, since there's nothing obstructing the view there). I tried it with the icon in the lower right, and it felt strange to me that it was so close to those other icons (block settings and remove block). Here's what it looks like:

Error icon in lower right corner

cover-upload-failed-icon-lower-right

Here's what it looks like in the lower left corner (better, IMO, but maybe not as nice as the upper right):

Error icon in lower left corner

cover-upload-failed-icon-lower-left

Maybe we can iterate on another PR? Wdyt?

@iamthomasbishop
Copy link

To achieve your designs I've added some paths to the svg to allow independent coloring:

I think to simplify this, we can probably just remove the bordering — I hate to break up and customize an icon's construction just for something like this. Simply having the white container background that fills the empty space in the middle should be enough.

I tried it with the icon in the lower right, and it felt strange to me

Totally agreed, I noticed this while playing around w/ the cell component in Figma. I think top-right is fine assuming we don't run into conflicts w/ other UI. In that case, we can always iterate by moving to the bottom-left, as you said. 👍

@mkevins mkevins merged commit 4f17612 into master Apr 20, 2020
@mkevins mkevins deleted the rnmobile/feature/cover-block-uploads-failure-ui branch April 20, 2020 09:17
@github-actions github-actions bot added this to the Gutenberg 8.0 milestone Apr 20, 2020
@mkevins
Copy link
Contributor Author

mkevins commented Apr 20, 2020

Thanks @geriux and @iamthomasbishop for your feedback!

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 [Feature] Media Anything that impacts the experience of managing media
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants