Skip to content

Commit

Permalink
theme.json schema: Allow object type on style properties (#45897)
Browse files Browse the repository at this point in the history
* Allow objects on color properties

* Add definition for ref property

* Reduce repetition in property definitions

* Move properties def to oneOf array

* Fix $ref path

* Move ref def to global scope

* Apply ref type to all style properties

* Update docs

* Result of docs:build script

* Run docs:build to update docs

* Make ref logic more specific
  • Loading branch information
mikachan authored Dec 20, 2022
1 parent ceef38a commit 32a1e37
Show file tree
Hide file tree
Showing 3 changed files with 395 additions and 67 deletions.
5 changes: 3 additions & 2 deletions bin/api-docs/gen-theme-reference.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,9 @@ const formatType = ( prop ) => {

propTypes.forEach( ( item ) => {
if ( item.type ) types.push( item.type );
// $ref is always an object
if ( item.$ref ) types.push( 'object' );
// refComplete is always an object
if ( item.$ref && item.$ref === '#/definitions/refComplete' )
types.push( 'object' );
} );

type = [ ...new Set( types ) ].join( ', ' );
Expand Down
40 changes: 20 additions & 20 deletions docs/reference-guides/theme-json-reference/theme-json-living.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,10 @@ Border styles.

| Property | Type | Props |
| --- | --- |--- |
| color | string | |
| color | string, object | |
| radius | string, object | |
| style | string | |
| width | string | |
| style | string, object | |
| width | string, object | |
| top | object | color, style, width |
| right | object | color, style, width |
| bottom | object | color, style, width |
Expand All @@ -162,9 +162,9 @@ Color styles.

| Property | Type | Props |
| --- | --- |--- |
| background | string | |
| gradient | string | |
| text | string | |
| background | string, object | |
| gradient | string, object | |
| text | string, object | |

---

Expand All @@ -174,7 +174,7 @@ Spacing styles.

| Property | Type | Props |
| --- | --- |--- |
| blockGap | string | |
| blockGap | string, object | |
| margin | object | bottom, left, right, top |
| padding | object | bottom, left, right, top |

Expand All @@ -186,14 +186,14 @@ Typography styles.

| Property | Type | Props |
| --- | --- |--- |
| fontFamily | string | |
| fontSize | string | |
| fontStyle | string | |
| fontWeight | string | |
| letterSpacing | string | |
| lineHeight | string | |
| textDecoration | string | |
| textTransform | string | |
| fontFamily | string, object | |
| fontSize | string, object | |
| fontStyle | string, object | |
| fontWeight | string, object | |
| letterSpacing | string, object | |
| lineHeight | string, object | |
| textDecoration | string, object | |
| textTransform | string, object | |

---

Expand All @@ -203,7 +203,7 @@ CSS and SVG filter styles.

| Property | Type | Props |
| --- | --- |--- |
| duotone | string | |
| duotone | string, object | |

---

Expand All @@ -220,10 +220,10 @@ Outline styles.

| Property | Type | Props |
| --- | --- |--- |
| color | string | |
| offset | string | |
| style | string | |
| width | string | |
| color | string, object | |
| offset | string, object | |
| style | string, object | |
| width | string, object | |

---

Expand Down
Loading

1 comment on commit 32a1e37

@github-actions
Copy link

Choose a reason for hiding this comment

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

Flaky tests detected.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/3742518279
📝 Reported issues:

Please sign in to comment.