Skip to content

Section Styles: Fix ref values within block style variations#6989

Closed
aaronrobertshaw wants to merge 2 commits intoWordPress:trunkfrom
aaronrobertshaw:fix/referenced-values-in-variations
Closed

Section Styles: Fix ref values within block style variations#6989
aaronrobertshaw wants to merge 2 commits intoWordPress:trunkfrom
aaronrobertshaw:fix/referenced-values-in-variations

Conversation

@aaronrobertshaw
Copy link
Copy Markdown

This PR backports the fix from:

This restores the ability to reference style values from elsewhere within theme.json for block style variations.

Trac ticket: https://core.trac.wordpress.org/ticket/61589#ticket

Test Instructions

  1. Add some ref values for block style variations to your theme.json e.g. update TT4 with the sections from the theme.json snippet below
  2. Load the site editor and edit the default home page
  3. Confirm that outline buttons are displayed and have the correct referenced style values
  4. Save and ensure the same on the frontend
Example theme.json snippet
{
    "styles": {
        "elements": {
            "button": {
                "border": {
                    "color": "transparent",
                    "radius": "0.25em",
                    "style": "solid",
                    "width": "1px"
                },
                "color": {
                    "background": "var(--wp--preset--color--accent)",
                    "text": "var(--wp--preset--color--base)"
                },
                "spacing": {
                    "padding": {
                        "bottom": "0.5em",
                        "left": "1.25em",
                        "right": "1.25em",
                        "top": "0.5em"
                    }
                }
            }
        },
        "blocks": {
            "core/button": {
                "border": {
                    "color": { "ref": "styles.elements.button.border.color" },
                    "radius": { "ref": "styles.elements.button.border.radius" },
                    "style": { "ref": "styles.elements.button.border.style" },
                    "width": { "ref": "styles.elements.button.border.width" }
                },
                "color": {
                    "background": { "ref": "styles.elements.button.color.background" },
                    "text": { "ref": "styles.elements.button.color.text" }
                },
                "spacing": {
                    "padding": {
                        "bottom": { "ref": "styles.elements.button.spacing.padding.bottom" },
                        "left": { "ref": "styles.elements.button.spacing.padding.left" },
                        "right": { "ref": "styles.elements.button.spacing.padding.right" },
                        "top": { "ref": "styles.elements.button.spacing.padding.top" }
                    }
                },
                "variations": {
                    "outline": {
                        "border": {
                            "color": "currentColor",
                            "width": { "ref": "styles.elements.button.border.width" }
                        },
                        "color": {
                            "text": { "ref": "styles.elements.button.color.background" }
                        },
                        "spacing": {
                            "padding": {
                                "bottom": { "ref": "styles.elements.button.spacing.padding.bottom" },
                                "left": { "ref": "styles.elements.button.spacing.padding.left" },
                                "right": { "ref": "styles.elements.button.spacing.padding.right" },
                                "top": { "ref": "styles.elements.button.spacing.padding.top" },
                            }
                        }
                    }
                }
            }
        }
    }
}

Screenshots or screencast

Before After
Screenshot 2024-07-05 at 6 21 01 PM Screenshot 2024-07-05 at 6 20 41 PM

This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

@aaronrobertshaw aaronrobertshaw self-assigned this Jul 8, 2024
@github-actions
Copy link
Copy Markdown

github-actions bot commented Jul 8, 2024

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • The Plugin and Theme Directories cannot be accessed within Playground.
  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

Copy link
Copy Markdown
Contributor

@andrewserong andrewserong left a comment

Choose a reason for hiding this comment

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

This is testing nicely for me, just as WordPress/gutenberg#63172 does on the site frontend. It'll need the JS packages update from that PR before it'll work in the site editor, but for the PHP changes this change looks good to land from my perspective!

Copy link
Copy Markdown
Member

@ramonjd ramonjd left a comment

Choose a reason for hiding this comment

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

I tested along the same lines as WordPress/gutenberg#63172

On the frontend, the values are being resolved from the theme.json tree as expected. 👍🏻

Screenshot 2024-07-09 at 5 13 37 PM

@github-actions
Copy link
Copy Markdown

github-actions bot commented Jul 9, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props aaronrobertshaw, andrewserong, ramonopoly.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@pento pento closed this in 5c45439 Jul 9, 2024
@ellatrix ellatrix reopened this Jul 9, 2024
github-actions bot pushed a commit to gilzow/wordpress-performance that referenced this pull request Jul 9, 2024
@pento pento closed this in 4a2c9c5 Jul 9, 2024
Debarghya-Banerjee pushed a commit to Debarghya-Banerjee/wordpress-develop that referenced this pull request Jul 18, 2024
This is fixed by preloading the styles.

Fixes #61589.
Fixes WordPress#6989.
See WordPress/gutenberg#63172.

Props aaronrobertshaw, andrewserong, ramonopoly.



git-svn-id: https://develop.svn.wordpress.org/trunk@58690 602fd350-edb4-49c9-b593-d223f7449a82
Debarghya-Banerjee pushed a commit to Debarghya-Banerjee/wordpress-develop that referenced this pull request Jul 18, 2024
aslamdoctor pushed a commit to aslamdoctor/wordpress-develop that referenced this pull request Dec 28, 2024
This is fixed by preloading the styles.

Fixes #61589.
Fixes WordPress#6989.
See WordPress/gutenberg#63172.

Props aaronrobertshaw, andrewserong, ramonopoly.



git-svn-id: https://develop.svn.wordpress.org/trunk@58690 602fd350-edb4-49c9-b593-d223f7449a82
aslamdoctor pushed a commit to aslamdoctor/wordpress-develop that referenced this pull request Dec 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

No open projects
Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

4 participants