-
Notifications
You must be signed in to change notification settings - Fork 333
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Before we removed compatibility mode, the font-families file included multiple ‘settings’ (realistically, more like constants) that defined the font to be used depending on whether compatibility mode was enabled or not. Now that we only have one possible default font stack, we can remove the unnecessary abstraction. We also need to update the default value for the `$govuk-include-default-font-face` setting. Previously it checked whether the chosen font family was the default stack based on GDS Transport, but we can instead just check whether “GDS Transport” is in the font list. This also makes it more robust if somebody for example wants to update the setting to change the fallback fonts.
- Loading branch information
Showing
4 changed files
with
48 additions
and
20 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
11 changes: 0 additions & 11 deletions
11
packages/govuk-frontend/src/govuk/settings/_typography-font-families.scss
This file was deleted.
Oops, something went wrong.
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
44 changes: 44 additions & 0 deletions
44
packages/govuk-frontend/src/govuk/settings/typography.test.js
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,44 @@ | ||
const { compileSassString } = require('govuk-frontend-helpers/tests') | ||
|
||
describe('$govuk-include-default-font-face', () => { | ||
it('is true if $govuk-font-family is default', async () => { | ||
const sass = ` | ||
@import "settings/typography-font"; | ||
:root { | ||
--result: #{$govuk-include-default-font-face} | ||
} | ||
` | ||
|
||
await expect(compileSassString(sass)).resolves.toMatchObject({ | ||
css: expect.stringContaining('--result: true') | ||
}) | ||
}) | ||
|
||
it('is true if $govuk-font-family includes GDS Transport', async () => { | ||
const sass = ` | ||
$govuk-font-family: "GDS Transport", "Comic Sans MS", "Comic Sans", cursive; | ||
@import "settings/typography-font"; | ||
:root { | ||
--result: #{$govuk-include-default-font-face} | ||
} | ||
` | ||
|
||
await expect(compileSassString(sass)).resolves.toMatchObject({ | ||
css: expect.stringContaining('--result: true') | ||
}) | ||
}) | ||
|
||
it('is false if $govuk-font-family does not include GDS Transport', async () => { | ||
const sass = ` | ||
$govuk-font-family: "Comic Sans MS", "Comic Sans", cursive; | ||
@import "settings/typography-font"; | ||
:root { | ||
--result: #{$govuk-include-default-font-face} | ||
} | ||
` | ||
|
||
await expect(compileSassString(sass)).resolves.toMatchObject({ | ||
css: expect.stringContaining('--result: false') | ||
}) | ||
}) | ||
}) |