init commit

This commit is contained in:
2025-04-07 11:45:14 -05:00
commit 644ef8d5c8
30 changed files with 1422 additions and 0 deletions

18
Pages/Counter.razor Normal file
View File

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

85
Pages/Home.razor Normal file
View File

@ -0,0 +1,85 @@
@page "/"
@inject WeatherService WeatherService
<PageTitle>Memphis Weather</PageTitle>
@if (weather == null)
{
<MudProgressCircular Color="Color.Primary" Indeterminate="true" />
}
else
{
<MudCard Class="mt-6" Style="max-width: 500px; margin: auto;">
<MudCardHeader>
<CardHeaderContent>
<MudText Typo="Typo.h5">@weather.City Weather</MudText>
<MudText Typo="Typo.body2">Current Conditions</MudText>
</CardHeaderContent>
<CardHeaderActions>
<MudIconButton Icon="@Icons.Material.Filled.Refresh" Color="Color.Default" OnClick="RefreshWeather" />
</CardHeaderActions>
</MudCardHeader>
<MudCardContent>
<div class="d-flex align-center">
<img src="@weather.Icon" alt="Weather icon" />
<div class="ml-3">
<MudText Typo="Typo.h3">@weather.Temperature.ToString("F1")°F</MudText>
<MudText Typo="Typo.body1" Style="text-transform: capitalize;">@weather.Description</MudText>
</div>
</div>
<MudDivider Class="my-4" />
<div>
<div class="d-flex align-center mb-2">
<MudIcon Icon="@Icons.Material.Filled.Opacity" Color="Color.Info" Class="mr-2" />
<MudText>Humidity: @weather.Humidity%</MudText>
</div>
<div class="d-flex align-center">
<MudIcon Icon="@Icons.Material.Filled.Air" Color="Color.Info" Class="mr-2" />
<MudText>Wind: @weather.WindSpeed mph</MudText>
</div>
</div>
</MudCardContent>
<MudCardActions>
<MudButton Variant="Variant.Text" Color="Color.Primary"
Href="https://openweathermap.org/city/4641239" Target="_blank">
More Details
</MudButton>
<MudSpacer />
<MudButton Variant="Variant.Filled" Color="Color.Secondary"
Href="/weather">
View Weather History
</MudButton>
</MudCardActions>
</MudCard>
<MudCard Class="mt-4" Style="max-width: 500px; margin: auto;">
<MudCardHeader>
<CardHeaderContent>
<MudText Typo="Typo.h5">Developer Resources</MudText>
</CardHeaderContent>
</MudCardHeader>
<MudCardContent>
<MudText>View PlayWright test report for this website.</MudText>
</MudCardContent>
<MudCardActions>
<MudButton Variant="Variant.Filled" Color="Color.Info"
Href="playwright-report/index.html" Target="_blank">
View Report
</MudButton>
</MudCardActions>
</MudCard>
}
@code {
private WeatherInfo? weather;
protected override async Task OnInitializedAsync()
{
await RefreshWeather();
}
private async Task RefreshWeather()
{
weather = await WeatherService.GetWeatherAsync();
}
}

62
Pages/Weather.razor Normal file
View File

@ -0,0 +1,62 @@
@page "/weather"
@inject HttpClient Http
<PageTitle>Weather</PageTitle>
<h1>Weather</h1>
<p>This page displays some fake weather data that seems to have been created when Blazor was installed.</p>
<div class="d-flex justify-space-between align-center">
<h1>Weather</h1>
<MudButton Variant="Variant.Filled" Color="Color.Primary" Href="/">Back to Home</MudButton>
</div>
@if (forecasts == null)
{
<p><em>Loading...</em></p>
}
else
{
<table class="table">
<thead>
<tr>
<th>Date</th>
<th>Temp. (C)</th>
<th>Temp. (F)</th>
<th>Summary</th>
</tr>
</thead>
<tbody>
@foreach (var forecast in forecasts)
{
<tr>
<td>@forecast.Date.ToShortDateString()</td>
<td>@forecast.TemperatureC</td>
<td>@forecast.TemperatureF</td>
<td>@forecast.Summary</td>
</tr>
}
</tbody>
</table>
}
@code {
private WeatherForecast[]? forecasts;
protected override async Task OnInitializedAsync()
{
forecasts = await Http.GetFromJsonAsync<WeatherForecast[]>("sample-data/weather.json");
}
public class WeatherForecast
{
public DateOnly Date { get; set; }
public int TemperatureC { get; set; }
public string? Summary { get; set; }
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
}
}