Skip to content

Commit f303a55

Browse files
committed
Add skeleton to use components + prerendering
This adds the skeleton needed for components + prerendring development in the MVC sandbox. We don't currently have a sample app for quick and dirty testing.
1 parent a3c8bd1 commit f303a55

File tree

12 files changed

+236
-6
lines changed

12 files changed

+236
-6
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
<Router AppAssembly="@typeof(MvcSandbox.Startup).Assembly" FallbackComponent="@typeof(NotFound)" />
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
@using MvcSandbox.Components.Shared
2+
@layout MainLayout
3+
<h1>Not Found</h1>
4+
<h2>Sorry, nothing was found.</h2>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@page "/"
2+
<h3>Hi from components</h3>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@using MvcSandbox.Components.Shared
2+
@layout MainLayout
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
@using Microsoft.AspNetCore.Components.Layouts
2+
@inherits LayoutComponentBase
3+
4+
<div class="sidebar">
5+
<NavMenu />
6+
</div>
7+
8+
<div class="main">
9+
<div class="top-row px-4">
10+
<a href="https://docs.microsoft.com/en-us/aspnet/" target="_blank" class="ml-md-auto">About</a>
11+
</div>
12+
13+
<div class="content px-4">
14+
@Body
15+
</div>
16+
</div>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
@using Microsoft.AspNetCore.Components.Routing
2+
3+
<div class="top-row pl-4 navbar navbar-dark">
4+
<a class="navbar-brand" href="">MvcSandbox</a>
5+
<button class="navbar-toggler" onclick="@ToggleNavMenu">
6+
<span class="navbar-toggler-icon"></span>
7+
</button>
8+
</div>
9+
10+
<div class="@NavMenuCssClass" onclick="@ToggleNavMenu">
11+
<ul class="nav flex-column">
12+
<li class="nav-item px-3">
13+
<NavLink class="nav-link" href="" Match="NavLinkMatch.All">
14+
<span class="oi oi-home" aria-hidden="true"></span> Home
15+
</NavLink>
16+
</li>
17+
</ul>
18+
</div>
19+
20+
@functions {
21+
bool collapseNavMenu = true;
22+
23+
string NavMenuCssClass => collapseNavMenu ? "collapse" : null;
24+
25+
void ToggleNavMenu()
26+
{
27+
collapseNavMenu = !collapseNavMenu;
28+
}
29+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@namespace MvcSandbox.Components

src/Mvc/samples/MvcSandbox/MvcSandbox.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22

33
<PropertyGroup>
44
<TargetFramework>netcoreapp3.0</TargetFramework>
5+
<_RazorComponentInclude>Components\**\*.cshtml</_RazorComponentInclude>
56
</PropertyGroup>
67

78
<ItemGroup>
89
<Reference Include="Microsoft.AspNetCore.Mvc" />
910
<Reference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" />
1011
<Reference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" />
12+
<Reference Include="Microsoft.AspNetCore.Components.Server" />
1113
<Reference Include="Microsoft.AspNetCore.Diagnostics" />
1214
<Reference Include="Microsoft.AspNetCore.Server.IISIntegration" />
1315
<Reference Include="Microsoft.AspNetCore.Server.Kestrel" />
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
@page
2+
@model MvcSandbox.Pages.ComponentsModel
3+
@{
4+
Layout = null;
5+
}
6+
7+
<!DOCTYPE html>
8+
<html>
9+
<head>
10+
<meta charset="utf-8" />
11+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
12+
<title>MvcSandbox - Components</title>
13+
<base href="~/" />
14+
<link rel="stylesheet" href="https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.5/css/bootstrap.min.css" />
15+
<link href="css/site.css" rel="stylesheet" />
16+
</head>
17+
<body>
18+
<app>@(await Html.RenderComponentAsync<MvcSandbox.Components.App>())</app>
19+
20+
<script src="_framework/components.server.js"></script>
21+
</body>
22+
</html>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
using Microsoft.AspNetCore.Mvc;
6+
using Microsoft.AspNetCore.Mvc.RazorPages;
7+
8+
namespace MvcSandbox.Pages
9+
{
10+
public class ComponentsModel : PageModel
11+
{
12+
public void OnGet()
13+
{
14+
}
15+
}
16+
}

0 commit comments

Comments
 (0)