Skip to content

Commit

Permalink
Merge pull request #3 from upmaru/feature/ops-564-clean-up-user-login…
Browse files Browse the repository at this point in the history
…-page

Feature/ops 564 clean up user login page
  • Loading branch information
zacksiri committed Feb 23, 2024
2 parents 2623614 + c7d0031 commit ff072d7
Show file tree
Hide file tree
Showing 5 changed files with 131 additions and 74 deletions.
2 changes: 1 addition & 1 deletion assets/tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports = {
theme: {
extend: {
colors: {
brand: "#FD4F00",
brand: "#818cf8",
},
fontFamily: {
sans: ['Inter var', ...defaultTheme.fontFamily.sans],
Expand Down
58 changes: 31 additions & 27 deletions lib/polar_web/components/core_components.ex
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ defmodule PolarWeb.CoreComponents do
data-cancel={JS.exec(@on_cancel, "phx-remove")}
class="relative z-50 hidden"
>
<div id={"#{@id}-bg"} class="bg-zinc-50/90 fixed inset-0 transition-opacity" aria-hidden="true" />
<div
id={"#{@id}-bg"}
class="bg-slate-50/90 fixed inset-0 transition-opacity"
aria-hidden="true"
/>
<div
class="fixed inset-0 overflow-y-auto"
aria-labelledby={"#{@id}-title"}
Expand All @@ -66,7 +70,7 @@ defmodule PolarWeb.CoreComponents do
phx-window-keydown={JS.exec("data-cancel", to: "##{@id}")}
phx-key="escape"
phx-click-away={JS.exec("data-cancel", to: "##{@id}")}
class="shadow-zinc-700/10 ring-zinc-700/10 relative hidden rounded-2xl bg-white p-14 shadow-lg ring-1 transition"
class="shadow-slate-700/10 ring-slate-700/10 relative hidden rounded-2xl bg-white p-14 shadow-lg ring-1 transition"
>
<div class="absolute top-6 right-5">
<button
Expand Down Expand Up @@ -202,7 +206,7 @@ defmodule PolarWeb.CoreComponents do
def simple_form(assigns) do
~H"""
<.form :let={f} for={@for} as={@as} {@rest}>
<div class="mt-10 space-y-8 bg-white">
<div class="space-y-8">
<%= render_slot(@inner_block, f) %>
<div :for={action <- @actions} class="mt-2 flex items-center justify-between gap-6">
<%= render_slot(action, f) %>
Expand Down Expand Up @@ -231,7 +235,7 @@ defmodule PolarWeb.CoreComponents do
<button
type={@type}
class={[
"phx-submit-loading:opacity-75 rounded-lg bg-zinc-900 hover:bg-zinc-700 py-2 px-3",
"phx-submit-loading:opacity-75 rounded-md bg-slate-900 hover:bg-slate-700 py-2 px-3",
"text-sm font-semibold leading-6 text-white active:text-white/80",
@class
]}
Expand Down Expand Up @@ -309,15 +313,15 @@ defmodule PolarWeb.CoreComponents do

~H"""
<div phx-feedback-for={@name}>
<label class="flex items-center gap-4 text-sm leading-6 text-zinc-600">
<label class="flex items-center gap-4 text-sm leading-6 text-slate-600">
<input type="hidden" name={@name} value="false" />
<input
type="checkbox"
id={@id}
name={@name}
value="true"
checked={@checked}
class="rounded border-zinc-300 text-zinc-900 focus:ring-0"
class="rounded border-slate-300 text-slate-900 focus:ring-0"
{@rest}
/>
<%= @label %>
Expand All @@ -334,7 +338,7 @@ defmodule PolarWeb.CoreComponents do
<select
id={@id}
name={@name}
class="mt-2 block w-full rounded-md border border-gray-300 bg-white shadow-sm focus:border-zinc-400 focus:ring-0 sm:text-sm"
class="mt-2 block w-full rounded-md border border-slate-300 bg-white shadow-sm focus:border-slate-400 focus:ring-0 sm:text-sm"
multiple={@multiple}
{@rest}
>
Expand All @@ -354,9 +358,9 @@ defmodule PolarWeb.CoreComponents do
id={@id}
name={@name}
class={[
"mt-2 block w-full rounded-lg text-zinc-900 focus:ring-0 sm:text-sm sm:leading-6",
"min-h-[6rem] phx-no-feedback:border-zinc-300 phx-no-feedback:focus:border-zinc-400",
@errors == [] && "border-zinc-300 focus:border-zinc-400",
"mt-2 block w-full rounded-lg text-slate-900 focus:ring-0 sm:text-sm sm:leading-6",
"min-h-[6rem] phx-no-feedback:border-slate-300 phx-no-feedback:focus:border-slate-400",
@errors == [] && "border-slate-300 focus:border-slate-400",
@errors != [] && "border-rose-400 focus:border-rose-400"
]}
{@rest}
Expand All @@ -377,9 +381,9 @@ defmodule PolarWeb.CoreComponents do
id={@id}
value={Phoenix.HTML.Form.normalize_value(@type, @value)}
class={[
"mt-2 block w-full rounded-lg text-zinc-900 focus:ring-0 sm:text-sm sm:leading-6",
"phx-no-feedback:border-zinc-300 phx-no-feedback:focus:border-zinc-400",
@errors == [] && "border-zinc-300 focus:border-zinc-400",
"mt-2 block w-full rounded-md text-slate-900 focus:ring-0 sm:text-sm sm:leading-6",
"phx-no-feedback:border-slate-300 phx-no-feedback:focus:border-slate-400",
@errors == [] && "border-slate-300 focus:border-slate-400",
@errors != [] && "border-rose-400 focus:border-rose-400"
]}
{@rest}
Expand All @@ -397,7 +401,7 @@ defmodule PolarWeb.CoreComponents do

def label(assigns) do
~H"""
<label for={@for} class="block text-sm font-semibold leading-6 text-zinc-800">
<label for={@for} class="block text-sm font-semibold leading-6 text-slate-800">
<%= render_slot(@inner_block) %>
</label>
"""
Expand Down Expand Up @@ -430,10 +434,10 @@ defmodule PolarWeb.CoreComponents do
~H"""
<header class={[@actions != [] && "flex items-center justify-between gap-6", @class]}>
<div>
<h1 class="text-lg font-semibold leading-8 text-zinc-800">
<h1 class="text-lg font-semibold leading-8 text-slate-800">
<%= render_slot(@inner_block) %>
</h1>
<p :if={@subtitle != []} class="mt-2 text-sm leading-6 text-zinc-600">
<p :if={@subtitle != []} class="mt-2 text-sm leading-6 text-slate-50">
<%= render_slot(@subtitle) %>
</p>
</div>
Expand Down Expand Up @@ -476,7 +480,7 @@ defmodule PolarWeb.CoreComponents do
~H"""
<div class="overflow-y-auto px-4 sm:overflow-visible sm:px-0">
<table class="w-[40rem] mt-11 sm:w-full">
<thead class="text-sm text-left leading-6 text-zinc-500">
<thead class="text-sm text-left leading-6 text-slate-500">
<tr>
<th :for={col <- @col} class="p-0 pb-4 pr-6 font-normal"><%= col[:label] %></th>
<th :if={@action != []} class="relative p-0 pb-4">
Expand All @@ -487,27 +491,27 @@ defmodule PolarWeb.CoreComponents do
<tbody
id={@id}
phx-update={match?(%Phoenix.LiveView.LiveStream{}, @rows) && "stream"}
class="relative divide-y divide-zinc-100 border-t border-zinc-200 text-sm leading-6 text-zinc-700"
class="relative divide-y divide-slate-100 border-t border-slate-200 text-sm leading-6 text-slate-700"
>
<tr :for={row <- @rows} id={@row_id && @row_id.(row)} class="group hover:bg-zinc-50">
<tr :for={row <- @rows} id={@row_id && @row_id.(row)} class="group hover:bg-slate-50">
<td
:for={{col, i} <- Enum.with_index(@col)}
phx-click={@row_click && @row_click.(row)}
class={["relative p-0", @row_click && "hover:cursor-pointer"]}
>
<div class="block py-4 pr-6">
<span class="absolute -inset-y-px right-0 -left-4 group-hover:bg-zinc-50 sm:rounded-l-xl" />
<span class={["relative", i == 0 && "font-semibold text-zinc-900"]}>
<span class="absolute -inset-y-px right-0 -left-4 group-hover:bg-slate-50 sm:rounded-l-xl" />
<span class={["relative", i == 0 && "font-semibold text-slate-900"]}>
<%= render_slot(col, @row_item.(row)) %>
</span>
</div>
</td>
<td :if={@action != []} class="relative w-14 p-0">
<div class="relative whitespace-nowrap py-4 text-right text-sm font-medium">
<span class="absolute -inset-y-px -right-4 left-0 group-hover:bg-zinc-50 sm:rounded-r-xl" />
<span class="absolute -inset-y-px -right-4 left-0 group-hover:bg-slate-50 sm:rounded-r-xl" />
<span
:for={action <- @action}
class="relative ml-4 font-semibold leading-6 text-zinc-900 hover:text-zinc-700"
class="relative ml-4 font-semibold leading-6 text-slate-900 hover:text-slate-700"
>
<%= render_slot(action, @row_item.(row)) %>
</span>
Expand Down Expand Up @@ -537,10 +541,10 @@ defmodule PolarWeb.CoreComponents do
def list(assigns) do
~H"""
<div class="mt-14">
<dl class="-my-4 divide-y divide-zinc-100">
<dl class="-my-4 divide-y divide-slate-100">
<div :for={item <- @item} class="flex gap-4 py-4 text-sm leading-6 sm:gap-8">
<dt class="w-1/4 flex-none text-zinc-500"><%= item.title %></dt>
<dd class="text-zinc-700"><%= render_slot(item) %></dd>
<dt class="w-1/4 flex-none text-slate-500"><%= item.title %></dt>
<dd class="text-slate-700"><%= render_slot(item) %></dd>
</div>
</dl>
</div>
Expand All @@ -562,7 +566,7 @@ defmodule PolarWeb.CoreComponents do
<div class="mt-16">
<.link
navigate={@navigate}
class="text-sm font-semibold leading-6 text-zinc-900 hover:text-zinc-700"
class="text-sm font-semibold leading-6 text-slate-900 hover:text-slate-700"
>
<.icon name="hero-arrow-left-solid" class="h-3 w-3" />
<%= render_slot(@inner_block) %>
Expand Down
87 changes: 63 additions & 24 deletions lib/polar_web/components/layouts/app.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@
</div>
<div class="hidden md:block">
<div class="ml-10 flex items-baseline space-x-4">
<!-- Current: "bg-slate-900 text-white", Default: "text-slate-300 hover:bg-slate-700 hover:text-white" -->
<!-- Current: "bg-slate-900 text-white", Default: "" -->
<.link
href={~p"/"}
class="bg-slate-900 text-white rounded-md px-3 py-2 text-sm font-medium"
class={
if assigns[:current_path] == ~p"/",
do: "bg-slate-900 text-white rounded-md px-3 py-2 text-sm font-medium",
else: "text-slate-300 hover:bg-slate-700 hover:text-white"
}
aria-current="page"
>
<%= gettext("Home") %>
Expand All @@ -21,27 +25,13 @@
</div>
<div class="hidden md:block">
<div class="ml-4 flex items-center md:ml-6">
<button
type="button"
class="relative rounded-full bg-slate-800 p-1 text-slate-400 hover:text-white focus:outline-none focus:ring-2 focus:ring-white focus:ring-offset-2 focus:ring-offset-slate-800"
<.link
href={~p"/users/log_in"}
class="text-slate-300 rounded-md px-3 py-2 text-sm font-medium hover:bg-slate-900 hover:text-white"
aria-current="page"
>
<span class="absolute -inset-1.5"></span>
<span class="sr-only">View notifications</span>
<svg
class="h-6 w-6"
fill="none"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="currentColor"
aria-hidden="true"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M14.857 17.082a23.848 23.848 0 005.454-1.31A8.967 8.967 0 0118 9.75v-.7V9A6 6 0 006 9v.75a8.967 8.967 0 01-2.312 6.022c1.733.64 3.56 1.085 5.455 1.31m5.714 0a24.255 24.255 0 01-5.714 0m5.714 0a3 3 0 11-5.714 0"
/>
</svg>
</button>
<%= gettext("Sign In") %>
</.link>
</div>
</div>
<div class="-mr-2 flex md:hidden">
Expand Down Expand Up @@ -87,15 +77,64 @@
<!-- Mobile menu, show/hide based on menu state. -->
<div class="md:hidden" id="mobile-menu">
<div class="space-y-1 px-2 pb-3 pt-2 sm:px-3">
<!-- Current: "bg-slate-900 text-white", Default: "text-slate-300 hover:bg-slate-700 hover:text-white" -->
<!-- Current: "bg-gray-900 text-white", Default: "text-gray-300 hover:bg-gray-700 hover:text-white" -->
<.link
href={~p"/"}
class="bg-slate-900 text-white rounded-md px-3 py-2 text-sm font-medium"
class="bg-slate-900 text-white block rounded-md px-3 py-2 text-base font-medium"
aria-current="page"
>
<%= gettext("Home") %>
</.link>
</div>
<div class="border-t border-gray-700 pb-3 pt-4">
<div class="flex items-center px-5">
<div class="ml-3">
<div class="text-base font-medium leading-none text-white">Tom Cook</div>
<div class="text-sm font-medium leading-none text-gray-400">[email protected]</div>
</div>
<button
type="button"
class="relative ml-auto flex-shrink-0 rounded-full bg-gray-800 p-1 text-gray-400 hover:text-white focus:outline-none focus:ring-2 focus:ring-white focus:ring-offset-2 focus:ring-offset-gray-800"
>
<span class="absolute -inset-1.5"></span>
<span class="sr-only">View notifications</span>
<svg
class="h-6 w-6"
fill="none"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="currentColor"
aria-hidden="true"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M14.857 17.082a23.848 23.848 0 005.454-1.31A8.967 8.967 0 0118 9.75v-.7V9A6 6 0 006 9v.75a8.967 8.967 0 01-2.312 6.022c1.733.64 3.56 1.085 5.455 1.31m5.714 0a24.255 24.255 0 01-5.714 0m5.714 0a3 3 0 11-5.714 0"
/>
</svg>
</button>
</div>
<div class="mt-3 space-y-1 px-2">
<a
href="#"
class="block rounded-md px-3 py-2 text-base font-medium text-gray-400 hover:bg-gray-700 hover:text-white"
>
Your Profile
</a>
<a
href="#"
class="block rounded-md px-3 py-2 text-base font-medium text-gray-400 hover:bg-gray-700 hover:text-white"
>
Settings
</a>
<a
href="#"
class="block rounded-md px-3 py-2 text-base font-medium text-gray-400 hover:bg-gray-700 hover:text-white"
>
Sign out
</a>
</div>
</div>
</div>
</nav>
</div>
Expand Down
6 changes: 5 additions & 1 deletion lib/polar_web/controllers/root_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ defmodule PolarWeb.RootController do
Streams.list_products([:active, :with_latest_version])
|> Enum.group_by(fn p -> {p.os, p.release} end)

render(conn, :show, page_title: gettext("OpsMaru Images"), grouped_products: products)
render(conn, :show,
current_path: current_path(conn),
page_title: gettext("OpsMaru Images"),
grouped_products: products
)
end
end
52 changes: 31 additions & 21 deletions lib/polar_web/live/user_login_live.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,44 @@ defmodule PolarWeb.UserLoginLive do

def render(assigns) do
~H"""
<div class="mx-auto max-w-sm">
<.header class="text-center">
Sign in to account
<div class="flex min-h-full flex-col justify-center py-12 sm:px-6 lg:px-8">
<.header class="sm:mx-auto sm:w-full sm:max-w-md text-center">
<img class="mx-auto h-10 w-auto" src={~p"/images/opsmaru-logo.png"} alt="opsmaru.com" />
<h2 class="mt-6 text-center text-2xl font-bold leading-9 tracking-tight text-white">
<%= gettext("Sign in to your account") %>
</h2>
<:subtitle>
Don't have an account?
<%= gettext("Don't have an account?") %>
<.link navigate={~p"/users/register"} class="font-semibold text-brand hover:underline">
Sign up
<%= gettext("Sign up") %>
</.link>
for an account now.
<%= gettext("for an account now.") %>
</:subtitle>
</.header>
<.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 />
<div class="mt-10 sm:mx-auto sm:w-full sm:max-w-[480px]">
<div class="bg-white px-6 py-12 shadow sm:rounded-lg sm:px-12">
<.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?
</.link>
</:actions>
<:actions>
<.button phx-disable-with="Signing in..." class="w-full">
Sign in <span aria-hidden="true">→</span>
</.button>
</:actions>
</.simple_form>
<:actions>
<.input field={@form[:remember_me]} type="checkbox" label="Keep me logged in" />
<.link href={~p"/users/reset_password"} class="text-sm font-semibold text-indigo-600">
<%= gettext("Forgot your password?") %>
</.link>
</:actions>
<:actions>
<.button
phx-disable-with="Signing in..."
class="w-full bg-indigo-600 hover:bg-indigo-500"
>
Sign in <span aria-hidden="true">→</span>
</.button>
</:actions>
</.simple_form>
</div>
</div>
</div>
"""
end
Expand Down

0 comments on commit ff072d7

Please sign in to comment.