My FeedDiscussionsHashnode Enterprise
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more
Borris

13 likes

·

114 reads

3 comments

Borris
Borris
Author
·May 24, 2024

As simple as that to configure the next/font with your storybook

1
·
Alex Mongeot
Alex Mongeot
Jun 19, 2024

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.

1
·
·1 reply
Borris
Borris
Author
·Jun 19, 2024

Definitely interesting idea, will definitely try it out. The story rendering part should be isolated, so it should be new afresh on every story - hence I will have to check if the class is being reset or not on each story rendering. Thanks for the suggestion - will keep up to date with this as well after trying it out.

1
·