-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Implement zGoogleFont zod type #4284
Draft
erayerdin
wants to merge
11
commits into
remotion-dev:main
Choose a base branch
from
erayerdin:feat/zGoogleFont
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+76
−40
Draft
Changes from 3 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
39405fb
link @remotion/google-fonts
erayerdin 26238d0
add zGoogleFont
erayerdin 595b2e4
update lock file
erayerdin 8abe7b2
add GoogleFontPicker to examples
erayerdin 0ac605d
declare module for *.module.scss to fix pnpm build error
erayerdin e42ec6a
remove unused lint to fix pnpm build error
erayerdin 687a5a2
remove unused input var to fix pnpm build error
erayerdin 516b15f
add default value to zGoogleFont
erayerdin 983d6c6
add comment to explain zod enums
erayerdin aaa6b97
use font prop in example composition
erayerdin 611921a
Merge branch 'main' into pr/4284
JonnyBurger File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import {getAvailableFonts} from '@remotion/google-fonts'; | ||
import {z} from 'zod'; | ||
|
||
const fonts = getAvailableFonts(); | ||
const fontImportNames = fonts.map(({importName}) => importName); | ||
|
||
export const zGoogleFont = () => z.enum(['None', ...fontImportNames]); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for starting this initiative!
Unfortunately I think it's not a good idea to use
@remotion/google-fonts
as a dependency.@remotion/zod-types
is a lightweight package and many people use it to for example show a color picker.Due to it's massive database,
@remotion/google-fonts
is a 50MB package that most people will not even need in this case.For a
zGoogleFont
type, we should use the Google Fonts package and write a script to generate a list of available fonts, then use that instead of depending on the whole package.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just out of curiosity and to clarify: Why do we even have to write a generator script here? I have checked
packages/google-fonts/scripts
and it does not seem like it fetches fonts from Google Fonts API. And, in this case, all we need (I presume) is to get the names of the fonts and that's all.So, doesn't that mean I can just copy all
FontName.ts
files underpackages/google-fonts/src
intopackages/zod-types/src/z-google-fonts
? Or maybe a create a bigpackages/zod-types/src/z-google-fonts/fonts.ts
and create something like:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The generator script does only retrieve metadata: List of available fonts, weights, styles, unicode ranges and most importantly the URLs at which it should fetch the actual fonts. The metadata powers also the TypeScript type completion and the
getInfo()
APIs. Yes even this data is massive.I would say yes, you can just copy all font names into an array. Then the developer can itself retrieve the metadata from that and load fonts.