-
Notifications
You must be signed in to change notification settings - Fork 0
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
Proposal for a Webfonts collection schema #4
Comments
Start with the end in mind. When talking about a Webfont API, I propose we start with the end in mind: how themes define the webfonts used in the theme. The future of theming will be in defining these types of assets within Terminology for collective understanding:
Goals:
Notes:
Why use one schema?
|
@aristath Is the expectation within the |
In the JSON parser we're converting camelCase to kebab-case: https://github.com/WordPress/gutenberg/blob/0cdcd47ee333cc64ae0c5641fd8865a8f6c3c4a5/lib/class-wp-theme-json-gutenberg.php#L514-L520 so they can be used later on in CSS generation and/or css-variable names |
Will the webfont camelCase properties ever be used? Or will they always be converted to kebab-case? If always converted during the parsing and never ever used in the camelCase format, then using the kebab-case in the schema gets rid of the added conversion processing (less code, memory, and execution time) and makes the webfont's schema more readable and understandable. |
Not in the initial implementation. However, at some point, we'll definitely want to use JS to generate these styles in the editor - in which case camelCase will be used. |
We also need to define the scope of the initial implementation... |
I agree. The implementation details for What could be Phase 1?
Most of this functionality already exists in the first PR. It can be ported over into a more modern and optimized architecture while exposing new functions for themes to register their webfonts collection and custom providers. The gathering of like font providers is a new piece, though not overly complex to build. And then a full suite of tests will be needed. |
What about custom providers? In the webfonts collection scheme, the Then the registration process for theme authors could be simplified to passing this webfonts collection schema through a function like What do you think @aristath? |
What I was thinking is to allow registering a custom provider using |
Yes, that makes sense.
I'd suggest avoiding singletons for future proofing. In the processing engine, the providers are instantiated for the collection of fonts associated with it. For those like fonts (such as Google fonts), I imagine they can use one provider object. This brings up a good point. Making Core aware of when not to collect like fonts. For custom providers, how will Core know whether to collect the like fonts or not? For example, let's say there's a custom provider for an external API that requires individual endpoints. How would Core know not to gather like fonts for this provider?
Would there ever be a use case for one or more fonts to be skipped in the collection process? Or would it be more at the custom provider level, such as for a specific third party API? |
How web fonts will be defined in a theme:
In a
theme.json
file:webfonts
is an object. The key is the webfont'shandle
, and the value contains all the webfont's props (all valid CSS props for@font-face
, plus aprovider
to define the type of webfont (local/google/other).The same exact structure will be used when defining a webfont-collection from PHP instead of a
theme.json
file.We may want to use
fontFamily
instead offont-family
intheme.json
... Everything else in atheme.json
file uses camelCase and not kebab-case, so it would make sense to follow that same pattern. In PHP however, we may want to stick to camel-case 'cause that's what the eventual CSS will beThe text was updated successfully, but these errors were encountered: