Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ae40f8a

Browse files
chore(site): fix storybook font issue (#14137)
1 parent a3c4586 commit ae40f8a

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

site/.storybook/preview.jsx

+9
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)