govuk_publishing_components 25.3.1 → 25.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/govuk_publishing_components/analytics/track-click.js +9 -3
  3. data/app/assets/javascripts/govuk_publishing_components/components/layout-super-navigation-header.js +3 -7
  4. data/app/assets/javascripts/govuk_publishing_components/modules.js +1 -1
  5. data/app/assets/stylesheets/govuk_publishing_components/components/_image-card.scss +4 -0
  6. data/app/assets/stylesheets/govuk_publishing_components/components/_layout-super-navigation-header.scss +22 -24
  7. data/app/assets/stylesheets/govuk_publishing_components/components/_step-by-step-nav-header.scss +2 -4
  8. data/app/views/govuk_publishing_components/components/_image_card.html.erb +10 -7
  9. data/app/views/govuk_publishing_components/components/_layout_for_public.html.erb +5 -2
  10. data/app/views/govuk_publishing_components/components/docs/image_card.yml +25 -0
  11. data/lib/govuk_publishing_components/presenters/image_card_helper.rb +3 -2
  12. data/lib/govuk_publishing_components/version.rb +1 -1
  13. data/node_modules/govuk-frontend/govuk/all.js +61 -3
  14. data/node_modules/govuk-frontend/govuk/components/breadcrumbs/_index.scss +1 -0
  15. data/node_modules/govuk-frontend/govuk/components/button/_index.scss +10 -4
  16. data/node_modules/govuk-frontend/govuk/components/checkboxes/_index.scss +49 -34
  17. data/node_modules/govuk-frontend/govuk/components/checkboxes/checkboxes.js +61 -3
  18. data/node_modules/govuk-frontend/govuk/components/checkboxes/fixtures.json +122 -41
  19. data/node_modules/govuk-frontend/govuk/components/checkboxes/macro-options.json +12 -0
  20. data/node_modules/govuk-frontend/govuk/components/checkboxes/template.njk +37 -39
  21. data/node_modules/govuk-frontend/govuk/components/footer/_index.scss +22 -10
  22. data/node_modules/govuk-frontend/govuk/components/header/_index.scss +11 -7
  23. data/node_modules/govuk-frontend/govuk/components/header/fixtures.json +18 -18
  24. data/node_modules/govuk-frontend/govuk/components/header/template.njk +5 -11
  25. data/node_modules/govuk-frontend/govuk/components/input/_index.scss +4 -0
  26. data/node_modules/govuk-frontend/govuk/components/skip-link/_index.scss +2 -0
  27. data/node_modules/govuk-frontend/govuk/components/warning-text/_index.scss +0 -1
  28. data/node_modules/govuk-frontend/govuk/core/_template.scss +0 -1
  29. data/node_modules/govuk-frontend/govuk/helpers/_links.scss +6 -0
  30. data/node_modules/govuk-frontend/govuk/objects/_button-group.scss +9 -2
  31. data/node_modules/govuk-frontend/govuk/objects/_width-container.scss +4 -0
  32. data/node_modules/govuk-frontend/govuk/template.njk +1 -1
  33. data/node_modules/govuk-frontend/package.json +1 -1
  34. metadata +4 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4a7604846e82e7d5741665c02447fd53ed8b8e144b93764dffaedf745a4751a4
4
- data.tar.gz: bcb4e7566730869377d7c1570acc4dce95200267a3d3f79567d82a266d878d61
3
+ metadata.gz: 4abd01ab2cfef631996c10f29cc13080322cb8df58ebd7da2eccd2c310c26d8b
4
+ data.tar.gz: 6707f734f671ba73b7e8350b033c0a7ba91562ad8fd05a2b8f62f649e2fcbb2a
5
5
  SHA512:
6
- metadata.gz: 40cf20a95a9129391d7395f71421ebfcf38656427a2b2f6f9e309164513751080bbb5eee944633c5d42a4ab7051ac1a26215fce1e97f45d0c97bff5017dcb602
7
- data.tar.gz: 3c2673f73683ca6375a62ec8c94ac7ee79bfd9a965cff5ba008d56f93a3c3fff41c473f2f9e79b74d0f2ba40fa23c093b805a782375b5030b1dc3eddd87404d2
6
+ metadata.gz: 0be2f94551c472261bb6bf1b2f0e4adb0e1a2b60ab764ae99976c3b4fe0f6413e601d9c465e990da5a329aa276030f810cf40f63a23678b7864ca64f764d5685
7
+ data.tar.gz: 8e9bfa9e1c683d9211c2a8a796f353dfeb834c3e56c14123ac5ef7268c9eafd378fc0cdd06ea14afaddbe6ae92f3fbbbdaa511462d0b6b9386c4bd5473db43b7
@@ -10,14 +10,20 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
10
10
  this.$module = $module[0]
11
11
  this.$module.handleClick = this.handleClick.bind(this)
12
12
  var trackLinksOnly = this.$module.hasAttribute('data-track-links-only')
13
+ var limitToElementClass = this.$module.getAttribute('data-limit-to-element-class')
13
14
 
14
15
  var that = this
15
16
  // add a listener to the whole element
16
17
  this.$module.addEventListener('click', function (e) {
18
+ var target = e.target
17
19
  if (!trackLinksOnly) {
18
- that.$module.handleClick(e.target)
19
- } else if (trackLinksOnly && e.target.tagName === 'A') {
20
- that.$module.handleClick(e.target)
20
+ that.$module.handleClick(target)
21
+ } else if (trackLinksOnly && target.tagName === 'A') {
22
+ if (!limitToElementClass) {
23
+ that.$module.handleClick(target)
24
+ } else if (limitToElementClass && target.closest('.' + limitToElementClass)) {
25
+ that.$module.handleClick(target)
26
+ }
21
27
  }
22
28
  })
23
29
  }
@@ -155,10 +155,6 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
155
155
  }
156
156
 
157
157
  this.$module.style.marginBottom = '0'
158
-
159
- window.removeEventListener('resize', this.resizeHandler, { passive: true })
160
-
161
- this.lastWindowSize = this.windowSize()
162
158
  }
163
159
 
164
160
  // Hide the navigation toggle button and show the navigation submenu:
@@ -166,10 +162,10 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
166
162
  this.$navigationToggle.setAttribute('hidden', 'hidden')
167
163
  this.$navigationMenu.removeAttribute('hidden')
168
164
 
169
- window.addEventListener('resize', this.resizeHandler, { passive: true })
170
-
171
- this.lastWindowSize = this.windowSize()
165
+ this.resizeHandler()
172
166
  }
167
+
168
+ this.lastWindowSize = this.windowSize()
173
169
  }
174
170
 
175
171
  SuperNavigationMegaMenu.prototype.buttonHandler = function (event) {
@@ -7,7 +7,7 @@
7
7
 
8
8
  GOVUK.modules = {
9
9
  find: function (container) {
10
- container = container || $(document)
10
+ container = $(container || document)
11
11
 
12
12
  var modules
13
13
  var moduleSelector = '[data-module]'
@@ -127,6 +127,10 @@
127
127
  margin-bottom: govuk-spacing(1);
128
128
  }
129
129
 
130
+ .gem-c-image-card__list-item--text {
131
+ color: govuk-colour("dark-grey", $legacy: "grey-1");
132
+ }
133
+
130
134
  .gem-c-image-card__list-item-link {
131
135
  line-height: 1.35em;
132
136
  }
@@ -269,7 +269,11 @@ $search-icon-size: 20px;
269
269
  color: $govuk-link-colour;
270
270
 
271
271
  &:hover {
272
- color: govuk-colour("mid-grey");
272
+ color: $govuk-link-hover-colour;
273
+
274
+ @include govuk-media-query($from: "desktop") {
275
+ color: govuk-colour("mid-grey");
276
+ }
273
277
  }
274
278
 
275
279
  &:focus {
@@ -358,6 +362,10 @@ $search-icon-size: 20px;
358
362
  position: absolute;
359
363
  right: 45px;
360
364
 
365
+ &.gem-c-layout-super-navigation-header__open-button {
366
+ border-top-color: govuk-colour("black");
367
+ }
368
+
361
369
  @include govuk-media-query($from: 360px) {
362
370
  &:before {
363
371
  @include chevron("white");
@@ -388,8 +396,19 @@ $search-icon-size: 20px;
388
396
  position: absolute;
389
397
  right: (0 - govuk-spacing(3));
390
398
 
391
- &:hover {
392
- border-color: govuk-colour("black");
399
+ &:after {
400
+ background-color: $govuk-link-colour;
401
+ content: " ";
402
+ left: 0;
403
+ right: 0;
404
+ }
405
+
406
+ &:not(.gem-c-layout-super-navigation-header__open-button):focus {
407
+ &:hover,
408
+ &:after {
409
+ background-color: $govuk-focus-colour;
410
+ border-top-color: $govuk-focus-colour;
411
+ }
393
412
  }
394
413
 
395
414
  @include govuk-media-query($from: 360px) {
@@ -405,22 +424,6 @@ $search-icon-size: 20px;
405
424
  position: relative;
406
425
  float: right;
407
426
 
408
- &:not(.gem-c-layout-super-navigation-header__open-button):hover {
409
- background: none;
410
- color: govuk-colour("light-grey");
411
-
412
- &:after {
413
- content: " ";
414
- left: 0;
415
- right: 0;
416
- }
417
- }
418
-
419
- &:focus:hover:after,
420
- &:after {
421
- content: none;
422
- }
423
-
424
427
  &.gem-c-layout-super-navigation-header__open-button {
425
428
  border-top-color: govuk-colour("black");
426
429
 
@@ -486,7 +489,6 @@ $search-icon-size: 20px;
486
489
 
487
490
  &:focus {
488
491
  color: $govuk-focus-text-colour;
489
- // border-color: $govuk-focus-text-colour;
490
492
 
491
493
  &:after {
492
494
  background-color: $govuk-focus-text-colour;
@@ -501,10 +503,6 @@ $search-icon-size: 20px;
501
503
  &.gem-c-layout-super-navigation-header__open-button {
502
504
  border-top-color: govuk-colour("black");
503
505
 
504
- &:focus {
505
- border-top-color: $govuk-focus-colour;
506
- }
507
-
508
506
  &:before {
509
507
  transform: translateY(20%) rotate(225deg);
510
508
  }
@@ -1,5 +1,7 @@
1
1
  .gem-c-step-nav-header {
2
+ @include govuk-font(24, $weight: bold);
2
3
  @include govuk-text-colour;
4
+
3
5
  position: relative;
4
6
  padding: 10px;
5
7
  background: govuk-colour("light-grey", $legacy: "grey-4");
@@ -15,7 +17,3 @@
15
17
  @include govuk-font(19, $weight: bold);
16
18
  display: block;
17
19
  }
18
-
19
- .gem-c-step-nav-header__title {
20
- @include govuk-font(24, $weight: bold, $line-height: 1);
21
- }
@@ -14,7 +14,6 @@
14
14
  heading_link_classes = %w[
15
15
  gem-c-image-card__title-link
16
16
  govuk-link
17
- govuk-link--no-underline
18
17
  ]
19
18
  heading_link_classes << brand_helper.color_class
20
19
  extra_link_classes = %w[
@@ -48,12 +47,16 @@
48
47
  <% if card_helper.extra_links.any? %>
49
48
  <ul class="gem-c-image-card__list <%= "gem-c-image-card__list--indented" if not card_helper.extra_links_no_indent %>">
50
49
  <% card_helper.extra_links.each do |link| %>
51
- <li class="gem-c-image-card__list-item">
52
- <%= link_to link[:text], link[:href],
53
- class: extra_link_classes,
54
- data: link[:data_attributes]
55
- %>
56
- </li>
50
+ <li class="gem-c-image-card__list-item <%= "gem-c-image-card__list-item--text" if not link[:href].present? %>">
51
+ <% if link[:href].present? %>
52
+ <%= link_to link[:text], link[:href],
53
+ class: extra_link_classes,
54
+ data: link[:data_attributes]
55
+ %>
56
+ <% else %>
57
+ <%= link[:text] %>
58
+ <% end %>
59
+ </li>
57
60
  <% end %>
58
61
  </ul>
59
62
  <% end %>
@@ -11,6 +11,7 @@
11
11
  omit_header ||= false
12
12
  product_name ||= nil
13
13
  show_explore_header ||= false
14
+ draft_watermark ||= false
14
15
  show_search = local_assigns.include?(:show_search) ? local_assigns[:show_search] : true
15
16
  title ||= "GOV.UK - The best place to find government services and information"
16
17
 
@@ -39,6 +40,8 @@
39
40
  # when a) there's content for the emergency or global banner *and* b) when using
40
41
  # the contrained width layout.
41
42
  blue_bar_dedupe = !full_width && global_bar.present?
43
+ body_css_classes = %w(gem-c-layout-for-public govuk-template__body)
44
+ body_css_classes << "draft" if draft_watermark
42
45
  -%>
43
46
  <!DOCTYPE html>
44
47
  <!--[if lt IE 9]><html class="lte-ie8" lang="<%= html_lang %>"><![endif]-->
@@ -72,7 +75,7 @@
72
75
 
73
76
  <%= yield :head %>
74
77
  </head>
75
- <body class="gem-c-layout-for-public govuk-template__body">
78
+ <%= tag.body class: body_css_classes do %>
76
79
  <script>
77
80
  document.body.className = ((document.body.className) ? document.body.className + ' js-enabled' : 'js-enabled');
78
81
  </script>
@@ -147,5 +150,5 @@
147
150
  } %>
148
151
  <% end %>
149
152
  <%= javascript_include_tag 'application' %>
150
- </body>
153
+ <% end %>
151
154
  </html>
@@ -35,6 +35,15 @@ examples:
35
35
  image_alt: "some meaningful alt text please"
36
36
  heading_text: "I am not a heading"
37
37
  heading_level: 0
38
+ with_lazy_loading:
39
+ description: The image can have an attribute of lazy loading. Defaults to auto if not passed.
40
+ data:
41
+ href: "/really-not-a-page"
42
+ image_src: "https://assets.publishing.service.gov.uk/government/uploads/system/uploads/feature/image/62756/s300_courts-of-justice.JPG"
43
+ image_alt: "some meaningful alt text please"
44
+ image_loading: "lazy"
45
+ heading_text: "I am not a heading"
46
+ heading_level: 0
38
47
  with_different_link_size:
39
48
  description: |
40
49
  Set a different font size for the link. Uses the [GOV.UK Frontend heading sizes](https://design-system.service.gov.uk/styles/typography/#headings) but defaults to 19px for legacy reasons. Valid options are `xl`, `l`, `m` and `s`.
@@ -94,6 +103,22 @@ examples:
94
103
  }
95
104
  ]
96
105
  extra_links_no_indent: true
106
+ extra_links_with_no_links:
107
+ description: If `extra_links` are passed to the component without `href` attributes, they are displayed as a simple text list.
108
+ data:
109
+ href: "/government/people/"
110
+ image_src: "https://assets.publishing.service.gov.uk/government/uploads/system/uploads/feature/image/62756/s300_courts-of-justice.JPG"
111
+ image_alt: "some meaningful alt text please"
112
+ heading_text: "John Whiskers MP"
113
+ extra_links: [
114
+ {
115
+ text: "Conservative 2010 to 2016",
116
+ },
117
+ {
118
+ text: "Labour 2007 to 2010",
119
+ }
120
+ ]
121
+ extra_links_no_indent: true
97
122
  extra_links_with_no_main_link:
98
123
  description: If extra links are included, the main link is not needed. Note that in this configuration the image is not a link as no link has been supplied.
99
124
  data:
@@ -4,7 +4,7 @@ module GovukPublishingComponents
4
4
  include ActionView::Helpers
5
5
  include ActionView::Context
6
6
 
7
- attr_reader :href, :href_data_attributes, :extra_links, :large, :extra_links_no_indent, :heading_text, :metadata, :lang
7
+ attr_reader :href, :href_data_attributes, :extra_links, :large, :extra_links_no_indent, :heading_text, :metadata, :lang, :image_loading
8
8
 
9
9
  def initialize(local_assigns)
10
10
  @href = local_assigns[:href]
@@ -12,6 +12,7 @@ module GovukPublishingComponents
12
12
  @extra_links = local_assigns[:extra_links] || []
13
13
  @image_src = local_assigns[:image_src]
14
14
  @image_alt = local_assigns[:image_alt] || ""
15
+ @image_loading = local_assigns[:image_loading] || "auto"
15
16
  @context = local_assigns[:context]
16
17
  @description = local_assigns[:description]
17
18
  @large = local_assigns[:large]
@@ -35,7 +36,7 @@ module GovukPublishingComponents
35
36
  def image
36
37
  if @image_src
37
38
  content_tag(:figure, class: "gem-c-image-card__image-wrapper") do
38
- image_tag(@image_src, class: "gem-c-image-card__image", alt: @image_alt)
39
+ image_tag(@image_src, class: "gem-c-image-card__image", alt: @image_alt, loading: @image_loading)
39
40
  end
40
41
  end
41
42
  end
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = "25.3.1".freeze
2
+ VERSION = "25.7.0".freeze
3
3
  end
@@ -1751,6 +1751,47 @@ Checkboxes.prototype.syncConditionalRevealWithInputState = function ($input) {
1751
1751
  }
1752
1752
  };
1753
1753
 
1754
+ /**
1755
+ * Uncheck other checkboxes
1756
+ *
1757
+ * Find any other checkbox inputs with the same name value, and uncheck them.
1758
+ * This is useful for when a “None of these" checkbox is checked.
1759
+ */
1760
+ Checkboxes.prototype.unCheckAllInputsExcept = function ($input) {
1761
+ var allInputsWithSameName = document.querySelectorAll('input[type="checkbox"][name="' + $input.name + '"]');
1762
+
1763
+ nodeListForEach(allInputsWithSameName, function ($inputWithSameName) {
1764
+ var hasSameFormOwner = ($input.form === $inputWithSameName.form);
1765
+ if (hasSameFormOwner && $inputWithSameName !== $input) {
1766
+ $inputWithSameName.checked = false;
1767
+ }
1768
+ });
1769
+
1770
+ this.syncAllConditionalReveals();
1771
+ };
1772
+
1773
+ /**
1774
+ * Uncheck exclusive inputs
1775
+ *
1776
+ * Find any checkbox inputs with the same name value and the 'exclusive' behaviour,
1777
+ * and uncheck them. This helps prevent someone checking both a regular checkbox and a
1778
+ * "None of these" checkbox in the same fieldset.
1779
+ */
1780
+ Checkboxes.prototype.unCheckExclusiveInputs = function ($input) {
1781
+ var allInputsWithSameNameAndExclusiveBehaviour = document.querySelectorAll(
1782
+ 'input[data-behaviour="exclusive"][type="checkbox"][name="' + $input.name + '"]'
1783
+ );
1784
+
1785
+ nodeListForEach(allInputsWithSameNameAndExclusiveBehaviour, function ($exclusiveInput) {
1786
+ var hasSameFormOwner = ($input.form === $exclusiveInput.form);
1787
+ if (hasSameFormOwner) {
1788
+ $exclusiveInput.checked = false;
1789
+ }
1790
+ });
1791
+
1792
+ this.syncAllConditionalReveals();
1793
+ };
1794
+
1754
1795
  /**
1755
1796
  * Click event handler
1756
1797
  *
@@ -1762,12 +1803,29 @@ Checkboxes.prototype.syncConditionalRevealWithInputState = function ($input) {
1762
1803
  Checkboxes.prototype.handleClick = function (event) {
1763
1804
  var $target = event.target;
1764
1805
 
1765
- // If a checkbox with aria-controls, handle click
1766
- var isCheckbox = $target.getAttribute('type') === 'checkbox';
1806
+ // Ignore clicks on things that aren't checkbox inputs
1807
+ if ($target.type !== 'checkbox') {
1808
+ return
1809
+ }
1810
+
1811
+ // If the checkbox conditionally-reveals some content, sync the state
1767
1812
  var hasAriaControls = $target.getAttribute('aria-controls');
1768
- if (isCheckbox && hasAriaControls) {
1813
+ if (hasAriaControls) {
1769
1814
  this.syncConditionalRevealWithInputState($target);
1770
1815
  }
1816
+
1817
+ // No further behaviour needed for unchecking
1818
+ if (!$target.checked) {
1819
+ return
1820
+ }
1821
+
1822
+ // Handle 'exclusive' checkbox behaviour (ie "None of these")
1823
+ var hasBehaviourExclusive = ($target.getAttribute('data-behaviour') === 'exclusive');
1824
+ if (hasBehaviourExclusive) {
1825
+ this.unCheckAllInputsExcept($target);
1826
+ } else {
1827
+ this.unCheckExclusiveInputs($target);
1828
+ }
1771
1829
  };
1772
1830
 
1773
1831
  (function(undefined) {
@@ -129,6 +129,7 @@
129
129
 
130
130
  .govuk-breadcrumbs__list {
131
131
  display: -webkit-box;
132
+ display: -webkit-flex;
132
133
  display: -ms-flexbox;
133
134
  display: flex;
134
135
  }
@@ -241,6 +241,8 @@
241
241
 
242
242
  display: -webkit-inline-box;
243
243
 
244
+ display: -webkit-inline-flex;
245
+
244
246
  display: -ms-inline-flexbox;
245
247
 
246
248
  display: inline-flex;
@@ -248,6 +250,8 @@
248
250
 
249
251
  -webkit-box-pack: center;
250
252
 
253
+ -webkit-justify-content: center;
254
+
251
255
  -ms-flex-pack: center;
252
256
 
253
257
  justify-content: center;
@@ -260,10 +264,12 @@
260
264
  margin-left: govuk-spacing(2);
261
265
  }
262
266
  vertical-align: middle;
263
- -ms-flex-negative: 0;
264
- flex-shrink: 0;
265
- -ms-flex-item-align: center;
266
- align-self: center;
267
+ -webkit-flex-shrink: 0;
268
+ -ms-flex-negative: 0;
269
+ flex-shrink: 0;
270
+ -webkit-align-self: center;
271
+ -ms-flex-item-align: center;
272
+ align-self: center;
267
273
  }
268
274
 
269
275
  @if $govuk-use-legacy-font {