Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Introduce Element.json #41748

Closed
adamziel opened this issue Jun 15, 2022 · 0 comments
Closed

Introduce Element.json #41748

adamziel opened this issue Jun 15, 2022 · 0 comments
Labels
[Feature] Block API API that allows to express the block paradigm. [Feature] Site Editor Related to the overarching Site Editor (formerly "full site editing") [Package] Edit Site /packages/edit-site [Type] New API New API to be used by plugin developers or package users.

Comments

@adamziel
Copy link
Contributor

adamziel commented Jun 15, 2022

What problem does this address?

As of recently, the Site Editor supports button elements.

The idea was to have a building block that's can be managed and embedded in other blocks (such as search), but that isn't a Gutenberg block in itself and thus doesn't support features like reordering.

Here's a problem: how to surface the Button element in global styles UI?

CleanShot 2022-06-15 at 14 16 03@2x

@scruffian explored updating the relevant sidebar components in #41659, but it requires updating four files:

  • packages/edit-site/src/components/global-styles/screen-typography-element.js
  • packages/edit-site/src/components/global-styles/screen-typography.js
  • packages/edit-site/src/components/global-styles/screen-colors.js
  • packages/edit-site/src/components/global-styles/ui.js

That's a lot of files and a lot of copypasted code!

Let's go a step further – how do we manage spacings, borders, and anything else that applies? How do we attach custom CSS?

This exact problem is already solved for blocks via block.json and the "supports" config key.

What is your proposed solution?

Let's introduce an element.json file – a declarative way of introducing and configuring elements.

With element.json in place, the above PR could look as follows:

// packages/edit-site/src/elements/button.json
{
	"$schema": "https://schemas.wp.org/trunk/element.json",
	"name": "button",
	"title": "Button",
	"supports": {
		"color": {
			"__experimentalSkipSerialization": true,
			"gradients": true,
			"__experimentalDefaultControls": {
				"background": true,
				"text": true
			}
		},
		"typography": {
			"fontSize": true,
			"__experimentalFontFamily": true,
			"__experimentalDefaultControls": {
				"fontSize": true
			}
		}
	}
}

Adding support for margins and would involve adding the relevant spacing and __experimentalBorder configuration keys.

cc @scruffian @draganescu @getdave @dmsnell @mcsf @gziolo @Mamaduka @noisysocks @tellthemachines @ellatrix @ramonjd @andrewserong @mtias

@adamziel adamziel added [Feature] Block API API that allows to express the block paradigm. [Type] New API New API to be used by plugin developers or package users. [Package] Edit Site /packages/edit-site [Feature] Site Editor Related to the overarching Site Editor (formerly "full site editing") labels Jun 15, 2022
@WordPress WordPress locked and limited conversation to collaborators Jun 15, 2022
@adamziel adamziel converted this issue into discussion #41750 Jun 15, 2022
@bph bph added Needs Dev Note Requires a developer note for a major WordPress release cycle and removed Needs Dev Note Requires a developer note for a major WordPress release cycle labels Sep 14, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
[Feature] Block API API that allows to express the block paradigm. [Feature] Site Editor Related to the overarching Site Editor (formerly "full site editing") [Package] Edit Site /packages/edit-site [Type] New API New API to be used by plugin developers or package users.
Projects
None yet
Development

No branches or pull requests

2 participants