Skip to content

Commit 3cb5df2

Browse files
committed
Add basic template.
1 parent e990ea5 commit 3cb5df2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1555
-0
lines changed

Templates/Basic.sln

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.30128.74
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Basic.Server", "Basic\Server\Basic.Server.csproj", "{415C9E90-4080-4421-93A7-B56F282FCCAB}"
7+
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Basic.Client", "Basic\Client\Basic.Client.csproj", "{6B8C938E-3297-4215-83EA-EDFDEDACA0B0}"
9+
EndProject
10+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Basic.Shared", "Basic\Shared\Basic.Shared.csproj", "{2BF069AE-0E49-48C4-8B32-FFE745DE33C5}"
11+
EndProject
12+
Global
13+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
14+
Debug|Any CPU = Debug|Any CPU
15+
Release|Any CPU = Release|Any CPU
16+
EndGlobalSection
17+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
18+
{415C9E90-4080-4421-93A7-B56F282FCCAB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
19+
{415C9E90-4080-4421-93A7-B56F282FCCAB}.Debug|Any CPU.Build.0 = Debug|Any CPU
20+
{415C9E90-4080-4421-93A7-B56F282FCCAB}.Release|Any CPU.ActiveCfg = Release|Any CPU
21+
{415C9E90-4080-4421-93A7-B56F282FCCAB}.Release|Any CPU.Build.0 = Release|Any CPU
22+
{6B8C938E-3297-4215-83EA-EDFDEDACA0B0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
23+
{6B8C938E-3297-4215-83EA-EDFDEDACA0B0}.Debug|Any CPU.Build.0 = Debug|Any CPU
24+
{6B8C938E-3297-4215-83EA-EDFDEDACA0B0}.Release|Any CPU.ActiveCfg = Release|Any CPU
25+
{6B8C938E-3297-4215-83EA-EDFDEDACA0B0}.Release|Any CPU.Build.0 = Release|Any CPU
26+
{2BF069AE-0E49-48C4-8B32-FFE745DE33C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27+
{2BF069AE-0E49-48C4-8B32-FFE745DE33C5}.Debug|Any CPU.Build.0 = Debug|Any CPU
28+
{2BF069AE-0E49-48C4-8B32-FFE745DE33C5}.Release|Any CPU.ActiveCfg = Release|Any CPU
29+
{2BF069AE-0E49-48C4-8B32-FFE745DE33C5}.Release|Any CPU.Build.0 = Release|Any CPU
30+
EndGlobalSection
31+
GlobalSection(SolutionProperties) = preSolution
32+
HideSolutionNode = FALSE
33+
EndGlobalSection
34+
GlobalSection(ExtensibilityGlobals) = postSolution
35+
SolutionGuid = {0B10CE16-55E3-4D2D-8724-984CF8F09FE3}
36+
EndGlobalSection
37+
EndGlobal

Templates/Basic/Client/App.razor

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<Router AppAssembly="@typeof(Program).Assembly">
2+
<Found Context="routeData">
3+
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
4+
</Found>
5+
<NotFound>
6+
<LayoutView Layout="@typeof(MainLayout)">
7+
<p>Sorry, there's nothing at this address.</p>
8+
</LayoutView>
9+
</NotFound>
10+
</Router>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netstandard2.1</TargetFramework>
5+
<RazorLangVersion>3.0</RazorLangVersion>
6+
</PropertyGroup>
7+
8+
<ItemGroup>
9+
<PackageReference Include="DotNetify.Blazor" Version="1.0.0" />
10+
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="3.2.0" />
11+
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Build" Version="3.2.0" PrivateAssets="all" />
12+
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="3.2.0" PrivateAssets="all" />
13+
<PackageReference Include="System.Net.Http.Json" Version="3.2.0" />
14+
</ItemGroup>
15+
16+
<ItemGroup>
17+
<ProjectReference Include="..\Shared\Basic.Shared.csproj" />
18+
</ItemGroup>
19+
20+
</Project>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
@page "/counter"
2+
3+
<h1>Counter</h1>
4+
5+
<VMContext VM="Counter" TState="ICounterState" OnStateChange="UpdateState">
6+
<p>Current count: @state?.CurrentCount</p>
7+
8+
<button class="btn btn-primary" @onclick="() => state.IncrementCount()">Click me</button>
9+
</VMContext>
10+
11+
@code {
12+
private ICounterState state;
13+
14+
private void UpdateState(ICounterState state)
15+
{
16+
this.state = state;
17+
StateHasChanged();
18+
}
19+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
@page "/fetchdata"
2+
@using Basic.Shared
3+
@inject HttpClient Http
4+
5+
<h1>Weather forecast</h1>
6+
7+
<p>This component demonstrates fetching data from the server.</p>
8+
9+
<VMContext VM="FetchData" TState="IFetchDataState" OnStateChange="UpdateState">
10+
@if (state == null)
11+
{
12+
<p><em>Loading...</em></p>
13+
}
14+
else
15+
{
16+
<table class="table">
17+
<thead>
18+
<tr>
19+
<th>Date</th>
20+
<th>Temp. (C)</th>
21+
<th>Temp. (F)</th>
22+
<th>Summary</th>
23+
</tr>
24+
</thead>
25+
<tbody>
26+
@foreach (var forecast in state.Forecasts)
27+
{
28+
<tr>
29+
<td>@forecast.Date.ToShortDateString()</td>
30+
<td>@forecast.TemperatureC</td>
31+
<td>@forecast.TemperatureF</td>
32+
<td>@forecast.Summary</td>
33+
</tr>
34+
}
35+
</tbody>
36+
</table>
37+
}
38+
</VMContext>
39+
40+
@code {
41+
private IFetchDataState state;
42+
43+
private void UpdateState(IFetchDataState state)
44+
{
45+
this.state = state;
46+
StateHasChanged();
47+
}
48+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
@page "/helloworld"
2+
3+
<VMContext VM="HelloWorld" TState="IHelloWorldState" OnStateChange="UpdateState">
4+
@if (state != null)
5+
{
6+
<h1>@state.Greetings</h1>
7+
<div>
8+
<p>Server time is: <strong>@state.ServerTime</strong></p>
9+
<p>Enter your name:</p>
10+
<div style="display:flex">
11+
<input type="text" class="form-control" placeholder="First name" @bind="person.FirstName" />
12+
<input type="text" class="form-control" placeholder="Last name" @bind="person.LastName" />
13+
<button class="btn btn-primary" @onclick="() => state.Submit(person)">Submit</button>
14+
</div>
15+
16+
</div>
17+
}
18+
</VMContext>
19+
20+
@code {
21+
private IHelloWorldState state;
22+
private Person person = new Person();
23+
24+
private void UpdateState(IHelloWorldState state)
25+
{
26+
this.state = state;
27+
StateHasChanged();
28+
}
29+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
@page "/"
2+
3+
<h1>Hello, world!</h1>
4+
5+
Welcome to your new app.
6+
7+
<SurveyPrompt Title="How is Blazor working for you?" />

Templates/Basic/Client/Program.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using System;
2+
using System.Net.Http;
3+
using System.Threading.Tasks;
4+
using DotNetify.Blazor;
5+
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
6+
using Microsoft.Extensions.DependencyInjection;
7+
8+
namespace Basic.Client
9+
{
10+
public class Program
11+
{
12+
public static async Task Main(string[] args)
13+
{
14+
var builder = WebAssemblyHostBuilder.CreateDefault(args);
15+
builder.RootComponents.Add<App>("app");
16+
17+
builder.Services.AddDotNetifyBlazor(config => config.Debug = true);
18+
builder.Services.AddTransient(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
19+
20+
await builder.Build().RunAsync();
21+
}
22+
}
23+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
@inherits LayoutComponentBase
2+
3+
<div class="sidebar">
4+
<NavMenu />
5+
</div>
6+
7+
<div class="main">
8+
<div class="top-row px-4">
9+
<a href="http://blazor.net" target="_blank" class="ml-md-auto">About</a>
10+
</div>
11+
12+
<div class="content px-4">
13+
@Body
14+
</div>
15+
</div>
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<div class="top-row pl-4 navbar navbar-dark">
2+
<a class="navbar-brand" href="">Basic</a>
3+
<button class="navbar-toggler" @onclick="ToggleNavMenu">
4+
<span class="navbar-toggler-icon"></span>
5+
</button>
6+
</div>
7+
8+
<div class="@NavMenuCssClass" @onclick="ToggleNavMenu">
9+
<ul class="nav flex-column">
10+
<li class="nav-item px-3">
11+
<NavLink class="nav-link" href="" Match="NavLinkMatch.All">
12+
<span class="oi oi-home" aria-hidden="true"></span> Home
13+
</NavLink>
14+
</li>
15+
<li class="nav-item px-3">
16+
<NavLink class="nav-link" href="counter">
17+
<span class="oi oi-plus" aria-hidden="true"></span> Counter
18+
</NavLink>
19+
</li>
20+
<li class="nav-item px-3">
21+
<NavLink class="nav-link" href="fetchdata">
22+
<span class="oi oi-list-rich" aria-hidden="true"></span> Fetch data
23+
</NavLink>
24+
</li>
25+
<li class="nav-item px-3">
26+
<NavLink class="nav-link" href="helloworld">
27+
<span class="oi oi-list-rich" aria-hidden="true"></span> Hello world
28+
</NavLink>
29+
</li>
30+
</ul>
31+
</div>
32+
33+
@code {
34+
private bool collapseNavMenu = true;
35+
36+
private string NavMenuCssClass => collapseNavMenu ? "collapse" : null;
37+
38+
private void ToggleNavMenu()
39+
{
40+
collapseNavMenu = !collapseNavMenu;
41+
}
42+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<div class="alert alert-secondary mt-4" role="alert">
2+
<span class="oi oi-pencil mr-2" aria-hidden="true"></span>
3+
<strong>@Title</strong>
4+
5+
<span class="text-nowrap">
6+
Please take our
7+
<a target="_blank" class="font-weight-bold" href="https://go.microsoft.com/fwlink/?linkid=2127996">brief survey</a>
8+
</span>
9+
and tell us what you think.
10+
</div>
11+
12+
@code {
13+
// Demonstrates how a parent component can supply parameters
14+
[Parameter]
15+
public string Title { get; set; }
16+
}

Templates/Basic/Client/_Imports.razor

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
@using System.Net.Http
2+
@using System.Net.Http.Json
3+
@using Microsoft.AspNetCore.Components.Forms
4+
@using Microsoft.AspNetCore.Components.Routing
5+
@using Microsoft.AspNetCore.Components.Web
6+
@using Microsoft.AspNetCore.Components.WebAssembly.Http
7+
@using Microsoft.JSInterop
8+
@using Basic.Client
9+
@using Basic.Client.Shared
10+
@using Basic.Shared
11+
@using DotNetify.Blazor;

0 commit comments

Comments
 (0)