Skip to content

Commit

Permalink
improvement: update to latest phoenix_live_view 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
zachdaniel committed Dec 5, 2024
1 parent 1eb563e commit 1b9a038
Show file tree
Hide file tree
Showing 21 changed files with 64 additions and 67 deletions.
24 changes: 11 additions & 13 deletions dev/dev_web/live/custom_sign_in_live.ex
Original file line number Diff line number Diff line change
Expand Up @@ -33,37 +33,35 @@ defmodule DevWeb.CustomSignInLive do
>
<:sign_in_extra :let={form}>
<div class="mt-2 mb-2 dark:text-white">
<%= label(form, :capcha,
{label(form, :capcha,
class: "block text-sm font-medium text-gray-700 mb-1 dark:text-white"
) %>
<%= text_input(form, :capcha,
)}
{text_input(form, :capcha,
class:
"appearance-none block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm placeholder-gray-400 focus:outline-none focus:ring-blue-pale-500 focus:border-blue-pale-500 sm:text-sm dark:text-black"
) %>
)}
</div>
</:sign_in_extra>
<:register_extra :let={form}>
<div class="mt-2 mb-2 dark:text-white">
<%= label(form, :name,
class: "block text-sm font-medium text-gray-700 mb-1 dark:text-white"
) %>
<%= text_input(form, :name,
{label(form, :name, class: "block text-sm font-medium text-gray-700 mb-1 dark:text-white")}
{text_input(form, :name,
class:
"appearance-none block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm placeholder-gray-400 focus:outline-none focus:ring-blue-pale-500 focus:border-blue-pale-500 sm:text-sm dark:text-black"
) %>
)}
</div>
</:register_extra>
<:reset_extra :let={form}>
<div class="mt-2 mb-2 dark:text-white">
<%= label(form, :capcha,
{label(form, :capcha,
class: "block text-sm font-medium text-gray-700 mb-1 dark:text-white"
) %>
<%= text_input(form, :capcha,
)}
{text_input(form, :capcha,
class:
"appearance-none block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm placeholder-gray-400 focus:outline-none focus:ring-blue-pale-500 focus:border-blue-pale-500 sm:text-sm dark:text-black"
) %>
)}
</div>
</:reset_extra>
</.live_component>
Expand Down
2 changes: 1 addition & 1 deletion dev/dev_web/live/home_page_live.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ defmodule DevWeb.HomePageLive do

~H"""
<%= if @current_user do %>
<h2>Current user: <%= @current_user.email %></h2>
<h2>Current user: {@current_user.email}</h2>
<.link navigate="/sign-out">Sign out</.link>
<% else %>
Expand Down
2 changes: 1 addition & 1 deletion dev/dev_web/templates/auth/failure.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
</pre>
</p>

<%= link("Home", to: Routes.live_path(@conn, DevWeb.HomePageLive)) %>
{link("Home", to: Routes.live_path(@conn, DevWeb.HomePageLive))}
2 changes: 1 addition & 1 deletion dev/dev_web/templates/auth/sign_out.html.heex
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<h2>Signed out</h2>

<%= link("Home", to: Routes.live_path(@conn, DevWeb.HomePageLive)) %>
{link("Home", to: Routes.live_path(@conn, DevWeb.HomePageLive))}
2 changes: 1 addition & 1 deletion dev/dev_web/templates/auth/success.html.heex
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Welcome back <%= @current_user.email %>. <%= link("Home", to: "/") %>
Welcome back {@current_user.email}. {link("Home", to: "/")}
6 changes: 3 additions & 3 deletions dev/dev_web/templates/layout/app.html.heex
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<main class="container">
<p class="alert alert-info" role="alert"><%= Phoenix.Flash.get(@flash, :info) %></p>
<p class="alert alert-danger" role="alert"><%= Phoenix.Flash.get(@flash, :error) %></p>
<%= @inner_content %>
<p class="alert alert-info" role="alert">{Phoenix.Flash.get(@flash, :info)}</p>
<p class="alert alert-danger" role="alert">{Phoenix.Flash.get(@flash, :error)}</p>
{@inner_content}
</main>
6 changes: 3 additions & 3 deletions dev/dev_web/templates/layout/live.html.heex
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<main class="container">
<p class="alert alert-info" role="alert" phx-click="lv:clear-flash" phx-value-key="info">
<%= Phoenix.Flash.get(@flash, :info) %>
{Phoenix.Flash.get(@flash, :info)}
</p>

<p class="alert alert-danger" role="alert" phx-click="lv:clear-flash" phx-value-key="error">
<%= Phoenix.Flash.get(@flash, :error) %>
{Phoenix.Flash.get(@flash, :error)}
</p>

<%= @inner_content %>
{@inner_content}
</main>
6 changes: 3 additions & 3 deletions dev/dev_web/templates/layout/root.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<%= csrf_meta_tag() %>
{csrf_meta_tag()}
<.live_title>
<%= assigns[:page_title] || "Dev" %>
{assigns[:page_title] || "Dev"}
</.live_title>
<script defer src="https://cdn.tailwindcss.com">
</script>
Expand All @@ -22,6 +22,6 @@
</script>
</head>
<body>
<%= @inner_content %>
{@inner_content}
</body>
</html>
2 changes: 1 addition & 1 deletion lib/ash_authentication_phoenix/components/apple.ex
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ defmodule AshAuthentication.Phoenix.Components.Apple do

def icon(assigns) do
~H"""
<%= raw(icon_svg(@icon, override_for(@overrides, :icon_class))) %>
{raw(icon_svg(@icon, override_for(@overrides, :icon_class)))}
"""
end

Expand Down
4 changes: 2 additions & 2 deletions lib/ash_authentication_phoenix/components/banner.ex
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ defmodule AshAuthentication.Phoenix.Components.Banner do
<% {nil, nil} -> %>
<% {nil, txt} -> %>
<div class={override_for(@overrides, :text_class)}>
<%= txt %>
{txt}
</div>
<% {hrf, txt} -> %>
<div class={override_for(@overrides, :text_class)}>
<a class={override_for(@overrides, :href_class)} href={hrf}>
<%= txt %>
{txt}
</a>
</div>
<% end %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ defmodule AshAuthentication.Phoenix.Components.HorizontalRule do
</div>
<div class={override_for(@overrides, :text_outer_class)}>
<span class={override_for(@overrides, :text_inner_class)}>
<%= override_for(@overrides, :text) %>
{override_for(@overrides, :text)}
</span>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion lib/ash_authentication_phoenix/components/magic_link.ex
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ defmodule AshAuthentication.Phoenix.Components.MagicLink do
~H"""
<div class={override_for(@overrides, :root_class)}>
<%= if @label do %>
<h2 class={override_for(@overrides, :label_class)}><%= @label %></h2>
<h2 class={override_for(@overrides, :label_class)}>{@label}</h2>
<% end %>
<.form
Expand Down
5 changes: 2 additions & 3 deletions lib/ash_authentication_phoenix/components/oauth2.ex
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ defmodule AshAuthentication.Phoenix.Components.OAuth2 do
href={auth_path(@socket, @subject_name, @auth_routes_prefix, @strategy, :request)}
class={override_for(@overrides, :link_class)}
>
<.icon icon={@strategy.icon} overrides={@overrides} />
Sign in with <%= strategy_name(@strategy) %>
<.icon icon={@strategy.icon} overrides={@overrides} /> Sign in with {strategy_name(@strategy)}
</a>
</div>
"""
Expand All @@ -60,7 +59,7 @@ defmodule AshAuthentication.Phoenix.Components.OAuth2 do
def icon(assigns) do
~H"""
<%= if @icon do %>
<%= raw(icon_svg(@icon, override_for(@overrides, :icon_class))) %>
{raw(icon_svg(@icon, override_for(@overrides, :icon_class)))}
<% end %>
"""
end
Expand Down
10 changes: 5 additions & 5 deletions lib/ash_authentication_phoenix/components/password.ex
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ defmodule AshAuthentication.Phoenix.Components.Password do
>
<%= if @sign_in_extra do %>
<div class={override_for(@overrides, :slot_class)}>
<%= render_slot(@sign_in_extra, form) %>
{render_slot(@sign_in_extra, form)}
</div>
<% end %>
Expand Down Expand Up @@ -219,7 +219,7 @@ defmodule AshAuthentication.Phoenix.Components.Password do
>
<%= if @register_extra do %>
<div class={override_for(@overrides, :slot_class)}>
<%= render_slot(@register_extra, form) %>
{render_slot(@register_extra, form)}
</div>
<% end %>
Expand Down Expand Up @@ -262,7 +262,7 @@ defmodule AshAuthentication.Phoenix.Components.Password do
>
<%= if @reset_extra do %>
<div class={override_for(@overrides, :slot_class)}>
<%= render_slot(@reset_extra, form) %>
{render_slot(@reset_extra, form)}
</div>
<% end %>
Expand Down Expand Up @@ -308,13 +308,13 @@ defmodule AshAuthentication.Phoenix.Components.Password do
if assigns[:to] do
~H"""
<.link patch={@to} class={override_for(@overrides, :toggler_class)}>
<%= @message %>
{@message}
</.link>
"""
else
~H"""
<a href="#" phx-click={toggle_js(@show, @hide)} class={override_for(@overrides, :toggler_class)}>
<%= @message %>
{@message}
</a>
"""
end
Expand Down
30 changes: 15 additions & 15 deletions lib/ash_authentication_phoenix/components/password/input.ex
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,16 @@ defmodule AshAuthentication.Phoenix.Components.Password.Input do

~H"""
<div class={override_for(@overrides, :field_class)}>
<%= label(@form, @identity_field, override_for(@overrides, :identity_input_label),
{label(@form, @identity_field, 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),
class: @input_class,
phx_debounce: override_for(@overrides, :input_debounce),
autofocus: "true",
placeholder: override_for(@overrides, :identity_input_placeholder)
) %>
)}
<.error form={@form} field={@identity_field} overrides={@overrides} />
</div>
"""
Expand Down Expand Up @@ -141,14 +141,14 @@ defmodule AshAuthentication.Phoenix.Components.Password.Input do

~H"""
<div class={override_for(@overrides, :field_class)}>
<%= label(@form, @password_field, override_for(@overrides, :password_input_label),
{label(@form, @password_field, 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,
value: input_value(@form, @password_field),
phx_debounce: override_for(@overrides, :input_debounce)
) %>
)}
<.error form={@form} field={@password_field} overrides={@overrides} />
</div>
"""
Expand Down Expand Up @@ -192,17 +192,17 @@ defmodule AshAuthentication.Phoenix.Components.Password.Input do

~H"""
<div class={override_for(@overrides, :field_class)}>
<%= label(
{label(
@form,
@password_confirmation_field,
override_for(@overrides, :password_confirmation_input_label),
class: override_for(@overrides, :label_class)
) %>
<%= password_input(@form, @password_confirmation_field,
)}
{password_input(@form, @password_confirmation_field,
class: @input_class,
value: input_value(@form, @password_confirmation_field),
phx_debounce: override_for(@overrides, :input_debounce)
) %>
)}
<.error form={@form} field={@password_confirmation_field} overrides={@overrides} />
</div>
"""
Expand Down Expand Up @@ -269,10 +269,10 @@ defmodule AshAuthentication.Phoenix.Components.Password.Input do
|> assign_new(:disable_text, fn -> nil end)

~H"""
<%= submit(@label,
{submit(@label,
class: override_for(@overrides, :submit_class),
phx_disable_with: @disable_text
) %>
)}
"""
end

Expand Down Expand Up @@ -310,7 +310,7 @@ defmodule AshAuthentication.Phoenix.Components.Password.Input do
<ul class={override_for(@overrides, :error_ul)}>
<%= for error <- @errors do %>
<li class={override_for(@overrides, :error_li)} phx-feedback-for={input_name(@form, @field)}>
<%= error %>
{error}
</li>
<% end %>
</ul>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ defmodule AshAuthentication.Phoenix.Components.Password.RegisterForm do
<div class={override_for(@overrides, :root_class)}>
<%= if @label do %>
<h2 class={override_for(@overrides, :label_class)}>
<%= @label %>
{@label}
</h2>
<% end %>
Expand All @@ -119,7 +119,7 @@ defmodule AshAuthentication.Phoenix.Components.Password.RegisterForm do
<%= if @inner_block do %>
<div class={override_for(@overrides, :slot_class)}>
<%= render_slot(@inner_block, form) %>
{render_slot(@inner_block, form)}
</div>
<% end %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ defmodule AshAuthentication.Phoenix.Components.Password.ResetForm do
<div class={override_for(@overrides, :root_class)}>
<%= if @label do %>
<h2 class={override_for(@overrides, :label_class)}>
<%= @label %>
{@label}
</h2>
<% end %>
Expand All @@ -105,7 +105,7 @@ defmodule AshAuthentication.Phoenix.Components.Password.ResetForm do
<%= if @inner_block do %>
<div class={override_for(@overrides, :slot_class)}>
<%= render_slot(@inner_block, form) %>
{render_slot(@inner_block, form)}
</div>
<% end %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ defmodule AshAuthentication.Phoenix.Components.Password.SignInForm do
~H"""
<div class={override_for(@overrides, :root_class)}>
<%= if @label do %>
<h2 class={override_for(@overrides, :label_class)}><%= @label %></h2>
<h2 class={override_for(@overrides, :label_class)}>{@label}</h2>
<% end %>
<.form
Expand All @@ -116,7 +116,7 @@ defmodule AshAuthentication.Phoenix.Components.Password.SignInForm do
<%= if @inner_block do %>
<div class={override_for(@overrides, :slot_class)}>
<%= render_slot(@inner_block, form) %>
{render_slot(@inner_block, form)}
</div>
<% end %>
Expand Down
4 changes: 2 additions & 2 deletions lib/ash_authentication_phoenix/components/reset/form.ex
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ defmodule AshAuthentication.Phoenix.Components.Reset.Form do
~H"""
<div class={override_for(@overrides, :root_class)}>
<%= if @label do %>
<h2 class={override_for(@overrides, :label_class)}><%= @label %></h2>
<h2 class={override_for(@overrides, :label_class)}>{@label}</h2>
<% end %>
<.form
Expand All @@ -117,7 +117,7 @@ defmodule AshAuthentication.Phoenix.Components.Reset.Form do
method="POST"
class={override_for(@overrides, :form_class)}
>
<%= hidden_input(form, :reset_token, value: @token) %>
{hidden_input(form, :reset_token, value: @token)}
<Input.error field={:reset_token} form={@form} overrides={@overrides} />
<Input.password_field strategy={@strategy} form={form} overrides={@overrides} />
Expand Down
6 changes: 3 additions & 3 deletions lib/ash_authentication_phoenix/templates/live.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
phx-click="lv:clear-flash"
phx-value-key="info"
>
<%= Phoenix.Flash.get(@flash, :info) %>
{Phoenix.Flash.get(@flash, :info)}
</p>
<% end %>

Expand All @@ -18,8 +18,8 @@
phx-click="lv:clear-flash"
phx-value-key="error"
>
<%= Phoenix.Flash.get(@flash, :error) %>
{Phoenix.Flash.get(@flash, :error)}
</p>
<% end %>

<%= @inner_content %>
{@inner_content}
Loading

0 comments on commit 1b9a038

Please sign in to comment.