From a06590afabc478bb3b1edd2a64c16c9f0fedc916 Mon Sep 17 00:00:00 2001 From: fabio-k Date: Sun, 9 Feb 2025 07:29:40 -0300 Subject: [PATCH 1/2] refactor: improve login page --- app/views/devise/sessions/new.html.erb | 51 ++++++++++--------- .../authentication/user_sign_in_spec.rb | 2 +- 2 files changed, 29 insertions(+), 24 deletions(-) diff --git a/app/views/devise/sessions/new.html.erb b/app/views/devise/sessions/new.html.erb index a53ca22..74c1451 100644 --- a/app/views/devise/sessions/new.html.erb +++ b/app/views/devise/sessions/new.html.erb @@ -1,29 +1,34 @@ -

Log in

+
+
+

Login

+ <%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %> +
+
+ <%= f.label :email, class: "input_label" %> + <%= f.email_field :email, autofocus: true, class: "input" %> +
-<%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %> -
-
- <%= f.label :email, "E-mail", class: 'input_label' %> - <%= f.email_field :email, autofocus: true, autocomplete: "email", class: 'input' %> -
+
+ <%= f.label :password, class: "input_label" %> + <%= f.password_field :password, class: "input" %> +
+ <%- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' %> + <%= link_to "Esqueceu sua Senha?", new_password_path(resource_name), class: 'hover:underline font-bold' %> + <% end %> -
- <%= f.label :password, "Senha", class: 'input_label' %> - <%= f.password_field :password, autocomplete: "current-password", class: 'input' %> -
+ <% if devise_mapping.rememberable? %> +
+ <%= f.check_box :remember_me, class: 'text-primary h-5 w-5' %> + <%= f.label :remember_me, class: 'input_label' %> +
+ <% end %> - <% if devise_mapping.rememberable? %> -
- <%= f.check_box :remember_me, class: 'text-primary h-5 w-5' %> - <%= f.label :remember_me, class: 'input_label' %> + + <%= f.submit "Entrar", class: 'form_button mt-2' %>
<% end %> - - - <%= f.submit "Entrar", class: 'form_button' %> -
-<% end %> - -
- <%= render "devise/shared/links" %> +
+

Não possui conta? <%= link_to "Cadastrar", new_registration_path(resource_name), class: 'hover:underline font-bold' %>

+

Não recebeu instruções de confirmação? <%= link_to "reenviar", new_confirmation_path(resource_name), class: 'hover:underline font-bold' %>

+ diff --git a/spec/system/authentication/user_sign_in_spec.rb b/spec/system/authentication/user_sign_in_spec.rb index 3fbd239..be1fb32 100644 --- a/spec/system/authentication/user_sign_in_spec.rb +++ b/spec/system/authentication/user_sign_in_spec.rb @@ -6,7 +6,7 @@ click_on 'Entrar' expect(current_path).to eq new_user_session_path - expect(page).to have_content "Log in" + expect(page).to have_content "Login" expect(page).to have_selector 'form' expect(page).to have_field 'E-mail' expect(page).to have_field 'Senha' From c0d0b9d15f7493e3ca67130c75a9f5bc3f9d2318 Mon Sep 17 00:00:00 2001 From: fabio-k Date: Sun, 9 Feb 2025 20:21:31 -0300 Subject: [PATCH 2/2] refactor sign up page style --- app/views/devise/registrations/new.html.erb | 107 +++++++++++++------- 1 file changed, 69 insertions(+), 38 deletions(-) diff --git a/app/views/devise/registrations/new.html.erb b/app/views/devise/registrations/new.html.erb index 4730f9c..d5d20bb 100644 --- a/app/views/devise/registrations/new.html.erb +++ b/app/views/devise/registrations/new.html.erb @@ -1,47 +1,78 @@ -

Criar Minha Conta

+
+
+

Criar Minha Conta

+

Já possui conta? <%= link_to "Entrar", new_session_path(resource_name), class: 'hover:underline font-bold' %>

-<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %> - <%= render "devise/shared/error_messages", resource: resource %> + <%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %> +
+
+ <%= f.label :name, class: 'input_label' %> + <%= f.text_field :name, autofocus: true, autocomplete: "username", class: 'input' %> + <% if resource.errors[:name].any? %> + <% resource.errors.full_messages_for(:name).each do |e| %> + <%= e %> + <% end %> + <% end %> +
-
-
- <%= f.label :name, class: 'input_label' %> - <%= f.text_field :name, autofocus: true, autocomplete: "username", class: 'input' %> -
- -
- <%= f.label :family_name, class: 'input_label' %> - <%= f.text_field :family_name, autocomplete: "family-name", class: 'input' %> -
- -
- <%= f.label :email, class: 'input_label' %> - <%= f.email_field :email, autocomplete: "email", class: 'input' %> -
+
+ <%= f.label :family_name, class: 'input_label' %> + <%= f.text_field :family_name, autocomplete: "family-name", class: 'input' %> + <% if resource.errors[:family_name].any? %> + <% resource.errors.full_messages_for(:family_name).each do |e| %> + <%= e %> + <% end %> + <% end %> +
-
- <%= f.label :registration_number, class: 'input_label' %> - <%= f.text_field :registration_number, class: 'input' %> -
+
+ <%= f.label :email, class: 'input_label' %> + <%= f.email_field :email, autocomplete: "email", class: 'input' %> + <% if resource.errors[:email].any? %> + <% resource.errors.full_messages_for(:email).each do |e| %> + <%= e %> + <% end %> + <% end %> +
-
- <%= f.label :password, class: 'input_label' %> - <% if @minimum_password_length %> - (Mínimo de <%= @minimum_password_length %> caracteres) - <% end %> - <%= f.password_field :password, autocomplete: "new-password", class: 'input' %> -
+
+ <%= f.label :registration_number, class: 'input_label' %> + <%= f.text_field :registration_number, class: 'input' %> + <% if resource.errors[:registration_number].any? %> + <% resource.errors.full_messages_for(:registration_number).each do |e| %> + <%= e %> + <% end %> + <% end %> +
-
- <%= f.label :password_confirmation, class: 'input_label' %> - <%= f.password_field :password_confirmation, autocomplete: "new-password", class: 'input' %> -
+
+ <%= f.label :password, class: 'input_label' %> + <% if @minimum_password_length %> + (Mínimo de <%= @minimum_password_length %> caracteres) + <% end %> + <%= f.password_field :password, autocomplete: "new-password", class: 'input' %> + <% if resource.errors[:password].any? %> + <% resource.errors.full_messages_for(:password).each do |e| %> + <%= e %> + <% end %> + <% end %> +
+
+ <%= f.label :password_confirmation, class: 'input_label' %> + <%= f.password_field :password_confirmation, autocomplete: "new-password", class: 'input' %> + <% if resource.errors[:password_confirmation].any? %> + <% resource.errors.full_messages_for(:password_confirmation).each do |e| %> + <%= e %> + <% end %> + <% end %> +
- <%= f.submit "Criar Conta", class: 'form_button' %> -
-<% end %> -
- <%= render "devise/shared/links" %> + <%= f.submit "Criar Conta", class: 'form_button' %> +
+ <% end %> +
+

Não recebeu instruções de confirmação? <%= link_to "reenviar", new_confirmation_path(resource_name), class: 'hover:underline font-bold' %>

+