如何最好地将全局切换添加到Storybook中以执行自定义JS

发布于 2025-01-22 07:11:28 字数 328 浏览 3 评论 0原文

Storybook 中,我想添加一个全局控制,基本上是一个下拉列表,我可以在两个或多个值之间切换。选择一个值应执行自定义JS脚本(在其中使用所选值)。这样做的最好方法是什么?

用户酶 我有一个带有两个或多个主题的主题对象const主题= {light:{},dark:{},颜色:{}}> 哪个记录了使用的颜色。我想动态选择的那些,然后从中创建CSS变量,然后将它们注入文档头部。所有这些都来自Storybook,它应该一直影响所有组件,因此我想一个全局切换或选择。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文