Open andrewplummer opened 3 years ago
@yannbf This seems similar in spirit to your matchers
parameter. any thoughts?
I was actually expecting a variant of that to work but it's not matching on the name so there didn't appear to be a way...
Also this isn't really a problem with controls unfortunately it appears to be buried deep inside client-api
In addon-controls, custom control types can be configured, however as far is I can tell they can only be explicitly configured with
argTypes
for specific properties. The default is to useradio
when less than 5 options andselect
for larger. This is especially a problem when usingprop-types
as there is no way to know at runtime whether a prop is an enum, so this cannot be dynamically configured.In the meantime this workaround will change all enums to
select
type. You can adjust as needed.Note that this has only been tested on v6.3.8 and will probably break anywhere else.
First, you will need to add a
webpackFinal
entry in.storybook/main.js
and add the following:Now create
.storybook/shims/controls/inferControls.js
and add the following:This will hijack the
inferControls
method of@storybook/client-api
and force any inferredradio
types to beselect
. You can adjust as needed here, for exampleinline-radio
.