Skip to content
Merged
Show file tree
Hide file tree
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
248 changes: 196 additions & 52 deletions schemas/json/theme.json
Original file line number Diff line number Diff line change
Expand Up @@ -1947,6 +1947,30 @@
"stylesBlocksPseudoSelectorsPropertyNames": {
"enum": [ ":hover", ":focus", ":focus-visible", ":active" ]
},
"stylesBlocksPropertiesAndPseudoComplete": {
"description": "Style properties plus the pseudo-selectors available to blocks that support them.",
"allOf": [
{
"$ref": "#/definitions/stylesProperties"
},
{
"$ref": "#/definitions/stylesBlocksPseudoSelectorsProperties"
},
{
"type": "object",
"propertyNames": {
"anyOf": [
{
"$ref": "#/definitions/stylesPropertyNames"
},
{
"$ref": "#/definitions/stylesBlocksPseudoSelectorsPropertyNames"
}
]
}
}
]
},
"stylesBlocksResponsiveSelectorsProperties": {
"description": "Responsive block states keyed by breakpoint name. Each breakpoint supports the same style properties as the default block state.",
"type": "object",
Expand All @@ -1962,6 +1986,67 @@
"stylesBlocksResponsiveSelectorsPropertyNames": {
"enum": [ "@mobile", "@tablet" ]
},
"stylesBlocksResponsiveSelectorsWithPseudoProperties": {
"description": "Responsive block states for blocks that support pseudo-selectors. Each breakpoint supports the same style properties as the default block state, plus the block's pseudo-selectors.",
"type": "object",
"properties": {
"@mobile": {
"$ref": "#/definitions/stylesBlocksPropertiesAndPseudoComplete"
},
"@tablet": {
"$ref": "#/definitions/stylesBlocksPropertiesAndPseudoComplete"
}
}
},
"stylesBlockVariationsWithPseudoProperties": {
"description": "Block style variations for blocks that support pseudo-selectors. Each variation supports the same style properties, responsive states and pseudo-selectors as the block itself.",
"type": "object",
"patternProperties": {
"^[a-z][a-z0-9-]*$": {
"allOf": [
{
"$ref": "#/definitions/stylesProperties"
},
{
"$ref": "#/definitions/stylesBlocksResponsiveSelectorsWithPseudoProperties"
},
{
"$ref": "#/definitions/stylesBlocksPseudoSelectorsProperties"
},
{
"type": "object",
"properties": {
"elements": {
"$ref": "#/definitions/stylesElementsPropertiesComplete"
},
"blocks": {
"$ref": "#/definitions/stylesVariationBlocksPropertiesComplete"
}
}
},
{
"type": "object",
"propertyNames": {
"anyOf": [
{
"$ref": "#/definitions/stylesPropertyNames"
},
{
"enum": [ "elements", "blocks" ]
},
{
"$ref": "#/definitions/stylesBlocksResponsiveSelectorsPropertyNames"
},
{
"$ref": "#/definitions/stylesBlocksPseudoSelectorsPropertyNames"
}
]
}
}
]
}
}
},
"stylesElementsPseudoSelectorsProperties": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -1996,15 +2081,15 @@
"description": "Styles applied to the current/active item (e.g. .current-menu-item in navigation).",
"allOf": [
{
"$ref": "#/definitions/stylesPropertiesComplete"
},
{
"$ref": "#/definitions/stylesBlocksPseudoSelectorsProperties"
"$ref": "#/definitions/stylesBlocksPropertiesAndPseudoComplete"
}
]
}
}
},
"stylesBlocksCustomStatesPropertyNames": {
"enum": [ "-current" ]
},
"stylesElementsPseudoSelectorsPropertyNames": {
"enum": [
":active",
Expand Down Expand Up @@ -2386,44 +2471,16 @@
"$ref": "#/definitions/stylesProperties"
},
{
"$ref": "#/definitions/stylesBlocksResponsiveSelectorsProperties"
"$ref": "#/definitions/stylesBlocksResponsiveSelectorsWithPseudoProperties"
},
{
"type": "object",
"properties": {
"elements": {
"$ref": "#/definitions/stylesElementsPropertiesComplete"
},
"variations": {
"type": "object",
"patternProperties": {
"^[a-z][a-z0-9-]*$": {
"allOf": [
{
"$ref": "#/definitions/stylesProperties"
},
{
"$ref": "#/definitions/stylesBlocksResponsiveSelectorsProperties"
},
{
"$ref": "#/definitions/stylesBlocksPseudoSelectorsProperties"
},
{
"type": "object",
"propertyNames": {
"anyOf": [
{
"$ref": "#/definitions/stylesPropertyNames"
},
{
"$ref": "#/definitions/stylesBlocksResponsiveSelectorsPropertyNames"
},
{
"$ref": "#/definitions/stylesBlocksPseudoSelectorsPropertyNames"
}
]
}
}
]
}
}
"$ref": "#/definitions/stylesBlockVariationsWithPseudoProperties"
}
}
},
Expand All @@ -2438,7 +2495,7 @@
"$ref": "#/definitions/stylesPropertyNames"
},
{
"enum": [ "variations" ]
"enum": [ "elements", "variations" ]
},
{
"$ref": "#/definitions/stylesBlocksResponsiveSelectorsPropertyNames"
Expand Down Expand Up @@ -2580,16 +2637,49 @@
"core/navigation-link": {
"allOf": [
{
"$ref": "#/definitions/stylesPropertiesAndElementsComplete"
"$ref": "#/definitions/stylesProperties"
},
{
"$ref": "#/definitions/stylesBlocksResponsiveSelectorsProperties"
"$ref": "#/definitions/stylesBlocksResponsiveSelectorsWithPseudoProperties"
},
{
"$ref": "#/definitions/stylesBlocksPseudoSelectorsProperties"
},
{
"$ref": "#/definitions/stylesBlocksCustomStatesProperties"
},
{
"type": "object",
"properties": {
"elements": {
"$ref": "#/definitions/stylesElementsPropertiesComplete"
},
"variations": {
"$ref": "#/definitions/stylesBlockVariationsWithPseudoProperties"
}
}
},
{
"type": "object",
"propertyNames": {
"anyOf": [
{
"$ref": "#/definitions/stylesPropertyNames"
},
{
"enum": [ "elements", "variations" ]
},
{
"$ref": "#/definitions/stylesBlocksResponsiveSelectorsPropertyNames"
},
{
"$ref": "#/definitions/stylesBlocksPseudoSelectorsPropertyNames"
},
{
"$ref": "#/definitions/stylesBlocksCustomStatesPropertyNames"
}
]
}
}
]
},
Expand Down Expand Up @@ -2765,12 +2855,12 @@
"$ref": "#/definitions/stylesPropertiesAndElementsComplete"
}
},
"patternProperties": {
"^[a-z][a-z0-9-]*/[a-z][a-z0-9-]*$": {
"$ref": "#/definitions/stylesPropertiesAndElementsComplete"
}
"propertyNames": {
"pattern": "^[a-z][a-z0-9-]*/[a-z][a-z0-9-]*$"
},
"additionalProperties": false
"additionalProperties": {
"$ref": "#/definitions/stylesPropertiesAndElementsComplete"
}
},
"stylesPropertiesAndElementsComplete": {
"allOf": [
Expand Down Expand Up @@ -2923,18 +3013,29 @@
"$ref": "#/definitions/stylesProperties"
},
{
"$ref": "#/definitions/stylesBlocksResponsiveSelectorsProperties"
"$ref": "#/definitions/stylesBlocksResponsiveSelectorsWithPseudoProperties"
},
{
"$ref": "#/definitions/stylesBlocksPseudoSelectorsProperties"
},
{
"type": "object",
"properties": {
"elements": {
"$ref": "#/definitions/stylesElementsPropertiesComplete"
}
}
},
{
"type": "object",
"propertyNames": {
"anyOf": [
{
"$ref": "#/definitions/stylesPropertyNames"
},
{
"enum": [ "elements" ]
},
{
"$ref": "#/definitions/stylesBlocksResponsiveSelectorsPropertyNames"
},
Expand Down Expand Up @@ -3073,7 +3174,50 @@
"$ref": "#/definitions/stylesVariationBlockPropertiesComplete"
},
"core/navigation-link": {
"$ref": "#/definitions/stylesVariationBlockPropertiesComplete"
"allOf": [
{
"$ref": "#/definitions/stylesProperties"
},
{
"$ref": "#/definitions/stylesBlocksResponsiveSelectorsWithPseudoProperties"
},
{
"$ref": "#/definitions/stylesBlocksPseudoSelectorsProperties"
},
{
"$ref": "#/definitions/stylesBlocksCustomStatesProperties"
},
{
"type": "object",
"properties": {
"elements": {
"$ref": "#/definitions/stylesElementsPropertiesComplete"
}
}
},
{
"type": "object",
"propertyNames": {
"anyOf": [
{
"$ref": "#/definitions/stylesPropertyNames"
},
{
"enum": [ "elements" ]
},
{
"$ref": "#/definitions/stylesBlocksResponsiveSelectorsPropertyNames"
},
{
"$ref": "#/definitions/stylesBlocksPseudoSelectorsPropertyNames"
},
{
"$ref": "#/definitions/stylesBlocksCustomStatesPropertyNames"
}
]
}
}
]
},
"core/navigation-submenu": {
"$ref": "#/definitions/stylesVariationBlockPropertiesComplete"
Expand Down Expand Up @@ -3247,12 +3391,12 @@
"$ref": "#/definitions/stylesVariationBlockPropertiesComplete"
}
},
"patternProperties": {
"^[a-z][a-z0-9-]*/[a-z][a-z0-9-]*$": {
"$ref": "#/definitions/stylesVariationBlockPropertiesComplete"
}
"propertyNames": {
"pattern": "^[a-z][a-z0-9-]*/[a-z][a-z0-9-]*$"
},
"additionalProperties": false
"additionalProperties": {
"$ref": "#/definitions/stylesVariationBlockPropertiesComplete"
}
},
"stylesVariationBlockPropertiesComplete": {
"allOf": [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"$schema": "../../../../schemas/json/theme.json",
"version": 3,
"styles": {
"blocks": {
"core/navigation-link": {
"variations": {
"outline": {
"-current": {
"color": {
"text": "red"
}
}
}
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I assume this and the below are the invalid test cases? Whereabouts are we asserting their invalidity? Not sure I understand how these tests work 😅

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fair question. I had no idea that these tests even existed before yesterday 😄

Invalidity assertions are made over in https://github.com/WordPress/gutenberg/blob/trunk/test/integration/theme-schema.test.js#L17

So creating a file in fixtures/schemas/ is the "assertion" that it's invalid.

"$schema": "../../../../schemas/json/theme.json",
"version": 3,
"styles": {
"blocks": {
"core/navigation-link": {
"-current": {
"invalidAdditionalProperty": true
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"$schema": "../../../../schemas/json/theme.json",
"version": 3,
"styles": {
"blocks": {
"notablockname": {
"color": {
"text": "red"
}
}
}
}
}
Loading
Loading