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

Styling blocks and elements inside template parts with theme.json #44126

Draft
wants to merge 2 commits into
base: trunk
Choose a base branch
from

Conversation

matiasbenedetto
Copy link
Contributor

@matiasbenedetto matiasbenedetto commented Sep 13, 2022

What?

Theme.json: adding capabilities to style blocks and elements at the scope level of a template part

⚠️ This is a draft, working, up to this moment, only server side. So the rendered styles are rendered correctly on the frontend (public version of the posts) but not on the editor.

Why?

To be able to style blocks or elements just for a particular template part and not for the entire site.

How?

Testing Instructions

Add some settings in order to style elements or block inside a template part.

Let's say you have 2 template parts defined in your theme.json file:

	"templateParts": [
        {
            "area": "header",
            "name": "header"
        },
        {
            "area": "footer",
            "name": "footer"
        }
    ]

Then you are able to define styles for the blocks or elements inside each of those template parts previously defined.

Examples:
You can add styles.templateParts.header.elements.link to style link elements inside the header template part.
You can add styles.templateParts.footer.blocks.core/site-title to style site-title block inside the footer template part.

"styles": {
    "templateParts": {
        "header": {
            "blocks": {
                "core/site-title": {
                    "color": {
                        "text": "lemonchiffon"
                    }
                },
                "core/site-tagline": {
                    "color": {
                        "text": "cyan"
                    }
                }
            },
            "elements": {
                "link": {
                    "color": {
                        "text": "yellow"
                    }
                }
            }
        },
        "footer": {
            "blocks": {
                "core/site-title": {
                    "color": {
                        "text": "red"
                    }
                }
            }
        }
    },
}

Fixes: #43347

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Experimental Experimental feature or API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow styling blocks inside template parts with theme.json
1 participant