make app responsive

This commit is contained in:
2022-02-15 23:52:44 -05:00
parent 669afd5dcb
commit d6e4090650
35 changed files with 470 additions and 422 deletions

View File

@ -7,7 +7,7 @@
let={f}
for={@changeset}
id="shot-group-form"
class="grid grid-cols-3 justify-center items-center space-y-4"
class="flex flex-col sm:grid sm:grid-cols-3 justify-center items-center space-y-4"
phx-target={@myself}
phx-change="validate"
phx-submit="save"

View File

@ -26,8 +26,11 @@ defmodule CanneryWeb.Components.InviteCard do
</h2>
<% end %>
<div class="flex flex-row justify-center items-center space-x-4">
<code id={"code-#{@invite.id}"} class="text-xs px-4 py-2 rounded-lg text-gray-100 bg-primary-800"><%= Routes.user_registration_url(Endpoint, :new, invite: @invite.token) %>
<div class="flex flex-row flex-wrap justify-center items-center">
<code
id={"code-#{@invite.id}"}
class="mx-2 my-1 text-xs px-4 py-2 rounded-lg text-center break-all text-gray-100 bg-primary-800"
><%= Routes.user_registration_url(Endpoint, :new, invite: @invite.token) %>
</code>
<%= if @code_actions do %>

View File

@ -5,7 +5,8 @@
<%= if @containers |> Enum.empty?() do %>
<h2 class="title text-xl text-primary-500">
<%= gettext("No other containers") %> <%= display_emoji("😔") %>
<%= gettext("No other containers") %>
<%= display_emoji("😔") %>
</h2>
<%= live_patch(dgettext("actions", "Add another container!"),

View File

@ -13,102 +13,105 @@ defmodule CanneryWeb.Components.Topbar do
%{results: [], title_content: nil, flash: nil, current_user: nil} |> Map.merge(assigns)
~H"""
<header class="mb-8 px-8 py-4 w-full bg-primary-400 overflow-x-hidden">
<nav role="navigation">
<div class="flex flex-row justify-between items-center space-x-4">
<div class="flex flex-row justify-start items-center space-x-2">
<%= link to: Routes.live_path(Endpoint, HomeLive) do %>
<h1 class="leading-5 text-xl text-white hover:underline">
Cannery
</h1>
<% end %>
<%= if @title_content do %>
<span>|</span>
<%= @title_content %>
<% end %>
</div>
<nav role="navigation" class="mb-8 px-8 py-4 w-full bg-primary-400">
<div class="flex flex-col sm:flex-row justify-between items-center">
<div class="mb-4 sm:mb-0 sm:mr-8 flex flex-row justify-start items-center space-x-2">
<%= link to: Routes.live_path(Endpoint, HomeLive) do %>
<h1 class="mx-2 my-1 leading-5 text-xl text-white hover:underline">
Cannery
</h1>
<% end %>
<ul class="flex flex-col sm:flex-row flex-wrap justify-center items-center
space-x-4 text-lg text-white text-ellipsis">
<%= if @current_user do %>
<li>
<%= link(gettext("Tags"),
<%= if @title_content do %>
<span class="mx-2 my-1">
|
</span>
<%= @title_content %>
<% end %>
</div>
<hr class="mb-2 sm:hidden hr-light">
<ul class="flex flex-row flex-wrap justify-center items-center
text-lg text-white text-ellipsis">
<%= if @current_user do %>
<li class="mx-2 my-1">
<%= link(gettext("Tags"),
class: "hover:underline",
to: Routes.tag_index_path(Endpoint, :index)
) %>
</li>
<li class="mx-2 my-1">
<%= link(gettext("Containers"),
class: "hover:underline",
to: Routes.container_index_path(Endpoint, :index)
) %>
</li>
<li class="mx-2 my-1">
<%= link(gettext("Ammo"),
class: "hover:underline",
to: Routes.ammo_type_index_path(Endpoint, :index)
) %>
</li>
<li class="mx-2 my-1">
<%= link(gettext("Manage"),
class: "hover:underline",
to: Routes.ammo_group_index_path(Endpoint, :index)
) %>
</li>
<li class="mx-2 my-1">
<%= link(gettext("Range"),
class: "hover:underline",
to: Routes.range_index_path(Endpoint, :index)
) %>
</li>
<%= if @current_user.role == :admin do %>
<li class="mx-2 my-1">
<%= link(gettext("Invites"),
class: "hover:underline",
to: Routes.tag_index_path(Endpoint, :index)
to: Routes.invite_index_path(Endpoint, :index)
) %>
</li>
<li>
<%= link(gettext("Containers"),
class: "hover:underline",
to: Routes.container_index_path(Endpoint, :index)
) %>
</li>
<li>
<%= link(gettext("Ammo"),
class: "hover:underline",
to: Routes.ammo_type_index_path(Endpoint, :index)
) %>
</li>
<li>
<%= link(gettext("Manage"),
class: "hover:underline",
to: Routes.ammo_group_index_path(Endpoint, :index)
) %>
</li>
<li>
<%= link(gettext("Range"),
class: "hover:underline",
to: Routes.range_index_path(Endpoint, :index)
) %>
</li>
<%= if @current_user.role == :admin do %>
<li>
<%= link(gettext("Invites"),
class: "hover:underline",
to: Routes.invite_index_path(Endpoint, :index)
) %>
</li>
<% end %>
<li class="mx-2 my-1">
<%= link(@current_user.email,
class: "hover:underline truncate",
to: Routes.user_settings_path(Endpoint, :edit)
) %>
</li>
<li class="mx-2 my-1">
<%= link to: Routes.user_session_path(Endpoint, :delete),
method: :delete,
data: [confirm: dgettext("prompts", "Are you sure you want to log out?")] do %>
<i class="fas fa-sign-out-alt"></i>
<% end %>
<li>
<%= link(@current_user.email,
class: "hover:underline truncate",
to: Routes.user_settings_path(Endpoint, :edit)
) %>
</li>
<li>
<%= link to: Routes.user_session_path(Endpoint, :delete),
method: :delete,
data: [confirm: dgettext("prompts", "Are you sure you want to log out?")] do %>
<i class="fas fa-sign-out-alt"></i>
</li>
<%= if @current_user.role == :admin and function_exported?(Routes, :live_dashboard_path, 2) do %>
<li class="mx-2 my-1">
<%= link to: Routes.live_dashboard_path(Endpoint, :home) do %>
<i class="fas fa-tachometer-alt"></i>
<% end %>
</li>
<%= if @current_user.role == :admin and function_exported?(Routes, :live_dashboard_path, 2) do %>
<li>
<%= link to: Routes.live_dashboard_path(Endpoint, :home) do %>
<i class="fas fa-tachometer-alt"></i>
<% end %>
</li>
<% end %>
<% else %>
<%= if Accounts.allow_registration?() do %>
<li>
<%= link(dgettext("actions", "Register"),
class: "hover:underline",
to: Routes.user_registration_path(Endpoint, :new)
) %>
</li>
<% end %>
<li>
<%= link(dgettext("actions", "Log in"),
<% end %>
<% else %>
<%= if Accounts.allow_registration?() do %>
<li class="mx-2 my-1">
<%= link(dgettext("actions", "Register"),
class: "hover:underline",
to: Routes.user_session_path(Endpoint, :new)
to: Routes.user_registration_path(Endpoint, :new)
) %>
</li>
<% end %>
</ul>
</div>
</nav>
</header>
<li class="mx-2 my-1">
<%= link(dgettext("actions", "Log in"),
class: "hover:underline",
to: Routes.user_session_path(Endpoint, :new)
) %>
</li>
<% end %>
</ul>
</div>
</nav>
"""
end
end

View File

@ -13,7 +13,7 @@ defmodule CanneryWeb.Components.UserCard do
border border-gray-400 rounded-lg shadow-lg hover:shadow-md
transition-all duration-300 ease-in-out"
>
<h1 class="px-4 py-2 rounded-lg title text-xl">
<h1 class="px-4 py-2 rounded-lg title text-xl break-all">
<%= @user.email %>
</h1>

View File

@ -10,7 +10,7 @@
phx-target={@myself}
phx-change="validate"
phx-submit="save"
class="grid grid-cols-3 justify-center items-center space-y-4"
class="flex flex-col sm:grid sm:grid-cols-3 justify-center items-center space-y-4"
>
<%= if @changeset.action && not @changeset.valid? do %>
<div class="invalid-feedback col-span-3 text-center">

View File

@ -1,11 +1,12 @@
<div class="mx-8 flex flex-col space-y-8 justify-center items-center">
<div class="flex flex-col space-y-8 justify-center items-center">
<h1 class="title text-2xl title-primary-500">
<%= gettext("Ammo") %>
</h1>
<%= if @ammo_groups |> Enum.empty?() do %>
<h2 class="title text-xl text-primary-500">
<%= gettext("No Ammo") %> <%= display_emoji("😔") %>
<%= gettext("No Ammo") %>
<%= display_emoji("😔") %>
</h2>
<%= live_patch(dgettext("actions", "Add your first box!"),
@ -35,7 +36,7 @@
<%= gettext("Notes") %>
</th>
<th class="p-2">
<%= gettext("Staging") %>
<%= gettext("Staged for Range") %>
</th>
<th class="p-2">
<%= gettext("Container") %>
@ -75,7 +76,7 @@
phx-click="toggle_staged"
phx-value-ammo_group_id={ammo_group.id}
>
<%= if ammo_group.staged, do: gettext("Unstage from range"), else: gettext("Stage for range") %>
<%= if ammo_group.staged, do: gettext("Unstage"), else: gettext("Stage") %>
</button>
</td>
@ -88,7 +89,7 @@
<% end %>
</td>
<td class="p-2 w-full h-full space-x-2 flex justify-center items-center">
<td class="p-2">
<div class="px-4 py-2 space-x-4 flex justify-center items-center">
<%= live_redirect to: Routes.ammo_group_show_path(@socket, :show, ammo_group),
class: "text-primary-500 link" do %>

View File

@ -24,25 +24,25 @@
<% end %>
</div>
<div class="flex space-x-4 justify-center items-center text-primary-500">
<div class="flex flex-wrap justify-center items-center text-primary-500">
<%= live_patch(dgettext("actions", "Ammo Details"),
to: Routes.ammo_type_show_path(Endpoint, :show, @ammo_group.ammo_type),
class: "btn btn-primary"
class: "mx-4 my-2 btn btn-primary"
) %>
<%= live_patch to: Routes.ammo_group_show_path(Endpoint, :edit, @ammo_group),
class: "text-primary-500 link" do %>
class: "mx-4 my-2 text-primary-500 link" do %>
<i class="fa-fw fa-lg fas fa-edit"></i>
<% end %>
<%= link to: "#",
class: "text-primary-500 link",
class: "mx-4 my-2 text-primary-500 link",
phx_click: "delete",
data: [confirm: dgettext("prompts", "Are you sure you want to delete this ammo?")] do %>
<i class="fa-fw fa-lg fas fa-trash"></i>
<% end %>
<button type="button" class="btn btn-primary" phx-click="toggle_staged">
<button type="button" class="mx-4 my-2 btn btn-primary" phx-click="toggle_staged">
<%= if @ammo_group.staged, do: gettext("Unstage from range"), else: gettext("Stage for range") %>
</button>

View File

@ -9,7 +9,7 @@
phx-target={@myself}
phx-change="validate"
phx-submit="save"
class="grid grid-cols-3 justify-center items-center space-y-4"
class="flex flex-col sm:grid sm:grid-cols-3 justify-center items-center space-y-4"
>
<%= if @changeset.action && not @changeset.valid? do %>
<div class="invalid-feedback col-span-3 text-center">

View File

@ -1,11 +1,12 @@
<div class="mx-8 flex flex-col space-y-8 justify-center items-center">
<div class="flex flex-col space-y-8 justify-center items-center">
<h1 class="title text-2xl title-primary-500">
<%= gettext("Ammo Types") %>
</h1>
<%= if @ammo_types |> Enum.empty?() do %>
<h2 class="title text-xl text-primary-500">
<%= gettext("No Ammo Types") %> <%= display_emoji("😔") %>
<%= gettext("No Ammo Types") %>
<%= display_emoji("😔") %>
</h2>
<%= live_patch(dgettext("actions", "Add your first type!"),

View File

@ -7,7 +7,7 @@
let={f}
for={:tag}
id="add-tag-to-container-form"
class="grid grid-cols-3 justify-center items-center space-x-2"
class="flex flex-col sm:grid sm:grid-cols-3 justify-center items-center space-x-2"
phx-target={@myself}
phx-submit="save"
>

View File

@ -6,7 +6,7 @@
let={f}
for={@changeset}
id="container-form"
class="grid grid-cols-3 justify-center items-center space-y-4"
class="flex flex-col sm:grid sm:grid-cols-3 justify-center items-center space-y-4"
phx-target={@myself}
phx-change="validate"
phx-submit="save"

View File

@ -5,7 +5,8 @@
<%= if @containers |> Enum.empty?() do %>
<h2 class="title text-xl text-primary-500">
<%= gettext("No containers") %> <%= display_emoji("😔") %>
<%= gettext("No containers") %>
<%= display_emoji("😔") %>
</h2>
<%= live_patch(dgettext("actions", "Add your first container!"),
@ -19,7 +20,7 @@
) %>
<% end %>
<div class="flex flex-row flex-wrap">
<div class="flex flex-row flex-wrap justify-center items-center">
<%= for container <- @containers do %>
<.container_card container={container}>
<%= live_patch to: Routes.container_index_path(@socket, :edit, container),

View File

@ -44,7 +44,8 @@
<%= if @container.tags |> Enum.empty?() do %>
<div class="flex flex-row justify-center items-center space-x-4">
<h2 class="title text-lg text-primary-500">
<%= gettext("No tags for this container") %> <%= display_emoji("😔") %>
<%= gettext("No tags for this container") %>
<%= display_emoji("😔") %>
</h2>
<%= live_patch(dgettext("actions", "Why not add one?"),

View File

@ -6,7 +6,7 @@
let={f}
for={@changeset}
id="invite-form"
class="grid grid-cols-3 justify-center items-center space-y-4"
class="flex flex-col sm:grid sm:grid-cols-3 justify-center items-center space-y-4"
phx-target={@myself}
phx-change="validate"
phx-submit="save"

View File

@ -5,7 +5,8 @@
<%= if @invites |> Enum.empty?() do %>
<h1 class="title text-xl text-primary-500">
<%= gettext("No invites") %> <%= display_emoji("😔") %>
<%= gettext("No invites") %>
<%= display_emoji("😔") %>
</h1>
<%= live_patch(dgettext("actions", "Invite someone new!"),
@ -26,7 +27,7 @@
<form phx-submit={JS.dispatch("cannery:clipcopy", to: "#code-#{invite.id}")}>
<button
type="submit"
class="btn btn-primary"
class="mx-2 my-1 btn btn-primary"
phx-click="copy_to_clipboard"
phx-value-invite_id={"#code-#{invite.id}"}
>

View File

@ -7,7 +7,7 @@
let={f}
for={@changeset}
id="shot-group-form"
class="grid grid-cols-3 justify-center items-center space-y-4"
class="flex flex-col sm:grid sm:grid-cols-3 justify-center items-center space-y-4"
phx-target={@myself}
phx-change="validate"
phx-submit="save"

View File

@ -1,11 +1,12 @@
<div class="mx-8 flex flex-col space-y-8 justify-center items-center">
<div class="flex flex-col space-y-8 justify-center items-center">
<h1 class="title text-2xl title-primary-500">
<%= gettext("Range day") %>
</h1>
<%= if @ammo_groups |> Enum.empty?() do %>
<h1 class="title text-xl text-primary-500">
<%= gettext("No ammo staged") %> <%= display_emoji("😔") %>
<%= gettext("No ammo staged") %>
<%= display_emoji("😔") %>
</h1>
<%= live_patch(dgettext("actions", "Why not get some ready to shoot?"),
@ -42,7 +43,8 @@
<%= if @shot_groups |> Enum.empty?() do %>
<h1 class="title text-xl text-primary-500">
<%= gettext("No shots recorded") %> <%= display_emoji("😔") %>
<%= gettext("No shots recorded") %>
<%= display_emoji("😔") %>
</h1>
<% else %>
<h1 class="title text-2xl text-primary-500">
@ -89,18 +91,20 @@
</td>
<td class="p-2 w-full h-full space-x-2 flex justify-center items-center">
<%= live_patch to: Routes.range_index_path(Endpoint, :edit, shot_group),
class: "text-primary-500 link" do %>
<i class="fa-fw fa-lg fas fa-edit"></i>
<% end %>
<div class="px-4 py-2 space-x-4 flex justify-center items-center">
<%= live_patch to: Routes.range_index_path(Endpoint, :edit, shot_group),
class: "text-primary-500 link" do %>
<i class="fa-fw fa-lg fas fa-edit"></i>
<% end %>
<%= link to: "#",
class: "text-primary-500 link",
phx_click: "delete",
phx_value_id: shot_group.id,
data: [confirm: dgettext("prompts", "Are you sure you want to delete this shot record?")] do %>
<i class="fa-fw fa-lg fas fa-trash"></i>
<% end %>
<%= link to: "#",
class: "text-primary-500 link",
phx_click: "delete",
phx_value_id: shot_group.id,
data: [confirm: dgettext("prompts", "Are you sure you want to delete this shot record?")] do %>
<i class="fa-fw fa-lg fas fa-trash"></i>
<% end %>
</div>
</td>
</tr>
<% end %>

View File

@ -36,7 +36,7 @@ defmodule CanneryWeb.TagLive.FormComponent do
let={f}
for={@changeset}
id="tag-form"
class="grid grid-cols-3 justify-center items-center space-y-4"
class="flex flex-col sm:grid sm:grid-cols-3 justify-center items-center space-y-4"
phx-target={@myself}
phx-change="validate"
phx-submit="save"

View File

@ -7,7 +7,8 @@
</p>
<%= if @tags |> Enum.empty?() do %>
<h2 class="title text-xl text-primary-500">
<%= gettext("No tags") %> <%= display_emoji("😔") %>
<%= gettext("No tags") %>
<%= display_emoji("😔") %>
</h2>
<%= live_patch(dgettext("actions", "Make your first tag!"),
@ -20,7 +21,7 @@
class: "btn btn-primary"
) %>
<% end %>
<div class="flex flex-row flex-wrap">
<div class="flex flex-row flex-wrap justify-center items-center">
<%= for tag <- @tags do %>
<.tag_card tag={tag}>
<%= live_patch to: Routes.tag_index_path(Endpoint, :edit, tag),

View File

@ -16,5 +16,7 @@
</div>
</header>
<%= @inner_content %>
<div class="mx-4 sm:mx-8 md:mx-16">
<%= @inner_content %>
</div>
</main>

View File

@ -17,5 +17,7 @@
</div>
</header>
<%= @inner_content %>
<div class="mx-4 sm:mx-8 md:mx-16">
<%= @inner_content %>
</div>
</main>

View File

@ -1,32 +1,33 @@
<div class="flex flex-col justify-center items-center space-y-4">
<div class="mb-8 flex flex-col justify-center items-center space-y-4">
<h1 class="title text-primary-500 text-xl">
<%= dgettext("actions", "Resend confirmation instructions") %>
</h1>
<%= form_for :user,
Routes.user_confirmation_path(@conn, :create),
[class: "flex flex-col justify-center items-center space-y-4"],
[class: "flex flex-col sm:grid sm:grid-cols-3
justify-center items-center text-center space-y-4"],
fn f -> %>
<div class="grid grid-cols-3 justify-center items-center text-center space-x-4">
<%= label(f, :email, class: "title text-lg text-primary-500") %>
<%= email_input(f, :email, required: true, class: "input input-primary col-span-2") %>
</div>
<%= label(f, :email, class: "title text-lg text-primary-500") %>
<%= email_input(f, :email, required: true, class: "input input-primary col-span-2") %>
<%= submit(dgettext("actions", "Resend confirmation instructions"), class: "btn btn-primary") %>
<%= submit(dgettext("actions", "Resend confirmation instructions"),
class: "mx-auto my-4 btn btn-primary col-span-3"
) %>
<% end %>
<hr class="hr">
<hr class="hr">
<div class="flex flex-row justify-center items-center space-x-4">
<%= if Accounts.allow_registration?() do %>
<%= link(dgettext("actions", "Register"),
to: Routes.user_registration_path(@conn, :new),
class: "btn btn-primary"
) %>
<% end %>
<%= link(dgettext("actions", "Log in"),
to: Routes.user_session_path(@conn, :new),
<div class="flex flex-row justify-center items-center space-x-4">
<%= if Accounts.allow_registration?() do %>
<%= link(dgettext("actions", "Register"),
to: Routes.user_registration_path(@conn, :new),
class: "btn btn-primary"
) %>
</div>
<% end %>
<% end %>
<%= link(dgettext("actions", "Log in"),
to: Routes.user_session_path(@conn, :new),
class: "btn btn-primary"
) %>
</div>
</div>

View File

@ -1,14 +1,15 @@
<div class="flex flex-col justify-center items-center space-y-4">
<div class="mb-8 flex flex-col justify-center items-center space-y-4">
<h1 class="title text-primary-500 text-xl">
<%= dgettext("actions", "Register") %>
</h1>
<%= form_for @changeset,
Routes.user_registration_path(@conn, :create),
[class: "flex flex-col justify-center items-center space-y-4"],
[class: "flex flex-col sm:grid sm:grid-cols-3
justify-center items-center text-center space-y-4"],
fn f -> %>
<%= if @changeset.action && not @changeset.valid? do %>
<div class="alert alert-danger">
<div class="alert alert-danger col-span-3">
<p>
<%= dgettext("errors", "Oops, something went wrong! Please check the errors below.") %>
</p>
@ -19,31 +20,27 @@
<%= hidden_input(f, :invite_token, value: @invite.token) %>
<% end %>
<div class="grid grid-cols-3 justify-center items-center text-center space-x-4">
<%= label(f, :email, class: "title text-lg text-primary-500") %>
<%= email_input(f, :email, required: true, class: "input input-primary col-span-2") %>
</div>
<%= error_tag(f, :email) %>
<%= label(f, :email, class: "title text-lg text-primary-500") %>
<%= email_input(f, :email, required: true, class: "input input-primary col-span-2") %>
<%= error_tag(f, :email, "col-span-3") %>
<div class="grid grid-cols-3 justify-center items-center text-center space-x-4">
<%= label(f, :password, class: "title text-lg text-primary-500") %>
<%= password_input(f, :password, required: true, class: "input input-primary col-span-2") %>
</div>
<%= error_tag(f, :password) %>
<%= label(f, :password, class: "title text-lg text-primary-500") %>
<%= password_input(f, :password, required: true, class: "input input-primary col-span-2") %>
<%= error_tag(f, :password, "col-span-3") %>
<%= submit(dgettext("actions", "Register"), class: "btn btn-primary") %>
<hr class="hr">
<div class="flex flex-row justify-center items-center space-x-4">
<%= link(dgettext("actions", "Log in"),
to: Routes.user_session_path(@conn, :new),
class: "btn btn-primary"
) %>
<%= link(dgettext("actions", "Forgot your password?"),
to: Routes.user_reset_password_path(@conn, :new),
class: "btn btn-primary"
) %>
</div>
<%= submit(dgettext("actions", "Register"), class: "mx-auto my-4 btn btn-primary col-span-3") %>
<% end %>
<hr class="hr">
<div class="flex flex-row justify-center items-center space-x-4">
<%= link(dgettext("actions", "Log in"),
to: Routes.user_session_path(@conn, :new),
class: "btn btn-primary"
) %>
<%= link(dgettext("actions", "Forgot your password?"),
to: Routes.user_reset_password_path(@conn, :new),
class: "btn btn-primary"
) %>
</div>
</div>

View File

@ -1,47 +1,44 @@
<div class="flex flex-col justify-center items-center space-y-4">
<div class="mb-8 flex flex-col justify-center items-center space-y-4">
<h1 class="title text-primary-500 text-xl">
<%= dgettext("actions", "Reset password") %>
</h1>
<%= form_for @changeset,
Routes.user_reset_password_path(@conn, :update, @token),
[class: "flex flex-col justify-center items-center space-y-4"],
[class: "flex flex-col sm:grid sm:grid-cols-3
justify-center items-center text-center space-y-4"],
fn f -> %>
<%= if @changeset.action && not @changeset.valid? do %>
<div class="alert alert-danger">
<div class="alert alert-danger col-span-3">
<p>
<%= dgettext("errors", "Oops, something went wrong! Please check the errors below.") %>
</p>
</div>
<% end %>
<div class="grid grid-cols-3 justify-center items-center text-center space-x-4">
<%= label(f, :password, "New password", class: "title text-lg text-primary-500") %>
<%= password_input(f, :password, required: true, class: "input input-primary col-span-2") %>
</div>
<%= error_tag(f, :password) %>
<%= label(f, :password, "New password", class: "title text-lg text-primary-500") %>
<%= password_input(f, :password, required: true, class: "input input-primary col-span-2") %>
<%= error_tag(f, :password, "col-span-3") %>
<div class="grid grid-cols-3 justify-center items-center text-center space-x-4">
<%= label(f, :password_confirmation, "Confirm new password", class: "title text-lg text-primary-500") %>
<%= password_input(f, :password_confirmation, required: true, class: "input input-primary col-span-2") %>
</div>
<%= error_tag(f, :password_confirmation) %>
<%= label(f, :password_confirmation, "Confirm new password", class: "title text-lg text-primary-500") %>
<%= password_input(f, :password_confirmation, required: true, class: "input input-primary col-span-2") %>
<%= error_tag(f, :password_confirmation, "col-span-3") %>
<%= submit(dgettext("actions", "Reset password"), class: "btn btn-primary") %>
<%= submit(dgettext("actions", "Reset password"), class: "mx-auto my-4 btn btn-primary col-span-3") %>
<% end %>
<hr class="hr">
<hr class="hr">
<div class="flex flex-row justify-center items-center space-x-4">
<%= if Accounts.allow_registration?() do %>
<%= link(dgettext("actions", "Register"),
to: Routes.user_registration_path(@conn, :new),
class: "btn btn-primary"
) %>
<% end %>
<%= link(dgettext("actions", "Log in"),
to: Routes.user_session_path(@conn, :new),
<div class="flex flex-row justify-center items-center space-x-4">
<%= if Accounts.allow_registration?() do %>
<%= link(dgettext("actions", "Register"),
to: Routes.user_registration_path(@conn, :new),
class: "btn btn-primary"
) %>
</div>
<% end %>
<% end %>
<%= link(dgettext("actions", "Log in"),
to: Routes.user_session_path(@conn, :new),
class: "btn btn-primary"
) %>
</div>
</div>

View File

@ -1,33 +1,34 @@
<div class="flex flex-col justify-center items-center space-y-4">
<div class="mb-8 flex flex-col justify-center items-center space-y-4">
<h1 class="title text-primary-500 text-xl">
<%= dgettext("actions", "Forgot your password?") %>
</h1>
<%= form_for :user,
Routes.user_reset_password_path(@conn, :create),
[class: "flex flex-col justify-center items-center space-y-4"],
[class: "flex flex-col sm:grid sm:grid-cols-3
justify-center items-center text-center space-y-4"],
fn f -> %>
<div class="grid grid-cols-3 justify-center items-center text-center space-x-4">
<%= label(f, :email, class: "title text-lg text-primary-500") %>
<%= email_input(f, :email, required: true, class: "input input-primary col-span-2") %>
</div>
<%= label(f, :email, class: "title text-lg text-primary-500") %>
<%= email_input(f, :email, required: true, class: "input input-primary col-span-2") %>
<%= submit(dgettext("actions", "Send instructions to reset password"), class: "btn btn-primary") %>
<%= submit(dgettext("actions", "Send instructions to reset password"),
class: "mx-auto my-4 btn btn-primary col-span-3"
) %>
<% end %>
<hr class="hr">
<hr class="hr">
<div class="flex flex-row justify-center items-center space-x-4">
<%= if Accounts.allow_registration?() do %>
<%= link(dgettext("actions", "Register"),
to: Routes.user_registration_path(@conn, :new),
class: "btn btn-primary"
) %>
<% end %>
<%= link(dgettext("actions", "Log in"),
to: Routes.user_session_path(@conn, :new),
<div class="flex flex-row justify-center items-center space-x-4">
<%= if Accounts.allow_registration?() do %>
<%= link(dgettext("actions", "Register"),
to: Routes.user_registration_path(@conn, :new),
class: "btn btn-primary"
) %>
</div>
<% end %>
<% end %>
<%= link(dgettext("actions", "Log in"),
to: Routes.user_session_path(@conn, :new),
class: "btn btn-primary"
) %>
</div>
</div>

View File

@ -1,52 +1,47 @@
<div class="flex flex-col justify-center items-center space-y-4">
<div class="mb-8 flex flex-col justify-center items-center space-y-4">
<h1 class="title text-primary-500 text-xl">
<%= dgettext("actions", "Log in") %>
</h1>
<%= form_for @conn,
Routes.user_session_path(@conn, :create),
[as: :user, class: "flex flex-col justify-center items-center space-y-4"],
[as: :user, class: "flex flex-col sm:grid sm:grid-cols-3
justify-center items-center text-center space-y-4"],
fn f -> %>
<%= if @error_message do %>
<div class="alert alert-danger">
<div class="alert alert-danger col-span-3">
<p>
<%= @error_message %>
</p>
</div>
<% end %>
<div class="grid grid-cols-3 justify-center items-center text-center space-x-4">
<%= label(f, :email, class: "title text-lg text-primary-500") %>
<%= email_input(f, :email, required: true, class: "input input-primary col-span-2") %>
</div>
<%= label(f, :email, class: "title text-lg text-primary-500") %>
<%= email_input(f, :email, required: true, class: "input input-primary col-span-2") %>
<div class="grid grid-cols-3 justify-center items-center text-center space-x-4">
<%= label(f, :password, class: "title text-lg text-primary-500") %>
<%= password_input(f, :password, required: true, class: "input input-primary col-span-2") %>
</div>
<%= label(f, :password, class: "title text-lg text-primary-500") %>
<%= password_input(f, :password, required: true, class: "input input-primary col-span-2") %>
<div class="flex flex-row justify-center items-center text-center space-x-4">
<%= label(f, :remember_me, gettext("Keep me logged in for 60 days"),
class: "title text-lg text-primary-500"
) %>
<%= checkbox(f, :remember_me, class: "checkbox") %>
</div>
<%= label(f, :remember_me, gettext("Keep me logged in for 60 days"),
class: "title text-lg text-primary-500"
) %>
<%= checkbox(f, :remember_me, class: "checkbox col-span-2") %>
<%= submit(dgettext("actions", "Log in"), class: "btn btn-primary") %>
<%= submit(dgettext("actions", "Log in"), class: "mx-auto my-4 btn btn-primary col-span-3") %>
<% end %>
<hr class="hr">
<hr class="hr">
<div class="flex flex-row justify-center items-center space-x-4">
<%= if Accounts.allow_registration?() do %>
<%= link(dgettext("actions", "Register"),
to: Routes.user_registration_path(@conn, :new),
class: "btn btn-primary"
) %>
<% end %>
<%= link(dgettext("actions", "Forgot your password?"),
to: Routes.user_reset_password_path(@conn, :new),
<div class="flex flex-row justify-center items-center space-x-4">
<%= if Accounts.allow_registration?() do %>
<%= link(dgettext("actions", "Register"),
to: Routes.user_registration_path(@conn, :new),
class: "btn btn-primary"
) %>
</div>
<% end %>
<% end %>
<%= link(dgettext("actions", "Forgot your password?"),
to: Routes.user_reset_password_path(@conn, :new),
class: "btn btn-primary"
) %>
</div>
</div>

View File

@ -1,18 +1,21 @@
<div class="mb-8 flex flex-col justify-center items-center space-y-8">
<h1 class="title text-primary-500 text-xl">
<div class="mb-8 flex flex-col justify-center items-center space-y-4">
<h1 class="pb-4 title text-primary-500 text-xl">
<%= gettext("Settings") %>
</h1>
<h3 class="title text-primary-500 text-lg">
<%= dgettext("actions", "Change email") %>
</h3>
<hr class="hr">
<%= form_for @email_changeset,
Routes.user_settings_path(@conn, :update),
[class: "flex flex-col justify-center items-center space-y-4"],
[class: "pb-4 flex flex-col sm:grid sm:grid-cols-3
justify-center items-center text-center space-y-4"],
fn f -> %>
<%= if @email_changeset.action do %>
<div class="alert alert-danger">
<h3 class="title text-primary-500 text-lg col-span-3">
<%= dgettext("actions", "Change email") %>
</h3>
<%= if @email_changeset.action && not @email_changeset.valid? do %>
<div class="alert alert-danger col-span-3">
<p>
<%= dgettext("errors", "Oops, something went wrong! Please check the errors below.") %>
</p>
@ -21,39 +24,40 @@
<%= hidden_input(f, :action, name: "action", value: "update_email") %>
<div class="grid grid-cols-3 justify-center items-center text-center space-x-4">
<%= label(f, :email, class: "title text-lg text-primary-500") %>
<%= email_input(f, :email, required: true, class: "input input-primary col-span-2") %>
</div>
<%= error_tag(f, :email) %>
<%= label(f, :email, class: "title text-lg text-primary-500") %>
<%= email_input(f, :email, required: true, class: "mx-2 my-1 input input-primary col-span-2") %>
<%= error_tag(f, :email, "col-span-3") %>
<div class="grid grid-cols-3 justify-center items-center text-center space-x-4">
<%= label(f, :current_password,
for: "current_password_for_email",
class: "title text-lg text-primary-500"
) %>
<%= password_input(f, :current_password,
required: true,
name: "current_password",
id: "current_password_for_email",
class: "input input-primary col-span-2"
) %>
</div>
<%= error_tag(f, :current_password) %>
<%= label(f, :current_password, gettext("Current password"),
for: "current_password_for_email",
class: "mx-2 my-1 title text-lg text-primary-500"
) %>
<%= password_input(f, :current_password,
required: true,
name: "current_password",
id: "current_password_for_email",
class: "mx-2 my-1 input input-primary col-span-2"
) %>
<%= error_tag(f, :current_password, "col-span-3") %>
<%= submit(dgettext("actions", "Change email"), class: "btn btn-primary") %>
<%= submit(dgettext("actions", "Change email"), class: "mx-auto my-4 btn btn-primary col-span-3") %>
<% end %>
<h3 class="title text-primary-500 text-lg">
<%= dgettext("actions", "Change password") %>
</h3>
<hr class="hr">
<%= form_for @password_changeset,
Routes.user_settings_path(@conn, :update),
[class: "flex flex-col justify-center items-center space-y-4"],
[
class:
"pb-4 flex flex-col sm:grid sm:grid-cols-3 justify-center items-center text-center space-y-4"
],
fn f -> %>
<%= if @password_changeset.action do %>
<div class="alert alert-danger">
<h3 class="title text-primary-500 text-lg col-span-3">
<%= dgettext("actions", "Change password") %>
</h3>
<%= if @password_changeset.action && not @password_changeset.valid? do %>
<div class="alert alert-danger col-span-3">
<p>
<%= dgettext("errors", "Oops, something went wrong! Please check the errors below.") %>
</p>
@ -62,41 +66,39 @@
<%= hidden_input(f, :action, name: "action", value: "update_password") %>
<div class="grid grid-cols-3 justify-center items-center text-center space-x-4">
<%= label(f, :password, "New password", class: "title text-lg text-primary-500") %>
<%= password_input(f, :password,
required: true,
class: "input input-primary col-span-2"
) %>
</div>
<%= error_tag(f, :password) %>
<%= label(f, :password, gettext("New password"), class: "title text-lg text-primary-500") %>
<%= password_input(f, :password,
required: true,
class: "mx-2 my-1 input input-primary col-span-2"
) %>
<%= error_tag(f, :password, "col-span-3") %>
<div class="grid grid-cols-3 justify-center items-center text-center space-x-4">
<%= label(f, :password_confirmation, "Confirm new password", class: "title text-lg text-primary-500") %>
<%= password_input(f, :password_confirmation,
required: true,
class: "input input-primary col-span-2"
) %>
</div>
<%= error_tag(f, :password_confirmation) %>
<%= label(f, :password_confirmation, gettext("Confirm new password"),
class: "title text-lg text-primary-500"
) %>
<%= password_input(f, :password_confirmation,
required: true,
class: "mx-2 my-1 input input-primary col-span-2"
) %>
<%= error_tag(f, :password_confirmation, "col-span-3") %>
<div class="grid grid-cols-3 justify-center items-center text-center space-x-4">
<%= label(f, :current_password,
for: "current_password_for_password",
class: "title text-lg text-primary-500"
) %>
<%= password_input(f, :current_password,
required: true,
name: "current_password",
id: "current_password_for_password",
class: "input input-primary col-span-2"
) %>
</div>
<%= error_tag(f, :current_password) %>
<%= label(f, :current_password, gettext("Current password"),
for: "current_password_for_password",
class: "title text-lg text-primary-500"
) %>
<%= password_input(f, :current_password,
required: true,
name: "current_password",
id: "current_password_for_password",
class: "mx-2 my-1 input input-primary col-span-2"
) %>
<%= error_tag(f, :current_password, "col-span-3") %>
<%= submit(dgettext("actions", "Change password"), class: "btn btn-primary") %>
<%= submit(dgettext("actions", "Change password"), class: "mx-auto my-4 btn btn-primary col-span-3") %>
<% end %>
<hr class="hr">
<%= link(dgettext("actions", "Delete User"),
to: Routes.user_settings_path(@conn, :delete, @current_user),
method: :delete,

View File

@ -13,6 +13,7 @@ defmodule CanneryWeb.ViewHelpers do
"""
@spec display_datetime(NaiveDateTime.t() | nil) :: Phoenix.LiveView.Rendered.t()
def display_datetime(nil), do: ""
def display_datetime(datetime) do
assigns = %{
datetime: datetime |> DateTime.from_naive!("Etc/UTC") |> DateTime.to_iso8601(:extended)
@ -39,8 +40,9 @@ defmodule CanneryWeb.ViewHelpers do
"""
@spec display_date(Date.t() | nil) :: Phoenix.LiveView.Rendered.t()
def display_date(nil), do: ""
def display_date(date) do
assigns = %{date: date |> Date.to_iso8601(:extended)}
assigns = %{date: date |> Date.to_iso8601(:extended)}
~H"""
<time
@ -60,6 +62,9 @@ defmodule CanneryWeb.ViewHelpers do
Displays emoji as text emoji if SHIBAO_MODE is set to true :)
"""
@spec display_emoji(String.t()) :: String.t()
def display_emoji("😔"), do: if Application.get_env(:cannery, CanneryWeb.ViewHelpers)[:shibao_mode], do: "q_q", else: "😔"
def display_emoji("😔"),
do:
if(Application.get_env(:cannery, CanneryWeb.ViewHelpers)[:shibao_mode], do: "q_q", else: "😔")
def display_emoji(other_emoji), do: other_emoji
end