Skip to content

Instantly share code, notes, and snippets.

@chengyin
Created April 13, 2020 05:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chengyin/b0a822604adfdd59dd2290fee18e8a8a to your computer and use it in GitHub Desktop.
Save chengyin/b0a822604adfdd59dd2290fee18e8a8a to your computer and use it in GitHub Desktop.
if (isChromatic() && document.fonts) {
addDecorator(story => {
const [isLoadingFonts, setIsLoadingFonts] = useState(true);
useEffect(() => {
Promise.all([
document.fonts.load('400 1em Untitled Sans'),
document.fonts.load('italic 400 1em Untitled Sans'),
document.fonts.load('500 1em Untitled Sans'),
document.fonts.load('italic 500 1em Untitled Sans'),
]).then(() => setIsLoadingFonts(false));
}, []);
return isLoadingFonts ? null : story();
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment