fixed theme select not updating (replaced js with server-side render)

This commit is contained in:
Mia Rose Winter 2024-01-25 13:41:52 +01:00
parent 0b18e1ac7e
commit cb8e12d01d
Signed by: miawinter
GPG key ID: 4B6F6A83178F595E
2 changed files with 10 additions and 4 deletions

View file

@ -35,7 +35,9 @@
</head>
<body>
<CascadingValue Value="UserTheme" Name="UserTheme">
<Routes />
</CascadingValue>
<script src="_framework/blazor.web.js"></script>
<SectionOutlet SectionName="scripts" />
</body>

View file

@ -61,11 +61,10 @@
</button>
<select id="theme-select" class="select select-bordered select-sm md:text-center join-item min-w-0 flex-1"
onchange="window.location = `/theme/${this.value}?returnUrl=@WebUtility.UrlEncode("/" + Navigation.ToBaseRelativePath(Navigation.Uri))`">
<option value="">@Localizer["Theme_Default"]</option>
<option value="wave-light">@Localizer["Theme_WaveLight"]</option>
<option value="wave-dark">@Localizer["Theme_WaveDark"]</option>
<option selected="@(UserTheme is null)" value="">@Localizer["Theme_Default"]</option>
<option selected="@(UserTheme is "wave-light")" value="wave-light">@Localizer["Theme_WaveLight"]</option>
<option selected="@(UserTheme is "wave-dark")" value="wave-dark">@Localizer["Theme_WaveDark"]</option>
</select>
<script>document.getElementById("theme-select").value = document.documentElement.dataset.theme</script>
</div>
</footer>
</div>
@ -78,3 +77,8 @@
</div>
</div>
</div>
@code {
[CascadingParameter(Name = "UserTheme")]
private string? UserTheme { get; set; }
}