Benito Serna Tips and tools for Ruby on Rails developers

Styler and tachyons examples

January 28, 2022

I built a tool to comples css classes like this…

styles = Styler.new do
  style :default, ["pa3", "white", "bg_blue"]
  style :danger, [default - "bg_blue", "bg_red"]
end

styles.default.to_s # => "pa3 white bg_blue"
styles.danger.to_s # => "pa3 white bg_red"

… because I think that, although css is awesome (really!), I think that it misses is the ability to compose already defined styles, to define new ones.

In the introduction post and on github, you can find a tutorial of how the tool works.

But until now there was no “real” examples of how to use it.

A collection of examples

That is why I am building a site with some examples from the list of tachyons components from the Tachyons’s page, to show you how you can use the the gem to define the styles.

You can visit the site on styler-tachyouns-examples.bhserna.com.

The code of the site

If you want to help to add more examples, or you want to see how I used the tool to style the site, or if you are curious about how it was build, you can see the code on github/bhserna/styler_tachyons_examples.

How do you think that this tool can help you?

I know that maybe it is a little unexpected way of doing things, but if you have have some ideas on how this tool can help you it would be nice to know them.

You can write a comment here or tell me via twitter.

Related articles

Subscribe to get future posts via email

Here I try to share knowledge and fixes to common problems and struggles for ruby on rails developers, like How to fetch the latest-N-of-each record or How to test that an specific mail was sent or a Capybara cheatsheet. You can see more examples on Most recent posts or all posts.