From 2e4bcaccae16c61be653f3d58bd5f59a73753146 Mon Sep 17 00:00:00 2001 From: maxmannen Date: Tue, 16 Jul 2024 21:32:43 +0200 Subject: [PATCH] improvement: Added overrides for identity (email) and password fields. (#477) --- .../components/password/input.ex | 12 +++++++----- lib/ash_authentication_phoenix/overrides/default.ex | 4 +++- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/ash_authentication_phoenix/components/password/input.ex b/lib/ash_authentication_phoenix/components/password/input.ex index 5bafd1d..7dbf92b 100644 --- a/lib/ash_authentication_phoenix/components/password/input.ex +++ b/lib/ash_authentication_phoenix/components/password/input.ex @@ -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"""
- <%= 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"""
- <%= 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"""
- <%= 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), diff --git a/lib/ash_authentication_phoenix/overrides/default.ex b/lib/ash_authentication_phoenix/overrides/default.ex index 55ed19a..a0e0b84 100644 --- a/lib/ash_authentication_phoenix/overrides/default.ex +++ b/lib/ash_authentication_phoenix/overrides/default.ex @@ -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