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
@@ -16,9 +16,11 @@ defmodule PinchflatWeb.CoreComponents do
"""
use Phoenix.Component
alias Phoenix.LiveView.JS
import PinchflatWeb.Gettext
alias Phoenix.LiveView.JS
alias PinchflatWeb.CustomComponents.TextComponents
@doc """
Renders a modal.
@@ -591,11 +593,12 @@ defmodule PinchflatWeb.CoreComponents do
assigns = assign(assigns, iterable_attributes: attrs)
~H"""
<.list>
<:item :for={{k, v} <- @iterable_attributes} title={k}>
<%= v %>
</:item>
</.list>
<ul>
<li :for={{k, v} <- @iterable_attributes} class="mb-2">
<strong><%= k %>:</strong>
<TextComponents.inline_code><%= v %></TextComponents.inline_code>
</li>
</ul>
"""
end
@@ -23,7 +23,7 @@ defmodule PinchflatWeb.CustomComponents.ButtonComponents do
<button
class={[
"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}",
"hover:bg-opacity-90 lg:px-8 xl:px-10",
@class
@@ -2,6 +2,8 @@ defmodule PinchflatWeb.CustomComponents.TextComponents do
@moduledoc false
use Phoenix.Component
alias PinchflatWeb.CoreComponents
@doc """
Renders a code block with the given content.
"""
@@ -28,4 +30,19 @@ defmodule PinchflatWeb.CustomComponents.TextComponents do
</.link>
"""
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
@@ -3,7 +3,7 @@
<div class="flex items-center gap-2 sm:gap-4 lg:hidden">
<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"
@click.stop="sidebarToggle = !sidebarToggle"
@click.stop="sidebarVisible = !sidebarVisible"
>
<.icon name="hero-bars-3" />
</button>
@@ -1,15 +1,18 @@
<aside
x-bind:class="sidebarToggle ? '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"
@click.outside="sidebarToggle = false"
x-bind:class="sidebarVisible ? 'translate-x-0' : '-translate-x-full'"
class={[
"-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">
<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>
</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" />
</button>
</div>
@@ -19,9 +22,7 @@
<h3 class="mb-4 ml-4 text-sm font-medium text-bodydark2">MENU</h3>
<ul class="mb-6 flex flex-col gap-1.5">
<.sidebar_item icon="hero-home" text="Home" navigate={~p"/"} />
<.sidebar_item icon="hero-tv" text="Sources" navigate={~p"/sources"} />
<.sidebar_item icon="hero-adjustments-vertical" text="Media Profiles" navigate={~p"/media_profiles"} />
</ul>
</div>
@@ -12,7 +12,7 @@
<script defer phx-track-static type="text/javascript" src={~p"/assets/app.js"}>
</script>
</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 %>
</body>
</html>