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

Separator: Add means to control height #28409

Closed
wants to merge 10 commits into from

Conversation

aaronrobertshaw
Copy link
Contributor

@aaronrobertshaw aaronrobertshaw commented Jan 21, 2021

Description

  • Add customizable height to the separator block

How has this been tested?

Manually.

Testing Instructions

  1. Checkout this PR, create a new post and add a separator block
  2. Select the separator block and adjust its height via the bottom resize handle
  3. Confirm the block still displays correctly and that different colors & block styles can be applied.
  4. Adjust the separator block's height via the height control in the sidebar control and confirm the block's height updates
  5. Change the height units between px, em or rem. Switching units will reset the height. Adjust it again via the sidebar control and confirm visual height of block adjusts.
  6. Save the post and confirm the separator's height on the frontend
  7. Repeat steps 1-6 using different themes (several use varying methods of styling the block e.g. bottom borders, background colors and pseudo elements).

Native Testing Instructions

  1. Checkout this PR, start up native emulation e.g. npm run native start and npm run native ios
  2. Add a separator block to the post
  3. Open the block's controls and adjust its height in pixels
  4. Switch to other height units and ensure that the control's value is set to the default for that unit and the block's height visually adjusts accordingly.

Screenshots

SeparatorHeightV2

Previous pixel height only iteration screenshot

iOS

Types of changes

New feature.

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.

@aaronrobertshaw aaronrobertshaw added [Block] Separator Affects the Separator Block [Feature] Design Tools Tools that impact the appearance of blocks both to expand the number of tools and improve the experi labels Jan 21, 2021
@aaronrobertshaw aaronrobertshaw self-assigned this Jan 21, 2021
In this interation the separator isn't showing the box around it as the resizable box is resize like the coblocks variant. The resizing is smoother and CSS is tweaked without markup changes such that there should be no breakage.

Still needs work though.
@github-actions
Copy link

github-actions bot commented Jan 22, 2021

Size Change: -13.8 kB (-1%)

Total Size: 1.37 MB

Filename Size Change
build/a11y/index.js 1.14 kB +2 B (0%)
build/autop/index.js 2.84 kB +2 B (0%)
build/block-directory/index.js 9.1 kB +18 B (0%)
build/block-editor/index.js 123 kB +938 B (+1%)
build/block-editor/style-rtl.css 12.1 kB +119 B (+1%)
build/block-editor/style.css 12.1 kB +121 B (+1%)
build/block-library/blocks/archives/editor-rtl.css 61 B -135 B (-69%) 🏆
build/block-library/blocks/archives/editor.css 60 B -136 B (-69%) 🏆
build/block-library/blocks/audio/editor-rtl.css 58 B -136 B (-70%) 🏆
build/block-library/blocks/audio/editor.css 58 B -136 B (-70%) 🏆
build/block-library/blocks/audio/style-rtl.css 103 B -122 B (-54%) 🏆
build/block-library/blocks/audio/style.css 103 B -122 B (-54%) 🏆
build/block-library/blocks/block/editor-rtl.css 161 B -122 B (-43%) 🎉
build/block-library/blocks/block/editor.css 161 B -122 B (-43%) 🎉
build/block-library/blocks/button/editor-rtl.css 475 B -101 B (-18%) 👏
build/block-library/blocks/button/editor.css 474 B -103 B (-18%) 👏
build/block-library/blocks/button/style-rtl.css 465 B -87 B (-16%) 👏
build/block-library/blocks/button/style.css 464 B -88 B (-16%) 👏
build/block-library/blocks/buttons/editor-rtl.css 233 B -112 B (-32%) 🎉
build/block-library/blocks/buttons/editor.css 233 B -113 B (-33%) 🎉
build/block-library/blocks/buttons/style-rtl.css 303 B -116 B (-28%) 🎉
build/block-library/blocks/buttons/style.css 303 B -116 B (-28%) 🎉
build/block-library/blocks/calendar/style-rtl.css 208 B -111 B (-35%) 🎉
build/block-library/blocks/calendar/style.css 208 B -111 B (-35%) 🎉
build/block-library/blocks/categories/editor-rtl.css 84 B -126 B (-60%) 🏆
build/block-library/blocks/categories/editor.css 83 B -126 B (-60%) 🏆
build/block-library/blocks/categories/style-rtl.css 79 B -129 B (-62%) 🏆
build/block-library/blocks/categories/style.css 79 B -129 B (-62%) 🏆
build/block-library/blocks/code/style-rtl.css 90 B -126 B (-58%) 🏆
build/block-library/blocks/code/style.css 90 B -126 B (-58%) 🏆
build/block-library/blocks/columns/editor-rtl.css 190 B -110 B (-37%) 🎉
build/block-library/blocks/columns/editor.css 190 B -109 B (-36%) 🎉
build/block-library/blocks/columns/style-rtl.css 421 B -108 B (-20%) 🎉
build/block-library/blocks/columns/style.css 421 B -107 B (-20%) 🎉
build/block-library/blocks/cover/editor-rtl.css 390 B -134 B (-26%) 🎉
build/block-library/blocks/cover/editor.css 389 B -133 B (-25%) 🎉
build/block-library/blocks/cover/style-rtl.css 1.25 kB -48 B (-4%)
build/block-library/blocks/cover/style.css 1.25 kB -47 B (-4%)
build/block-library/blocks/embed/editor-rtl.css 486 B -108 B (-18%) 👏
build/block-library/blocks/embed/editor.css 486 B -109 B (-18%) 👏
build/block-library/blocks/embed/style-rtl.css 396 B -93 B (-19%) 👏
build/block-library/blocks/embed/style.css 395 B -94 B (-19%) 👏
build/block-library/blocks/file/editor-rtl.css 199 B -115 B (-37%) 🎉
build/block-library/blocks/file/editor.css 198 B -115 B (-37%) 🎉
build/block-library/blocks/file/style-rtl.css 248 B -104 B (-30%) 🎉
build/block-library/blocks/file/style.css 248 B -104 B (-30%) 🎉
build/block-library/blocks/freeform/editor-rtl.css 2.45 kB -98 B (-4%)
build/block-library/blocks/freeform/editor.css 2.45 kB -99 B (-4%)
build/block-library/blocks/gallery/editor-rtl.css 679 B -104 B (-13%) 👏
build/block-library/blocks/gallery/editor.css 679 B -104 B (-13%) 👏
build/block-library/blocks/gallery/style-rtl.css 1.07 kB -106 B (-9%)
build/block-library/blocks/gallery/style.css 1.06 kB -106 B (-9%)
build/block-library/blocks/group/editor-rtl.css 318 B -115 B (-27%) 🎉
build/block-library/blocks/group/editor.css 317 B -115 B (-27%) 🎉
build/block-library/blocks/group/style-rtl.css 57 B -133 B (-70%) 🏆
build/block-library/blocks/group/style.css 57 B -133 B (-70%) 🏆
build/block-library/blocks/heading/editor-rtl.css 129 B -119 B (-48%) 🎉
build/block-library/blocks/heading/editor.css 129 B -119 B (-48%) 🎉
build/block-library/blocks/heading/style-rtl.css 76 B -136 B (-64%) 🏆
build/block-library/blocks/heading/style.css 76 B -136 B (-64%) 🏆
build/block-library/blocks/html/editor-rtl.css 281 B -103 B (-27%) 🎉
build/block-library/blocks/html/editor.css 281 B -104 B (-27%) 🎉
build/block-library/blocks/image/editor-rtl.css 717 B -84 B (-10%) 👏
build/block-library/blocks/image/editor.css 716 B -84 B (-10%) 👏
build/block-library/blocks/image/style-rtl.css 477 B -92 B (-16%) 👏
build/block-library/blocks/image/style.css 478 B -92 B (-16%) 👏
build/block-library/blocks/latest-comments/editor-rtl.css 159 B -118 B (-43%) 🎉
build/block-library/blocks/latest-comments/editor.css 158 B -117 B (-43%) 🎉
build/block-library/blocks/latest-comments/style-rtl.css 269 B -113 B (-30%) 🎉
build/block-library/blocks/latest-comments/style.css 269 B -113 B (-30%) 🎉
build/block-library/blocks/latest-posts/editor-rtl.css 137 B -117 B (-46%) 🎉
build/block-library/blocks/latest-posts/editor.css 137 B -117 B (-46%) 🎉
build/block-library/blocks/latest-posts/style-rtl.css 523 B -111 B (-18%) 👏
build/block-library/blocks/latest-posts/style.css 522 B -112 B (-18%) 👏
build/block-library/blocks/list/editor-rtl.css 65 B -138 B (-68%) 🏆
build/block-library/blocks/list/editor.css 65 B -138 B (-68%) 🏆
build/block-library/blocks/list/style-rtl.css 63 B -138 B (-69%) 🏆
build/block-library/blocks/list/style.css 63 B -138 B (-69%) 🏆
build/block-library/blocks/media-text/editor-rtl.css 191 B -120 B (-39%) 🎉
build/block-library/blocks/media-text/editor.css 191 B -120 B (-39%) 🎉
build/block-library/blocks/media-text/style-rtl.css 535 B -107 B (-17%) 👏
build/block-library/blocks/media-text/style.css 532 B -108 B (-17%) 👏
build/block-library/blocks/more/editor-rtl.css 434 B -111 B (-20%) 🎉
build/block-library/blocks/more/editor.css 434 B -111 B (-20%) 🎉
build/block-library/blocks/navigation-link/editor-rtl.css 395 B -108 B (-21%) 🎉
build/block-library/blocks/navigation-link/editor.css 397 B -107 B (-21%) 🎉
build/block-library/blocks/navigation-link/style-rtl.css 704 B -101 B (-13%) 👏
build/block-library/blocks/navigation-link/style.css 702 B -101 B (-13%) 👏
build/block-library/blocks/navigation/editor-rtl.css 1.34 kB -145 B (-10%) 👏
build/block-library/blocks/navigation/editor.css 1.34 kB -146 B (-10%) 👏
build/block-library/blocks/navigation/style-rtl.css 195 B -94 B (-33%) 🎉
build/block-library/blocks/navigation/style.css 195 B -94 B (-33%) 🎉
build/block-library/blocks/nextpage/editor-rtl.css 395 B -112 B (-22%) 🎉
build/block-library/blocks/nextpage/editor.css 395 B -112 B (-22%) 🎉
build/block-library/blocks/paragraph/editor-rtl.css 109 B -127 B (-54%) 🏆
build/block-library/blocks/paragraph/editor.css 109 B -127 B (-54%) 🏆
build/block-library/blocks/paragraph/style-rtl.css 273 B -119 B (-30%) 🎉
build/block-library/blocks/paragraph/style.css 273 B -119 B (-30%) 🎉
build/block-library/blocks/post-author/editor-rtl.css 209 B -120 B (-36%) 🎉
build/block-library/blocks/post-author/editor.css 209 B -120 B (-36%) 🎉
build/block-library/blocks/post-author/style-rtl.css 183 B -120 B (-40%) 🎉
build/block-library/blocks/post-author/style.css 184 B -119 B (-39%) 🎉
build/block-library/blocks/post-comments-form/style-rtl.css 250 B -108 B (-30%) 🎉
build/block-library/blocks/post-comments-form/style.css 250 B -108 B (-30%) 🎉
build/block-library/blocks/post-content/editor-rtl.css 139 B -123 B (-47%) 🎉
build/block-library/blocks/post-content/editor.css 139 B -123 B (-47%) 🎉
build/block-library/blocks/post-excerpt/editor-rtl.css 73 B -133 B (-65%) 🏆
build/block-library/blocks/post-excerpt/editor.css 73 B -133 B (-65%) 🏆
build/block-library/blocks/post-featured-image/editor-rtl.css 338 B -115 B (-25%) 🎉
build/block-library/blocks/post-featured-image/editor.css 338 B -115 B (-25%) 🎉
build/block-library/blocks/post-featured-image/style-rtl.css 100 B -123 B (-55%) 🏆
build/block-library/blocks/post-featured-image/style.css 100 B -123 B (-55%) 🏆
build/block-library/blocks/preformatted/style-rtl.css 63 B -130 B (-67%) 🏆
build/block-library/blocks/preformatted/style.css 63 B -130 B (-67%) 🏆
build/block-library/blocks/pullquote/editor-rtl.css 183 B -121 B (-40%) 🎉
build/block-library/blocks/pullquote/editor.css 183 B -121 B (-40%) 🎉
build/block-library/blocks/pullquote/style-rtl.css 316 B -112 B (-26%) 🎉
build/block-library/blocks/pullquote/style.css 316 B -112 B (-26%) 🎉
build/block-library/blocks/query-loop/editor-rtl.css 90 B -127 B (-59%) 🏆
build/block-library/blocks/query-loop/editor.css 89 B -127 B (-59%) 🏆
build/block-library/blocks/query-loop/style-rtl.css 315 B -112 B (-26%) 🎉
build/block-library/blocks/query-loop/style.css 317 B -112 B (-26%) 🎉
build/block-library/blocks/query-pagination-numbers/editor-rtl.css 122 B -121 B (-50%) 🏆
build/block-library/blocks/query-pagination-numbers/editor.css 121 B -119 B (-50%) 🏆
build/block-library/blocks/query-pagination/editor-rtl.css 270 B -120 B (-31%) 🎉
build/block-library/blocks/query-pagination/editor.css 262 B -117 B (-31%) 🎉
build/block-library/blocks/query-pagination/style-rtl.css 168 B -120 B (-42%) 🎉
build/block-library/blocks/query-pagination/style.css 168 B -120 B (-42%) 🎉
build/block-library/blocks/query/editor-rtl.css 159 B -120 B (-43%) 🎉
build/block-library/blocks/query/editor.css 160 B -119 B (-43%) 🎉
build/block-library/blocks/quote/editor-rtl.css 61 B -134 B (-69%) 🏆
build/block-library/blocks/quote/editor.css 61 B -134 B (-69%) 🏆
build/block-library/blocks/quote/style-rtl.css 169 B -115 B (-40%) 🎉
build/block-library/blocks/quote/style.css 169 B -116 B (-41%) 🎉
build/block-library/blocks/rss/editor-rtl.css 201 B -106 B (-35%) 🎉
build/block-library/blocks/rss/editor.css 202 B -107 B (-35%) 🎉
build/block-library/blocks/rss/style-rtl.css 290 B -104 B (-26%) 🎉
build/block-library/blocks/rss/style.css 290 B -103 B (-26%) 🎉
build/block-library/blocks/search/editor-rtl.css 165 B -120 B (-42%) 🎉
build/block-library/blocks/search/editor.css 165 B -120 B (-42%) 🎉
build/block-library/blocks/search/style-rtl.css 342 B -112 B (-25%) 🎉
build/block-library/blocks/search/style.css 344 B -112 B (-25%) 🎉
build/block-library/blocks/separator/editor-rtl.css 239 B +10 B (+4%)
build/block-library/blocks/separator/editor.css 239 B +10 B (+4%)
build/block-library/blocks/separator/style-rtl.css 236 B -116 B (-33%) 🎉
build/block-library/blocks/separator/style.css 236 B -116 B (-33%) 🎉
build/block-library/blocks/shortcode/editor-rtl.css 504 B -99 B (-16%) 👏
build/block-library/blocks/shortcode/editor.css 504 B -99 B (-16%) 👏
build/block-library/blocks/site-logo/editor-rtl.css 201 B -120 B (-37%) 🎉
build/block-library/blocks/site-logo/editor.css 201 B -120 B (-37%) 🎉
build/block-library/blocks/site-logo/style-rtl.css 117 B -121 B (-51%) 🏆
build/block-library/blocks/site-logo/style.css 117 B -121 B (-51%) 🏆
build/block-library/blocks/social-link/editor-rtl.css 164 B -119 B (-42%) 🎉
build/block-library/blocks/social-link/editor.css 165 B -118 B (-42%) 🎉
build/block-library/blocks/social-links/editor-rtl.css 696 B -115 B (-14%) 👏
build/block-library/blocks/social-links/editor.css 696 B -114 B (-14%) 👏
build/block-library/blocks/social-links/style-rtl.css 1.37 kB -109 B (-7%)
build/block-library/blocks/social-links/style.css 1.37 kB -109 B (-7%)
build/block-library/blocks/spacer/editor-rtl.css 302 B -114 B (-27%) 🎉
build/block-library/blocks/spacer/editor.css 302 B -114 B (-27%) 🎉
build/block-library/blocks/spacer/style-rtl.css 48 B -136 B (-74%) 🏆
build/block-library/blocks/spacer/style.css 48 B -136 B (-74%) 🏆
build/block-library/blocks/subhead/editor-rtl.css 99 B -124 B (-56%) 🏆
build/block-library/blocks/subhead/editor.css 99 B -124 B (-56%) 🏆
build/block-library/blocks/subhead/style-rtl.css 80 B -130 B (-62%) 🏆
build/block-library/blocks/subhead/style.css 80 B -130 B (-62%) 🏆
build/block-library/blocks/table/editor-rtl.css 489 B -104 B (-18%) 👏
build/block-library/blocks/table/editor.css 489 B -104 B (-18%) 👏
build/block-library/blocks/table/style-rtl.css 386 B -115 B (-23%) 🎉
build/block-library/blocks/table/style.css 386 B -115 B (-23%) 🎉
build/block-library/blocks/tag-cloud/editor-rtl.css 118 B -119 B (-50%) 🏆
build/block-library/blocks/tag-cloud/editor.css 118 B -117 B (-50%) 🏆
build/block-library/blocks/tag-cloud/style-rtl.css 94 B -127 B (-57%) 🏆
build/block-library/blocks/tag-cloud/style.css 94 B -127 B (-57%) 🏆
build/block-library/blocks/template-part/editor-rtl.css 557 B -237 B (-30%) 🎉
build/block-library/blocks/template-part/editor.css 556 B -238 B (-30%) 🎉
build/block-library/blocks/text-columns/editor-rtl.css 95 B -125 B (-57%) 🏆
build/block-library/blocks/text-columns/editor.css 95 B -125 B (-57%) 🏆
build/block-library/blocks/text-columns/style-rtl.css 166 B -117 B (-41%) 🎉
build/block-library/blocks/text-columns/style.css 166 B -117 B (-41%) 🎉
build/block-library/blocks/verse/editor-rtl.css 62 B -132 B (-68%) 🏆
build/block-library/blocks/verse/editor.css 62 B -132 B (-68%) 🏆
build/block-library/blocks/verse/style-rtl.css 87 B -128 B (-60%) 🏆
build/block-library/blocks/verse/style.css 87 B -128 B (-60%) 🏆
build/block-library/blocks/video/editor-rtl.css 504 B -113 B (-18%) 👏
build/block-library/blocks/video/editor.css 503 B -114 B (-18%) 👏
build/block-library/blocks/video/style-rtl.css 193 B -110 B (-36%) 🎉
build/block-library/blocks/video/style.css 193 B -111 B (-37%) 🎉
build/block-library/editor-rtl.css 9.1 kB -104 B (-1%)
build/block-library/editor.css 9.08 kB -102 B (-1%)
build/block-library/index.js 145 kB +2 kB (+1%)
build/block-library/style-rtl.css 8.8 kB +150 B (+2%)
build/block-library/style.css 8.8 kB +147 B (+2%)
build/block-library/theme-rtl.css 748 B -112 B (-13%) 👏
build/block-library/theme.css 748 B -112 B (-13%) 👏
build/block-serialization-default-parser/index.js 1.88 kB +1 B (0%)
build/blocks/index.js 48.2 kB -42 B (0%)
build/components/index.js 270 kB +4.17 kB (+2%)
build/components/style-rtl.css 15.5 kB +22 B (0%)
build/components/style.css 15.5 kB +23 B (0%)
build/compose/index.js 11 kB -169 B (-2%)
build/core-data/index.js 16.8 kB +1.59 kB (+10%) ⚠️
build/data-controls/index.js 827 B -3 B (0%)
build/data/index.js 8.86 kB -109 B (-1%)
build/date/index.js 31.8 kB -1 B (0%)
build/dom-ready/index.js 570 B -1 B (0%)
build/dom/index.js 4.93 kB +2 B (0%)
build/edit-navigation/index.js 10.5 kB -620 B (-6%)
build/edit-navigation/style-rtl.css 1.12 kB +184 B (+20%) 🚨
build/edit-navigation/style.css 1.12 kB +176 B (+19%) ⚠️
build/edit-post/index.js 307 kB +545 B (0%)
build/edit-post/style-rtl.css 6.79 kB +276 B (+4%)
build/edit-post/style.css 6.78 kB +275 B (+4%)
build/edit-site/index.js 24.8 kB +761 B (+3%)
build/edit-site/style-rtl.css 4.04 kB +22 B (+1%)
build/edit-site/style.css 4.04 kB +22 B (+1%)
build/edit-widgets/index.js 20 kB -3.54 kB (-15%) 👏
build/edit-widgets/style-rtl.css 3.2 kB +28 B (+1%)
build/edit-widgets/style.css 3.2 kB +24 B (+1%)
build/editor/index.js 41.8 kB +41 B (0%)
build/element/index.js 4.61 kB -3 B (0%)
build/format-library/index.js 6.76 kB +4 B (0%)
build/hooks/index.js 2.28 kB +9 B (0%)
build/i18n/index.js 4.01 kB +446 B (+13%) ⚠️
build/keyboard-shortcuts/index.js 2.53 kB +3 B (0%)
build/list-reusable-blocks/index.js 3.15 kB +13 B (0%)
build/media-utils/index.js 5.35 kB +37 B (+1%)
build/notices/index.js 1.85 kB -1 B (0%)
build/nux/index.js 3.41 kB +2 B (0%)
build/plugins/index.js 2.54 kB +8 B (0%)
build/redux-routine/index.js 2.84 kB -2 B (0%)
build/reusable-blocks/index.js 2.92 kB -1 B (0%)
build/rich-text/index.js 13.4 kB +2 B (0%)
build/server-side-render/index.js 2.77 kB +10 B (0%)
build/shortcode/index.js 1.7 kB -1 B (0%)
build/url/index.js 3.01 kB -2 B (0%)
build/wordcount/index.js 1.22 kB -1 B (0%)
ℹ️ View Unchanged
Filename Size Change
build/annotations/index.js 3.77 kB 0 B
build/api-fetch/index.js 3.4 kB 0 B
build/blob/index.js 665 B 0 B
build/block-directory/style-rtl.css 1.01 kB 0 B
build/block-directory/style.css 1.01 kB 0 B
build/block-library/blocks/page-list/editor-rtl.css 214 B 0 B
build/block-library/blocks/page-list/editor.css 214 B 0 B
build/block-library/blocks/page-list/style-rtl.css 527 B 0 B
build/block-library/blocks/page-list/style.css 526 B 0 B
build/block-library/common-rtl.css 1.01 kB 0 B
build/block-library/common.css 1.01 kB 0 B
build/block-serialization-spec-parser/index.js 3.06 kB 0 B
build/customize-widgets/index.js 4.08 kB 0 B
build/customize-widgets/style-rtl.css 168 B 0 B
build/customize-widgets/style.css 168 B 0 B
build/deprecated/index.js 769 B 0 B
build/editor/editor-styles-rtl.css 543 B 0 B
build/editor/editor-styles.css 545 B 0 B
build/editor/style-rtl.css 3.89 kB 0 B
build/editor/style.css 3.89 kB 0 B
build/escape-html/index.js 735 B 0 B
build/format-library/style-rtl.css 637 B 0 B
build/format-library/style.css 639 B 0 B
build/html-entities/index.js 622 B 0 B
build/is-shallow-equal/index.js 699 B 0 B
build/keycodes/index.js 1.93 kB 0 B
build/list-reusable-blocks/style-rtl.css 629 B 0 B
build/list-reusable-blocks/style.css 628 B 0 B
build/nux/style-rtl.css 731 B 0 B
build/nux/style.css 727 B 0 B
build/primitives/index.js 1.42 kB 0 B
build/priority-queue/index.js 791 B 0 B
build/token-list/index.js 1.27 kB 0 B
build/viewport/index.js 1.86 kB 0 B
build/warning/index.js 1.14 kB 0 B

compressed-size-action

This approach has the downside of needed to overcome theme CSS to be able to display the separator style in a different way for it to be vertically centered.
This change keeps block selection styling and visual cues without losing the normal styling of the `hr`. It also allows the ResizableBox control to naturally represent the separator's height.

The downside is it is a little hacky to get around themes styling separators using bottom borders, background colors and pseudo elements.
@gziolo
Copy link
Member

gziolo commented Jan 22, 2021

As far I remember this blocks is cross-platform and works in React Native. I anticipate this refactoring will break it in the mobile app.

@hypest, I'm flagging it so the mobile team could advise on how to move forward in a seamless way.

@hypest
Copy link
Contributor

hypest commented Jan 22, 2021

Thanks for the ping @gziolo , I opened wordpress-mobile/gutenberg-mobile#3041 on the gutenberg-mobile side to have the extended native mobile tests run. We can look into this deeper if any test fails 👍

@geriux
Copy link
Member

geriux commented Jan 22, 2021

Hey 👋

I anticipate this refactoring will break it in the mobile app.

Indeed, it's broken using this PR.

One issue is related to accessing an undefined variable:

Second, is because it's using div:

We had similar issues for this block before. I'd suggest avoiding using div in cross-platform components but if it's really needed then using View from packages/primitives/src/view

Please let us know if there's something we can help with to not block this PR, even if it's just testing any new changes.

Thanks!

@apeatling
Copy link
Contributor

@aaronrobertshaw I think this should also include an input field so the user knows what height has been set, and adds the ability set a specific value. Much like the search block input minus the percentages?

Screen Shot 2021-01-22 at 11 37 52 AM

@paaljoachim
Copy link
Contributor

Here is an issue for the Separator block: #25989
There is also an older PR here: #26764

@paaljoachim
Copy link
Contributor

Or we can also use the same setup as the Spacer block.

Screen Shot 2021-01-23 at 00 20 12

@ItsJonQ and @jasmussen might also want to know about this PR.

* Add sidebar for height control
* Add optional chaining to call to strip class from `className` to prevent error in mobile
* Replace div with View component for mobile use
@aaronrobertshaw
Copy link
Contributor Author

aaronrobertshaw commented Jan 25, 2021

Thank you everyone for the testing and feedback 👍

I think this should also include an input field so the user knows what height has been set, and adds the ability set a specific value. Much like the search block input minus the percentages?

A control for the separator's height has been added to the sidebar matching the control in the spacer block as suggested.

Indeed, it's broken using this PR.

I've added optional chaining to the call to replace the problematic class from the className. As suggested I've replaced the <div> with <View>. I no longer receives the reported errors when running this PR on mobile locally.

Regarding the use of div or View, I couldn't find a way around needing a wrapper here to still maintain the styling for the visual separator itself. There is a mix of approaches to styling the separator such as border bottom (default style), pseudo elements (dots) and background with fixed height (custom colors, non-dots). On top of that, different themes took different approaches again. So the wrapper to provide the height in the editor was the best that worked for me. The frontend remains essentially the same except for the styles splitting the height into as top and bottom margins on the normal <hr>.

@geriux it would be good to take you up on that offer to give this PR another test.

I also attempted simply adding the height control to the separator-settings.native.js file. While that works for specifying the height, the display of the block in the editor would need updating so that the separator's hr is vertically centred in the wrapper. I'm not sure of the best course of action here or whether I should be adding the native controls at all at this point.

Open to any suggestions on that.

@aaronrobertshaw
Copy link
Contributor Author

Another approach to adding margins or height to the separator block can be found in #28451 created today.

@aaronrobertshaw aaronrobertshaw changed the title [WIP] Separator: Add means to control height Separator: Add means to control height Jan 25, 2021
@aaronrobertshaw aaronrobertshaw marked this pull request as ready for review January 25, 2021 07:46
@paaljoachim
Copy link
Contributor

#28451 contains a very fascinating suggestion about how to better control where the line is seen in the Separator block!
In addition one would be able to change the width of the Separator line.

@aristath
Copy link
Member

Just my 2c: On my FSE theme I have responsive/adaptive typography (see theme.json). If the height is limited to px values then it will look OK for one viewport, but not scale properly for all viewports unless it's possible to also use em values.

@apeatling
Copy link
Contributor

This is one reason to use the same control as the search block. You can then select different units, including ems.

@aaronrobertshaw
Copy link
Contributor Author

I've updated this to use a <UnitControl> allowing non-pixel heights. The <ResizableBox> element didn't want to play nice with values that weren't in pixels or percentage. That said, I've worked around that such that we can at least see how the ResizableBox and its draggable handles UI might work with margins or heights of different units.

I'd say it would be possible to combine this with the approach using the margins-based spacing support.

The PR description has been updated with a new GIF of the current UI.

@aaronrobertshaw
Copy link
Contributor Author

After evolving this PR to handle different units, em & rem, the resulting code could benefit from a refactor. I think it's important to settle on an agreed approach and UI moving forward though before investing further efforts.

Notes:

  • Using the Resizablebox gives a more user friendly option to control height
  • This PR's wrapper allows for the separator block to be easily selectable by clicking anywhere in its height.
  • If only adjusting the margin you have to use the block navigator or be able to target the very thin <hr> to select the block.
  • Changing units results in a reset of the height value

Next steps:

  • Should the UI include the ResizableBox component to provide user friendly draggable sizing?
  • Refactor this PR to polish up the code
  • Possibly iterate again to use spacing support to control margins

@geriux
Copy link
Member

geriux commented Jan 28, 2021

@geriux it would be good to take you up on that offer to give this PR another test.

@aaronrobertshaw related to the things you mentioned for the vertical alignment issue and the settings, I pushed some changes to another branch and I was able to have it working like this:

One thing I had to change was the default height for the main container, not sure if that would break your current work. Let me know! Thanks!

@aaronrobertshaw
Copy link
Contributor Author

@geriux Thanks for all the effort working on the mobile side to this! 👍

One thing I had to change was the default height for the main container, not sure if that would break your current work. Let me know! Thanks!

Unfortunately, that does break the functionality allowing non-pixel units such as em and rem.

I haven't been able to spend much time exploring this yet but will be able to take a deeper dive on Monday. My guess is we need a dedicated edit.native.js file to handle the mobile specific behaviour.

Using the cover block as an example, it allows non-pixel units for its minimum height, but requires converting those non-pixel values via useConvertUnitToMobile hook. That in turn relies on the GlobalStylesContext.

const convertedMinHeight = useConvertUnitToMobile(
minHeight || COVER_DEFAULT_HEIGHT,
minHeightUnit
);

@aaronrobertshaw
Copy link
Contributor Author

I've taken another run at updating the display and control of the separator block's height on mobile. It's a bit rough at the moment and could do with a refactor, which I'll do if the general approach gets the nod.

@geriux
Copy link
Member

geriux commented Feb 1, 2021

I've taken another run at updating the display and control of the separator block's height on mobile.

That looks great! Thanks for making the changes for mobile!

My guess is we need a dedicated edit.native.js file to handle the mobile specific behaviour.

Yeah, I agree. It made more sense to share the same file before since it was a very simple component.

It's a bit rough at the moment and could do with a refactor, which I'll do if the general approach gets the nod.

Sounds good 👍

@stokesman
Copy link
Contributor

If only adjusting the margin you have to use the block navigator or be able to target the very thin <hr> to select the block.

I think there's been some recent regression around block selection that has something to do with that. I haven't seen it reported but was meaning to get to that.


On an implementation note, it's interesting that the height is applied through margins. Say this lands and then later margin is added to spacing block support. We'd have to avoid enabling margin for the Separator block (and forgo control of individual sides). Or, if enabled, we'd have to remove the height control (or maybe have the height update as the margins update, which seems funky).

I wonder about the need to support this feature for now. Padding support is stable, so putting a Separator in a Group to be able to apply padding seems like an easy enough workaround for what I believe is the infrequent need to space out the Separator (if the need is frequent for some particular user, making that combo a reusable block is also an option).


It does seem like a good thing that the mobile version would support color settings though.

@aaronrobertshaw
Copy link
Contributor Author

Thanks @stokesman, I appreciate your time taking a look at this PR and the work on the alternative approach.

I think there's been some recent regression around block selection that has something to do with that. I haven't seen it reported but was meaning to get to that.

The current situation is less than ideal, it definitely shouldn't be so hard to click to select the block. Given this is the primary means of block selection, I'd say it's pretty important to address.

On an implementation note, it's interesting that the height is applied through margins. Say this lands and then later margin is added to spacing block support. We'd have to avoid enabling margin for the Separator block (and forgo control of individual sides). Or, if enabled, we'd have to remove the height control (or maybe have the height update as the margins update, which seems funky).

Given the current methods of styling the separator's <hr>, leveraging margins does solve the problem without introducing additional markup purely for an aesthetic change.

I don't have very strong opinions on how a custom separator height is implemented behind the scenes. One big issue though is the UX around how the user achieves that custom height.

I think the ability to click a drag handle in the editor itself to visually resize the height of the block is a must. It is the most intuitive means of doing this and is consistent with the Spacer block. The UnitControl, or even the spacing control in the future, within the sidebar gives power users finer control over the height. For example using ems so its height matches responsive/adaptive typography.

Being able to adjust the top and bottom margins independently had been considered however I thought it best to leave to a future iteration. Left and right margins I think will interfere too much with block alignments.

I wonder about the need to support this feature for now.

We have a number of block patterns driving the need for this rather soon.

I think you are right, wrapping the separator in a group block could achieve a similar outcome. For the average user though, I do not think that is going to be very intuitive or even thought of.

@stokesman
Copy link
Contributor

Thanks for the thorough reply @aaronrobertshaw

Being able to adjust the top and bottom margins independently had been considered however I thought it best to leave to a future iteration.

I'd been concerned about the feasibility of a future iteration, at least with regards to integration with spacing block supports. Akin to what is brought up in #28518 (which you may have good suggestions for given your work on the PRs mentioned within).

After further consideration, any concern of mine is gone. I've realized that even if an ad-hoc implementation here could make difficult any later block spacing integration, the features that could be enabled by that (and are probably more niche uses anyway) can be had with the idea I'd suggested previously. E.g. If it's desired to adjust the spacing on the sides it can put it inside a Group to provide the padding.

One idea I had for this PR is that maybe it wouldn't hurt to label the setting “Vertical margins” since that's actually what gets adjusted. Plus it makes sense for splitting out as top and bottom in a later iteration.

@aaronrobertshaw
Copy link
Contributor Author

I'd been concerned about the feasibility of a future iteration, at least with regards to integration with spacing block supports. Akin to what is brought up in #28518 (which you may have good suggestions for given your work on the PRs mentioned within).

At this stage, I don't know what the outcome of #28518 will be. It seems to me that a lot of things we need to accomplish are blocked by that. Leaving the user to go without a feature or suffer an inferior experience to what we could provide.

Even though the preferred way to add styles is via block supports, the current proposed approach to spacing doesn't provide the usability of the resizable box. This block could be argued to add a new category to the linked issue where the block support controls are insufficient to a block's needs.

The downside is the inability to leverage global styles or the theme.json for this first iteration. Themes can already target the separator block with standard CSS so the sacrifice appears to be a user not being able to override that via global styles.

After further consideration, any concern of mine is gone. I've realized that even if an ad-hoc implementation here could make difficult any later block spacing integration, the features that could be enabled by that (and are probably more niche uses anyway) can be had with the idea I'd suggested previously.

In the case of this PR, despite the complexity around the UI, it really comes down to setting an attribute representing the height and then using that to apply margins when the block is saved. That attribute could be height as it is now or marginTop/marginBottom. Once spacing with margins support was in place, I saw it being a matter of adding a deprecation that moved the attribute value into the appropriate style attribute property. Then updating the UI around the controls injected via block support. This is assuming the decision to opt-in to spacing margins support is made.

Given the wide spread implications of the spacing controls using margins, I didn't see that being something that landed in the near future.

@stokesman
Copy link
Contributor

A couple of issues I saw in testing this and #28688 were that the first attempt to drag the handle doesn't work (unless height was already established by setting it in the inspector controls) and the height does not update while dragging (unlike in the Spacer block).

@oandregal oandregal mentioned this pull request Feb 10, 2021
82 tasks
@aaronrobertshaw
Copy link
Contributor Author

A couple of issues I saw in testing this and #28688 were that the first attempt to drag the handle doesn't work (unless height was already established by setting it in the inspector controls) and the height does not update while dragging (unlike in the Spacer block).

The issue preventing drag resizing on initial insertion has been fixed. The height isn't currently set in the attributes until the resize is complete in the onResizeStop handler. Updating the height on every resize event at the moment is pretty chunky. I will address that when I polish whichever out of this PR or #28688 moves ahead.

@stokesman
Copy link
Contributor

Updating the height on every resize event at the moment is pretty chunky.

Not surprising but I'd guess no worse than other blocks' resizing operations. Also, I do find any dragging-based interaction in Gutenberg to get much chunkier when the dev tools are open.

- Adjusts height minimums so they are effectively the same regardless of
  block style such as Dots.
- Height is now set on resize not resize stop
- Refactored edit component and settings controls to be clearer
@aaronrobertshaw
Copy link
Contributor Author

This now sets the height onResize rather than onResizeStop.

Base automatically changed from master to trunk March 1, 2021 15:45
@apeatling
Copy link
Contributor

I think we should concentrate on #29363 and look to add the handle in a future iteration.

@aaronrobertshaw
Copy link
Contributor Author

Thanks @apeatling , I'll close this PR in favour of #29363

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Separator Affects the Separator Block [Feature] Design Tools Tools that impact the appearance of blocks both to expand the number of tools and improve the experi
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants