|
1 |
| -export type BodyFont = 'Fira Mono' | 'Fira Sans' | 'IBM Plex Serif' | 'Inter' | 'JetBrains Mono' | 'Lora' | 'Manrope' | 'Merriweather' | 'Nunito' | 'Noto Sans' | 'Noto Serif' | 'Poppins' | 'Roboto' | 'Space Mono'; |
2 |
| -export type HeadingFont = 'Cardo' | 'Chakra Petch' | 'Old Standard TT' | 'Rufina' | 'Space Grotesk' | 'Tenor Sans' | BodyFont; |
3 |
| -export type CustomFonts = {heading: HeadingFont[], body: BodyFont[]}; |
| 1 | +export type BodyFontName = |
| 2 | + | 'Fira Mono' |
| 3 | + | 'Fira Sans' |
| 4 | + | 'IBM Plex Serif' |
| 5 | + | 'Inter' |
| 6 | + | 'JetBrains Mono' |
| 7 | + | 'Lora' |
| 8 | + | 'Manrope' |
| 9 | + | 'Merriweather' |
| 10 | + | 'Nunito' |
| 11 | + | 'Noto Sans' |
| 12 | + | 'Noto Serif' |
| 13 | + | 'Poppins' |
| 14 | + | 'Roboto' |
| 15 | + | 'Space Mono'; |
| 16 | + |
| 17 | +export type HeadingFontName = |
| 18 | + | 'Cardo' |
| 19 | + | 'Chakra Petch' |
| 20 | + | 'Old Standard TT' |
| 21 | + | 'Rufina' |
| 22 | + | 'Space Grotesk' |
| 23 | + | 'Tenor Sans' |
| 24 | + | BodyFontName; |
| 25 | + |
| 26 | +export type Font<T extends string> = { |
| 27 | + name: T; |
| 28 | + creator: string; |
| 29 | +}; |
| 30 | + |
| 31 | +export type HeadingFont = Font<HeadingFontName>; |
| 32 | +export type BodyFont = Font<BodyFontName>; |
| 33 | + |
| 34 | +export type CustomFonts = { |
| 35 | + heading: HeadingFont[]; |
| 36 | + body: BodyFont[]; |
| 37 | +}; |
4 | 38 |
|
5 | 39 | export type FontSelection = {
|
6 |
| - heading?: HeadingFont, |
7 |
| - body?: BodyFont |
| 40 | + heading?: HeadingFontName; |
| 41 | + body?: BodyFontName; |
8 | 42 | };
|
9 | 43 |
|
10 | 44 | export const CUSTOM_FONTS: CustomFonts = {
|
11 | 45 | heading: [
|
12 |
| - 'Cardo', |
13 |
| - 'Chakra Petch', |
14 |
| - 'Fira Mono', |
15 |
| - 'Fira Sans', |
16 |
| - 'IBM Plex Serif', |
17 |
| - 'Inter', |
18 |
| - 'JetBrains Mono', |
19 |
| - 'Lora', |
20 |
| - 'Manrope', |
21 |
| - 'Merriweather', |
22 |
| - 'Noto Sans', |
23 |
| - 'Noto Serif', |
24 |
| - 'Nunito', |
25 |
| - 'Old Standard TT', |
26 |
| - 'Poppins', |
27 |
| - 'Roboto', |
28 |
| - 'Rufina', |
29 |
| - 'Space Grotesk', |
30 |
| - 'Space Mono', |
31 |
| - 'Tenor Sans' |
| 46 | + {name: 'Cardo', creator: 'David Perry'}, |
| 47 | + {name: 'Chakra Petch', creator: 'Cadson Demak'}, |
| 48 | + {name: 'Fira Mono', creator: 'Carrois Apostrophe'}, |
| 49 | + {name: 'Fira Sans', creator: 'Carrois Apostrophe'}, |
| 50 | + {name: 'IBM Plex Serif', creator: 'Mike Abbink'}, |
| 51 | + {name: 'Inter', creator: 'Rasmus Andersson'}, |
| 52 | + {name: 'JetBrains Mono', creator: 'JetBrains'}, |
| 53 | + {name: 'Lora', creator: 'Cyreal'}, |
| 54 | + {name: 'Manrope', creator: 'Mikhail Sharanda'}, |
| 55 | + {name: 'Merriweather', creator: 'Sorkin Type'}, |
| 56 | + {name: 'Noto Sans', creator: 'Google'}, |
| 57 | + {name: 'Noto Serif', creator: 'Google'}, |
| 58 | + {name: 'Nunito', creator: 'Vernon Adams'}, |
| 59 | + {name: 'Old Standard TT', creator: 'Alexey Kryukov'}, |
| 60 | + {name: 'Poppins', creator: 'Indian Type Foundry'}, |
| 61 | + {name: 'Roboto', creator: 'Christian Robertson'}, |
| 62 | + {name: 'Rufina', creator: 'Martin Sommaruga'}, |
| 63 | + {name: 'Space Grotesk', creator: 'Florian Karsten'}, |
| 64 | + {name: 'Space Mono', creator: 'Colophon Foundry'}, |
| 65 | + {name: 'Tenor Sans', creator: 'Denis Masharov'} |
32 | 66 | ],
|
33 | 67 | body: [
|
34 |
| - 'Fira Mono', |
35 |
| - 'Fira Sans', |
36 |
| - 'IBM Plex Serif', |
37 |
| - 'Inter', |
38 |
| - 'JetBrains Mono', |
39 |
| - 'Lora', |
40 |
| - 'Manrope', |
41 |
| - 'Merriweather', |
42 |
| - 'Noto Sans', |
43 |
| - 'Noto Serif', |
44 |
| - 'Nunito', |
45 |
| - 'Poppins', |
46 |
| - 'Roboto', |
47 |
| - 'Space Mono' |
| 68 | + {name: 'Fira Mono', creator: 'Carrois Apostrophe'}, |
| 69 | + {name: 'Fira Sans', creator: 'Carrois Apostrophe'}, |
| 70 | + {name: 'IBM Plex Serif', creator: 'Mike Abbink'}, |
| 71 | + {name: 'Inter', creator: 'Rasmus Andersson'}, |
| 72 | + {name: 'JetBrains Mono', creator: 'JetBrains'}, |
| 73 | + {name: 'Lora', creator: 'Cyreal'}, |
| 74 | + {name: 'Manrope', creator: 'Mikhail Sharanda'}, |
| 75 | + {name: 'Merriweather', creator: 'Sorkin Type'}, |
| 76 | + {name: 'Noto Sans', creator: 'Google'}, |
| 77 | + {name: 'Noto Serif', creator: 'Google'}, |
| 78 | + {name: 'Nunito', creator: 'Vernon Adams'}, |
| 79 | + {name: 'Poppins', creator: 'Indian Type Foundry'}, |
| 80 | + {name: 'Roboto', creator: 'Christian Robertson'}, |
| 81 | + {name: 'Space Mono', creator: 'Colophon Foundry'} |
48 | 82 | ]
|
49 | 83 | };
|
50 | 84 |
|
@@ -208,10 +242,10 @@ export function getCustomFonts(): CustomFonts {
|
208 | 242 | return CUSTOM_FONTS;
|
209 | 243 | }
|
210 | 244 |
|
211 |
| -export function isValidCustomFont(font: string): font is BodyFont { |
212 |
| - return CUSTOM_FONTS.body.includes(font as BodyFont); |
| 245 | +export function isValidCustomFont(fontName: string): fontName is BodyFontName { |
| 246 | + return CUSTOM_FONTS.body.some(font => font.name === fontName); |
213 | 247 | }
|
214 | 248 |
|
215 |
| -export function isValidCustomHeadingFont(font: string): font is HeadingFont { |
216 |
| - return CUSTOM_FONTS.heading.includes(font as HeadingFont); |
| 249 | +export function isValidCustomHeadingFont(fontName: string): fontName is HeadingFontName { |
| 250 | + return CUSTOM_FONTS.heading.some(font => font.name === fontName); |
217 | 251 | }
|
0 commit comments