-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
Showing
12 changed files
with
236 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
<Router AppAssembly="@typeof(MvcSandbox.Startup).Assembly" FallbackComponent="@typeof(NotFound)" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
@using MvcSandbox.Components.Shared | ||
@layout MainLayout | ||
<h1>Not Found</h1> | ||
<h2>Sorry, nothing was found.</h2> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
@page "/" | ||
<h3>Hi from components</h3> |
2 changes: 2 additions & 0 deletions
2
src/Mvc/samples/MvcSandbox/Components/Pages/_ViewImports.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
@using MvcSandbox.Components.Shared | ||
@layout MainLayout |
16 changes: 16 additions & 0 deletions
16
src/Mvc/samples/MvcSandbox/Components/Shared/MainLayout.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
@using Microsoft.AspNetCore.Components.Layouts | ||
@inherits LayoutComponentBase | ||
|
||
<div class="sidebar"> | ||
<NavMenu /> | ||
</div> | ||
|
||
<div class="main"> | ||
<div class="top-row px-4"> | ||
<a href="https://docs.microsoft.com/en-us/aspnet/" target="_blank" class="ml-md-auto">About</a> | ||
</div> | ||
|
||
<div class="content px-4"> | ||
@Body | ||
</div> | ||
</div> |
29 changes: 29 additions & 0 deletions
29
src/Mvc/samples/MvcSandbox/Components/Shared/NavMenu.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
@using Microsoft.AspNetCore.Components.Routing | ||
|
||
<div class="top-row pl-4 navbar navbar-dark"> | ||
<a class="navbar-brand" href="">MvcSandbox</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> | ||
</ul> | ||
</div> | ||
|
||
@functions { | ||
bool collapseNavMenu = true; | ||
|
||
string NavMenuCssClass => collapseNavMenu ? "collapse" : null; | ||
|
||
void ToggleNavMenu() | ||
{ | ||
collapseNavMenu = !collapseNavMenu; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
@namespace MvcSandbox.Components |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
@page | ||
@model MvcSandbox.Pages.ComponentsModel | ||
@{ | ||
Layout = null; | ||
} | ||
|
||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>MvcSandbox - Components</title> | ||
<base href="~/" /> | ||
<link rel="stylesheet" href="https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.5/css/bootstrap.min.css" /> | ||
<link href="css/site.css" rel="stylesheet" /> | ||
</head> | ||
<body> | ||
<app>@(await Html.RenderComponentAsync<MvcSandbox.Components.App>())</app> | ||
|
||
<script src="_framework/components.server.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.AspNetCore.Mvc.RazorPages; | ||
|
||
namespace MvcSandbox.Pages | ||
{ | ||
public class ComponentsModel : PageModel | ||
{ | ||
public void OnGet() | ||
{ | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
html, body { | ||
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; | ||
} | ||
|
||
app { | ||
position: relative; | ||
display: flex; | ||
flex-direction: column; | ||
} | ||
|
||
.top-row { | ||
height: 3.5rem; | ||
display: flex; | ||
align-items: center; | ||
} | ||
|
||
.main { | ||
flex: 1; | ||
} | ||
|
||
.main .top-row { | ||
background-color: #e6e6e6; | ||
border-bottom: 1px solid #d6d5d5; | ||
} | ||
|
||
.sidebar { | ||
background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%); | ||
} | ||
|
||
.sidebar .top-row { | ||
background-color: rgba(0,0,0,0.4); | ||
} | ||
|
||
.sidebar .navbar-brand { | ||
font-size: 1.1rem; | ||
} | ||
|
||
.sidebar .oi { | ||
width: 2rem; | ||
font-size: 1.1rem; | ||
vertical-align: text-top; | ||
top: -2px; | ||
} | ||
|
||
.nav-item { | ||
font-size: 0.9rem; | ||
padding-bottom: 0.5rem; | ||
} | ||
|
||
.nav-item:first-of-type { | ||
padding-top: 1rem; | ||
} | ||
|
||
.nav-item:last-of-type { | ||
padding-bottom: 1rem; | ||
} | ||
|
||
.nav-item a { | ||
color: #d7d7d7; | ||
border-radius: 4px; | ||
height: 3rem; | ||
display: flex; | ||
align-items: center; | ||
line-height: 3rem; | ||
} | ||
|
||
.nav-item a.active { | ||
background-color: rgba(255,255,255,0.25); | ||
color: white; | ||
} | ||
|
||
.nav-item a:hover { | ||
background-color: rgba(255,255,255,0.1); | ||
color: white; | ||
} | ||
|
||
.content { | ||
padding-top: 1.1rem; | ||
} | ||
|
||
.navbar-toggler { | ||
background-color: rgba(255, 255, 255, 0.1); | ||
} | ||
|
||
.valid.modified:not([type=checkbox]) { | ||
outline: 1px solid #26b050; | ||
} | ||
|
||
.invalid { | ||
outline: 1px solid red; | ||
} | ||
|
||
.validation-message { | ||
color: red; | ||
} | ||
|
||
@media (max-width: 767.98px) { | ||
.main .top-row { | ||
display: none; | ||
} | ||
} | ||
|
||
@media (min-width: 768px) { | ||
app { | ||
flex-direction: row; | ||
} | ||
|
||
.sidebar { | ||
width: 250px; | ||
height: 100vh; | ||
position: sticky; | ||
top: 0; | ||
} | ||
|
||
.main .top-row { | ||
position: sticky; | ||
top: 0; | ||
} | ||
|
||
.main > div { | ||
padding-left: 2rem !important; | ||
padding-right: 1.5rem !important; | ||
} | ||
|
||
.navbar-toggler { | ||
display: none; | ||
} | ||
|
||
.sidebar .collapse { | ||
/* Never collapse the sidebar for wide screens */ | ||
display: block; | ||
} | ||
} |