govuk_publishing_components 25.4.0 → 26.0.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 (36) 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/stylesheets/govuk_publishing_components/components/_image-card.scss +4 -0
  5. data/app/assets/stylesheets/govuk_publishing_components/components/_layout-super-navigation-header.scss +22 -24
  6. data/app/assets/stylesheets/govuk_publishing_components/components/_step-by-step-nav-header.scss +2 -4
  7. data/app/views/govuk_publishing_components/components/_image_card.html.erb +10 -7
  8. data/app/views/govuk_publishing_components/components/_layout_for_public.html.erb +5 -2
  9. data/app/views/govuk_publishing_components/components/docs/image_card.yml +16 -0
  10. data/app/views/govuk_publishing_components/components/layout_for_public/_account-feedback-footer.html.erb +1 -1
  11. data/app/views/govuk_publishing_components/components/layout_for_public/_account-layout.html.erb +1 -1
  12. data/app/views/govuk_publishing_components/components/layout_for_public/_account-navigation.html.erb +3 -3
  13. data/lib/govuk_publishing_components/version.rb +1 -1
  14. data/lib/govuk_publishing_components.rb +1 -0
  15. data/node_modules/govuk-frontend/govuk/all.js +61 -3
  16. data/node_modules/govuk-frontend/govuk/components/breadcrumbs/_index.scss +1 -0
  17. data/node_modules/govuk-frontend/govuk/components/button/_index.scss +10 -4
  18. data/node_modules/govuk-frontend/govuk/components/checkboxes/_index.scss +49 -34
  19. data/node_modules/govuk-frontend/govuk/components/checkboxes/checkboxes.js +61 -3
  20. data/node_modules/govuk-frontend/govuk/components/checkboxes/fixtures.json +122 -41
  21. data/node_modules/govuk-frontend/govuk/components/checkboxes/macro-options.json +12 -0
  22. data/node_modules/govuk-frontend/govuk/components/checkboxes/template.njk +37 -39
  23. data/node_modules/govuk-frontend/govuk/components/footer/_index.scss +22 -10
  24. data/node_modules/govuk-frontend/govuk/components/header/_index.scss +11 -7
  25. data/node_modules/govuk-frontend/govuk/components/header/fixtures.json +18 -18
  26. data/node_modules/govuk-frontend/govuk/components/header/template.njk +5 -11
  27. data/node_modules/govuk-frontend/govuk/components/input/_index.scss +4 -0
  28. data/node_modules/govuk-frontend/govuk/components/skip-link/_index.scss +2 -0
  29. data/node_modules/govuk-frontend/govuk/components/warning-text/_index.scss +0 -1
  30. data/node_modules/govuk-frontend/govuk/core/_template.scss +0 -1
  31. data/node_modules/govuk-frontend/govuk/helpers/_links.scss +6 -0
  32. data/node_modules/govuk-frontend/govuk/objects/_button-group.scss +9 -2
  33. data/node_modules/govuk-frontend/govuk/objects/_width-container.scss +4 -0
  34. data/node_modules/govuk-frontend/govuk/template.njk +1 -1
  35. data/node_modules/govuk-frontend/package.json +1 -1
  36. metadata +20 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d8c8ce0242fc9e1dac0d594933ea4f0edc235315a3fbc1e021d38e000ba28326
4
- data.tar.gz: 36e25da868ef4303c553bf2bbca204a0b765ac87e4b84921984dd2c0da4217e1
3
+ metadata.gz: 5c3fd9e474526fc795f4e36972c920118b87ea55a36296a4b5ed63e5e6fdc116
4
+ data.tar.gz: 84373dc03aa19d36852a9d7766924a42c2a1e97704f23f0829b1723d1bf46e33
5
5
  SHA512:
6
- metadata.gz: 100b3c1fc07b20fedb2acb1d4e2993b8f8bf38e8ab725b3af0d8f409ce71ba6d7c50953b76757852b59429e6b4cf5acaaea0827571279944b585cb3ecd76c3ea
7
- data.tar.gz: 21e3f30700778d5d1b021294a366c00b6c9a407232184201eac41145c415c052432ae05d35e9905721b1ee91e851761de6191ab5c56919177b31f49bc7c2de65
6
+ metadata.gz: e997a780198073f264b340747df742bf7b9540e2f8106f9f29afb16028ea95533a22d4bf1403aa2b027785a9298585ac7700865ede41d7ab42dd1c00c6fcee70
7
+ data.tar.gz: 1d38aaaff509242556aebea94b66fe42001345f93f15513ee42c27f1f71d105e8a2f49e7b2e110f1ca317f5ffbf769e4cc4bc3fb00113a9ca88a00eb1fb28cad
@@ -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) {
@@ -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>
@@ -103,6 +103,22 @@ examples:
103
103
  }
104
104
  ]
105
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
106
122
  extra_links_with_no_main_link:
107
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.
108
124
  data:
@@ -9,7 +9,7 @@
9
9
 
10
10
  <p class="govuk-body govuk-!-margin-bottom-0">
11
11
  <%= t("components.layout_for_public.account_layout.feedback.banners.footer_intro") %>
12
- <a href="<%= "#{Plek.find('account-manager')}/feedback" %>" class="govuk-link">
12
+ <a href="<%= GovukPersonalisation::Urls.feedback %>" class="govuk-link">
13
13
  <%= t("components.layout_for_public.account_layout.feedback.banners.footer_link") %>
14
14
  </a>
15
15
  <%= t("components.layout_for_public.account_layout.feedback.banners.footer_outro") %>
@@ -1,7 +1,7 @@
1
1
  <div class="govuk-width-container">
2
2
  <% message = capture do %>
3
3
  <%= t("components.layout_for_public.account_layout.feedback.banners.phase_intro") %>
4
- <a class="govuk-link" href=<%= "#{Plek.find('account-manager')}/feedback" %>>
4
+ <a class="govuk-link" href=<%= GovukPersonalisation::Urls.feedback %>>
5
5
  <%= t("components.layout_for_public.account_layout.feedback.banners.phase_link") %>
6
6
  </a>
7
7
  <%= t("components.layout_for_public.account_layout.feedback.banners.phase_outro") %>
@@ -5,7 +5,7 @@
5
5
  <li class="gem-c-layout-for-public-account-menu__item <%= "gem-c-layout-for-public-account-menu__item--current" if page_is == "your-account" %>">
6
6
  <%= link_to(
7
7
  t("components.layout_for_public.account_layout.navigation.menu_bar.account.link_text"),
8
- "#{Plek.find('account-manager')}",
8
+ GovukPersonalisation::Urls.your_account,
9
9
  class: 'gem-c-layout-for-public-account-menu__link govuk-link govuk-link--no-visited-state',
10
10
  'aria-current': page_is == "your-account" ? "page" : nil,
11
11
  ) %>
@@ -13,7 +13,7 @@
13
13
  <li class="gem-c-layout-for-public-account-menu__item <%= "gem-c-layout-for-public-account-menu__item--current" if page_is == "manage" %>">
14
14
  <%= link_to(
15
15
  t("components.layout_for_public.account_layout.navigation.menu_bar.manage.link_text"),
16
- "#{Plek.find('account-manager')}/account/manage",
16
+ GovukPersonalisation::Urls.manage,
17
17
  class: 'gem-c-layout-for-public-account-menu__link govuk-link govuk-link--no-visited-state',
18
18
  'aria-current': page_is == "manage" ? "page" : nil,
19
19
  ) %>
@@ -21,7 +21,7 @@
21
21
  <li class="gem-c-layout-for-public-account-menu__item <%= "gem-c-layout-for-public-account-menu__item--current" if page_is == "security" %>">
22
22
  <%= link_to(
23
23
  t("components.layout_for_public.account_layout.navigation.menu_bar.security.link_text"),
24
- "#{Plek.find('account-manager')}/account/security",
24
+ GovukPersonalisation::Urls.security,
25
25
  class: 'gem-c-layout-for-public-account-menu__link govuk-link govuk-link--no-visited-state',
26
26
  'aria-current': page_is == "security" ? "page" : nil,
27
27
  ) %>
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = "25.4.0".freeze
2
+ VERSION = "26.0.0".freeze
3
3
  end
@@ -1,6 +1,7 @@
1
1
  require "active_support"
2
2
  require "action_controller"
3
3
  require "action_view"
4
+ require "govuk_personalisation"
4
5
  require "govuk_publishing_components/config"
5
6
  require "govuk_publishing_components/engine"
6
7
  require "govuk_publishing_components/presenters/shared_helper"
@@ -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 {