Files
GmRelayBot/src/GmRelay.Web/Components/Layout/NavMenu.razor
T
Toutsu 976e204102 feat(web): add Discord login button, platform indicator, and CSS styles
- Discord login button on /login with brand colors
- NavMenu shows user avatar (Discord) and platform label
- CSS: login-divider, login-btn-discord, nav-user-info, nav-user-platform
- NavMenu version bumped to v2.8.0

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-25 11:12:16 +03:00

96 lines
4.3 KiB
Plaintext

@inject NavigationManager Navigation
<div class="nav-header">
<a class="nav-brand" href="">
<img src="logo.png" alt="GM-Relay" class="nav-brand-icon" />
<span class="nav-brand-text">GM-Relay</span>
</a>
<button class="nav-toggle" @onclick="ToggleMenu" aria-label="Переключить меню">
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<line x1="3" y1="6" x2="21" y2="6"/>
<line x1="3" y1="12" x2="21" y2="12"/>
<line x1="3" y1="18" x2="21" y2="18"/>
</svg>
</button>
</div>
<nav class="nav-body @(isOpen ? "open" : "")">
<AuthorizeView>
<Authorized>
<div class="nav-section">
<NavLink class="nav-item" href="" Match="NavLinkMatch.All" @onclick="CloseMenu">
<svg class="nav-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"/>
<polyline points="9 22 9 12 15 12 15 22"/>
</svg>
Главная страница
</NavLink>
<NavLink class="nav-item" href="templates" @onclick="CloseMenu">
<svg class="nav-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<rect x="3" y="4" width="18" height="16" rx="2"/>
<path d="M7 8h10"/>
<path d="M7 12h6"/>
<path d="M7 16h8"/>
</svg>
Шаблоны
</NavLink>
</div>
<div class="nav-footer">
<div class="nav-user">
<div class="nav-user-avatar">
@if (!string.IsNullOrWhiteSpace(context.User.GetAvatarUrl()))
{
<img src="@context.User.GetAvatarUrl()" alt="" />
}
else
{
@(context.User.Identity?.Name?.Substring(0, 1).ToUpper() ?? "?")
}
</div>
<div class="nav-user-info">
<span class="nav-user-name">@context.User.Identity?.Name</span>
<span class="nav-user-platform">@GetPlatformLabel(context.User)</span>
</div>
</div>
<form action="/auth/logout" method="post">
<AntiforgeryToken />
<button type="submit" class="nav-logout-btn">
<svg class="nav-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1-2 2h4"/>
<polyline points="16 17 21 12 16 7"/>
<line x1="21" y1="12" x2="9" y2="12"/>
</svg>
Выход
</button>
</form>
<div class="nav-version">v2.8.0</div>
</div>
</Authorized>
<NotAuthorized>
<div class="nav-section">
<NavLink class="nav-item" href="login" @onclick="CloseMenu">
<svg class="nav-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4"/>
<polyline points="10 17 15 12 10 7"/>
<line x1="15" y1="12" x2="3" y2="12"/>
</svg>
Вход
</NavLink>
</div>
</NotAuthorized>
</AuthorizeView>
</nav>
@code {
private bool isOpen;
private void ToggleMenu() => isOpen = !isOpen;
private void CloseMenu() => isOpen = false;
private static string GetPlatformLabel(System.Security.Claims.ClaimsPrincipal user) =>
user.TryGetDiscordId(out _) ? "Discord" : "Telegram";
}