Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #43 from rafaelfranca/create_documentation
[WIP] - Create the documentation for the integration of Simple Form and Bootstrap.
- Loading branch information
Showing
14 changed files
with
1,280 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,6 @@ | |
//= require jquery | ||
//= require jquery_ujs | ||
//= require bootstrap | ||
//= require rainbow | ||
//= require ruby | ||
// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
/* | ||
*= require bootstrap | ||
*= require github | ||
*/ | ||
|
||
body { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class DocumentationController < ApplicationController | ||
def index | ||
@user_basic = User.new | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
<%%= simple_form_for @user_basic, url: create_basic_examples_url, as: 'user_basic' do |f| %> | ||
|
||
<%%= f.input :email, placeholder: 'Enter email' %> | ||
|
||
<%%= f.input :password, placeholder: 'Password' %> | ||
|
||
<%%= f.input :file, as: :file, wrapper: :vertical_file_input %> | ||
|
||
<%%= f.input :active, wrapper: :vertical_boolean %> | ||
|
||
<%%= f.input :choices, as: :check_boxes, | ||
collection: [ | ||
'Option one is this and that—be sure to include why it\'s great', | ||
'Option two can be something else and selecting it will deselect option one'], | ||
wrapper: :vertical_radio_and_checkboxes %> | ||
|
||
<%%= f.input :sex, as: :radio_buttons, | ||
collection: ['Male', 'Female'], wrapper: :vertical_radio_and_checkboxes %> | ||
|
||
<%%= f.button :submit %> | ||
<%% end %> |
27 changes: 27 additions & 0 deletions
27
app/views/documentation/form_example_with_wrapper_mappings.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
|
||
<%%= simple_form_for @user_basic, url: create_basic_examples_url, as: 'user_basic', | ||
wrapper_mappings: { | ||
check_boxes: :vertical_radio_and_checkboxes, | ||
radio_buttons: :vertical_radio_and_checkboxes, | ||
file: :vertical_file_input, | ||
boolean: :vertical_boolean | ||
} do |f| %> | ||
|
||
<%%= f.input :email, placeholder: 'Enter email' %> | ||
|
||
<%%= f.input :password, placeholder: 'Password' %> | ||
|
||
<%%= f.input :file, as: :file %> | ||
|
||
<%%= f.input :active %> | ||
|
||
<%%= f.input :choices, as: :check_boxes, | ||
collection: [ | ||
'Option one is this and that—be sure to include why it\'s great', | ||
'Option two can be something else and selecting it will deselect option one'] %> | ||
|
||
<%%= f.input :sex, as: :radio_buttons, | ||
collection: ['Male', 'Female'] %> | ||
|
||
<%%= f.button :submit %> | ||
<%% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<% content_for :breadcrumb do %> | ||
<li><%= link_to "Home", root_path %></li> | ||
<li class="active">Documentation</li> | ||
<% end %> | ||
|
||
<div class='row'> | ||
<h3>How to build your Rails application with Simple Form and Bootstrap</h3> | ||
</div> | ||
|
||
<div class='row'> | ||
<h4>Configuring your Rails app with Simple Form and Bootstrap</h4> | ||
<ol> | ||
<li>Create your new Rails application: <code>rails new my_new_app</code></li> | ||
<li>Open the generated Gemfile and add the Simple Form dependency: <code>gem 'simple_form'</code></li> | ||
<li>Install the dependencies: <code>bundle install</code></li> | ||
<li>Install the Simple Form, using the --bootstrap option: <code>rails generate simple_form:install --bootstrap</code></li> | ||
<li>Now you have a new Rails application using Simple Form and configured to use Bootstrap</li> | ||
</ol> | ||
</div> | ||
|
||
<div class='row'> | ||
<h4>Building your first form</h4> | ||
|
||
<p>Example: Lets build the following form.</p> | ||
</div> | ||
|
||
<div class='row'> | ||
<%= render partial: 'examples/basic_example_sf', layout: 'examples/sf_label', locals: { title: 'Basic Form' } %> | ||
</div> | ||
|
||
<div class='row'> | ||
<p>The code is straightforward and looks like this:</p> | ||
|
||
<pre> | ||
<code data-language='ruby'> | ||
<%= render file: 'documentation/form_example' %> | ||
</code> | ||
</pre> | ||
</div> | ||
|
||
<div class='row'> | ||
<p>The code is very simple, isn't it?</p> | ||
|
||
<p> | ||
But it can get better! We can use the <code>wrapper_mapping</code> option | ||
to remove that wrapper duplication. This option receives a Hash containing an input | ||
type and the wrapper that will be used for all inputs with specified type. | ||
</p> | ||
|
||
<p> | ||
Example: | ||
<pre> | ||
<code data-language='ruby'>{ string: :string_wrapper, boolean: :boolean_wrapper }</code> | ||
</pre> | ||
|
||
All the String inputs will now use the <code>:string_wrapper</code>, and the | ||
same applies to boolean fields, which will use the <code>:boolean_wrapper</code> | ||
for all its inputs. | ||
You can see more information about wrapper_mappings | ||
<%= link_to 'here.', 'https://github.com/plataformatec/simple_form/blob/v3.0.2/lib/simple_form.rb#L107-L111' %> | ||
</p> | ||
</div> | ||
|
||
<div class="row"> | ||
<pre> | ||
<code data-language='ruby'> | ||
<%= render file: 'documentation/form_example_with_wrapper_mappings' %> | ||
</code> | ||
</pre> | ||
</div> | ||
|
||
<div class="row"> | ||
<p> | ||
Simple, right? You can see the code for the other examples | ||
<%= link_to 'on GitHub.', 'https://github.com/rafaelfranca/simple_form-bootstrap' %> | ||
</p> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.