Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Font Library: simplify font collection schema #58574

Merged
merged 4 commits into from
Feb 1, 2024

Conversation

matiasbenedetto
Copy link
Contributor

@matiasbenedetto matiasbenedetto commented Feb 1, 2024

What?

Simplify the font-collection.json schema.

Why?

After removing the not needed preview key from the theme.json schema, we added some complexity to the font-collection.json schema that was revealed as unnecessary and promoting more complex code down the line, so in this PR, we are reverting part of the complexity added.

How?

Simplify the font-collection.json schema to make it look like theme.json font families but with the preview key.

Testing Instructions

Create a JSON file in vscode or other editor with JSON Schema validation and autocomplete.
Add this content to the file:

{
    "$schema": "https://raw.githubusercontent.com/WordPress/gutenberg/ed06197dc046f77a38d290182c632c7d20af7d71/schemas/json/font-collection.json",
    "name": "My Font Collection",
    "slug": "my-font-collection",
    "description": "A collection of my favorite fonts",
    "font_families": [
        {
            "font_family_settings": {
                "fontFamily": "Roboto",
                "name": "Roboto",
                "slug": "roboto",
                "fontFace": [
                    {
                        "fontFamily": "Roboto",
                        "fontStyle": "normal",
                        "fontWeight": "400",
                        "src": "https://fonts.gstatic.com/s/roboto/v20/KFOmCnqEu92Fr1Mu4mxP.ttf",
                        "preview": "https://fonts.gstatic.com/s/roboto/v20/KFOmCnqEu92Fr1Mu4mxP.ttf"
                    }
                ]
            },
            "categories": [
                "sans-serif"
            ]
        }
    ],
    "categories": [
        {
            "name": "Sans serif",
            "slug": "sans-serif"
        }
    ]
}

You should not see any validation error.
If you add keys not present in the schema you should see validation errors.

Copy link
Contributor

@creativecoder creativecoder left a comment

Choose a reason for hiding this comment

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

See comments for a couple of nitpicks.

It looks like the font_family_settings description also needs to be updated. It says "Font family settings similar to theme.json but without fontFace key.", and that's no longer correct.

Otherwise looks good

  • ✅ schema is valid
  • ✅ Google fonts collection is valid against the schema
  • ✅ properties from theme.json match here with correct types and descriptions

schemas/json/font-collection.json Outdated Show resolved Hide resolved
schemas/json/font-collection.json Outdated Show resolved Hide resolved
Co-authored-by: Grant Kinney <creativecoder@users.noreply.github.com>
@matiasbenedetto matiasbenedetto enabled auto-merge (squash) February 1, 2024 20:20
Copy link

github-actions bot commented Feb 1, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core SVN

If you're a Core Committer, use this list when committing to wordpress-develop in SVN:

Props: mmaattiiaass, grantmkin.

GitHub Merge commits

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: matiasbenedetto <mmaattiiaass@git.wordpress.org>
Co-authored-by: creativecoder <grantmkin@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Copy link
Contributor

@creativecoder creativecoder left a comment

Choose a reason for hiding this comment

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

I pushed a couple of small updates, the main one being the font_family_settings description. This looks good to go!

@creativecoder creativecoder enabled auto-merge (squash) February 1, 2024 22:39
@creativecoder creativecoder merged commit 6d75b0f into trunk Feb 1, 2024
56 of 57 checks passed
@creativecoder creativecoder deleted the add/simplify-font-collection-schema branch February 1, 2024 23:09
@github-actions github-actions bot added this to the Gutenberg 17.7 milestone Feb 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Font Library [Type] Code Quality Issues or PRs that relate to code quality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants