Skip to content

Commit

Permalink
DRY.
Browse files Browse the repository at this point in the history
  • Loading branch information
johnbillion committed Jul 14, 2024
1 parent cee61be commit 3431d6c
Show file tree
Hide file tree
Showing 6 changed files with 229 additions and 237 deletions.
164 changes: 78 additions & 86 deletions packages/wp-types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1924,90 +1924,94 @@ export interface WP_REST_API_Font_Collection {
* The font families for the font collection.
*/
font_families: {
font_family_settings: {
name: string;
fontFamily: string;
slug: string;
fontFace?: {
/**
* URL to a preview image of the font.
*/
preview?: string;
/**
* CSS font-family value.
*/
fontFamily: string;
/**
* CSS font-style value.
*/
fontStyle?: string;
/**
* List of available font weights, separated by a space.
*/
fontWeight?: string | number;
/**
* CSS font-display value.
*/
fontDisplay?: "auto" | "block" | "fallback" | "swap" | "optional";
/**
* Paths or URLs to the font files.
*/
src: string | string[];
/**
* CSS font-stretch value.
*/
fontStretch?: string;
/**
* CSS ascent-override value.
*/
ascentOverride?: string;
/**
* CSS descent-override value.
*/
descentOverride?: string;
/**
* CSS font-variant value.
*/
fontVariant?: string;
/**
* CSS font-feature-settings value.
*/
fontFeatureSettings?: string;
/**
* CSS font-variation-settings value.
*/
fontVariationSettings?: string;
/**
* CSS line-gap-override value.
*/
lineGapOverride?: string;
/**
* CSS size-adjust value.
*/
sizeAdjust?: string;
/**
* CSS unicode-range value.
*/
unicodeRange?: string;
[k: string]: unknown;
}[];
preview?: string;
[k: string]: unknown;
};
font_family_settings: WP_Font_Family_Settings;
categories?: string[];
[k: string]: unknown;
}[];
/**
* The categories for the font collection.
*/
categories: {
name: string;
slug: string;
[k: string]: unknown;
}[];
_links: WP_REST_API_Object_Links;
[k: string]: unknown;
}
/**
* Font family settings.
*/
export interface WP_Font_Family_Settings {
name: string;
fontFamily: string;
slug: string;
fontFace?: WP_Font_Face[];
preview?: string;
}
/**
* A font face.
*/
export interface WP_Font_Face {
/**
* URL to a preview image of the font.
*/
preview?: string;
/**
* CSS font-family value.
*/
fontFamily: string;
/**
* CSS font-style value.
*/
fontStyle?: string;
/**
* List of available font weights, separated by a space.
*/
fontWeight?: string | number;
/**
* CSS font-display value.
*/
fontDisplay?: "auto" | "block" | "fallback" | "swap" | "optional";
/**
* Paths or URLs to the font files.
*/
src: string | string[];
/**
* CSS font-stretch value.
*/
fontStretch?: string;
/**
* CSS ascent-override value.
*/
ascentOverride?: string;
/**
* CSS descent-override value.
*/
descentOverride?: string;
/**
* CSS font-variant value.
*/
fontVariant?: string;
/**
* CSS font-feature-settings value.
*/
fontFeatureSettings?: string;
/**
* CSS font-variation-settings value.
*/
fontVariationSettings?: string;
/**
* CSS line-gap-override value.
*/
lineGapOverride?: string;
/**
* CSS size-adjust value.
*/
sizeAdjust?: string;
/**
* CSS unicode-range value.
*/
unicodeRange?: string;
}
/**
* A font family object in a REST API context.
*/
Expand All @@ -2024,13 +2028,7 @@ export interface WP_REST_API_Font_Family {
* The IDs of the child font faces in the font family.
*/
font_faces: number[];
font_family_settings: {
name?: string;
slug?: string;
fontFamily?: string;
preview?: string;
[k: string]: unknown;
};
font_family_settings: WP_Font_Family_Settings;
_links: WP_REST_API_Object_Links;
/**
* The embedded representation of relations. Only present when the '_embed' query parameter is set.
Expand Down Expand Up @@ -2076,13 +2074,7 @@ export interface WP_REST_API_Font_Face {
* The IDs of the child font faces in the font family.
*/
font_faces?: number[];
font_family_settings?: {
name?: string;
slug?: string;
fontFamily?: string;
preview?: string;
[k: string]: unknown;
};
font_family_settings?: WP_Font_Family_Settings;
_links?: WP_REST_API_Object_Links;
/**
* The embedded representation of relations. Only present when the '_embed' query parameter is set.
Expand Down
127 changes: 6 additions & 121 deletions schemas/rest-api/font-collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,126 +37,11 @@
],
"properties": {
"font_family_settings": {
"type": "object",
"required": [
"name",
"fontFamily",
"slug"
],
"properties": {
"name": {
"type": "string"
},
"fontFamily": {
"type": "string"
},
"slug": {
"type": "string"
},
"fontFace": {
"type": "array",
"items": {
"type": "object",
"required": [
"src",
"fontFamily"
],
"properties": {
"preview": {
"description": "URL to a preview image of the font.",
"type": "string",
"format": "uri"
},
"fontFamily": {
"description": "CSS font-family value.",
"type": "string"
},
"fontStyle": {
"description": "CSS font-style value.",
"type": "string"
},
"fontWeight": {
"description": "List of available font weights, separated by a space.",
"oneOf": [
{
"type": "string"
},
{
"type": "integer"
}
]
},
"fontDisplay": {
"description": "CSS font-display value.",
"type": "string",
"enum": [
"auto",
"block",
"fallback",
"swap",
"optional"
]
},
"src": {
"description": "Paths or URLs to the font files.",
"oneOf": [
{
"type": "string"
},
{
"type": "array",
"items": {
"type": "string"
}
}
]
},
"fontStretch": {
"description": "CSS font-stretch value.",
"type": "string"
},
"ascentOverride": {
"description": "CSS ascent-override value.",
"type": "string"
},
"descentOverride": {
"description": "CSS descent-override value.",
"type": "string"
},
"fontVariant": {
"description": "CSS font-variant value.",
"type": "string"
},
"fontFeatureSettings": {
"description": "CSS font-feature-settings value.",
"type": "string"
},
"fontVariationSettings": {
"description": "CSS font-variation-settings value.",
"type": "string"
},
"lineGapOverride": {
"description": "CSS line-gap-override value.",
"type": "string"
},
"sizeAdjust": {
"description": "CSS size-adjust value.",
"type": "string"
},
"unicodeRange": {
"description": "CSS unicode-range value.",
"type": "string"
}
},
"additionalProperties": true
}
},
"preview": {
"type": "string",
"format": "uri"
"oneOf": [
{
"$ref": "properties/font-family-settings.json"
}
},
"additionalProperties": true
]
},
"categories": {
"type": "array",
Expand All @@ -165,7 +50,7 @@
}
}
},
"additionalProperties": true
"additionalProperties": false
}
},
"categories": {
Expand All @@ -185,7 +70,7 @@
"type": "string"
}
},
"additionalProperties": true
"additionalProperties": false
}
},
"_links": {
Expand Down
19 changes: 4 additions & 15 deletions schemas/rest-api/font-face.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,22 +47,11 @@
}
},
"font_family_settings": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"slug": {
"type": "string"
},
"fontFamily": {
"type": "string"
},
"preview": {
"type": "string",
"format": "uri"
"oneOf": [
{
"$ref": "properties/font-family-settings.json"
}
}
]
},
"_links": {
"$ref": "properties/object-links.json"
Expand Down
19 changes: 4 additions & 15 deletions schemas/rest-api/font-family.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,11 @@
}
},
"font_family_settings": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"slug": {
"type": "string"
},
"fontFamily": {
"type": "string"
},
"preview": {
"type": "string",
"format": "uri"
"oneOf": [
{
"$ref": "properties/font-family-settings.json"
}
}
]
},
"_links": {
"$ref": "properties/object-links.json"
Expand Down
Loading

0 comments on commit 3431d6c

Please sign in to comment.