mirror of
https://github.com/fly-apps/live_beats.git
synced 2024-11-25 01:10:59 +00:00
Merge pull request #8 from chrismccord/feature/set_active_tab_in_navbar
Active tab highlighted in sidebar based on current URL
This commit is contained in:
commit
6849e108d7
3 changed files with 12 additions and 6 deletions
|
@ -3,7 +3,13 @@ defmodule LiveBeatsWeb.Nav do
|
||||||
|
|
||||||
alias LiveBeats.MediaLibrary
|
alias LiveBeats.MediaLibrary
|
||||||
|
|
||||||
def on_mount(:default, _params, _session, socket) do
|
def on_mount(:default, params, _session, socket) do
|
||||||
{:cont, assign(socket, :active_users, MediaLibrary.list_active_profiles(limit: 20))}
|
active_tab =
|
||||||
|
case params do
|
||||||
|
%{"profile_username" => _profile} -> :index
|
||||||
|
_ -> :settings
|
||||||
|
end
|
||||||
|
|
||||||
|
{:cont, assign(socket, [active_users: MediaLibrary.list_active_profiles(limit: 20), active_tab: active_tab])}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
|
|
||||||
<nav class="px-2">
|
<nav class="px-2">
|
||||||
<%= if @current_user do %>
|
<%= if @current_user do %>
|
||||||
<.sidebar_nav_links current_user={@current_user}/>
|
<.sidebar_nav_links current_user={@current_user} active_tab={@active_tab}/>
|
||||||
<% end %>
|
<% end %>
|
||||||
<.sidebar_active_users id="desktop-active-users" users={@active_users}/>
|
<.sidebar_active_users id="desktop-active-users" users={@active_users}/>
|
||||||
</nav>
|
</nav>
|
||||||
|
@ -73,7 +73,7 @@
|
||||||
<!-- Navigation -->
|
<!-- Navigation -->
|
||||||
<nav class="px-3 mt-6">
|
<nav class="px-3 mt-6">
|
||||||
<%= if @current_user do %>
|
<%= if @current_user do %>
|
||||||
<.sidebar_nav_links current_user={@current_user}/>
|
<.sidebar_nav_links current_user={@current_user} active_tab={@active_tab}/>
|
||||||
<% end %>
|
<% end %>
|
||||||
<!-- Secondary navigation -->
|
<!-- Secondary navigation -->
|
||||||
<.sidebar_active_users id="mobile-active-users" users={@active_users}/>
|
<.sidebar_active_users id="mobile-active-users" users={@active_users}/>
|
||||||
|
|
|
@ -33,7 +33,7 @@ defmodule LiveBeatsWeb.LayoutView do
|
||||||
<%= if @current_user do %>
|
<%= if @current_user do %>
|
||||||
<.link
|
<.link
|
||||||
redirect_to={profile_path(@current_user)}
|
redirect_to={profile_path(@current_user)}
|
||||||
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"
|
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 == :index, do: "bg-gray-300"}"}
|
||||||
>
|
>
|
||||||
<.icon name={:music_note} outlined class="text-gray-400 group-hover:text-gray-500 mr-3 flex-shrink-0 h-6 w-6"/>
|
<.icon name={:music_note} outlined class="text-gray-400 group-hover:text-gray-500 mr-3 flex-shrink-0 h-6 w-6"/>
|
||||||
My Songs
|
My Songs
|
||||||
|
@ -41,7 +41,7 @@ defmodule LiveBeatsWeb.LayoutView do
|
||||||
|
|
||||||
<.link
|
<.link
|
||||||
redirect_to={Routes.settings_path(LiveBeatsWeb.Endpoint, :edit)}
|
redirect_to={Routes.settings_path(LiveBeatsWeb.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"
|
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-300"}"}
|
||||||
>
|
>
|
||||||
<.icon name={:adjustments} outlined class="text-gray-400 group-hover:text-gray-500 mr-3 flex-shrink-0 h-6 w-6"/>
|
<.icon name={:adjustments} outlined class="text-gray-400 group-hover:text-gray-500 mr-3 flex-shrink-0 h-6 w-6"/>
|
||||||
Settings
|
Settings
|
||||||
|
|
Loading…
Reference in a new issue