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

[Site Editor] Spacing values declared as variable have no effect in the site editor. #43042

Closed
Gierand opened this issue Aug 6, 2022 · 7 comments
Labels
[Feature] Site Editor Related to the overarching Site Editor (formerly "full site editing") [Feature] Themes Questions or issues with incorporating or styling blocks in a theme. [Type] Bug An existing feature does not function as intended

Comments

@Gierand
Copy link

Gierand commented Aug 6, 2022

Description

When we add variable values to the spacing in the theme.json file, no change occurs.

Step-by-step reproduction instructions

Try changing the settings in theme.json using the following code snippet example.
The problem is not only with the buttons, but also with the rest of the blocks.

Screenshots, screen recording, code snippet

"elements": {
	"button": {
		"spacing": {
			"padding": {
				"top": "var:preset|spacing|100", //  It doesn't work
				"right": "0", // It works
				"bottom": "var(--wp--preset--spacing--100)", // It doesn't work
				"left": "2rem" // It works => var(--wp--custom--spacing--*) too
		}
	}
}

Frontend:

Frontend

Site Editor:

Editor

Environment info

WordPress version: 6.0.1 and 6.1-alpha-53848
Gutenberg version: 13.9.20220805
Theme: TT2

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

@Gierand Gierand changed the title [Site Editor] Spacing values declared as variable have no effect in the editor. [Site Editor] Spacing values declared as variable have no effect in the site editor. Aug 6, 2022
@ramonjd
Copy link
Member

ramonjd commented Aug 12, 2022

I think this commit in #42173 might address the issue.

cc @glendaviesnz

@glendaviesnz
Copy link
Contributor

glendaviesnz commented Aug 12, 2022

I think this commit in #42173 might address the issue.

Yes, @Gierand, the above PR should resolve this issue, and also adds the UI for selecting the spacing presets for padding in the block and site editor. Something else to note about the changes in that PR is that the spacing scale provided by core will be reduced from 10 to 7 levels which gives 3 sizes each side of medium (2XS, XS, S, M, L, XL, 2XL), so the var:preset|spacing|100 value won't be generated by default once this is merged, but you will be able to modify your theme.json to still generate these extra values if you need them.

@Gierand
Copy link
Author

Gierand commented Aug 12, 2022

@glendaviesnz, thank you for the clarification. However, I have a question. Will .has-10-spacing , .has-*-spacing classes be generated as with other presets?

@glendaviesnz
Copy link
Contributor

I have a question. Will .has-10-spacing , .has-*-spacing classes be generated as with other presets

That would be the ideal, and there is a task listed in the tracking issue to follow up on this. To do this we just need to make sure that we can conditionally load these class definitions based on the block content of the current page as loading all of them would add a lot of additional CSS to every page as classes and property definitions are needed for every side for every step in the scale, eg. .has-10-spacing-all .has-10-spacing-top has-10-spacing-bottom .has-10-spacing-left .has-10-spacing-right

@Gierand
Copy link
Author

Gierand commented Aug 15, 2022

There seems to be a problem with custom spacing presets (dragging not working).

"spacing": {
		"spacingSizes": [
			{
				"name": "50",
				"slug": "50",
				"size": "2rem"
			},
			{
				"name": "XL",
				"slug": "60",
				"size": "4rem"
			},
			{
				"name": "2XL",
				"slug": "70",
				"size": "clamp(2rem, 10vw, 20rem)"
			}
		]
}

padding

@richtabor
Copy link
Member

I've confirmed that this is resolved by #42173 (spacing values are generated in the site editor).

I've also found the same issue as @Gierand's latest comment — wrote up an issue: #43234

@skorasaurus skorasaurus added [Feature] Themes Questions or issues with incorporating or styling blocks in a theme. [Feature] Site Editor Related to the overarching Site Editor (formerly "full site editing") [Type] Bug An existing feature does not function as intended labels Aug 15, 2022
@glendaviesnz
Copy link
Contributor

Closing this as the outstanding bug has been moved to a separate issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Site Editor Related to the overarching Site Editor (formerly "full site editing") [Feature] Themes Questions or issues with incorporating or styling blocks in a theme. [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

5 participants