Skip to content

Commit 4dfccff

Browse files
committed
Init
1 parent c26db03 commit 4dfccff

24 files changed

+1210
-0
lines changed

App.razor

+10
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>

BlazorDemo.csproj

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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="Microsoft.AspNetCore.Blazor" Version="3.2.0-preview1.20073.1" />
10+
<PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="3.2.0-preview1.20073.1" PrivateAssets="all" />
11+
<PackageReference Include="Microsoft.AspNetCore.Blazor.DevServer" Version="3.2.0-preview1.20073.1" PrivateAssets="all" />
12+
<PackageReference Include="Microsoft.AspNetCore.Blazor.HttpClient" Version="3.2.0-preview1.20073.1" />
13+
</ItemGroup>
14+
15+
</Project>

Pages/Counter.razor

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
@page "/counter"
2+
3+
<h1>Counter</h1>
4+
5+
<p>Current count: @currentCount</p>
6+
7+
<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>
8+
9+
@code {
10+
private int currentCount = 0;
11+
12+
private void IncrementCount()
13+
{
14+
currentCount++;
15+
}
16+
}

Pages/FetchData.razor

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
@page "/fetchdata"
2+
@inject HttpClient Http
3+
4+
<h1>Weather forecast</h1>
5+
6+
<p>This component demonstrates fetching data from the server.</p>
7+
8+
@if (forecasts == null)
9+
{
10+
<p><em>Loading...</em></p>
11+
}
12+
else
13+
{
14+
<table class="table">
15+
<thead>
16+
<tr>
17+
<th>Date</th>
18+
<th>Temp. (C)</th>
19+
<th>Temp. (F)</th>
20+
<th>Summary</th>
21+
</tr>
22+
</thead>
23+
<tbody>
24+
@foreach (var forecast in forecasts)
25+
{
26+
<tr>
27+
<td>@forecast.Date.ToShortDateString()</td>
28+
<td>@forecast.TemperatureC</td>
29+
<td>@forecast.TemperatureF</td>
30+
<td>@forecast.Summary</td>
31+
</tr>
32+
}
33+
</tbody>
34+
</table>
35+
}
36+
37+
@code {
38+
private WeatherForecast[] forecasts;
39+
40+
protected override async Task OnInitializedAsync()
41+
{
42+
forecasts = await Http.GetJsonAsync<WeatherForecast[]>("sample-data/weather.json");
43+
}
44+
45+
public class WeatherForecast
46+
{
47+
public DateTime Date { get; set; }
48+
49+
public int TemperatureC { get; set; }
50+
51+
public string Summary { get; set; }
52+
53+
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
54+
}
55+
}

Pages/Index.razor

+7
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?" />

Program.cs

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Threading.Tasks;
4+
using System.Text;
5+
using Microsoft.AspNetCore.Blazor.Hosting;
6+
using Microsoft.Extensions.DependencyInjection;
7+
8+
namespace BlazorDemo
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+
await builder.Build().RunAsync();
18+
}
19+
}
20+
}

Shared/MainLayout.razor

+15
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>

Shared/NavMenu.razor

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<div class="top-row pl-4 navbar navbar-dark">
2+
<a class="navbar-brand" href="">BlazorDemo</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+
</ul>
26+
</div>
27+
28+
@code {
29+
private bool collapseNavMenu = true;
30+
31+
private string NavMenuCssClass => collapseNavMenu ? "collapse" : null;
32+
33+
private void ToggleNavMenu()
34+
{
35+
collapseNavMenu = !collapseNavMenu;
36+
}
37+
}

Shared/SurveyPrompt.razor

+16
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=2116045">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+
}

_Imports.razor

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
@using System.Net.Http
2+
@using Microsoft.AspNetCore.Components.Forms
3+
@using Microsoft.AspNetCore.Components.Routing
4+
@using Microsoft.AspNetCore.Components.Web
5+
@using Microsoft.JSInterop
6+
@using BlazorDemo
7+
@using BlazorDemo.Shared

wwwroot/css/bootstrap/bootstrap.min.css

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

wwwroot/css/bootstrap/bootstrap.min.css.map

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

wwwroot/css/open-iconic/FONT-LICENSE

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
SIL OPEN FONT LICENSE Version 1.1
2+
3+
Copyright (c) 2014 Waybury
4+
5+
PREAMBLE
6+
The goals of the Open Font License (OFL) are to stimulate worldwide
7+
development of collaborative font projects, to support the font creation
8+
efforts of academic and linguistic communities, and to provide a free and
9+
open framework in which fonts may be shared and improved in partnership
10+
with others.
11+
12+
The OFL allows the licensed fonts to be used, studied, modified and
13+
redistributed freely as long as they are not sold by themselves. The
14+
fonts, including any derivative works, can be bundled, embedded,
15+
redistributed and/or sold with any software provided that any reserved
16+
names are not used by derivative works. The fonts and derivatives,
17+
however, cannot be released under any other type of license. The
18+
requirement for fonts to remain under this license does not apply
19+
to any document created using the fonts or their derivatives.
20+
21+
DEFINITIONS
22+
"Font Software" refers to the set of files released by the Copyright
23+
Holder(s) under this license and clearly marked as such. This may
24+
include source files, build scripts and documentation.
25+
26+
"Reserved Font Name" refers to any names specified as such after the
27+
copyright statement(s).
28+
29+
"Original Version" refers to the collection of Font Software components as
30+
distributed by the Copyright Holder(s).
31+
32+
"Modified Version" refers to any derivative made by adding to, deleting,
33+
or substituting -- in part or in whole -- any of the components of the
34+
Original Version, by changing formats or by porting the Font Software to a
35+
new environment.
36+
37+
"Author" refers to any designer, engineer, programmer, technical
38+
writer or other person who contributed to the Font Software.
39+
40+
PERMISSION & CONDITIONS
41+
Permission is hereby granted, free of charge, to any person obtaining
42+
a copy of the Font Software, to use, study, copy, merge, embed, modify,
43+
redistribute, and sell modified and unmodified copies of the Font
44+
Software, subject to the following conditions:
45+
46+
1) Neither the Font Software nor any of its individual components,
47+
in Original or Modified Versions, may be sold by itself.
48+
49+
2) Original or Modified Versions of the Font Software may be bundled,
50+
redistributed and/or sold with any software, provided that each copy
51+
contains the above copyright notice and this license. These can be
52+
included either as stand-alone text files, human-readable headers or
53+
in the appropriate machine-readable metadata fields within text or
54+
binary files as long as those fields can be easily viewed by the user.
55+
56+
3) No Modified Version of the Font Software may use the Reserved Font
57+
Name(s) unless explicit written permission is granted by the corresponding
58+
Copyright Holder. This restriction only applies to the primary font name as
59+
presented to the users.
60+
61+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
62+
Software shall not be used to promote, endorse or advertise any
63+
Modified Version, except to acknowledge the contribution(s) of the
64+
Copyright Holder(s) and the Author(s) or with their explicit written
65+
permission.
66+
67+
5) The Font Software, modified or unmodified, in part or in whole,
68+
must be distributed entirely under this license, and must not be
69+
distributed under any other license. The requirement for fonts to
70+
remain under this license does not apply to any document created
71+
using the Font Software.
72+
73+
TERMINATION
74+
This license becomes null and void if any of the above conditions are
75+
not met.
76+
77+
DISCLAIMER
78+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
79+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
80+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
81+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
82+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
83+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
84+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
85+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
86+
OTHER DEALINGS IN THE FONT SOFTWARE.

wwwroot/css/open-iconic/ICON-LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2014 Waybury
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

0 commit comments

Comments
 (0)