From c8703296c4e964aabf855eb3bc0afc51ab9c2ac8 Mon Sep 17 00:00:00 2001 From: Gary Geisler Date: Fri, 10 Jun 2016 12:51:12 -0700 Subject: [PATCH] Update styling of sign up (registration) page --- app/assets/stylesheets/accounts.scss | 22 +++++++++++++--- app/views/accounts/_new_form.html.erb | 2 +- app/views/devise/registrations/new.html.erb | 29 +++++++++++---------- app/views/devise/shared/_links.html.erb | 2 +- config/initializers/simple_form.rb | 19 ++++++++++++++ 5 files changed, 54 insertions(+), 20 deletions(-) diff --git a/app/assets/stylesheets/accounts.scss b/app/assets/stylesheets/accounts.scss index ec894543b..aaeef392f 100644 --- a/app/assets/stylesheets/accounts.scss +++ b/app/assets/stylesheets/accounts.scss @@ -1,22 +1,36 @@ .account-form { margin: 0 10px 30px; - h1 { + h1, + h2 { font-size: 2em; margin-bottom: 30px; } label, - .actions { + .actions, + .form-actions { text-align: right; } - .actions .btn { + .actions .btn, + .form-actions .btn { margin-left: 10px; } .help-block { - margin-bottom: 20px; + margin-bottom: 0; margin-top: 5px; } } + +.registration { + .required-tag { + display: none; + } +} + +.field_with_errors { + border-radius: $border-radius-base; + margin-top: 5px; +} diff --git a/app/views/accounts/_new_form.html.erb b/app/views/accounts/_new_form.html.erb index 9d771905f..869429fe7 100644 --- a/app/views/accounts/_new_form.html.erb +++ b/app/views/accounts/_new_form.html.erb @@ -1,4 +1,4 @@ -<%= form_for(@account, class: 'form') do |f| %> +<%= form_for(@account, :html => { class: 'form form-horizontal' }) do |f| %> <% if @account.errors.any? %>
<%= pluralize(@account.errors.count, "error") %> prohibited this repository from being saved: diff --git a/app/views/devise/registrations/new.html.erb b/app/views/devise/registrations/new.html.erb index 536fc582b..4c62e4eb7 100644 --- a/app/views/devise/registrations/new.html.erb +++ b/app/views/devise/registrations/new.html.erb @@ -1,17 +1,18 @@ -

TEST

+ diff --git a/app/views/devise/shared/_links.html.erb b/app/views/devise/shared/_links.html.erb index e6a3e4196..5c891c283 100644 --- a/app/views/devise/shared/_links.html.erb +++ b/app/views/devise/shared/_links.html.erb @@ -1,5 +1,5 @@ <%- if controller_name != 'sessions' %> - <%= link_to "Log in", new_session_path(resource_name) %>
+ <%= link_to "Log in", new_session_path(resource_name) %> <% end -%> <%- if devise_mapping.registerable? && controller_name != 'registrations' %> diff --git a/config/initializers/simple_form.rb b/config/initializers/simple_form.rb index a561d3acb..6e88cb0e5 100644 --- a/config/initializers/simple_form.rb +++ b/config/initializers/simple_form.rb @@ -167,4 +167,23 @@ # Defines which i18n scope will be used in Simple Form. # config.i18n_scope = 'simple_form' + + config.wrappers :inline, + class: :input, + hint_class: 'hint', error_class: 'field_with_errors' do |b| + + # mix in special behavior using `use :component` + b.use :html5 + # b.use :placeholder + + # define custom HTML output using `wrapper` + b.wrapper tag: :div, class: 'form-group' do |c| + c.use :label, class: 'control-label col-md-2' + c.wrapper tag: :div, class: 'col-md-10' do |d| + d.use :input, class: 'form-control' + d.use :hint, wrap_with: { tag: :span, class: 'help-block' } + d.use :error, wrap_with: { tag: :div, class: 'field_with_errors alert-danger' } + end + end + end end