Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/mseri/rails-purecss

Integrate pure (purecss.io) to ruby on rails
https://github.com/mseri/rails-purecss

Last synced: about 2 months ago
JSON representation

Integrate pure (purecss.io) to ruby on rails

Awesome Lists containing this project

README

        

# Purecss

Pure is a set of small, responsive CSS modules that you can use in every web project realized by the yahoo developer team.
This gem adds Pure CSS 0.5.0 to the Assets Pipeline of Rails 3.2.

Additionally it provides
- a jQuery function that automatically enables the dropdown menu without the need of additional rails packages/frameworks (YUI or others).
- a small optional set of css for right-aligned horizontal menus, CSS carets (font-independent), vertical separators, alerts, ...

I cite directly from [purecss.io](http://purecss.io)
> CSS with a minimal footprint.
>
> Pure is ridiculously tiny. The entire set of modules clocks in at 5.7KB minified and gzipped, without forgoing responsive styles, design, or ease of use. Crafted with mobile devices in mind, it was important to us to keep our file sizes small, and every line of CSS was carefully considered. If you decide to only use a subset of these modules, you'll save even more bytes.

Note: [will_paginate](https://github.com/mislav/will_paginate) is integrated with purecss pagination style using the [purecss-will_paginate](https://github.com/mseri/rails-purecss-will_paginate) gem.

[![Build Status](https://travis-ci.org/mseri/rails-purecss.png?branch=master)](https://travis-ci.org/mseri/rails-purecss)

## Installation

Add this line to your application's Gemfile:

gem 'purecss'

And then execute:

$ bundle

Then you can add the following directives to your css manifest file (application.css):

*= require purecss

for the responsive bundle, or

*= require purecss-nr

for the non-responsive one.

If you want to include just an individual module (see [purecss.io](http://purecss.io)) add instead

*= require purecss/

If it is too long for you, you can avoid touching the manifest files and run the generator (with optional parameter responsive/nonresponsive):

$ rails generate purecss:install

To add the viewport meta in the head of your application.html.erb it is enough to append `--add_viewport_meta` when you run the generator.

## Usage

After the installation you can simply go to [purecss.io](http://purecss.io) and use their styles.

### Custom CSS

Add to your css manifest file, under the ```require purecss``` line:

*= require purecss-addons

It provides the CSS classes

- ```pure-custom-caret``` for the dropdown menu (to use if you are not using FontAwsome)
- (no more needed) ```pure-menu-custom-separator-vertical``` to add a vertical separator to the horizontal menu
- ```pure-custom-close``` for nicer ```x``` to close eventual modal views (to display modals, bootstrap-modal works quite well with Pure)
- ```pure-custom-alert```, ```pure-custom-alert-error```, ```pure-custom-alert-success```, ```pure-custom-alert-warning```
- ```pure-menu-pull-right``` to align the menu to the right (must be in the same tag of ```pure-menu```, see [this example](http://jsfiddle.net/xUwCw/)). Thanks to [msweeney](https://github.com/msweeney) for this workaround.

### Dropdown Menu

For dropdown menu I developed a small workaround based on [bootstrap-dropdown.js](https://github.com/twitter/bootstrap/blob/master/js/bootstrap-dropdown.js).
It is enough to add the following directive to your js manifest file (application.js):

//= require purecss-dropdown

and then use the class ```pure-menu-has-children``` for the ```li``` that will contain the submenu,
add ```data-toggle="dropdown"``` to its label element (tipically an anchor),
and use the class ```pure-menu-children``` for the ```ul``` that contains the submenu.

I hope it becomes clear with the following example:
```


<%= link_to "sample app", root_path, id: "logo" %>


  • <%= link_to "Home", root_path %>

  • <%= link_to "Help", help_path %>

  • <% if signed_in? %>
  • <%= link_to "Users", users_path %>


  • Account

    • <%= link_to "Profile", current_user %>

    • <%= link_to "Settings", edit_user_path(current_user) %>



    • <%= link_to "Sign Out", signout_path, method: "delete" %>



  • <% else %>
  • <%= link_to "Sign In", signin_path %>

  • <% end %>

```

My dropdown menu code do not support dropdown submenus, for that you can use YUI as in purecss.io example, or pull me a workaround :)

## Contributing

1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request