Skip to content

Commit

Permalink
Improve formatting in the theme.json document
Browse files Browse the repository at this point in the history
  • Loading branch information
gziolo authored and oandregal committed Jun 5, 2020
1 parent 583ea7f commit aa79bb7
Showing 1 changed file with 17 additions and 21 deletions.
38 changes: 17 additions & 21 deletions docs/designers-developers/developers/themes/theme-json.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,21 +78,21 @@ Some of the functions are context-dependant. Take, as an example, the drop cap:
"features": {
"typography": {
"dropCap": false
}
}
}
},
"core/paragraph": {
"features": {
"typography": {
"dropCap": true
}
}
}
},
"core/image": {
"features": {
"typography": {
"dropCap": true
}
}
}
}
}
Expand Down Expand Up @@ -174,17 +174,24 @@ The list of properties that are currently exposed via this method are:

### Features

So far, this function is only enabled for the `global` section in `experimental-theme.json`.
Via the features key we allow controlling some editor and block features according to the following rules:
- The features within `global` override the default editor settings, which plugins can modify by hooking into the `block_editor_settings` filter on the server.
- The features within the context of each block override the default block settings, which plugins can modify by hooking into the `blocks.registerBlockType` filter on the client.
- Block settings take precedence over global settings.

For example, if a feature is enabled for a block by default, although the theme disables it at the global level, the block keeps it enabled. If the theme wants to override a block's default, it has to target that particular block.

So far, this function is enabled only for the `global` section in `lib/experimental-default-theme.json`.

```
{
"global": {
"features": {
"typography": {
"dropCap": false
}
}
}
}
}
}
}
```

Expand All @@ -196,24 +203,13 @@ Then each block can decide to override how they handle block editor features dur
"__experimentalFeatures": {
"typography": {
"dropCap": true
}
}
}
}
}
}
```

Moving forward, we plan to integrate overrides targeting individual blocks defined inside `experimental-theme.json` file that would be applied on top of features defined by block authors in `supports` property.

Finally, this is how it can be used in the block's `edit` implementation:

```js
// edit.js

const Edit = ( props ) => {
const isDisabled = ! useEditorFeature( 'typography.dropCap' );
// ...
};
```
Moving forward, we plan to integrate overrides targeting individual blocks defined inside a theme specific file (`experimental-theme.json`) that would be applied on top of features defined by block authors in `supports` property.

The list of features that are currently supported are:
- Paragraph: drop cap.
Expand Down

0 comments on commit aa79bb7

Please sign in to comment.