Skip to content

Commit c39aea4

Browse files
Rename nhsuk-typography-responsive mixin to nhsuk-font-size
Co-authored-by: owenatgov <owen.jones@digital.cabinet-office.gov.uk>
1 parent 79f4a17 commit c39aea4

File tree

1 file changed

+35
-14
lines changed

1 file changed

+35
-14
lines changed

packages/core/tools/_typography.scss

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,15 @@
8181
@return $line-height;
8282
}
8383

84-
/// Responsive typography
84+
/// Font size and line height helper
8585
///
86-
/// Takes a 'font map' as an argument and uses it to create font-size and
87-
/// line-height declarations for different breakpoints, and for print.
86+
/// Takes a point from the responsive 'font map' as an argument (the size as it
87+
/// would appear on tablet and above), and uses it to create font-size and
88+
/// line-height declarations for different breakpoints, and print.
8889
///
8990
/// Example font map:
9091
///
91-
/// $my-font-map: (
92+
/// 19: (
9293
/// null: (
9394
/// font-size: 16px,
9495
/// line-height: 20px
@@ -101,29 +102,29 @@
101102
/// font-size: 14pt,
102103
/// line-height: 1.15
103104
/// )
104-
/// );\
105+
/// );
105106
///
106107
/// @example scss
107108
/// .foo {
108-
/// @include nhsuk-typography-responsive(19);
109+
/// @include nhsuk-font-size(19);
109110
/// }
110111
///
111112
/// .foo {
112-
/// @include nhsuk-typography-responsive(36, $important: true);
113+
/// @include nhsuk-font-size(36, $important: true);
113114
/// }
114115
///
115-
/// @param {Map} $font-map - Font map
116+
/// @param {Number} $size - Point from the spacing scale (the size as it would
117+
/// appear on tablet and above)
116118
/// @param {Number} $override-line-height [false] - Non responsive custom line
117119
/// height. Omit to use the line height from the font map.
118120
/// @param {Boolean} $important [false] - Whether to mark declarations as
119121
/// `!important`.
120122
///
121-
/// 1. Mark rules as !important if $important is true - this will result in
122-
/// these variables becoming strings, so this needs to happen *after* they
123-
/// are used in calculations
123+
/// @throw if `$size` is not a valid point from the spacing scale
124124
///
125+
/// @link https://github.com/alphagov/govuk-frontend Original code taken from GDS (Government Digital Service)
125126

126-
@mixin nhsuk-typography-responsive($size, $override-line-height: false, $important: false) {
127+
@mixin nhsuk-font-size($size, $override-line-height: false, $important: false) {
127128
@if not map.has-key($nhsuk-typography-scale, $size) {
128129
@error "Unknown font size `#{$size}` - expected a point from the typography scale.";
129130
}
@@ -139,7 +140,9 @@
139140
$font-size: $font-size
140141
);
141142

142-
// [1]
143+
// Mark rules as !important if $important is true - this will result in
144+
// these variables becoming strings, so this needs to happen *after* they
145+
// are used in calculations
143146
$font-size: $font-size if($important, !important, null);
144147
$font-size-rem: $font-size-rem if($important, !important, null);
145148
$line-height: $line-height if($important, !important, null);
@@ -165,6 +168,24 @@
165168
}
166169
}
167170

171+
/// Font size and line height helper (deprecated)
172+
///
173+
/// @param {Number} $size - Point from the spacing scale (the size as it would
174+
/// appear on tablet and above)
175+
/// @param {Number} $override-line-height [false] - Non responsive custom line
176+
/// height. Omit to use the line height from the font map.
177+
/// @param {Boolean} $important [false] - Whether to mark declarations as
178+
/// `!important`.
179+
///
180+
/// @throw if `$size` is not a valid point from the spacing scale
181+
///
182+
/// @alias nhsuk-font-size
183+
/// @deprecated Use `nhsuk-font-size` instead
184+
185+
@mixin nhsuk-typography-responsive($size, $override-line-height: false, $important: false) {
186+
@include nhsuk-font-size($size, $override-line-height, $important);
187+
}
188+
168189
/// Font
169190
///
170191
/// @example scss
@@ -191,6 +212,6 @@
191212
}
192213

193214
@if $size {
194-
@include nhsuk-typography-responsive($size, $override-line-height: $line-height);
215+
@include nhsuk-font-size($size, $override-line-height: $line-height);
195216
}
196217
}

0 commit comments

Comments
 (0)