Live data from Hacker News

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

finnian.io

11–20 of 44 posts

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

#11
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...

I have a Hotwire post cooking too - stay tuned ;)

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

#12
post #8

Earlier quoted context omitted.

Lookbook _looks_ interesting. We use some React in some places of our app which is why I went with Storybook for now, as I figured we could render both types of components (Rails & React) in the same library, which I thought could be neat. How does Lookbook stack up against Storybook? Always keen to stay in the Ruby ecosystem if possible :-)

I only tested it out a couple of days ago, I'm no expert. So far it's been plain sailing, I'm already familiar with Yard-style docs and getting everything up and running from the spec/dummy app was really straightforward. The library I maintain currently uses a home-rolled docs page ( https://dfe-digital.github.io/govuk-components/ ) that needs to be refreshed manually. It's been an 'ok' approach until now but as it'…

Wow that's awesome, I knew GDS had a design system but didn't realise there was a Ruby implementation.

Quick link for others: https://github.com/DFE-Digital/govuk-components

I'm going to take a look through the repo as I'm sure there's some patterns you've found given you're at a much bigger scale. Any hot tips?

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

#14

Will this get the nod from dhh and make it into Rails? Dhh wdyt?

I'm sure I read somewhere (either on viewcomponent.org or on their GitHub) that their end goal is to merge upstream into Rails core.

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

#15
post #2

I've been using view_components for a while, and there's no going back for me. Much easier to organise views and keep them modular and easy to change and reuse. Only thing I haven't figured out yet is refactoring, how to organise a large number of views into folders / modules without having to move tons of files manually or script it. Tailwind is pretty useful as well, but definitely needs a component system like thi…

Are you using the sidecar setup?

Nope. Does the sidecar create a folder for each component?

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

#16
post #15

Earlier quoted context omitted.

Are you using the sidecar setup?

Nope. Does the sidecar create a folder for each component?

Yep. It's "experimental" but stable. It creates the .rb file at the root and then you can put the template, CSS & JS in a subfolder.

`bin/rails g component Button --sidecar`

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

#17

Will this get the nod from dhh and make it into Rails? Dhh wdyt?

I'm sure I read somewhere (either on viewcomponent.org or on their GitHub) that their end goal is to merge upstream into Rails core.

They merged the ability to hijack the renderer already in Rails 6 I think, which this gem uses. But if they wanted to merge this one into Rails , Rails 7 would have been a good timing. So I'm not really sure this will go into Rails actually.

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

#18

Earlier quoted context omitted.

I'm sure I read somewhere (either on viewcomponent.org or on their GitHub) that their end goal is to merge upstream into Rails core.

They merged the ability to hijack the renderer already in Rails 6 I think, which this gem uses. But if they wanted to merge this one into Rails , Rails 7 would have been a good timing. So I'm not really sure this will go into Rails actually.

Yeah that is a good point. Rails 7 is going with importmaps by default too, further moving away from the JS ecosystem (unless you want it) which would've paired nicely with merging VC.

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

#19
post #8

Earlier quoted context omitted.

I only tested it out a couple of days ago, I'm no expert. So far it's been plain sailing, I'm already familiar with Yard-style docs and getting everything up and running from the spec/dummy app was really straightforward. The library I maintain currently uses a home-rolled docs page ( https://dfe-digital.github.io/govuk-components/ ) that needs to be refreshed manually. It's been an 'ok' approach until now but as it'…

Wow that's awesome, I knew GDS had a design system but didn't realise there was a Ruby implementation. Quick link for others: https://github.com/DFE-Digital/govuk-components I'm going to take a look through the repo as I'm sure there's some patterns you've found given you're at a much bigger scale. Any hot tips?

This isn't _large scale_ yet, we only have about 15 services using this library. I'm hoping that now we've stabilised and are spending time on making things structurally better (removing tech debt, improving the tests, rewriting the docs) that will rise.

My tip would be to not worry too much about covering every last detail or feature immediately, aim to do what most people need most of the time and release early - then if there's demand for extra stuff add it as you go.

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

#20
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...

Could you explain please, for those of us unfamiliar with ASP?
Post reply on HN