Skip to content

Commit

Permalink
Deprecate $govuk-font-family-tabular
Browse files Browse the repository at this point in the history
  • Loading branch information
owenatgov committed Sep 15, 2022
1 parent d49326c commit 833b55d
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
25 changes: 22 additions & 3 deletions src/govuk/helpers/typography.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -408,9 +408,9 @@ describe('@mixin govuk-typography-responsive', () => {
${sassBootstrap}`

await renderSass({ data: sass, ...sassConfig }).then(() => {
// Expect our mocked @warn function to have been called once with a single
// argument, which should be the deprecation notice
return expect(mockWarnFunction.mock.calls[0][0].getValue())
// Get the argument of the last @warn call, which we expect to be the
// deprecation notice
return expect(mockWarnFunction.mock.calls.at(-1)[0].getValue())
.toEqual(
'$govuk-typography-use-rem is deprecated. ' +
'From version 5.0, Govuk-frontend will not support rem value suppression in typography'
Expand Down Expand Up @@ -598,3 +598,22 @@ describe('@mixin govuk-typography-responsive', () => {
})
})
})

describe('$govuk-font-family-tabular value is specified', () => {
it('outputs a deprecation warning when set', async () => {
const sass = `
$govuk-font-family-tabular: monospace;
${sassBootstrap}`

await renderSass({ data: sass, ...sassConfig }).then(() => {
// Get the argument of the last @warn call, which we expect to be the
// deprecation notice
return expect(mockWarnFunction.mock.calls.at(-1)[0].getValue())
.toEqual(
'$govuk-font-family-tabular is deprecated. ' +
'From version 5.0, Govuk-frontend will not support this method of ' +
'specifying tabular data'
)
})
})
})
10 changes: 10 additions & 0 deletions src/govuk/settings/_typography-font.scss
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,23 @@ $govuk-font-family: if(
///
/// @type List
/// @access public
/// @deprecated Will be removed in v5.0 with the rest of the compatibility mode
/// suite of tools and settings

$govuk-font-family-tabular: if(
$govuk-use-legacy-font,
$govuk-font-family-nta-tabular,
false
) !default;

// Only show the deprecation warning if user is setting $govuk-font-family-tabular
// manually instead of automatically via $govuk-use-legacy-font
@if $govuk-font-family-tabular != false and $govuk-use-legacy-font == false {
@warn "$govuk-font-family-tabular is deprecated. " +
"From version 5.0, Govuk-frontend will not support this method of " +
"specifying tabular data";
}

/// Font families to use for print media
///
/// We recommend that you use system fonts when printing. This will avoid issues
Expand Down

0 comments on commit 833b55d

Please sign in to comment.