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 ref to groups of settings in theme.json. #56104

Open
jdamner opened this issue Nov 14, 2023 · 0 comments
Open

Allow ref to groups of settings in theme.json. #56104

jdamner opened this issue Nov 14, 2023 · 0 comments
Labels
[Feature] Themes Questions or issues with incorporating or styling blocks in a theme. [Type] Enhancement A suggestion for improvement.

Comments

@jdamner
Copy link

jdamner commented Nov 14, 2023

What problem does this address?

At the moment, you can only ref to another single value in theme.json, but quite often you might want different elements/blocks to share the same settings. For example, the core/post-title block you may wish to have the same settings as the core/heading block so that the post-title inherits any settings for heading such as typography and font-sizes.

Another example where this would make perfect sense would be the core/query-pagination-next and core/query-pagination-previous - typically I'd expect most themes to want these two blocks to share the same settings/styles and at the moment duplication is required in order to achieve this.

What is your proposed solution?

To enable ref to refer to a whole section of settings in theme.json. Effectively have the following example work as you'd expect.

{
  "$schema": "https://schemas.wp.org/wp/6.4/theme.json",
  "description": "Example of group-based refs",
  "settings": {
    "blocks": {
      "core/heading": {
        "typography": {
          "fontSizes": [
            {
              "fluid": false,
              "name": "Small",
              "size": "1.3215rem",
              "slug": "small"
            },
            {
              "fluid": {
                "max": "1.75rem",
                "min": "1.5rem"
              },
              "name": "Default",
              "size": "1.7rem",
              "slug": "default"
            },
            {
              "fluid": {
                "max": "2.625rem",
                "min": "1.75rem"
              },
              "name": "Large",
              "size": "2.25rem",
              "slug": "large"
            }
          ]
        }
      },
      "core/post-title": {
        "ref": "settings.blocks.core/heading"
      }
    }
  },
  "styles": {
    "blocks":{
      "core/query-pagination-next": {
        "color": { 
          "text": "red",
          "background": "blue"
         },
         "spacing": {
          "padding": {
            "top": "1rem",
            "bottom": "1rem"
          }
         }
      },
      "core/query-pagination-previous": {
        "ref": "styles.blocks.core/query-pagination-next"
      }
    }
  }
}

In this instance, I would expect the core/heading and core/post-title should inherit the same settings, and the core/query-pagination-next and core/query-pagination-previous should share the same styles.

@jdamner jdamner added the [Type] Enhancement A suggestion for improvement. label Nov 14, 2023
@t-hamano t-hamano added the [Feature] Themes Questions or issues with incorporating or styling blocks in a theme. label Nov 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Themes Questions or issues with incorporating or styling blocks in a theme. [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

No branches or pull requests

2 participants