@@ -57,6 +57,14 @@ defmodule CoreWeb.Helpers do
{classes, rest_opts} = Keyword.pop(rest_opts, :class, "px-3 py-3 placeholder-gray-400 text-gray-700 bg-white rounded text-sm shadow focus:outline-none focus:shadow-outline w-full")
{label_text, rest_opts} = Keyword.pop(rest_opts, :label)
{input_helper, rest_opts} = Keyword.pop(rest_opts, :input_helper, :text_input)
+
+ error_classes =
+ if Keyword.get_values(f.errors, field) |> Enum.any?() do
+ " border border-red-500"
+ else
+ ""
+ end
+
~E"""
<%= if label_text do %>
@@ -67,17 +75,53 @@ defmodule CoreWeb.Helpers do
<%= if options == nil do %>
- <%= apply(Phoenix.HTML.Form, input_helper, [f, field, rest_opts ++ [class: classes]]) %>
+ <%= apply(Phoenix.HTML.Form, input_helper, [f, field, rest_opts ++ [class: Enum.join([classes, error_classes], " ")]]) %>
<% else %>
- <%= apply(Phoenix.HTML.Form, input_helper, [f, field, options, rest_opts ++ [class: classes]]) %>
+ <%= apply(Phoenix.HTML.Form, input_helper, [f, field, options, rest_opts ++ [class: Enum.join([classes, error_classes], " ")]]) %>
<% end %>
<%= content %>
- <%= error_tag f, field, class: "ui pointing red basic label" %>
+ <%= error_tag f, field, class: "text-red-500 italic" %>
"""
end
+ def styled_button(text) do
+ ~E"""
+ <%= submit text, class: "bg-gray-900 text-white active:bg-gray-700 text-sm font-bold uppercase px-6 py-3 rounded shadow hover:shadow-lg outline-none focus:outline-none mr-1 mb-1 w-full" %>
+ """
+ end
+
+ def floating_form(title, changeset, do: content) do
+ ~E"""
+
<%= title %>
+
+ <%= changeset_error_block(changeset) %>
+
+ <%= content %>
+
+
+ """
+
+ end
+
+ def floating_page_wrapper(do: content) do
+ ~E"""
+
+ """
+ end
+
def pow_extension_enabled?(extension) do
{extensions, _rest} = Application.get_env(:auth_web, :pow) |> Keyword.pop(:extensions, [])