feat: Initial style of home page

This commit is contained in:
henrik
2024-12-09 23:47:38 +01:00
parent 95c6190e69
commit 41a174e1cb
12 changed files with 3354 additions and 39 deletions

View File

@@ -0,0 +1,77 @@
@page "/test"
@rendermode InteractiveWebAssembly
@inject PersistentComponentState ApplicationState
@inject ILogger<TestClientForm> Logger
<p>@Data - @RendererInfo.Name</p>
<EditForm Enhance FormName="TestForm" OnSubmit="Callback" Model="Item">
<InputText @bind-Value="@Item.Text"/>
<button class="btn " type="submit" disabled="@(doingStuff || !RendererInfo.IsInteractive)">
@if (doingStuff || !RendererInfo.IsInteractive)
{
<span class="loading loading-spinner"></span>
<a>Loading...</a>
}
else
{
<a>Test</a>
}
</button>
</EditForm>
@code {
private bool doingStuff = false;
private PersistingComponentStateSubscription persistingSubscription;
public sealed class FormInput
{
public required string Text { get; set; }
public required string[] Existing { get; set; }
}
[SupplyParameterFromForm] public FormInput Item { get; set; } = new()
{
Text = string.Empty,
Existing = []
};
public Guid Data = Guid.NewGuid();
protected override Task OnInitializedAsync()
{
persistingSubscription =
ApplicationState.RegisterOnPersisting(PersistData);
if (!ApplicationState.TryTakeFromJson<Guid>("TOKEN", out Data))
{
Data = Guid.NewGuid();
Logger.LogInformation("Data needs to be persisted! {Data}", Data);
}
else
{
Logger.LogInformation("Using persisted DATA");
}
return Task.CompletedTask;
}
private Task PersistData()
{
Logger.LogInformation("Persisting! {Data}", Data);
ApplicationState.PersistAsJson("TOKEN", Data);
return Task.CompletedTask;
}
private async Task Callback()
{
Item = new FormInput
{
Text = string.Empty,
Existing = [..Item.Existing, Item.Text, RendererInfo.Name]
};
}
}