Home

Awesome

Rocks

This is a tiny library of mixins and styles for developing large-ish stylesheets with Sass.

I extracted these styles from a bunch of larger-than-average projects I have worked on, as I found I was repeating myself over and over again. There is nothing groundbreaking in here, just a useful collection of snippets to build your own stylesheets with.

This library does not aim to help you write CSS, but better stylesheets. It provides re-usable components and patterns to help you simplify styling common objects on your page.

The contents of this project are in partly homegrown and partly borrowed from projects like Blueprint, Compass and many others.

Note: this is very much a work in progress. Mind the gap.

Installation

Installation for Rails 3.1+ projects

Include Rocks in your Gemfile:

gem 'rocks'

Let Bundler install it:

$ bundle install

Make sure your application.css file is compiled by Sass by renaming it to application.css.scss. Import the Rocks stylesheets:

@import "rocks";

Add your own styles and imports below that.

Note if you also include Bourbon in your project, make sure put @import "bourbon"; before @import "rocks";, as per its installation instructions.

Installation for non-Rails 3.1+ projects

Unsupported so far. I may write a simple installer script one day that automatically copies all the stylesheets into a directory of your choosing. For now, you'll have to do that manually.

If you are using Sass directly, you could try to just add the Rocks gem to load_path, using something like the following:

Sass::Engine.new(my_stylesheet,
  :syntax => :scss,
  :load_path => [
    File.join(`bundle show rocks`, 'app', 'assets', 'stylesheets')
  ]
 )

This would allow you to @import 'rocks'; in the my_stylesheet file.

Contents

Grid

Contains functions and mixins for working with a grid-based layout. The grid is based on variables $grid-column-width and $grid-margin. It provides the following functions:

The difference between span and columns is inclusion of $grid-margin at the end.

It contains the following mixins:

Layout

Contains simple layout helper mixins:

All of leading, trailing, voutset-top and voutset-bottom can take both pixel values as arguments, or a unit-less number. When given a unit-less number, it will be fed to the lines function.

When using any of the voutset mixins, you can add an optional $border argument to reduce the amount of padding that is applied, leaving room for a border on element while preserving vertical rhythm.

It also contains a plain class .clearfix that you can use in your HTML. It is meant, however, to be used with @extend. When your stylesheet needs a lot of clearfixes, the end result will contain a lot of duplicated code. Using @extend .clearfix you can define the class once, and simply apply many selectors to it.

Links

Provides mixins for common link behaviours:

Lists

Provides basic building blocks for styling lists:

Reset

Provides a single reset mixin that reset all styles. You probably want to mix this into your body selector, but you could also use it for a local reset in a specific element.

Type

Defines the following variables:

Defines the following functions:

It defines the following mixins:

History

See CHANGELOG.md for a full of changes.

Credits

Author: Arjan van der Gaag
URL: http://arjanvandergaag.nl

License

See the LICENSE file for more information.