Skip to content

Commit 0b9e067

Browse files
authored
Refactor: UI layout styling and accessibility (#287)
* use grid for layout * use proper html tags * sidebar properly shrinking * add accessibility for buttons
1 parent 06497e9 commit 0b9e067

5 files changed

Lines changed: 26 additions & 14 deletions

File tree

lib/live_debugger/components.ex

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -317,9 +317,15 @@ defmodule LiveDebugger.Components do
317317
assigns
318318
|> assign(:button_class, button_class)
319319
|> assign(:icon_class, icon_class)
320+
|> assign(:aria_label, assigns[:"aria-label"] || icon_label(assigns.icon))
320321

321322
~H"""
322-
<.button class={[@button_class | List.wrap(@class)]} variant={@variant} {@rest}>
323+
<.button
324+
aria-label={@aria_label}
325+
class={[@button_class | List.wrap(@class)]}
326+
variant={@variant}
327+
{@rest}
328+
>
323329
<.icon name={@icon} class={@icon_class} />
324330
</.button>
325331
"""
@@ -333,6 +339,7 @@ defmodule LiveDebugger.Components do
333339
def nav_icon(assigns) do
334340
~H"""
335341
<button
342+
aria-label={icon_label(@icon)}
336343
class={[
337344
"w-8! h-8! px-[0.25rem] py-[0.25rem] w-max h-max rounded text-xs font-semibold text-navbar-icon hover:text-navbar-icon-hover hover:bg-navbar-icon-bg-hover"
338345
| List.wrap(@class)
@@ -546,7 +553,7 @@ defmodule LiveDebugger.Components do
546553

547554
def navbar(assigns) do
548555
~H"""
549-
<div class="w-full h-12 shrink-0 py-auto px-4 flex items-center gap-2 bg-navbar-bg text-navbar-logo border-b border-navbar-border">
556+
<navbar class="w-full h-12 shrink-0 py-auto px-4 flex items-center gap-2 bg-navbar-bg text-navbar-logo border-b border-navbar-border">
550557
<.link :if={@return_link?} patch={Routes.live_views_dashboard()}>
551558
<.nav_icon icon="icon-arrow-left" />
552559
</.link>
@@ -573,7 +580,7 @@ defmodule LiveDebugger.Components do
573580
<%= @inner_block && render_slot(@inner_block) %>
574581
</div>
575582
</div>
576-
</div>
583+
</navbar>
577584
"""
578585
end
579586

@@ -651,4 +658,10 @@ defmodule LiveDebugger.Components do
651658

652659
defp button_size_classes("md"), do: "py-2 px-3"
653660
defp button_size_classes("sm"), do: "py-1.5 px-2"
661+
662+
defp icon_label("icon-" <> icon_name) do
663+
icon_name
664+
|> String.capitalize()
665+
|> String.replace("-", " ")
666+
end
654667
end

lib/live_debugger/components/tree.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ defmodule LiveDebugger.Components.Tree do
3131

3232
def tree(assigns) do
3333
~H"""
34-
<div class={["w-full overflow-y-auto flex flex-col", @class]}>
34+
<div class={["min-h-20 w-full overflow-y-auto flex flex-col", @class]}>
3535
<div class="flex items-center justify-between">
3636
<div class="shrink-0 font-medium text-secondary-text px-6 py-3"><%= @title %></div>
3737
<%= if LiveDebugger.Feature.enabled?(:highlighting) do %>

lib/live_debugger/live_views/channel_dashboard_live.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ defmodule LiveDebugger.LiveViews.ChannelDashboardLive do
3939
@impl true
4040
def render(assigns) do
4141
~H"""
42-
<div class="w-screen h-screen flex flex-col">
42+
<div class="w-screen h-screen grid grid-rows-[auto_1fr]">
4343
<.navbar return_link?={true}>
4444
<div class="grow flex items-center justify-end">
4545
<.nav_icon
@@ -52,7 +52,7 @@ defmodule LiveDebugger.LiveViews.ChannelDashboardLive do
5252
</.navbar>
5353
<.async_result :let={lv_process} assign={@lv_process}>
5454
<:loading>
55-
<div class="h-full flex items-center justify-center">
55+
<div class="m-auto flex items-center justify-center">
5656
<.spinner size="xl" />
5757
</div>
5858
</:loading>
@@ -62,7 +62,7 @@ defmodule LiveDebugger.LiveViews.ChannelDashboardLive do
6262
<Error.unexpected_error_component :if={reason not in [:not_found, :session_limit]} />
6363
</:failed>
6464
65-
<div class="flex flex-1 overflow-hidden">
65+
<div class="flex overflow-hidden">
6666
<SidebarLive.live_render
6767
id="sidebar"
6868
socket={@socket}

lib/live_debugger/live_views/live_views_dashboard_live.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ defmodule LiveDebugger.LiveViews.LiveViewsDashboardLive do
2020
@impl true
2121
def render(assigns) do
2222
~H"""
23-
<div class="w-full h-full min-w-[25rem] flex flex-col items-center">
23+
<div class="flex-1 min-w-[25rem] grid grid-rows-[auto_1fr]">
2424
<.navbar return_link?={false} />
25-
<div class="max-xl:p-8 pt-8 w-full xl:max-w-[40rem] h-full">
26-
<div class="flex gap-4 items-center justify-between">
25+
<div class="flex-1 max-lg:p-8 pt-8 lg:w-[60rem] lg:m-auto">
26+
<div class="flex items-center justify-between">
2727
<.h1>Active LiveViews</.h1>
2828
<.button phx-click="refresh">
2929
<div class="flex items-center gap-2">

lib/live_debugger/live_views/sidebar_live.ex

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ defmodule LiveDebugger.LiveViews.SidebarLive do
3939
<%= live_render(@socket, __MODULE__,
4040
id: @id,
4141
session: @session,
42-
container: {:div, class: "h-full"}
42+
container: {:aside, class: "h-full"}
4343
) %>
4444
"""
4545
end
@@ -93,7 +93,6 @@ defmodule LiveDebugger.LiveViews.SidebarLive do
9393
highlight?={@highlight?}
9494
parent_lv_process={@parent_lv_process}
9595
/>
96-
<.report_issue class="border-t border-default-border" />
9796
</div>
9897
<.sidebar_slide_over :if={not @hidden?}>
9998
<.sidebar_content
@@ -105,7 +104,6 @@ defmodule LiveDebugger.LiveViews.SidebarLive do
105104
highlight?={@highlight?}
106105
parent_lv_process={@parent_lv_process}
107106
/>
108-
<.report_issue class="border-t border-default-border" />
109107
</.sidebar_slide_over>
110108
</div>
111109
"""
@@ -210,7 +208,7 @@ defmodule LiveDebugger.LiveViews.SidebarLive do
210208

211209
defp sidebar_content(assigns) do
212210
~H"""
213-
<div class="flex flex-col max-h-full h-max">
211+
<div class="grid grid-rows-[auto_auto_1fr_auto] h-full">
214212
<.basic_info
215213
pid={@lv_process.pid}
216214
socket_id={@lv_process.socket_id}
@@ -228,6 +226,7 @@ defmodule LiveDebugger.LiveViews.SidebarLive do
228226
max_opened_node_level={@max_opened_node_level}
229227
highlight?={@highlight?}
230228
/>
229+
<.report_issue class="border-t border-default-border" />
231230
</div>
232231
"""
233232
end

0 commit comments

Comments
 (0)