how to best add global toggle to storybook to execute custom JS

387 views Asked by At

Within storybook I'd like to add a global control, basically a dropdown where I can switch between two or more values. Selecting one value should execute a custom JS scrip (in which I use the selected value). What is the best way of doing this?

usecase I have a theme object with two or more themes const themes = {light: {}, dark:{}, color:{}} which documentes the used colors. Those I want to dynamically select, then create CSS variables out of them and inject them into the documents head. All from within storybook and it should effect all components all the time, so a global toggle or select I thought.

0

There are 0 answers