Add project files.

This commit is contained in:
2020-01-06 22:29:20 +01:00
parent 0c5631787c
commit 514796de23
33 changed files with 1496 additions and 0 deletions

View File

@ -0,0 +1,16 @@
@page "/counter"
<h1>Counter</h1>
<p>Current count: @currentCount</p>
<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>
@code {
private int currentCount = 0;
private void IncrementCount()
{
currentCount++;
}
}

View File

@ -0,0 +1,16 @@
@page "/error"
<h1 class="text-danger">Error.</h1>
<h2 class="text-danger">An error occurred while processing your request.</h2>
<h3>Development Mode</h3>
<p>
Swapping to <strong>Development</strong> environment will display more detailed information about the error that occurred.
</p>
<p>
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
It can result in displaying sensitive information from exceptions to end users.
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
and restarting the app.
</p>

View File

@ -0,0 +1,47 @@
@page "/fetchdata"
@using Blazor3State.Data
@inject WeatherForecastService ForecastService
<h1>Showing states in blazor</h1>
<p>This component demonstrates fetching data from a service.</p>
<button class="btn btn-primary" @onclick="LoadImage">New Image</button>
<div class="image-container">
@if (state == LoadingContainerState.Loading)
{
<div class="lds-default"><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div></div>
}
else if (state == LoadingContainerState.Loaded)
{
<img src="https://loremflickr.com/200/300" alt="Alternate text" />
}
else if (state == LoadingContainerState.Error)
{
<p><em>An error has occurred. Click new image to try again !</em></p>
}
</div>
@code {
Random random = new Random();
public enum LoadingContainerState { Loading, Loaded, Error }
LoadingContainerState state;
protected override async Task OnInitializedAsync()
{
await LoadImage();
}
async Task LoadImage()
{
state = LoadingContainerState.Loading;
await Task.Delay(1000);
if (random.Next(3) == 2)
{
state = LoadingContainerState.Error;
}
else state = LoadingContainerState.Loaded;
}
}

View File

@ -0,0 +1,5 @@
@page "/"
<h1>Hello, world!</h1>
Welcome to your new app.

View File

@ -0,0 +1,36 @@
@page "/"
@namespace Blazor3State.Pages
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@{
Layout = null;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Blazor3State</title>
<base href="~/" />
<link rel="stylesheet" href="css/bootstrap/bootstrap.min.css" />
<link href="css/site.css" rel="stylesheet" />
</head>
<body>
<app>
<component type="typeof(App)" render-mode="ServerPrerendered" />
</app>
<div id="blazor-error-ui">
<environment include="Staging,Production">
An error has occurred. This application may no longer respond until reloaded.
</environment>
<environment include="Development">
An unhandled exception has occurred. See browser dev tools for details.
</environment>
<a href="" class="reload">Reload</a>
<a class="dismiss">🗙</a>
</div>
<script src="_framework/blazor.server.js"></script>
</body>
</html>