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

Border Panel: Combine width and style in panel menu #36942

Closed

Conversation

aaronrobertshaw
Copy link
Contributor

@aaronrobertshaw aaronrobertshaw commented Nov 29, 2021

Related:

Description

This PR:

  • Combines the border width and style options within the border panel in both the block editor and global styles.
  • Enforces border-width support if border-style is supported ( requesting comment )

The desire for combing controls stems from the switch to the ToolsPanel for the border block support: #33743 (comment)

Notes

  • In the last iteration on the border panel, the repetition in labels was removed e.g. "Border color" and "Border Radius" being renamed to "color" and "radius" respectively.
Suggested This PR
Screen Shot 2021-11-29 at 4 34 10 pm Screen Shot 2021-11-29 at 4 33 47 pm

How has this been tested?

Block Editor

  1. Create a post, add a group block and select it
  2. Ensure the border controls within the sidebar's border panel function correctly
  3. Test various combinations of support (block.json) and UI disabling (theme.json)
    • Width and style supported
      • Menu item label is: "Width & style"
      • Menu item toggles both width and style control display
      • Menu item resets both width and style controls
    • Width only
      • Menu item label is: "Width"
      • Menu item toggles width control display
      • Menu item resets width control
    • Style only ( width will be automatically supported )
      • Menu item label is: "Width & style"
      • Menu item toggles both width and style control display
      • Menu item resets both width and style controls
    • No width/style support
      • Confirm no width/style controls displayed
      • Confirm no width/style menu item present
  4. Tested various default control display configurations via __experimentalBorder.__experimentalDefaultControls in block.json
    • "widthAndstyle": "true" --> controls displayed by default
    • "width": "true" --> controls displayed by default if width supported
    • "style": "true" --> controls displayed by default if style supported
  5. Confirm dynamic blocks still have borders rendered correctly on the frontend.

Global Styles

  1. Load site editor and select "Blocks > Group" from Global Styles sidebar
  2. Confirm all border controls are still shown by default
  3. Test various combinations of support and UI disabling

Screenshots

BorderCombinedWidthAndStyleItem

Types of changes

Enhancement.

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. [Feature] Design Tools Tools that impact the appearance of blocks both to expand the number of tools and improve the experi labels Nov 29, 2021
@aaronrobertshaw aaronrobertshaw self-assigned this Nov 29, 2021
@github-actions
Copy link

github-actions bot commented Nov 29, 2021

Size Change: +156 B (0%)

Total Size: 1.11 MB

Filename Size Change
build/block-editor/index.min.js 139 kB +121 B (0%)
build/edit-site/index.min.js 34.2 kB +35 B (0%)
ℹ️ View Unchanged
Filename Size
build/a11y/index.min.js 960 B
build/admin-manifest/index.min.js 1.1 kB
build/annotations/index.min.js 2.75 kB
build/api-fetch/index.min.js 2.21 kB
build/autop/index.min.js 2.12 kB
build/blob/index.min.js 459 B
build/block-directory/index.min.js 6.28 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-editor/style-rtl.css 14.4 kB
build/block-editor/style.css 14.4 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 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 470 B
build/block-library/blocks/button/editor.css 470 B
build/block-library/blocks/button/style-rtl.css 560 B
build/block-library/blocks/button/style.css 560 B
build/block-library/blocks/buttons/editor-rtl.css 291 B
build/block-library/blocks/buttons/editor.css 291 B
build/block-library/blocks/buttons/style-rtl.css 275 B
build/block-library/blocks/buttons/style.css 275 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 134 B
build/block-library/blocks/code/theme.css 134 B
build/block-library/blocks/columns/editor-rtl.css 210 B
build/block-library/blocks/columns/editor.css 208 B
build/block-library/blocks/columns/style-rtl.css 503 B
build/block-library/blocks/columns/style.css 502 B
build/block-library/blocks/comments-pagination-numbers/editor-rtl.css 123 B
build/block-library/blocks/comments-pagination-numbers/editor.css 121 B
build/block-library/blocks/comments-pagination/editor-rtl.css 222 B
build/block-library/blocks/comments-pagination/editor.css 209 B
build/block-library/blocks/comments-pagination/style-rtl.css 235 B
build/block-library/blocks/comments-pagination/style.css 231 B
build/block-library/blocks/cover/editor-rtl.css 546 B
build/block-library/blocks/cover/editor.css 547 B
build/block-library/blocks/cover/style-rtl.css 1.22 kB
build/block-library/blocks/cover/style.css 1.22 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/style-rtl.css 417 B
build/block-library/blocks/embed/style.css 417 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/editor-rtl.css 966 B
build/block-library/blocks/gallery/editor.css 970 B
build/block-library/blocks/gallery/style-rtl.css 1.63 kB
build/block-library/blocks/gallery/style.css 1.62 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 78 B
build/block-library/blocks/group/theme.css 78 B
build/block-library/blocks/heading/style-rtl.css 114 B
build/block-library/blocks/heading/style.css 114 B
build/block-library/blocks/html/editor-rtl.css 332 B
build/block-library/blocks/html/editor.css 333 B
build/block-library/blocks/image/editor-rtl.css 731 B
build/block-library/blocks/image/editor.css 730 B
build/block-library/blocks/image/style-rtl.css 507 B
build/block-library/blocks/image/style.css 511 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/list/style-rtl.css 94 B
build/block-library/blocks/list/style.css 94 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 493 B
build/block-library/blocks/media-text/style.css 490 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 649 B
build/block-library/blocks/navigation-link/editor.css 650 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-submenu/editor-rtl.css 299 B
build/block-library/blocks/navigation-submenu/editor.css 299 B
build/block-library/blocks/navigation-submenu/view.min.js 343 B
build/block-library/blocks/navigation/editor-rtl.css 1.89 kB
build/block-library/blocks/navigation/editor.css 1.89 kB
build/block-library/blocks/navigation/style-rtl.css 1.68 kB
build/block-library/blocks/navigation/style.css 1.67 kB
build/block-library/blocks/navigation/view.min.js 2.79 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 377 B
build/block-library/blocks/page-list/editor.css 377 B
build/block-library/blocks/page-list/style-rtl.css 172 B
build/block-library/blocks/page-list/style.css 172 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 273 B
build/block-library/blocks/paragraph/style.css 273 B
build/block-library/blocks/post-author/style-rtl.css 175 B
build/block-library/blocks/post-author/style.css 176 B
build/block-library/blocks/post-comments-form/style-rtl.css 444 B
build/block-library/blocks/post-comments-form/style.css 444 B
build/block-library/blocks/post-comments/style-rtl.css 492 B
build/block-library/blocks/post-comments/style.css 493 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 721 B
build/block-library/blocks/post-featured-image/editor.css 721 B
build/block-library/blocks/post-featured-image/style-rtl.css 153 B
build/block-library/blocks/post-featured-image/style.css 153 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 391 B
build/block-library/blocks/post-template/style.css 392 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 80 B
build/block-library/blocks/post-title/style.css 80 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/style-rtl.css 378 B
build/block-library/blocks/pullquote/style.css 378 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 221 B
build/block-library/blocks/query-pagination/editor.css 211 B
build/block-library/blocks/query-pagination/style-rtl.css 273 B
build/block-library/blocks/query-pagination/style.css 269 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 187 B
build/block-library/blocks/quote/style.css 187 B
build/block-library/blocks/quote/theme-rtl.css 223 B
build/block-library/blocks/quote/theme.css 226 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 397 B
build/block-library/blocks/search/style.css 398 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 245 B
build/block-library/blocks/separator/style.css 245 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 772 B
build/block-library/blocks/site-logo/editor.css 772 B
build/block-library/blocks/site-logo/style-rtl.css 165 B
build/block-library/blocks/site-logo/style.css 165 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 177 B
build/block-library/blocks/social-link/editor.css 177 B
build/block-library/blocks/social-links/editor-rtl.css 670 B
build/block-library/blocks/social-links/editor.css 669 B
build/block-library/blocks/social-links/style-rtl.css 1.32 kB
build/block-library/blocks/social-links/style.css 1.32 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 560 B
build/block-library/blocks/template-part/editor.css 559 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/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 857 B
build/block-library/common.css 856 B
build/block-library/editor-rtl.css 9.92 kB
build/block-library/editor.css 9.91 kB
build/block-library/index.min.js 162 kB
build/block-library/reset-rtl.css 474 B
build/block-library/reset.css 474 B
build/block-library/style-rtl.css 10.7 kB
build/block-library/style.css 10.7 kB
build/block-library/theme-rtl.css 672 B
build/block-library/theme.css 677 B
build/block-serialization-default-parser/index.min.js 1.09 kB
build/block-serialization-spec-parser/index.min.js 2.79 kB
build/blocks/index.min.js 46.3 kB
build/components/index.min.js 214 kB
build/components/style-rtl.css 15.4 kB
build/components/style.css 15.4 kB
build/compose/index.min.js 10.9 kB
build/core-data/index.min.js 13.2 kB
build/customize-widgets/index.min.js 11.4 kB
build/customize-widgets/style-rtl.css 1.5 kB
build/customize-widgets/style.css 1.49 kB
build/data-controls/index.min.js 631 B
build/data/index.min.js 7.47 kB
build/date/index.min.js 31.5 kB
build/deprecated/index.min.js 485 B
build/dom-ready/index.min.js 304 B
build/dom/index.min.js 4.5 kB
build/edit-navigation/index.min.js 16 kB
build/edit-navigation/style-rtl.css 3.76 kB
build/edit-navigation/style.css 3.76 kB
build/edit-post/classic-rtl.css 492 B
build/edit-post/classic.css 494 B
build/edit-post/index.min.js 29.6 kB
build/edit-post/style-rtl.css 7.1 kB
build/edit-post/style.css 7.09 kB
build/edit-site/style-rtl.css 6.58 kB
build/edit-site/style.css 6.58 kB
build/edit-widgets/index.min.js 16.5 kB
build/edit-widgets/style-rtl.css 4.18 kB
build/edit-widgets/style.css 4.18 kB
build/editor/index.min.js 37.8 kB
build/editor/style-rtl.css 3.78 kB
build/editor/style.css 3.77 kB
build/element/index.min.js 3.29 kB
build/escape-html/index.min.js 517 B
build/format-library/index.min.js 6.57 kB
build/format-library/style-rtl.css 571 B
build/format-library/style.css 571 B
build/hooks/index.min.js 1.63 kB
build/html-entities/index.min.js 424 B
build/i18n/index.min.js 3.71 kB
build/is-shallow-equal/index.min.js 501 B
build/keyboard-shortcuts/index.min.js 1.8 kB
build/keycodes/index.min.js 1.39 kB
build/list-reusable-blocks/index.min.js 1.72 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.92 kB
build/notices/index.min.js 925 B
build/nux/index.min.js 2.08 kB
build/nux/style-rtl.css 747 B
build/nux/style.css 743 B
build/plugins/index.min.js 1.84 kB
build/primitives/index.min.js 924 B
build/priority-queue/index.min.js 582 B
build/react-i18n/index.min.js 671 B
build/redux-routine/index.min.js 2.65 kB
build/reusable-blocks/index.min.js 2.22 kB
build/reusable-blocks/style-rtl.css 256 B
build/reusable-blocks/style.css 256 B
build/rich-text/index.min.js 11 kB
build/server-side-render/index.min.js 1.57 kB
build/shortcode/index.min.js 1.49 kB
build/token-list/index.min.js 639 B
build/url/index.min.js 1.9 kB
build/viewport/index.min.js 1.05 kB
build/warning/index.min.js 248 B
build/widgets/index.min.js 7.15 kB
build/widgets/style-rtl.css 1.16 kB
build/widgets/style.css 1.16 kB
build/wordcount/index.min.js 1.04 kB

compressed-size-action

@jasmussen
Copy link
Contributor

Thanks for the PR and the quick followup.

Before we move much further on this, I think we need to align on what it is we mean to accomplish here. Bringing CSS features 1:1 to the editor isn't necessarily the goal, because we can add smarts and systems that helps abstract the complexity of CSS in favor of a better user experience.

In this case, it really doesn't feel like we should support the use case of adding only border width, or border style, either in the editor or the site editor. I'm personally curious what the value there would ever be. CC: @apeatling @jameskoster @mtias

The way I picture this working is that if you opt into border support, a single control, called "Border", becomes available which inextricably ties the width and the style together.

@aaronrobertshaw
Copy link
Contributor Author

In this case, it really doesn't feel like we should support the use case of adding only border width, or border style, either in the editor or the site editor. I'm personally curious what the value there would ever be.

There has been some previous discussion around potentially removing border-style entirely as a visible control.

It has also been raised in internal discussions that it could be valid for a theme author to wish to prevent a user selecting dashed/dotted borders. The thinking being that it can help avoid bad choices from the user.

The way I picture this working is that if you opt into border support, a single control, called "Border", becomes available which inextricably ties the width and the style together.

When there is a design or clear direction on how that should look and function, I'll be happy to implement it.

@jasmussen
Copy link
Contributor

it could be valid for a theme author to wish to prevent a user selecting dashed/dotted borders. The thinking being that it can help avoid bad choices from the user.

That definitely feels valid 👍 👍

The use case I think we should avoid is a user seeing border style but no border width. If you have style, you should always have width, at the very least. Designwise I don't think it needs to look any different from what it looks like today, so to me it feels more like a technical implementation.

@jameskoster
Copy link
Contributor

Is the inconsistency between block and site editors here ok?

I think there's probably more value in the panels behaving consistently.

@stacimc
Copy link
Contributor

stacimc commented Dec 3, 2021

I'm not sure I totally understand the issue. The original concern with users needing to add a non-default control from the ToolsPanel menu just to get a functional border (in the case of Style) makes total sense to me -- that's certainly a bad workflow. Similarly, just making Style and Width both default controls but still requiring users to set two values before they get a functional border also seems problematic. Especially because as others have pointed out, Style seems like a very rarely desired control in the first place; it's generally safe to assume you want a solid border.

With Aaron's changes in #33743, the solid style is applied by default even if the Style control is hidden in the Tools panel. That feels like a good balance to me, because it allows the majority of users to never worry about the Style control at all.

The use case I think we should avoid is a user seeing border style but no border width.

I agree this would be an odd choice of controls to enable. Testing this scenario on trunk though, if you only select a border style, you still get a functional border with the default medium width. It's harder for me to imagine a scenario where a theme developer would want this, but it doesn't feel like a broken experience in the way that the original concern did (to me).

I can't seem to find a link, but I believe there's been discussion before about making certain options required for block supports. I suppose that could be an angle we take?

@aaronrobertshaw
Copy link
Contributor Author

This PR has been updated to:

  • enforce border-width support whenever border style is supported
  • combine the width & style menu items in Global Styles as well

I can't seem to find a link, but I believe there's been discussion before about making certain options required for block supports.

I know it has been raised a few times that being able to conditionally opt into a block support feature would be handy. Is that what you mean? One example of this could be supporting margins on the group block so long as it isn't a top-level block where it's left/right margins would be overwritten by the layouts block support.

@stacimc
Copy link
Contributor

stacimc commented Dec 7, 2021

I’ve given this a test and it works well according to the PR description, but I'm still not sure I understand why it's necessary in addition to the CSS defaults solution that was merged with #33743. Configuring a block to support style but not width seems unlikely, but even in the event that someone does so those defaults already ensure that you don’t need to update multiple controls to get a working border. For example if you select a ‘dashed’ style but don’t select a width, the medium width is automatically applied and your border appears.

Given that, it’s not clear to me what problem linking the controls fixes. It also raises a couple of new concerns:

  • If the controls are linked, it's much more difficult to hide the style control as an optional control. Style ought to be rarely used, and I think it's fair to expect that, when supported, it would generally be considered optional. If it's linked to width it ends up getting much more prominence, because it now displays every time width is selected. The only alternative is to disable the style support entirely.
  • This feature also requires introducing a quirk into the support: if a developer configures a block to support the style feature but excludes width, the width gets added in anyway. This may be an unlikely scenario, but it feels wrong to me to silently override or ignore an explicit configuration. I don’t believe we do this with any other block support.

@aaronrobertshaw
Copy link
Contributor Author

Given that, it’s not clear to me what problem linking the controls fixes. It also raises a couple of new concerns:

Both of the points you make are valid. Personally, I prefer the status quo with individual controls and no surprises for theme authors/users. My aim with this PR was to make good on a promise to follow up on these controls.

If others agree, I'd be happy to close this PR in favour of the way it is on trunk or new ideas if they emerge.

Any thoughts @apeatling, @jasmussen, @mtias?

@jasmussen
Copy link
Contributor

jasmussen commented Dec 7, 2021

The border control has been difficult, both technically and from an UX point of view. I appreciate your patience on this. The challenge has always been entirely from a UX point of view, that atomizing a border into three distinct pieces brought with it very few upsides over the previous collapsible panel: the ability to clear each individually from the tools panel, and to disable the "style". The downside is a lot of clicking (the next GIF shows what's shipping in trunk):

trunk tt2

I want to applaud the effort to make the border appear even without also choosing a style and color. That was a big win even for the classic collapsible panel.

To me, this branch is a step in the right direction:
border tt2

  • It's fewer clicks
  • If style is available to me, I should never have to explicitly choose it

"Style" doesn't feel like an easily understood term. While it maps to the CSS property, it doesn't necessarily translate well to UI controls. While we definitely want to keep theme.json support and the implementation as simple as we can, at the moment it feels like we are optimizing for an edgecase at the cost of splitting up what feels like symbiotic controls.

Would the following rename plus behavior tweak be possible?

  • Width and style are both enabled. Click plus to add "Border" and get both.
  • Width is enabled, style is not. Click plus to add "Border" and get only width.
  • If width is disabled, the border panel isn't available at all.

I know I've been the main voice of concern with borders, and just to boost my own confidence, I really would love to hear from others: @jameskoster @shaunandrews @javierarce @critterverse @mtias.

@jameskoster
Copy link
Contributor

I don't think surfacing the style control along with the width is a problem. Though one change I would suggest is to set it to solid by default (that seems to be the case on the canvas, but isn't reflected on the control).

On occasions where you want a different style, having to add that control manually, in addition to width, is tedious. Especially as – like Joen pointed out – "style" is not an intuitive term, whereas the icons for dotted / dashed are immediately obvious.

This feature also requires introducing a quirk into the support: if a developer configures a block to support the style feature but excludes width, the width gets added in anyway.

This doesn't feel like a situation we should be compromising the UI for.


I've said this in other issues, but I think we're allowing the design tools gamut to complicate what could be a much simpler experience. Each of width, style, and color must to be set for the border to apply, and it is easy to set defaults for each, so why not reveal those controls whenever a border is added? I'd love to work towards something like:

border.mp4

Which I think the PR does.

@apeatling
Copy link
Contributor

apeatling commented Dec 7, 2021

I've read through this and it's amazing how complicated things can get when you can enable/disable controls, and they are split up by their CSS properties. :)

I do agree with @jasmussen that this is ideal assuming default values are set for things that don't appear in the UI:

Width and style are both enabled. Click plus to add "Border" and get both.
Width is enabled, style is not. Click plus to add "Border" and get only width.
If width is disabled, the border panel isn't available at all.

However, @jasmussen what happens when radius is enabled? You have to have the dropdown menu rather than immediately adding those controls. In this case I assume menu names would be [Width and Style] or [Width] for first two points above?

@apeatling
Copy link
Contributor

apeatling commented Dec 7, 2021

I've said this in other issues, but I think we're allowing the design tools gamut to complicate what could be a much simpler experience. Each of width, style, and color must to be set for the border to apply, and it is easy to set defaults for each, so why not reveal those controls whenever a border is added? [...]

@jameskoster I think the issue with removing the dropdown entirely is how does this work when you add radius? Or if a third party comes along and adds an option for border image? It doesn't really scale unless you're going to add everything with one click.

@shaunandrews
Copy link
Contributor

I'm not sure it makes much sense to combine width and style. Border style is mostly irrelevant, and shouldn't be so prominent.

At the bare-minimum a border requires a color and a width. As such, I think it makes sense to combine these two options. Now, a block might only support one of these, so the options would have to adjust as needed. I outline most of these thoughts over here: #35602

@jameskoster
Copy link
Contributor

@apeatling I'm not totally convinced that radius should be a part of the border panel at all. I think we maybe got a bit caught up with the css property when adding it there.

It seems unlikely to me that the average user would look in the "border" section to round the corners of a block.

@stacimc
Copy link
Contributor

stacimc commented Dec 7, 2021

Though one change I would suggest is to set it to solid by default (that seems to be the case on the canvas, but isn't reflected on the control).

This is unfortunately a recurring problem in the block editor, which is that we cannot set default values in the controls because we do not have access to global styles -- so we cannot know that we are not overriding a value that's set in theme.json or global styles. I wrote a PR to add defaults, but it relied on a global styles API which was not merged. I absolutely think we should work on adding this, though.

@stacimc
Copy link
Contributor

stacimc commented Dec 7, 2021

Can this be solved in the short term by simply updating the configuration of default controls? #34061 adds defaults. We could just update all the blocks that support border to make width and color default controls. If the consensus is that having to click to add style is more of a problem than giving it prominence, we can make it default as well.

In the longer term the designs @shaunandrews linked above at #35602 could address the bigger problem of disconnected controls.

@jasmussen
Copy link
Contributor

However, @jasmussen what happens when radius is enabled? You have to have the dropdown menu rather than immediately adding those controls. In this case I assume menu names would be [Width and Style] or [Width] for first two points above?

Jay beat me to it: border radius, despite its name seeming to suggest otherwise, affects the shape of the block element instead, with the curve more or less being a side effect. I wish I could've been a fly on the wall when it the property was named, and I wonder if anyone suggested corner-radius instead 😅

The border panel seems a fine enough place to put the radius, at least until (and if) we find a better place to put it. But simply because of its behavior, it also makes sense to keep it separate.

@ramonjd
Copy link
Member

ramonjd commented Dec 7, 2021

we cannot set default values in the controls because we do not have access to global styles -- so we cannot know that we are not overriding a value that's set in theme.json or global styles. I wrote a PR to add defaults, but it relied on a global styles API which was not merged. I absolutely think we should work on adding this, though.

Is @jorgefilipecosta's PR still relevant? Add: API to allow blocks to access global styles. It hasn't seen much love recently, but last time I tested it, it was working well.

@stacimc
Copy link
Contributor

stacimc commented Dec 7, 2021

Is @jorgefilipecosta's PR still relevant? Add: API to allow blocks to access global styles. It hasn't seen much love recently, but last time I tested it, it was working well.

It is relevant (to the issue with adding placeholder/default values to the controls)! That's the PR that changes to add the placeholders in #34465 relied upon. It was working quite well, but recent changes to global styles broke the API. I do think it would add great value to be able to populate controls in the block-editor with existing values coming from global styles, in a future iteration.

@aaronrobertshaw
Copy link
Contributor Author

Thank you everyone for your thought and feedback on these issues. It's appreciated 👍

My plan to move forward is:

  1. Close this PR. (done)
  2. Add appropriate default controls to the border panel through #34061 as per @stacimc's suggestion ( in progress )
  3. Land API allowing blocks access to global styles and use to apply default selections to the border controls (in progress)
  4. Move towards implementing the design vision @shaunandrews has shared through #35602 & a related post

The second step above needs implementing as soon as we can. The third will allow us to polish things further keeping the control selections in sync with what is visible.

Lastly, implementing the new control designs will require supporting changes in addition to the new control and will take some time. Once 5.9 is released, I can start work on this if the opportunity hasn't presented itself sooner.

@jorgefilipecosta
Copy link
Member

Is @jorgefilipecosta's PR still relevant? Add: API to allow blocks to access global styles. It hasn't seen much love recently, but last time I tested it, it was working well.

Yes, it is still relevant our priorities changed because of 5.9 but I will soon rebase and try to push the PR forward.

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

Successfully merging this pull request may close these issues.

None yet

8 participants