Skip to content

Commit

Permalink
First commit. Define theme.json schema
Browse files Browse the repository at this point in the history
Updating constants and docs

Fix props
  • Loading branch information
ramonjd committed Feb 26, 2024
1 parent 4d5fd5a commit 841e782
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 0 deletions.
13 changes: 13 additions & 0 deletions docs/reference-guides/theme-json-reference/theme-json-living.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,19 @@ Generate custom CSS custom properties of the form `--wp--custom--{key}--{nested-
## Styles


### background

Background styles

| Property | Type | Props |
| --- | --- |--- |
| backgroundImage | string, object | |
| backgroundPosition | string, object | |
| backgroundRepeat | string, object | |
| backgroundSize | string, object | |

---

### border

Border styles.
Expand Down
12 changes: 12 additions & 0 deletions lib/class-wp-theme-json-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,13 +203,18 @@ class WP_Theme_JSON_Gutenberg {
* removed the `--wp--style--block-gap` property.
* @since 6.2.0 Added `outline-*`, and `min-height` properties.
* @since 6.3.0 Added `writing-mode` property.
* @since 6.6.0 Added `background-[image|position|repeat|size]` properties.
*
* @var array
*/
const PROPERTIES_METADATA = array(
'aspect-ratio' => array( 'dimensions', 'aspectRatio' ),
'background' => array( 'color', 'gradient' ),
'background-color' => array( 'color', 'background' ),
'background-image' => array( 'background', 'backgroundImage' ),
'background-position' => array( 'background', 'backgroundPosition' ),
'background-repeat' => array( 'background', 'backgroundRepeat' ),
'background-size' => array( 'background', 'backgroundSize' ),
'border-radius' => array( 'border', 'radius' ),
'border-top-left-radius' => array( 'border', 'radius', 'topLeft' ),
'border-top-right-radius' => array( 'border', 'radius', 'topRight' ),
Expand Down Expand Up @@ -461,10 +466,17 @@ class WP_Theme_JSON_Gutenberg {
* added new property `shadow`,
* updated `blockGap` to be allowed at any level.
* @since 6.2.0 Added `outline`, and `minHeight` properties.
* @since 6.6.0 Added `background` sub properties to top-level only.
*
* @var array
*/
const VALID_STYLES = array(
'background' => array(
'backgroundImage' => 'top',
'backgroundPosition' => 'top',
'backgroundRepeat' => 'top',
'backgroundSize' => 'top',
),
'border' => array(
'color' => null,
'radius' => null,
Expand Down
50 changes: 50 additions & 0 deletions schemas/json/theme.json
Original file line number Diff line number Diff line change
Expand Up @@ -1110,6 +1110,56 @@
"stylesProperties": {
"type": "object",
"properties": {
"background": {
"description": "Background styles",
"type": "object",
"properties": {
"backgroundImage": {
"description": "Sets the `background-image` CSS property.",
"oneOf": [
{
"type": "string"
},
{
"$ref": "#/definitions/refComplete"
}
]
},
"backgroundPosition": {
"description": "Sets the `background-position` CSS property.",
"oneOf": [
{
"type": "string"
},
{
"$ref": "#/definitions/refComplete"
}
]
},
"backgroundRepeat": {
"description": "Sets the `background-repeat` CSS property.",
"oneOf": [
{
"type": "string"
},
{
"$ref": "#/definitions/refComplete"
}
]
},
"backgroundSize": {
"description": "Sets the `background-size` CSS property.",
"oneOf": [
{
"type": "string"
},
{
"$ref": "#/definitions/refComplete"
}
]
}
}
},
"border": {
"description": "Border styles.",
"type": "object",
Expand Down

0 comments on commit 841e782

Please sign in to comment.