README.md in foundation_rails_helper-0.5.0 vs README.md in foundation_rails_helper-1.0.0

- old
+ new

@@ -1,54 +1,62 @@ -# FoundationRailsHelper [![Build Status](https://secure.travis-ci.org/sgruhier/foundation_rails_helper.png)](http://travis-ci.org/sgruhier/foundation_rails_helper) +# Foundation Rails Helper [![Build Status](https://secure.travis-ci.org/sgruhier/foundation_rails_helper.png)](http://travis-ci.org/sgruhier/foundation_rails_helper) -Gem for Rails 4.1.x applications that use the excellent Zurb Foundation framework. +Gem for Rails 4.1+ applications that use the excellent Zurb Foundation framework. * [Zurb Foundation](https://github.com/zurb/foundation) * [Zurb Foundation Rails](https://github.com/zurb/foundation-rails) So far it includes: -* A custom FormBuilder that generates a form using the Foundation framework. It replaces the current `form_for` so you don't have to change your Rails code. Error messages are properly displayed. +* A custom FormBuilder that generates a form using the Foundation framework classes. It replaces the current `form_for`, so there is no need to change your Rails code. Error messages are properly displayed. * A `display_flash_messages` helper method that uses Zurb Foundation Alerts UI. #### Compatibility -* Only Rails 4.1 and Foundation 4 and 5 are fully supported -* Some features may work with Foundation 3 and older, but results may vary, and markup which exists only for those versions will be gradually removed -* Legacy branches exist for Rails 3 and 4.0 (see the rails3 and rails4.0 branches). These are not actively supported, and fixes are not retroactively applied, but pull requests are welcomed. +* Only Rails 4.1/4.2 and Foundation 5 are fully supported +* Some features may work with Foundation 4 and older, but results may vary, and markup which exists only for those versions will be gradually removed +* Legacy branches exist for Rails 3 and 4.0 (see the rails3 and rails4.0 branches). These are not actively supported, and fixes are not retroactively applied, but pull requests are welcome. ## Screenshots ### Forms A classic devise sign up view will look like this: ```erb <%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %> - <%= f.email_field :email %> + <%= f.email_field :email, label: 'E-mail' %> <%= f.password_field :password %> <%= f.password_field :password_confirmation %> <%= f.submit %> <% end %> ``` <table> - <tr> - <th>Form</th> - <th>Form with errors</th> - </tr> - <tr> - <td valign='top'> <img src="http://dl.dropbox.com/u/517768/sign-up.png"/></td> - <td valign='top'> <img src="http://dl.dropbox.com/u/517768/sign-up-with-errors.png"/></td> - </tr> + <thead> + <tr> + <th>Form</th> + <th>Form with errors</th> + </tr> + </thead> + <tbody> + <tr> + <td valign='top'> + <img src="https://cloud.githubusercontent.com/assets/1400414/5994195/d9b467ce-aa1e-11e4-914c-f696724b53ed.png"/> + </td> + <td valign='top'> + <img src="https://cloud.githubusercontent.com/assets/1400414/5994196/dbf4bc0a-aa1e-11e4-8c18-b7d3b1b370dc.png"/> + </td> + </tr> + </tbody> </table> ### Flash messages -![Flash-message](http://dl.dropbox.com/u/517768/flash.png "Flash-message") +![Flash-message](https://cloud.githubusercontent.com/assets/393167/5845238/563dc094-a1b2-11e4-8548-2dd2950a60be.png "Flash-message") ## Installation Add this line to your application's Gemfile: @@ -63,44 +71,32 @@ $ bundle ``` ### Flash Messages -To get access to `display_flash_messages` in your views, add +To use the built in flash helper, add `<%= display_flash_messages %>` to your layout file (eg. *app/views/layouts/application.html.erb*). -```ruby -include FoundationRailsHelper::FlashHelper -``` - -to `app/helpers/application_helper.rb` - ## Usage ### form_for -Form_for wraps the standard rails form_for helper and adds a 'nice' class by default. +Form_for wraps the standard rails form_for helper. ```erb <%= form_for @user do |f| %> ... <% end %> ``` generates: ```html -<form accept-charset="UTF-8" action="/users" class="nice" id="new_user" method="post"> +<form accept-charset="UTF-8" action="/users" class="new_user" id="new_user" method="post"> ... +</form> ``` -Override the default class like so: - -```erb -<%= form_for(@user, html: {class: 'mean'}) do |f| %> - ... -``` - ### text_field and Field Helpers Field helpers add a label element and an input of the proper type. ```ruby @@ -109,25 +105,13 @@ generates: ```html <label for="user_email">Name</label> -<input class="medium input-text" id="user_name" name="user[name]" type="text"> +<input id="user_name" name="user[name]" type="text"> ``` -The 'input-text' class will always be added to the input element, but the 'medium' class can be replaced. - -```ruby -f.text_field :name, class: 'large' -``` - -generates: - -```html -<input class="large input-text" ... > -``` - Prevent the generation of a label: ```ruby f.text_field :name, label: false ``` @@ -175,33 +159,35 @@ ``` generates: ```html -<label class=" error" for="user_email">Email</label> -<input class="medium input-text error" id="user_email" name="user[email]" type="email" value=""> -<small class="error medium input-text error">can't be blank</small> +<label class="error" for="user_email">Email</label> +<input class="error" id="user_email" name="user[email]" type="email" value=""> +<small class="error">can't be blank</small> ``` The class attribute of the 'small' element will mirror the class attribute of the 'input' element. If the `html_safe_errors: true` option is specified on a field, then any HTML you may have embedded in a custom error string will be displayed with the html_safe option. -## TODO +## Configuration +Add an initializer file to your Rails app: *config/initializers/foundation_rails_helper.rb*. See below for current options. -* Handle more UI components -* Make something for ajax forms +### Submit Button Class +To use a different class for the [submit button](https://github.com/sgruhier/foundation_rails_helper#submit-button) used in `form_for`, add a config named **button_class**. Please note, the button class can still be overridden by an options hash. +```ruby +FoundationRailsHelper.configure do |config| + # Default: 'small radius success button' + config.button_class = 'large secondary button' +end +``` ## Contributing -1. Fork it -2. Create your feature branch (`git checkout -b my-new-feature`) -3. Commit your changes (`git commit -am 'Added some feature'`) -4. Push to the branch (`git push origin my-new-feature`) -5. Create a new Pull Request +See the [CONTRIBUTING](CONTRIBUTING.md) file. ## Copyright -Sébastien Gruhier (http://xilinus.com, http://v2.maptimize.com) - MIT LICENSE - 2012 +Sébastien Gruhier (http://xilinus.com, http://v2.maptimize.com) - MIT LICENSE - 2015 [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/sgruhier/foundation_rails_helper/trend.png)](https://bitdeli.com/free "Bitdeli Badge") -