improvement: Added overrides for identity (email) and password fields. (#477)

This commit is contained in:
maxmannen 2024-07-16 21:32:43 +02:00 committed by GitHub
parent 8a1fe30d7b
commit 2e4bcaccae
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 6 deletions

View file

@ -3,6 +3,8 @@ defmodule AshAuthentication.Phoenix.Components.Password.Input do
field_class: "CSS class for `div` elements surrounding the fields.",
label_class: "CSS class for `label` elements.",
input_class: "CSS class for text/password `input` elements.",
identity_input_label: "Label for identity (email) field.",
password_input_label: "Label for password field.",
input_class_with_error:
"CSS class for text/password `input` elements when there is a validation error.",
submit_class: "CSS class for the form submit `input` element.",
@ -64,8 +66,8 @@ defmodule AshAuthentication.Phoenix.Components.Password.Input do
assigns =
assigns
|> assign(:identity_field, identity_field)
|> assign_new(:input_type, fn ->
|> assign(:identity_field, identity_field)
|> assign_new(:input_type, fn ->
identity_field
|> to_string()
|> String.contains?("email")
@ -84,7 +86,7 @@ defmodule AshAuthentication.Phoenix.Components.Password.Input do
~H"""
<div class={override_for(@overrides, :field_class)}>
<%= label(@form, @identity_field, class: override_for(@overrides, :label_class)) %>
<%= label(@form, override_for(@overrides, :identity_input_label), class: override_for(@overrides, :label_class)) %>
<%= text_input(@form, @identity_field,
type: to_string(@input_type),
class: @input_class,
@ -134,7 +136,7 @@ defmodule AshAuthentication.Phoenix.Components.Password.Input do
~H"""
<div class={override_for(@overrides, :field_class)}>
<%= label(@form, @password_field, class: override_for(@overrides, :label_class)) %>
<%= label(@form, override_for(@overrides, :password_input_label), class: override_for(@overrides, :label_class)) %>
<%= password_input(@form, @password_field,
class: @input_class,
value: input_value(@form, @password_field),
@ -183,7 +185,7 @@ defmodule AshAuthentication.Phoenix.Components.Password.Input do
~H"""
<div class={override_for(@overrides, :field_class)}>
<%= label(@form, @password_confirmation_field, class: override_for(@overrides, :label_class)) %>
<%= label(@form, override_for(@overrides, :password_input_label), class: override_for(@overrides, :label_class)) %>
<%= password_input(@form, @password_confirmation_field,
class: @input_class,
value: input_value(@form, @password_confirmation_field),

View file

@ -120,6 +120,7 @@ defmodule AshAuthentication.Phoenix.Overrides.Default do
end
override Components.Password.Input do
set :field_class, "mt-2 mb-2 dark:text-white"
set :label_class, "block text-sm font-medium text-gray-700 mb-1 dark:text-white"
@ -141,7 +142,8 @@ defmodule AshAuthentication.Phoenix.Overrides.Default do
focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500
mt-4 mb-4
"""
set :password_input_label, "Password"
set :identity_input_label, "Email"
set :error_ul, "text-red-400 font-light my-3 italic text-sm"
set :error_li, nil
set :input_debounce, 350