【问题标题】:@storybook/addon-controls: howto not auto-generate control for a certain prop@storybook/addon-controls:如何不为某个道具自动生成控件
【发布时间】:2020-10-19 19:42:43
【问题描述】:

@storybook/addon-controls 很有趣,但是我找不到为给定 arg 禁用控件生成的方法。假设我有一个组件道具,它是一个事件处理程序,我显然不希望它有一个控件。所以我希望它出现在带有名称、类型和描述的道具列表中,但没有控制权。我该怎么做?

【问题讨论】:

    标签: reactjs storybook


    【解决方案1】:

    这是最近添加的:https://github.com/storybookjs/storybook/pull/11388 从本质上讲,您应该能够在 argTypes 中为给定的 arg 使用 control.disable

    假设您有一个包含 foobar 属性(自动生成或以其他方式)的故事,并且您想完全隐藏 foo 行并禁用特定故事上 bar 行的控件:

    MyStory.argTypes = {
      foo: { table: { disable: true } },
      bar: { control: { disable: true } },
    };
    

    这是docs 中的条目。

    干杯

    【讨论】:

    • 也许用一个实际的例子来更新它,而不仅仅是链接外部资源 - 链接将来可能会中断,但你的答案应该保持自我可持续发展。
    • 即使经过上述更改,似乎也无法在控件中显示arg,而是将其隐藏在表格中
    • {table: {disable: true}}{control: {disable: true}}有什么区别
    猜你喜欢
    • 2021-07-05
    • 2023-03-16
    • 2021-09-11
    • 2011-02-26
    • 2019-03-06
    • 2022-12-03
    • 2019-06-02
    • 1970-01-01
    • 2023-03-13
    相关资源
    最近更新 更多