view_component_storybook
view_component_storybook copied to clipboard
Allow rendering of polymorphic slots
Polymorphic slots are an experimental feature, but I've found them to be quite useful so I'm pulling for their stability.
https://viewcomponent.org/guide/slots.html#polymorphic-slots-experimental
I've started a patch that allows their use in ViewComponent::Storybook, but it requires a bit of TLC. It is built on the support for nested components from #109.
Here's the patch:
https://github.com/dark-panda/view_component_storybook/commit/07de5e95c1136e798e65c6603766a8e6ce446ca9
Not the nicest looking patch and it could stand to be cleaned up, but it appears to be working at the moment.
Thanks for the contribution. Can you perhaps create the pull request where we have a few more tools to discuss and look at the code?
The patch you linked too is certainly pretty expansive. I'm curious about why it's so complex. I remember similar kind of logic in this repo that was ultimately much simplified by adding slot_type
to view_component: https://github.com/github/view_component/pull/1009
I wonder would the logic simplify here if we added Polymorphic support to slot_type there too?
It's been a while since I worked on the code, but I think the basic gist of it had something to do with the way that polymorphic slot names are generated, and how the nesting in polymorphic slots work. It's been a few months now but that's more or less what I recall. The patch could likely be simplified a bit, of course, but it does presently work as far as I can tell.
Circling back to this conversation I'm curious if you have thoughts on the discussion in #150
fixed in v1.0.0