mirror of
https://github.com/team-alembic/ash_authentication_phoenix.git
synced 2024-09-19 13:03:50 +12:00
improvement: Added overrides for identity (email) and password fields. (#477)
This commit is contained in:
parent
8a1fe30d7b
commit
2e4bcaccae
2 changed files with 10 additions and 6 deletions
|
@ -3,6 +3,8 @@ defmodule AshAuthentication.Phoenix.Components.Password.Input do
|
||||||
field_class: "CSS class for `div` elements surrounding the fields.",
|
field_class: "CSS class for `div` elements surrounding the fields.",
|
||||||
label_class: "CSS class for `label` elements.",
|
label_class: "CSS class for `label` elements.",
|
||||||
input_class: "CSS class for text/password `input` 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:
|
input_class_with_error:
|
||||||
"CSS class for text/password `input` elements when there is a validation error.",
|
"CSS class for text/password `input` elements when there is a validation error.",
|
||||||
submit_class: "CSS class for the form submit `input` element.",
|
submit_class: "CSS class for the form submit `input` element.",
|
||||||
|
@ -64,8 +66,8 @@ defmodule AshAuthentication.Phoenix.Components.Password.Input do
|
||||||
|
|
||||||
assigns =
|
assigns =
|
||||||
assigns
|
assigns
|
||||||
|> assign(:identity_field, identity_field)
|
|> assign(:identity_field, identity_field)
|
||||||
|> assign_new(:input_type, fn ->
|
|> assign_new(:input_type, fn ->
|
||||||
identity_field
|
identity_field
|
||||||
|> to_string()
|
|> to_string()
|
||||||
|> String.contains?("email")
|
|> String.contains?("email")
|
||||||
|
@ -84,7 +86,7 @@ defmodule AshAuthentication.Phoenix.Components.Password.Input do
|
||||||
|
|
||||||
~H"""
|
~H"""
|
||||||
<div class={override_for(@overrides, :field_class)}>
|
<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,
|
<%= text_input(@form, @identity_field,
|
||||||
type: to_string(@input_type),
|
type: to_string(@input_type),
|
||||||
class: @input_class,
|
class: @input_class,
|
||||||
|
@ -134,7 +136,7 @@ defmodule AshAuthentication.Phoenix.Components.Password.Input do
|
||||||
|
|
||||||
~H"""
|
~H"""
|
||||||
<div class={override_for(@overrides, :field_class)}>
|
<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,
|
<%= password_input(@form, @password_field,
|
||||||
class: @input_class,
|
class: @input_class,
|
||||||
value: input_value(@form, @password_field),
|
value: input_value(@form, @password_field),
|
||||||
|
@ -183,7 +185,7 @@ defmodule AshAuthentication.Phoenix.Components.Password.Input do
|
||||||
|
|
||||||
~H"""
|
~H"""
|
||||||
<div class={override_for(@overrides, :field_class)}>
|
<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,
|
<%= password_input(@form, @password_confirmation_field,
|
||||||
class: @input_class,
|
class: @input_class,
|
||||||
value: input_value(@form, @password_confirmation_field),
|
value: input_value(@form, @password_confirmation_field),
|
||||||
|
|
|
@ -120,6 +120,7 @@ defmodule AshAuthentication.Phoenix.Overrides.Default do
|
||||||
end
|
end
|
||||||
|
|
||||||
override Components.Password.Input do
|
override Components.Password.Input do
|
||||||
|
|
||||||
set :field_class, "mt-2 mb-2 dark:text-white"
|
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"
|
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
|
focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500
|
||||||
mt-4 mb-4
|
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_ul, "text-red-400 font-light my-3 italic text-sm"
|
||||||
set :error_li, nil
|
set :error_li, nil
|
||||||
set :input_debounce, 350
|
set :input_debounce, 350
|
||||||
|
|
Loading…
Reference in a new issue