Skip to content

Commit 90ebe14

Browse files
committed
Add help button to primary toolbar
The keyboard shortcuts modal was only accessible via the ? key with no visual indication it existed. Added a help dropdown to the toolbar that links to documentation and opens the shortcuts modal.
1 parent 06514f3 commit 90ebe14

File tree

6 files changed

+65
-6
lines changed

6 files changed

+65
-6
lines changed

lib/oban/web/components/layouts/live.html.heex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<.live_component module={Oban.Web.ConnectivityComponent} id="connectivity" conf={@conf} />
1919
<.live_component module={Oban.Web.ThemeComponent} id="theme" theme={@theme} />
2020
<.live_component module={Oban.Web.RefreshComponent} id="refresh" refresh={@refresh} />
21+
<.live_component module={Oban.Web.HelpComponent} id="help" />
2122
<.live_component
2223
module={Oban.Web.InstancesComponent}
2324
id="instances"
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
defmodule Oban.Web.HelpComponent do
2+
use Oban.Web, :live_component
3+
4+
@impl Phoenix.LiveComponent
5+
def render(assigns) do
6+
~H"""
7+
<div class="relative" id="help-selector">
8+
<button
9+
aria-expanded="true"
10+
aria-haspopup="listbox"
11+
class="cursor-pointer text-gray-500 dark:text-gray-400 focus:outline-none hover:text-gray-700 dark:hover:text-gray-200 hidden md:block"
12+
data-title="Help"
13+
id="help-menu-toggle"
14+
phx-hook="Tippy"
15+
phx-click={JS.toggle(to: "#help-menu")}
16+
type="button"
17+
>
18+
<Icons.question_mark_circle />
19+
</button>
20+
21+
<ul
22+
class="hidden absolute z-50 top-full right-0 mt-2 py-2 w-48 overflow-hidden rounded-md shadow-lg text-sm font-semibold bg-white dark:bg-gray-800 focus:outline-none"
23+
id="help-menu"
24+
role="listbox"
25+
tabindex="-1"
26+
>
27+
<li
28+
class="block w-full py-1 px-2 flex items-center cursor-pointer space-x-2 text-gray-500 dark:text-gray-400 hover:bg-gray-50 hover:dark:bg-gray-600/30"
29+
phx-click-away={JS.hide(to: "#help-menu")}
30+
role="option"
31+
>
32+
<a
33+
href="https://hexdocs.pm/oban_web"
34+
target="_blank"
35+
rel="noopener noreferrer"
36+
class="flex items-center space-x-2 w-full"
37+
>
38+
<Icons.arrow_top_right_on_square class="w-5 h-5" />
39+
<span class="text-gray-800 dark:text-gray-200">Documentation</span>
40+
</a>
41+
</li>
42+
<li
43+
class="block w-full py-1 px-2 flex items-center cursor-pointer space-x-2 text-gray-500 dark:text-gray-400 hover:bg-gray-50 hover:dark:bg-gray-600/30"
44+
phx-click-away={JS.hide(to: "#help-menu")}
45+
phx-click={JS.hide(to: "#help-menu") |> JS.exec("data-shortcut", to: "#shortcuts")}
46+
role="option"
47+
>
48+
<Icons.command_line class="w-5 h-5" />
49+
<span class="text-gray-800 dark:text-gray-200">Keyboard shortcuts</span>
50+
</li>
51+
</ul>
52+
</div>
53+
"""
54+
end
55+
end

lib/oban/web/live/instances_component.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ defmodule Oban.Web.InstancesComponent do
3838
<button
3939
aria-expanded="true"
4040
aria-haspopup="listbox"
41-
class="rounded-md px-3 py-2 text-sm text-gray-600 dark:text-gray-300
41+
class="cursor-pointer rounded-md px-3 py-2 text-sm text-gray-600 dark:text-gray-300
4242
hover:text-gray-800 dark:hover:text-gray-200
4343
hover:bg-black/5 dark:hover:bg-white/5
4444
ring-1 ring-inset ring-gray-400 dark:ring-gray-700
@@ -53,7 +53,7 @@ defmodule Oban.Web.InstancesComponent do
5353
</button>
5454
5555
<ul
56-
class="hidden absolute z-10 top-full right-0 mt-2 text-sm font-semibold overflow-auto rounded-md bg-white dark:bg-gray-800 shadow-lg ring-1 ring-black/5"
56+
class="hidden absolute z-10 top-full right-0 mt-2 py-2 text-sm font-semibold overflow-auto rounded-md bg-white dark:bg-gray-800 shadow-lg ring-1 ring-black/5"
5757
id="instance-select-menu"
5858
>
5959
<li

lib/oban/web/live/refresh_component.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ defmodule Oban.Web.RefreshComponent do
2929
aria-haspopup="listbox"
3030
aria-expanded="true"
3131
aria-labelledby="listbox-label"
32-
class="text-gray-500 dark:text-gray-400 focus:outline-none hover:text-gray-600 dark:hover:text-gray-200 hidden md:flex"
32+
class="cursor-pointer text-gray-500 dark:text-gray-400 focus:outline-none hover:text-gray-700 dark:hover:text-gray-200 hidden md:flex"
3333
data-title="Change refresh rate"
3434
id="refresh-menu-toggle"
3535
phx-hook="Tippy"
@@ -41,7 +41,7 @@ defmodule Oban.Web.RefreshComponent do
4141
</button>
4242
4343
<ul
44-
class="hidden absolute z-50 top-full right-0 mt-2 w-18 overflow-hidden rounded-md shadow-lg text-sm font-semibold bg-white dark:bg-gray-800 focus:outline-none"
44+
class="hidden absolute z-50 top-full right-0 mt-2 py-2 w-18 overflow-hidden rounded-md shadow-lg text-sm font-semibold bg-white dark:bg-gray-800 focus:outline-none"
4545
id="refresh-menu"
4646
role="listbox"
4747
tabindex="-1"

lib/oban/web/live/theme_component.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ defmodule Oban.Web.ThemeComponent do
1313
<button
1414
aria-expanded="true"
1515
aria-haspopup="listbox"
16-
class="text-gray-500 dark:text-gray-400 focus:outline-none hover:text-gray-600 dark:hover:text-gray-200 hidden md:block"
16+
class="cursor-pointer text-gray-500 dark:text-gray-400 focus:outline-none hover:text-gray-700 dark:hover:text-gray-200 hidden md:block"
1717
data-title="Change theme"
1818
id="theme-menu-toggle"
1919
phx-hook="Tippy"
@@ -24,7 +24,7 @@ defmodule Oban.Web.ThemeComponent do
2424
</button>
2525
2626
<ul
27-
class="hidden absolute z-50 top-full right-0 mt-2 w-32 overflow-hidden rounded-md shadow-lg text-sm font-semibold bg-white dark:bg-gray-800 focus:outline-none"
27+
class="hidden absolute z-50 top-full right-0 mt-2 py-2 w-32 overflow-hidden rounded-md shadow-lg text-sm font-semibold bg-white dark:bg-gray-800 focus:outline-none"
2828
id="theme-menu"
2929
role="listbox"
3030
tabindex="-1"
Lines changed: 3 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)