mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-22 22:25:28 +01:00
* Add logo upload * Add brand color definition * Cleanups * Add logo to store selector * Improve brand color handling * Update color input * Add logo dimensions hint * Fixes * Fix pattern and warning in js logs for color validation * Fix condition, add test Co-authored-by: nicolas.dorier <nicolas.dorier@gmail.com>
79 lines
3.9 KiB
Text
79 lines
3.9 KiB
Text
@using Microsoft.AspNetCore.Mvc.TagHelpers
|
|
@using BTCPayServer.Abstractions.Extensions
|
|
@using BTCPayServer.Abstractions.TagHelpers
|
|
@using BTCPayServer.Abstractions.Contracts
|
|
@inject BTCPayServer.Services.BTCPayServerEnvironment Env
|
|
@inject SignInManager<ApplicationUser> SignInManager
|
|
@inject IFileService FileService
|
|
@model BTCPayServer.Components.StoreSelector.StoreSelectorViewModel
|
|
@functions {
|
|
@* ReSharper disable once CSharpWarnings::CS1998 *@
|
|
#pragma warning disable 1998
|
|
private async Task LogoContent()
|
|
{
|
|
var logoSrc = $"{ViewContext.HttpContext.Request.PathBase}/img/logo.svg";
|
|
<svg xmlns="http://www.w3.org/2000/svg" role="img" alt="BTCPay Server" class="logo"><use href="@logoSrc#small" class="logo-small" /><use href="@logoSrc#large" class="logo-large" /></svg>
|
|
@if (Env.NetworkType != NBitcoin.ChainName.Mainnet)
|
|
{
|
|
<span class="badge bg-warning ms-1 ms-sm-0" style="font-size:10px;">@Env.NetworkType.ToString()</span>
|
|
}
|
|
}
|
|
private string StoreName(string title)
|
|
{
|
|
return string.IsNullOrEmpty(title) ? "Unnamed Store" : title;
|
|
}
|
|
#pragma warning restore 1998
|
|
}
|
|
@if (Model.CurrentStoreId == null)
|
|
{
|
|
<a href="~/" class="navbar-brand py-2 js-scroll-trigger">@{await LogoContent();}</a>
|
|
}
|
|
else if (Model.CurrentStoreIsOwner)
|
|
{
|
|
<a asp-controller="UIStores" asp-action="Dashboard" asp-route-storeId="@Model.CurrentStoreId" class="navbar-brand py-2 js-scroll-trigger">@{await LogoContent();}</a>
|
|
}
|
|
else
|
|
{
|
|
<a asp-controller="UIInvoice" asp-action="ListInvoices" asp-route-storeId="@Model.CurrentStoreId" class="navbar-brand py-2 js-scroll-trigger">@{await LogoContent();}</a>
|
|
}
|
|
|
|
<div id="StoreSelector">
|
|
@if (Model.Options.Count > 0)
|
|
{
|
|
<div id="StoreSelectorDropdown" class="dropdown only-for-js">
|
|
<button id="StoreSelectorToggle" class="btn btn-secondary dropdown-toggle rounded-pill px-3 @(Model.CurrentStoreId == null ? "text-secondary" : "")" type="button" data-bs-toggle="dropdown" aria-expanded="false">
|
|
@if (!string.IsNullOrEmpty(Model.CurrentStoreLogoFileId))
|
|
{
|
|
<img class="logo" src="@(await FileService.GetFileUrl(Context.Request.GetAbsoluteRootUri(), Model.CurrentStoreLogoFileId))" alt="@Model.CurrentDisplayName" />
|
|
}
|
|
else
|
|
{
|
|
<vc:icon symbol="store"/>
|
|
}
|
|
<span>@(Model.CurrentStoreId == null ? "Select Store" : Model.CurrentDisplayName)</span>
|
|
<vc:icon symbol="caret-down"/>
|
|
</button>
|
|
<ul id="StoreSelectorMenu" class="dropdown-menu" aria-labelledby="StoreSelectorToggle">
|
|
@foreach (var option in Model.Options)
|
|
{
|
|
<li>
|
|
@if (option.IsOwner)
|
|
{
|
|
<a asp-controller="UIStores" asp-action="Dashboard" asp-route-storeId="@option.Value" class="dropdown-item@(option.Selected ? " active" : "")" id="StoreSelectorMenuItem-@option.Value">@StoreName(option.Text)</a>
|
|
}
|
|
else
|
|
{
|
|
<a asp-controller="UIInvoice" asp-action="ListInvoices" asp-route-storeId="@option.Value" class="dropdown-item@(option.Selected ? " active" : "")" id="StoreSelectorMenuItem-@option.Value">@StoreName(option.Text)</a>
|
|
}
|
|
</li>
|
|
}
|
|
<li><hr class="dropdown-divider"></li>
|
|
<li><a asp-controller="UIUserStores" asp-action="CreateStore" class="dropdown-item" id="StoreSelectorCreate">Create Store</a></li>
|
|
</ul>
|
|
</div>
|
|
}
|
|
else if (SignInManager.IsSignedIn(User))
|
|
{
|
|
<a asp-controller="UIUserStores" asp-action="CreateStore" class="btn btn-primary w-100 rounded-pill" id="StoreSelectorCreate">Create Store</a>
|
|
}
|
|
</div>
|