Is there a way to dynamically change the ArgTypes
when args
of a components changes in Storybook?
For instance, suppose a strory with a component that has 2 controls: id
and value
.
id
can either be 1
or 2
.
If id == '1'
then argTypes.value.control.min = 0
, else argTypes.value.control.min = -100
.
Example code:
export default {
argTypes: {
id: { control: { type: 'select', options: ['1', '2']}},
value: { control: {type: 'range', min:0, max: 100, step:10}},
}
};
const Template = (args) => <MyComponent {...args} />;
export const Example = Template.bind({});
Template.args = {
id: '1',
value: 0,
};