|
115 | 115 | ///
|
116 | 116 | /// @param {Number} $size - Point from the spacing scale (the size as it would
|
117 | 117 | /// 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 |
119 | 119 | /// height. Omit to use the line height from the font map.
|
120 | 120 | /// @param {Boolean} $important [false] - Whether to mark declarations as
|
121 | 121 | /// `!important`.
|
|
124 | 124 | ///
|
125 | 125 | /// @link https://github.com/alphagov/govuk-frontend Original code taken from GDS (Government Digital Service)
|
126 | 126 |
|
127 |
| -@mixin nhsuk-font-size($size, $override-line-height: false, $important: false) { |
| 127 | +@mixin nhsuk-font-size($size, $line-height: false, $important: false) { |
128 | 128 | @if not map.has-key($nhsuk-typography-scale, $size) {
|
129 | 129 | @error "Unknown font size `#{$size}` - expected a point from the typography scale.";
|
130 | 130 | }
|
|
135 | 135 | $font-size: map.get($breakpoint-map, "font-size");
|
136 | 136 | $font-size-rem: nhsuk-px-to-rem($font-size);
|
137 | 137 |
|
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")), |
140 | 146 | $font-size: $font-size
|
141 | 147 | );
|
142 | 148 |
|
|
145 | 151 | // are used in calculations
|
146 | 152 | $font-size: $font-size if($important, !important, null);
|
147 | 153 | $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); |
149 | 155 |
|
150 | 156 | & {
|
151 | 157 | @if not $breakpoint {
|
152 | 158 | font-size: $font-size;
|
153 | 159 | font-size: $font-size-rem;
|
154 |
| - line-height: $line-height; |
| 160 | + line-height: $calculated-line-height; |
155 | 161 | } @else if $breakpoint == "print" {
|
156 | 162 | @include nhsuk-media-query($media-type: print) {
|
157 | 163 | font-size: $font-size;
|
158 |
| - line-height: $line-height; |
| 164 | + line-height: $calculated-line-height; |
159 | 165 | }
|
160 | 166 | } @else {
|
161 | 167 | @include nhsuk-media-query($from: $breakpoint) {
|
162 | 168 | font-size: $font-size;
|
163 | 169 | font-size: $font-size-rem;
|
164 |
| - line-height: $line-height; |
| 170 | + line-height: $calculated-line-height; |
165 | 171 | }
|
166 | 172 | }
|
167 | 173 | }
|
|
212 | 218 | }
|
213 | 219 |
|
214 | 220 | @if $size {
|
215 |
| - @include nhsuk-font-size($size, $override-line-height: $line-height); |
| 221 | + @include nhsuk-font-size($size, $line-height); |
216 | 222 | }
|
217 | 223 | }
|
0 commit comments