diff --git a/assets/js/app.js b/assets/js/app.js index c673ab7..fbddeae 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -57,7 +57,7 @@ Hooks.Menu = { window.requestAnimationFrame(() => this.activate(0)) } }) - this.menuItemsContainer.addEventListener("phx:hide", () => this.reset()) + this.menuItemsContainer.addEventListener("phx:hide-start", () => this.reset()) }, activate(index, fallbackIndex){ let menuItems = this.menuItems() diff --git a/lib/live_beats_web/live/live_helpers.ex b/lib/live_beats_web/live/live_helpers.ex index 43640ed..7a39efc 100644 --- a/lib/live_beats_web/live/live_helpers.ex +++ b/lib/live_beats_web/live/live_helpers.ex @@ -158,6 +158,88 @@ defmodule LiveBeatsWeb.LiveHelpers do """ end + @doc """ + Returns a button triggered dropdown with aria keyboard and focus supporrt. + + Accepts the follow slots: + + * `:id` - The id to uniquely identify this dropdown + * `:img` - The optional img to show beside the button title + * `:title` - The button title + * `:subtitle` - The button subtitle + + ## Examples + + <.dropdown id={@id}> + <:img src={@current_user.avatar_url}/> + <:title><%= @current_user.name %> + <:subtitle>@<%= @current_user.username %> + + <:link redirect_to={profile_path(@current_user)}>View Profile + <:link redirect_to={Routes.settings_path(LiveBeatsWeb.Endpoint, :edit)}Settings + + """ + def dropdown(assigns) do + assigns = + assigns + |> assign_new(:img, fn -> nil end) + |> assign_new(:title, fn -> nil end) + |> assign_new(:subtitle, fn -> nil end) + + ~H""" + +
+
+ +
+ +
+ """ + end + def show_mobile_sidebar(js \\ %JS{}) do js |> JS.show(to: "#mobile-sidebar-container", transition: "fade-in") diff --git a/lib/live_beats_web/views/layout_view.ex b/lib/live_beats_web/views/layout_view.ex index ba3a056..b40b37c 100644 --- a/lib/live_beats_web/views/layout_view.ex +++ b/lib/live_beats_web/views/layout_view.ex @@ -5,6 +5,8 @@ defmodule LiveBeatsWeb.LayoutView do # so we instruct Elixir to not warn if the dashboard route is missing. @compile {:no_warn_undefined, {Routes, :live_dashboard_path, 2}} + alias LiveBeatsWeb.Endpoint + def sidebar_active_users(assigns) do ~H"""
@@ -40,14 +42,14 @@ defmodule LiveBeatsWeb.LayoutView do <.link - redirect_to={Routes.settings_path(LiveBeatsWeb.Endpoint, :edit)} + redirect_to={Routes.settings_path(Endpoint, :edit)} class={"text-gray-700 hover:text-gray-900 hover:bg-gray-50 group flex items-center px-2 py-2 text-sm font-medium rounded-md #{if @active_tab == :settings, do: "bg-gray-200 hover:bg-gray-200"}"} > <.icon name={:adjustments} outlined class="text-gray-400 group-hover:text-gray-500 mr-3 flex-shrink-0 h-6 w-6"/> Settings <% else %> - <.link redirect_to={Routes.sign_in_path(LiveBeatsWeb.Endpoint, :index)} + <.link redirect_to={Routes.sign_in_path(Endpoint, :index)} class="text-gray-700 hover:text-gray-900 hover:bg-gray-50 group flex items-center px-2 py-2 text-sm font-medium rounded-md" > -
-
- -
- -
+ <:link redirect_to={profile_path(@current_user)}>View Profile + <:link redirect_to={Routes.settings_path(Endpoint, :edit)}>Settings + <:link href={Routes.o_auth_callback_path(Endpoint, :sign_out)} method={:delete}>Sign out + """ end end