[frontend] Set theme-color meta tag to --background-color

This commit is contained in:
Lilian 2024-11-17 03:00:02 +01:00 committed by Laura Hausmann
parent 1a39b2856a
commit bd6972a0c3
No known key found for this signature in database
GPG key ID: D044E84C5BE01605

View file

@ -1,6 +1,7 @@
@using Iceshrimp.Frontend.Components
@using Iceshrimp.Frontend.Core.Services
@using Microsoft.AspNetCore.Components.Authorization
@inject IJSRuntime Js;
@* ReSharper disable once UnusedMember.Local *@
@inject UpdateService UpdateSvc;
<ErrorBoundary>
@ -28,5 +29,16 @@
</ErrorContent>
</ErrorBoundary>
<HeadContent>
<meta name="theme-color" content="@_backgroundColor"/>
</HeadContent>
@code {
private string? _backgroundColor;
protected override void OnInitialized()
{
_backgroundColor = ((IJSInProcessRuntime)Js).Invoke<string>("eval",
"getComputedStyle(document.documentElement).getPropertyValue('--background-color')");
}
}