Skip to content

Commit f45fc3e

Browse files
authored
Fix generated CSS scopes in layout views and update templates (#31257)
* Fix generated CSS scopes in layout views and update templates * Update template baselines * Enabled scoped CSS for MVC template tests * Bring back static CSS file
1 parent f32b525 commit f45fc3e

File tree

12 files changed

+307
-137
lines changed

12 files changed

+307
-137
lines changed

src/ProjectTemplates/Web.ProjectTemplates/content/StarterWeb-CSharp/Views/Shared/_Layout.cshtml

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<title>@ViewData["Title"] - Company.WebApplication1</title>
77
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
88
<link rel="stylesheet" href="~/css/site.css" />
9+
<link rel="stylesheet" href="~/Company.WebApplication1.styles.css" />
910
</head>
1011
<body>
1112
<header>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification
2+
for details on configuring this project to bundle and minify static web assets. */
3+
4+
a.navbar-brand {
5+
white-space: normal;
6+
text-align: center;
7+
word-break: break-all;
8+
}
9+
10+
/* Provide sufficient contrast against white background */
11+
a {
12+
color: #0366d6;
13+
}
14+
15+
.btn-primary {
16+
color: #fff;
17+
background-color: #1b6ec2;
18+
border-color: #1861ac;
19+
}
20+
21+
.nav-pills .nav-link.active, .nav-pills .show > .nav-link {
22+
color: #fff;
23+
background-color: #1b6ec2;
24+
border-color: #1861ac;
25+
}
26+
27+
.border-top {
28+
border-top: 1px solid #e5e5e5;
29+
}
30+
.border-bottom {
31+
border-bottom: 1px solid #e5e5e5;
32+
}
33+
34+
.box-shadow {
35+
box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05);
36+
}
37+
38+
button.accept-policy {
39+
font-size: 1rem;
40+
line-height: inherit;
41+
}
42+
43+
/* Sticky footer styles
44+
-------------------------------------------------- */
45+
.footer {
46+
position: absolute;
47+
bottom: 0;
48+
width: 100%;
49+
white-space: nowrap;
50+
line-height: 60px; /* Vertically center the text there */
51+
}
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,21 @@
1-
/* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification
2-
for details on configuring this project to bundle and minify static web assets. */
3-
4-
a.navbar-brand {
5-
white-space: normal;
6-
text-align: center;
7-
word-break: break-all;
8-
}
9-
10-
/* Provide sufficient contrast against white background */
11-
a {
12-
color: #0366d6;
13-
}
14-
15-
.btn-primary {
16-
color: #fff;
17-
background-color: #1b6ec2;
18-
border-color: #1861ac;
19-
}
20-
21-
.nav-pills .nav-link.active, .nav-pills .show > .nav-link {
22-
color: #fff;
23-
background-color: #1b6ec2;
24-
border-color: #1861ac;
25-
}
26-
27-
/* Sticky footer styles
28-
-------------------------------------------------- */
291
html {
30-
font-size: 14px;
31-
}
32-
@media (min-width: 768px) {
2+
font-size: 14px;
3+
}
4+
@media (min-width: 768px) {
5+
html {
6+
font-size: 16px;
7+
}
8+
}
9+
10+
/* Sticky footer styles
11+
-------------------------------------------------- */
3312
html {
34-
font-size: 16px;
13+
position: relative;
14+
min-height: 100%;
3515
}
36-
}
37-
38-
.border-top {
39-
border-top: 1px solid #e5e5e5;
40-
}
41-
.border-bottom {
42-
border-bottom: 1px solid #e5e5e5;
43-
}
44-
45-
.box-shadow {
46-
box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05);
47-
}
48-
49-
button.accept-policy {
50-
font-size: 1rem;
51-
line-height: inherit;
52-
}
53-
54-
/* Sticky footer styles
55-
-------------------------------------------------- */
56-
html {
57-
position: relative;
58-
min-height: 100%;
59-
}
60-
61-
body {
62-
/* Margin bottom by footer height */
63-
margin-bottom: 60px;
64-
}
65-
.footer {
66-
position: absolute;
67-
bottom: 0;
68-
width: 100%;
69-
white-space: nowrap;
70-
line-height: 60px; /* Vertically center the text there */
71-
}
16+
17+
body {
18+
/* Margin bottom by footer height */
19+
margin-bottom: 60px;
20+
}
21+

src/ProjectTemplates/Web.ProjectTemplates/content/StarterWeb-FSharp/Views/Shared/_Layout.cshtml

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
99
<link rel="stylesheet" href="~/css/site.css" />
10+
<link rel="stylesheet" href="~/Company.WebApplication1.css" />
1011
</head>
1112
<body>
1213
<header>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification
2+
for details on configuring this project to bundle and minify static web assets. */
3+
4+
a.navbar-brand {
5+
white-space: normal;
6+
text-align: center;
7+
word-break: break-all;
8+
}
9+
10+
/* Provide sufficient contrast against white background */
11+
a {
12+
color: #0366d6;
13+
}
14+
15+
.btn-primary {
16+
color: #fff;
17+
background-color: #1b6ec2;
18+
border-color: #1861ac;
19+
}
20+
21+
.nav-pills .nav-link.active, .nav-pills .show > .nav-link {
22+
color: #fff;
23+
background-color: #1b6ec2;
24+
border-color: #1861ac;
25+
}
26+
27+
.border-top {
28+
border-top: 1px solid #e5e5e5;
29+
}
30+
.border-bottom {
31+
border-bottom: 1px solid #e5e5e5;
32+
}
33+
34+
.box-shadow {
35+
box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05);
36+
}
37+
38+
button.accept-policy {
39+
font-size: 1rem;
40+
line-height: inherit;
41+
}
42+
43+
/* Sticky footer styles
44+
-------------------------------------------------- */
45+
.footer {
46+
position: absolute;
47+
bottom: 0;
48+
width: 100%;
49+
white-space: nowrap;
50+
line-height: 60px; /* Vertically center the text there */
51+
}
52+
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,21 @@
1-
/* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification
2-
for details on configuring this project to bundle and minify static web assets. */
3-
4-
a.navbar-brand {
5-
white-space: normal;
6-
text-align: center;
7-
word-break: break-all;
8-
}
9-
10-
/* Provide sufficient contrast against white background */
11-
a {
12-
color: #0366d6;
13-
}
14-
15-
.btn-primary {
16-
color: #fff;
17-
background-color: #1b6ec2;
18-
border-color: #1861ac;
19-
}
20-
21-
.nav-pills .nav-link.active, .nav-pills .show > .nav-link {
22-
color: #fff;
23-
background-color: #1b6ec2;
24-
border-color: #1861ac;
25-
}
26-
27-
/* Sticky footer styles
28-
-------------------------------------------------- */
291
html {
30-
font-size: 14px;
31-
}
32-
@media (min-width: 768px) {
2+
font-size: 14px;
3+
}
4+
@media (min-width: 768px) {
5+
html {
6+
font-size: 16px;
7+
}
8+
}
9+
10+
/* Sticky footer styles
11+
-------------------------------------------------- */
3312
html {
34-
font-size: 16px;
13+
position: relative;
14+
min-height: 100%;
3515
}
36-
}
37-
38-
.border-top {
39-
border-top: 1px solid #e5e5e5;
40-
}
41-
.border-bottom {
42-
border-bottom: 1px solid #e5e5e5;
43-
}
44-
45-
.box-shadow {
46-
box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05);
47-
}
48-
49-
button.accept-policy {
50-
font-size: 1rem;
51-
line-height: inherit;
52-
}
53-
54-
/* Sticky footer styles
55-
-------------------------------------------------- */
56-
html {
57-
position: relative;
58-
min-height: 100%;
59-
}
60-
61-
body {
62-
/* Margin bottom by footer height */
63-
margin-bottom: 60px;
64-
}
65-
.footer {
66-
position: absolute;
67-
bottom: 0;
68-
width: 100%;
69-
white-space: nowrap;
70-
line-height: 60px; /* Vertically center the text there */
71-
}
16+
17+
body {
18+
/* Margin bottom by footer height */
19+
margin-bottom: 60px;
20+
}
21+

src/ProjectTemplates/test/MvcTemplateTest.cs

+6
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ public ITestOutputHelper Output
4545

4646
private async Task MvcTemplateCore(string languageOverride)
4747
{
48+
// Additional arguments are needed. See: https://github.com/dotnet/aspnetcore/issues/24278
49+
Environment.SetEnvironmentVariable("EnableDefaultScopedCssItems", "true");
50+
4851
var project = await ProjectFactory.GetOrCreateProject("mvcnoauth" + (languageOverride == "F#" ? "fsharp" : "csharp"), Output);
4952

5053
var createResult = await project.RunDotNetNewAsync("mvc", language: languageOverride);
@@ -121,6 +124,9 @@ private async Task MvcTemplateCore(string languageOverride)
121124
[SkipOnHelix("Cert failure, https://github.com/dotnet/aspnetcore/issues/28090", Queues = "All.OSX;" + HelixConstants.Windows10Arm64 + HelixConstants.DebianArm64)]
122125
public async Task MvcTemplate_IndividualAuth(bool useLocalDB)
123126
{
127+
// Additional arguments are needed. See: https://github.com/dotnet/aspnetcore/issues/24278
128+
Environment.SetEnvironmentVariable("EnableDefaultScopedCssItems", "true");
129+
124130
var project = await ProjectFactory.GetOrCreateProject("mvcindividual" + (useLocalDB ? "uld" : ""), Output);
125131

126132
var createResult = await project.RunDotNetNewAsync("mvc", auth: "Individual", useLocalDB: useLocalDB);

src/ProjectTemplates/test/template-baselines.json

+7
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,7 @@
484484
"Views/Home/Privacy.cshtml",
485485
"Views/Shared/Error.cshtml",
486486
"Views/Shared/_Layout.cshtml",
487+
"Views/Shared/_Layout.cshtml.css",
487488
"Views/Shared/_LoginPartial.cshtml",
488489
"Views/Shared/_ValidationScriptsPartial.cshtml",
489490
"wwwroot/favicon.ico",
@@ -542,6 +543,7 @@
542543
"Views/Home/Privacy.cshtml",
543544
"Views/Shared/Error.cshtml",
544545
"Views/Shared/_Layout.cshtml",
546+
"Views/Shared/_Layout.cshtml.css",
545547
"Views/Shared/_ValidationScriptsPartial.cshtml",
546548
"wwwroot/favicon.ico",
547549
"wwwroot/css/site.css",
@@ -599,6 +601,7 @@
599601
"Views/Home/Privacy.cshtml",
600602
"Views/Shared/Error.cshtml",
601603
"Views/Shared/_Layout.cshtml",
604+
"Views/Shared/_Layout.cshtml.css",
602605
"Views/Shared/_LoginPartial.cshtml",
603606
"Views/Shared/_ValidationScriptsPartial.cshtml",
604607
"wwwroot/favicon.ico",
@@ -657,6 +660,7 @@
657660
"Views/Home/Privacy.cshtml",
658661
"Views/Shared/Error.cshtml",
659662
"Views/Shared/_Layout.cshtml",
663+
"Views/Shared/_Layout.cshtml.css",
660664
"Views/Shared/_LoginPartial.cshtml",
661665
"Views/Shared/_ValidationScriptsPartial.cshtml",
662666
"wwwroot/favicon.ico",
@@ -715,6 +719,7 @@
715719
"Views/Home/Privacy.cshtml",
716720
"Views/Shared/Error.cshtml",
717721
"Views/Shared/_Layout.cshtml",
722+
"Views/Shared/_Layout.cshtml.css",
718723
"Views/Shared/_ValidationScriptsPartial.cshtml",
719724
"wwwroot/favicon.ico",
720725
"wwwroot/css/site.css",
@@ -772,6 +777,7 @@
772777
"Views/Home/Privacy.cshtml",
773778
"Views/Shared/Error.cshtml",
774779
"Views/Shared/_Layout.cshtml",
780+
"Views/Shared/_Layout.cshtml.css",
775781
"Views/Shared/_LoginPartial.cshtml",
776782
"Views/Shared/_ValidationScriptsPartial.cshtml",
777783
"wwwroot/favicon.ico",
@@ -830,6 +836,7 @@
830836
"Views/Home/Privacy.cshtml",
831837
"Views/Shared/Error.cshtml",
832838
"Views/Shared/_Layout.cshtml",
839+
"Views/Shared/_Layout.cshtml.css",
833840
"Views/Shared/_ValidationScriptsPartial.cshtml",
834841
"wwwroot/favicon.ico",
835842
"wwwroot/css/site.css",

0 commit comments

Comments
 (0)