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] Update the bottom sheet header #34309

Merged
merged 9 commits into from
Sep 7, 2021
Merged

Conversation

enejb
Copy link
Contributor

@enejb enejb commented Aug 25, 2021

Description

This PR Refactors the Navigation Header Component so that it is more compostable, easier to understand and updates the usage of the component.

How has this been tested?

  1. Load up this PR on a mobile simulator.
  2. Navigate to different Bottoms Sheets. Notice that they look the same as expected.
    Bottoms sheets to test out.
  • Button Block.
    • Button Width.
    • Link Settings.
  • Image block
    • Alt text
    • Size Picker
  • Cover Block.
    • Edit Focal Point
    • Color Picker
  • Columns Block
    • Columns Selector
  • Paragraph Block
    • Font Site Settings.
    • Colour Settings
    • Gradient Settings
  • Help Section.

Screenshots

The Bottom Sheet Header should look exactly the same as before.
Something like this.
Screen Shot 2021-08-25 at 3 02 27 PM

Types of changes

Refactor

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • I've tested my changes with keyboard and screen readers.
  • 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 (please manually search all *.native.js files for terms that need renaming or removal).

@enejb enejb 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 Aug 25, 2021
@enejb enejb self-assigned this Aug 25, 2021
@enejb enejb changed the title Rnmobile/add/bottom sheet header [Rnmobile] Update the bottom sheet header Aug 25, 2021
@github-actions
Copy link

github-actions bot commented Aug 25, 2021

Size Change: -1.95 kB (0%)

Total Size: 1.04 MB

Filename Size Change
build/block-editor/index.min.js 119 kB +380 B (0%)
build/block-editor/style-rtl.css 13.8 kB -18 B (0%)
build/block-editor/style.css 13.8 kB -18 B (0%)
build/block-library/blocks/button/style-rtl.css 600 B -5 B (-1%)
build/block-library/blocks/button/style.css 600 B -4 B (-1%)
build/block-library/blocks/embed/style-rtl.css 417 B +17 B (+4%)
build/block-library/blocks/embed/style.css 417 B +17 B (+4%)
build/block-library/blocks/gallery/editor-rtl.css 925 B +46 B (+5%) 🔍
build/block-library/blocks/gallery/editor.css 929 B +53 B (+6%) 🔍
build/block-library/blocks/heading/style-rtl.css 114 B +38 B (+50%) 🆘
build/block-library/blocks/heading/style.css 114 B +38 B (+50%) 🆘
build/block-library/blocks/list/style-rtl.css 94 B +31 B (+49%) 🚨
build/block-library/blocks/list/style.css 94 B +31 B (+49%) 🚨
build/block-library/blocks/navigation/editor-rtl.css 1.72 kB +18 B (+1%)
build/block-library/blocks/navigation/editor.css 1.72 kB +17 B (+1%)
build/block-library/blocks/navigation/style-rtl.css 1.42 kB -48 B (-3%)
build/block-library/blocks/navigation/style.css 1.41 kB -47 B (-3%)
build/block-library/blocks/paragraph/style-rtl.css 261 B +13 B (+5%) 🔍
build/block-library/blocks/paragraph/style.css 261 B +13 B (+5%) 🔍
build/block-library/blocks/pullquote/style-rtl.css 378 B +17 B (+5%) 🔍
build/block-library/blocks/pullquote/style.css 378 B +18 B (+5%) 🔍
build/block-library/blocks/quote/style-rtl.css 187 B +18 B (+11%) ⚠️
build/block-library/blocks/quote/style.css 187 B +18 B (+11%) ⚠️
build/block-library/common-rtl.css 853 B -437 B (-34%) 🎉
build/block-library/common.css 849 B -439 B (-34%) 🎉
build/block-library/editor-rtl.css 9.52 kB -394 B (-4%)
build/block-library/editor.css 9.51 kB -396 B (-4%)
build/block-library/index.min.js 150 kB -84 B (0%)
build/block-library/style-rtl.css 10.2 kB -450 B (-4%)
build/block-library/style.css 10.2 kB -443 B (-4%)
build/blocks/index.min.js 46.9 kB -152 B (0%)
build/components/index.min.js 209 kB +1 B (0%)
build/components/style-rtl.css 15.8 kB +29 B (0%)
build/components/style.css 15.8 kB +30 B (0%)
build/compose/index.min.js 10.2 kB +69 B (+1%)
build/core-data/index.min.js 12.4 kB -55 B (0%)
build/edit-navigation/index.min.js 13.6 kB +2 B (0%)
build/edit-post/index.min.js 29 kB +35 B (0%)
build/edit-post/style-rtl.css 7.19 kB -8 B (0%)
build/edit-post/style.css 7.18 kB -8 B (0%)
build/edit-site/index.min.js 26.3 kB +82 B (0%)
build/edit-widgets/index.min.js 16 kB -1 B (0%)
build/editor/index.min.js 37.7 kB +22 B (0%)
build/i18n/index.min.js 3.6 kB +8 B (0%)
build/rich-text/index.min.js 10.6 kB -8 B (0%)
ℹ️ View Unchanged
Filename Size
build/a11y/index.min.js 931 B
build/admin-manifest/index.min.js 1.09 kB
build/annotations/index.min.js 2.7 kB
build/api-fetch/index.min.js 2.19 kB
build/autop/index.min.js 2.08 kB
build/blob/index.min.js 459 B
build/block-directory/index.min.js 6.2 kB
build/block-directory/style-rtl.css 1.01 kB
build/block-directory/style.css 1.01 kB
build/block-editor/default-editor-styles-rtl.css 378 B
build/block-editor/default-editor-styles.css 378 B
build/block-library/blocks/archives/editor-rtl.css 61 B
build/block-library/blocks/archives/editor.css 60 B
build/block-library/blocks/archives/style-rtl.css 65 B
build/block-library/blocks/archives/style.css 65 B
build/block-library/blocks/audio/editor-rtl.css 58 B
build/block-library/blocks/audio/editor.css 58 B
build/block-library/blocks/audio/style-rtl.css 111 B
build/block-library/blocks/audio/style.css 111 B
build/block-library/blocks/audio/theme-rtl.css 125 B
build/block-library/blocks/audio/theme.css 125 B
build/block-library/blocks/block/editor-rtl.css 161 B
build/block-library/blocks/block/editor.css 161 B
build/block-library/blocks/button/editor-rtl.css 474 B
build/block-library/blocks/button/editor.css 474 B
build/block-library/blocks/buttons/editor-rtl.css 315 B
build/block-library/blocks/buttons/editor.css 315 B
build/block-library/blocks/buttons/style-rtl.css 370 B
build/block-library/blocks/buttons/style.css 370 B
build/block-library/blocks/calendar/style-rtl.css 207 B
build/block-library/blocks/calendar/style.css 207 B
build/block-library/blocks/categories/editor-rtl.css 84 B
build/block-library/blocks/categories/editor.css 83 B
build/block-library/blocks/categories/style-rtl.css 79 B
build/block-library/blocks/categories/style.css 79 B
build/block-library/blocks/code/style-rtl.css 90 B
build/block-library/blocks/code/style.css 90 B
build/block-library/blocks/code/theme-rtl.css 131 B
build/block-library/blocks/code/theme.css 131 B
build/block-library/blocks/columns/editor-rtl.css 194 B
build/block-library/blocks/columns/editor.css 193 B
build/block-library/blocks/columns/style-rtl.css 474 B
build/block-library/blocks/columns/style.css 475 B
build/block-library/blocks/cover/editor-rtl.css 666 B
build/block-library/blocks/cover/editor.css 670 B
build/block-library/blocks/cover/style-rtl.css 1.23 kB
build/block-library/blocks/cover/style.css 1.23 kB
build/block-library/blocks/embed/editor-rtl.css 488 B
build/block-library/blocks/embed/editor.css 488 B
build/block-library/blocks/embed/theme-rtl.css 124 B
build/block-library/blocks/embed/theme.css 124 B
build/block-library/blocks/file/editor-rtl.css 300 B
build/block-library/blocks/file/editor.css 300 B
build/block-library/blocks/file/style-rtl.css 255 B
build/block-library/blocks/file/style.css 255 B
build/block-library/blocks/file/view.min.js 322 B
build/block-library/blocks/freeform/editor-rtl.css 2.44 kB
build/block-library/blocks/freeform/editor.css 2.44 kB
build/block-library/blocks/gallery/style-rtl.css 1.61 kB
build/block-library/blocks/gallery/style.css 1.61 kB
build/block-library/blocks/gallery/theme-rtl.css 122 B
build/block-library/blocks/gallery/theme.css 122 B
build/block-library/blocks/group/editor-rtl.css 159 B
build/block-library/blocks/group/editor.css 159 B
build/block-library/blocks/group/style-rtl.css 57 B
build/block-library/blocks/group/style.css 57 B
build/block-library/blocks/group/theme-rtl.css 70 B
build/block-library/blocks/group/theme.css 70 B
build/block-library/blocks/home-link/style-rtl.css 247 B
build/block-library/blocks/home-link/style.css 247 B
build/block-library/blocks/html/editor-rtl.css 283 B
build/block-library/blocks/html/editor.css 284 B
build/block-library/blocks/image/editor-rtl.css 728 B
build/block-library/blocks/image/editor.css 728 B
build/block-library/blocks/image/style-rtl.css 482 B
build/block-library/blocks/image/style.css 487 B
build/block-library/blocks/image/theme-rtl.css 124 B
build/block-library/blocks/image/theme.css 124 B
build/block-library/blocks/latest-comments/style-rtl.css 284 B
build/block-library/blocks/latest-comments/style.css 284 B
build/block-library/blocks/latest-posts/editor-rtl.css 137 B
build/block-library/blocks/latest-posts/editor.css 137 B
build/block-library/blocks/latest-posts/style-rtl.css 528 B
build/block-library/blocks/latest-posts/style.css 527 B
build/block-library/blocks/media-text/editor-rtl.css 266 B
build/block-library/blocks/media-text/editor.css 263 B
build/block-library/blocks/media-text/style-rtl.css 488 B
build/block-library/blocks/media-text/style.css 485 B
build/block-library/blocks/more/editor-rtl.css 431 B
build/block-library/blocks/more/editor.css 431 B
build/block-library/blocks/navigation-link/editor-rtl.css 489 B
build/block-library/blocks/navigation-link/editor.css 488 B
build/block-library/blocks/navigation-link/style-rtl.css 94 B
build/block-library/blocks/navigation-link/style.css 94 B
build/block-library/blocks/navigation/view.min.js 2.52 kB
build/block-library/blocks/nextpage/editor-rtl.css 395 B
build/block-library/blocks/nextpage/editor.css 395 B
build/block-library/blocks/page-list/editor-rtl.css 310 B
build/block-library/blocks/page-list/editor.css 310 B
build/block-library/blocks/page-list/style-rtl.css 241 B
build/block-library/blocks/page-list/style.css 241 B
build/block-library/blocks/paragraph/editor-rtl.css 157 B
build/block-library/blocks/paragraph/editor.css 157 B
build/block-library/blocks/post-author/editor-rtl.css 210 B
build/block-library/blocks/post-author/editor.css 210 B
build/block-library/blocks/post-author/style-rtl.css 182 B
build/block-library/blocks/post-author/style.css 181 B
build/block-library/blocks/post-comments-form/style-rtl.css 140 B
build/block-library/blocks/post-comments-form/style.css 140 B
build/block-library/blocks/post-comments/style-rtl.css 360 B
build/block-library/blocks/post-comments/style.css 359 B
build/block-library/blocks/post-content/editor-rtl.css 138 B
build/block-library/blocks/post-content/editor.css 138 B
build/block-library/blocks/post-excerpt/editor-rtl.css 73 B
build/block-library/blocks/post-excerpt/editor.css 73 B
build/block-library/blocks/post-excerpt/style-rtl.css 69 B
build/block-library/blocks/post-excerpt/style.css 69 B
build/block-library/blocks/post-featured-image/editor-rtl.css 398 B
build/block-library/blocks/post-featured-image/editor.css 398 B
build/block-library/blocks/post-featured-image/style-rtl.css 143 B
build/block-library/blocks/post-featured-image/style.css 143 B
build/block-library/blocks/post-template/editor-rtl.css 99 B
build/block-library/blocks/post-template/editor.css 98 B
build/block-library/blocks/post-template/style-rtl.css 378 B
build/block-library/blocks/post-template/style.css 379 B
build/block-library/blocks/post-terms/style-rtl.css 73 B
build/block-library/blocks/post-terms/style.css 73 B
build/block-library/blocks/post-title/style-rtl.css 60 B
build/block-library/blocks/post-title/style.css 60 B
build/block-library/blocks/preformatted/style-rtl.css 103 B
build/block-library/blocks/preformatted/style.css 103 B
build/block-library/blocks/pullquote/editor-rtl.css 198 B
build/block-library/blocks/pullquote/editor.css 198 B
build/block-library/blocks/pullquote/theme-rtl.css 167 B
build/block-library/blocks/pullquote/theme.css 167 B
build/block-library/blocks/query-pagination-numbers/editor-rtl.css 122 B
build/block-library/blocks/query-pagination-numbers/editor.css 121 B
build/block-library/blocks/query-pagination/editor-rtl.css 270 B
build/block-library/blocks/query-pagination/editor.css 262 B
build/block-library/blocks/query-pagination/style-rtl.css 168 B
build/block-library/blocks/query-pagination/style.css 168 B
build/block-library/blocks/query-title/editor-rtl.css 85 B
build/block-library/blocks/query-title/editor.css 85 B
build/block-library/blocks/query/editor-rtl.css 131 B
build/block-library/blocks/query/editor.css 132 B
build/block-library/blocks/quote/theme-rtl.css 220 B
build/block-library/blocks/quote/theme.css 222 B
build/block-library/blocks/rss/editor-rtl.css 202 B
build/block-library/blocks/rss/editor.css 204 B
build/block-library/blocks/rss/style-rtl.css 289 B
build/block-library/blocks/rss/style.css 288 B
build/block-library/blocks/search/editor-rtl.css 165 B
build/block-library/blocks/search/editor.css 165 B
build/block-library/blocks/search/style-rtl.css 374 B
build/block-library/blocks/search/style.css 375 B
build/block-library/blocks/search/theme-rtl.css 64 B
build/block-library/blocks/search/theme.css 64 B
build/block-library/blocks/separator/editor-rtl.css 99 B
build/block-library/blocks/separator/editor.css 99 B
build/block-library/blocks/separator/style-rtl.css 250 B
build/block-library/blocks/separator/style.css 250 B
build/block-library/blocks/separator/theme-rtl.css 172 B
build/block-library/blocks/separator/theme.css 172 B
build/block-library/blocks/shortcode/editor-rtl.css 474 B
build/block-library/blocks/shortcode/editor.css 474 B
build/block-library/blocks/site-logo/editor-rtl.css 462 B
build/block-library/blocks/site-logo/editor.css 464 B
build/block-library/blocks/site-logo/style-rtl.css 153 B
build/block-library/blocks/site-logo/style.css 153 B
build/block-library/blocks/site-tagline/editor-rtl.css 86 B
build/block-library/blocks/site-tagline/editor.css 86 B
build/block-library/blocks/site-title/editor-rtl.css 84 B
build/block-library/blocks/site-title/editor.css 84 B
build/block-library/blocks/social-link/editor-rtl.css 165 B
build/block-library/blocks/social-link/editor.css 165 B
build/block-library/blocks/social-links/editor-rtl.css 812 B
build/block-library/blocks/social-links/editor.css 811 B
build/block-library/blocks/social-links/style-rtl.css 1.33 kB
build/block-library/blocks/social-links/style.css 1.33 kB
build/block-library/blocks/spacer/editor-rtl.css 307 B
build/block-library/blocks/spacer/editor.css 307 B
build/block-library/blocks/spacer/style-rtl.css 48 B
build/block-library/blocks/spacer/style.css 48 B
build/block-library/blocks/table/editor-rtl.css 471 B
build/block-library/blocks/table/editor.css 472 B
build/block-library/blocks/table/style-rtl.css 481 B
build/block-library/blocks/table/style.css 481 B
build/block-library/blocks/table/theme-rtl.css 188 B
build/block-library/blocks/table/theme.css 188 B
build/block-library/blocks/tag-cloud/style-rtl.css 146 B
build/block-library/blocks/tag-cloud/style.css 146 B
build/block-library/blocks/template-part/editor-rtl.css 636 B
build/block-library/blocks/template-part/editor.css 635 B
build/block-library/blocks/template-part/theme-rtl.css 101 B
build/block-library/blocks/template-part/theme.css 101 B
build/block-library/blocks/term-description/editor-rtl.css 90 B
build/block-library/blocks/term-description/editor.css 90 B
build/block-library/blocks/text-columns/editor-rtl.css 95 B
build/block-library/blocks/text-columns/editor.css 95 B
build/block-library/blocks/text-columns/style-rtl.css 166 B
build/block-library/blocks/text-columns/style.css 166 B
build/block-library/blocks/verse/style-rtl.css 87 B
build/block-library/blocks/verse/style.css 87 B
build/block-library/blocks/video/editor-rtl.css 571 B
build/block-library/blocks/video/editor.css 572 B
build/block-library/blocks/video/style-rtl.css 173 B
build/block-library/blocks/video/style.css 173 B
build/block-library/blocks/video/theme-rtl.css 124 B
build/block-library/blocks/video/theme.css 124 B
build/block-library/reset-rtl.css 527 B
build/block-library/reset.css 527 B
build/block-library/theme-rtl.css 658 B
build/block-library/theme.css 663 B
build/block-serialization-default-parser/index.min.js 1.09 kB
build/block-serialization-spec-parser/index.min.js 2.79 kB
build/customize-widgets/index.min.js 11.1 kB
build/customize-widgets/style-rtl.css 1.5 kB
build/customize-widgets/style.css 1.49 kB
build/data-controls/index.min.js 614 B
build/data/index.min.js 7.1 kB
build/date/index.min.js 31.5 kB
build/deprecated/index.min.js 428 B
build/dom-ready/index.min.js 304 B
build/dom/index.min.js 4.53 kB
build/edit-navigation/style-rtl.css 3.14 kB
build/edit-navigation/style.css 3.14 kB
build/edit-post/classic-rtl.css 492 B
build/edit-post/classic.css 494 B
build/edit-site/style-rtl.css 5.07 kB
build/edit-site/style.css 5.07 kB
build/edit-widgets/style-rtl.css 4.06 kB
build/edit-widgets/style.css 4.06 kB
build/editor/style-rtl.css 3.74 kB
build/editor/style.css 3.73 kB
build/element/index.min.js 3.17 kB
build/escape-html/index.min.js 517 B
build/format-library/index.min.js 5.36 kB
build/format-library/style-rtl.css 668 B
build/format-library/style.css 669 B
build/hooks/index.min.js 1.55 kB
build/html-entities/index.min.js 424 B
build/is-shallow-equal/index.min.js 501 B
build/keyboard-shortcuts/index.min.js 1.49 kB
build/keycodes/index.min.js 1.25 kB
build/list-reusable-blocks/index.min.js 1.85 kB
build/list-reusable-blocks/style-rtl.css 838 B
build/list-reusable-blocks/style.css 838 B
build/media-utils/index.min.js 2.88 kB
build/notices/index.min.js 845 B
build/nux/index.min.js 2.03 kB
build/nux/style-rtl.css 747 B
build/nux/style.css 743 B
build/plugins/index.min.js 1.83 kB
build/primitives/index.min.js 921 B
build/priority-queue/index.min.js 582 B
build/react-i18n/index.min.js 671 B
build/redux-routine/index.min.js 2.63 kB
build/reusable-blocks/index.min.js 2.28 kB
build/reusable-blocks/style-rtl.css 256 B
build/reusable-blocks/style.css 256 B
build/server-side-render/index.min.js 1.32 kB
build/shortcode/index.min.js 1.48 kB
build/token-list/index.min.js 562 B
build/url/index.min.js 1.74 kB
build/viewport/index.min.js 1.02 kB
build/warning/index.min.js 248 B
build/widgets/index.min.js 6.37 kB
build/widgets/style-rtl.css 1.05 kB
build/widgets/style.css 1.05 kB
build/wordcount/index.min.js 1.04 kB

compressed-size-action

@enejb enejb changed the title [Rnmobile] Update the bottom sheet header [Mobile] Update the bottom sheet header Aug 26, 2021
Copy link
Contributor

@SiobhyB SiobhyB left a comment

Choose a reason for hiding this comment

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

I tested the following in the demo app for both iOS and Android, including both light and dark mode, and confirm that the header looks visually the same as before the changes:


  • Button Block

    • Button Width
    • Link Settings
  • Image block

    • Alt text
  • Cover Block

    • Edit Focal Point
    • Color Picker
  • Paragraph Block

    • Font Site Settings.
    • Colour Settings

I made a couple of small suggestions for the README and also asked a question about the navigation-header-native.js file (i.e. whether there's a reason it can't be deleted). Other than that, all the code makes sense to me and I agree the updated component is more readable. :) As I couldn't spot any obvious big issues or blockers, I've approved from my side.

@@ -600,6 +601,7 @@ ThemedBottomSheet.Button = Button;
ThemedBottomSheet.Cell = Cell;
ThemedBottomSheet.SubSheet = BottomSheetSubSheet;
ThemedBottomSheet.NavigationHeader = NavigationHeader;
Copy link
Contributor

Choose a reason for hiding this comment

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

As far as I can see, the NavigationHeader component is no longer in use anywhere and removing this reference doesn't have any effect on the BottomSheet's header component. Is there a reason for keeping the bottom-sheet/navigation-header.native.js file and references to the component?

Copy link
Contributor Author

@enejb enejb Aug 26, 2021

Choose a reason for hiding this comment

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

I think we can remove it. Good catch!

Header components is meant to be used to compose the header inside the BottomSheet.

### Usage
See
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
See

It looks like this can either be removed or perhaps there was a missing referencing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the suggestion @SiobhyB The documentation section got converted updated in #34339.

@@ -0,0 +1,91 @@
# Header

Header components is meant to be used to compose the header inside the BottomSheet.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Header components is meant to be used to compose the header inside the BottomSheet.
`BottomSheet.Header` should be used to add a header to the top of a `BottomSheet` component. It makes several other components available, which can then be used to compose the header's content.

It took me a bit to fully process how this component works, so think adding a bit more detail to the intro might help with clarity. WDYT?

Copy link
Member

@dcalhoun dcalhoun 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 really great work! Thank you!

I think abstractions like this require a lot of thought to get right. So, thank you for spending the time on this and please have grace with the large amounts of comments questions I pose. 😄 I appreciate you putting this together.

I noticed that the bottom sheet for the Columns block variation selection does not use these components. Is that intentional? I would think we should use these new components there as well for consistency. WDYT?

Comment on lines 91 to 93
function CloseButton( { onPress } ) {
return <CancelButton onPress={ onPress } text={ __( 'Close' ) } />;
}
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure if the small text change to "Close" merits an entire component. I'm not sure it provides value. WDYT about leveraging CancelButton and passing text as a prop when needed instead?

<CancelButton onPress={ () => {} } text={ __( 'Close' ) } />

Copy link
Contributor Author

@enejb enejb Aug 26, 2021

Choose a reason for hiding this comment

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

I am not a big fan of the text prop. Mostly because I would expect the text to be passed down with via the children like

<Button onPress={ () => {}  }>{ __( 'Close' ) } ></Button>

but in this case, because we are not just rendering all the children but only in special cases. (only on iOS) having a prop of text could work well and we can make the component a bit more generic. and remove the need for the different components.

Another way we would accomplish the same thing would be if a had a specific some sort of type and then pass in the different ones. ( 'close', 'back', 'close' ) this would also help us set different accessibility hints in the future.
I am not a fan of this approach mostly since it creates type is a bit generic term and we end up in a place where we don't really know all the different types.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Coming back to think I think once we have more specific accessibility Hint and specific content.
I think it would make sense to have a block for each of the different "BackButtons" s.
Also, the code would read better and we could avoid things like

<BottomSheet.Header.CancelButton onPress={ close } text={ __( 'Close' ) } />

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't have strong opinions about the granularity of the components in this case, but I wanted to mention that there may be cases where "Close" "Cancel" and "Back" are use somewhat inconsistently. The componentization in this PR might also be a good opportunity to clarify the intended semantics of these.

Copy link
Member

Choose a reason for hiding this comment

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

I am not a big fan of the text prop. Mostly because I would expect the text to be passed down with via the children [...]

but in this case, because we are not just rendering all the children but only in special cases. (only on iOS) having a prop of text could work well and we can make the component a bit more generic. and remove the need for the different components.

Understandable. I think relying upon children over text generally makes sense and should be the default. In reality, the fact that the text is conditionally rendered doesn't prohibit us from setting it with children. We could still pass it as children.

That said, would it be better to communicate the conditional rendering via the property name? E.g. iosText.

<BottomSheet.Header.CancelButton iosText={ __('Close') } />

Another way we would accomplish the same thing would be if a had a specific some sort of type and then pass in the different ones. ( 'close', 'back', 'close' ) this would also help us set different accessibility hints in the future.
I am not a fan of this approach mostly since it creates type is a bit generic term and we end up in a place where we don't really know all the different types.

I agree that moving to an abstraction where there is a "type" prop is likely too far an abstraction (also CancelButton, BackButton, CloseButton is sort of already the "types"). The original limitation I ran into with the Help section refactor was that I could not pass custom text for the one-off "Cancel" text needed.

We could create "types" including one for the "Cancel" scenario, but it sort of puts us right back into the original limitation I hit. What if we encounter a new context where we need "Dismiss" text? If we encounter a new context, do we want to add another "type" or pass the required text via a freeform text prop? WDYT?

Coming back to think I think once we have more specific accessibility Hint and specific content.
I think it would make sense to have a block for each of the different "BackButtons" s.

I don't have strong opinions about the granularity of the components in this case, but I wanted to mention that there may be cases where "Close" "Cancel" and "Back" are use somewhat inconsistently. The componentization in this PR might also be a good opportunity to clarify the intended semantics of these.

The last two quotes are from each of @enejb and @mkevins separately, but I think you are both saying the same thing — that you might prefer to keep CloseButton. If I am interpreting that correctly, that is fine with me. My original question of its existence is loosely held. I understand how creating it as a separate component to mange the text and any other accessibility properties provides value. 👍🏻

}
/>
<BottomSheet.Header>
<BottomSheet.Header.CloseButton onPress={ close } />
Copy link
Member

@dcalhoun dcalhoun Aug 26, 2021

Choose a reason for hiding this comment

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

As questioned elsewhere, I think we may be better off passing the desired text here.

Suggested change
<BottomSheet.Header.CloseButton onPress={ close } />
<BottomSheet.Header.CancelButton onPress={ close } text={ __( 'Close' ) } />

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think you mean to write

<BottomSheet.Header.CancelButton onPress={ close } text={ __( 'Close' ) } />

Looking at the code I am not sure it is an improvement. Mostly since it creates confusion.
Maybe we should change it to?

<BottomSheet.Header.ReturnButton onPress={ close } text={ __( 'Close' ) } />

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 you mean to write

<BottomSheet.Header.CancelButton onPress={ close } text={ __( 'Close' ) } />

Ah, yes. I did make a typo with the text string.

Looking at the code I am not sure it is an improvement. Mostly since it creates confusion.
Maybe we should change it to?

<BottomSheet.Header.ReturnButton onPress={ close } text={ __( 'Close' ) } />

Confusion between the "CancelButton" component name and "Close" text? Possibly. If you believe renaming CancelButton provides more clarity, that works for me. ReturnButton or DismissButton could potentially work.

Copy link
Member

Choose a reason for hiding this comment

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

Leaving one additional note that this conversation will be moot if we decide to retain the CloseButton, which I am open to doing.

text-align: center;
font-weight: 600;
font-size: 16px;
position: absolute;
Copy link
Member

Choose a reason for hiding this comment

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

When I worked on the refactor for the Help section, I attempted to create the left-center-right layout while avoiding absolute positioning. I did this largely to reduce the likelihood of UI collisions. E.g. what happens with a really long title? Do you think there is any value in using the flex layout approach instead of absolute positioning?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The problem that I ran into is that the title component wasn't centred anymore once I removed the empty View component that was making things centred.
I am not sure how we can make this happen without using absolute positioning. I will see if I can remove the absolute positing by using align-items: "center".

Copy link
Member

Choose a reason for hiding this comment

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

Makes sense. If I am not mistaken, my CodePen I linked in my previous comment to does have the title centered even when the right button is not present. I used that in the original Help section header. So, I do believe it is possible.

Copy link
Member

Choose a reason for hiding this comment

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

That said, it may not be worth the effort or complexity. Absolute position may work well for our use case.

align-items: flex-start;
flex: 1;
justify-content: center;
z-index: 2;
Copy link
Member

Choose a reason for hiding this comment

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

If we avoid absolute positioning, it'd also likely negate the need for any z-index declarations.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

Comment on lines 87 to 92
<BottomSheet.Header>
<BottomSheet.Header.BackButton onPress={ goBack } />
<BottomSheet.Header.Title>
{ label }
</BottomSheet.Header.Title>
</BottomSheet.Header>
Copy link
Member

Choose a reason for hiding this comment

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

I have largely seen "compound" components used to share state via React Context. I have not often seen "compound" components created largely for style application, i.e. providing the structural styles needed to keep the header UI consistent.

I think this use is really smart, and could work well for (1) ensuring the styles are applied consistently and (2) provide the ability to compose the elements as necessary for each context.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

BottomSheet.Header.Title
I am not really sure if this is desired. I kind of like it mostly because it gives you a context where the compone is meant to be used but this same "advantage" makes it harder to reuse the same component.

For example.

<BottomSheet.Footer>
<Header.Title>Some footer title</Header.Title>
</BottomSheet.Footer>

but I guess at that point we could refactor it to look be part of the bottom sheet title component. But all that could be avoided if we made the component a bottom sheet component at this point. Thought?

Copy link
Contributor

Choose a reason for hiding this comment

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

Just a thought, but maybe "title" is not the best choice here 🤔 imho there should only be one title on a sheet.. so maybe label or heading is a better name?

Copy link
Member

Choose a reason for hiding this comment

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

I agree with both of your perspectives. I suppose there is a fine line between naming the is too restrictive and naming so generic that it does not communicate intent.

I do like "heading" instead of "title." If we desire to allow these components to be used in a footer, we could replace "header" with "navbar."

<BottomSheet.NavBar>
  <BottomSheet.NavBar.Heading>A Footer Component</BottomSheet.NavBar.Heading>
</BottomSheet.NavBar>

Leverage short, declarative statements when possible.
Copy link
Contributor

@mkevins mkevins left a comment

Choose a reason for hiding this comment

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

Thanks for these changes Enej! I made a few comments / suggestions, but none of them are blockers.

Also, I tested this for the link picker in the format library, and these changes don't seem to introduce any new regressions there. 👍

Comment on lines 49 to 67
## BottomSheet.Header.CancelButton

Displays a styled button to dismiss a full screen bottom sheet.

### Props

#### onPress

Callback invoked once the button is pressed.

## BottomSheet.Header.CloseButton

Displays a styled button to dismiss a full screen bottom sheet.

### Props

#### onPress

Callback invoked once the button is pressed.
Copy link
Contributor

Choose a reason for hiding this comment

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

Though the description here is the same for both of these components, I'm wondering about their intended semantics, and whether they really are the same. I think that Cancel implies "undoing" some changes that were made, while Close does not imply that. Otoh, what actually happens is entirely dependent on the implementation in the callback. Maybe we can find a way to define the difference between these components in the readme to guide developers that use these components toward a more consistent usage?

Copy link
Member

Choose a reason for hiding this comment

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

Otoh, what actually happens is entirely dependent on the implementation in the callback.

That was my original thought with the documentation for the onPress callback. The current description is very much focused on what does occur, not the intended usage.

Maybe we can find a way to define the difference between these components in the readme to guide developers that use these components toward a more consistent usage?

Counter to the current documentation (I modified) and my aforementioned original thought, I do understand and agree there is value in describing the intent. The description of the components themselves differ somewhat from the onPress prop description. E.g. ApplyButton states "Displays a styled button to apply settings of bottom sheet controls," which describe the intent to apply the settings.

If we want to update the documentation to better describe the intent of the components and props, that is fine with me. Apologies if my previous changes removed too much of that, and thus creating more work to add the intent back. 😄

Copy link
Contributor

Choose a reason for hiding this comment

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

Apologies if my previous changes removed too much of that, and thus creating more work to add the intent back.

No worries! I think it's great to discuss this and I'm happy this is being addressed. The usage of these patterns will certainly grow, so it's valuable to consider many paths. There is a tendency (and maybe a goal?) to make changes to block settings immediately reflected in the block rendering (i.e. no "confirm" or "cancel" needed). I think this can't cover the case for any fullscreen sheets, though, so this may be at least one source of tension. Historically, though, this may have been addressed in a somewhat ad-hoc way, giving rise to some redundancy in naming — but that's just my guess.

In any case, removing truly synonymous components and clarifying the usage of the remaining ones is a great idea. Also, I especially like the idea mentioned here to add iosText as a prop. This accurate signalling provides immediate clarity, whereas the current form feels like it is violating the principle of least surprise, imo.

Comment on lines 91 to 93
function CloseButton( { onPress } ) {
return <CancelButton onPress={ onPress } text={ __( 'Close' ) } />;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't have strong opinions about the granularity of the components in this case, but I wanted to mention that there may be cases where "Close" "Cancel" and "Back" are use somewhat inconsistently. The componentization in this PR might also be a good opportunity to clarify the intended semantics of these.

Comment on lines 87 to 92
<BottomSheet.Header>
<BottomSheet.Header.BackButton onPress={ goBack } />
<BottomSheet.Header.Title>
{ label }
</BottomSheet.Header.Title>
</BottomSheet.Header>
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a thought, but maybe "title" is not the best choice here 🤔 imho there should only be one title on a sheet.. so maybe label or heading is a better name?

@enejb
Copy link
Contributor Author

enejb commented Sep 6, 2021

Thanks for all the feedback and reviews @SiobhyB , @dcalhoun and @mkevins !

In my last update, I did the following:

  • Replaced the CancelButton and CloseButton with a DismissButton that defaults to "Cancel" and has an iosText prop to accommodate the "close" button case.
  • Updated the Components to be called. NavBar and Heading instead of Header and Title. So that they are a bit more generic.
  • Update the read me. to add more clarity.

I think things are in pretty good shape.

I tested this as best as I could on iOS and Android and it seems it works now as before.

Things to get done in different PRs.
[ ] Get clarification when it comes to the Touch Feedback.
[ ] Update the Variation control to use this new NavBar Component. (Columns Block)
[ ] Update the accessibilityLabels so that they make more sense for the different Dismiss / Back components.

Copy link
Member

@dcalhoun dcalhoun left a comment

Choose a reason for hiding this comment

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

LGTM. Well done! I retested on an iPhone 12 mini simulator and Android Pixel 5 emulator.

@enejb enejb merged commit 435119c into trunk Sep 7, 2021
@enejb enejb deleted the rnmobile/add/bottom-sheet-header branch September 7, 2021 15:56
@github-actions github-actions bot added this to the Gutenberg 11.5 milestone Sep 7, 2021
fullofcaffeine added a commit that referenced this pull request Sep 9, 2021
* trunk: (214 commits)
  Fix snackbar overflow on nav editor (#34661)
  Mobile - Allow disabling text and background color via theme.json (#34633)
  Fix disabled blocks logical error on Widgets screen (#34634)
  [Mobile] - Global styles - Add support to render font sizes and line height (#34144)
  ESLint Plugin: Update eslint jsdoc dependency (#34338)
  Scripts: Add CHANGELOG entry for `jest-dev-server` upgrade (#34657)
  Bump jest-dev-server to v5 (#34560)
  Refactor the `core-data` store to thunks (#28389)
  Only capture toolbars on parent Nav block when not in vertical mode (#34615)
  Update Changelog for 11.5.0-rc.1
  Bump plugin version to 11.5.0-rc.1
  Gallery block: Fix media placeholder height in site editor (#34629)
  Border Controls: Display color indicator and check selected color (#34467)
  Remove horizontal and vertical navigation block variations from inserter (#34614)
  AlignmentMatrixControl : Fix/update docs (#34624)
  Gap block support: force gap change to cause the block to re-render (fix Safari issue) (#34567)
  [Block Library - Social Links]: Use the new `flex` layout (#34493)
  [Mobile] Update the bottom sheet header (#34309)
  Group block: Add a row variation (#34535)
  Migrate entities.js to thunks (#34582)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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