Skip to main content

Making a gem like thoughtbot's refills gem

Gems / Libraries • Asked by Josh Sandlin

Heya,

I saw on HN the other day that USDS has released a styleguide/component system based off of Bourbon. I'd like to toy around with making a gem based off of the Refills gem that allows me to list out components and then "import" them (sticking their styles, erb templates, and js into a directory in app/assets).

Initially I was just going to fork the Refills gem and swap out the assets it generates, but I'm still relatively new to Rails, and I can't see the forest for the trees there. I know logically what it's doing, but everything seems very well connected to how they have things organized.

Would it be worth while to migrate the USDS assets to a "form-factor" that agrees with the Refills gem layout, or to try and roll my own using the USDS "form-factor".

Ideally, I'd like to just be able to type "rails generate wds:list" and then rails generate wds:import SNIPPET" like I can do with Refills.

I hope that makes sense.


Hey Josh,

I would love to see this! I think what you're looking for is learning how to create generators that install things from a gem. I've been building the simple_calendar gem and made an episode on how you can create generators that should be helpful. https://gorails.com/episodes/vlog-day-13?autoplay=1

The next step after you get a basic generator done is to take a look at the refills gem and see how they build the "import" generator. I'm not entirely sure, but it should be a good basis on how to do that. I've yet to dive into any of the USDS styleguides, but this would be a really really cool gem to make and should help adoption of it a lot. You'd be famous if you get this built. :)


Thanks!

I've given myself some motivation to get this going by entering it into this year's Octobuild (http://octobuild.com/) (https://github.com/dydx/usds-wds).

So far it sort of works, though I've still got a few weeks to iron out the kinks.


Octobuild sounds like an awesome idea! I hadn't heard of it. Thanks for sharing that!

Also awesome start to the USDS project! It looks great so far. Nice and simple. :)


Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 27,623+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.