Skip to content

Commit 6e9a9f0

Browse files
authored
Merge pull request #30 from mehimanshupatil/font-name-error
fixed classname add logic on font load
2 parents cc977af + 19cb924 commit 6e9a9f0

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

utils/fontListener.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ export const fontListener = ({ fontNames, scope }) => {
1111
addClassName("all");
1212
}
1313

14-
function handleFontLoad(fontName: string) {
15-
addClassName(fontName);
14+
function handleFontLoad(fontFaces: FontFace[]) {
15+
fontFaces.forEach((fontFace) => {
16+
addClassName(fontFace.family);
17+
})
1618
}
1719

1820
function fontMapper(fontName) {
@@ -37,7 +39,7 @@ export const fontListener = ({ fontNames, scope }) => {
3739
errorFallback();
3840
}
3941

40-
function addClassName(fontName) {
42+
function addClassName(fontName: string) {
4143
document[targetElement].classList.add(`wf-${kebabCase(fontName)}`);
4244
}
4345

0 commit comments

Comments
 (0)