mountain_view icon indicating copy to clipboard operation
mountain_view copied to clipboard

Adding a wrapper in the style guide

Open ChristineP2 opened this issue 6 years ago • 3 comments

Hey, sorry I haven't had any PRs recently, work is intense.

I've been pondering how useful it would be to be able to have the ability to insert the example into a partial in the style guide.

So, if you wanted to show how a complex form component would display within your simple_form, you could create a partial with the form setup, then display the example within that partial.

Would that make sense to add? All I could think of was using content_for to capture the sample component and if there was a partial, that would use the capture, if there wasn't a partial, then we'd display the content_for directly.

I am sure there are other options as well, what thoughts do you have on this one?

ChristineP2 avatar Feb 23 '19 05:02 ChristineP2

This is a very interesting proposition and can potentially solve a bunch of issues! :) Thanks for proposing this! And no worries at all about PRs, there's no pressure and life's busy!

Do you have any ideas how the final API could look like, from the user perspective? Like, how would an example with this wrapper look like in the yaml?

I'm trying to think how the easiest way for the user to do this without interfering with regular component usage in your views. I'll give it some thought as well and come up with a few options, but curious to know how you envision this from the user perspective, as it's a great idea!

kitop avatar Feb 24 '19 10:02 kitop

I was going to try out a theory tonight, but I ended up fussing with the demo app for quite some time after re-checking it out. I forgot I had to update pg to 1.1.3 in order for it to work on windows (in addition to adding tz-info).

My current theory is that I'll be looking for the key partial within the mv_stub_meta. If the key is present and has a valid partial, the component would be loaded into content_for :mv_component, and the partial would be rendered with the expectation that it will load :mv_component in content_for. If there was not a partial in mv_stub_meta the component would be rendered as it is now. I believe I may have to use the index number for the loop and send that into the partial in order to make it unique... but I'd like to give it a try to work out the details...

ChristineP2 avatar Mar 11 '19 04:03 ChristineP2

I made a PR (#88) with the general concept I was going for. Let me know what you think

ChristineP2 avatar Mar 24 '19 21:03 ChristineP2