Skip to content

Commit f34cba5

Browse files
authored
SAB-181 Add GDS style sheet with sass support (#5)
Added GovUK Gds support via SASS and removed boiler plating of MVC template.
1 parent b8a6faf commit f34cba5

82 files changed

Lines changed: 169 additions & 82770 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,4 +523,11 @@ FodyWeavers.xsd
523523
### VisualStudio Patch ###
524524
# Additional files built by Visual Studio
525525

526-
# End of https://www.toptal.com/developers/gitignore/api/rider,visualstudio,visualstudiocode,osx
526+
# End of https://www.toptal.com/developers/gitignore/api/rider,visualstudio,visualstudiocode,osx
527+
528+
# Custom exclusions
529+
package_cache/
530+
src/SchoolAccount.Web.Mvc/wwwroot/app.css*
531+
src/SchoolAccount.Web.Mvc/wwwroot/assets
532+
src/SchoolAccount.Web.Mvc/wwwroot/govuk-frontend.min.js
533+
src/SchoolAccount.Web.Mvc/lib/govuk-frontend*

Directory.Packages.props

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
<PackageVersion Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.23.0" />
2020
<PackageVersion Include="Serilog.AspNetCore" Version="10.0.0" />
2121
<PackageVersion Include="Serilog.Sinks.Seq" Version="9.1.0" />
22+
<!-- Web.Mvc -->
23+
<PackageVersion Include="AspNetCore.SassCompiler" Version="1.102.0" />
24+
<PackageVersion Include="GovUk.Frontend.AspNetCore" Version="4.4.0" />
2225
<!-- ArchitectureTests -->
2326
<PackageVersion Include="Shouldly" Version="4.3.0" />
2427
<PackageVersion Include="NetArchTest.Rules" Version="1.3.2" />

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Architecture decisions are recorded as ADRs in the [decisions](decisions) folder
1919
- [Run tests on the Microsoft Testing Platform](decisions/0004-microsoft-testing-platform-and-ci-reporting.md) - testing platform and how results and coverage are reported in CI
2020
- [Format code with CSharpier](decisions/0005-format-code-with-csharpier.md) - why formatting is automated and enforced in the build
2121
- [Enforce code quality with Roslyn analysers](decisions/0006-enforce-code-quality-with-roslyn-analysers.md) - why SonarAnalyzer.CSharp and strict analysis are enforced in the build
22+
- [Supporting SASS within GDS Styles](decisions/0007-supporting-sass-within-gds-styles.md) - why SASS support has been enabled
2223

2324
New decisions should follow the [ADR template](decisions/0000-adr-template.md).
2425

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
status: "accepted"
3+
date: "2026-07-29"
4+
decision-makers: Paul Custance & Mark Harrop
5+
---
6+
7+
# Supporting SASS within GDS Styles
8+
9+
## Context and Problem Statement
10+
11+
To implement government standards into the application to align closer with the design team.
12+
13+
<!-- This is an optional element. Feel free to remove. -->
14+
## Decision Drivers
15+
16+
* To closer align with the design team we should support SASS components
17+
* Easier for a like for like comparison
18+
19+
<!-- This is an optional element. Feel free to remove. -->
20+
### Consequences
21+
22+
* Good, because we can use the GDS SASS variables, colours and layout rather than redefining them within the css.
23+
* Good, because it aligns closer with the component structure within the design prototype project.
24+
* Bad, as it adds further complexity to the components and file structure.
25+
26+
<!-- This is an optional element. Feel free to remove. -->
27+
### Confirmation
28+
29+
Changes to the SASS files are reflected within the generated css when building the application.
30+
31+
<!-- This is an optional element. Feel free to remove. -->
32+
## More Information
33+
34+
* See [Sass Examples](https://github.com/x-govuk/govuk-frontend-aspnetcore/tree/main/samples/Samples.Sass) on how to integrate SASS within a GDS MVC app.

docs/clean-architecture.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ Contains:
9090
- **Middleware** - request pipeline concerns
9191
- **Error handling** - exception handling and mapping `Result` failures to HTTP problem details
9292
- **Authentication configuration**
93+
- **Style** - a dedicated scss file for and named after each component
9394

9495
The Presentation layer depends on Application (to send commands/queries) but should not reference Infrastructure directly.
9596

docs/coding-standards.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,7 @@ definitions.
7777
Coding standards cover how individual files are written. For how projects relate to each other,
7878
see [Clean Architecture](clean-architecture.md). For how tests are written, see
7979
[Testing Standards](testing-standards.md) and [Integration Testing](integration-testing.md).
80+
81+
## Style sheets
82+
83+
Each component should have a dedicated scss style sheet within the `./Style/components/` directory.

launchSettings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"commandName": "DockerCompose",
55
"commandVersion": "1.0",
66
"serviceActions": {
7-
"web.api": "StartDebugging"
7+
"presentation": "StartDebugging"
88
}
99
}
1010
}

nuget.config

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<packageSources>
4+
<clear />
5+
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
6+
</packageSources>
7+
<config>
8+
<add key="globalPackagesFolder" value="./package_cache" />
9+
</config>
10+
</configuration>

src/SchoolAccount.Web.Mvc/Program.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
1+
using GovUk.Frontend.AspNetCore;
2+
13
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
24

35
// Add services to the container.
46
builder.Services.AddControllersWithViews();
7+
builder.Services.AddGovUkFrontend();
8+
9+
if (builder.Environment.IsDevelopment())
10+
{
11+
builder.Services.AddSassCompiler();
12+
}
513

614
WebApplication app = builder.Build();
715

@@ -15,7 +23,7 @@
1523

1624
app.UseHttpsRedirection();
1725
app.UseRouting();
18-
26+
app.UseGovUkFrontend();
1927
app.UseAuthorization();
2028

2129
app.MapStaticAssets();

src/SchoolAccount.Web.Mvc/SchoolAccount.Web.Mvc.csproj

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,23 @@
55
<Nullable>enable</Nullable>
66
<ImplicitUsings>enable</ImplicitUsings>
77
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
8+
<EnableGovUkFrontendSupport>true</EnableGovUkFrontendSupport>
9+
<RestoreGovUkFrontendStylesheet>false</RestoreGovUkFrontendStylesheet>
10+
<RestoreGovUkFrontendNpmPackage>true</RestoreGovUkFrontendNpmPackage>
11+
<RestoreGovUkFrontendSupportPackage>true</RestoreGovUkFrontendSupportPackage>
12+
</PropertyGroup>
13+
14+
<PropertyGroup Condition="$([MSBuild]::IsOSPlatform('Windows'))">
15+
<GovUkFrontendAssetsDirectory>/wwwroot</GovUkFrontendAssetsDirectory>
816
</PropertyGroup>
917

1018
<ItemGroup>
1119
<ProjectReference Include="..\SchoolAccount.Infrastructure\SchoolAccount.Infrastructure.csproj" />
1220
</ItemGroup>
21+
22+
<ItemGroup>
23+
<PackageReference Include="AspNetCore.SassCompiler" />
24+
<PackageReference Include="GovUk.Frontend.AspNetCore" />
25+
</ItemGroup>
1326

1427
</Project>

0 commit comments

Comments
 (0)