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

Update block supports documentation for text and background colors #26931

Merged
merged 1 commit into from
Nov 12, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions docs/designers-developers/developers/block-api/block-supports.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,23 +85,36 @@ supports: {
- Type: `Object`
- Default value: null
- Subproperties:
- `background`: type `boolean`, default value `false`
- `gradient`: type `boolean`, default value `false`
- `background`: type `boolean`, default value `true`
- `gradient`: type `boolean`, default value `true`
- `text`: type `boolean`, default value `false`

This value signals that a block supports some of the CSS style properties related to color. When it does, the block editor will show UI controls for the user to set their values.

The controls for background and text will source their colors from the `editor-color-palette` [theme support](https://developer.wordpress.org/block-editor/developers/themes/theme-support/#block-color-palettes), while the gradient's from `editor-gradient-presets` [theme support](https://developer.wordpress.org/block-editor/developers/themes/theme-support/#block-gradient-presets).

Note that the `text` and `background` keys have a default value of `true`, so if the `color` property is present they'll also be considered enabled:

```js
supports: {
background: true, // Enable background color UI control.
gradient: true, // Enable gradients UI control.
text: true, // Eneble text color UI control.
color: { // This also enables text and background UI controls.
gradient: true // Enable gradients UI control.
}
}
```

It's possible to disable them individually:

```js
supports: {
color: { // Text UI control is enabled.
background: false, // Disable background UI control.
gradient: true // Enable gradients UI control.
}
}
```

When the block declares support for a specific color property, the attributes definition is extended to include some attributes.
When the block has support for a specific color property, the attributes definition is extended to include some attributes.

- `style`: attribute of `object` type with no default assigned. This is added when any of support color properties are declared. It stores the custom values set by the user. The block can apply a default style by specifying its own `style` attribute with a default e.g.:

Expand Down