From b34d040ce37df71c605cc58f30f15559d89762d0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?R=C3=A2u=20Cao?=
Date: Wed, 8 Mar 2023 15:51:09 +0700
Subject: [PATCH] Refactor form input styles
* Fix issue where button is rendered taller in flexbox, due to default
margin on input elements
* Refactor/improve all login and signup views
---
app/assets/stylesheets/components/forms.css | 2 +-
app/views/devise/confirmations/new.html.erb | 4 +--
app/views/devise/passwords/new.html.erb | 20 +++++++-------
app/views/devise/sessions/new.html.erb | 20 +++++++-------
app/views/invitations/index.html.erb | 9 +++----
app/views/settings/profile/index.html.erb | 8 +++---
app/views/signup/index.html.erb | 2 +-
app/views/signup/steps.html.erb | 30 ++++++++++-----------
8 files changed, 48 insertions(+), 47 deletions(-)
diff --git a/app/assets/stylesheets/components/forms.css b/app/assets/stylesheets/components/forms.css
index 61c7b1e..5603ba4 100644
--- a/app/assets/stylesheets/components/forms.css
+++ b/app/assets/stylesheets/components/forms.css
@@ -1,7 +1,7 @@
@layer components {
input[type=text], input[type=email], input[type=password],
input[type=number], select, textarea {
- @apply mt-1 rounded-md bg-gray-100 focus:bg-white
+ @apply rounded-md bg-gray-100 focus:bg-white
border-transparent focus:border-transparent focus:ring-2
focus:ring-blue-600 focus:ring-opacity-75;
}
diff --git a/app/views/devise/confirmations/new.html.erb b/app/views/devise/confirmations/new.html.erb
index 4f51d90..da793a0 100644
--- a/app/views/devise/confirmations/new.html.erb
+++ b/app/views/devise/confirmations/new.html.erb
@@ -6,7 +6,7 @@
<%= form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { method: :post }) do |f| %>
<%= render "devise/shared/error_messages", resource: resource %>
- <%= f.label :email, 'Email address', class: 'block mb-1 w-full' %>
+ <%= f.label :email, 'Email address', class: 'block mb-2 font-bold' %>
<%= f.email_field :email,
required: true, autofocus: true, autocomplete: "email",
value: (resource.pending_reconfirmation? ? resource.unconfirmed_email : resource.email),
@@ -14,7 +14,7 @@
<%= f.submit "Resend confirmation link",
- class: 'btn-md btn-blue w-full sm:w-auto' %>
+ class: 'btn-md btn-blue w-full' %>
<% end %>
diff --git a/app/views/devise/passwords/new.html.erb b/app/views/devise/passwords/new.html.erb
index 622f238..a0345f3 100644
--- a/app/views/devise/passwords/new.html.erb
+++ b/app/views/devise/passwords/new.html.erb
@@ -5,19 +5,21 @@
<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| %>
<%= render "devise/shared/error_messages", resource: resource %>
+
+ <%= f.label :cn, 'User', class: 'block mb-2 font-bold' %>
+
+ <%= f.text_field :cn, autofocus: true, autocomplete: "username",
+ required: true, class: "relative grow"%>
+ @ kosmos.org
+
+
- <%= f.label :cn, 'User', class: 'block' %>
- <%= f.text_field :cn, autofocus: true, autocomplete: "username",
- required: true, class: "w-full md:w-3/5"%>
- @ kosmos.org
-
-
- <%= f.label :email, 'Email address', class: 'block' %>
+ <%= f.label :email, 'Email address', class: 'block mb-2 font-bold' %>
<%= f.email_field :email, autocomplete: "email", required: true,
- class: "w-full md:w-3/5"%>
+ class: "w-full"%>
- <%= f.submit "Send me a reset link", class: 'btn-md btn-blue w-full sm:w-auto' %>
+ <%= f.submit "Send me a reset link", class: 'btn-md btn-blue w-full' %>
<% end %>
diff --git a/app/views/devise/sessions/new.html.erb b/app/views/devise/sessions/new.html.erb
index 607edb3..687d90a 100644
--- a/app/views/devise/sessions/new.html.erb
+++ b/app/views/devise/sessions/new.html.erb
@@ -3,19 +3,21 @@
<%= render MainCompactComponent.new do %>
<%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>
<%= render "devise/shared/error_messages", resource: resource %>
+
+ <%= f.label :cn, 'User', class: 'block mb-2 font-bold' %>
+
+ <%= f.text_field :cn, autofocus: true, autocomplete: "username",
+ required: true, class: "relative grow"%>
+ @ kosmos.org
+
+
- <%= f.label :cn, 'User', class: 'block' %>
- <%= f.text_field :cn, autofocus: true, autocomplete: "username",
- class: "w-full md:w-3/5"%>
- @ kosmos.org
-
-
- <%= f.label :password, class: 'block' %>
+ <%= f.label :password, class: 'block mb-2 font-bold' %>
<%= f.password_field :password, autocomplete: "current-password",
- class: "w-full md:w-3/5"%>
+ required: true, class: "w-full"%>
- <%= f.submit "Log in", class: 'btn-md btn-blue w-full sm:w-auto' %>
+ <%= f.submit "Log in", class: 'btn-md btn-blue w-full' %>
<% end %>
diff --git a/app/views/invitations/index.html.erb b/app/views/invitations/index.html.erb
index 5517a47..b2c5a22 100644
--- a/app/views/invitations/index.html.erb
+++ b/app/views/invitations/index.html.erb
@@ -6,14 +6,13 @@
Invite your friends to a Kosmos account by sharing an invitation URL with them:
-
+
<% @invitations_unused.each do |invitation| %>
- -
-
+
-
- <%= f.submit "Create account",
- class: "btn-md btn-blue block w-full sm:inline-block sm:w-auto" %>
+ <%= f.submit "Create account", class: "btn-md btn-blue block w-full" %>
<% end %>
<% end %>