btcpayserver/BTCPayServer/Views/Shared/LayoutHeadTheme.cshtml
2023-11-20 11:18:19 +01:00

30 lines
1.6 KiB
Text

@using BTCPayServer.Services
@using BTCPayServer.Abstractions.Contracts
@inject ThemeSettings Theme
@inject IFileService FileService
<script>if (window.localStorage.getItem('btcpay-hide-sensitive-info') === 'true') { document.documentElement.setAttribute('data-hide-sensitive-info', 'true')}</script>
@if (Theme.CustomTheme && !string.IsNullOrEmpty(Theme.CssUri))
{ // legacy customization with CSS URI - keep it for backwards-compatibility
<link href="@Context.Request.GetRelativePathOrAbsolute(Theme.CssUri)" rel="stylesheet" asp-append-version="true" />
}
else if (Theme.CustomTheme && !string.IsNullOrEmpty(Theme.CustomThemeFileId))
{ // new customization uses theme file id provided by upload
@if (Theme.CustomThemeExtension != ThemeExtension.Custom)
{ // needs to be added for light and dark, because dark extends light
<link href="~/main/themes/default.css" rel="stylesheet" asp-append-version="true" />
}
@if (Theme.CustomThemeExtension == ThemeExtension.Dark)
{
<link href="~/main/themes/default-dark.css" rel="stylesheet" asp-append-version="true" />
}
<link href="@(await FileService.GetFileUrl(Context.Request.GetAbsoluteRootUri(), Theme.CustomThemeFileId))" rel="stylesheet" asp-append-version="true" />
}
else
{
<link href="~/main/themes/default.css" asp-append-version="true" rel="stylesheet" />
<link href="~/main/themes/default-dark.css" asp-append-version="true" rel="stylesheet" id="DarkThemeLinkTag" />
<script src="~/js/theme-switch.js" asp-append-version="true"></script>
<noscript><style>.btcpay-theme-switch { display: none !important; }</style></noscript>
}