Skip to content

Commit

Permalink
Add documentation page for CfaV2FormBuilder
Browse files Browse the repository at this point in the history
Adds text input

Still needs:
- Remaining implemented fields
- Styles for form builder methods
  • Loading branch information
hartsick committed Sep 2, 2020
1 parent ef91444 commit a8652d4
Show file tree
Hide file tree
Showing 17 changed files with 64 additions and 14 deletions.
7 changes: 6 additions & 1 deletion app/controllers/cfa/styleguide/pages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ module Styleguide
class PagesController < ApplicationController
layout "main"

def form_builder
def form_builder_v1
@form = Cfa::Styleguide::FormExample.new
@form.valid?
end

def form_builder_v2
@form = Cfa::Styleguide::FormExample.new
@form.valid?
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@
</div>
</div>
</section>
<%= render 'section', title: 'Input Field', example: 'form_builder/cfa_input_field' %>
<%= render 'section', title: 'Range Field', example: 'form_builder/cfa_range_field' %>
<%= render 'section', title: 'Text area', example: 'form_builder/cfa_textarea' %>
<%= render 'section', title: 'Date select', example: 'form_builder/cfa_date_select' %>
<%= render 'section', title: 'Checkbox set', example: 'form_builder/cfa_checkbox_set' %>
<%= render 'section', title: 'Checkbox set with none', example: 'form_builder/cfa_checkbox_set_with_none' %>
<%= render 'section', title: 'Radio set', example: 'form_builder/cfa_radio_set' %>
<%= render 'section', title: 'Radio set with follow up', example: 'form_builder/cfa_radio_set_with_follow_up' %>
<%= render 'section', title: 'Single tap button', example: 'form_builder/cfa_single_tap_button' %>
<%= render 'section', title: 'Select', example: 'form_builder/cfa_select' %>

<%= render 'section', title: 'Input Field', example: 'form_builder/v1/cfa_input_field' %>
<%= render 'section', title: 'Range Field', example: 'form_builder/v1/cfa_range_field' %>
<%= render 'section', title: 'Text area', example: 'form_builder/v1/cfa_textarea' %>
<%= render 'section', title: 'Date select', example: 'form_builder/v1/cfa_date_select' %>
<%= render 'section', title: 'Checkbox set', example: 'form_builder/v1/cfa_checkbox_set' %>
<%= render 'section', title: 'Checkbox set with none', example: 'form_builder/v1/cfa_checkbox_set_with_none' %>
<%= render 'section', title: 'Radio set', example: 'form_builder/v1/cfa_radio_set' %>
<%= render 'section', title: 'Radio set with follow up', example: 'form_builder/v1/cfa_radio_set_with_follow_up' %>
<%= render 'section', title: 'Single tap button', example: 'form_builder/v1/cfa_single_tap_button' %>
<%= render 'section', title: 'Select', example: 'form_builder/v1/cfa_select' %>
17 changes: 17 additions & 0 deletions app/views/cfa/styleguide/pages/form_builder_v2.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<% content_for(:template_name) { "styleguide" } %>

<section class="slab slab--styleguide">
<div class="grid">
<div class="grid__item">
<h1>CfaV2FormBuilder</h1>
<p class="text--help">CfAV2FormBuilder is a helper that generates accessible form fields for the styleguide.</p>
</div>
</div>
</section>

<%= render 'section', title: 'Text Input', example: 'form_builder/v2/cfa_text_input' %>
<%#= render 'section', title: 'Radio Button', example: 'form_builder/v2/cfa_radio' %>
<%#= render 'section', title: 'Radiogroup', example: 'form_builder/v2/cfa_radiogroup' %>
<%#= render 'section', title: 'Select', example: 'form_builder/v2/cfa_select' %>
<%#= render 'section', title: 'Date Input', example: 'form_builder/v2/cfa_date_input' %>
<%#= render 'section', title: 'Checkbox', example: 'form_builder/v2/cfa_checkbox' %>
9 changes: 9 additions & 0 deletions app/views/examples/form_builder/v2/_cfa_text_input.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<%= fields_for(:form, @form, builder: Cfa::Styleguide::CfaV2FormBuilder) do |f| %>
<%= f.cfa_text_input(:example_method_name, 'Example input') %>
<%= f.cfa_text_input(:example_method_name, 'Example input (required)', required: true) %>
<%= f.cfa_text_input(:example_method_name, 'Example input with help text', help_text: "You could answer this any way you like.") %>
<%= f.cfa_text_input(:example_method_name, 'Example input with wrapper class', wrapper_classes: ['blue']) %>
<%= f.cfa_text_input(:example_method_name, 'Example input with options', options: { placeholder: 'Enter text here.' }) %>
<%= f.cfa_text_input(:example_method_with_validation, 'Example input with error') %>
<% end %>
3 changes: 2 additions & 1 deletion app/views/layouts/_sidebar_nav.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
<span class="section-header heading-25-small spacing-below-10">For Engineers</span>
<ul class="sidebar__sub-items spacing-below-10">
<li class="spacing-below-25"><%= link_to "Emojis", styleguide_emojis_path, class: '' %></li>
<li class="spacing-below-25"><%= link_to "Form Builder", styleguide_form_builder_path, class: '' %></li>
<li class="spacing-below-25"><%= link_to "Form Builder V1", styleguide_form_builder_v1_path, class: '' %></li>
<li class="spacing-below-25"><%= link_to "Form Builder V2", styleguide_form_builder_v2_path, class: '' %></li>
<!--<li class="spacing-below-25"><%#= link_to "Css Conventions", styleguide_main_path(anchor: "atoms"), class: '' %></li>-->
</ul>
</li>
Expand Down
3 changes: 2 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Cfa::Styleguide::Engine.routes.draw do
get "/styleguide" => "pages#index", as: :styleguide_main
get "/styleguide/form-builder" => "pages#form_builder", as: :styleguide_form_builder
get "/styleguide/form-builder/v1" => "pages#form_builder_v1", as: :styleguide_form_builder_v1
get "/styleguide/form-builder/v2" => "pages#form_builder_v2", as: :styleguide_form_builder_v2
get "/styleguide/examples/*example_path" => "examples#show", as: :styleguide_example
get "/styleguide/emojis" => "pages#emojis", as: :styleguide_emojis
end
18 changes: 17 additions & 1 deletion spec/system/pages_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

it "can use the CfaFormBuilder" do
visit "/cfa/styleguide"
click_link "Form Builder"
click_link "Form Builder V1"

expect(page).to have_content("Example input")
expect(page).to have_content("Example textarea")
Expand All @@ -37,4 +37,20 @@
expect(page).to have_content("Example radio set with follow up")
expect(page).to have_content("Example select")
end

it "can use the CfaFormV2Builder" do
visit "/cfa/styleguide"
click_link "Form Builder V2"

expect(page).to have_content("CfAV2FormBuilder")
# expect(page).to have_content("Example textarea")
# expect(page).to have_content("Example range")
# expect(page).to have_content("Example date select")
#
# expect(page).to have_content("Example choice 1")
# expect(page).to have_content("Example choice 2")
# expect(page).to have_content("Example radio set (regular)")
# expect(page).to have_content("Example radio set with follow up")
# expect(page).to have_content("Example select")
end
end

0 comments on commit a8652d4

Please sign in to comment.