govuk_tech_docs 6.0.1 → 6.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (145) hide show
  1. checksums.yaml +4 -4
  2. data/.github/ISSUE_TEMPLATE/bug.yaml +69 -0
  3. data/.github/ISSUE_TEMPLATE/config.yaml +6 -0
  4. data/.github/ISSUE_TEMPLATE/enhancement.yaml +25 -0
  5. data/.github/pull_request_template.md +22 -8
  6. data/.github/workflows/dependency-review.yaml +17 -0
  7. data/.github/workflows/test.yaml +1 -1
  8. data/.nvmrc +1 -1
  9. data/.ruby-version +1 -1
  10. data/CHANGELOG.md +18 -2
  11. data/README.md +3 -2
  12. data/example/.ruby-version +1 -1
  13. data/example/config/tech-docs.yml +4 -0
  14. data/example/config.rb +15 -0
  15. data/example/source/active-pages/index.html.md.erb +7 -0
  16. data/example/source/active-pages/sub-section/index.html.md.erb +7 -0
  17. data/example/source/index.html.md.erb +6 -1
  18. data/govuk_tech_docs.gemspec +21 -19
  19. data/lib/govuk_tech_docs/custom_method_missing_handler.rb +30 -0
  20. data/lib/govuk_tech_docs/govuk_nunjuck_componenet_renderer.rb +43 -0
  21. data/lib/govuk_tech_docs/version.rb +1 -1
  22. data/lib/govuk_tech_docs.rb +35 -5
  23. data/node_modules/govuk-frontend/dist/govuk/all.bundle.js +1 -1
  24. data/node_modules/govuk-frontend/dist/govuk/all.bundle.mjs +1 -1
  25. data/node_modules/govuk-frontend/dist/govuk/common/govuk-frontend-version.mjs +1 -1
  26. data/node_modules/govuk-frontend/dist/govuk/components/accordion/_accordion.scss +4 -1
  27. data/node_modules/govuk-frontend/dist/govuk/components/accordion/_index.scss +3 -1
  28. data/node_modules/govuk-frontend/dist/govuk/components/back-link/_back-link.scss +4 -1
  29. data/node_modules/govuk-frontend/dist/govuk/components/back-link/_index.scss +7 -3
  30. data/node_modules/govuk-frontend/dist/govuk/components/breadcrumbs/_breadcrumbs.scss +4 -1
  31. data/node_modules/govuk-frontend/dist/govuk/components/breadcrumbs/_index.scss +8 -4
  32. data/node_modules/govuk-frontend/dist/govuk/components/button/_button.scss +4 -1
  33. data/node_modules/govuk-frontend/dist/govuk/components/button/_index.scss +3 -1
  34. data/node_modules/govuk-frontend/dist/govuk/components/character-count/_character-count.scss +4 -1
  35. data/node_modules/govuk-frontend/dist/govuk/components/character-count/_index.scss +2 -0
  36. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/_checkboxes.scss +4 -1
  37. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/_index.scss +10 -6
  38. data/node_modules/govuk-frontend/dist/govuk/components/cookie-banner/_cookie-banner.scss +4 -1
  39. data/node_modules/govuk-frontend/dist/govuk/components/cookie-banner/_index.scss +2 -0
  40. data/node_modules/govuk-frontend/dist/govuk/components/date-input/_date-input.scss +4 -1
  41. data/node_modules/govuk-frontend/dist/govuk/components/date-input/_index.scss +2 -0
  42. data/node_modules/govuk-frontend/dist/govuk/components/details/_details.scss +4 -1
  43. data/node_modules/govuk-frontend/dist/govuk/components/details/_index.scss +3 -1
  44. data/node_modules/govuk-frontend/dist/govuk/components/error-message/_error-message.scss +4 -1
  45. data/node_modules/govuk-frontend/dist/govuk/components/error-message/_index.scss +2 -0
  46. data/node_modules/govuk-frontend/dist/govuk/components/error-summary/_error-summary.scss +4 -1
  47. data/node_modules/govuk-frontend/dist/govuk/components/error-summary/_index.scss +3 -1
  48. data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/_exit-this-page.scss +4 -1
  49. data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/_index.scss +3 -1
  50. data/node_modules/govuk-frontend/dist/govuk/components/fieldset/_fieldset.scss +4 -1
  51. data/node_modules/govuk-frontend/dist/govuk/components/fieldset/_index.scss +3 -1
  52. data/node_modules/govuk-frontend/dist/govuk/components/file-upload/_file-upload.scss +4 -1
  53. data/node_modules/govuk-frontend/dist/govuk/components/file-upload/_index.scss +4 -1
  54. data/node_modules/govuk-frontend/dist/govuk/components/footer/_footer.scss +4 -1
  55. data/node_modules/govuk-frontend/dist/govuk/components/footer/_index.scss +2 -0
  56. data/node_modules/govuk-frontend/dist/govuk/components/header/_header.scss +4 -1
  57. data/node_modules/govuk-frontend/dist/govuk/components/header/_index.scss +2 -0
  58. data/node_modules/govuk-frontend/dist/govuk/components/hint/_hint.scss +4 -1
  59. data/node_modules/govuk-frontend/dist/govuk/components/hint/_index.scss +2 -0
  60. data/node_modules/govuk-frontend/dist/govuk/components/input/_index.scss +2 -0
  61. data/node_modules/govuk-frontend/dist/govuk/components/input/_input.scss +4 -1
  62. data/node_modules/govuk-frontend/dist/govuk/components/inset-text/_index.scss +5 -1
  63. data/node_modules/govuk-frontend/dist/govuk/components/inset-text/_inset-text.scss +4 -1
  64. data/node_modules/govuk-frontend/dist/govuk/components/label/_index.scss +3 -1
  65. data/node_modules/govuk-frontend/dist/govuk/components/label/_label.scss +4 -1
  66. data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/_index.scss +6 -2
  67. data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/_notification-banner.scss +4 -1
  68. data/node_modules/govuk-frontend/dist/govuk/components/pagination/_index.scss +2 -0
  69. data/node_modules/govuk-frontend/dist/govuk/components/pagination/_pagination.scss +4 -1
  70. data/node_modules/govuk-frontend/dist/govuk/components/panel/_index.scss +3 -1
  71. data/node_modules/govuk-frontend/dist/govuk/components/panel/_panel.scss +4 -1
  72. data/node_modules/govuk-frontend/dist/govuk/components/password-input/_index.scss +2 -0
  73. data/node_modules/govuk-frontend/dist/govuk/components/password-input/_password-input.scss +4 -1
  74. data/node_modules/govuk-frontend/dist/govuk/components/phase-banner/_index.scss +3 -1
  75. data/node_modules/govuk-frontend/dist/govuk/components/phase-banner/_phase-banner.scss +4 -1
  76. data/node_modules/govuk-frontend/dist/govuk/components/radios/_index.scss +14 -10
  77. data/node_modules/govuk-frontend/dist/govuk/components/radios/_radios.scss +4 -1
  78. data/node_modules/govuk-frontend/dist/govuk/components/select/_index.scss +2 -0
  79. data/node_modules/govuk-frontend/dist/govuk/components/select/_select.scss +4 -1
  80. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/_index.scss +5 -1
  81. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/_service-navigation.scss +4 -1
  82. data/node_modules/govuk-frontend/dist/govuk/components/skip-link/_index.scss +7 -3
  83. data/node_modules/govuk-frontend/dist/govuk/components/skip-link/_skip-link.scss +4 -1
  84. data/node_modules/govuk-frontend/dist/govuk/components/summary-list/_index.scss +15 -2
  85. data/node_modules/govuk-frontend/dist/govuk/components/summary-list/_summary-list.scss +4 -1
  86. data/node_modules/govuk-frontend/dist/govuk/components/table/_index.scss +4 -1
  87. data/node_modules/govuk-frontend/dist/govuk/components/table/_table.scss +4 -1
  88. data/node_modules/govuk-frontend/dist/govuk/components/tabs/_index.scss +5 -2
  89. data/node_modules/govuk-frontend/dist/govuk/components/tabs/_tabs.scss +4 -1
  90. data/node_modules/govuk-frontend/dist/govuk/components/tag/_index.scss +4 -1
  91. data/node_modules/govuk-frontend/dist/govuk/components/tag/_tag.scss +4 -1
  92. data/node_modules/govuk-frontend/dist/govuk/components/task-list/_index.scss +6 -2
  93. data/node_modules/govuk-frontend/dist/govuk/components/task-list/_task-list.scss +4 -1
  94. data/node_modules/govuk-frontend/dist/govuk/components/textarea/_index.scss +2 -0
  95. data/node_modules/govuk-frontend/dist/govuk/components/textarea/_textarea.scss +4 -1
  96. data/node_modules/govuk-frontend/dist/govuk/components/warning-text/_index.scss +3 -1
  97. data/node_modules/govuk-frontend/dist/govuk/components/warning-text/_warning-text.scss +4 -1
  98. data/node_modules/govuk-frontend/dist/govuk/core/_global-styles.scss +4 -0
  99. data/node_modules/govuk-frontend/dist/govuk/core/_index.scss +4 -0
  100. data/node_modules/govuk-frontend/dist/govuk/core/_links.scss +8 -0
  101. data/node_modules/govuk-frontend/dist/govuk/core/_lists.scss +10 -1
  102. data/node_modules/govuk-frontend/dist/govuk/core/_section-break.scss +5 -0
  103. data/node_modules/govuk-frontend/dist/govuk/core/_typography.scss +14 -13
  104. data/node_modules/govuk-frontend/dist/govuk/custom-properties/_frontend-version.scss +1 -1
  105. data/node_modules/govuk-frontend/dist/govuk/custom-properties/_functional-colours.scss +5 -0
  106. data/node_modules/govuk-frontend/dist/govuk/govuk-frontend.min.js +1 -1
  107. data/node_modules/govuk-frontend/dist/govuk/helpers/_colour.scss +38 -70
  108. data/node_modules/govuk-frontend/dist/govuk/helpers/_device-pixels.scss +2 -0
  109. data/node_modules/govuk-frontend/dist/govuk/helpers/_focused.scss +1 -1
  110. data/node_modules/govuk-frontend/dist/govuk/helpers/_grid.scss +3 -2
  111. data/node_modules/govuk-frontend/dist/govuk/helpers/_links.scss +4 -4
  112. data/node_modules/govuk-frontend/dist/govuk/helpers/_media-queries.scss +17 -15
  113. data/node_modules/govuk-frontend/dist/govuk/helpers/_shape-arrow.scss +2 -2
  114. data/node_modules/govuk-frontend/dist/govuk/helpers/_spacing.scss +19 -13
  115. data/node_modules/govuk-frontend/dist/govuk/helpers/_typography.scss +48 -26
  116. data/node_modules/govuk-frontend/dist/govuk/helpers/_visually-hidden.scss +13 -11
  117. data/node_modules/govuk-frontend/dist/govuk/objects/_grid.scss +4 -2
  118. data/node_modules/govuk-frontend/dist/govuk/objects/_width-container.scss +10 -9
  119. data/node_modules/govuk-frontend/dist/govuk/overrides/_display.scss +2 -0
  120. data/node_modules/govuk-frontend/dist/govuk/overrides/_index.scss +3 -0
  121. data/node_modules/govuk-frontend/dist/govuk/overrides/_spacing.scss +5 -1
  122. data/node_modules/govuk-frontend/dist/govuk/overrides/_text-align.scss +2 -0
  123. data/node_modules/govuk-frontend/dist/govuk/overrides/_typography.scss +7 -2
  124. data/node_modules/govuk-frontend/dist/govuk/overrides/_width.scss +3 -0
  125. data/node_modules/govuk-frontend/dist/govuk/settings/_assets.scss +18 -0
  126. data/node_modules/govuk-frontend/dist/govuk/settings/_colours-functional.scss +28 -4
  127. data/node_modules/govuk-frontend/dist/govuk/settings/_links.scss +3 -2
  128. data/node_modules/govuk-frontend/dist/govuk/settings/_measurements.scss +8 -16
  129. data/node_modules/govuk-frontend/dist/govuk/settings/_typography-font.scss +4 -1
  130. data/node_modules/govuk-frontend/dist/govuk/settings/_warnings.scss +15 -2
  131. data/node_modules/govuk-frontend/dist/govuk/tools/_exports.scss +3 -2
  132. data/node_modules/govuk-frontend/dist/govuk/tools/_font-url.scss +13 -5
  133. data/node_modules/govuk-frontend/dist/govuk/tools/_if.scss +24 -0
  134. data/node_modules/govuk-frontend/dist/govuk/tools/_image-url.scss +13 -5
  135. data/node_modules/govuk-frontend/dist/govuk/tools/_index.scss +1 -0
  136. data/node_modules/govuk-frontend/dist/govuk/tools/_px-to-em.scss +5 -3
  137. data/node_modules/govuk-frontend/dist/govuk/tools/_px-to-rem.scss +4 -2
  138. data/node_modules/govuk-frontend/dist/govuk/utilities/_clearfix.scss +3 -0
  139. data/node_modules/govuk-frontend/dist/govuk/utilities/_index.scss +1 -0
  140. data/node_modules/govuk-frontend/dist/govuk/utilities/_visually-hidden.scss +3 -0
  141. data/node_modules/govuk-frontend/dist/govuk-prototype-kit/init.scss +3 -1
  142. data/package-lock.json +1302 -4959
  143. data/package.json +5 -4
  144. metadata +74 -80
  145. data/.github/ISSUE_TEMPLATE.md +0 -13
@@ -1,6 +1,12 @@
1
1
  ////
2
2
  /// @group helpers/spacing
3
3
  ////
4
+ @use "sass:map";
5
+ @use "sass:math";
6
+ @use "sass:meta";
7
+
8
+ @import "../tools/if";
9
+ @import "../helpers/media-queries";
4
10
 
5
11
  /// Single point spacing
6
12
  ///
@@ -29,7 +35,7 @@
29
35
  /// @access public
30
36
 
31
37
  @function govuk-spacing($spacing-point) {
32
- $actual-input-type: type-of($spacing-point);
38
+ $actual-input-type: meta.type-of($spacing-point);
33
39
  @if $actual-input-type != "number" {
34
40
  @error "Expected a number (integer), but got a "
35
41
  + "#{$actual-input-type}.";
@@ -38,15 +44,15 @@
38
44
  $is-negative: false;
39
45
  @if $spacing-point < 0 {
40
46
  $is-negative: true;
41
- $spacing-point: abs($spacing-point);
47
+ $spacing-point: math.abs($spacing-point);
42
48
  }
43
49
 
44
- @if not map-has-key($govuk-spacing-points, $spacing-point) {
50
+ @if not map.has-key($govuk-spacing-points, $spacing-point) {
45
51
  @error "Unknown spacing variable `#{$spacing-point}`. Make sure you are using a point from the spacing scale in `_settings/spacing.scss`.";
46
52
  }
47
53
 
48
- $value: map-get($govuk-spacing-points, $spacing-point);
49
- @return if($is-negative, $value * -1, $value);
54
+ $value: map.get($govuk-spacing-points, $spacing-point);
55
+ @return govuk-if($is-negative, $value * -1, $value);
50
56
  }
51
57
 
52
58
  /// Responsive spacing
@@ -75,19 +81,19 @@
75
81
  $important: false,
76
82
  $adjustment: false
77
83
  ) {
78
- $actual-input-type: type-of($responsive-spacing-point);
84
+ $actual-input-type: meta.type-of($responsive-spacing-point);
79
85
  @if $actual-input-type != "number" {
80
86
  @error "Expected a number (integer), but got a " + "#{$actual-input-type}.";
81
87
  }
82
88
 
83
- @if not map-has-key($govuk-spacing-responsive-scale, $responsive-spacing-point) {
89
+ @if not map.has-key($govuk-spacing-responsive-scale, $responsive-spacing-point) {
84
90
  @error "Unknown spacing point `#{$responsive-spacing-point}`. Make sure you are using a point from the "
85
91
  + "responsive spacing scale in `_settings/spacing.scss`.";
86
92
  }
87
93
 
88
94
  // Make sure that the return value from `_settings/spacing.scss` is a map.
89
- $scale-map: map-get($govuk-spacing-responsive-scale, $responsive-spacing-point);
90
- $actual-map-type: type-of($scale-map);
95
+ $scale-map: map.get($govuk-spacing-responsive-scale, $responsive-spacing-point);
96
+ $actual-map-type: meta.type-of($scale-map);
91
97
  @if $actual-map-type != "map" {
92
98
  @error "Expected a number (integer), but got a "
93
99
  + "#{$actual-map-type}. Make sure you are using a map to set the responsive spacing in `_settings/spacing.scss`)";
@@ -102,16 +108,16 @@
102
108
  // The 'null' breakpoint is for mobile.
103
109
  @if not $breakpoint {
104
110
  @if $direction == all {
105
- #{$property}: $breakpoint-value if($important, !important, null);
111
+ #{$property}: $breakpoint-value govuk-if($important, !important);
106
112
  } @else {
107
- #{$property}-#{$direction}: $breakpoint-value if($important, !important, null);
113
+ #{$property}-#{$direction}: $breakpoint-value govuk-if($important, !important);
108
114
  }
109
115
  } @else {
110
116
  @media #{govuk-from-breakpoint($breakpoint)} {
111
117
  @if $direction == all {
112
- #{$property}: $breakpoint-value if($important, !important, null);
118
+ #{$property}: $breakpoint-value govuk-if($important, !important);
113
119
  } @else {
114
- #{$property}-#{$direction}: $breakpoint-value if($important, !important, null);
120
+ #{$property}-#{$direction}: $breakpoint-value govuk-if($important, !important);
115
121
  }
116
122
  }
117
123
  }
@@ -1,8 +1,21 @@
1
1
  ////
2
2
  /// @group helpers/typography
3
3
  ////
4
-
4
+ @use "sass:map";
5
+ @use "sass:math";
6
+ @use "sass:string";
7
+
8
+ @import "../settings/assets";
9
+ @import "../settings/colours-functional";
10
+ @import "../settings/spacing";
11
+ @import "../settings/typography-font";
12
+ @import "../settings/warnings";
13
+ @import "../tools/font-url";
5
14
  @import "../tools/px-to-rem";
15
+ @import "../tools/if";
16
+ @import "font-faces";
17
+ @import "media-queries";
18
+ @import "spacing";
6
19
 
7
20
  /// 'Common typography' helper
8
21
  ///
@@ -32,14 +45,16 @@
32
45
  ///
33
46
  /// Sets the text colour, including a suitable override for print.
34
47
  ///
48
+ /// @deprecated
35
49
  /// @access public
36
50
 
37
51
  @mixin govuk-text-colour {
38
- color: govuk-functional-colour(text);
52
+ @include _warning(
53
+ "govuk-text-colour",
54
+ "The `govuk-text-colour` mixin is deprecated. Use `color: govuk-colour(text)` instead."
55
+ );
39
56
 
40
- @media print {
41
- color: govuk-functional-colour(print-text);
42
- }
57
+ color: govuk-functional-colour(text);
43
58
  }
44
59
 
45
60
  /// Regular font weight helper
@@ -49,7 +64,7 @@
49
64
  /// @access public
50
65
 
51
66
  @mixin govuk-typography-weight-regular($important: false) {
52
- font-weight: $govuk-font-weight-regular if($important, !important, null);
67
+ font-weight: $govuk-font-weight-regular govuk-if($important, !important);
53
68
  }
54
69
 
55
70
  /// Bold font weight helper
@@ -59,7 +74,7 @@
59
74
  /// @access public
60
75
 
61
76
  @mixin govuk-typography-weight-bold($important: false) {
62
- font-weight: $govuk-font-weight-bold if($important, !important, null);
77
+ font-weight: $govuk-font-weight-bold govuk-if($important, !important);
63
78
  }
64
79
 
65
80
  /// Tabular number helper
@@ -76,7 +91,7 @@
76
91
  /// @access public
77
92
 
78
93
  @mixin govuk-font-tabular-numbers($important: false) {
79
- font-variant-numeric: tabular-nums if($important, !important, null);
94
+ font-variant-numeric: tabular-nums govuk-if($important, !important);
80
95
  }
81
96
 
82
97
  /// Word break helper
@@ -90,10 +105,10 @@
90
105
 
91
106
  @mixin govuk-text-break-word($important: false) {
92
107
  // IE 11 and Edge 16–17 only support the non-standard `word-wrap` property
93
- word-wrap: break-word if($important, !important, null);
108
+ word-wrap: break-word govuk-if($important, !important);
94
109
 
95
110
  // All other browsers support `overflow-wrap`
96
- overflow-wrap: break-word if($important, !important, null);
111
+ overflow-wrap: break-word govuk-if($important, !important);
97
112
  }
98
113
 
99
114
  /// Convert line-heights specified in pixels into a relative value, unless
@@ -107,8 +122,8 @@
107
122
  /// @access private
108
123
 
109
124
  @function _govuk-line-height($line-height, $font-size) {
110
- @if not unitless($line-height) and unit($line-height) == unit($font-size) {
111
- $line-height: $line-height / $font-size;
125
+ @if not math.is-unitless($line-height) and math.unit($line-height) == math.unit($font-size) {
126
+ $line-height: math.div($line-height, $font-size);
112
127
  }
113
128
 
114
129
  @return $line-height;
@@ -153,21 +168,21 @@
153
168
  @mixin govuk-font-size($size, $line-height: false, $important: false) {
154
169
  // Flag font sizes that start with underscores so we can suppress warnings on
155
170
  // deprecated sizes used internally, for example `govuk-font($size: "_14")`
156
- $size-internal-use-only: str-slice(#{$size}, 1, 1) == "_";
171
+ $size-internal-use-only: string.slice(#{$size}, 1, 1) == "_";
157
172
 
158
173
  // Remove underscore from font sizes flagged for internal use
159
174
  @if $size-internal-use-only {
160
- $size: str-slice(#{$size}, 2);
175
+ $size: string.slice(#{$size}, 2);
161
176
  }
162
177
 
163
178
  // Check for a font map exactly matching the given size
164
- $font-map: map-get($govuk-typography-scale, $size);
179
+ $font-map: map.get($govuk-typography-scale, $size);
165
180
 
166
181
  // No match? Try with string type (e.g. $size: "16" not 16)
167
182
  @if not $font-map {
168
- @each $font-size in map-keys($govuk-typography-scale) {
183
+ @each $font-size in map.keys($govuk-typography-scale) {
169
184
  @if not $font-map and "#{$font-size}" == "#{$size}" {
170
- $font-map: map-get($govuk-typography-scale, $font-size);
185
+ $font-map: map.get($govuk-typography-scale, $font-size);
171
186
  }
172
187
  }
173
188
  }
@@ -178,39 +193,46 @@
178
193
  }
179
194
 
180
195
  // Check for a deprecation within the type scale
181
- $deprecation: map-get($font-map, "deprecation");
196
+ $deprecation: map.get($font-map, "deprecation");
182
197
 
183
198
  @if $deprecation {
184
199
  // Warn on deprecated font sizes unless flagged for internal use
185
200
  @if not $size-internal-use-only {
186
- @include _warning(map-get($deprecation, "key"), map-get($deprecation, "message"));
201
+ @include _warning(map.get($deprecation, "key"), map.get($deprecation, "message"));
187
202
  }
188
203
 
189
204
  // remove the deprecation map keys so they do not break the breakpoint loop
190
- $font-map: map-remove($font-map, "deprecation");
205
+ $font-map: map.remove($font-map, "deprecation");
191
206
  }
192
207
 
193
208
  @each $breakpoint, $breakpoint-map in $font-map {
194
- $font-size: map-get($breakpoint-map, "font-size");
209
+ $font-size: map.get($breakpoint-map, "font-size");
195
210
  $font-size-rem: govuk-px-to-rem($font-size);
196
211
 
197
212
  // $calculated-line-height is a separate variable from $line-height,
198
213
  // as otherwise the value would get redefined with each loop and
199
214
  // eventually break _govuk-line-height.
200
- //
215
+ // 1. See if the function was called with a specific line-height
216
+ $calculated-line-height: $line-height;
217
+ // 2. Default to the breakpoint-map if no specific value was given
218
+ @if not $calculated-line-height {
219
+ $calculated-line-height: map.get($breakpoint-map, "line-height");
220
+ }
221
+
222
+ // 3. Turn the value into a unitless line-height if possible
201
223
  // We continue to call the param $line-height to stay consistent with the
202
224
  // naming with govuk-font.
203
225
  $calculated-line-height: _govuk-line-height(
204
- $line-height: if($line-height, $line-height, map-get($breakpoint-map, "line-height")),
226
+ $line-height: $calculated-line-height,
205
227
  $font-size: $font-size
206
228
  );
207
229
 
208
230
  // Mark rules as !important if $important is true - this will result in
209
231
  // these variables becoming strings, so this needs to happen *after* they
210
232
  // are used in calculations
211
- $font-size: $font-size if($important, !important, null);
212
- $font-size-rem: $font-size-rem if($important, !important, null);
213
- $calculated-line-height: $calculated-line-height if($important, !important, null);
233
+ $font-size: $font-size govuk-if($important, !important);
234
+ $font-size-rem: $font-size-rem govuk-if($important, !important);
235
+ $calculated-line-height: $calculated-line-height govuk-if($important, !important);
214
236
 
215
237
  @if not $breakpoint {
216
238
  font-size: $font-size-rem;
@@ -2,6 +2,8 @@
2
2
  /// @group helpers/accessibility
3
3
  ////
4
4
 
5
+ @import "../tools/if";
6
+
5
7
  /// Helper function containing the common code for the following two mixins
6
8
  ///
7
9
  /// @link https://snook.ca/archives/html_and_css/hiding-content-for-accessibility
@@ -14,28 +16,28 @@
14
16
  /// @access private
15
17
 
16
18
  @mixin _govuk-visually-hide-content($important: true) {
17
- position: absolute if($important, !important, null);
19
+ position: absolute govuk-if($important, !important);
18
20
 
19
- width: 1px if($important, !important, null);
20
- height: 1px if($important, !important, null);
21
+ width: 1px govuk-if($important, !important);
22
+ height: 1px govuk-if($important, !important);
21
23
  // If margin is set to a negative value it can cause text to be announced in
22
24
  // the wrong order in VoiceOver for OSX
23
- margin: 0 if($important, !important, null);
24
- padding: 0 if($important, !important, null);
25
+ margin: 0 govuk-if($important, !important);
26
+ padding: 0 govuk-if($important, !important);
25
27
 
26
- overflow: hidden if($important, !important, null);
28
+ overflow: hidden govuk-if($important, !important);
27
29
 
28
30
  // `clip` is needed for IE11 support
29
- clip: rect(0 0 0 0) if($important, !important, null);
30
- -webkit-clip-path: inset(50%) if($important, !important, null);
31
- clip-path: inset(50%) if($important, !important, null);
31
+ clip: rect(0 0 0 0) govuk-if($important, !important);
32
+ -webkit-clip-path: inset(50%) govuk-if($important, !important);
33
+ clip-path: inset(50%) govuk-if($important, !important);
32
34
 
33
- border: 0 if($important, !important, null);
35
+ border: 0 govuk-if($important, !important);
34
36
 
35
37
  // For long content, line feeds are not interpreted as spaces and small width
36
38
  // causes content to wrap 1 word per line:
37
39
  // https://medium.com/@jessebeach/beware-smushed-off-screen-accessible-text-5952a4c2cbfe
38
- white-space: nowrap if($important, !important, null);
40
+ white-space: nowrap govuk-if($important, !important);
39
41
 
40
42
  // Prevent users from selecting or copying visually-hidden text. This prevents
41
43
  // a user unintentionally copying more text than they intended and needing to
@@ -1,3 +1,5 @@
1
+ @use "sass:map";
2
+
1
3
  @import "../base";
2
4
 
3
5
  @include govuk-exports("govuk/objects/grid") {
@@ -7,7 +9,7 @@
7
9
  margin-left: -($govuk-gutter-half);
8
10
  }
9
11
 
10
- @each $width in map-keys($govuk-grid-widths) {
12
+ @each $width in map.keys($govuk-grid-widths) {
11
13
  .govuk-grid-column-#{$width} {
12
14
  @include govuk-grid-column($width);
13
15
  }
@@ -16,7 +18,7 @@
16
18
  // These *must* be defined in a separate loop as they have the same
17
19
  // specificity as the non-breakpoint specific classes, so need to appear after
18
20
  // them in the outputted CSS
19
- @each $width in map-keys($govuk-grid-widths) {
21
+ @each $width in map.keys($govuk-grid-widths) {
20
22
  .govuk-grid-column-#{$width}-from-desktop {
21
23
  @include govuk-grid-column($width, $at: desktop);
22
24
  }
@@ -1,8 +1,9 @@
1
- @import "../base";
2
-
3
1
  ////
4
2
  /// @group objects/layout
5
3
  ////
4
+ @use "sass:string";
5
+
6
+ @import "../base";
6
7
 
7
8
  /// Width container mixin
8
9
  ///
@@ -26,14 +27,14 @@
26
27
  margin-left: $govuk-gutter-half;
27
28
 
28
29
  // Respect 'display cutout' safe area (avoids notches and rounded corners)
29
- @supports (margin: unquote("max(calc(0px))")) {
30
+ @supports (margin: string.unquote("max(calc(0px))")) {
30
31
  $gutter-safe-area-right: calc(#{$govuk-gutter-half} + env(safe-area-inset-right));
31
32
  $gutter-safe-area-left: calc(#{$govuk-gutter-half} + env(safe-area-inset-left));
32
33
 
33
34
  // Use max() to pick largest margin, default or with safe area
34
35
  // Escaped due to Sass max() vs. CSS native max()
35
- margin-right: unquote("max(#{$govuk-gutter-half}, #{$gutter-safe-area-right})");
36
- margin-left: unquote("max(#{$govuk-gutter-half}, #{$gutter-safe-area-left})");
36
+ margin-right: string.unquote("max(#{$govuk-gutter-half}, #{$gutter-safe-area-right})");
37
+ margin-left: string.unquote("max(#{$govuk-gutter-half}, #{$gutter-safe-area-left})");
37
38
  }
38
39
 
39
40
  // On tablet, add full width gutters
@@ -42,14 +43,14 @@
42
43
  margin-left: $govuk-gutter;
43
44
 
44
45
  // Respect 'display cutout' safe area (avoids notches and rounded corners)
45
- @supports (margin: unquote("max(calc(0px))")) {
46
+ @supports (margin: string.unquote("max(calc(0px))")) {
46
47
  $gutter-safe-area-right: calc(#{$govuk-gutter-half} + env(safe-area-inset-right));
47
48
  $gutter-safe-area-left: calc(#{$govuk-gutter-half} + env(safe-area-inset-left));
48
49
 
49
50
  // Use max() to pick largest margin, default or with safe area
50
51
  // Escaped due to Sass max() vs. CSS native max()
51
- margin-right: unquote("max(#{$govuk-gutter}, #{$gutter-safe-area-right})");
52
- margin-left: unquote("max(#{$govuk-gutter}, #{$gutter-safe-area-left})");
52
+ margin-right: string.unquote("max(#{$govuk-gutter}, #{$gutter-safe-area-right})");
53
+ margin-left: string.unquote("max(#{$govuk-gutter}, #{$gutter-safe-area-left})");
53
54
  }
54
55
  }
55
56
 
@@ -61,7 +62,7 @@
61
62
 
62
63
  // Since a safe area may have previously been set above,
63
64
  // we need to duplicate this margin that centers the page.
64
- @supports (margin: unquote("max(calc(0px))")) {
65
+ @supports (margin: string.unquote("max(calc(0px))")) {
65
66
  margin-right: auto;
66
67
  margin-left: auto;
67
68
  }
@@ -1,3 +1,5 @@
1
+ @import "../tools/exports";
2
+
1
3
  // stylelint-disable declaration-no-important
2
4
  @include govuk-exports("govuk/overrides/display") {
3
5
  .govuk-\!-display-inline {
@@ -1,3 +1,6 @@
1
+ @import "../settings/spacing";
2
+ @import "../tools/exports";
3
+ @import "../helpers/spacing";
1
4
  @import "display";
2
5
  @import "spacing";
3
6
  @import "text-align";
@@ -1,6 +1,10 @@
1
1
  ////
2
2
  /// @group overrides
3
3
  ////
4
+ @use "sass:map";
5
+ @import "../settings/spacing";
6
+ @import "../tools/exports";
7
+ @import "../helpers/spacing";
4
8
 
5
9
  // stylelint-disable declaration-no-important
6
10
 
@@ -62,7 +66,7 @@ $_spacing-directions: ("top", "right", "bottom", "left") !default;
62
66
  ///
63
67
  /// @access private
64
68
  @mixin _govuk-generate-static-spacing-overrides($property) {
65
- @each $spacing-point in map-keys($govuk-spacing-points) {
69
+ @each $spacing-point in map.keys($govuk-spacing-points) {
66
70
  .govuk-\!-static-#{$property}-#{$spacing-point} {
67
71
  #{$property}: govuk-spacing($spacing-point) !important;
68
72
  }
@@ -1,3 +1,5 @@
1
+ @import "../tools/exports";
2
+
1
3
  // stylelint-disable declaration-no-important
2
4
  @include govuk-exports("govuk/overrides/text-align") {
3
5
  .govuk-\!-text-align-left {
@@ -1,3 +1,8 @@
1
+ @use "sass:map";
2
+ @import "../settings/typography-responsive";
3
+ @import "../tools/exports";
4
+ @import "../helpers/typography";
5
+
1
6
  @include govuk-exports("govuk/overrides/typography") {
2
7
  // Font size and line height
3
8
 
@@ -5,10 +10,10 @@
5
10
  // typography scale eg .govuk-\!-font-size-80
6
11
  @each $size, $font-map in $govuk-typography-scale {
7
12
  .govuk-\!-font-size-#{$size} {
8
- $font-map: map-get($govuk-typography-scale, $size);
13
+ $font-map: map.get($govuk-typography-scale, $size);
9
14
 
10
15
  // Add underscore to deprecated typography scale keys
11
- @if map-has-key($font-map, "deprecation") {
16
+ @if map.has-key($font-map, "deprecation") {
12
17
  $size: _#{$size};
13
18
  }
14
19
 
@@ -1,3 +1,6 @@
1
+ @import "../tools/exports";
2
+ @import "../helpers/media-queries";
3
+
1
4
  // stylelint-disable declaration-no-important
2
5
  @include govuk-exports("govuk/overrides/width") {
3
6
  .govuk-\!-width-full {
@@ -50,6 +50,15 @@ $govuk-fonts-path: "#{$govuk-assets-path}fonts/" !default;
50
50
  ///
51
51
  /// $govuk-image-url-function: 'my-url-handler';
52
52
  ///
53
+ /// @example scss - From an external module
54
+ ///
55
+ /// @use "sass:meta";
56
+ /// // Include the module containing the handler function
57
+ /// @use "url-handlers";
58
+ ///
59
+ /// // Then pass the handler function using `meta.get-function`
60
+ /// $govuk-image-url-function: meta.get-function("image-url", $module: "url-handlers");
61
+ ///
53
62
  /// @access public
54
63
 
55
64
  $govuk-image-url-function: false !default;
@@ -77,6 +86,15 @@ $govuk-image-url-function: false !default;
77
86
  ///
78
87
  /// $govuk-font-url-function: 'my-url-handler';
79
88
  ///
89
+ /// @example scss - From an external module
90
+ ///
91
+ /// @use "sass:meta";
92
+ /// // Include the module containing the handler function
93
+ /// @use "url-handlers";
94
+ ///
95
+ /// // Then pass the handler function using `meta.get-function`
96
+ /// $govuk-font-url-function: meta.get-function("font-url", $module: "url-handlers");
97
+ ///
80
98
  /// @access public
81
99
 
82
100
  $govuk-font-url-function: false !default;
@@ -1,8 +1,11 @@
1
1
  ////
2
2
  /// @group settings/colours
3
3
  ////
4
+ @use "sass:list";
5
+ @use "sass:map";
6
+ @use "sass:meta";
4
7
 
5
- @import "../helpers/colour";
8
+ @import "../settings/warnings";
6
9
 
7
10
  /// Default definitions of the functional colours
8
11
  ///
@@ -99,6 +102,27 @@ $govuk-default-functional-colours: (
99
102
  )
100
103
  );
101
104
 
105
+ /// Validates and merges functional colour overrides with defaults.
106
+ ///
107
+ /// Throws an error if any provided colour name does not exist in the default
108
+ /// functional colours map.
109
+ ///
110
+ /// @param {Map} $colours Functional colour overrides.
111
+ /// @param {Map} $defaults Default functional colours.
112
+ /// @return {Map} Merged functional colours.
113
+ /// @access private
114
+ @function _govuk-define-functional-colours($colours, $defaults) {
115
+ $existing-colours: map.keys($defaults);
116
+
117
+ @each $colour-name, $colour in $colours {
118
+ @if not list.index($existing-colours, $colour-name) {
119
+ @error 'Unknown colour `#{$colour-name}` (available colours: #{$existing-colours})';
120
+ }
121
+ }
122
+
123
+ @return map.merge($defaults, $colours);
124
+ }
125
+
102
126
  /// Functional colours for the GOV.UK palette.
103
127
  ///
104
128
  /// Each functional colour is represented by a name (for example `'brand'`) to
@@ -156,14 +180,14 @@ $_govuk-deprecated-applied-colour-variables: () !default;
156
180
  /// @param {String} Name of variable to check
157
181
  /// @access private
158
182
  @mixin _warn-if-applied-colour-variable-set($functional-colour-name) {
159
- @if not index($_govuk-deprecated-applied-colour-variables, $functional-colour-name) {
160
- @if variable-exists("govuk-#{$functional-colour-name}-colour") {
183
+ @if not list.index($_govuk-deprecated-applied-colour-variables, $functional-colour-name) {
184
+ @if meta.variable-exists("govuk-#{$functional-colour-name}-colour") {
161
185
  $deprecation-message: "Setting \`$govuk-#{$functional-colour-name}-colour\` no longer has any effect. Use \`$govuk-functional-colours: (#{$functional-colour-name}: <NEW_COLOUR_VALUE>);\` instead.";
162
186
 
163
187
  @include _warning("applied-colour-variables", $deprecation-message);
164
188
  }
165
189
 
166
- $_govuk-deprecated-applied-colour-variables: append(
190
+ $_govuk-deprecated-applied-colour-variables: list.append(
167
191
  $_govuk-deprecated-applied-colour-variables,
168
192
  $functional-colour-name
169
193
  ) !global;
@@ -1,6 +1,7 @@
1
1
  ////
2
2
  /// @group settings/links
3
3
  ////
4
+ @use "sass:string";
4
5
 
5
6
  /// Thickness of link underlines
6
7
  ///
@@ -15,7 +16,7 @@
15
16
  /// @type Number
16
17
  /// @access public
17
18
 
18
- $govuk-link-underline-thickness: unquote("max(1px, .0625rem)") !default;
19
+ $govuk-link-underline-thickness: string.unquote("max(1px, .0625rem)") !default;
19
20
 
20
21
  /// Offset of link underlines from text baseline
21
22
  ///
@@ -44,6 +45,6 @@ $govuk-link-underline-offset: 0.1578em !default;
44
45
  /// @type Number
45
46
  /// @access public
46
47
 
47
- $govuk-link-hover-underline-thickness: unquote("max(3px, .1875rem, .12em)") !default;
48
+ $govuk-link-hover-underline-thickness: string.unquote("max(3px, .1875rem, .12em)") !default;
48
49
 
49
50
  /*# sourceMappingURL=_links.scss.map */
@@ -11,6 +11,8 @@
11
11
  /// @type Number
12
12
  /// @access public
13
13
 
14
+ @use "sass:math";
15
+
14
16
  $govuk-page-width: 960px !default;
15
17
 
16
18
  /// Map of grid column widths
@@ -19,21 +21,11 @@ $govuk-page-width: 960px !default;
19
21
  /// @access public
20
22
 
21
23
  $govuk-grid-widths: (
22
- one-quarter: (
23
- 100% / 4
24
- ),
25
- one-third: (
26
- 100% / 3
27
- ),
28
- one-half: (
29
- 100% / 2
30
- ),
31
- two-thirds: (
32
- 200% / 3
33
- ),
34
- three-quarters: (
35
- 300% / 4
36
- ),
24
+ one-quarter: math.div(100%, 4),
25
+ one-third: math.div(100%, 3),
26
+ one-half: math.div(100%, 2),
27
+ two-thirds: math.div(200%, 3),
28
+ three-quarters: math.div(300%, 4),
37
29
  full: 100%
38
30
  ) !default;
39
31
 
@@ -49,7 +41,7 @@ $govuk-gutter: 30px !default;
49
41
  /// @type Number
50
42
  /// @access public
51
43
 
52
- $govuk-gutter-half: $govuk-gutter / 2;
44
+ $govuk-gutter-half: math.div($govuk-gutter, 2);
53
45
 
54
46
  // =========================================================
55
47
  // Borders
@@ -1,6 +1,9 @@
1
1
  ////
2
2
  /// @group settings/typography
3
3
  ////
4
+ @use "sass:list";
5
+
6
+ @import "../tools/if";
4
7
 
5
8
  // =========================================================
6
9
  // Font families
@@ -31,7 +34,7 @@ $govuk-font-family-print: sans-serif !default;
31
34
  /// @type Boolean
32
35
  /// @access public
33
36
 
34
- $govuk-include-default-font-face: if(index($govuk-font-family, "GDS Transport"), true, false) !default;
37
+ $govuk-include-default-font-face: govuk-if(list.index($govuk-font-family, "GDS Transport"), true, false) !default;
35
38
 
36
39
  // =========================================================
37
40
  // Font weights