Skip to content

Commit c82a5fb

Browse files
author
Francis Champagne
committed
Change loaded font behavior
1 parent 6ecdf28 commit c82a5fb

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

components/FontListener.tsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ export const FontListener: React.FC<Props> = ({
2525
[loadedFonts, fontNames]
2626
)
2727

28-
const loadedClassname = useMemo(getLoadedFontClassNames, [loadedFonts])
29-
28+
const loadedAttrName = useMemo(getLoadedFontAttrNames, [loadedFonts])
29+
3030
const apiAvailable = "fonts" in document
3131

3232
useEffect(() => {
@@ -46,18 +46,17 @@ export const FontListener: React.FC<Props> = ({
4646
clearInterval(intervalId)
4747
}
4848
}, [hasLoaded, intervalId])
49-
49+
5050
return (
5151
<Helmet>
52-
<body className={loadedClassname} />
52+
<html {...loadedAttrName} />
5353
</Helmet>
5454
)
5555

56-
function getLoadedFontClassNames() {
56+
function getLoadedFontAttrNames() {
5757
return Boolean(loadedFonts.length)
5858
? loadedFonts
59-
.map(fontName => `wf-${kebabCase(fontName)}--loaded`)
60-
.join(" ")
59+
.reduce((acc, fontName) => ({ ...acc, ...({[`wf-${kebabCase(fontName)}`]: "loaded"}) }), {})
6160
: ""
6261
}
6362

0 commit comments

Comments
 (0)