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 support for border configuration via theme.json #28049

Merged
merged 1 commit into from
Jan 28, 2021

Conversation

pbking
Copy link
Contributor

@pbking pbking commented Jan 7, 2021

Description

With this change a block can be configured to allow a theme to define
border color, width and style in addition to the already available
radius.

How has this been tested?

To leverage this change a block must first be configured to support this change.
For my test I did this with the CODE block. The details of that can be found here.
Specifically to the block.json file the following was added:

	"supports": {
		"__experimentalBorder": {
			"radius": true,
			"color": true,
			"width": true,
			"style": true
		},

With this change in place I added to a Block-based theme (tt1-blocks) the following to the experimental-theme.json:

	"core/code": {
		"styles": {
			"border": {
				"radius": "0px",
				"color": "blue",
				"style": "dotted",
				"width": "4px"
			}

Which you can see demonstrated here.

When a code block was rendered with that theme the results were as the theme was configured:

image

I am not aware of what unit- or functional-tests should be added to support this change and so have not done so.

Types of changes

This enhancement allows BLOCKS to add support for border color, style and width. Unless the block adds support for these features then those border attributes remain un-style-able.

This enhancement does NOT allow a USER to make stylistic changes to the border attributes, only by way of a theme.

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR.

With this change a block can be configured to allow a theme to define
border color, width and style in addition to the already available
radius.
@github-actions github-actions bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Jan 7, 2021
@youknowriad youknowriad added [Type] Experimental Experimental feature or API. Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json labels Jan 11, 2021
@gziolo
Copy link
Member

gziolo commented Jan 12, 2021

I don't know how the whole system works, but on the surface, it aligns with other config options. Are there any recommendations created that would help reviewers to decide?

@oandregal
Copy link
Member

Gave this a try, there's a missing piece for this to work on the site editor as well (it uses a different mechanism than the other editors): essentially, add to the __EXPERIMENTAL_STYLE_PROPERTY at https://github.com/WordPress/gutenberg/blob/master/packages/blocks/src/api/constants.js#L15 the same configuration added to the PHP schema.

With that change, this will technically work. So far, the way we approached this kind of change was that whoever wanted a particular feature (say, borders) had to do the full work ―both infrastructure and UI controls― to distribute the workload among people. I'd like to hear what other people think of fast-tracking the infrastructure work and let UI work for later.

@gziolo
Copy link
Member

gziolo commented Jan 13, 2021

With that change, this will technically work. So far, the way we approached this kind of change was that whoever wanted a particular feature (say, borders) had to do the full work ―both infrastructure and UI controls― to distribute the workload among people. I'd like to hear what other people think of fast-tracking the infrastructure work and let UI work for later.

I personally find it far more important to let themes and site authors to configure those styling options. In fact, I wouldn't be surprised seeing sites don't expose UI controls to remove clutter in the editor.

Copy link
Contributor

@scruffian scruffian left a comment

Choose a reason for hiding this comment

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

I think we can go ahead and merge this.

@scruffian scruffian merged commit 742ae83 into WordPress:master Jan 28, 2021
@github-actions
Copy link

Congratulations on your first merged pull request, @pbking! We'd like to credit you for your contribution in the post announcing the next WordPress release, but we can't find a WordPress.org profile associated with your GitHub account. When you have a moment, visit the following URL and click "link your GitHub account" under "GitHub Username" to link your accounts:

https://profiles.wordpress.org/me/profile/edit/

And if you don't have a WordPress.org account, you can create one on this page:

https://login.wordpress.org/register

Kudos!

@github-actions github-actions bot added this to the Gutenberg 9.9 milestone Jan 28, 2021
@oandregal oandregal mentioned this pull request Feb 3, 2021
82 tasks
@oandregal
Copy link
Member

👋 I've noticed this landed without support for the site editor, as suggested here. Prepared a fix at #29618

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json [Type] Experimental Experimental feature or API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants