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

Styles for different templates #51384

Open
audunmb opened this issue Jun 9, 2023 · 0 comments
Open

Styles for different templates #51384

audunmb opened this issue Jun 9, 2023 · 0 comments
Labels
Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json [Type] Enhancement A suggestion for improvement.

Comments

@audunmb
Copy link

audunmb commented Jun 9, 2023

What problem does this address?

My use case is that I want H2 to look different on posts and pages. With a style.css-file and classic theme editing this a very simple thing to do. But there's no option to do this with a theme.json-file. I can style blocks, add block styles and block variations, but I can't connect the styles to specific templates. I tried to search trough all documentation and open issues, and I couldn't find a solution nor this exact issue. #44997 is the closest one, but it's for the editor, not theme.json.

While my case is quite simple (h2 only), there's tons of different use cases, like for custom post types and different kinds of page templates (FAQ, landing page, etc). Post titles may look different, you may want different content widths for different templates, etc.

This should be handled by at theme level IMO, so it should be in theme.json.

What is your proposed solution?

Same markup as the one proposed in #44126 , but with Templates, not only template parts. So:

"styles": {
    "template": {
        "page": {
            "elements": {
			"h2": {
				"typography": {
					"fontSize": "var(--wp--preset--font-size--x-large)",
					"fontWeight": "800"
			}            
                }
            }
        },
        "single": {
            "elements": {
			"h2": {
				"typography": {
					"fontSize": "var(--wp--preset--font-size--large)",
					"fontWeight": "600"
			}            
                }
            }
        }
}

@ndiego ndiego added [Type] Enhancement A suggestion for improvement. Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json labels Jun 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

No branches or pull requests

2 participants