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

Global Styles: Add a way to set defaults for all styles #27338

Closed
scruffian opened this issue Nov 27, 2020 · 7 comments
Closed

Global Styles: Add a way to set defaults for all styles #27338

scruffian opened this issue Nov 27, 2020 · 7 comments
Labels
[Feature] Design Tools Tools that impact the appearance of blocks both to expand the number of tools and improve the experi

Comments

@scruffian
Copy link
Contributor

If I declare support for a global style in a block I'd also like to be able to set a default value for that block. For example I could set default values for padding in the block attributes like this:

		"spacing": {
			"type": "object",
			"default": {
				"padding": {
					"type": "number",
					"default": 10
				}
			}
		},

I think this is already supported by some properties but either this one doesn't work, or I'm doing it wrong!

@scruffian
Copy link
Contributor Author

This is achievable now, the syntax is like this:

"style": { "default": { "spacing": { "padding": { "default": 10 } } } }

It might be good to document this

@scruffian
Copy link
Contributor Author

There also seem to be two bugs with this:

  1. If you set a default value it's not reflected in the block - is it expected that this is set in CSS?
  2. If you reset the control it wipes the value rather than going back to the default.

@oandregal
Copy link
Member

I think I may benefit from some more context on the specifics you're working with! Is this something you do with theme.json (presumably not because I don't know how you'd do it), or are you working with a block and so trying to create its block.json (block supports docs, in case they're helpful)? If it is the latter, you can add defaults (there's an example about padding in the docs).

@scruffian
Copy link
Contributor Author

Ah yes, that's what I'm doing. Sorry I hadn't seen the docs. I think the bugs I mentioned above are still relevant though.

@oandregal
Copy link
Member

@scruffian I found #27341 which I believe is what prompted you to file this issue?

I left a few comments there, but, essentially instead of default you need to use top, right, bottom, left ― see the documentation for padding. As per the control, I believe it works as designed (remove any style value).

@oandregal oandregal removed their assignment Dec 3, 2020
@oandregal oandregal added [Feature] Design Tools Tools that impact the appearance of blocks both to expand the number of tools and improve the experi and removed Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json labels Dec 3, 2020
@gziolo
Copy link
Member

gziolo commented Dec 3, 2020

Would be it fine to define this default value inside supports rather than passing true? It’d more convenient for developers.

@scruffian
Copy link
Contributor Author

Closing in favour of #27796

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Design Tools Tools that impact the appearance of blocks both to expand the number of tools and improve the experi
Projects
None yet
Development

No branches or pull requests

3 participants