Skip to content

Commit

Permalink
Await font file loading for Storybook
Browse files Browse the repository at this point in the history
  • Loading branch information
ahosgood committed Oct 18, 2023
1 parent aacab29 commit 11391e5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
18 changes: 12 additions & 6 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import "../src/nationalarchives/all.scss";
import { a11yConfig } from "./storybook-config";
import { customViewports } from "./viewports";
// import { MINIMAL_VIEWPORTS } from "@storybook/addon-viewport";
import isChromatic from "chromatic/isChromatic";

document.documentElement.classList.add(
"tna-template",
// "tna-template--system-theme",
);
document.documentElement.classList.add("tna-template");
if (window.self !== window.top) {
document.documentElement.classList.add("tna-template--padded");
}
Expand All @@ -21,7 +18,6 @@ export const parameters = {
a11y: {
config: a11yConfig,
},
// backgrounds: { disable: true },
backgrounds: {
values: [],
grid: {
Expand All @@ -33,3 +29,13 @@ export const parameters = {
expanded: true,
},
};

const fontLoader = async () => ({
fonts: await Promise.all([
document.fonts.load("normal 1em Open Sans"),
document.fonts.load("bold 1em Open Sans"),
document.fonts.load("normal 1em Roboto Mono"),
]),
});

export const loaders = isChromatic() && document.fonts ? [fontLoader] : [];
4 changes: 2 additions & 2 deletions src/nationalarchives/variables/_typography.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ $body-line-height: #{math.div(16, 18) * 2} !default; // 1.77777
$interactive-text-decoration-thickness: 3.5px !default;

$font-family-main: "Open Sans", sans-serif !default;
$font-weight-main: normal !default;
$font-weight-main-bold: bold !default;
$font-weight-main: normal !default; // Defined in utilities/_typography.scss
$font-weight-main-bold: bold !default; // Defined in utilities/_typography.scss

$font-family-heading: supria-sans-condensed, "Arial Narrow", sans-serif !default;
$font-weight-heading: 400 !default;
Expand Down

0 comments on commit 11391e5

Please sign in to comment.