Skip to content

Commit

Permalink
Add basic template.
Browse files Browse the repository at this point in the history
  • Loading branch information
dsuryd committed Jul 13, 2020
1 parent e990ea5 commit 3cb5df2
Show file tree
Hide file tree
Showing 41 changed files with 1,555 additions and 0 deletions.
37 changes: 37 additions & 0 deletions Templates/Basic.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30128.74
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Basic.Server", "Basic\Server\Basic.Server.csproj", "{415C9E90-4080-4421-93A7-B56F282FCCAB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Basic.Client", "Basic\Client\Basic.Client.csproj", "{6B8C938E-3297-4215-83EA-EDFDEDACA0B0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Basic.Shared", "Basic\Shared\Basic.Shared.csproj", "{2BF069AE-0E49-48C4-8B32-FFE745DE33C5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{415C9E90-4080-4421-93A7-B56F282FCCAB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{415C9E90-4080-4421-93A7-B56F282FCCAB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{415C9E90-4080-4421-93A7-B56F282FCCAB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{415C9E90-4080-4421-93A7-B56F282FCCAB}.Release|Any CPU.Build.0 = Release|Any CPU
{6B8C938E-3297-4215-83EA-EDFDEDACA0B0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6B8C938E-3297-4215-83EA-EDFDEDACA0B0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6B8C938E-3297-4215-83EA-EDFDEDACA0B0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6B8C938E-3297-4215-83EA-EDFDEDACA0B0}.Release|Any CPU.Build.0 = Release|Any CPU
{2BF069AE-0E49-48C4-8B32-FFE745DE33C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2BF069AE-0E49-48C4-8B32-FFE745DE33C5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2BF069AE-0E49-48C4-8B32-FFE745DE33C5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2BF069AE-0E49-48C4-8B32-FFE745DE33C5}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {0B10CE16-55E3-4D2D-8724-984CF8F09FE3}
EndGlobalSection
EndGlobal
10 changes: 10 additions & 0 deletions Templates/Basic/Client/App.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Router AppAssembly="@typeof(Program).Assembly">
<Found Context="routeData">
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
</Found>
<NotFound>
<LayoutView Layout="@typeof(MainLayout)">
<p>Sorry, there's nothing at this address.</p>
</LayoutView>
</NotFound>
</Router>
20 changes: 20 additions & 0 deletions Templates/Basic/Client/Basic.Client.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<RazorLangVersion>3.0</RazorLangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="DotNetify.Blazor" Version="1.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="3.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Build" Version="3.2.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="3.2.0" PrivateAssets="all" />
<PackageReference Include="System.Net.Http.Json" Version="3.2.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Shared\Basic.Shared.csproj" />
</ItemGroup>

</Project>
19 changes: 19 additions & 0 deletions Templates/Basic/Client/Pages/Counter.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@page "/counter"

<h1>Counter</h1>

<VMContext VM="Counter" TState="ICounterState" OnStateChange="UpdateState">
<p>Current count: @state?.CurrentCount</p>

<button class="btn btn-primary" @onclick="() => state.IncrementCount()">Click me</button>
</VMContext>

@code {
private ICounterState state;

private void UpdateState(ICounterState state)
{
this.state = state;
StateHasChanged();
}
}
48 changes: 48 additions & 0 deletions Templates/Basic/Client/Pages/FetchData.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
@page "/fetchdata"
@using Basic.Shared
@inject HttpClient Http

<h1>Weather forecast</h1>

<p>This component demonstrates fetching data from the server.</p>

<VMContext VM="FetchData" TState="IFetchDataState" OnStateChange="UpdateState">
@if (state == 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 state.Forecasts)
{
<tr>
<td>@forecast.Date.ToShortDateString()</td>
<td>@forecast.TemperatureC</td>
<td>@forecast.TemperatureF</td>
<td>@forecast.Summary</td>
</tr>
}
</tbody>
</table>
}
</VMContext>

@code {
private IFetchDataState state;

private void UpdateState(IFetchDataState state)
{
this.state = state;
StateHasChanged();
}
}
29 changes: 29 additions & 0 deletions Templates/Basic/Client/Pages/HelloWorld.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
@page "/helloworld"

<VMContext VM="HelloWorld" TState="IHelloWorldState" OnStateChange="UpdateState">
@if (state != null)
{
<h1>@state.Greetings</h1>
<div>
<p>Server time is: <strong>@state.ServerTime</strong></p>
<p>Enter your name:</p>
<div style="display:flex">
<input type="text" class="form-control" placeholder="First name" @bind="person.FirstName" />
<input type="text" class="form-control" placeholder="Last name" @bind="person.LastName" />
<button class="btn btn-primary" @onclick="() => state.Submit(person)">Submit</button>
</div>

</div>
}
</VMContext>

@code {
private IHelloWorldState state;
private Person person = new Person();

private void UpdateState(IHelloWorldState state)
{
this.state = state;
StateHasChanged();
}
}
7 changes: 7 additions & 0 deletions Templates/Basic/Client/Pages/Index.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@page "/"

<h1>Hello, world!</h1>

Welcome to your new app.

<SurveyPrompt Title="How is Blazor working for you?" />
23 changes: 23 additions & 0 deletions Templates/Basic/Client/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System;
using System.Net.Http;
using System.Threading.Tasks;
using DotNetify.Blazor;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using Microsoft.Extensions.DependencyInjection;

namespace Basic.Client
{
public class Program
{
public static async Task Main(string[] args)
{
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("app");

builder.Services.AddDotNetifyBlazor(config => config.Debug = true);
builder.Services.AddTransient(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });

await builder.Build().RunAsync();
}
}
}
15 changes: 15 additions & 0 deletions Templates/Basic/Client/Shared/MainLayout.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@inherits LayoutComponentBase

<div class="sidebar">
<NavMenu />
</div>

<div class="main">
<div class="top-row px-4">
<a href="http://blazor.net" target="_blank" class="ml-md-auto">About</a>
</div>

<div class="content px-4">
@Body
</div>
</div>
42 changes: 42 additions & 0 deletions Templates/Basic/Client/Shared/NavMenu.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<div class="top-row pl-4 navbar navbar-dark">
<a class="navbar-brand" href="">Basic</a>
<button class="navbar-toggler" @onclick="ToggleNavMenu">
<span class="navbar-toggler-icon"></span>
</button>
</div>

<div class="@NavMenuCssClass" @onclick="ToggleNavMenu">
<ul class="nav flex-column">
<li class="nav-item px-3">
<NavLink class="nav-link" href="" Match="NavLinkMatch.All">
<span class="oi oi-home" aria-hidden="true"></span> Home
</NavLink>
</li>
<li class="nav-item px-3">
<NavLink class="nav-link" href="counter">
<span class="oi oi-plus" aria-hidden="true"></span> Counter
</NavLink>
</li>
<li class="nav-item px-3">
<NavLink class="nav-link" href="fetchdata">
<span class="oi oi-list-rich" aria-hidden="true"></span> Fetch data
</NavLink>
</li>
<li class="nav-item px-3">
<NavLink class="nav-link" href="helloworld">
<span class="oi oi-list-rich" aria-hidden="true"></span> Hello world
</NavLink>
</li>
</ul>
</div>

@code {
private bool collapseNavMenu = true;

private string NavMenuCssClass => collapseNavMenu ? "collapse" : null;

private void ToggleNavMenu()
{
collapseNavMenu = !collapseNavMenu;
}
}
16 changes: 16 additions & 0 deletions Templates/Basic/Client/Shared/SurveyPrompt.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<div class="alert alert-secondary mt-4" role="alert">
<span class="oi oi-pencil mr-2" aria-hidden="true"></span>
<strong>@Title</strong>

<span class="text-nowrap">
Please take our
<a target="_blank" class="font-weight-bold" href="https://go.microsoft.com/fwlink/?linkid=2127996">brief survey</a>
</span>
and tell us what you think.
</div>

@code {
// Demonstrates how a parent component can supply parameters
[Parameter]
public string Title { get; set; }
}
11 changes: 11 additions & 0 deletions Templates/Basic/Client/_Imports.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@using System.Net.Http
@using System.Net.Http.Json
@using Microsoft.AspNetCore.Components.Forms
@using Microsoft.AspNetCore.Components.Routing
@using Microsoft.AspNetCore.Components.Web
@using Microsoft.AspNetCore.Components.WebAssembly.Http
@using Microsoft.JSInterop
@using Basic.Client
@using Basic.Client.Shared
@using Basic.Shared
@using DotNetify.Blazor;
Loading

0 comments on commit 3cb5df2

Please sign in to comment.