You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In primer_view_components we use kwargs for most of our components, so we can easily modify some simpler css (like margins, background colors...). An example:
When I'm writing a story, I wanted to show examples with different margins. This would be something like
classPrimer::BoxComponentStories < ViewComponent::Storybook::Storieslayout"storybook_preview"story(:box)docontrolsdoselect(:m,[1,2,3],1)endcontentdo"This is a div"endendend
which would be the same as calling Primer::BoxComponent.new(m: 1)
But, this is raising an error due the component_params validation, since m is not directly defined as a parameter name from initialize
a fix would be to check if there is a :keyrest type parameter, which indicates that the method receives a **kwarg parameter and in that case any control name should be accepted.
The text was updated successfully, but these errors were encountered:
👋 Hello there!
In primer_view_components we use kwargs for most of our components, so we can easily modify some simpler css (like margins, background colors...). An example:
When I'm writing a story, I wanted to show examples with different margins. This would be something like
which would be the same as calling
Primer::BoxComponent.new(m: 1)
But, this is raising an error due the
component_params
validation, sincem
is not directly defined as a parameter name frominitialize
https://github.com/jonspalmer/view_component_storybook/blob/1631e9cfcbaa9936f86f8b9d5f2bda44ede48f1a/lib/view_component/storybook/controls/control_config.rb#L33-L35
a fix would be to check if there is a
:keyrest
type parameter, which indicates that the method receives a**kwarg
parameter and in that case any control name should be accepted.The text was updated successfully, but these errors were encountered: