From 42812d1699d75ecb6fddc5889d763949235571c1 Mon Sep 17 00:00:00 2001 From: Arnaud Levy <contact@arnaudlevy.com> Date: Wed, 13 Oct 2021 15:34:01 +0200 Subject: [PATCH] better devise --- app/views/devise/confirmations/new.html.erb | 27 ++++--- app/views/devise/passwords/edit.html.erb | 7 +- app/views/devise/passwords/new.html.erb | 25 +++--- app/views/devise/registrations/edit.html.erb | 67 ++++++++-------- app/views/devise/registrations/new.html.erb | 83 ++++++++++---------- app/views/devise/sessions/new.html.erb | 67 ++++++++-------- app/views/devise/unlocks/new.html.erb | 26 +++--- app/views/layouts/devise.html.erb | 2 +- 8 files changed, 153 insertions(+), 151 deletions(-) diff --git a/app/views/devise/confirmations/new.html.erb b/app/views/devise/confirmations/new.html.erb index 5c2c4d200..b15178511 100644 --- a/app/views/devise/confirmations/new.html.erb +++ b/app/views/devise/confirmations/new.html.erb @@ -1,19 +1,20 @@ -<h2><%= t(".resend_confirmation_instructions") %></h2> +<h2 class="mb-4"><%= t(".resend_confirmation_instructions") %></h2> <%= simple_form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { method: :post }) do |f| %> <%= f.error_notification %> <%= f.full_error :confirmation_token %> - - <div class="form-inputs"> - <%= f.input :email, - required: true, - autofocus: true, - value: (resource.pending_reconfirmation? ? resource.unconfirmed_email : resource.email), - input_html: { autocomplete: "email" } %> - </div> - - <div class="form-actions text-end mt-3"> - <%= f.button :submit, t(".resend_confirmation_instructions"), class: 'btn btn-primary' %> - <%= render "devise/shared/links" %> + <div class="row"> + <div class="col-md-6"> + <%= f.input :email, + required: true, + autofocus: true, + value: (resource.pending_reconfirmation? ? resource.unconfirmed_email : resource.email), + input_html: { autocomplete: "email" } %> + </div> + <div class="col-md-6"> + <label class="form-label"> </label><br> + <%= f.button :submit, t(".resend_confirmation_instructions"), class: 'btn btn-primary' %> + <%= render "devise/shared/links" %> + </div> </div> <% end %> diff --git a/app/views/devise/passwords/edit.html.erb b/app/views/devise/passwords/edit.html.erb index 7ade5e68a..f9f48cfc0 100644 --- a/app/views/devise/passwords/edit.html.erb +++ b/app/views/devise/passwords/edit.html.erb @@ -1,4 +1,4 @@ -<h2><%= t(".change_your_password") %></h2> +<h2 class="mb-4"><%= t(".change_your_password") %></h2> <%= simple_form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put }) do |f| %> <%= f.error_notification %> @@ -30,9 +30,8 @@ input_html: { autocomplete: "new-password" } %> </div> - <div class="form-actions text-end mt-3"> + <div class="form-actions"> <%= f.button :submit, t(".change_my_password"), class: 'btn btn-primary' %> + <%= render "devise/shared/links" %> </div> <% end %> - -<%= render "devise/shared/links" %> diff --git a/app/views/devise/passwords/new.html.erb b/app/views/devise/passwords/new.html.erb index 7afaf7530..a708f5e6a 100644 --- a/app/views/devise/passwords/new.html.erb +++ b/app/views/devise/passwords/new.html.erb @@ -1,18 +1,19 @@ -<h2><%= t(".forgot_your_password") %></h2> +<h2 class="mb-4"><%= t(".forgot_your_password") %></h2> <%= simple_form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| %> <%= f.error_notification %> - <div class="form-inputs"> - <%= f.input :email, - required: true, - autofocus: true, - input_html: { autocomplete: "email" } %> - </div> - - <div class="form-actions text-center mt-3"> - <%= f.button :submit, t(".send_me_reset_password_instructions"), class: 'btn btn-primary' %> + <div class="row"> + <div class="col-md-6"> + <%= f.input :email, + required: true, + autofocus: true, + input_html: { autocomplete: "email" } %> + </div> + <div class="col-md-6"> + <label class="form-label"> </label><br> + <%= f.button :submit, t(".send_me_reset_password_instructions"), class: 'btn btn-primary' %> + <%= render "devise/shared/links" %> + </div> </div> <% end %> - -<%= render "devise/shared/links" %> diff --git a/app/views/devise/registrations/edit.html.erb b/app/views/devise/registrations/edit.html.erb index 9b9746835..b0c75c2f9 100644 --- a/app/views/devise/registrations/edit.html.erb +++ b/app/views/devise/registrations/edit.html.erb @@ -1,45 +1,42 @@ -<h2><%= t(".title", resource: resource.model_name.human) %></h2> +<h2 class="mb-4"><%= t(".title", resource: resource.model_name.human) %></h2> <%= simple_form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %> <%= f.error_notification %> - <div class="form-inputs"> - <%= f.input :first_name, - required: true, - autofocus: true, - input_html: { autocomplete: "first_name" } %> - <%= f.input :last_name, - required: true, - input_html: { autocomplete: "last_name" } %> - <%= f.input :email, required: true %> - - <% if devise_mapping.confirmable? && resource.pending_reconfirmation? %> - <p><%= t(".currently_waiting_confirmation_for_email", email: resource.unconfirmed_email) %></p> - <% end %> - - <%= f.input :mobile_phone %> - <%= f.association :language, - include_blank: false, - label_method: lambda { |l| t("languages.#{l.iso_code.to_s}") } %> - - <%= f.input :picture, - as: :single_deletable_file, - input_html: { accept: '.png,.jpg' } %> - - <%= f.input :password, - hint: t(".leave_blank_if_you_don_t_want_to_change_it"), - required: false, - input_html: { autocomplete: "new-password" } %> - - - </div> - - <div class="form-actions"> - <%= f.button :submit, t(".update"), class: 'btn btn-primary' %> + <div class="row"> + <div class="col-md-4"> + <%= f.input :email, required: true %> + <%= f.input :first_name, + required: true, + autofocus: true, + input_html: { autocomplete: "first_name" } %> + <%= f.input :last_name, + required: true, + input_html: { autocomplete: "last_name" } %> + </div> + <div class="col-md-4"> + <%= f.association :language, + include_blank: false, + label_method: lambda { |l| t("languages.#{l.iso_code.to_s}") } %> + <%= f.input :mobile_phone %> + </div> + <div class="col-md-4"> + <%= f.input :password, + hint: t(".leave_blank_if_you_don_t_want_to_change_it"), + required: false, + input_html: { autocomplete: "new-password" } %> + <%= f.input :picture, + as: :single_deletable_file, + input_html: { accept: '.png,.jpg' } %> + <% if devise_mapping.confirmable? && resource.pending_reconfirmation? %> + <p><%= t(".currently_waiting_confirmation_for_email", email: resource.unconfirmed_email) %></p> + <% end %> + </div> </div> + <%= f.button :submit, t(".update"), class: 'btn btn-primary' %> <% end %> -<h3><%= t(".cancel_my_account") %></h3> +<h3 class="mt-5 mb-4"><%= t(".cancel_my_account") %></h3> <p><%= t(".unhappy") %> <%= link_to t(".cancel_my_account"), registration_path(resource_name), data: { confirm: t(".are_you_sure") }, method: :delete %></p> diff --git a/app/views/devise/registrations/new.html.erb b/app/views/devise/registrations/new.html.erb index a64bb4f92..1e79c8490 100644 --- a/app/views/devise/registrations/new.html.erb +++ b/app/views/devise/registrations/new.html.erb @@ -1,49 +1,50 @@ -<h2><%= t(".sign_up") %></h2> +<h2 class="mb-4"><%= t(".sign_up") %></h2> <%= simple_form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %> <%= f.error_notification %> - <div class="form-inputs"> - <%= f.input :first_name, - required: true, - autofocus: true, - input_html: { autocomplete: "first_name" } %> - <%= f.input :last_name, - required: true, - input_html: { autocomplete: "last_name" } %> - <%= f.input :email, - required: true, - input_html: { autocomplete: "email" } %> - <%= f.input :password, - as: :password_with_hints, - required: true, - allow_password_uncloaking: true, - validators: { - length: Devise.password_length.first, - uppercase_char: true, - lowercase_char: true, - numeric_char: true, - special_char: Rails.application.config.allowed_special_chars - }, - input_html: { autocomplete: "new-password" } %> - <%= f.input :password_confirmation, - as: :password_with_sync, - required: true, - allow_password_uncloaking: true, - compare_with_field: :password, - input_html: { autocomplete: "new-password" } %> - <%= f.association :language, - required: true, - label_method: lambda { |l| t("languages.#{l.iso_code.to_s}") }, - include_blank: 'Sélectionnez une langue' %> - <%= f.input :picture, - as: :single_deletable_file, - input_html: { accept: '.png' } %> - </div> - - <div class="form-actions text-center mt-3"> - <%= f.button :submit, t(".sign_up"), class: 'btn btn-primary' %> + <div class="row"> + <div class="col-md-6"> + <%= f.input :email, + required: true, + input_html: { autocomplete: "email" } %> + <%= f.input :first_name, + required: true, + autofocus: true, + input_html: { autocomplete: "first_name" } %> + <%= f.input :last_name, + required: true, + input_html: { autocomplete: "last_name" } %> + <%= f.association :language, + required: true, + label_method: lambda { |l| t("languages.#{l.iso_code.to_s}") }, + include_blank: 'Sélectionnez une langue' %> + </div> + <div class="col-md-6"> + <%= f.input :password, + as: :password_with_hints, + required: true, + allow_password_uncloaking: true, + validators: { + length: Devise.password_length.first, + uppercase_char: true, + lowercase_char: true, + numeric_char: true, + special_char: Rails.application.config.allowed_special_chars + }, + input_html: { autocomplete: "new-password" } %> + <%= f.input :password_confirmation, + as: :password_with_sync, + required: true, + allow_password_uncloaking: true, + compare_with_field: :password, + input_html: { autocomplete: "new-password" } %> + <%= f.input :picture, + as: :single_deletable_file, + input_html: { accept: '.png' } %> + </div> </div> + <%= f.button :submit, t(".sign_up"), class: 'btn btn-primary' %> <% end %> <%= render "devise/shared/links" %> diff --git a/app/views/devise/sessions/new.html.erb b/app/views/devise/sessions/new.html.erb index ebf5a05b8..9e9222d07 100644 --- a/app/views/devise/sessions/new.html.erb +++ b/app/views/devise/sessions/new.html.erb @@ -1,36 +1,39 @@ -<h2><%= t('login.not_registered_yet') %></h2> -<p><%= t('login.not_registered_yet_details') %></p> -<div class="form-actions text-end"> - <%= link_to t("devise.registrations.new.sign_up"), - new_registration_path(resource_name), - class: 'btn btn-primary' %> -</div> - -<hr class="my-5"> - -<h2 class="mb-4"><%= t('login.already_registered') %></h2> -<%= simple_form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %> - <div class="form-inputs"> - <%= f.input :email, - required: false, - autofocus: true, - input_html: { autocomplete: "email" } %> - <div class="mb-3 password optional user_password"> - <%= f.input :password, - as: :password_with_hints, - allow_password_uncloaking: true, - required: false, - wrapper: false, - input_html: { autocomplete: "current-password" } %> - <small> - <%= link_to t("devise.passwords.new.forgot_your_password"), new_password_path(resource_name) %> - </small> +<div class="row"> + <div class="col-md-6"> + <h2 class="mb-4"><%= t('login.not_registered_yet') %></h2> + <p><%= t('login.not_registered_yet_details') %></p> + <div class="form-actions"> + <%= link_to t("devise.registrations.new.sign_up"), + new_registration_path(resource_name), + class: 'btn btn-primary' %> </div> - <%= f.input :remember_me, as: :boolean if devise_mapping.rememberable? %> </div> + <div class="col-md-6"> + <h2 class="mb-4"><%= t('login.already_registered') %></h2> + <%= simple_form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %> + <div class="form-inputs"> + <%= f.input :email, + required: false, + autofocus: true, + input_html: { autocomplete: "email" } %> + <div class="mb-3 password optional user_password"> + <%= f.input :password, + as: :password_with_hints, + allow_password_uncloaking: true, + required: false, + wrapper: false, + input_html: { autocomplete: "current-password" } %> + <small> + <%= link_to t("devise.passwords.new.forgot_your_password"), new_password_path(resource_name) %> + </small> + </div> + <%= f.input :remember_me, as: :boolean if devise_mapping.rememberable? %> + </div> - <div class="form-actions text-end"> - <%= f.button :submit, t(".sign_in"), class: 'btn btn-primary align-end' %> - <%= render "devise/shared/links" %> + <div class="form-actions"> + <%= f.button :submit, t(".sign_in"), class: 'btn btn-primary' %> + <%= render "devise/shared/links" %> + </div> + <% end %> </div> -<% end %> +</div> diff --git a/app/views/devise/unlocks/new.html.erb b/app/views/devise/unlocks/new.html.erb index 1a7b8928e..e5086ff94 100644 --- a/app/views/devise/unlocks/new.html.erb +++ b/app/views/devise/unlocks/new.html.erb @@ -1,19 +1,19 @@ -<h2><%= t(".resend_unlock_instructions") %></h2> +<h2 class="mb-4"><%= t(".resend_unlock_instructions") %></h2> <%= simple_form_for(resource, as: resource_name, url: unlock_path(resource_name), html: { method: :post }) do |f| %> <%= f.error_notification %> <%= f.full_error :unlock_token %> - - <div class="form-inputs"> - <%= f.input :email, - required: true, - autofocus: true, - input_html: { autocomplete: "email" } %> - </div> - - <div class="form-actions text-center mt-3"> - <%= f.button :submit, t(".resend_unlock_instructions"), class: 'btn btn-primary' %> + <div class="row"> + <div class="col-md-6"> + <%= f.input :email, + required: true, + autofocus: true, + input_html: { autocomplete: "email" } %> + </div> + <div class="col-md-6"> + <label class="form-label"> </label><br> + <%= f.button :submit, t(".resend_unlock_instructions"), class: 'btn btn-primary' %> + <%= render "devise/shared/links" %> + </div> </div> <% end %> - -<%= render "devise/shared/links" %> diff --git a/app/views/layouts/devise.html.erb b/app/views/layouts/devise.html.erb index c304e6859..468087632 100644 --- a/app/views/layouts/devise.html.erb +++ b/app/views/layouts/devise.html.erb @@ -13,7 +13,7 @@ <body> <div class="container"> <div class="row"> - <div class="col-sm-10 col-md-8 col-lg-6 mx-auto"> + <div class="col-sm-10 mx-auto"> <h1 class="my-5 py-5 text-center"><%= current_university %></h1> <div class="card"> <div class="card-body text-start"> -- GitLab