118 lines
5.1 KiB
Plaintext
118 lines
5.1 KiB
Plaintext
@using Moonlight.Client.Services
|
|
@using Moonlight.Client.UI.Layouts
|
|
|
|
@inject IdentityService IdentityService
|
|
@inject ToastService ToastService
|
|
|
|
<div class="sticky top-0 z-40 flex h-16 shrink-0 items-center gap-x-4 bg-gray-800/60 backdrop-blur px-4 shadow-sm sm:gap-x-6 sm:px-6 lg:px-8">
|
|
@if (Layout.ShowMobileNavigation)
|
|
{
|
|
<button @onclick="Layout.ToggleMobileNavigation" type="button" class="-m-2.5 p-2.5 text-gray-700 lg:hidden">
|
|
<span class="sr-only">Close sidebar</span>
|
|
<i class="bi bi-x-lg text-xl"></i>
|
|
</button>
|
|
}
|
|
else
|
|
{
|
|
<button @onclick="Layout.ToggleMobileNavigation" type="button" class="-m-2.5 p-2.5 text-gray-700 lg:hidden">
|
|
<span class="sr-only">Open sidebar</span>
|
|
<i class="bi bi-list text-xl"></i>
|
|
</button>
|
|
}
|
|
|
|
<div class="h-6 w-px bg-gray-800 lg:hidden" aria-hidden="true"></div>
|
|
|
|
<div class="flex justify-between gap-x-4 lg:gap-x-6 w-full">
|
|
<div></div>
|
|
<div class="flex items-center gap-x-4 lg:gap-x-6">
|
|
@*
|
|
<button type="button" class="-m-2.5 p-2.5 text-gray-200 hover:text-gray-100">
|
|
<span class="sr-only">View notifications</span>
|
|
<svg class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" aria-hidden="true">
|
|
<path stroke-linecap="round" stroke-linejoin="round" d="M14.857 17.082a23.848 23.848 0 005.454-1.31A8.967 8.967 0 0118 9.75v-.7V9A6 6 0 006 9v.75a8.967 8.967 0 01-2.312 6.022c1.733.64 3.56 1.085 5.455 1.31m5.714 0a24.255 24.255 0 01-5.714 0m5.714 0a3 3 0 11-5.714 0"/>
|
|
</svg>
|
|
</button>
|
|
*@
|
|
|
|
<!-- Separator -->
|
|
<div class="hidden lg:block lg:h-6 lg:w-px lg:bg-gray-900/10" aria-hidden="true"></div>
|
|
|
|
<!-- Profile dropdown -->
|
|
<div class="relative">
|
|
<button @onclick="ToggleProfileNav" @onfocusout="ProfileNav_OnFocusOut" type="button" class="-m-1.5 flex items-center p-1.5" id="user-menu-button" aria-expanded="false" aria-haspopup="true">
|
|
<span class="sr-only">Open user menu</span>
|
|
<img class="h-8 w-8 rounded-full" src="https://masuowo.xyz/assets/images/avatar.png" alt="">
|
|
<span class="hidden lg:flex lg:items-center">
|
|
<span class="ml-4 text-sm font-semibold leading-6 text-gray-100" aria-hidden="true">
|
|
@("@" + IdentityService.Username)
|
|
</span>
|
|
<svg class="ml-2 h-5 w-5 text-gray-400" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
|
|
<path fill-rule="evenodd" d="M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z" clip-rule="evenodd"/>
|
|
</svg>
|
|
</span>
|
|
</button>
|
|
|
|
<!--
|
|
Dropdown menu, show/hide based on menu state.
|
|
|
|
Entering: ""
|
|
From: "transform scale-95"
|
|
To: "transform opacity-100 scale-100"
|
|
Leaving: "transition ease-in duration-75"
|
|
From: "transform opacity-100 scale-100"
|
|
To: "transform opacity-0 scale-95"
|
|
-->
|
|
<div class="@(ShowProfileNav ? "opacity-100" : "opacity-0") transition ease-out duration-100 absolute right-0 z-10 mt-2.5 w-44 origin-top-right rounded-md bg-gray-750 py-2 shadow-lg ring-1 ring-gray-100/5 focus:outline-none" role="menu" aria-orientation="vertical" aria-labelledby="user-menu-button" tabindex="-1">
|
|
<!-- Active: "bg-gray-50", Not Active: "" -->
|
|
<a href="/admin" class="block px-3 py-1 text-sm leading-6 text-gray-100 hover:text-primary-500" role="menuitem" tabindex="-1" id="user-menu-item-0">Your profile</a>
|
|
<a @onclick="Logout" @onclick:preventDefault href="#" class="block px-3 py-1 text-sm leading-6 text-gray-100 hover:text-primary-500" role="menuitem" tabindex="-1" id="user-menu-item-1">Sign out</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
@code
|
|
{
|
|
[Parameter] public MainLayout Layout { get; set; }
|
|
|
|
private bool ShowProfileNav = false;
|
|
|
|
protected override Task OnAfterRenderAsync(bool firstRender)
|
|
{
|
|
if(!firstRender)
|
|
return Task.CompletedTask;
|
|
|
|
Layout.OnStateChanged += () => InvokeAsync(StateHasChanged);
|
|
|
|
return Task.CompletedTask;
|
|
}
|
|
|
|
private async Task ToggleProfileNav()
|
|
{
|
|
ShowProfileNav = !ShowProfileNav;
|
|
await InvokeAsync(StateHasChanged);
|
|
}
|
|
|
|
private Task ProfileNav_OnFocusOut()
|
|
{
|
|
Task.Run(async () =>
|
|
{
|
|
await Task.Delay(200);
|
|
|
|
ShowProfileNav = false;
|
|
await InvokeAsync(StateHasChanged);
|
|
});
|
|
|
|
return Task.CompletedTask;
|
|
}
|
|
|
|
private async Task Logout()
|
|
{
|
|
await IdentityService.Logout();
|
|
await ToastService.Info("Successfully logged out");
|
|
|
|
await Layout.Load();
|
|
}
|
|
}
|