From 41887672eac5428ad73b9cca63a222363de9a622 Mon Sep 17 00:00:00 2001 From: Harshad Sharma Date: Mon, 13 May 2024 15:55:37 +0530 Subject: [PATCH] Port login_live to Liliform --- .../components/layouts/app.html.heex | 202 +++++++++--------- lib/freedive_web/components/liliform.ex | 24 ++- lib/freedive_web/live/user_login_live.ex | 65 +++--- 3 files changed, 161 insertions(+), 130 deletions(-) diff --git a/lib/freedive_web/components/layouts/app.html.heex b/lib/freedive_web/components/layouts/app.html.heex index 9f460af..420dc72 100644 --- a/lib/freedive_web/components/layouts/app.html.heex +++ b/lib/freedive_web/components/layouts/app.html.heex @@ -1,112 +1,110 @@ -
-
- <.flash_group flash={@flash} /> - <.navbar is-fixed-top> - <.navbar_brand> - <.navbar_item> - <.title is-4> - Freedive - - +
+ <.flash_group flash={@flash} /> + <.navbar is-fixed-top> + <.navbar_brand> + <.navbar_item> + <.title is-4> + Freedive + + - <.navbar_burger target="navbar_top" /> - + <.navbar_burger target="navbar_top" /> + - <.navbar_menu id="navbar_top"> - <%= if @current_user do %> - <.navbar_start> - <.navbar_item has-dropdown is-hoverable> - <.navbar_link> - Compute - - - <.navbar_dropdown> - <.navbar_item> - <.link>Bastille Jails - - - - - <.navbar_item has-dropdown is-hoverable> - <.navbar_link> - Storage - - - <.navbar_dropdown> - <.navbar_item> - <.link>Shared Folders - - - - - <.navbar_item has-dropdown is-hoverable> - <.navbar_link> - Network - - - <.navbar_dropdown> - <.navbar_item> - <.link>Private Network - - - - - <% end %> - - <.navbar_end> - <%= if @current_user do %> - <.navbar_item> - <%= @current_user.email %> - - - <.navbar_item has-dropdown is-hoverable> - <.navbar_link> - System - - - <.navbar_dropdown> - <.navbar_item> - <.link>Software Updates - - <.navbar_divider /> - <.navbar_item> - <.link>Packages - - <.navbar_item> - <.link>Services - - - - <% end %> + <.navbar_menu id="navbar_top"> + <%= if @current_user do %> + <.navbar_start> <.navbar_item has-dropdown is-hoverable> <.navbar_link> - Account + Compute <.navbar_dropdown> - <%= if @current_user do %> - <.navbar_item> - <.link href={~p"/users/settings"}> - Settings - - - <.navbar_item> - <.link href={~p"/users/log_out"} method="delete"> - Log out - - - <% else %> - <.navbar_item> - <.link href={~p"/users/log_in"}> - Log in - - - <% end %> + <.navbar_item> + <.link>Bastille Jails + - - - - <%= @inner_content %> -
+ + <.navbar_item has-dropdown is-hoverable> + <.navbar_link> + Storage + + + <.navbar_dropdown> + <.navbar_item> + <.link>Shared Folders + + + + + <.navbar_item has-dropdown is-hoverable> + <.navbar_link> + Network + + + <.navbar_dropdown> + <.navbar_item> + <.link>Private Network + + + + + <% end %> + + <.navbar_end> + <%= if @current_user do %> + <.navbar_item> + <%= @current_user.email %> + + + <.navbar_item has-dropdown is-hoverable> + <.navbar_link> + System + + + <.navbar_dropdown> + <.navbar_item> + <.link>Software Updates + + <.navbar_divider /> + <.navbar_item> + <.link>Packages + + <.navbar_item> + <.link>Services + + + + <% end %> + <.navbar_item has-dropdown is-hoverable> + <.navbar_link> + Account + + + <.navbar_dropdown> + <%= if @current_user do %> + <.navbar_item> + <.link href={~p"/users/settings"}> + Settings + + + <.navbar_item> + <.link href={~p"/users/log_out"} method="delete"> + Log out + + + <% else %> + <.navbar_item> + <.link href={~p"/users/log_in"}> + Log in + + + <% end %> + + + + + + <%= @inner_content %>
diff --git a/lib/freedive_web/components/liliform.ex b/lib/freedive_web/components/liliform.ex index 52f369d..78d3840 100644 --- a/lib/freedive_web/components/liliform.ex +++ b/lib/freedive_web/components/liliform.ex @@ -248,6 +248,28 @@ defmodule Liliform.Components do """ end + @doc """ + Renders block. + """ + attr :class, :string, default: nil, doc: "the optional class of the block" + attr :rest, :global, doc: "the arbitrary HTML attributes to add to the block" + + slot :inner_block, required: true, doc: "the inner block that renders the block content" + + def block(assigns) do + assigns = + assigns + |> extend_class("block") + |> set_phx_attributes() + |> set_bulma_classes() + + ~H""" +
+ <%= render_slot(@inner_block) %> +
+ """ + end + @doc """ Renders container. """ @@ -956,7 +978,7 @@ defmodule Liliform.Components do <.form :let={f} for={@for} as={@as} {@rest}>
<%= render_slot(@inner_block, f) %> -
+
<%= render_slot(action, f) %>
diff --git a/lib/freedive_web/live/user_login_live.ex b/lib/freedive_web/live/user_login_live.ex index 6d6d00f..705b667 100644 --- a/lib/freedive_web/live/user_login_live.ex +++ b/lib/freedive_web/live/user_login_live.ex @@ -3,35 +3,46 @@ defmodule FreediveWeb.UserLoginLive do def render(assigns) do ~H""" -
- <.header class="text-center"> - Log in to account - <:subtitle> - Don't have an account? - <.link navigate={~p"/users/register"} class="font-semibold text-brand hover:underline"> - Sign up - - for an account now. - - + <.hero> + <.container> + <.block> + <.title is-4> + Log in to account + + <.subtitle is-6 has-text-grey> + freedive@hostname + + - <.simple_form for={@form} id="login_form" action={~p"/users/log_in"} phx-update="ignore"> - <.input field={@form[:email]} type="email" label="Email" required /> - <.input field={@form[:password]} type="password" label="Password" required /> + <.column is-6-desktop> + <.simple_form for={@form} id="login_form" action={~p"/users/log_in"} phx-update="ignore"> + <.input field={@form[:email]} type="email" label="Email" required /> + <.input field={@form[:password]} type="password" label="Password" required /> - <:actions> - <.input field={@form[:remember_me]} type="checkbox" label="Keep me logged in" /> - <.link href={~p"/users/reset_password"} class="text-sm font-semibold"> - Forgot your password? - - - <:actions> - <.button phx-disable-with="Logging in..." class="w-full" type="submit"> - Log in - - - -
+ <:actions> + <.input field={@form[:remember_me]} type="checkbox" label="Keep me logged in" /> + <.link href={~p"/users/reset_password"} class="text-sm font-semibold"> + Forgot your password? + + + <:actions> + <.button type="submit" phx-disable-with="Logging in..." is-info> + Log in + + + <:actions> + <.block> + Don't have an account? + <.link navigate={~p"/users/register"} class="font-semibold text-brand hover:underline"> + Sign up + + for an account now. + + + + + + """ end