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

Background: add background attachment support to theme.json styles #6991

Closed

Conversation

ramonjd
Copy link
Member

@ramonjd ramonjd commented Jul 8, 2024

Syncing changes from WordPress/gutenberg#61382

Note

This PR should be committed after #6836 to ensure a clean rebase 😄

Testing

Unit tests:

npm run test:php -- --filter Tests_Theme_wpThemeJson && npm run test:php -- --filter Tests_Block_Supports_WpRenderBackgroundSupport && npm run test:php -- --filter Tests_wpStyleEngine

This PR adds the backend functionality only, which means the editor UI isn't yet available.

To test, define a background image for the site in theme.json.

Here's an example using an image in src/wp-content/themes/twentytwentyfour/

{
	"$schema": "../../schemas/json/theme.json",
	"version": 3,
	"settings": {
		"appearanceTools": true
	},
	"styles": {
		"background": {
				"backgroundImage": {
					"url": "file:./assets/images/art-gallery.webp"
				},
				"backgroundAttachment": "fixed"
		},
		"blocks": {
			"core/verse": {
				"background": {
					"backgroundImage": {
						"url": "file:./assets/images/abstract-geometric-art.webp"
					}
				}
			}
        }
   	}
}

Now check the site:

2024-07-22.14.26.52.mp4

Trac ticket: https://core.trac.wordpress.org/ticket/61720


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.

Copy link

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.

@ramonjd ramonjd force-pushed the add/theme-json-background-attachment branch from e5721aa to e9071bf Compare July 22, 2024 04:06
@ramonjd ramonjd self-assigned this Jul 22, 2024
@ramonjd ramonjd marked this pull request as ready for review July 22, 2024 04:32
Copy link

github-actions bot commented Jul 22, 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 ramonopoly, mukesh27, andrewserong, noisysocks.

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

@@ -237,6 +237,7 @@ class WP_Theme_JSON {
'background-position' => array( 'background', 'backgroundPosition' ),
'background-repeat' => array( 'background', 'backgroundRepeat' ),
'background-size' => array( 'background', 'backgroundSize' ),
'background-attachment' => array( 'background', 'backgroundAttachment' ),
Copy link
Member

Choose a reason for hiding this comment

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

Add the property in docblock with @since

Copy link
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 code change looks good to me and is testing nicely in the site frontend 👍

For anyone else reviewing, some of the PHP changes in block-supports/background.php also include changes from #6836, as mentioned in the PR description, so it looks like that PR should land first. Factoring in #6836, the changes here match the expected changes from WordPress/gutenberg#61382 👍

LGTM!

@ramonjd ramonjd force-pushed the add/theme-json-background-attachment branch from 1ab0c30 to 1ea4884 Compare July 24, 2024 05:48
@ramonjd
Copy link
Member Author

ramonjd commented Jul 24, 2024

I've rebased on top of #6836 and have added theme json block-level tests.

One thing to note is that #6836 opens up block-level global styles, so I've updated the theme.json test snippet in the description.

🍺

@noisysocks
Copy link
Member

@ramonjd: Is this ready to commit?

@ramonjd
Copy link
Member Author

ramonjd commented Jul 30, 2024

Is this ready to commit?

Oh yes, please!!

@noisysocks
Copy link
Member

I intended that as a nudge for you... 😂 You win this round, I was unclear.

@ramonjd
Copy link
Member Author

ramonjd commented Jul 31, 2024

I intended that as a nudge for you... 😂 You win this round, I was unclear.

Haha. No worries. I mistakenly assumed there was some rule about committing your own patches.

@ramonjd ramonjd force-pushed the add/theme-json-background-attachment branch from 1e4861a to 8485950 Compare July 31, 2024 01:29
@ramonjd
Copy link
Member Author

ramonjd commented Jul 31, 2024

Merged in [58834]

c3e1d3a

@ramonjd ramonjd closed this Jul 31, 2024
@ramonjd ramonjd deleted the add/theme-json-background-attachment branch July 31, 2024 02:43
@noisysocks
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants