Responsive UI improvements (#41)

* Improved responsive UX for media profiles

* Improved responsiveness for other pages

* Added docs; fixed up stragglers
This commit is contained in:
Kieran 2024-02-29 17:51:54 -08:00 committed by GitHub
parent d2c2cda479
commit 7809a25f2d
14 changed files with 67 additions and 56 deletions

View file

@ -16,9 +16,11 @@ defmodule PinchflatWeb.CoreComponents do
""" """
use Phoenix.Component use Phoenix.Component
alias Phoenix.LiveView.JS
import PinchflatWeb.Gettext import PinchflatWeb.Gettext
alias Phoenix.LiveView.JS
alias PinchflatWeb.CustomComponents.TextComponents
@doc """ @doc """
Renders a modal. Renders a modal.
@ -591,11 +593,12 @@ defmodule PinchflatWeb.CoreComponents do
assigns = assign(assigns, iterable_attributes: attrs) assigns = assign(assigns, iterable_attributes: attrs)
~H""" ~H"""
<.list> <ul>
<:item :for={{k, v} <- @iterable_attributes} title={k}> <li :for={{k, v} <- @iterable_attributes} class="mb-2">
<%= v %> <strong><%= k %>:</strong>
</:item> <TextComponents.inline_code><%= v %></TextComponents.inline_code>
</.list> </li>
</ul>
""" """
end end

View file

@ -23,7 +23,7 @@ defmodule PinchflatWeb.CustomComponents.ButtonComponents do
<button <button
class={[ class={[
"text-center font-medium text-white", "text-center font-medium text-white",
"#{@rounding} inline-flex items-center justify-center px-10 py-4", "#{@rounding} inline-flex items-center justify-center px-8 py-4",
"#{@color}", "#{@color}",
"hover:bg-opacity-90 lg:px-8 xl:px-10", "hover:bg-opacity-90 lg:px-8 xl:px-10",
@class @class

View file

@ -2,6 +2,8 @@ defmodule PinchflatWeb.CustomComponents.TextComponents do
@moduledoc false @moduledoc false
use Phoenix.Component use Phoenix.Component
alias PinchflatWeb.CoreComponents
@doc """ @doc """
Renders a code block with the given content. Renders a code block with the given content.
""" """
@ -28,4 +30,19 @@ defmodule PinchflatWeb.CustomComponents.TextComponents do
</.link> </.link>
""" """
end end
@doc """
Renders an icon as a link with the given href.
"""
attr :href, :string, required: true
attr :icon, :string, required: true
attr :class, :string, default: ""
def icon_link(assigns) do
~H"""
<.link href={@href} class={["hover:text-secondary duration-200 ease-in-out", @class]}>
<CoreComponents.icon name={@icon} />
</.link>
"""
end
end end

View file

@ -3,7 +3,7 @@
<div class="flex items-center gap-2 sm:gap-4 lg:hidden"> <div class="flex items-center gap-2 sm:gap-4 lg:hidden">
<button <button
class="z-99999 block rounded-sm border border-stroke bg-white p-1.5 shadow-sm dark:border-strokedark dark:bg-boxdark lg:hidden" class="z-99999 block rounded-sm border border-stroke bg-white p-1.5 shadow-sm dark:border-strokedark dark:bg-boxdark lg:hidden"
@click.stop="sidebarToggle = !sidebarToggle" @click.stop="sidebarVisible = !sidebarVisible"
> >
<.icon name="hero-bars-3" /> <.icon name="hero-bars-3" />
</button> </button>

View file

@ -1,15 +1,18 @@
<aside <aside
x-bind:class="sidebarToggle ? 'translate-x-0' : '-translate-x-full'" x-bind:class="sidebarVisible ? 'translate-x-0' : '-translate-x-full'"
class="absolute left-0 top-0 z-9999 flex h-screen w-72.5 flex-col overflow-y-hidden bg-black duration-300 ease-linear dark:bg-boxdark lg:static lg:translate-x-0" class={[
@click.outside="sidebarToggle = false" "-translate-x-full absolute left-0 top-0 z-9999 flex h-screen w-60 flex-col overflow-y-hidden",
"bg-black duration-300 ease-linear shadow-lg sm:shadow-none dark:bg-boxdark lg:static lg:translate-x-0"
]}
@click.outside="sidebarVisible = false"
> >
<div class="flex items-center justify-between gap-2 px-6 py-5.5 lg:py-6.5"> <div class="flex items-center justify-between gap-2 px-6 py-5.5 lg:py-6.5">
<a href="/" class="flex items-center"> <a href="/" class="flex items-center">
<img src={~p"/images/logo.png"} alt="Pinchflat" class="w-9 h-9" /> <img src={~p"/images/logo.png?cachebust=2024-02-29"} alt="Pinchflat" class="w-9 h-9" />
<h2 class="text-xl font-bold text-white pl-2">Pinchflat</h2> <h2 class="text-xl font-bold text-white pl-2">Pinchflat</h2>
</a> </a>
<button class="block lg:hidden" @click.stop="sidebarToggle = !sidebarToggle"> <button class="block lg:hidden" @click.stop="sidebarVisible = !sidebarVisible">
<.icon name="hero-arrow-left" class="fill-current" /> <.icon name="hero-arrow-left" class="fill-current" />
</button> </button>
</div> </div>
@ -19,9 +22,7 @@
<h3 class="mb-4 ml-4 text-sm font-medium text-bodydark2">MENU</h3> <h3 class="mb-4 ml-4 text-sm font-medium text-bodydark2">MENU</h3>
<ul class="mb-6 flex flex-col gap-1.5"> <ul class="mb-6 flex flex-col gap-1.5">
<.sidebar_item icon="hero-home" text="Home" navigate={~p"/"} /> <.sidebar_item icon="hero-home" text="Home" navigate={~p"/"} />
<.sidebar_item icon="hero-tv" text="Sources" navigate={~p"/sources"} /> <.sidebar_item icon="hero-tv" text="Sources" navigate={~p"/sources"} />
<.sidebar_item icon="hero-adjustments-vertical" text="Media Profiles" navigate={~p"/media_profiles"} /> <.sidebar_item icon="hero-adjustments-vertical" text="Media Profiles" navigate={~p"/media_profiles"} />
</ul> </ul>
</div> </div>

View file

@ -12,7 +12,7 @@
<script defer phx-track-static type="text/javascript" src={~p"/assets/app.js"}> <script defer phx-track-static type="text/javascript" src={~p"/assets/app.js"}>
</script> </script>
</head> </head>
<body x-data="{ 'sidebarToggle': false }" class="dark text-bodydark bg-boxdark-2"> <body x-data="{ 'sidebarVisible': false }" class="dark text-bodydark bg-boxdark-2">
<%= @inner_content %> <%= @inner_content %>
</body> </body>
</html> </html>

View file

@ -1,9 +1,11 @@
<div class="mb-6 flex gap-3 flex-row items-center justify-between"> <div class="mb-6 flex gap-3 flex-row items-center justify-between">
<h2 class="text-title-md2 font-bold text-black dark:text-white">All Media Profiles</h2> <h2 class="text-title-md2 font-bold text-black dark:text-white">
Media Profiles
</h2>
<nav> <nav>
<.link navigate={~p"/media_profiles/new"}> <.link navigate={~p"/media_profiles/new"}>
<.button color="bg-primary" rounding="rounded-full"> <.button color="bg-primary" rounding="rounded-full">
<span class="font-bold mx-2">+</span> New Media Profile <span class="font-bold text-xl mx-2">+</span> New <span class="hidden sm:inline pl-1">Media Profile</span>
</.button> </.button>
</.link> </.link>
</nav> </nav>
@ -11,7 +13,7 @@
<div class="rounded-sm border border-stroke bg-white shadow-default dark:border-strokedark dark:bg-boxdark"> <div class="rounded-sm border border-stroke bg-white shadow-default dark:border-strokedark dark:bg-boxdark">
<div class="max-w-full overflow-x-auto"> <div class="max-w-full overflow-x-auto">
<div class="flex flex-col gap-10"> <div class="flex flex-col gap-10 min-w-max">
<.table rows={@media_profiles} table_class="text-black dark:text-white"> <.table rows={@media_profiles} table_class="text-black dark:text-white">
<:col :let={media_profile} label="Name"> <:col :let={media_profile} label="Name">
<%= media_profile.name %> <%= media_profile.name %>
@ -23,18 +25,8 @@
<%= media_profile.preferred_resolution %> <%= media_profile.preferred_resolution %>
</:col> </:col>
<:col :let={media_profile} label="" class="flex place-content-evenly"> <:col :let={media_profile} label="" class="flex place-content-evenly">
<.link <.icon_link href={~p"/media_profiles/#{media_profile.id}"} icon="hero-eye" class="mx-1" />
navigate={~p"/media_profiles/#{media_profile.id}"} <.icon_link href={~p"/media_profiles/#{media_profile.id}/edit"} icon="hero-pencil-square" class="mx-1" />
class="hover:text-secondary duration-200 ease-in-out mx-0.5"
>
<.icon name="hero-eye" />
</.link>
<.link
navigate={~p"/media_profiles/#{media_profile.id}/edit"}
class="hover:text-secondary duration-200 ease-in-out mx-0.5"
>
<.icon name="hero-pencil-square" />
</.link>
</:col> </:col>
</.table> </.table>
</div> </div>

View file

@ -97,7 +97,7 @@
help="Will grab the closest available resolution if your preferred is not available" help="Will grab the closest available resolution if your preferred is not available"
/> />
<.button class="mt-15 mb-5 sm:mb-7.5">Save Media profile</.button> <.button class="my-10 sm:mb-7.5 w-full sm:w-auto">Save Media profile</.button>
<div class="rounded-sm dark:bg-meta-4 p-4 md:p-6 mb-5"> <div class="rounded-sm dark:bg-meta-4 p-4 md:p-6 mb-5">
<.output_template_help /> <.output_template_help />

View file

@ -1,17 +1,17 @@
<div class="mb-6 flex gap-3 flex-row items-center justify-between"> <div class="mb-6 flex gap-3 flex-row items-center justify-between">
<div class="flex gap-3 items-center"> <div class="flex items-center">
<.link navigate={~p"/media_profiles"}> <.link navigate={~p"/media_profiles"}>
<.icon name="hero-arrow-left" class="w-10 h-10 hover:dark:text-white" /> <.icon name="hero-arrow-left" class="w-10 h-10 hover:dark:text-white" />
</.link> </.link>
<h2 class="text-title-md2 font-bold text-black dark:text-white ml-4"> <h2 class="text-title-md2 font-bold text-black dark:text-white ml-2">
Media Profile #<%= @media_profile.id %> Media Profile <span class="hidden sm:inline">#<%= @media_profile.id %></span>
</h2> </h2>
</div> </div>
<nav> <nav>
<.link navigate={~p"/media_profiles/#{@media_profile}/edit"}> <.link navigate={~p"/media_profiles/#{@media_profile}/edit"}>
<.button color="bg-primary" rounding="rounded-full"> <.button color="bg-primary" rounding="rounded-full">
<.icon name="hero-pencil-square" class="mr-2" /> Edit Media Profile <.icon name="hero-pencil-square" class="mr-2" />Edit <span class="hidden sm:inline pl-1">Media Profile</span>
</.button> </.button>
</.link> </.link>
</nav> </nav>
@ -19,7 +19,7 @@
<div class="rounded-sm border border-stroke bg-white px-5 pb-2.5 pt-6 shadow-default dark:border-strokedark dark:bg-boxdark sm:px-7.5 xl:pb-1"> <div class="rounded-sm border border-stroke bg-white px-5 pb-2.5 pt-6 shadow-default dark:border-strokedark dark:bg-boxdark sm:px-7.5 xl:pb-1">
<div class="max-w-full overflow-x-auto"> <div class="max-w-full overflow-x-auto">
<div class="flex flex-col gap-10 dark:text-white"> <div class="flex flex-col gap-10 dark:text-white">
<h3 class="font-bold text-xl">Attributes</h3> <h3 class="font-bold text-xl">Attributes for "<%= @media_profile.name %>"</h3>
<.list_items_from_map map={Map.from_struct(@media_profile)} /> <.list_items_from_map map={Map.from_struct(@media_profile)} />
</div> </div>
@ -40,7 +40,7 @@
class="mt-5 md:mt-0" class="mt-5 md:mt-0"
> >
<.button color="bg-meta-1" rounding="rounded-full"> <.button color="bg-meta-1" rounding="rounded-full">
Delete Profile, Sources and Files Delete Profile, Sources, and Files
</.button> </.button>
</.link> </.link>
</section> </section>

View file

@ -1,9 +1,9 @@
<div class="mb-6 flex gap-3 flex-row items-center justify-between"> <div class="mb-6 flex gap-3 flex-row items-center justify-between">
<h2 class="text-title-md2 font-bold text-black dark:text-white">All Sources</h2> <h2 class="text-title-md2 font-bold text-black dark:text-white">Sources</h2>
<nav> <nav>
<.link navigate={~p"/sources/new"}> <.link navigate={~p"/sources/new"}>
<.button color="bg-primary" rounding="rounded-full"> <.button color="bg-primary" rounding="rounded-full">
<span class="font-bold mx-2">+</span> New Source <span class="font-bold mx-2">+</span> New <span class="hidden sm:inline pl-1">Source</span>
</.button> </.button>
</.link> </.link>
</nav> </nav>
@ -11,7 +11,7 @@
<div class="rounded-sm border border-stroke bg-white shadow-default dark:border-strokedark dark:bg-boxdark"> <div class="rounded-sm border border-stroke bg-white shadow-default dark:border-strokedark dark:bg-boxdark">
<div class="max-w-full overflow-x-auto"> <div class="max-w-full overflow-x-auto">
<div class="flex flex-col gap-10"> <div class="flex flex-col gap-10 min-w-max">
<.table rows={@sources} table_class="text-black dark:text-white"> <.table rows={@sources} table_class="text-black dark:text-white">
<:col :let={source} label="Name"> <:col :let={source} label="Name">
<%= source.friendly_name || source.collection_name %> <%= source.friendly_name || source.collection_name %>
@ -29,12 +29,8 @@
</.link> </.link>
</:col> </:col>
<:col :let={source} label="" class="flex place-content-evenly"> <:col :let={source} label="" class="flex place-content-evenly">
<.link navigate={~p"/sources/#{source.id}"} class="hover:text-secondary duration-200 ease-in-out mx-0.5"> <.icon_link href={~p"/sources/#{source.id}"} icon="hero-eye" class="mx-1" />
<.icon name="hero-eye" /> <.icon_link href={~p"/sources/#{source.id}/edit"} icon="hero-pencil-square" class="mx-1" />
</.link>
<.link navigate={~p"/sources/#{source.id}/edit"} class="hover:text-secondary duration-200 ease-in-out mx-0.5">
<.icon name="hero-pencil-square" />
</.link>
</:col> </:col>
</.table> </.table>
</div> </div>

View file

@ -4,14 +4,14 @@
<.icon name="hero-arrow-left" class="w-10 h-10 hover:dark:text-white" /> <.icon name="hero-arrow-left" class="w-10 h-10 hover:dark:text-white" />
</.link> </.link>
<h2 class="text-title-md2 font-bold text-black dark:text-white ml-4"> <h2 class="text-title-md2 font-bold text-black dark:text-white ml-4">
Source #<%= @source.id %> Source <span class="hidden sm:inline">#<%= @source.id %></span>
</h2> </h2>
</div> </div>
<nav> <nav>
<.link navigate={~p"/sources/#{@source}/edit"}> <.link navigate={~p"/sources/#{@source}/edit"}>
<.button color="bg-primary" rounding="rounded-full"> <.button color="bg-primary" rounding="rounded-full">
<.icon name="hero-pencil-square" class="mr-2" /> Edit Source <.icon name="hero-pencil-square" class="mr-2" /> Edit <span class="hidden sm:inline pl-1">Source</span>
</.button> </.button>
</.link> </.link>
</nav> </nav>
@ -19,7 +19,9 @@
<div class="rounded-sm border border-stroke bg-white px-5 py-5 shadow-default dark:border-strokedark dark:bg-boxdark sm:px-7.5"> <div class="rounded-sm border border-stroke bg-white px-5 py-5 shadow-default dark:border-strokedark dark:bg-boxdark sm:px-7.5">
<div class="max-w-full overflow-x-auto"> <div class="max-w-full overflow-x-auto">
<div class="flex flex-col gap-10 dark:text-white"> <div class="flex flex-col gap-10 dark:text-white">
<h3 class="mt-14 font-bold text-xl">Relationships</h3> <h3 class="font-bold text-xl">Attributes for "<%= @source.friendly_name %>"</h3>
<h3 class="font-bold text-lg">Relationships</h3>
<.list> <.list>
<:item title="media_profile"> <:item title="media_profile">
<.link <.link
@ -31,7 +33,7 @@
</:item> </:item>
</.list> </.list>
<h3 class="font-bold text-xl">Attributes</h3> <h3 class="font-bold text-lg">Attributes</h3>
<.list_items_from_map map={Map.from_struct(@source)} /> <.list_items_from_map map={Map.from_struct(@source)} />
<h3 class="font-bold text-xl">Downloaded Media</h3> <h3 class="font-bold text-xl">Downloaded Media</h3>

View file

@ -35,6 +35,6 @@
/> />
<:actions> <:actions>
<.button class="mt-15 mb-5 sm:mb-7.5">Save Source</.button> <.button class="my-10 sm:mb-7.5 w-full sm:w-auto">Save Source</.button>
</:actions> </:actions>
</.simple_form> </.simple_form>

View file

@ -17,7 +17,7 @@ defmodule PinchflatWeb.MediaProfileControllerTest do
describe "index" do describe "index" do
test "lists all media_profiles", %{conn: conn} do test "lists all media_profiles", %{conn: conn} do
conn = get(conn, ~p"/media_profiles") conn = get(conn, ~p"/media_profiles")
assert html_response(conn, 200) =~ "All Media Profiles" assert html_response(conn, 200) =~ "Media Profiles"
end end
end end
@ -45,7 +45,7 @@ defmodule PinchflatWeb.MediaProfileControllerTest do
assert redirected_to(conn) == ~p"/media_profiles/#{id}" assert redirected_to(conn) == ~p"/media_profiles/#{id}"
conn = get(conn, ~p"/media_profiles/#{id}") conn = get(conn, ~p"/media_profiles/#{id}")
assert html_response(conn, 200) =~ "Media Profile ##{id}" assert html_response(conn, 200) =~ "Media Profile"
end end
test "renders errors when data is invalid", %{conn: conn} do test "renders errors when data is invalid", %{conn: conn} do

View file

@ -32,7 +32,7 @@ defmodule PinchflatWeb.SourceControllerTest do
describe "index" do describe "index" do
test "lists all sources", %{conn: conn} do test "lists all sources", %{conn: conn} do
conn = get(conn, ~p"/sources") conn = get(conn, ~p"/sources")
assert html_response(conn, 200) =~ "All Sources" assert html_response(conn, 200) =~ "Sources"
end end
end end
@ -61,7 +61,7 @@ defmodule PinchflatWeb.SourceControllerTest do
assert redirected_to(conn) == ~p"/sources/#{id}" assert redirected_to(conn) == ~p"/sources/#{id}"
conn = get(conn, ~p"/sources/#{id}") conn = get(conn, ~p"/sources/#{id}")
assert html_response(conn, 200) =~ "Source ##{id}" assert html_response(conn, 200) =~ "Source"
end end
test "renders errors when data is invalid", %{conn: conn, invalid_attrs: invalid_attrs} do test "renders errors when data is invalid", %{conn: conn, invalid_attrs: invalid_attrs} do