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

Columns: Add border support #31737

Merged
merged 5 commits into from
Feb 16, 2022
Merged

Columns: Add border support #31737

merged 5 commits into from
Feb 16, 2022

Conversation

aaronrobertshaw
Copy link
Contributor

@aaronrobertshaw aaronrobertshaw commented May 12, 2021

Related: #21889

Description

  • Opts into border block support for the Columns block
  • No changes to the inner Column blocks have been made regarding border support. They will be addressed in the near future when support for individual border configurations is available.
Previous PR Description (included block style approach to dividing borders for inner columns)

Description

  • Adds control of Columns block border
  • Adds control of inner Column block right hand borders
  • Adds "divided" block style where only right border is shown or only bottom border on mobile
Notes
  • Until Refine border control panel with design tools #31337 is resolved the UI for this won't be enabled. (See Block Support: Update border support UI #31585 for WIP PR)
  • Inner column borders are controlled individually. If we want a single set of controls for them all, an ad hoc solution needs to be implemented at the Columns block level rather than using block supports
  • Positioning of the borders isn't ideal however will be addressed separately when margin & padding support is added to columns
  • The naming of the "Divided" block style could use improving. Open to suggestions for that.

Block patterns that may use this feature

Screenshots

How has this been tested?

Manually.

Setup

  • Ensure your current theme has the border support UI enabled or has appearanceTools: true under settings.

Test Instructions

  1. Create a post, add a columns block, some inner columns and give them some content
  2. Select the outer columns block and confirm border controls in the sidebar work
  3. Select an inner column block and note the absence of border control (for the time being)
  4. Apply a border to the main columns block, save the post and confirm correct rendering on frontend
  5. Back in the block editor, remove the border and save
  6. Switch to the site editor and via the Global Styles sidebar navigate to Blocks > Columns. Then apply a generic border.
  7. Confirm the global border style for Columns blocks renders in the site editor, block editor, and frontend.

Screenshots

ColumnBordersDemo

Types of changes

New feature.

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).

@aaronrobertshaw aaronrobertshaw added [Type] Enhancement A suggestion for improvement. Needs Design Feedback Needs general design feedback. [Block] Columns Affects the Columns Block [Feature] Design Tools Tools that impact the appearance of blocks both to expand the number of tools and improve the experi labels May 12, 2021
@aaronrobertshaw aaronrobertshaw self-assigned this May 12, 2021
@github-actions
Copy link

github-actions bot commented May 12, 2021

Size Change: +5.15 kB (0%)

Total Size: 1.07 MB

Filename Size Change
build/a11y/index.min.js 1.12 kB -1 B (0%)
build/admin-manifest/index.min.js 1.41 kB +2 B (0%)
build/annotations/index.min.js 2.93 kB +4 B (0%)
build/autop/index.min.js 2.28 kB +1 B (0%)
build/block-directory/index.min.js 6.61 kB -2 B (0%)
build/block-editor/index.min.js 126 kB +5.44 kB (+5%) 🔍
build/block-library/blocks/columns/style-rtl.css 563 B +88 B (+19%) ⚠️
build/block-library/blocks/columns/style.css 563 B +87 B (+18%) ⚠️
build/block-library/blocks/file/view.min.js 780 B +1 B (0%)
build/block-library/blocks/navigation-link/editor-rtl.css 474 B -159 B (-25%) 🎉
build/block-library/blocks/navigation-link/editor.css 473 B -161 B (-25%) 🎉
build/block-library/editor-rtl.css 9.85 kB -1 B (0%)
build/block-library/editor.css 9.84 kB -1 B (0%)
build/block-library/index.min.js 146 kB +15 B (0%)
build/block-library/style-rtl.css 10.3 kB +71 B (+1%)
build/block-library/style.css 10.3 kB +77 B (+1%)
build/block-serialization-default-parser/index.min.js 1.3 kB +1 B (0%)
build/blocks/index.min.js 47.2 kB +23 B (0%)
build/components/index.min.js 194 kB +39 B (0%)
build/compose/index.min.js 10.2 kB -3 B (0%)
build/core-data/index.min.js 12.4 kB -60 B (0%)
build/customize-widgets/index.min.js 10.3 kB -4 B (0%)
build/data/index.min.js 7.22 kB -1 B (0%)
build/date/index.min.js 31.8 kB +1 B (0%)
build/deprecated/index.min.js 738 B -1 B (0%)
build/dom-ready/index.min.js 576 B -1 B (0%)
build/edit-navigation/index.min.js 13.8 kB -85 B (-1%)
build/edit-post/index.min.js 58.6 kB -53 B (0%)
build/edit-site/index.min.js 25.9 kB -64 B (0%)
build/edit-widgets/index.min.js 16.1 kB -67 B (0%)
build/editor/index.min.js 38.6 kB -52 B (0%)
build/element/index.min.js 3.44 kB -1 B (0%)
build/format-library/index.min.js 5.71 kB -7 B (0%)
build/hooks/index.min.js 1.76 kB -1 B (0%)
build/html-entities/index.min.js 628 B -1 B (0%)
build/list-reusable-blocks/index.min.js 2.07 kB +1 B (0%)
build/media-utils/index.min.js 3.08 kB +2 B (0%)
build/notices/index.min.js 1.07 kB -1 B (0%)
build/plugins/index.min.js 1.99 kB +2 B (0%)
build/priority-queue/index.min.js 790 B -1 B (0%)
build/react-i18n/index.min.js 924 B -1 B (0%)
build/url/index.min.js 1.95 kB +1 B (0%)
build/viewport/index.min.js 1.28 kB -1 B (0%)
build/warning/index.min.js 1.16 kB +24 B (+2%)
build/widgets/index.min.js 6.45 kB -1 B (0%)
ℹ️ View Unchanged
Filename Size
build/api-fetch/index.min.js 2.44 kB
build/blob/index.min.js 673 B
build/block-directory/style-rtl.css 1.02 kB
build/block-directory/style.css 1.02 kB
build/block-editor/style-rtl.css 14 kB
build/block-editor/style.css 13.9 kB
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 112 B
build/block-library/blocks/audio/style.css 112 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 475 B
build/block-library/blocks/button/editor.css 474 B
build/block-library/blocks/button/style-rtl.css 603 B
build/block-library/blocks/button/style.css 602 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 375 B
build/block-library/blocks/buttons/style.css 375 B
build/block-library/blocks/calendar/style-rtl.css 208 B
build/block-library/blocks/calendar/style.css 208 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 190 B
build/block-library/blocks/columns/editor.css 190 B
build/block-library/blocks/cover/editor-rtl.css 670 B
build/block-library/blocks/cover/editor.css 670 B
build/block-library/blocks/cover/style-rtl.css 1.22 kB
build/block-library/blocks/cover/style.css 1.23 kB
build/block-library/blocks/embed/editor-rtl.css 486 B
build/block-library/blocks/embed/editor.css 486 B
build/block-library/blocks/embed/style-rtl.css 401 B
build/block-library/blocks/embed/style.css 400 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 301 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/freeform/editor-rtl.css 2.44 kB
build/block-library/blocks/freeform/editor.css 2.44 kB
build/block-library/blocks/gallery/editor-rtl.css 704 B
build/block-library/blocks/gallery/editor.css 705 B
build/block-library/blocks/gallery/style-rtl.css 1.06 kB
build/block-library/blocks/gallery/style.css 1.06 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 160 B
build/block-library/blocks/group/editor.css 160 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 93 B
build/block-library/blocks/group/theme.css 93 B
build/block-library/blocks/heading/editor-rtl.css 152 B
build/block-library/blocks/heading/editor.css 152 B
build/block-library/blocks/heading/style-rtl.css 76 B
build/block-library/blocks/heading/style.css 76 B
build/block-library/blocks/home-link/style-rtl.css 259 B
build/block-library/blocks/home-link/style.css 259 B
build/block-library/blocks/html/editor-rtl.css 281 B
build/block-library/blocks/html/editor.css 281 B
build/block-library/blocks/image/editor-rtl.css 729 B
build/block-library/blocks/image/editor.css 727 B
build/block-library/blocks/image/style-rtl.css 481 B
build/block-library/blocks/image/style.css 485 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 286 B
build/block-library/blocks/latest-comments/style.css 286 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 534 B
build/block-library/blocks/latest-posts/style.css 532 B
build/block-library/blocks/list/style-rtl.css 63 B
build/block-library/blocks/list/style.css 63 B
build/block-library/blocks/media-text/editor-rtl.css 263 B
build/block-library/blocks/media-text/editor.css 264 B
build/block-library/blocks/media-text/style-rtl.css 492 B
build/block-library/blocks/media-text/style.css 489 B
build/block-library/blocks/more/editor-rtl.css 434 B
build/block-library/blocks/more/editor.css 434 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/editor-rtl.css 1.69 kB
build/block-library/blocks/navigation/editor.css 1.69 kB
build/block-library/blocks/navigation/style-rtl.css 1.65 kB
build/block-library/blocks/navigation/style.css 1.65 kB
build/block-library/blocks/navigation/view.min.js 2.87 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 311 B
build/block-library/blocks/page-list/style-rtl.css 240 B
build/block-library/blocks/page-list/style.css 240 B
build/block-library/blocks/paragraph/editor-rtl.css 157 B
build/block-library/blocks/paragraph/editor.css 157 B
build/block-library/blocks/paragraph/style-rtl.css 247 B
build/block-library/blocks/paragraph/style.css 248 B
build/block-library/blocks/post-author/editor-rtl.css 209 B
build/block-library/blocks/post-author/editor.css 209 B
build/block-library/blocks/post-author/style-rtl.css 183 B
build/block-library/blocks/post-author/style.css 184 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 139 B
build/block-library/blocks/post-content/editor.css 139 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 338 B
build/block-library/blocks/post-featured-image/editor.css 338 B
build/block-library/blocks/post-featured-image/style-rtl.css 141 B
build/block-library/blocks/post-featured-image/style.css 141 B
build/block-library/blocks/post-template/editor-rtl.css 100 B
build/block-library/blocks/post-template/editor.css 99 B
build/block-library/blocks/post-template/style-rtl.css 379 B
build/block-library/blocks/post-template/style.css 380 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 183 B
build/block-library/blocks/pullquote/editor.css 183 B
build/block-library/blocks/pullquote/style-rtl.css 318 B
build/block-library/blocks/pullquote/style.css 318 B
build/block-library/blocks/pullquote/theme-rtl.css 169 B
build/block-library/blocks/pullquote/theme.css 169 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 86 B
build/block-library/blocks/query-title/editor.css 86 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/style-rtl.css 169 B
build/block-library/blocks/quote/style.css 169 B
build/block-library/blocks/quote/theme-rtl.css 221 B
build/block-library/blocks/quote/theme.css 221 B
build/block-library/blocks/rss/editor-rtl.css 201 B
build/block-library/blocks/rss/editor.css 202 B
build/block-library/blocks/rss/style-rtl.css 290 B
build/block-library/blocks/rss/style.css 290 B
build/block-library/blocks/search/editor-rtl.css 211 B
build/block-library/blocks/search/editor.css 211 B
build/block-library/blocks/search/style-rtl.css 359 B
build/block-library/blocks/search/style.css 362 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 251 B
build/block-library/blocks/separator/style.css 251 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 476 B
build/block-library/blocks/shortcode/editor.css 476 B
build/block-library/blocks/site-logo/editor-rtl.css 465 B
build/block-library/blocks/site-logo/editor.css 465 B
build/block-library/blocks/site-logo/style-rtl.css 154 B
build/block-library/blocks/site-logo/style.css 154 B
build/block-library/blocks/site-tagline/editor-rtl.css 87 B
build/block-library/blocks/site-tagline/editor.css 87 B
build/block-library/blocks/site-title/editor-rtl.css 85 B
build/block-library/blocks/site-title/editor.css 85 B
build/block-library/blocks/social-link/editor-rtl.css 164 B
build/block-library/blocks/social-link/editor.css 165 B
build/block-library/blocks/social-links/editor-rtl.css 800 B
build/block-library/blocks/social-links/editor.css 799 B
build/block-library/blocks/social-links/style-rtl.css 1.34 kB
build/block-library/blocks/social-links/style.css 1.34 kB
build/block-library/blocks/spacer/editor-rtl.css 308 B
build/block-library/blocks/spacer/editor.css 308 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 478 B
build/block-library/blocks/table/editor.css 478 B
build/block-library/blocks/table/style-rtl.css 480 B
build/block-library/blocks/table/style.css 480 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/editor-rtl.css 118 B
build/block-library/blocks/tag-cloud/editor.css 118 B
build/block-library/blocks/tag-cloud/style-rtl.css 94 B
build/block-library/blocks/tag-cloud/style.css 94 B
build/block-library/blocks/template-part/editor-rtl.css 551 B
build/block-library/blocks/template-part/editor.css 550 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 569 B
build/block-library/blocks/video/editor.css 570 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/common-rtl.css 1.29 kB
build/block-library/common.css 1.29 kB
build/block-library/reset-rtl.css 514 B
build/block-library/reset.css 515 B
build/block-library/theme-rtl.css 692 B
build/block-library/theme.css 693 B
build/block-serialization-spec-parser/index.min.js 3.06 kB
build/components/style-rtl.css 16.1 kB
build/components/style.css 16.1 kB
build/customize-widgets/style-rtl.css 1.48 kB
build/customize-widgets/style.css 1.48 kB
build/data-controls/index.min.js 830 B
build/dom/index.min.js 4.66 kB
build/edit-navigation/style-rtl.css 3.12 kB
build/edit-navigation/style.css 3.12 kB
build/edit-post/classic-rtl.css 483 B
build/edit-post/classic.css 483 B
build/edit-post/style-rtl.css 7.25 kB
build/edit-post/style.css 7.24 kB
build/edit-site/style-rtl.css 5.04 kB
build/edit-site/style.css 5.03 kB
build/edit-widgets/style-rtl.css 3.88 kB
build/edit-widgets/style.css 3.89 kB
build/editor/style-rtl.css 3.88 kB
build/editor/style.css 3.88 kB
build/escape-html/index.min.js 739 B
build/format-library/style-rtl.css 668 B
build/format-library/style.css 669 B
build/i18n/index.min.js 3.73 kB
build/is-shallow-equal/index.min.js 709 B
build/keyboard-shortcuts/index.min.js 1.74 kB
build/keycodes/index.min.js 1.43 kB
build/list-reusable-blocks/style-rtl.css 842 B
build/list-reusable-blocks/style.css 842 B
build/nux/index.min.js 2.31 kB
build/nux/style-rtl.css 745 B
build/nux/style.css 742 B
build/primitives/index.min.js 1.03 kB
build/redux-routine/index.min.js 2.82 kB
build/reusable-blocks/index.min.js 2.56 kB
build/reusable-blocks/style-rtl.css 256 B
build/reusable-blocks/style.css 256 B
build/rich-text/index.min.js 10.6 kB
build/server-side-render/index.min.js 1.64 kB
build/shortcode/index.min.js 1.68 kB
build/token-list/index.min.js 847 B
build/widgets/style-rtl.css 1.04 kB
build/widgets/style.css 1.05 kB
build/wordcount/index.min.js 1.24 kB

compressed-size-action

Copy link
Contributor

@stacimc stacimc 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 looking good to me. Not necessarily a problem with the PR but I did find it slightly confusing that because the "Default" style is undefined, I could make changes to the color/width selections but not see them reflected until I selected a different option from the border style dropdown.

I confirmed:

  • Border style, color, radius, and width work for the outer Columns in the editor
  • All options work for the outer Columns on the frontend
  • Only the right-hand border is visually updated for inner columns
  • Setting border options for the last column have no visual effect, but take effect when that column is moved to a new position
  • Border style, width, and radius work on the frontend for inner Columns

One small issue: it looks like border color does not reflect on the frontend for inner columns:

Editor Frontend
Screen Shot 2021-05-12 at 5 03 10 PM Screen Shot 2021-05-12 at 5 03 15 PM

@aaronrobertshaw
Copy link
Contributor Author

Thanks for testing @stacimc!

This is looking good to me. Not necessarily a problem with the PR but I did find it slightly confusing that because the "Default" style is undefined, I could make changes to the color/width selections but not see them reflected until I selected a different option from the border style dropdown.

Agreed. There is a PR aiming to refine the border support UI (#31585). It will help improve the experience a little. The issue you describe has been raised though no decision was made on the best path forward for the short term.

Longer term though there is the idea to allow borders to be "added" rather than just tweaking border attributes. So when a border gets added it would include a default border style that is visible, alleviating this problem.

One small issue: it looks like border color does not reflect on the frontend for inner columns:

Looks like the named color class isn't applying correctly, I'll fix that. Nice catch 👍

@aaronrobertshaw
Copy link
Contributor Author

The application of named color classes in the save function has been fixed (e67a8b6)

Copy link
Contributor

@stacimc stacimc left a comment

Choose a reason for hiding this comment

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

I don't have write access to approve, but LGTM! The inner column border colors are now applying on the frontend as well.

There is a PR aiming to refine the border support UI (#31585). It will help improve the experience a little. The issue you describe has been raised though no decision was made on the best path forward for the short term.

Agreed, that's definitely seems like a much bigger conversation. Thank you for the link!

One last tiny thing I noticed is that the inner columns have a 32px left margin but no right margin; with borders applied this becomes noticeable because the content does not appear perfectly centered between borders:
Screen Shot 2021-05-13 at 2 42 42 PM
This isn't a problem with the border support application and could be considered a separate issue in my opinion, though.

@aaronrobertshaw
Copy link
Contributor Author

This isn't a problem with the border support application and could be considered a separate issue in my opinion, though.

Thanks @stacimc, I agree. My thoughts were in the PR description as follows:

Positioning of the borders isn't ideal however will be addressed separately when margin & padding support is added to columns

@andrewserong is currently working on adding spacing support to the Columns block. My understanding is that work should be ready to land very close to the time this PR will get merged.

Copy link
Contributor

@stacimc stacimc left a comment

Choose a reason for hiding this comment

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

Positioning of the borders isn't ideal however will be addressed separately when margin & padding support is added to columns

Whoops, sorry to be redundant -- should've read closer! Completely agree. LGTM for what it's worth!

@glendaviesnz
Copy link
Contributor

glendaviesnz commented May 19, 2021

This works as advertised for me, but I wonder if we want to add some additional css to handle the borders when stacked in mobile, eg. it currently looks odd with the border just on the right and not on last child?

Screen Shot 2021-05-19 at 12 07 37 PM

@aaronrobertshaw
Copy link
Contributor Author

This works as advertised for me, but I wonder if we want to add some additional css to handle the borders when stacked in mobile, eg. it currently looks odd with the border just on the right and not on last child?

Thanks @glendaviesnz, definitely a good call. I've added some responsive styles for the application of the column borders. I wasn't sure on the best balance between reasonable default behaviour or just omitting the border entirely.

I've made it such that the right border doesn't display on even columns when in a medium viewport.

Screen Shot 2021-05-20 at 3 53 12 pm

On mobile I've applied the border as a bottom border expect for the last column at the bottom of the vertical stack.

Screen Shot 2021-05-20 at 3 53 19 pm

Ideally, the border support would be able to provide configurations for individual borders combined with responsive styles. Hopefully this is a reasonable option until then or the G2 project is brought into Gutenberg.

Happy to roll back the bottom border change and just omit the borders entirely on mobile if that is deemed a better option.

Copy link
Contributor

@glendaviesnz glendaviesnz left a comment

Choose a reason for hiding this comment

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

This tested well for me, and I think the default behaviours for stacking in mobile make sense.

@justintadlock
Copy link
Contributor

justintadlock commented May 21, 2021

Just noting users/themers might want to have a border around the entire Column block and not just in between. What's shown in the video is redefining expectations around the current border controls.

I see two options:

  1. Border widths (top, left, bottom, right) should be un/linkable like the margin/spacing controls. This solution has the problem of handling vertical borders after the breakpoint since there is currently no screen-specific block options.

  2. Create a new control called a "Divide" (or similar) like what Tailwind CSS does. We can more tightly control its behavior. Long-term, there could be more applications for this control with flex/grid containers (it could already be useful with the Navigation block). Ref: https://tailwindcss.com/docs/divide-width

@aaronrobertshaw
Copy link
Contributor Author

Thank you for the feedback @justintadlock 👍

Just noting users/themers might want to have a border around the entire Column block and not just in between.

Good point!

I was focused on being able to offer something to allow block pattern designs with just a separating border. One unsatisfactory workaround could be to add a group block to the column and apply a full border.

What's shown in the video is redefining expectations around the current border controls.

I agree.

  1. Border widths (top, left, bottom, right) should be un/linkable like the margin/spacing controls. This solution has the problem of handling vertical borders after the breakpoint since there is currently no screen-specific block options.

Unfortunately, at the moment that is the case across all block support provided styles however a solution to this responsive styling issue is being explored and worked on.

In terms of possibly unlinking the border-width control and supporting individual side values, this might cause some issues with the currently proposed border support UI in #31337. Nothing insurmountable but worth noting.

There are some other issues about whether to rely on the shorthand border-width CSS property, in that case forgoing inheriting theme values, or changing the block supports to be compatible with the longhand properties e.g. border-left-width. There is currently a separate PR addressing these same issues for the border radius support feature. This would be effectively solved through that.

  1. Create a new control called a "Divide" (or similar) like what Tailwind CSS does. We can more tightly control its behavior. Long-term, there could be more applications for this control with flex/grid containers (it could already be useful with the Navigation block). Ref: https://tailwindcss.com/docs/divide-width

I'm not sure how this would work exactly. It would not be a part of the border block support yet might need to implement similar control over the color, width, style etc. That overlaps a lot of what the border block support already provides. There would also be a problem relating to how this is added to the sidebar controls. This issue already highlights a range of design issues with adding more.

I agree the current support doesn't fit the ideal 100% due to non-responsive styles and an inability to configure borders for separate sides.


There might be an "Option 3". We could opt into the standard border support and allow for it to be used as per normal. The right only border could be achieved via a block style. That block style's CSS class could add a default right border, enforce only the right border is shown when appropriate, include media queries to switch it to the bottom for mobile etc.

Given that covers a lot more bases, I'll make those changes.

Thanks again for taking a look at this!

@aaronrobertshaw
Copy link
Contributor Author

I've updated this PR to use the new approach of a block style to achieve the divided style where only the right border is shown. This allows for the block support to be applied in a predictable manner. It also has the benefit of reducing the amount of code changed.

The PR description and test instructions have been updated to reflect the changes.

@justintadlock
Copy link
Contributor

justintadlock commented May 25, 2021

I like option 3. It's a good compromise between the first solution and a whole new divider control.

@glendaviesnz
Copy link
Contributor

The new approach looks good, the only issue I found was that the default grey border colour is barely visible on the likes of the tt1 theme:

divided

something closer to black may be better.

@aaronrobertshaw
Copy link
Contributor Author

The new approach looks good, the only issue I found was that the default grey border colour is barely visible on the likes of the tt1 theme:

Fair point. I'd just picked that color as the base-styles/_colors.scss had that as "Used for most borders". I'll tweak it.

@aaronrobertshaw aaronrobertshaw force-pushed the add/column-border-support branch from b59db37 to 8bd1947 Compare July 9, 2021 06:28
@aaronrobertshaw
Copy link
Contributor Author

I've rebased this PR after the recent merge of the refined border support UI in #31585.

It would be great to get some further testing and feedback on how borders are applied to columns.

@jasmussen Any thoughts? What might we need to improve for border controls on columns to be ok to unlock.

@aaronrobertshaw
Copy link
Contributor Author

This brief demo illustrates some of the rough edges present with the current experience.

Screen.Recording.2021-07-09.at.4.25.12.pm.mp4

@jasmussen
Copy link
Contributor

Took this for a spin:

columns

While the end result here isn't super compelling visually, the tools present definitely show their power and what can be unlocked by adding border support. So overall, this seems on the right track.

A few things became clear in testing this. First off, we really need a new color swatch soon, because the "Clear" button here feels like it should clear all the contents of the panel, not just that one particular color:

Screenshot 2021-07-09 at 08 44 23

That's a problem specific with the color picker, and not with the border panel especially.

It's nice that the "Divided" style lets you customize just the border between columns. That, specifically, feels like it can enable some compelling patterns. However this is made slightly trickier to accomplish by only working when the border is set on the column (singular), rather than the entire columns block itself:

Screenshot 2021-07-09 at 08 45 51

Would it be possible to add border support only to the parent columns block, and not to the child column block as a starting point, and make the divided style work directly there? While selecting the individual column blocks have become easier, it's still a little fiddly. And it seems like if the border support is to be aware of the divided style, the border properties should also be shown in context of the same style picker. That would also, presumably, allow us to avoid the situation where you have to set the border properties for each column in order to accomplish the gridded look, i.e. avoid this:

Screenshot 2021-07-09 at 08 48 47

border: 1px solid $gray-900;

// Disable top and left borders.
border-top: none !important;
Copy link
Contributor

@jasmussen jasmussen Jul 9, 2021

Choose a reason for hiding this comment

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

If at all possible, we should avoid !importants. If we need to increase specificity instead, that would be preferable. I could imagine a particular theme wanting to customize this style variation further.

One way to increase specificity would be &.is-style-divided.is-style-divided .wp-block-column. It's slightly hacky to duplicate the same classname to increase specificity, but it works, and should be preferable to !importants.

Another option is to reduce the specificity of whatever needs overriding. Lately I've become fond of using :where for that: https://codepen.io/joen/pen/abJVrGX

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If at all possible, we should avoid !importants. If we need to increase specificity instead, that would be preferable.

Allowing users to configure border colour, style or width via these block support controls means those styles will be applied via inline styles. To overcome those and disable the other sides to give this "Divided" block style !important is required.

The comment at the top of that CSS section defining "Divided" styles explains this. Does it need to be made clearer or more prominent?

@jasmussen
Copy link
Contributor

Another thought: the divided style is very compelling for patterns. However by being a style variation, it's also tied specifically to this block, and to this style being present. Honestly the visual is compelling enough that we might want it to be a core part of the border support feature directly, rather than something that requires a style choice. Being able to style the outer and inner borders separately, I could see being compelling also inside Table or Media & Text blocks, possibly even Buttons or others. That does put some extra strain on the border UI to be able to accommodate that extra complexity, but it might be worth it.

Is it okay to ship the feature that relies on the style variation in the mean time? Maybe, but I'd love thoughts by global styles savvy folks such as @nosolosw or @jorgefilipecosta if they have time (thank you).

Overall, really nice work on this, thanks for all the effort you put into this.

@oandregal
Copy link
Member

Hey, I took a look at this. Thanks for pushing what's possible to support cool designs, Aaron!

I've tried it a few times. First, with excitement; then, growing slowly concerned 😓 My concern boils down to this: we're coupling the style variation of a parent block to the individual properties of the children. Examples: the use of important! to coordinate styles among the two, the user has to go to those two different places to make it work. But also, considerations such as what if a theme disables border support? Would the style variation work on its own given that its values can't be modified because the border panel of the children is hidden?

The effect would be super cool to have, though. It'd be great to look at how to accomplish it via a standalone mechanism. If we can do it via block supports it'd be fantastic.

In terms of subcomponents for this to work as a block support I'd think we need 1) being able to tweak side borders individually (as we do with margin or padding) 2) attach behavior to borders (enable right or bottom depending on some conditions, etc) and 3) allow the parent to absorb the inspector controls of the children so users don't need to go child by child to set the same conditions. I think I could explore 3 if nobody else has gotten to it yet. It's related to #33255 and would benefit many design tools.

@aaronrobertshaw
Copy link
Contributor Author

My concern boils down to this: we're coupling the style variation of a parent block to the individual properties of the children

Agreed. This isn't ideal. I didn't see a means of achieving this without that or completely overhauling the border block support where it then gets further bogged down by theme.json and global styles support.

From the perspective that all the individual columns belong to their parent, that relationship by definition means they'd be affected by the parent's styles. I wondered whether that would be sufficient to allow the parent's styles to dictate that certain sides of a border on an individual column wouldn't show.

Examples: the use of important! to coordinate styles among the two

This was the only means to override block support inline styles. The use of !important is to effectively make up for the shortfall in the current border support of not being able to define individual border sides.

the user has to go to those two different places to make it work

The block style could be moved to the individual column level. That would mean the block style is all in one place in terms of blocks however it's now also multiplied by the number of columns. The same issue as the per column border configuration.

But also, considerations such as what if a theme disables border support? Would the style variation work on its own given that its values can't be modified because the border panel of the children is hidden?

The block style has its own default CSS so I believe it would work even without borders enabled. The theme author can then also set their own styles in CSS. The block support side of it would only allow leveraging of theme.json, global styles and individual block configuration. Even that isn't clean but provides the most flexibility. There are a lot of designs out there for columns and it could be difficult to draw the line on which should be achievable.

  1. being able to tweak side borders individually (as we do with margin or padding)

Achieving this under-the-hood looks like it would be much easier than providing the UI to manage it.

Most PRs along this one's lines will create discussion about a proposed "appearance" panel. To hopefully fast-forward that, I'll include the mock up below. One of the issues I have with it is it isn't clear how we can get to that stage. We'll also need a design around how to specify individual border sides. Would we only rely on splitting border widths? Or, do we wish to also allow different colors and border styles per side?

  1. attach behavior to borders (enable right or bottom depending on some conditions, etc)

Could this also begin to extend into the realms of responsive block support values? Do you have any ideas on how this would work if we are only configuring this block support via block.json?

  1. allow the parent to absorb the inspector controls of the children so users don't need to go child by child to set the same conditions.

I'm not aware of anyone tackling that one yet. Let me know if I can assist at all.

@mtias
Copy link
Member

mtias commented Feb 14, 2022

Would it be possible to add border support only to the parent columns block, and not to the child column block as a starting point

I'd favor this approach as well. Once the border tools are capable of handling specific edges well we can revisit the children, but right now having borders on the entire columns set can be quite useful.

Can we get that in as a first step?

@aaronrobertshaw
Copy link
Contributor Author

Can we get that in as a first step?

Absolutely.

This PR has been on the back-burner for quite a while but I can update it accordingly in the next few days.

Once the border tools are capable of handling specific edges well we can revisit the children

It might also be of interest that there are new border control components approaching a point where they can land. Following that, there is a related PR extending the border block support to allow the configuration of individual side borders.

Essentially, it might not be too long before we can have it all.

@mtias
Copy link
Member

mtias commented Feb 14, 2022

Indeed, seems we can do a quick one just to add border to the container, continue the work on the panel itself, and extend the support to single column blocks once that's solid.

@aaronrobertshaw aaronrobertshaw force-pushed the add/column-border-support branch from a8c790d to 2dc39f2 Compare February 15, 2022 02:43
@aaronrobertshaw
Copy link
Contributor Author

I've updated this PR to only opt into the border support for the Columns block. This reduces the changes to a simple tweak of the block.json.

While testing, I noticed that the available colors in the Global Styles border panel only show colors from the "last source" palette. I'll create a fix for that in a separate PR.

@jasmussen
Copy link
Contributor

Nice one. Before:
before

After:

after

The branch is very old so it looks like it hasn't picked up recent changes to the border panel. Even if the checks are green, it might be worth doing that rebase just so there aren't any surprises that happened to the UI in the mean time. Otherwise, it seems like a good start. Thank you!

@aaronrobertshaw
Copy link
Contributor Author

The branch is very old so it looks like it hasn't picked up recent changes to the border panel.

@jasmussen I'm not sure what you are referring to here. This was rebased yesterday before pushing the changes.

Am I correct that the issue is that the border controls for the columns block weren't made defaults? I've pushed a new commit adding this.

Copy link
Contributor

@andrewserong andrewserong 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 looking good to me @aaronrobertshaw, nice idea starting with the parent Columns block support for the moment.

✅ Works well at the individual block level
✅ Adding border in global styles for the Columns block works correctly
✅ Borders at the individual level override styles set at the global styles

LGTM!

Editor Global styles
image image

@aaronrobertshaw aaronrobertshaw merged commit 64a6490 into trunk Feb 16, 2022
@aaronrobertshaw aaronrobertshaw deleted the add/column-border-support branch February 16, 2022 02:18
@github-actions github-actions bot added this to the Gutenberg 12.7 milestone Feb 16, 2022
@jasmussen
Copy link
Contributor

Am I correct that the issue is that the border controls for the columns block weren't made defaults? I've pushed a new commit adding this.

It's very likely the behavior of the border panel that was confusing me. It's been a bit back and forth on which controls get added at the same time or not. Thanks for landing this.

@mtias
Copy link
Member

mtias commented Feb 26, 2022

Thanks for pushing this over the finish line

@aaronrobertshaw
Copy link
Contributor Author

It might also be of interest that there are #37769 approaching a point where they can land. Following that, there is a related PR extending the border block support to #37770.

In anticipation of #37770 landing soon a new PR has been created to explore adopting border support on the Column block (including for individual side borders).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Columns Affects the Columns Block [Feature] Design Tools Tools that impact the appearance of blocks both to expand the number of tools and improve the experi Needs Design Feedback Needs general design feedback. [Package] Block library /packages/block-library [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants