Skip to content

Commit

Permalink
Remove duplicate font declarations for point 14
Browse files Browse the repository at this point in the history
We can remove the underscore in `_14` → `14` so the deprecated font declaration map continue to work without duplication
  • Loading branch information
colinrotherham committed Feb 2, 2024
1 parent 02f5803 commit 220a4c0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 25 deletions.
5 changes: 5 additions & 0 deletions packages/govuk-frontend/src/govuk/helpers/_typography.scss
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,11 @@
// deprecated sizes used internally, for example `govuk-font($size: "_14")`
$size-internal-use-only: str-slice(#{$size}, 1, 1) == "_";

// Remove underscore from font sizes flagged for internal use
@if $size-internal-use-only {
$size: str-slice(#{$size}, 2);
}

// Check for a font map exactly matching the given size
$font-map: map-get($govuk-typography-scale, $size);

Expand Down
18 changes: 7 additions & 11 deletions packages/govuk-frontend/src/govuk/overrides/_typography.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,15 @@
//
// govuk-!-font-size-14 is deprecated
@each $size, $font-map in $govuk-typography-scale {
// Suppress class if the map key is a string with an underscore eg: _14 to
// avoid classes like govuk-!-font-size-_14 getting generated
@if type-of($size) == "number" or str-slice(#{$size}, 1, 1) != "_" {
.govuk-\!-font-size-#{$size} {
$font-map: map-get($govuk-typography-scale, $size);
.govuk-\!-font-size-#{$size} {
$font-map: map-get($govuk-typography-scale, $size);

// Add underscore to deprecated typography scale keys
@if map-has-key($font-map, "deprecation") {
$size: _#{$size};
}

@include govuk-font-size($size, $important: true);
// Add underscore to deprecated typography scale keys
@if map-has-key($font-map, "deprecation") {
$size: _#{$size};
}

@include govuk-font-size($size, $important: true);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,19 +157,5 @@ $govuk-typography-scale: (
message: "14 on the type scale is deprecated and will be removed as " +
"a possible option in the next major version."
)
),
_14: (
null: (
font-size: 12px,
line-height: 15px
),
tablet: (
font-size: 14px,
line-height: 20px
),
print: (
font-size: 12pt,
line-height: 1.2
)
)
) !default;

0 comments on commit 220a4c0

Please sign in to comment.