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

[WIP] Design Tools: Add section based styling via theme.json #56234

Closed
wants to merge 23 commits into from

Conversation

aaronrobertshaw
Copy link
Contributor

@aaronrobertshaw aaronrobertshaw commented Nov 17, 2023

🚧 🚧 🚧 🚧 Not yet ready for review! 🚧 🚧 🚧 🚧

Related:

What?

Provides the ability to style sections of a page with a predefined set of styles contained within the theme.json.

For this initial MVP, there will be no global styles support as that will require heavy UI updates and would be unlikely to make it into 6.5.

Why?

The ability to style entire sections with curated sets of styles will help unlock a level of composability for site designs and further encourage building sites with patterns.

Todo

  • Replace the simple placeholder approach to making merged global styles data available in the block editor
  • Refine the shape and location for the sections config within theme.json
  • Add further unit tests
  • Enhance the fallback logic to improve the experience when switching themes
  • Decide whether the sections panel should be restricted so 3rd parties can't render to it inserting controls above higher priority panels
  • A LOT of testing

Future Follow-ups

  • Update the Global Styles UI to allow in-editor configuration of section styles
  • Allow users to push a block instance's styling as a section style to Global Styles
  • Reflect an applied section style's values within the block's design tools

How?

  • Adds merged global styles data to the block editor store so section styles can be accessed in post editor (to be revised)
  • Registers new sections block support to include section block attribute
  • Section block support adds PHP filter to inject the section CSS class on the frontend
  • Adds new inspector control group for sections
  • Updates PHP and JS scope selector util functions to handle cases where scope or selector arguments are undefined
  • Created JS block support hook to add section attribute, inject CSS class, and render section UI
  • Updates the PHP theme.json class and useGlobalStylesOutput JS hook to generate CSS for sections
    • These updates required a lot of repeated but slightly different code. This was refactored into some shared util functions

Testing Instructions

TBA

Testing Instructions for Keyboard

TBA

Screenshots or screencast

Screen.Recording.2023-11-17.at.1.26.46.pm.mp4
Sample `sections` config for the theme.json used in above demo
{
  "styles": {
    "sections": [
      {
        "title": "Hero",
        "color": {
          "background": "#034078",
          "text": "var(--wp--preset--color--base)"
        },
        "blocks": {
          "core/heading": {
            "typography": {
              "fontSize": "90px"
            }
          },
          "core/paragraph": {
            "typography": {
              "fontSize": "24px"
            }
          },
          "core/button": {
            "color": {
              "background": "#1282a2",
              "text": "var(--wp--preset--color--base)"
            }
          }
        }
      },
      {
        "title": "Dark",
        "color": {
          "background": "#0A1128",
          "text": "var(--wp--preset--color--base)"
        },
        "typography": {
          "fontSize": "var(--wp--preset--font-size--small)",
          "fontStyle": "normal",
          "fontWeight": "600"
        },
        "blocks": {
          "core/button": {
            "color": {
              "background": "#1282a2",
              "text": "var(--wp--preset--color--base)"
            }
          }
        }
      },
      {
        "title": "Light",
        "color": {
          "background": "#F8F8F8",
          "text": "#0A1128"
        },
        "elements": {
          "heading": {
            "color": {
              "text": "#034078"
            }
          },
          "h5": {
            "color": {
              "text": "#1282a2"
            }
          }
        }
      }
    ]
  }
}

@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 17, 2023
Copy link

github-actions bot commented Nov 17, 2023

This pull request has changed or added PHP files. Please confirm whether these changes need to be synced to WordPress Core, and therefore featured in the next release of WordPress.

If so, it is recommended to create a new Trac ticket and submit a pull request to the WordPress Core Github repository soon after this pull request is merged.

If you're unsure, you can always ask for help in the #core-editor channel in WordPress Slack.

Thank you! ❤️

View changed files
❔ lib/block-supports/sections.php
❔ lib/block-editor-settings.php
❔ lib/class-wp-theme-json-gutenberg.php
❔ lib/experimental/class-wp-rest-block-editor-settings-controller.php
❔ lib/load.php
❔ phpunit/class-wp-theme-json-test.php

Copy link

github-actions bot commented Nov 17, 2023

Size Change: +1.35 kB (0%)

Total Size: 1.7 MB

Filename Size Change
build/block-editor/index.min.js 248 kB +838 B (0%)
build/block-editor/style-rtl.css 15.7 kB +20 B (0%)
build/block-editor/style.css 15.7 kB +20 B (0%)
build/block-library/index.min.js 212 kB +4 B (0%)
build/core-data/index.min.js 72.4 kB +557 B (+1%)
build/edit-post/index.min.js 35.7 kB +2 B (0%)
build/edit-post/style-rtl.css 7.58 kB -42 B (-1%)
build/edit-post/style.css 7.57 kB -42 B (-1%)
build/edit-site/index.min.js 208 kB +3 B (0%)
build/edit-site/style-rtl.css 14.3 kB -32 B (0%)
build/edit-site/style.css 14.3 kB -32 B (0%)
build/editor/index.min.js 46.9 kB +83 B (0%)
build/editor/style-rtl.css 3.69 kB +3 B (0%)
build/editor/style.css 3.69 kB +4 B (0%)
build/patterns/index.min.js 4.81 kB -18 B (0%)
build/reusable-blocks/index.min.js 2.75 kB -16 B (-1%)
ℹ️ View Unchanged
Filename Size
build/a11y/index.min.js 964 B
build/annotations/index.min.js 2.71 kB
build/api-fetch/index.min.js 2.29 kB
build/autop/index.min.js 2.11 kB
build/blob/index.min.js 590 B
build/block-directory/index.min.js 7.25 kB
build/block-directory/style-rtl.css 1.04 kB
build/block-directory/style.css 1.04 kB
build/block-editor/content-rtl.css 4.29 kB
build/block-editor/content.css 4.28 kB
build/block-editor/default-editor-styles-rtl.css 403 B
build/block-editor/default-editor-styles.css 403 B
build/block-library/blocks/archives/editor-rtl.css 61 B
build/block-library/blocks/archives/editor.css 60 B
build/block-library/blocks/archives/style-rtl.css 90 B
build/block-library/blocks/archives/style.css 90 B
build/block-library/blocks/audio/editor-rtl.css 150 B
build/block-library/blocks/audio/editor.css 150 B
build/block-library/blocks/audio/style-rtl.css 122 B
build/block-library/blocks/audio/style.css 122 B
build/block-library/blocks/audio/theme-rtl.css 138 B
build/block-library/blocks/audio/theme.css 138 B
build/block-library/blocks/avatar/editor-rtl.css 116 B
build/block-library/blocks/avatar/editor.css 116 B
build/block-library/blocks/avatar/style-rtl.css 104 B
build/block-library/blocks/avatar/style.css 104 B
build/block-library/blocks/block/editor-rtl.css 305 B
build/block-library/blocks/block/editor.css 305 B
build/block-library/blocks/button/editor-rtl.css 587 B
build/block-library/blocks/button/editor.css 587 B
build/block-library/blocks/button/style-rtl.css 633 B
build/block-library/blocks/button/style.css 632 B
build/block-library/blocks/buttons/editor-rtl.css 337 B
build/block-library/blocks/buttons/editor.css 337 B
build/block-library/blocks/buttons/style-rtl.css 332 B
build/block-library/blocks/buttons/style.css 332 B
build/block-library/blocks/calendar/style-rtl.css 239 B
build/block-library/blocks/calendar/style.css 239 B
build/block-library/blocks/categories/editor-rtl.css 113 B
build/block-library/blocks/categories/editor.css 112 B
build/block-library/blocks/categories/style-rtl.css 124 B
build/block-library/blocks/categories/style.css 124 B
build/block-library/blocks/code/editor-rtl.css 53 B
build/block-library/blocks/code/editor.css 53 B
build/block-library/blocks/code/style-rtl.css 121 B
build/block-library/blocks/code/style.css 121 B
build/block-library/blocks/code/theme-rtl.css 124 B
build/block-library/blocks/code/theme.css 124 B
build/block-library/blocks/columns/editor-rtl.css 108 B
build/block-library/blocks/columns/editor.css 108 B
build/block-library/blocks/columns/style-rtl.css 421 B
build/block-library/blocks/columns/style.css 421 B
build/block-library/blocks/comment-author-avatar/editor-rtl.css 125 B
build/block-library/blocks/comment-author-avatar/editor.css 125 B
build/block-library/blocks/comment-content/style-rtl.css 92 B
build/block-library/blocks/comment-content/style.css 92 B
build/block-library/blocks/comment-template/style-rtl.css 199 B
build/block-library/blocks/comment-template/style.css 198 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/comments-title/editor-rtl.css 75 B
build/block-library/blocks/comments-title/editor.css 75 B
build/block-library/blocks/comments/editor-rtl.css 840 B
build/block-library/blocks/comments/editor.css 839 B
build/block-library/blocks/comments/style-rtl.css 637 B
build/block-library/blocks/comments/style.css 636 B
build/block-library/blocks/cover/editor-rtl.css 647 B
build/block-library/blocks/cover/editor.css 650 B
build/block-library/blocks/cover/style-rtl.css 1.7 kB
build/block-library/blocks/cover/style.css 1.69 kB
build/block-library/blocks/details/editor-rtl.css 65 B
build/block-library/blocks/details/editor.css 65 B
build/block-library/blocks/details/style-rtl.css 98 B
build/block-library/blocks/details/style.css 98 B
build/block-library/blocks/embed/editor-rtl.css 293 B
build/block-library/blocks/embed/editor.css 293 B
build/block-library/blocks/embed/style-rtl.css 410 B
build/block-library/blocks/embed/style.css 410 B
build/block-library/blocks/embed/theme-rtl.css 138 B
build/block-library/blocks/embed/theme.css 138 B
build/block-library/blocks/file/editor-rtl.css 316 B
build/block-library/blocks/file/editor.css 316 B
build/block-library/blocks/file/style-rtl.css 280 B
build/block-library/blocks/file/style.css 281 B
build/block-library/blocks/file/view.min.js 320 B
build/block-library/blocks/footnotes/style-rtl.css 201 B
build/block-library/blocks/footnotes/style.css 199 B
build/block-library/blocks/form-input/editor-rtl.css 229 B
build/block-library/blocks/form-input/editor.css 228 B
build/block-library/blocks/form-input/style-rtl.css 343 B
build/block-library/blocks/form-input/style.css 343 B
build/block-library/blocks/form-submission-notification/editor-rtl.css 343 B
build/block-library/blocks/form-submission-notification/editor.css 342 B
build/block-library/blocks/form-submit-button/style-rtl.css 69 B
build/block-library/blocks/form-submit-button/style.css 69 B
build/block-library/blocks/form/view.min.js 452 B
build/block-library/blocks/freeform/editor-rtl.css 2.61 kB
build/block-library/blocks/freeform/editor.css 2.61 kB
build/block-library/blocks/gallery/editor-rtl.css 957 B
build/block-library/blocks/gallery/editor.css 962 B
build/block-library/blocks/gallery/style-rtl.css 1.55 kB
build/block-library/blocks/gallery/style.css 1.55 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 654 B
build/block-library/blocks/group/editor.css 654 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 189 B
build/block-library/blocks/heading/style.css 189 B
build/block-library/blocks/html/editor-rtl.css 340 B
build/block-library/blocks/html/editor.css 341 B
build/block-library/blocks/image/editor-rtl.css 834 B
build/block-library/blocks/image/editor.css 833 B
build/block-library/blocks/image/style-rtl.css 1.61 kB
build/block-library/blocks/image/style.css 1.6 kB
build/block-library/blocks/image/theme-rtl.css 137 B
build/block-library/blocks/image/theme.css 137 B
build/block-library/blocks/image/view.min.js 2.05 kB
build/block-library/blocks/latest-comments/style-rtl.css 357 B
build/block-library/blocks/latest-comments/style.css 357 B
build/block-library/blocks/latest-posts/editor-rtl.css 213 B
build/block-library/blocks/latest-posts/editor.css 212 B
build/block-library/blocks/latest-posts/style-rtl.css 478 B
build/block-library/blocks/latest-posts/style.css 478 B
build/block-library/blocks/list/style-rtl.css 88 B
build/block-library/blocks/list/style.css 88 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 505 B
build/block-library/blocks/media-text/style.css 503 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 671 B
build/block-library/blocks/navigation-link/editor.css 672 B
build/block-library/blocks/navigation-link/style-rtl.css 103 B
build/block-library/blocks/navigation-link/style.css 103 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/editor-rtl.css 2.26 kB
build/block-library/blocks/navigation/editor.css 2.26 kB
build/block-library/blocks/navigation/style-rtl.css 2.27 kB
build/block-library/blocks/navigation/style.css 2.26 kB
build/block-library/blocks/navigation/view.min.js 1.07 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 401 B
build/block-library/blocks/page-list/editor.css 401 B
build/block-library/blocks/page-list/style-rtl.css 175 B
build/block-library/blocks/page-list/style.css 175 B
build/block-library/blocks/paragraph/editor-rtl.css 235 B
build/block-library/blocks/paragraph/editor.css 235 B
build/block-library/blocks/paragraph/style-rtl.css 335 B
build/block-library/blocks/paragraph/style.css 335 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/editor-rtl.css 96 B
build/block-library/blocks/post-comments-form/editor.css 96 B
build/block-library/blocks/post-comments-form/style-rtl.css 508 B
build/block-library/blocks/post-comments-form/style.css 508 B
build/block-library/blocks/post-date/style-rtl.css 61 B
build/block-library/blocks/post-date/style.css 61 B
build/block-library/blocks/post-excerpt/editor-rtl.css 71 B
build/block-library/blocks/post-excerpt/editor.css 71 B
build/block-library/blocks/post-excerpt/style-rtl.css 141 B
build/block-library/blocks/post-excerpt/style.css 141 B
build/block-library/blocks/post-featured-image/editor-rtl.css 666 B
build/block-library/blocks/post-featured-image/editor.css 662 B
build/block-library/blocks/post-featured-image/style-rtl.css 345 B
build/block-library/blocks/post-featured-image/style.css 345 B
build/block-library/blocks/post-navigation-link/style-rtl.css 215 B
build/block-library/blocks/post-navigation-link/style.css 214 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 409 B
build/block-library/blocks/post-template/style.css 408 B
build/block-library/blocks/post-terms/style-rtl.css 96 B
build/block-library/blocks/post-terms/style.css 96 B
build/block-library/blocks/post-time-to-read/style-rtl.css 69 B
build/block-library/blocks/post-time-to-read/style.css 69 B
build/block-library/blocks/post-title/style-rtl.css 100 B
build/block-library/blocks/post-title/style.css 100 B
build/block-library/blocks/preformatted/style-rtl.css 125 B
build/block-library/blocks/preformatted/style.css 125 B
build/block-library/blocks/pullquote/editor-rtl.css 135 B
build/block-library/blocks/pullquote/editor.css 135 B
build/block-library/blocks/pullquote/style-rtl.css 335 B
build/block-library/blocks/pullquote/style.css 335 B
build/block-library/blocks/pullquote/theme-rtl.css 168 B
build/block-library/blocks/pullquote/theme.css 168 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 288 B
build/block-library/blocks/query-pagination/style.css 284 B
build/block-library/blocks/query-title/style-rtl.css 63 B
build/block-library/blocks/query-title/style.css 63 B
build/block-library/blocks/query/editor-rtl.css 486 B
build/block-library/blocks/query/editor.css 486 B
build/block-library/blocks/query/style-rtl.css 312 B
build/block-library/blocks/query/style.css 308 B
build/block-library/blocks/query/view.min.js 637 B
build/block-library/blocks/quote/style-rtl.css 237 B
build/block-library/blocks/quote/style.css 237 B
build/block-library/blocks/quote/theme-rtl.css 223 B
build/block-library/blocks/quote/theme.css 226 B
build/block-library/blocks/read-more/style-rtl.css 140 B
build/block-library/blocks/read-more/style.css 140 B
build/block-library/blocks/rss/editor-rtl.css 149 B
build/block-library/blocks/rss/editor.css 149 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 184 B
build/block-library/blocks/search/editor.css 184 B
build/block-library/blocks/search/style-rtl.css 613 B
build/block-library/blocks/search/style.css 613 B
build/block-library/blocks/search/theme-rtl.css 114 B
build/block-library/blocks/search/theme.css 114 B
build/block-library/blocks/search/view.min.js 471 B
build/block-library/blocks/separator/editor-rtl.css 146 B
build/block-library/blocks/separator/editor.css 146 B
build/block-library/blocks/separator/style-rtl.css 234 B
build/block-library/blocks/separator/style.css 234 B
build/block-library/blocks/separator/theme-rtl.css 194 B
build/block-library/blocks/separator/theme.css 194 B
build/block-library/blocks/shortcode/editor-rtl.css 329 B
build/block-library/blocks/shortcode/editor.css 329 B
build/block-library/blocks/site-logo/editor-rtl.css 760 B
build/block-library/blocks/site-logo/editor.css 760 B
build/block-library/blocks/site-logo/style-rtl.css 204 B
build/block-library/blocks/site-logo/style.css 204 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 116 B
build/block-library/blocks/site-title/editor.css 116 B
build/block-library/blocks/site-title/style-rtl.css 57 B
build/block-library/blocks/site-title/style.css 57 B
build/block-library/blocks/social-link/editor-rtl.css 184 B
build/block-library/blocks/social-link/editor.css 184 B
build/block-library/blocks/social-links/editor-rtl.css 682 B
build/block-library/blocks/social-links/editor.css 681 B
build/block-library/blocks/social-links/style-rtl.css 1.45 kB
build/block-library/blocks/social-links/style.css 1.45 kB
build/block-library/blocks/spacer/editor-rtl.css 359 B
build/block-library/blocks/spacer/editor.css 359 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 432 B
build/block-library/blocks/table/editor.css 432 B
build/block-library/blocks/table/style-rtl.css 646 B
build/block-library/blocks/table/style.css 645 B
build/block-library/blocks/table/theme-rtl.css 157 B
build/block-library/blocks/table/theme.css 157 B
build/block-library/blocks/tag-cloud/style-rtl.css 251 B
build/block-library/blocks/tag-cloud/style.css 253 B
build/block-library/blocks/template-part/editor-rtl.css 403 B
build/block-library/blocks/template-part/editor.css 403 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/style-rtl.css 111 B
build/block-library/blocks/term-description/style.css 111 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 99 B
build/block-library/blocks/verse/style.css 99 B
build/block-library/blocks/video/editor-rtl.css 552 B
build/block-library/blocks/video/editor.css 555 B
build/block-library/blocks/video/style-rtl.css 191 B
build/block-library/blocks/video/style.css 191 B
build/block-library/blocks/video/theme-rtl.css 139 B
build/block-library/blocks/video/theme.css 139 B
build/block-library/classic-rtl.css 179 B
build/block-library/classic.css 179 B
build/block-library/common-rtl.css 1.11 kB
build/block-library/common.css 1.11 kB
build/block-library/editor-elements-rtl.css 75 B
build/block-library/editor-elements.css 75 B
build/block-library/editor-rtl.css 12.5 kB
build/block-library/editor.css 12.4 kB
build/block-library/elements-rtl.css 54 B
build/block-library/elements.css 54 B
build/block-library/reset-rtl.css 472 B
build/block-library/reset.css 472 B
build/block-library/style-rtl.css 14.5 kB
build/block-library/style.css 14.5 kB
build/block-library/theme-rtl.css 700 B
build/block-library/theme.css 705 B
build/block-serialization-default-parser/index.min.js 1.13 kB
build/block-serialization-spec-parser/index.min.js 2.87 kB
build/blocks/index.min.js 51.5 kB
build/commands/index.min.js 15.5 kB
build/commands/style-rtl.css 947 B
build/commands/style.css 942 B
build/components/index.min.js 256 kB
build/components/style-rtl.css 12 kB
build/components/style.css 12 kB
build/compose/index.min.js 12.7 kB
build/core-commands/index.min.js 2.72 kB
build/customize-widgets/index.min.js 12.1 kB
build/customize-widgets/style-rtl.css 1.43 kB
build/customize-widgets/style.css 1.43 kB
build/data-controls/index.min.js 651 B
build/data/index.min.js 8.87 kB
build/date/index.min.js 17.9 kB
build/deprecated/index.min.js 462 B
build/dom-ready/index.min.js 336 B
build/dom/index.min.js 4.68 kB
build/edit-post/classic-rtl.css 571 B
build/edit-post/classic.css 571 B
build/edit-widgets/index.min.js 17.2 kB
build/edit-widgets/style-rtl.css 4.65 kB
build/edit-widgets/style.css 4.65 kB
build/element/index.min.js 4.87 kB
build/escape-html/index.min.js 548 B
build/format-library/index.min.js 7.76 kB
build/format-library/style-rtl.css 577 B
build/format-library/style.css 577 B
build/hooks/index.min.js 1.57 kB
build/html-entities/index.min.js 454 B
build/i18n/index.min.js 3.61 kB
build/interactivity/index.min.js 11.4 kB
build/is-shallow-equal/index.min.js 535 B
build/keyboard-shortcuts/index.min.js 1.76 kB
build/keycodes/index.min.js 1.9 kB
build/list-reusable-blocks/index.min.js 2.11 kB
build/list-reusable-blocks/style-rtl.css 865 B
build/list-reusable-blocks/style.css 865 B
build/media-utils/index.min.js 2.92 kB
build/notices/index.min.js 964 B
build/nux/index.min.js 2.01 kB
build/nux/style-rtl.css 775 B
build/nux/style.css 771 B
build/patterns/style-rtl.css 567 B
build/patterns/style.css 566 B
build/plugins/index.min.js 1.81 kB
build/preferences-persistence/index.min.js 1.85 kB
build/preferences/index.min.js 1.26 kB
build/primitives/index.min.js 994 B
build/priority-queue/index.min.js 1.52 kB
build/private-apis/index.min.js 988 B
build/react-i18n/index.min.js 631 B
build/react-refresh-entry/index.min.js 9.46 kB
build/react-refresh-runtime/index.min.js 6.78 kB
build/redux-routine/index.min.js 2.71 kB
build/reusable-blocks/style-rtl.css 265 B
build/reusable-blocks/style.css 265 B
build/rich-text/index.min.js 9.96 kB
build/router/index.min.js 1.79 kB
build/server-side-render/index.min.js 1.96 kB
build/shortcode/index.min.js 1.4 kB
build/style-engine/index.min.js 1.98 kB
build/token-list/index.min.js 587 B
build/url/index.min.js 3.83 kB
build/vendors/inert-polyfill.min.js 2.48 kB
build/vendors/react-dom.min.js 41.8 kB
build/vendors/react.min.js 4.02 kB
build/viewport/index.min.js 967 B
build/warning/index.min.js 259 B
build/widgets/index.min.js 7.18 kB
build/widgets/style-rtl.css 1.18 kB
build/widgets/style.css 1.18 kB
build/wordcount/index.min.js 1.03 kB

compressed-size-action

@youknowriad
Copy link
Contributor

I didn't check the code or anything, just reading through the documentation of the PR. The thing I'm wondering is:

  • A section attribute adds a classname.
  • A style variation for block adds a classname.
  • A section corresponds to the "style" part of theme.json.
  • A style variation is also style provided using CSS.

I guess what I'm saying is that a "section" is very close to a "style variation" that is shared across blocks maybe. So I wonder if we should introduce a new concept/attribute... or find a way to have a new type of style variation. I'm not totally convinced yet but curious if you thought about this.

Curious about thoughts from others @oandregal @mtias @mcsf

@richtabor
Copy link
Member

Themes would define section styles in theme.json, as well as within corresponding style variations.

So each variation would have different section styles, just like each variation can have different colors, gradients and duotones.

@aaronrobertshaw
Copy link
Contributor Author

Thanks for questions and discussion @youknowriad and @richtabor

I guess what I'm saying is that a "section" is very close to a "style variation" that is shared across blocks maybe. So I wonder if we should introduce a new concept/attribute

I did consider the potential overlap in concepts here. As Rich noted, the idea was that these section styles could be overridden by theme style variations, making them distinct in that regard.

Another approach I looked at was whether the individual block type style variations could accommodate these section styles by allowing the variation to define their own nested blocks definition. This seemed to fall short as well as we'd like to be able to define section styles that could be applied to multiple types of container blocks without having to repeatedly define the section style for each block type. It would also make it more difficult to apply fallback logic when switching themes and there is different numbers of section styles.

In addition, I had a discussion with @SaxonF, @tellthemachines, and @andrewserong about where in the theme.json a new sections config should live e.g. settings vs styles vs split between the two. We settled on styles as other than a slug or label property, each section is effectively just styling data. Splitting the config between settings and styles quickly became awkward for theme authors.

I hope that provides some extra clarity.

Nothing is set in stone yet so any further questions or ideas are more than welcome! It would be great if we can finalize a direction on this soon though to ensure we can deliver an MVP for WP 6.5.

@oandregal
Copy link
Member

oandregal commented Nov 20, 2023

👋 Read the original issue to understand the why and this is what I see:

  • We want to have "chunks of styles" that can be shared and applied to several areas, without having to copy&paste or repeat the same styles over and over. Ex: apply a "hero" look&feel across many pages of the same site. I see how this is useful.
  • We want to fix the theme-switching by providing sets: most people would not select a specific color, but a set (hero, light, dark, etc.). Is this correct? Unless we plan to have a set of sections (e.g. hero, dark, light) that themes cannot modify, I don't see how this would work. I'd appreciate a concrete example.

@fabiankaegy
Copy link
Member

We want to fix the theme-switching by providing sets: most people would not select a specific color, but a set (hero, light, dark, etc.). Is this correct? Unless we plan to have a set of sections (e.g. hero, dark, light) that themes cannot modify, I don't see how this would work. I'd appreciate a concrete example.

I can see how retaining section assignments when switching themes may be a nice, theoretically desirable goal. But in reality, I also don't see how it could / should work in practice. Limiting the available types of sections one could defined would be severely limiting and make this feature useless for anyone trying to push the boundaries a bit.

And "randomly" picking a replacement section from another theme when switching also seems like a not ideal experience.

@oandregal
Copy link
Member

oandregal commented Nov 20, 2023

Took a look at the proposal and a bit of the code to understand the data flow. This is what I see:

  • A theme declares "sections" via its theme.json:
{
"styles": {
  "sections": {
    "default": {},
    "hero": { /* any valid style (color, border, etc) & elements (button, heading, etc) but not blocks */  },
    "dark": {},
    "light": {}
  }
}
  • These sections are not bounded to any block. All blocks that declare support for section in its block.json would have them all listed:
"supports": {
  "section": true
}
  • When the user selects a section for a given block, the block gets a classname. Same with patterns: they can provide the class names instead of all the styles.
<style>
/* Styles generated from theme.json */
.wp-section-brand { }
</style>

<!-- wp:group {"section":"hero" } -->
<div class="wp-block-group wp-section-hero"></div>

Does this sound about right?

If understood correctly, it looks very similar to block style variations. Note that I may miss some context, specially regarding how this helps theme switching. However, based on this comment, it seems the only reason block style variations are not a good fit is because they don't apply to multiple blocks at once. I also see that Justin has gotten far by just using block style variations.

I wonder if we can review that experiment and streamline the developer experience of block style variations by:

  1. Allow declaring a block style variation for a few blocks at once: register_block_style( [ group, columns ], style_properties).
  2. Allow declaring a block style variation from theme.json. Related: #49602
  3. Make a block style variations essentially a theme.json-like object (can provide different presets than the default, in addition to styles, can target elements, we could consider even targeting blocks as well though I'd leave this as a follow-up). Related: #33232

@youknowriad
Copy link
Contributor

I'm in complete agreement with @oandregal here. Also, maybe we don't need to support multiple blocks but just "any block register_block_style( '*', style_properties)

@richtabor
Copy link
Member

{
"styles": {
"sections": {
"default": {},
"hero": { /* any valid style (color, border, etc) & elements (button, heading, etc) but not blocks */ },
"dark": {},
"light": {}
}
}

I feel pretty strongly that we should not define these via slug values. Otherwise, we're back to square one with trying to come up with an unofficial standard of naming slugs, to have a higher level of interoperability across themes.

I want to assign multiple section color sets to patterns in the pattern library—then each theme chooses their own color combinations (if any, and however many).

@aaronrobertshaw
Copy link
Contributor Author

aaronrobertshaw commented Nov 21, 2023

Thank you everyone for sanity checks, questions, and suggestions. My apologies in advance for this wall-of-text reply 🙏

I get the impression there is some confusion of Theme Style Variations vs Block Style Variations in some of the earlier discussion. At least there is for me reading it 🙂

Do you happen to have a link to where this conversation happened? Would love to follow the trail to better understand the constraints that you have already thought through :)

@fabiankaegy, unfortunately, I don’t have something I can link to for this but I can give more of a historical summary if necessary. The conversation currently happening here on this PR, looks like it will cover it all anyway.

I'm still not sure I follow to be honest. It looks like you're saying you want to apply a "section" and a "style variation". This feels very confusing to me as a user.

@youknowriad, this is what I was saying. The idea was that you might activate a theme, then on a page you might apply different section styles such as hero, light, dark etc. Then you might select a different Style Variation. That new theme style variation (not block style variation) could have its own definition for the section styles so the example hero, light, and dark sections now appear different.

The ability to create presets for each high-level category of design token in theme.json and then combine them as a section style would help make this more scalable:

@cbirdsong I like this approach and it would align with being able to configure each high-level category of design token via a drill down or something. I’d avoided this initially to focus on getting a workable proof of concept as I’m wary about scope for WP 6.5. That said, I also appreciate we don’t want to go too far down any path that may box us into a corner.

We want to fix the theme-switching by providing sets: most people would not select a specific color, but a set (hero, light, dark, etc.). Is this correct?

@oandregal Yes (also thanks for diving deeper and the proposals here)

Unless we plan to have a set of sections (e.g. hero, dark, light) that themes cannot modify, I don't see how this would work. I'd appreciate a concrete example.

And "randomly" picking a replacement section from another theme when switching also seems like a not ideal experience.

The current direction was led primarily by the color sets concept.

Take a theme with 3 section styles defined. These section styles would be applied via their index e.g. .wp-section-0, .wp-section-1, and .wp-section-2. If the theme was switched to a theme with only 2 section styles, the first two sections would map directly. Any sections with the final style set applied would fall back to the previous set, so in this example .wp-section-1 being the last available set.

This may work for colors, but I agree 100% that when expanded beyond that things fall apart. It has also been floated that in that fallback logic we could look for matching slugs first before falling back numerically. Personally, I struggle to see this working cleanly in all situations but my understanding was this is pretty important to the idea of colour sets.

I believe @richtabor and @SaxonF can speak more on this and offer a better example as to how the non-slug-based application of section styles helps facilitate potential use cases.

Another possiblity is that we could scope the section class to a given theme as well, e.g. .wp-section-twentytwentyfour-1. We can omit that class if the theme doesn't match anymore.

This limitation would allow switching between a theme’s style variations to update sections but not when entirely switching themes. If applying that constraint, we could do away with the index fallback and simply use a slug. Which if changing the sections config to an object would be re-using the section's key as the slug.

A theme declares "sections" via its theme.json:

Correct although, sections was an array to reflect the "order" of sections. The default option is just not having a section style applied rather than something that is configured.

These sections are not bounded to any block. All blocks that declare support for section in its block.json would have them all listed:

Correct, these are not bound to any block type. It was intended however that this section support be limited to an allowed list of blocks. To start with perhaps only Group, Columns, Column etc. (The code doesn’t enforce this fully yet though).

  • When the user selects a section for a given block, the block gets a classname. Same with patterns: they can provide the class names instead of all the styles.

Correct. The block with a section style applied gets a class name added to its wrapper. That classname currently though does not use the section’s slug but an index for the, admittedly flawed, fallback side of things when switching themes.

If understood correctly, it looks very similar to block style variations.

Except that block style variations do not support child styles per block type.

I noted in an earlier comment, we could update block style variations to also support a nested blocks definition so they could define child styles for inner blocks per block type. The catch then was that section styles should be applicable across different block types.

Take the following scenario, where we wish to have a hero section. That section should define some tailored styles for the section’s container block, any inner Paragraph, Cover, Gallery, Media and Text blocks within it. It can also define element (or further block type styles) for buttons, headings etc. On some templates the hero section is a Group block, others it’s a Columns block or something. The same section styles should be able to be applied to each of those container blocks (Group/Columns).

We also still have the issue of combining block style variations with a section style, e.g. a dark background pattern that tweaks the outline button block style variation (assuming we also add theme.json supported configuration of block style variations)

However, based on this comment, it seems the only reason block style variations are not a good fit is because they don't apply to multiple blocks at once.

That was a primary reason, yes. A section style could also define tweaks to a block’s style variations so they make sense aesthetically within the section too.

I’m not sure overloading block style variations helps keep things simpler than a new sections concept within theme.json

Could keeping section styles separate also make them more portable? Such as being provided along with patterns etc.?

@fabiankaegy
Copy link
Member

{

"styles": {

"sections": {

"default": {},

"hero": { /* any valid style (color, border, etc) & elements (button, heading, etc) but not blocks */  },

"dark": {},

"light": {}

}

}

I feel pretty strongly that we should not define these via slug values. Otherwise, we're back to square one with trying to come up with an unofficial standard of naming slugs, to have a higher level of interoperability across themes.

I want to assign multiple section color sets to patterns in the pattern library—then each theme chooses their own color combinations (if any, and however many).

@richtabor I'm not sure I fully understand how you would want to reference different section color sets in a pattern though.

I thought the entire point of the sections is to still use the same color names but swap out the value of them. So in your pattern you would say that the background uses the primary color and the text uses the contrast color.

Depending on what section this pattern is then placed in it looks drastically differently.

I understand your aspiration of not dealing with random user generated slugs all over the place. But I similarly feel that nameless color sets are going to be very confusing to use.

All the examples here so far refer to sections as "Hero", "Light", "Dark" etc.

It's like we give names to style variations of themes. Because the name gives meaning to what the section is trying to represent.

Do you have any ideas / examples for how you think this could / should work in the UI for nameless sections?

I know you've played a lot with this idea and am really curious about how you think this could be solved. Your exploration here https://x.com/richard_tabor/status/1719685837552832979?s=46 seems really interesting though it looks like it also relies on names to indicate meaning 🤔

@tellthemachines
Copy link
Contributor

I wonder if we can review that experiment and streamline the developer experience of block style variations by:

  1. Allow declaring a block style variation for a few blocks at once: register_block_style( [ group, columns ], style_properties).
  2. Allow declaring a block style variation from theme.json. Related: #49602
  3. Make a block style variations essentially a theme.json-like object (can provide different presets than the default, in addition to styles, can target elements, we could consider even targeting blocks as well though I'd leave this as a follow-up). Related: #33232

Independently of whether or not we use block style variations for sections, all of these would be good additions!

My main devex concern about sections being block style variations is currently having to define them as PHP functions, which splits styling logic between several different places.

There's also the question of how the UI would work: would the existing style variations buttons in the block sidebar be used to show the section styles? That might become confusing if we consider

Also, maybe we don't need to support multiple blocks but just "any block register_block_style( '*', style_properties)

Would every single block now have those section buttons in its sidebar in addition to any other block style variations it may have?

(As a side note: it would be convenient to be able to apply section styles to any block at all, otherwise folks using custom blocks won't be able to benefit from this feature)

My other thought if we did go this route is that we'll probably have to build in the ability to target blocks inside sections from the start, otherwise competing specificity of existing block styles will make section styling a frustrating experience. For it to work well, I suspect targeting blocks is a must.

@aaronrobertshaw
Copy link
Contributor Author

aaronrobertshaw commented Nov 21, 2023

(As a side note: it would be convenient to be able to apply section styles to any block at all, otherwise folks using custom blocks won't be able to benefit from this feature)

Agreed, a catch here was specificity issues when a block type style applies styles to a selector more specific than a single CSS class e.g. .wp-section-1 vs .wp-block-image img (for borders). It part of why the intention was to limit the blocks allowed to support this initially to Group blocks and possibly Column/s blocks.

My other thought if we did go this route is that we'll probably have to build in the ability to target blocks inside sections from the start

This PR currently supports block type styles within sections.

Some random `sections` config for the theme.json as an example
{
  "styles": {
    "sections": [
      {
        "title": "Hero",
        "slug": "hero",
        "color": {
          "background": "#034078",
          "text": "var(--wp--preset--color--base)"
        },
        "blocks": {
          "core/heading": {
            "typography": {
              "fontSize": "90px"
            }
          },
          "core/paragraph": {
            "typography": {
              "fontSize": "24px"
            }
          },
          "core/button": {
            "color": {
              "background": "#1282a2",
              "text": "var(--wp--preset--color--base)"
            }
          }
        }
      },
      {
        "title": "Dark",
        "slug": "dark",
        "color": {
          "background": "#0A1128",
          "text": "var(--wp--preset--color--base)"
        },
        "typography": {
          "fontSize": "var(--wp--preset--font-size--small)",
          "fontStyle": "normal",
          "fontWeight": "600"
        },
        "blocks": {
          "core/button": {
            "color": {
              "background": "#1282a2",
              "text": "var(--wp--preset--color--base)"
            }
          }
        }
      },
      {
        "title": "Light",
        "slug": "light",
        "color": {
          "background": "#F8F8F8",
          "text": "#0A1128"
        },
        "elements": {
          "heading": {
            "color": {
              "text": "#034078"
            }
          },
          "h5": {
            "color": {
              "text": "#1282a2"
            }
          }
        }
      }
    ]
  }
}

@tellthemachines
Copy link
Contributor

This PR currently supports block type styles within sections.

Yes, and that's an argument in favour of this implementation! I meant to argue that any solution using block style variations would be incomplete if it didn't support that.

@aaronrobertshaw
Copy link
Contributor Author

To move this feature forward, I'll be putting together an alternative proof of concept that extends block style variations as proposed by @oandregal with the suggestions offered by @youknowriad.

Some guidelines for the new proof of concept include:

  • The CSS that extended block style variations can generate shouldn't be limited beyond what's possible via theme.json
  • There should be no restrictions on which block types can apply extended block style variations
  • It may not make sense for all block style variations to be available as a “section style"
  • There are a few gaps, or enhancements, that need to be addressed for block style variations
    • The register block style function will need to accept a style object
    • Block style registration will also need to accept an array of block types it is eligible for (or wildcard to make global)
    • Later on, the theme.json can be updated to allow the definition of block style variations there as well
    • Block style variations need to support nested blocks and elements definitions
    • It’s not clear if being able to redefine nested block style variations is something that should be catered for, so it will be pushed to a future exploration
  • By extending block style variations there will be no change in the UI required
  • The requested ability to make section styles fall back when switching themes will be considered a separate problem
    • This means it is possible that a different solution for element color sets will be needed
  • A future extension to block style variations is to allow “block setting variations” also.
    • For now, however, this is out of scope.

@richtabor
Copy link
Member

@richtabor I'm not sure I fully understand how you would want to reference different section color sets in a pattern though.

I thought the entire point of the sections is to still use the same color names but swap out the value of them. So in your pattern you would say that the background uses the primary color and the text uses the contrast color.

Depending on what section this pattern is then placed in it looks drastically differently.

I understand your aspiration of not dealing with random user generated slugs all over the place. But I similarly feel that nameless color sets are going to be very confusing to use.

I'm not concerned with swapping out values of colors, but to assign different color names to elements. Say use 'theme-3' color as the background color, and 'theme-1' as the text color in one section. And the inverse in another.

The theme picks that set of colors for that applied section style, not the block.

I'm concerned that if we don't have a way to auto-generate, we'll end up with the same scenario we face with theme colors. That you can't assume color slugs across variations and whole themes. I like how spacing values work, where they are mainly generated by WordPress, and the theme provides its values for each. This way spacing 20 is nearly always the second largest spacing value.

If theme A uses "dark" and theme B uses "darker" then those won't map. It's a long shot, but would be nice to not have to worry about interoperability.

@oandregal
Copy link
Member

Thanks for the follow-up, @aaronrobertshaw I see how sections may seem to be theme switch friendly if we ask theme to use a closed set of slugs such as 0, 1, 2, etc. (a number is still a slug). I'd like to provide an example of how it could break:

Captura de ecrã 2023-11-23, às 18 54 55

Let's use the above pattern. I created a codepen to illustrate as well, if that helps. By using sections we are able to only serialize the class wp-section-0 and not the whole lot of styles in the HTML of the pattern:

<style>
/* WHO PROVIDES THESE STYLES? */
.wp-block-group {
  background-color: var(--wp-section-color-0);
  color: var(--wp-section-color-1);
}

.wp-block-group .wp-block-button {
  background-color: var(--wp-section-color-2);
}
</style>
<div class="wp-block-group wp-section-0">
  <h2>Visit us</h2>
  <p>Our address in Cool Place, 23 street.</p>
  <div class="wp-block-buttons">
    <div class="wp-block-button">
      <a class="wp-block-button__link">Get directions</a>
    </div>
  </div>
</div>

The theme X could provide the following CSS for section 0:

/* Section 0 from THEME X */
.wp-section-0 {
  --wp-section-color-0: black;
  --wp-section-color-1: white;
  --wp-section-color-2: purple;
}

Now, user switches themes and the new theme provides the following color set for section 0:

Captura de ecrã 2023-11-23, às 18 53 40
/*
 * Section 0 from THEME Y
 * that happens to use a black color palette.
 * https://www.color-hex.com/color-palette/45492
 */ 
.wp-section-0 {
  --wp-section-color-0: #000000;
  --wp-section-color-1: #111111;
  --wp-section-color-2: #1e1e1e;
  --wp-section-color-3: #3c3c3c;
  --wp-section-color-3: #4d4d4d;
}

Because the new theme uses a black-based palette, this is how the pattern looks like:

Captura de ecrã 2023-11-23, às 18 56 06

That's why I'm confused as to how sections help with theme switches.

For a pattern author, it's certainly easier to work with classes rather than individual styles. It seems that we want "Pattern Style Variations". However, patterns being just an abstraction for a set of blocks, I still see "Block Style Variations" as the way forward. Though we need the fixes mentioned in the thread: better devexp by declaring them via theme.json, allowing them to target child blocks, etc.

Note that I've not been involved in design tools for a long time, so I may miss tons of context. Please, do share as much as you think I'm missing!

@oandregal
Copy link
Member

In addition to "author devexp" when creating block style variations, there's also "user devexp" of current block style variations – when you compare them to style variations the difference is striking:

Block style variation switching Style variation switching
Captura de ecrã 2023-11-23, às 19 11 32 Captura de ecrã 2023-11-23, às 19 11 15

@aaronrobertshaw
Copy link
Contributor Author

Thanks for taking the time to expand on your thoughts @oandregal 👍

I'm currently in the process of trying to work through a block style variation approach to section styling, with some general guidelines mentioned in my earlier comment.

I'd like to provide an example of how it could break:

I still agree there are problems.

Let's use the above pattern. I created a codepen to illustrate as well, if that helps. By using sections we are able to only serialize the class wp-section-0 and not the whole lot of styles in the HTML of the pattern:

One thing to note here is the example pattern included the block styles in hardcoded CSS, whereas for the switchability to have any chance those would be defined within the sections themselves (hence noting block style variations must be extended to support block type styles). I understand also that existing patterns or content could have such hardcoded styles that make this all difficult as well.

My understanding of some of the assembler work going on was that the idea is to avoid most styling within patterns and rely on sections to provide the styling.

I've tweaked the codepen to hopefully illustrate this a little. Again, I'm not trying to advocate that this is bulletproof but instead provide a starting point to evolve from.

Screen.Recording.2023-11-24.at.10.21.53.am.mp4

In addition to "author devexp" when creating block style variations, there's also "user devexp" of current block style variations – when you compare them to style variations the difference is striking:

With the potential for several block style variations and the limited real estate in the block inspector, compared with the theme style variation screen in the site editor, we might need to have a threshold at which the block styles UI becomes something other than the collection of buttons it is now.

I'm not concerned with swapping out values of colors, but to assign different color names to elements. Say use 'theme-3' color as the background color, and 'theme-1' as the text color in one section. And the inverse in another.

The theme picks that set of colors for that applied section style, not the block.

This can work within a single theme. If we consider switching themes, then I don't think there's any guarantee the colors make sense still and it breaks as it does now.

@oandregal
Copy link
Member

I've tweaked the codepen to hopefully illustrate this a little. Again, I'm not trying to advocate that this is bulletproof but instead provide a starting point to evolve from.

Thanks for following up on that. The changes you've done to make the two sections 0 work with the same HTML illustrate my point: each section changed how the colors were mapped to the specific HTML elements. They had to include “structural CSS”, the CSS that maps elements to section colors. They are no longer a “generic” section 0 that can work across themes: it's a “section 0” designed for working with a specific pattern.

To be clear, I insist on this because I believe a safe “theme switch” or “pattern style variations” are two different problem spaces. It's best if we don't conflate the goals, and it's fine to only address one right now!

@oandregal
Copy link
Member

@fabiankaegy this is great feedback, thanks! The three examples you mentioned were in the initial theme.json/global styles roadmap, though they haven't been developed (yet?):

  • theme.json for templates & posts #27233 I'm glad you made this work with the existing filters :)
  • theme.json for template parts (same as above) #27233
  • theme.json for sections (dynamic content that cannot be "identified" at runtime such as patterns) #40318

And we also had

  • theme.json for style variations #33232

@oandregal
Copy link
Member

I've read through #48581 and #48581 as well as @richtabor comments (1, 2).

What if we scope "Element color sets" to "providing different color palettes to blocks"? I know this is not the intended goal of that issue (provide a safe "theme switch"). Though I hope I conveyed why/how I don't see that working, and I'd be more than happy to be proved wrong and seeing counter-examples!

Providing different palettes to blocks could work in different ways:

  1. Expose to blocks all the color palettes that have been declared via the style variation of the themes. In a way, this could be thought as "unbundling" theme style variations.

  2. Create a new settings.color.palettes in theme.json:

{
  "settings": {
    "color": {
      "palettes": {
        "light": [ { "color": "...", "name": "...", "slug": "..." }, { "...", "..." } ],
        "dark": [ { "color": "...", "name": "...", "slug": "..." }, { "...", "..." } ],
        "brand": [ { "color": "...", "name": "...", "slug": "..." }, { "...", "..." } ], 
      }
    }
  }
}

Each approach has its pros/cons. Probably there are more approaches. In principle, I'd think I'd start with 1, as it leverages what's available already. We'd also need to consider cross-cutting concerns: do we ship all colors defined by all palettes? It's a lot to ship to browsers. Etc.

Would this be useful to pattern authors?

I keep commenting on this PR, though it's no longer on topic! Happy to go elsewhere that's more relevant :)

@aaronrobertshaw
Copy link
Contributor Author

Appreciate the continued discussion on these issues @oandregal 🙏

As the potential solutions and issues here diverge, I'm conscious of trying to keep things manageable and break it down into deliverable chunks.

Currently, I'm still working on a proof of concept for extending block style variations as proposed previously. My focus will continue to be on that as more of a direct alternative to this PR. I will work on the Element Color Sets feature after that.

Thanks again for sharing your thoughts and wisdom on these possible features. 🙇

@aaronrobertshaw
Copy link
Contributor Author

Closing this PR given the agreement to go in a different direction.

@aaronrobertshaw
Copy link
Contributor Author

I've written up an issue to perhaps track and communicate the efforts in extending block style variations better. You can find it here: #56632.

If anyone has anything they'd like to add to it, don't be shy 🙂

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
Development

Successfully merging this pull request may close these issues.

7 participants