Skip to content

Commit a1a550d

Browse files
Remove $override-line-height from nhsuk-font-size
This means that nhsuk-font-size is consistent with nhsuk-font, making them easier to use interchangeably. Co-authored-by: owenatgov <owen.jones@digital.cabinet-office.gov.uk>
1 parent dfc6415 commit a1a550d

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

packages/core/tools/_typography.scss

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@
115115
///
116116
/// @param {Number} $size - Point from the spacing scale (the size as it would
117117
/// appear on tablet and above)
118-
/// @param {Number} $override-line-height [false] - Non responsive custom line
118+
/// @param {Number} $line-height [false] - Non responsive custom line
119119
/// height. Omit to use the line height from the font map.
120120
/// @param {Boolean} $important [false] - Whether to mark declarations as
121121
/// `!important`.
@@ -124,7 +124,7 @@
124124
///
125125
/// @link https://github.com/alphagov/govuk-frontend Original code taken from GDS (Government Digital Service)
126126

127-
@mixin nhsuk-font-size($size, $override-line-height: false, $important: false) {
127+
@mixin nhsuk-font-size($size, $line-height: false, $important: false) {
128128
@if not map.has-key($nhsuk-typography-scale, $size) {
129129
@error "Unknown font size `#{$size}` - expected a point from the typography scale.";
130130
}
@@ -135,8 +135,14 @@
135135
$font-size: map.get($breakpoint-map, "font-size");
136136
$font-size-rem: nhsuk-px-to-rem($font-size);
137137

138-
$line-height: nhsuk-line-height(
139-
$line-height: if($override-line-height, $override-line-height, map.get($breakpoint-map, "line-height")),
138+
// $calculated-line-height is a separate variable from $line-height,
139+
// as otherwise the value would get redefined with each loop and
140+
// eventually break nhsuk-line-height.
141+
//
142+
// We continue to call the param $line-height to stay consistent with the
143+
// naming with nhsuk-font.
144+
$calculated-line-height: nhsuk-line-height(
145+
$line-height: if($line-height, $line-height, map-get($breakpoint-map, "line-height")),
140146
$font-size: $font-size
141147
);
142148

@@ -145,23 +151,23 @@
145151
// are used in calculations
146152
$font-size: $font-size if($important, !important, null);
147153
$font-size-rem: $font-size-rem if($important, !important, null);
148-
$line-height: $line-height if($important, !important, null);
154+
$calculated-line-height: $calculated-line-height if($important, !important, null);
149155

150156
& {
151157
@if not $breakpoint {
152158
font-size: $font-size;
153159
font-size: $font-size-rem;
154-
line-height: $line-height;
160+
line-height: $calculated-line-height;
155161
} @else if $breakpoint == "print" {
156162
@include nhsuk-media-query($media-type: print) {
157163
font-size: $font-size;
158-
line-height: $line-height;
164+
line-height: $calculated-line-height;
159165
}
160166
} @else {
161167
@include nhsuk-media-query($from: $breakpoint) {
162168
font-size: $font-size;
163169
font-size: $font-size-rem;
164-
line-height: $line-height;
170+
line-height: $calculated-line-height;
165171
}
166172
}
167173
}
@@ -212,6 +218,6 @@
212218
}
213219

214220
@if $size {
215-
@include nhsuk-font-size($size, $override-line-height: $line-height);
221+
@include nhsuk-font-size($size, $line-height);
216222
}
217223
}

0 commit comments

Comments
 (0)