Skip to content

Update templates to use scoped CSS #35658

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/ProjectTemplates/Shared/AspNetProcess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,10 @@ public async Task ContainsLinks(Page page)
foreach (IHtmlLinkElement styleSheet in html.GetElementsByTagName("link"))
{
Assert.Equal("stylesheet", styleSheet.Relation);
await AssertOk(styleSheet.Href.Replace("about://", string.Empty));
// Workaround for https://github.com/dotnet/aspnetcore/issues/31030#issuecomment-811334450
// Cleans up incorrectly generated filename for scoped CSS files
var styleSheetHref = styleSheet.Href.Replace("_", string.Empty).Replace("about://", string.Empty);
await AssertOk(styleSheetHref);
}
foreach (var script in html.Scripts)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<title>@ViewData["Title"] - Company.WebApplication1</title>
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
<link rel="stylesheet" href="~/Company.WebApplication1.styles.css" asp-append-version="true" />
</head>
<body>
<header>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification
for details on configuring this project to bundle and minify static web assets. */

a.navbar-brand {
white-space: normal;
text-align: center;
word-break: break-all;
}

a {
color: #0077cc;
}

.btn-primary {
color: #fff;
background-color: #1b6ec2;
border-color: #1861ac;
}

.nav-pills .nav-link.active, .nav-pills .show > .nav-link {
color: #fff;
background-color: #1b6ec2;
border-color: #1861ac;
}

.border-top {
border-top: 1px solid #e5e5e5;
}
.border-bottom {
border-bottom: 1px solid #e5e5e5;
}

.box-shadow {
box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05);
}

button.accept-policy {
font-size: 1rem;
line-height: inherit;
}

.footer {
position: absolute;
bottom: 0;
width: 100%;
white-space: nowrap;
line-height: 60px;
}
Original file line number Diff line number Diff line change
@@ -1,65 +1,18 @@
/* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification
for details on configuring this project to bundle and minify static web assets. */

a.navbar-brand {
white-space: normal;
text-align: center;
word-break: break-all;
}

a {
color: #0077cc;
}

.btn-primary {
color: #fff;
background-color: #1b6ec2;
border-color: #1861ac;
}

.nav-pills .nav-link.active, .nav-pills .show > .nav-link {
color: #fff;
background-color: #1b6ec2;
border-color: #1861ac;
}

html {
font-size: 14px;
}

@media (min-width: 768px) {
html {
font-size: 16px;
}
}

.border-top {
border-top: 1px solid #e5e5e5;
}
.border-bottom {
border-bottom: 1px solid #e5e5e5;
}

.box-shadow {
box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05);
}

button.accept-policy {
font-size: 1rem;
line-height: inherit;
}

html {
position: relative;
min-height: 100%;
}

body {
margin-bottom: 60px;
}
.footer {
position: absolute;
bottom: 0;
width: 100%;
white-space: nowrap;
line-height: 60px;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<title>@ViewData["Title"] - Company.WebApplication1</title>
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
<link rel="stylesheet" href="~/Company.WebApplication1.styles.css" asp-append-version="true" />
</head>
<body>
<header>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification
for details on configuring this project to bundle and minify static web assets. */

a.navbar-brand {
white-space: normal;
text-align: center;
word-break: break-all;
}

a {
color: #0077cc;
}

.btn-primary {
color: #fff;
background-color: #1b6ec2;
border-color: #1861ac;
}

.nav-pills .nav-link.active, .nav-pills .show > .nav-link {
color: #fff;
background-color: #1b6ec2;
border-color: #1861ac;
}

.border-top {
border-top: 1px solid #e5e5e5;
}
.border-bottom {
border-bottom: 1px solid #e5e5e5;
}

.box-shadow {
box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05);
}

button.accept-policy {
font-size: 1rem;
line-height: inherit;
}

.footer {
position: absolute;
bottom: 0;
width: 100%;
white-space: nowrap;
line-height: 60px;
}
Original file line number Diff line number Diff line change
@@ -1,65 +1,18 @@
/* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification
for details on configuring this project to bundle and minify static web assets. */

a.navbar-brand {
white-space: normal;
text-align: center;
word-break: break-all;
}

a {
color: #0077cc;
}

.btn-primary {
color: #fff;
background-color: #1b6ec2;
border-color: #1861ac;
}

.nav-pills .nav-link.active, .nav-pills .show > .nav-link {
color: #fff;
background-color: #1b6ec2;
border-color: #1861ac;
}

html {
font-size: 14px;
}

@media (min-width: 768px) {
html {
font-size: 16px;
}
}

.border-top {
border-top: 1px solid #e5e5e5;
}
.border-bottom {
border-bottom: 1px solid #e5e5e5;
}

.box-shadow {
box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05);
}

button.accept-policy {
font-size: 1rem;
line-height: inherit;
}

html {
position: relative;
min-height: 100%;
}

body {
margin-bottom: 60px;
}
.footer {
position: absolute;
bottom: 0;
width: 100%;
white-space: nowrap;
line-height: 60px;
}
}
12 changes: 12 additions & 0 deletions src/ProjectTemplates/test/template-baselines.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"Pages/_ViewImports.cshtml",
"Pages/_ViewStart.cshtml",
"Pages/Shared/_Layout.cshtml",
"Pages/Shared/_Layout.cshtml.css",
"Pages/Shared/_LoginPartial.cshtml",
"Pages/Shared/_ValidationScriptsPartial.cshtml",
"Properties/launchSettings.json",
Expand Down Expand Up @@ -104,6 +105,7 @@
"Pages/_ViewImports.cshtml",
"Pages/_ViewStart.cshtml",
"Pages/Shared/_Layout.cshtml",
"Pages/Shared/_Layout.cshtml.css",
"Pages/Shared/_ValidationScriptsPartial.cshtml",
"Properties/launchSettings.json",
"wwwroot/favicon.ico",
Expand Down Expand Up @@ -185,6 +187,7 @@
"Pages/_ViewImports.cshtml",
"Pages/_ViewStart.cshtml",
"Pages/Shared/_Layout.cshtml",
"Pages/Shared/_Layout.cshtml.css",
"Pages/Shared/_LoginPartial.cshtml",
"Pages/Shared/_ValidationScriptsPartial.cshtml",
"Properties/launchSettings.json",
Expand Down Expand Up @@ -267,6 +270,7 @@
"Pages/_ViewImports.cshtml",
"Pages/_ViewStart.cshtml",
"Pages/Shared/_Layout.cshtml",
"Pages/Shared/_Layout.cshtml.css",
"Pages/Shared/_LoginPartial.cshtml",
"Pages/Shared/_ValidationScriptsPartial.cshtml",
"Properties/launchSettings.json",
Expand Down Expand Up @@ -349,6 +353,7 @@
"Pages/_ViewImports.cshtml",
"Pages/_ViewStart.cshtml",
"Pages/Shared/_Layout.cshtml",
"Pages/Shared/_Layout.cshtml.css",
"Pages/Shared/_ValidationScriptsPartial.cshtml",
"Properties/launchSettings.json",
"wwwroot/favicon.ico",
Expand Down Expand Up @@ -430,6 +435,7 @@
"Pages/_ViewImports.cshtml",
"Pages/_ViewStart.cshtml",
"Pages/Shared/_Layout.cshtml",
"Pages/Shared/_Layout.cshtml.css",
"Pages/Shared/_LoginPartial.cshtml",
"Pages/Shared/_ValidationScriptsPartial.cshtml",
"Properties/launchSettings.json",
Expand Down Expand Up @@ -611,6 +617,7 @@
"Views/Home/Privacy.cshtml",
"Views/Shared/Error.cshtml",
"Views/Shared/_Layout.cshtml",
"Views/Shared/_Layout.cshtml.css",
"Views/Shared/_LoginPartial.cshtml",
"Views/Shared/_ValidationScriptsPartial.cshtml",
"wwwroot/favicon.ico",
Expand Down Expand Up @@ -692,6 +699,7 @@
"Views/Home/Privacy.cshtml",
"Views/Shared/Error.cshtml",
"Views/Shared/_Layout.cshtml",
"Views/Shared/_Layout.cshtml.css",
"Views/Shared/_ValidationScriptsPartial.cshtml",
"wwwroot/favicon.ico",
"wwwroot/css/site.css",
Expand Down Expand Up @@ -772,6 +780,7 @@
"Views/Home/Privacy.cshtml",
"Views/Shared/Error.cshtml",
"Views/Shared/_Layout.cshtml",
"Views/Shared/_Layout.cshtml.css",
"Views/Shared/_LoginPartial.cshtml",
"Views/Shared/_ValidationScriptsPartial.cshtml",
"wwwroot/favicon.ico",
Expand Down Expand Up @@ -853,6 +862,7 @@
"Views/Home/Privacy.cshtml",
"Views/Shared/Error.cshtml",
"Views/Shared/_Layout.cshtml",
"Views/Shared/_Layout.cshtml.css",
"Views/Shared/_LoginPartial.cshtml",
"Views/Shared/_ValidationScriptsPartial.cshtml",
"wwwroot/favicon.ico",
Expand Down Expand Up @@ -934,6 +944,7 @@
"Views/Home/Privacy.cshtml",
"Views/Shared/Error.cshtml",
"Views/Shared/_Layout.cshtml",
"Views/Shared/_Layout.cshtml.css",
"Views/Shared/_ValidationScriptsPartial.cshtml",
"wwwroot/favicon.ico",
"wwwroot/css/site.css",
Expand Down Expand Up @@ -1014,6 +1025,7 @@
"Views/Home/Privacy.cshtml",
"Views/Shared/Error.cshtml",
"Views/Shared/_Layout.cshtml",
"Views/Shared/_Layout.cshtml.css",
"Views/Shared/_LoginPartial.cshtml",
"Views/Shared/_ValidationScriptsPartial.cshtml",
"wwwroot/favicon.ico",
Expand Down