Skip to content

Commit 210e41d

Browse files
committed
chore(site): fix storybook font issue
1 parent 500a789 commit 210e41d

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

site/.storybook/preview.jsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { QueryClient, QueryClientProvider } from "react-query";
1111
import { HelmetProvider } from "react-helmet-async";
1212
import themes from "theme";
1313
import "theme/globalFonts";
14+
import isChromatic from "chromatic/isChromatic";
1415

1516
DecoratorHelpers.initializeThemeState(Object.keys(themes), "dark");
1617

@@ -102,3 +103,11 @@ function withQuery(Story, { parameters }) {
102103
</QueryClientProvider>
103104
);
104105
}
106+
107+
// Try to fix storybook rendering fonts inconsistently
108+
// https://www.chromatic.com/docs/font-loading/#solution-c-check-fonts-have-loaded-in-a-loader
109+
const fontLoader = async () => ({
110+
fonts: await document.fonts.ready
111+
});
112+
113+
export const loaders = isChromatic() && document.fonts ? [fontLoader] : [];

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy