btcpayserver/BTCPayServer/Views/Shared/LayoutHeadStoreBranding.cshtml

55 lines
1.9 KiB
Text
Raw Normal View History

@model (string BrandColor, string CssFileId, string CustomCSSLink, string EmbeddedCSS)
2022-12-19 15:51:05 +01:00
@using BTCPayServer.Abstractions.Extensions
@using Microsoft.AspNetCore.Mvc.TagHelpers
@using BTCPayServer.Abstractions.Contracts
@inject IFileService FileService
@{
var cssUrl = !string.IsNullOrEmpty(Model.CssFileId)
? await FileService.GetFileUrl(Context.Request.GetAbsoluteRootUri(), Model.CssFileId)
: null;
}
@if (!string.IsNullOrEmpty(Model.BrandColor))
{
var brand = Model.BrandColor;
var brandColor = ColorPalette.Default.FromHtml(brand);
var brandRgbValues = $"{brandColor.R}, {brandColor.G}, {brandColor.B}";
var accent = ColorPalette.Default.AdjustBrightness(brand, (float)-0.15);
var complement = ColorPalette.Default.TextColor(brand);
var complementVar = $"var(--btcpay-{(complement == "black" ? "black" : "white")})";
2022-12-19 15:51:05 +01:00
<style>
:root {
--btcpay-primary: @brand;
--btcpay-primary-rgb: @brandRgbValues;
--btcpay-primary-shadow: @brand;
--btcpay-primary-bg-hover: @accent;
--btcpay-primary-bg-active: @accent;
--btcpay-body-link: @brand;
--btcpay-body-link-accent: @accent;
--btcpay-primary-text: @complementVar;
--btcpay-primary-text-hover: @complementVar;
--btcpay-primary-text-active: @complementVar;
}
a {
color: var(--btcpay-body-link);
}
a:hover {
color: var(--btcpay-body-link-accent);
2022-12-19 15:51:05 +01:00
}
</style>
}
@if (!string.IsNullOrEmpty(cssUrl))
{
<link href="@cssUrl" asp-append-version="true" rel="stylesheet" />
}
@* Deprecated, but added for backwards-compatibility *@
@if (!string.IsNullOrEmpty(Model.CustomCSSLink))
{
<link href="@Model.CustomCSSLink" asp-append-version="true" rel="stylesheet" />
}
@if (!string.IsNullOrEmpty(Model.EmbeddedCSS))
{
<style>
@Safe.Raw(Model.EmbeddedCSS)
</style>
}