view_component_storybook icon indicating copy to clipboard operation
view_component_storybook copied to clipboard

Enable rendering of nested components

Open jklina opened this issue 3 years ago • 5 comments

This alters how slots are rendered on the view story page. The main change has the slots render themselves rather then evaluating the contents of the slots' block outside of the slots' context. This should allow stories to render nested slots which I don't believe is currently possible.

jklina avatar Dec 15 '21 15:12 jklina

I'd like to understand a slightly larger use case than is shared in the tests. I have concern that this approach isn't going to work in some cases. The reason we do instance_eval when rendering content_block (for the component or the slots) is that it allows the correct rendering of slots that use various view helpers etc. I think we'd want that to be true for nested components too?

jonspalmer avatar Jan 15 '22 13:01 jonspalmer

@jklina @jonspalmer I believe you'd be able to combine both the use of helpers with nested components using the following addition to this PR:

https://github.com/dark-panda/view_component_storybook/commit/ec07f4261d16e6608d3562f7808819056358e8b7

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

@jklina @dark-panda I've added a slightly deeper example to the specs and included the suggested patch. I think we now get nested slots and helpers. Please take a look and see if these supports the use cases you'd expect. Happy to merge and release a new version if it does.

jonspalmer avatar Aug 06 '22 14:08 jonspalmer

This looks great! Thank you and @dark-panda for taking this over the finish line! 👊

jklina avatar Aug 08 '22 12:08 jklina

Cheers, I'll give this a shot soon to see how it looks on my end.

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