feat: Initial style of home page
This commit is contained in:
@@ -2,4 +2,6 @@ using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
|
||||
|
||||
var builder = WebAssemblyHostBuilder.CreateDefault(args);
|
||||
|
||||
builder.Services.AddLogging();
|
||||
|
||||
await builder.Build().RunAsync();
|
||||
77
Pushy/Pushy.Client/TestClientForm.razor
Normal file
77
Pushy/Pushy.Client/TestClientForm.razor
Normal 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]
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user