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

Simplify font family settings #3949

Merged
merged 2 commits into from
Jul 20, 2023
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
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,18 @@ If you need to maintain the existing behaviour, you can set the value to an empt

This change was introduced in [pull request #3773: Omit the value attribute from select options with no value](https://github.com/alphagov/govuk-frontend/pull/3773).

### Removal of font family Sass variables

The following Sass variables have been removed:

- `$govuk-font-family-gds-transport`
- `$govuk-font-family-nta`
- `$govuk-font-family-nta-tabular`

If you were using `$govuk-font-family-gds-transport` to set the font on an element we recommend using [the `govuk-font` mixin](https://frontend.design-system.service.gov.uk/sass-api-reference/#govuk-font) instead.

This change was introduced in [pull request #3949: Simplify font family settings](https://github.com/alphagov/govuk-frontend/pull/3949).

### Suggested changes

#### Update the Pagination component's default `aria-label`
Expand Down
1 change: 0 additions & 1 deletion packages/govuk-frontend/src/govuk/settings/_all.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
@import "spacing";
@import "measurements";

@import "typography-font-families";
@import "typography-font";
@import "typography-responsive";

Expand Down

This file was deleted.

12 changes: 4 additions & 8 deletions packages/govuk-frontend/src/govuk/settings/_typography-font.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@import "typography-font-families";

////
/// @group settings/typography
////
Expand All @@ -13,7 +11,7 @@
/// @type List
/// @access public

$govuk-font-family: $govuk-font-family-gds-transport !default;
$govuk-font-family: "GDS Transport", arial, sans-serif !default;

/// Font families to use for print media
///
Expand All @@ -27,15 +25,13 @@ $govuk-font-family-print: sans-serif !default;

/// Include the default @font-face declarations
///
/// If you have set $govuk-font-family to something other than
/// `$govuk-font-family-gds-transport` this option is disabled by default.
/// Defaults to true if "GDS Transport" appears in the $govuk-font-family
/// setting.
///
/// @type Boolean
/// @access public

$govuk-include-default-font-face: (
$govuk-font-family == $govuk-font-family-gds-transport
) !default;
$govuk-include-default-font-face: if(index($govuk-font-family, "GDS Transport"), true, false) !default;
36degrees marked this conversation as resolved.
Show resolved Hide resolved

// =========================================================
// Font weights
Expand Down
44 changes: 44 additions & 0 deletions packages/govuk-frontend/src/govuk/settings/typography.test.js
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')
})
})
})