{"id":4149,"date":"2014-08-13T09:00:39","date_gmt":"2014-08-13T12:00:39","guid":{"rendered":"http:\/\/blog.plataformatec.com.br\/?p=4149"},"modified":"2014-08-12T16:34:39","modified_gmt":"2014-08-12T19:34:39","slug":"css-at-plataformatec","status":"publish","type":"post","link":"http:\/\/blog.plataformatec.com.br\/2014\/08\/css-at-plataformatec\/","title":{"rendered":"CSS at Plataformatec"},"content":{"rendered":"
Last month some amazing developers gave a sneak peek on how they write CSS in their companies – Mark Otto has written about CSS at GitHub<\/a>, followed by Ian Feather’s post about Lonely Planet’s CSS<\/a> and Chris Coyier write up about CodePen’s code<\/a> – so I thought about sharing a bit of how we have been doing CSS in our projects here at Plataformatec over the last years.<\/p>\n After working on different projects with different styles of CSS, we wrote some Guidelines<\/a> of what kind of code we would like to work with. These guidelines and some other practices have proven to be successful so far, and I want to tell you a bit about how we are doing this here.<\/p>\n We have always used Sass (with the SCSS syntax), using most of the Sass features wherever seemed fit and without making the code too complex to grasp so developers outside the project – or without a long experience with preprocessors – could get things done right after jumping in the code.<\/p>\n We do our best to use the most of the Rails Asset Pipeline<\/a>. I know that it isn’t the most beloved Rails feature out there, but we are pretty happy with it. The Sprockets + Rails integration in Rails 4 is way better than it was before (you can read a bit about what was done on this post<\/a>), thanks to the work of Guillermo<\/a>, Rafael<\/a> and Richard<\/a> (the Sprocket heroes) and everybody else who contributed to sprockets-rails<\/a>, and things will only get better on future releases. If you had a hard time with a Rails 3 app, I recommend that you try it out the latest releases and see what have improved.<\/p>\n We don’t have strict guidelines about how we should organize and architect our CSS code, but we have some general rules and conventions. We organize most of our code into isolated partial stylesheets under something like We do our best to keep our selectors small and using only classes, somewhat based on Wealthfront post on Functional CSS<\/a> and OOCSS-ish. With this setup we can avoid complex nested blocks and keep things quite readable for everybody.<\/p>\n We don’t have a specific guideline on linting, but I have been experimenting with SCSS Lint<\/a> on the project that I\u2019m current working on, and I want to evolve this into a default configuration for future projects.<\/p>\n We have some different setup across our projects, but we usually just have Normalize.css<\/a> as our “reset” stylesheet and everything else is custom made – buttons, grids, typography rules, etc. And of all the existing CSS frameworks out there, we had some encounters with Bootstrap<\/a> and Foundation<\/a> once.<\/p>\n We love documentation – not obvious code comments, but real documentation that makes easier to understand how to use a specific piece of code.<\/p>\n We started writing docs for our CSS to make more sense out of a SCSS partial, so through a single file we can understand how the application can use those styles. We have adopted some loose form of the KSS<\/a> syntax, because we currently don’t care about generating pretty styleguides with live examples of the styles in use. But the KSS format is human-readable enough and does the job of explaining the purpose of a set of classes to someone.<\/p>\n Last year I created a gem called Spriteful<\/a> to help us manage the image sprites in some projects without having to bring Compass<\/a> and compass-rails<\/a> as dependencies to our pipeline. Spriteful has proven useful to me and my coworkers, and now we can generate sprites and SCSS partials out of icons and SVG images with just a single command.<\/p>\n Some close friends from outside the company have used it on their projects and it’s awesome that someone else has found our little tool handy for this task.<\/p>\n One important aspect of how we work is that every developer in the team is capable to work with the front end code of the application and build new things or fix existing bugs, not just turn some static markup into ERB blocks. This provides a higher sense of collective ownership of the code, instead of enlisting one or two programmers who are in charge of half of the application while everybody else works elsewhere without caring about that layer.<\/p>\n \n <\/a><\/span><\/span> Last month some amazing developers gave a sneak peek on how they write CSS in their companies – Mark Otto has written about CSS at GitHub, followed by Ian Feather’s post about Lonely Planet’s CSS and Chris Coyier write up about CodePen’s code – so I thought about sharing a bit of how we have … \u00bb<\/a><\/p>\n","protected":false},"author":17,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0,"footnotes":""},"categories":[1],"tags":[220,189],"aioseo_notices":[],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"http:\/\/blog.plataformatec.com.br\/wp-json\/wp\/v2\/posts\/4149"}],"collection":[{"href":"http:\/\/blog.plataformatec.com.br\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.plataformatec.com.br\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.plataformatec.com.br\/wp-json\/wp\/v2\/users\/17"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.plataformatec.com.br\/wp-json\/wp\/v2\/comments?post=4149"}],"version-history":[{"count":4,"href":"http:\/\/blog.plataformatec.com.br\/wp-json\/wp\/v2\/posts\/4149\/revisions"}],"predecessor-version":[{"id":4152,"href":"http:\/\/blog.plataformatec.com.br\/wp-json\/wp\/v2\/posts\/4149\/revisions\/4152"}],"wp:attachment":[{"href":"http:\/\/blog.plataformatec.com.br\/wp-json\/wp\/v2\/media?parent=4149"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.plataformatec.com.br\/wp-json\/wp\/v2\/categories?post=4149"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.plataformatec.com.br\/wp-json\/wp\/v2\/tags?post=4149"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}Quick Facts<\/h3>\n
\n
Preprocessors and the Pipeline<\/h3>\n
Architecture<\/h3>\n
modules<\/code> or
components<\/code>. And we also break functions, mixins and generic placeholders into specific files and
@import<\/code> everything on the application
application.css.scss<\/code> file.<\/p>\n
Linting<\/h3>\n
Frameworks<\/h3>\n
Documentation<\/h3>\n
Sprites<\/h3>\n
Who’s in charge?<\/h3>\n
\n<\/p>\n","protected":false},"excerpt":{"rendered":"