view_component_storybook icon indicating copy to clipboard operation
view_component_storybook copied to clipboard

Allow rendering of polymorphic slots

Open dark-panda opened this issue 2 years ago • 3 comments

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.

dark-panda avatar Apr 28 '22 20:04 dark-panda

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?

jonspalmer avatar Apr 28 '22 21:04 jonspalmer

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?

jonspalmer avatar Jul 30 '22 12:07 jonspalmer

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.

dark-panda avatar Aug 08 '22 13:08 dark-panda

Circling back to this conversation I'm curious if you have thoughts on the discussion in #150

jonspalmer avatar Dec 12 '22 01:12 jonspalmer

fixed in v1.0.0

jonspalmer avatar Jan 07 '23 20:01 jonspalmer