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

Allow longhand and shorthand properties in theme.json and block attributes #31641

Merged
merged 9 commits into from
Jun 18, 2021

Conversation

aaronrobertshaw
Copy link
Contributor

@aaronrobertshaw aaronrobertshaw commented May 10, 2021

Related: #31337, #31585
Depends on: #31483

Description

This PR:

  • Flattens the configuration array used to map CSS property names with paths to the appropriate value in theme.json and block attributes
  • Updates border and spacing support so that border radius, margin and padding support allow both shorthand and longhand styles e.g. margin: 10px or margin-left: 20px
  • Updates the theme.json and block support style tests to cover shorthand and longhand styles
  • Updates global styles renderer to handle shorthand/longhand style values and configuration

The driving force behind this was achieving the refined border support UI in #31337. To do so, the border block support needs to allow custom values for each corner's border radius. This PR addresses this need while also maintaining backwards compatibility for a single border radius value.

How has this been tested?

Automated tests.

Theme.json stylesheet generation:
/var/www/html/wp-content/plugins/gutenberg/phpunit/class-wp-theme-json-test.php

Block support inline styles:
packages/block-editor/src/hooks/test/style.js
packages/edit-site/src/components/editor/test/global-styles-renderer.js

Manual testing:

  1. Apply this PR
  2. Enable custom margin and padding support via theme.json
  3. Add theme styles for the core/group block in the theme.json as well. Try simple shorthand margin and padding values
  4. Open the site editor and in the global styles sidebar switch to the By block type tab, then expand the Group block panel.
  5. Confirm the margin and padding controls work and their global style values can be updated and saved correctly
  6. Edit the theme.json margin / padding styles to use split values per side
  7. Reload the site editor and confirm the group block's margin/padding controls still function
  8. Create a post within the normal block editor and add a group block
  9. Select the group block and configure its margin and paddding
  10. Save and confirm the spacing displays correctly.

This PR does not update the border support UI, to test the border changes manually, try #31585

  1. Checkout out the Block Support: Update border support UI #31585 branch update/border-block-support-ui
    (that's all that is needed, it contains the changes from this PR)
  2. Enable border support UI via theme.json - example theme.json gist
  3. Build (you might need to run npm install)
  4. Load editor, create post, add group block, and select it
  5. Confirm border support panel and radius control display and function as expected

Screenshots

Via use of these changes in #31585

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

github-actions bot commented May 10, 2021

Size Change: +147 B (0%)

Total Size: 1.04 MB

Filename Size Change
build/block-editor/index.min.js 119 kB +15 B (0%)
build/blocks/index.min.js 47.3 kB +78 B (0%)
build/edit-site/index.min.js 26 kB +54 B (0%)
ℹ️ View Unchanged
Filename Size Change
build/a11y/index.min.js 1.12 kB 0 B
build/annotations/index.min.js 2.93 kB 0 B
build/api-fetch/index.min.js 2.42 kB 0 B
build/autop/index.min.js 2.28 kB 0 B
build/blob/index.min.js 672 B 0 B
build/block-directory/index.min.js 6.61 kB 0 B
build/block-directory/style-rtl.css 989 B 0 B
build/block-directory/style.css 990 B 0 B
build/block-editor/style-rtl.css 13.5 kB 0 B
build/block-editor/style.css 13.5 kB 0 B
build/block-library/blocks/archives/editor-rtl.css 61 B 0 B
build/block-library/blocks/archives/editor.css 60 B 0 B
build/block-library/blocks/archives/style-rtl.css 65 B 0 B
build/block-library/blocks/archives/style.css 65 B 0 B
build/block-library/blocks/audio/editor-rtl.css 58 B 0 B
build/block-library/blocks/audio/editor.css 58 B 0 B
build/block-library/blocks/audio/style-rtl.css 112 B 0 B
build/block-library/blocks/audio/style.css 112 B 0 B
build/block-library/blocks/audio/theme-rtl.css 125 B 0 B
build/block-library/blocks/audio/theme.css 125 B 0 B
build/block-library/blocks/block/editor-rtl.css 161 B 0 B
build/block-library/blocks/block/editor.css 161 B 0 B
build/block-library/blocks/button/editor-rtl.css 475 B 0 B
build/block-library/blocks/button/editor.css 474 B 0 B
build/block-library/blocks/button/style-rtl.css 603 B 0 B
build/block-library/blocks/button/style.css 602 B 0 B
build/block-library/blocks/buttons/editor-rtl.css 315 B 0 B
build/block-library/blocks/buttons/editor.css 315 B 0 B
build/block-library/blocks/buttons/style-rtl.css 375 B 0 B
build/block-library/blocks/buttons/style.css 375 B 0 B
build/block-library/blocks/calendar/style-rtl.css 208 B 0 B
build/block-library/blocks/calendar/style.css 208 B 0 B
build/block-library/blocks/categories/editor-rtl.css 84 B 0 B
build/block-library/blocks/categories/editor.css 83 B 0 B
build/block-library/blocks/categories/style-rtl.css 79 B 0 B
build/block-library/blocks/categories/style.css 79 B 0 B
build/block-library/blocks/code/style-rtl.css 90 B 0 B
build/block-library/blocks/code/style.css 90 B 0 B
build/block-library/blocks/code/theme-rtl.css 131 B 0 B
build/block-library/blocks/code/theme.css 131 B 0 B
build/block-library/blocks/columns/editor-rtl.css 190 B 0 B
build/block-library/blocks/columns/editor.css 190 B 0 B
build/block-library/blocks/columns/style-rtl.css 422 B 0 B
build/block-library/blocks/columns/style.css 422 B 0 B
build/block-library/blocks/cover/editor-rtl.css 644 B 0 B
build/block-library/blocks/cover/editor.css 646 B 0 B
build/block-library/blocks/cover/style-rtl.css 1.22 kB 0 B
build/block-library/blocks/cover/style.css 1.23 kB 0 B
build/block-library/blocks/embed/editor-rtl.css 486 B 0 B
build/block-library/blocks/embed/editor.css 486 B 0 B
build/block-library/blocks/embed/style-rtl.css 401 B 0 B
build/block-library/blocks/embed/style.css 400 B 0 B
build/block-library/blocks/embed/theme-rtl.css 124 B 0 B
build/block-library/blocks/embed/theme.css 124 B 0 B
build/block-library/blocks/file/editor-rtl.css 301 B 0 B
build/block-library/blocks/file/editor.css 300 B 0 B
build/block-library/blocks/file/frontend.min.js 773 B 0 B
build/block-library/blocks/file/style-rtl.css 255 B 0 B
build/block-library/blocks/file/style.css 255 B 0 B
build/block-library/blocks/freeform/editor-rtl.css 2.44 kB 0 B
build/block-library/blocks/freeform/editor.css 2.44 kB 0 B
build/block-library/blocks/gallery/editor-rtl.css 704 B 0 B
build/block-library/blocks/gallery/editor.css 705 B 0 B
build/block-library/blocks/gallery/style-rtl.css 1.06 kB 0 B
build/block-library/blocks/gallery/style.css 1.06 kB 0 B
build/block-library/blocks/gallery/theme-rtl.css 122 B 0 B
build/block-library/blocks/gallery/theme.css 122 B 0 B
build/block-library/blocks/group/editor-rtl.css 160 B 0 B
build/block-library/blocks/group/editor.css 160 B 0 B
build/block-library/blocks/group/style-rtl.css 57 B 0 B
build/block-library/blocks/group/style.css 57 B 0 B
build/block-library/blocks/group/theme-rtl.css 93 B 0 B
build/block-library/blocks/group/theme.css 93 B 0 B
build/block-library/blocks/heading/editor-rtl.css 152 B 0 B
build/block-library/blocks/heading/editor.css 152 B 0 B
build/block-library/blocks/heading/style-rtl.css 76 B 0 B
build/block-library/blocks/heading/style.css 76 B 0 B
build/block-library/blocks/home-link/style-rtl.css 259 B 0 B
build/block-library/blocks/home-link/style.css 259 B 0 B
build/block-library/blocks/html/editor-rtl.css 281 B 0 B
build/block-library/blocks/html/editor.css 281 B 0 B
build/block-library/blocks/image/editor-rtl.css 729 B 0 B
build/block-library/blocks/image/editor.css 727 B 0 B
build/block-library/blocks/image/style-rtl.css 481 B 0 B
build/block-library/blocks/image/style.css 485 B 0 B
build/block-library/blocks/image/theme-rtl.css 124 B 0 B
build/block-library/blocks/image/theme.css 124 B 0 B
build/block-library/blocks/latest-comments/style-rtl.css 281 B 0 B
build/block-library/blocks/latest-comments/style.css 282 B 0 B
build/block-library/blocks/latest-posts/editor-rtl.css 137 B 0 B
build/block-library/blocks/latest-posts/editor.css 137 B 0 B
build/block-library/blocks/latest-posts/style-rtl.css 529 B 0 B
build/block-library/blocks/latest-posts/style.css 529 B 0 B
build/block-library/blocks/list/style-rtl.css 63 B 0 B
build/block-library/blocks/list/style.css 63 B 0 B
build/block-library/blocks/media-text/editor-rtl.css 176 B 0 B
build/block-library/blocks/media-text/editor.css 176 B 0 B
build/block-library/blocks/media-text/style-rtl.css 492 B 0 B
build/block-library/blocks/media-text/style.css 489 B 0 B
build/block-library/blocks/more/editor-rtl.css 434 B 0 B
build/block-library/blocks/more/editor.css 434 B 0 B
build/block-library/blocks/navigation-link/editor-rtl.css 633 B 0 B
build/block-library/blocks/navigation-link/editor.css 634 B 0 B
build/block-library/blocks/navigation-link/style-rtl.css 94 B 0 B
build/block-library/blocks/navigation-link/style.css 94 B 0 B
build/block-library/blocks/navigation/editor-rtl.css 1.55 kB 0 B
build/block-library/blocks/navigation/editor.css 1.55 kB 0 B
build/block-library/blocks/navigation/frontend.min.js 2.86 kB 0 B
build/block-library/blocks/navigation/style-rtl.css 1.63 kB 0 B
build/block-library/blocks/navigation/style.css 1.63 kB 0 B
build/block-library/blocks/nextpage/editor-rtl.css 395 B 0 B
build/block-library/blocks/nextpage/editor.css 395 B 0 B
build/block-library/blocks/page-list/editor-rtl.css 310 B 0 B
build/block-library/blocks/page-list/editor.css 311 B 0 B
build/block-library/blocks/page-list/style-rtl.css 240 B 0 B
build/block-library/blocks/page-list/style.css 240 B 0 B
build/block-library/blocks/paragraph/editor-rtl.css 157 B 0 B
build/block-library/blocks/paragraph/editor.css 157 B 0 B
build/block-library/blocks/paragraph/style-rtl.css 247 B 0 B
build/block-library/blocks/paragraph/style.css 248 B 0 B
build/block-library/blocks/post-author/editor-rtl.css 209 B 0 B
build/block-library/blocks/post-author/editor.css 209 B 0 B
build/block-library/blocks/post-author/style-rtl.css 183 B 0 B
build/block-library/blocks/post-author/style.css 184 B 0 B
build/block-library/blocks/post-comments-form/style-rtl.css 140 B 0 B
build/block-library/blocks/post-comments-form/style.css 140 B 0 B
build/block-library/blocks/post-comments/style-rtl.css 360 B 0 B
build/block-library/blocks/post-comments/style.css 359 B 0 B
build/block-library/blocks/post-content/editor-rtl.css 139 B 0 B
build/block-library/blocks/post-content/editor.css 139 B 0 B
build/block-library/blocks/post-excerpt/editor-rtl.css 73 B 0 B
build/block-library/blocks/post-excerpt/editor.css 73 B 0 B
build/block-library/blocks/post-excerpt/style-rtl.css 69 B 0 B
build/block-library/blocks/post-excerpt/style.css 69 B 0 B
build/block-library/blocks/post-featured-image/editor-rtl.css 338 B 0 B
build/block-library/blocks/post-featured-image/editor.css 338 B 0 B
build/block-library/blocks/post-featured-image/style-rtl.css 141 B 0 B
build/block-library/blocks/post-featured-image/style.css 141 B 0 B
build/block-library/blocks/post-template/editor-rtl.css 100 B 0 B
build/block-library/blocks/post-template/editor.css 99 B 0 B
build/block-library/blocks/post-template/style-rtl.css 379 B 0 B
build/block-library/blocks/post-template/style.css 380 B 0 B
build/block-library/blocks/post-title/style-rtl.css 60 B 0 B
build/block-library/blocks/post-title/style.css 60 B 0 B
build/block-library/blocks/preformatted/style-rtl.css 103 B 0 B
build/block-library/blocks/preformatted/style.css 103 B 0 B
build/block-library/blocks/pullquote/editor-rtl.css 183 B 0 B
build/block-library/blocks/pullquote/editor.css 183 B 0 B
build/block-library/blocks/pullquote/style-rtl.css 318 B 0 B
build/block-library/blocks/pullquote/style.css 318 B 0 B
build/block-library/blocks/pullquote/theme-rtl.css 169 B 0 B
build/block-library/blocks/pullquote/theme.css 169 B 0 B
build/block-library/blocks/query-pagination-numbers/editor-rtl.css 122 B 0 B
build/block-library/blocks/query-pagination-numbers/editor.css 121 B 0 B
build/block-library/blocks/query-pagination/editor-rtl.css 270 B 0 B
build/block-library/blocks/query-pagination/editor.css 262 B 0 B
build/block-library/blocks/query-pagination/style-rtl.css 168 B 0 B
build/block-library/blocks/query-pagination/style.css 168 B 0 B
build/block-library/blocks/query-title/editor-rtl.css 86 B 0 B
build/block-library/blocks/query-title/editor.css 86 B 0 B
build/block-library/blocks/query/editor-rtl.css 131 B 0 B
build/block-library/blocks/query/editor.css 132 B 0 B
build/block-library/blocks/quote/style-rtl.css 169 B 0 B
build/block-library/blocks/quote/style.css 169 B 0 B
build/block-library/blocks/quote/theme-rtl.css 221 B 0 B
build/block-library/blocks/quote/theme.css 221 B 0 B
build/block-library/blocks/rss/editor-rtl.css 201 B 0 B
build/block-library/blocks/rss/editor.css 202 B 0 B
build/block-library/blocks/rss/style-rtl.css 290 B 0 B
build/block-library/blocks/rss/style.css 290 B 0 B
build/block-library/blocks/search/editor-rtl.css 211 B 0 B
build/block-library/blocks/search/editor.css 211 B 0 B
build/block-library/blocks/search/style-rtl.css 359 B 0 B
build/block-library/blocks/search/style.css 362 B 0 B
build/block-library/blocks/search/theme-rtl.css 64 B 0 B
build/block-library/blocks/search/theme.css 64 B 0 B
build/block-library/blocks/separator/editor-rtl.css 99 B 0 B
build/block-library/blocks/separator/editor.css 99 B 0 B
build/block-library/blocks/separator/style-rtl.css 251 B 0 B
build/block-library/blocks/separator/style.css 251 B 0 B
build/block-library/blocks/separator/theme-rtl.css 172 B 0 B
build/block-library/blocks/separator/theme.css 172 B 0 B
build/block-library/blocks/shortcode/editor-rtl.css 512 B 0 B
build/block-library/blocks/shortcode/editor.css 512 B 0 B
build/block-library/blocks/site-logo/editor-rtl.css 440 B 0 B
build/block-library/blocks/site-logo/editor.css 441 B 0 B
build/block-library/blocks/site-logo/style-rtl.css 154 B 0 B
build/block-library/blocks/site-logo/style.css 154 B 0 B
build/block-library/blocks/social-link/editor-rtl.css 164 B 0 B
build/block-library/blocks/social-link/editor.css 165 B 0 B
build/block-library/blocks/social-links/editor-rtl.css 800 B 0 B
build/block-library/blocks/social-links/editor.css 799 B 0 B
build/block-library/blocks/social-links/style-rtl.css 1.34 kB 0 B
build/block-library/blocks/social-links/style.css 1.34 kB 0 B
build/block-library/blocks/spacer/editor-rtl.css 308 B 0 B
build/block-library/blocks/spacer/editor.css 308 B 0 B
build/block-library/blocks/spacer/style-rtl.css 48 B 0 B
build/block-library/blocks/spacer/style.css 48 B 0 B
build/block-library/blocks/table/editor-rtl.css 478 B 0 B
build/block-library/blocks/table/editor.css 478 B 0 B
build/block-library/blocks/table/style-rtl.css 480 B 0 B
build/block-library/blocks/table/style.css 480 B 0 B
build/block-library/blocks/table/theme-rtl.css 188 B 0 B
build/block-library/blocks/table/theme.css 188 B 0 B
build/block-library/blocks/tag-cloud/editor-rtl.css 118 B 0 B
build/block-library/blocks/tag-cloud/editor.css 118 B 0 B
build/block-library/blocks/tag-cloud/style-rtl.css 94 B 0 B
build/block-library/blocks/tag-cloud/style.css 94 B 0 B
build/block-library/blocks/template-part/editor-rtl.css 551 B 0 B
build/block-library/blocks/template-part/editor.css 550 B 0 B
build/block-library/blocks/template-part/theme-rtl.css 101 B 0 B
build/block-library/blocks/template-part/theme.css 101 B 0 B
build/block-library/blocks/term-description/editor-rtl.css 90 B 0 B
build/block-library/blocks/term-description/editor.css 90 B 0 B
build/block-library/blocks/text-columns/editor-rtl.css 95 B 0 B
build/block-library/blocks/text-columns/editor.css 95 B 0 B
build/block-library/blocks/text-columns/style-rtl.css 166 B 0 B
build/block-library/blocks/text-columns/style.css 166 B 0 B
build/block-library/blocks/verse/style-rtl.css 87 B 0 B
build/block-library/blocks/verse/style.css 87 B 0 B
build/block-library/blocks/video/editor-rtl.css 569 B 0 B
build/block-library/blocks/video/editor.css 570 B 0 B
build/block-library/blocks/video/style-rtl.css 173 B 0 B
build/block-library/blocks/video/style.css 173 B 0 B
build/block-library/blocks/video/theme-rtl.css 124 B 0 B
build/block-library/blocks/video/theme.css 124 B 0 B
build/block-library/common-rtl.css 1.26 kB 0 B
build/block-library/common.css 1.26 kB 0 B
build/block-library/editor-rtl.css 9.68 kB 0 B
build/block-library/editor.css 9.67 kB 0 B
build/block-library/index.min.js 145 kB 0 B
build/block-library/reset-rtl.css 506 B 0 B
build/block-library/reset.css 507 B 0 B
build/block-library/style-rtl.css 10.2 kB 0 B
build/block-library/style.css 10.2 kB 0 B
build/block-library/theme-rtl.css 692 B 0 B
build/block-library/theme.css 693 B 0 B
build/block-serialization-default-parser/index.min.js 1.3 kB 0 B
build/block-serialization-spec-parser/index.min.js 3.06 kB 0 B
build/components/index.min.js 180 kB 0 B
build/components/style-rtl.css 16.2 kB 0 B
build/components/style.css 16.1 kB 0 B
build/compose/index.min.js 10.2 kB 0 B
build/core-data/index.min.js 12.2 kB 0 B
build/customize-widgets/index.min.js 9.97 kB 0 B
build/customize-widgets/style-rtl.css 1.45 kB 0 B
build/customize-widgets/style.css 1.44 kB 0 B
build/data-controls/index.min.js 828 B 0 B
build/data/index.min.js 7.22 kB 0 B
build/date/index.min.js 31.8 kB 0 B
build/deprecated/index.min.js 739 B 0 B
build/dom-ready/index.min.js 576 B 0 B
build/dom/index.min.js 4.62 kB 0 B
build/edit-navigation/index.min.js 14 kB 0 B
build/edit-navigation/style-rtl.css 3.08 kB 0 B
build/edit-navigation/style.css 3.08 kB 0 B
build/edit-post/classic-rtl.css 454 B 0 B
build/edit-post/classic.css 454 B 0 B
build/edit-post/index.min.js 58.5 kB 0 B
build/edit-post/style-rtl.css 7.05 kB 0 B
build/edit-post/style.css 7.04 kB 0 B
build/edit-site/style-rtl.css 4.75 kB 0 B
build/edit-site/style.css 4.75 kB 0 B
build/edit-widgets/index.min.js 15.8 kB 0 B
build/edit-widgets/style-rtl.css 3.45 kB 0 B
build/edit-widgets/style.css 3.45 kB 0 B
build/editor/index.min.js 38.6 kB 0 B
build/editor/style-rtl.css 3.91 kB 0 B
build/editor/style.css 3.9 kB 0 B
build/element/index.min.js 3.44 kB 0 B
build/escape-html/index.min.js 739 B 0 B
build/format-library/index.min.js 5.68 kB 0 B
build/format-library/style-rtl.css 637 B 0 B
build/format-library/style.css 639 B 0 B
build/hooks/index.min.js 1.76 kB 0 B
build/html-entities/index.min.js 628 B 0 B
build/i18n/index.min.js 3.73 kB 0 B
build/is-shallow-equal/index.min.js 709 B 0 B
build/keyboard-shortcuts/index.min.js 1.74 kB 0 B
build/keycodes/index.min.js 1.43 kB 0 B
build/list-reusable-blocks/index.min.js 2.07 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/media-utils/index.min.js 3.08 kB 0 B
build/notices/index.min.js 1.07 kB 0 B
build/nux/index.min.js 2.31 kB 0 B
build/nux/style-rtl.css 718 B 0 B
build/nux/style.css 716 B 0 B
build/plugins/index.min.js 1.99 kB 0 B
build/primitives/index.min.js 1.03 kB 0 B
build/priority-queue/index.min.js 791 B 0 B
build/react-i18n/index.min.js 924 B 0 B
build/redux-routine/index.min.js 2.82 kB 0 B
build/reusable-blocks/index.min.js 2.56 kB 0 B
build/reusable-blocks/style-rtl.css 225 B 0 B
build/reusable-blocks/style.css 225 B 0 B
build/rich-text/index.min.js 10.6 kB 0 B
build/server-side-render/index.min.js 1.63 kB 0 B
build/shortcode/index.min.js 1.68 kB 0 B
build/token-list/index.min.js 847 B 0 B
build/url/index.min.js 1.95 kB 0 B
build/viewport/index.min.js 1.28 kB 0 B
build/warning/index.min.js 1.13 kB 0 B
build/widgets/index.min.js 6.48 kB 0 B
build/widgets/style-rtl.css 693 B 0 B
build/widgets/style.css 693 B 0 B
build/wordcount/index.min.js 1.24 kB 0 B

compressed-size-action

@aaronrobertshaw aaronrobertshaw marked this pull request as draft May 10, 2021 07:03
@jasmussen
Copy link
Contributor

A few wee early and very initial thoughts: the border radius panel should probably start collapsed and default to PX rather than EM. I'd also put color below both border style, width and radius.

We also really need the collapsed color swatch from #27331 and #27473 (comment) soon, it simply takes up too much space in this vein.

Honestly I wish we could collapse the border control as far down as this:

Screenshot 2021-05-11 at 08 59 27

— that is, slightly Figma inspired, a border is something you add:

border

We'd need for the border controls to be in a separate panel that could look like #31337, right @jameskoster?

@aaronrobertshaw
Copy link
Contributor Author

Thanks for the early feedback @jasmussen! It's very much appreciated.

A few wee early and very initial thoughts: the border radius panel should probably start collapsed and default to PX rather than EM.

The screenshot in the PR description was mistakenly captured after I'd already set border radii on the block while testing. That's why the border radius field defaulted to open, I'd set specific per-corner values for it. If you were testing via #31585 this is what I see:

I'd also put color below both border style, width and radius.

The current order (in #31585) matches the order of controls in #31337. I believe the idea there was for them to match the CSS syntax order. Can you confirm I should change the order so the color controls appear last?

We also really need the collapsed color swatch from #27331 and #27473 (comment) soon, it simply takes up too much space in this vein.

I can appreciate the desire for the collapsed color swatch. I was also looking at being able to add separate background & text color controls for table header, footer and striped rows as requested in #30791 (comment). The current control is definitely too unwieldy to provide that many options.

Screen Shot 2021-05-11 at 5 18 36 pm

Looking at the initial designs for the collapsed color control, it looks to me like it will take quite some time to be able to implement along with required subcomponents.

I don't think it should hold up the other refinements to the border block support UI ( #31337 ) as there are several PRs blocked waiting to be able to leverage this support. In addition, the controls are disabled by default which might provide the window to iterate on the color control.

I'm happy to make a start on implementing the collapsed color control as soon as I free up a little extra bandwidth.

We'd need for the border controls to be in a separate panel that could look like #31337, right @jameskoster?

I might be missing something but this is what #31585 is looking to achieve. However, to achieve some of the controls in that UI design we needed to refine the border block support to handle non-pixel units and the split border radius values in this PR.

@jameskoster
Copy link
Contributor

Honestly I wish we could collapse the border control as far down as this:

The missing piece there is being able to toggle the panels themselves in the UI. I don't think we ever got to designs for that in #27331.

@aaronrobertshaw This is looking good from the screenshots, but I'm not seeing the controls in my local environment. Is there anything I need to do besides building this branch?

One other question: were the icons for the border style added to the icons package?

@aaronrobertshaw
Copy link
Contributor Author

Thanks for testing @jameskoster 👍

This is looking good from the screenshots, but I'm not seeing the controls in my local environment.

This PR itself only updates the block support etc to be capable of handling the individual border radius values. It includes updates to automated tests that can be run.

Is there anything I need to do besides building this branch?

I have a separate PR ( #31585 ) based upon this one that introduces the new border radius control and refines the border block support UI. It's currently only a draft and marked as WIP as I need to confirm the approach taken both in this PR and for custom units for border width and radius.

It would be great if you still had time to give this all a test. To do that, build #31585 and then enable custom borders in your experimental-theme.json. The group block already opts into all the border block support features so it's the easiest block to add to a post and test with.

One other question: were the icons for the border style added to the icons package?

Not at this stage, they were packaged with the new border radius control. I was suffering from some tunnel vision while putting together the PR refining the border support UI. I can add them to the icons package as part of #31585 or a separate PR, whichever is best.

Also, from the early discussion on that border radius control, it sounded as though it would need its own icon to represent corners rather than sides for the linked button. However, if the simple link/unlink icons used at the moment are ok, it might be possible to iterate on that control and make it more generic. Something we can work on via a separate PR.

@jameskoster
Copy link
Contributor

enable custom borders in your experimental-theme.json

Asking for a friend... how does one do this? 😆

@aaronrobertshaw
Copy link
Contributor Author

aaronrobertshaw commented May 11, 2021

Asking for a friend... how does one do this? 😆

Sorry @jameskoster I hadn't gotten to detailing test instructions on the WIP PR. The easiest method for testing is to just toggle on the custom border properties under the defaults settings in the theme.json. Below is a snippet of the relevant config flags or for more context a gist of my default theme.json with custom borders enabled

		"border": {
			"customColor": true,
			"customRadius": true,
			"customStyle": true,
			"customWidth": true
		},

@jameskoster
Copy link
Contributor

I must be doing something wrong 🙈

To do that, build #31585 and then enable custom borders in your experimental-theme.json.

I've done this and I'm not seeing border controls anywhere, even on the group block.

@aaronrobertshaw
Copy link
Contributor Author

aaronrobertshaw commented May 24, 2021

I must be doing something wrong 🙈

In this case, it's most likely poor instructions 🙂

I've retested and after checking out #31585 and toggling all the border properties below to true. The border support panel shows for me on the group block.

		"border": {
			"customColor": true,
			"customRadius": true,
			"customStyle": true,
			"customWidth": true
		},

I think the problem could be that I linked to a gist that had borders enabled but was more recent. The theme.json schema has been recently reshaped. It caught me out on a couple of PRs. If you copied and pasted the entire gist it wouldn't have matched the schema and been misinterpreted.

Here is a gist you can copy and paste into your theme's experimental-theme.json file or the lib/experimental-default-theme.json if appropriate. I've tested copying and pasting this gist into my theme.json and it works.

One other question: were the icons for the border style added to the icons package?

The icons have been added to the icons package via a commit in #31585.

@jameskoster
Copy link
Contributor

No luck :( FWIW I'm using tt1-blocks which seems to have the correct declaration: https://github.com/WordPress/theme-experiments/blob/master/tt1-blocks/theme.json#L188-L193

@ramonjd
Copy link
Member

ramonjd commented May 28, 2021

I'm also having trouble testing this manually.

I applied this patch on top of #31483 and set the following in settings.default in lib/experimental-default-theme.json

			"border": {
				"customColor": true,
				"customRadius": true,
				"customStyle": true,
				"customWidth": true
			}

Should customRadius be an array of [ "topLeft", ... ] or something?

I tried a few themes and seeing these controls

Screen Shot 2021-05-28 at 3 34 32 pm

Are there updated instructions?

@ramonjd
Copy link
Member

ramonjd commented May 28, 2021

No luck :(

@jameskoster I think we have to test these changes manually by checking out this PR branch #31585

Automated tests.

Unit tests passed locally for me 👍

@aaronrobertshaw
Copy link
Contributor Author

I'm also having trouble testing this manually.

Thanks @ramonjd for testing.

I'd tried to separate the changes related to updating the border radius support from the updates to the border support UI. The idea being to keep the PRs a manageable size. That's why I only had instructions related to the automated tests on this PR. Perhaps adding the gif illustrating what this PR allows caused some confusion. My apologies.

Are there updated instructions?

I'll update the test instructions for those that would like to see the updated block support in action. To test this support manually, we need the updated border support UI in #31585.

  1. Checkout out the Block Support: Update border support UI #31585 branch update/border-block-support-ui
    (that's all that is needed, it contains the changes from this PR)
  2. Enable border support UI via theme.json - example theme.json gist
  3. Build
  4. Load editor, create post, add group block, and select it
  5. Confirm border support panel and radius control display and function as expected

cc/ @jameskoster in case this helps.

@ramonjd
Copy link
Member

ramonjd commented May 28, 2021

That's why I only had instructions related to the automated tests on this PR.

Thanks @aaronrobertshaw It's totally obvious now you point it out. :D I think I was fixated on the GIF and design feedback and assumed...

@aaronrobertshaw
Copy link
Contributor Author

It's totally obvious now you point it out. :D I think I was fixated on the GIF and design feedback and assumed...

I appreciate the feedback all the same. I'll try and make the distinction clearer on future PRs. The little comment above the gif "Via use of these changes in #31585" is pretty easy to scan straight passed and isn't exactly clear either.

Thanks again for testing 👍

I've also re-tested using the new instructions and it is still working for me.

@aaronrobertshaw aaronrobertshaw mentioned this pull request Jun 3, 2021
15 tasks
Base automatically changed from update/border-support-for-custom-units to trunk June 7, 2021 06:04
@aaronrobertshaw aaronrobertshaw force-pushed the update/border-radius-support-custom-corners branch from 677a9a8 to 6408a75 Compare June 7, 2021 09:39
@aaronrobertshaw aaronrobertshaw changed the title Block Support: Allow custom per corner border radius values Block Support: Flatten CSS properties metadata config and allow per corner border radii Jun 16, 2021
$corner = strtolower( preg_replace( '/(?<!^)[A-Z]/', '-$0', $key ) );
$styles[] = sprintf( 'border-%s-radius: %s;', $corner, $radius );
}
} else {
Copy link
Member

Choose a reason for hiding this comment

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

Can the border radius be null? Do we need to check for that like we do for spacing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe the original code here for the border support was added prior to _wp_array_get getting wider usage so the code approaches the check a little differently to the spacing support.

Along with checking for the feature support, it also does an isset check which would return false for a null value. Would making the supports' code consistent in approach be best done in a separate PR? I'm happy to take care of that in a follow up.

@oandregal
Copy link
Member

There seems to be some conflict in files and I've left some minor comments. I think once that's addressed we can merge this one (I can manually test then, haven't done yet).

This updates the theme.json generated stylesheet to handle individual border radius values per corner.

It maintains single string value support for the shorthand expression for all corners at once. This allows backwards compatibility for blocks that have already adopted border radius support.
Maintains support for flat string value for setting all border radii at once.
@aaronrobertshaw aaronrobertshaw force-pushed the update/border-radius-support-custom-corners branch from 706321b to 9b8f2c7 Compare June 17, 2021 06:37
@aaronrobertshaw
Copy link
Contributor Author

There seems to be some conflict in files and I've left some minor comments. I think once that's addressed we can merge this one (I can manually test then, haven't done yet).

The conflicts turned out to be only for the assertions relating to generated stylesheets. I've resolved those and the tests are all green again. I'll rebase the PR updating the border support UI onto this shortly so it can be used for manual testing if desired.

Copy link
Member

@oandregal oandregal left a comment

Choose a reason for hiding this comment

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

Tested this using padding -both short and longhands- in the front, site, and post editor. Also tested that content created in trunk works well with this PR (no invalidations, etc).

Thanks to your patience through this we're getting a great simplification in the implementation + new behaviour across the board. 🌟

I'm just crossing my fingers for this not to cause too many headaches when/if we need to port late things to core for 5.8 😅 🤞 🍀 I'll take care of that should it happen.

@oandregal oandregal merged commit a1eac43 into trunk Jun 18, 2021
@oandregal oandregal deleted the update/border-radius-support-custom-corners branch June 18, 2021 08:50
@oandregal oandregal changed the title Block Support: Flatten CSS properties metadata config and allow per corner border radii Allow longhand and shorthand properties in theme.json and block attributes Jun 18, 2021
@github-actions github-actions bot added this to the Gutenberg 11.0 milestone Jun 18, 2021
$attrs[] = 'border-top-left-radius';
$attrs[] = 'border-top-right-radius';
$attrs[] = 'border-bottom-right-radius';
$attrs[] = 'border-bottom-left-radius';
Copy link
Contributor

Choose a reason for hiding this comment

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

Was this change backported to Core at any point?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It appears to me that the changes were backported and were done so in (WordPress/wordpress-develop@f034bc8).

Copy link
Contributor

Choose a reason for hiding this comment

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

Part of my confusion is that the function indicates that it should be removed once the minimum WP version is 5.8, I guess it should have been updated to 5.9 after this change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That was an oversight of mine sorry. This change didn't make it into a release until 11.0 and therefore WP 5.9.

An additional attribute was added to this filter a few months later (#36280) that would also make the minimum version requirement 5.9 before it can be removed.

I've created a tiny PR to fix this comment in #38359.

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.

6 participants