Skip to content
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

Fix generated CSS scopes in layout views and update templates #31257

Merged
4 commits merged into from
Mar 30, 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
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" />
<link rel="stylesheet" href="~/Company.WebApplication1.styles.css" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is interesting. In the Blazor templates, we still have the global CSS files as well as the scoped ones. I see that you've been able to make the global one unnecessary here. Is it possible that developers will still want to have a global non-scoped CSS file too?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call!

I've brought back the non-scoped CSS file and moved the html/body style to it. This will help indicate to developers that non-scoped CSS files are still sensible to use in some scenarios.

</head>
<body>
<header>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/* 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;
}

/* Provide sufficient contrast against white background */
a {
color: #0366d6;
}

.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;
}

/* Sticky footer styles
-------------------------------------------------- */
.footer {
position: absolute;
bottom: 0;
width: 100%;
white-space: nowrap;
line-height: 60px; /* Vertically center the text there */
}
Original file line number Diff line number Diff line change
@@ -1,71 +1,21 @@
/* 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;
}

/* Provide sufficient contrast against white background */
a {
color: #0366d6;
}

.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;
}

/* Sticky footer styles
-------------------------------------------------- */
html {
font-size: 14px;
}
@media (min-width: 768px) {
font-size: 14px;
}
@media (min-width: 768px) {
html {
font-size: 16px;
}
}

/* Sticky footer styles
-------------------------------------------------- */
html {
font-size: 16px;
position: relative;
min-height: 100%;
}
}

.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;
}

/* Sticky footer styles
-------------------------------------------------- */
html {
position: relative;
min-height: 100%;
}

body {
/* Margin bottom by footer height */
margin-bottom: 60px;
}
.footer {
position: absolute;
bottom: 0;
width: 100%;
white-space: nowrap;
line-height: 60px; /* Vertically center the text there */
}

body {
/* Margin bottom by footer height */
margin-bottom: 60px;
}

Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
<link rel="stylesheet" href="~/css/site.css" />
<link rel="stylesheet" href="~/Company.WebApplication1.css" />
</head>
<body>
<header>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/* 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;
}

/* Provide sufficient contrast against white background */
a {
color: #0366d6;
}

.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;
}

/* Sticky footer styles
-------------------------------------------------- */
.footer {
position: absolute;
bottom: 0;
width: 100%;
white-space: nowrap;
line-height: 60px; /* Vertically center the text there */
}

Original file line number Diff line number Diff line change
@@ -1,71 +1,21 @@
/* 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;
}

/* Provide sufficient contrast against white background */
a {
color: #0366d6;
}

.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;
}

/* Sticky footer styles
-------------------------------------------------- */
html {
font-size: 14px;
}
@media (min-width: 768px) {
font-size: 14px;
}
@media (min-width: 768px) {
html {
font-size: 16px;
}
}

/* Sticky footer styles
-------------------------------------------------- */
html {
font-size: 16px;
position: relative;
min-height: 100%;
}
}

.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;
}

/* Sticky footer styles
-------------------------------------------------- */
html {
position: relative;
min-height: 100%;
}

body {
/* Margin bottom by footer height */
margin-bottom: 60px;
}
.footer {
position: absolute;
bottom: 0;
width: 100%;
white-space: nowrap;
line-height: 60px; /* Vertically center the text there */
}

body {
/* Margin bottom by footer height */
margin-bottom: 60px;
}

6 changes: 6 additions & 0 deletions src/ProjectTemplates/test/MvcTemplateTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ public ITestOutputHelper Output

private async Task MvcTemplateCore(string languageOverride)
{
// Additional arguments are needed. See: https://github.com/dotnet/aspnetcore/issues/24278
Environment.SetEnvironmentVariable("EnableDefaultScopedCssItems", "true");

var project = await ProjectFactory.GetOrCreateProject("mvcnoauth" + (languageOverride == "F#" ? "fsharp" : "csharp"), Output);

var createResult = await project.RunDotNetNewAsync("mvc", language: languageOverride);
Expand Down Expand Up @@ -121,6 +124,9 @@ private async Task MvcTemplateCore(string languageOverride)
[SkipOnHelix("Cert failure, https://github.com/dotnet/aspnetcore/issues/28090", Queues = "All.OSX;" + HelixConstants.Windows10Arm64 + HelixConstants.DebianArm64)]
public async Task MvcTemplate_IndividualAuth(bool useLocalDB)
{
// Additional arguments are needed. See: https://github.com/dotnet/aspnetcore/issues/24278
Environment.SetEnvironmentVariable("EnableDefaultScopedCssItems", "true");

var project = await ProjectFactory.GetOrCreateProject("mvcindividual" + (useLocalDB ? "uld" : ""), Output);

var createResult = await project.RunDotNetNewAsync("mvc", auth: "Individual", useLocalDB: useLocalDB);
Expand Down
7 changes: 7 additions & 0 deletions src/ProjectTemplates/test/template-baselines.json
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,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 @@ -542,6 +543,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 @@ -599,6 +601,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 @@ -657,6 +660,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 @@ -715,6 +719,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 +777,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 @@ -830,6 +836,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
Loading