Live data from Hacker News

Ruby on Rails: View Components, Storybook and Tailwind - a match made in heaven?

finnian.io

21–30 of 44 posts

Re: Ruby on Rails: View Components, Storybook and Tailwind - a match made in heaven?

#22
post #7
post #3

I've used view component heavily over the last year or so, it's an amazing library. It perfectly fits the gap between helpers and partials and really does help keep things well organised. I maintain a library of components and being able to spin up a new project and hit the ground running makes for a great experience. I'm looking at documenting with lookbook instead of storybook, but both look decent. https://github.…

The more stuff like this I see (Rails view components and HTML over the wire) the more I realize how, for lack of a better word, "advanced" ASP.Net MVC was over 10 years ago...

haha my exact thoughts

Re: Ruby on Rails: View Components, Storybook and Tailwind - a match made in heaven?

#23
post #7
post #3

I've used view component heavily over the last year or so, it's an amazing library. It perfectly fits the gap between helpers and partials and really does help keep things well organised. I maintain a library of components and being able to spin up a new project and hit the ground running makes for a great experience. I'm looking at documenting with lookbook instead of storybook, but both look decent. https://github.…

The more stuff like this I see (Rails view components and HTML over the wire) the more I realize how, for lack of a better word, "advanced" ASP.Net MVC was over 10 years ago...

Some people just wont shut up about this. Sure, requiring a server to display some html is really "advanced", doubly so when you use a dozen of "technologies" because a js only codebase is lame.

Re: Ruby on Rails: View Components, Storybook and Tailwind - a match made in heaven?

#24
post #9
post #7

Earlier quoted context omitted.

The more stuff like this I see (Rails view components and HTML over the wire) the more I realize how, for lack of a better word, "advanced" ASP.Net MVC was over 10 years ago...

Yeah, that's undoubtedly the case. Rails appears to have (Apple-style) taken some cues from elsewhere and made the user experience actually nice.

They were truly one of the first frameworks to give a hoot about developer experience

Re: Ruby on Rails: View Components, Storybook and Tailwind - a match made in heaven?

#25
post #21
post #13

Equivalent for Django?

Maybe django-components, if you need something a bit higher level than plain include or inclusion tags: https://github.com/EmilStenstrom/django-components/

Is it worth adopting? I hesitate adding more dependencies to projects unless it provides a LOT of value.

Re: Ruby on Rails: View Components, Storybook and Tailwind - a match made in heaven?

#26
I've recently discovered Slippers [1] which provides something very similar but for Django Templates. I've tried it in a side project and it is amazing. I'm pairing it with Unpoly [2] and Tailwind and honestly, I wouldn't try to build and SPA ever again unless I need full offline support.

[1] https://mitchel.me/slippers/

[2] https://unpoly.com

Re: Ruby on Rails: View Components, Storybook and Tailwind - a match made in heaven?

#28
post #21
post #13

Equivalent for Django?

Maybe django-components, if you need something a bit higher level than plain include or inclusion tags: https://github.com/EmilStenstrom/django-components/

I've tried this and, honestly, I don't like it. Reason number one is how verbose it becomes on the templates when you have to pass a "body", it's at least 4 tags... when you have many nested tags it becomes messy. And then the worst offender to me is that it doesn't isolate the context from the parent template (you have to add the 'only' keyword like with includes), etc. I mean, it was my first option until I found Slippers which for my taste, makes the right trade offs and design decisions.

Re: Ruby on Rails: View Components, Storybook and Tailwind - a match made in heaven?

#30
post #25
post #21

Earlier quoted context omitted.

Maybe django-components, if you need something a bit higher level than plain include or inclusion tags: https://github.com/EmilStenstrom/django-components/

Is it worth adopting? I hesitate adding more dependencies to projects unless it provides a LOT of value.

In my opinion, it is!

Imagine you have a dropdown, or a list of items, etc which is composed of more than one single markup element, such as a couple divs, an ul and a li for each element. Wrapping all of this into a component helps reusing this parameterized component in as many places as you need. You might think why not just use "includes"? Well, includes are great for very simple use cases, but for example, you cannot pass a "body" of html to them (imagine you want a "ListWrapper" component, etc) among other shortcomings. Thinking in components makes things a lot easier in my opinion.

Post reply on HN