Next.js has font optimization option using their package next/font using google fonts and local. When adding a storybook to a Next.js project, you will start to wonder on how we can achieve the same font to be loaded into the storybook itself as well...

Markdown supported · ⌘↵ to post
Alex Mongeot
Hi Borris, thanks for this very nice blog post! If I may suggest a simple improvement, since this decorator is run before rendering each Story, you can add, out of the preview scope, a boolean variable that becomes true once the classes have been added to the body. You can then check the value of this variable on subsequent runs of the decorator and return early if the classes have already been added. Even if the cost of a classList.add isn't that important, this would help your technique scale better as the number of Stories grows.