gfonts-loader
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -1,5 +0,5 @@ | ||
declare type Category = "sans-serif" | "serif" | "display" | "handwriting" | "monospace"; | ||
declare type Subset = "arabic" | "bengali" | "chinese-simplified" | "chinese-traditional" | "cyrillic" | "cyrillic-ext" | "devanagari" | "greek" | "greek-ext" | "gujarati" | "gurmukhi" | "hebrew" | "japanese" | "kannada" | "khmer" | "korean" | "latin" | "latin-ext" | "malayalam" | "myanmar" | "oriya" | "sinhala" | "tamil" | "telugu" | "thai" | "vietnamese"; | ||
declare type Variant = "100" | "100italic" | "200" | "200italic" | "300" | "300italic" | "regular" | "italic" | "500" | "500italic" | "600" | "600italic" | "700" | "700italic" | "800" | "800italic" | "900" | "900italic"; | ||
declare type Font = { | ||
type Category = "sans-serif" | "serif" | "display" | "handwriting" | "monospace"; | ||
type Subset = "arabic" | "bengali" | "chinese-simplified" | "chinese-traditional" | "cyrillic" | "cyrillic-ext" | "devanagari" | "greek" | "greek-ext" | "gujarati" | "gurmukhi" | "hebrew" | "japanese" | "kannada" | "khmer" | "korean" | "latin" | "latin-ext" | "malayalam" | "myanmar" | "oriya" | "sinhala" | "tamil" | "telugu" | "thai" | "vietnamese"; | ||
type Variant = "100" | "100italic" | "200" | "200italic" | "300" | "300italic" | "regular" | "italic" | "500" | "500italic" | "600" | "600italic" | "700" | "700italic" | "800" | "800italic" | "900" | "900italic"; | ||
type Font = { | ||
family: string; | ||
@@ -15,5 +15,5 @@ id: string; | ||
}; | ||
declare type FontMap = Map<string, Font>; | ||
declare type SortOption = "alphabet" | "popularity"; | ||
declare type Options = { | ||
type FontMap = Map<string, Font>; | ||
type SortOption = "alphabet" | "popularity"; | ||
type Options = { | ||
families?: string[]; | ||
@@ -20,0 +20,0 @@ categories?: Category[]; |
@@ -61,5 +61,3 @@ "use strict"; | ||
const variantsStr = variants.join(","); | ||
const familiesStr = fonts.map( | ||
(font) => `${font.family}:${variantsStr}` | ||
); | ||
const familiesStr = fonts.map((font) => `${font.family}:${variantsStr}`); | ||
url.searchParams.append("family", familiesStr.join("|")); | ||
@@ -100,4 +98,6 @@ url.searchParams.append("subset", subsets.join(",")); | ||
activeFontFamily; | ||
// Name of currently applied font | ||
onChange; | ||
fontMap = /* @__PURE__ */ new Map(); | ||
// Map from font families to font objects | ||
constructor(apiKey, { | ||
@@ -132,7 +132,10 @@ families = [], | ||
break; | ||
if ((this.options.families.length === 0 || this.options.families.includes(font.family)) && (this.options.categories.length === 0 || this.options.categories.includes(font.category)) && this.options.subsets.every( | ||
(subset) => font.subsets.includes(subset) | ||
) && this.options.variants.every( | ||
(variant) => font.variants.includes(variant) | ||
) && this.options.filter(font) === true) { | ||
if ( | ||
// Only keep fonts whose names are included in the provided array | ||
(this.options.families.length === 0 || this.options.families.includes(font.family)) && // Only keep fonts in categories from the provided array | ||
(this.options.categories.length === 0 || this.options.categories.includes(font.category)) && // Only keep fonts which are available in all specified subsets | ||
this.options.subsets.every((subset) => font.subsets.includes(subset)) && // Only keep fonts which contain all specified variants | ||
this.options.variants.every((variant) => font.variants.includes(variant)) && // Only keep fonts for which the `filter` function evaluates to `true` | ||
this.options.filter(font) === true | ||
) { | ||
this.fontMap.set(font.family, font); | ||
@@ -163,8 +166,9 @@ } | ||
} | ||
/** | ||
* Set the specified font as the active font and download it | ||
*/ | ||
async setActiveFont(fontFamily) { | ||
const activeFont = this.fontMap.get(fontFamily); | ||
if (!activeFont) { | ||
throw Error( | ||
`Cannot update active font: "${fontFamily}" is not in the font list` | ||
); | ||
throw Error(`Cannot update active font: "${fontFamily}" is not in the font list`); | ||
} | ||
@@ -171,0 +175,0 @@ this.activeFontFamily = fontFamily; |
{ | ||
"name": "gfonts-loader", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Extract YAML front matter from a string", | ||
@@ -9,9 +9,9 @@ "keywords": [ | ||
], | ||
"homepage": "https://github.com/Renovamen/oh-cv/tree/main/packages/gfonts-loader", | ||
"homepage": "https://github.com/Renovamen/oh-my-cv/tree/main/packages/gfonts-loader", | ||
"bugs": { | ||
"url": "https://github.com/Renovamen/oh-cv" | ||
"url": "https://github.com/Renovamen/oh-my-cv" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/Renovamen/oh-cv.git", | ||
"url": "git+https://github.com/Renovamen/oh-my-cv.git", | ||
"directory": "packages/gfonts-loader" | ||
@@ -25,2 +25,3 @@ }, | ||
"exports": { | ||
"types": "./dist/index.d.ts", | ||
"require": "./dist/index.js", | ||
@@ -27,0 +28,0 @@ "import": "./dist/index.mjs" |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
22886
7
555