Skip to content

Commit

Permalink
modified preview.js in order to try to load fonts
Browse files Browse the repository at this point in the history
  • Loading branch information
Francis Thibault committed Oct 5, 2023
1 parent 3c6f394 commit 6250890
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,22 @@ import { withBackgroundMatchingColorScheme, withCenteredCanvas, withDocsContaine
import { Code, Highlight } from "@stories/mdx";
import { Themes } from "./styles/themes";

if (!isChromatic) {
// Custom font makes chromatic inconsistent and cause "false positive". View https://www.chromatic.com/docs/resource-loading#loading-custom-fonts.
import("@css/font/index.css");
}
// if (isChromatic) {
// // Custom font makes chromatic inconsistent and cause "false positive". View https://www.chromatic.com/docs/resource-loading#loading-custom-fonts.
// import("@css/font/index.css");
// }

// Use the document.fonts API to check if fonts have loaded
// https://developer.mozilla.org/en-US/docs/Web/API/Document/fonts API to
const fontLoader = async () => ({
fonts: await Promise.all([document.fonts.load("400 1em Font Name")]),
});

/* 👇 It's configured as a global loader
* See https://storybook.js.org/docs/react/writing-stories/loaders
* to learn more about loaders
*/
export const loaders = isChromatic() && document.fonts ? [fontLoader] : [];

export const parameters = {
options: {
Expand Down

0 comments on commit 6250890

Please sign in to comment.