Skip to content

Commit

Permalink
Add new $size-internal-use-only for deprecated font sizes
Browse files Browse the repository at this point in the history
Clearly explain why we’re flagging sizes that start with an underscore and what we’re going to do about it
  • Loading branch information
colinrotherham committed Feb 2, 2024
1 parent 1ed26b0 commit 02f5803
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/govuk-frontend/src/govuk/helpers/_typography.scss
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@
/// @access public

@mixin govuk-font-size($size, $line-height: false, $important: false) {
// Flag font sizes that start with underscores so we can suppress warnings on
// deprecated sizes used internally, for example `govuk-font($size: "_14")`
$size-internal-use-only: str-slice(#{$size}, 1, 1) == "_";

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

Expand All @@ -177,7 +181,11 @@
$deprecation: map-get($font-map, "deprecation");

@if $deprecation {
@include _warning(map-get($deprecation, "key"), map-get($deprecation, "message"));
// Warn on deprecated font sizes unless flagged for internal use
@if not $size-internal-use-only {
@include _warning(map-get($deprecation, "key"), map-get($deprecation, "message"));
}

// remove the deprecation map keys so they do not break the breakpoint loop
$font-map: map-remove($font-map, "deprecation");
}
Expand Down

0 comments on commit 02f5803

Please sign in to comment.