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

Add spacing presets for theme support #45276

Open
t-hamano opened this issue Oct 25, 2022 · 0 comments
Open

Add spacing presets for theme support #45276

t-hamano opened this issue Oct 25, 2022 · 0 comments
Labels
[Type] Enhancement A suggestion for improvement.

Comments

@t-hamano
Copy link
Contributor

What problem does this address?

#41527 introduced spacing presets. The preset values can be customized in settings.spacing.spacingScale or settings.spacing.spacingSizes or settings.spacing.customSpacingSize in theme.json.

On the other hand, classic themes that don't have theme.json can opt-in to the spacing feature via custom-spacing or new appearance-tools. However, as far as I know, there is no way to change this preset value without theme.json.

What is your proposed solution?

It would be nice if spacing presets could be opted in at the PHP level, like font size, color, and gradients.
For example:

add_theme_support(
	'editor-spacing-presets',
	array(
		array(
			'size' => 'clamp(16px, 1.5vw, 20px)',
			'slug' => '45',
			'name' => 'Flexi Normal'
		),
		array(
			'size' => 'clamp(1.4rem, 2.15vw, 4rem)',
			'slug' => '55',
			'name' => 'Flexi Large'
		)
	)
);

In theme.json, spacingSizes are available to automatically generate presets, but for theme support, I prefer to simply specify variations in an array.

@t-hamano t-hamano added the [Type] Enhancement A suggestion for improvement. label Oct 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

No branches or pull requests

1 participant