govuk_publishing_components 46.3.1 → 46.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (30) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-core.js +5 -0
  3. data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-page-views.js +10 -1
  4. data/app/models/govuk_publishing_components/component_wrapper_helper_options.rb +1 -0
  5. data/app/views/govuk_publishing_components/component_guide/show.html.erb +2 -2
  6. data/app/views/govuk_publishing_components/components/_accordion.html.erb +0 -2
  7. data/app/views/govuk_publishing_components/components/_action_link.html.erb +0 -3
  8. data/app/views/govuk_publishing_components/components/_chart.html.erb +1 -2
  9. data/app/views/govuk_publishing_components/components/_chat_entry.html.erb +1 -1
  10. data/app/views/govuk_publishing_components/components/_contents_list.html.erb +0 -2
  11. data/app/views/govuk_publishing_components/components/_contextual_guidance.html.erb +0 -2
  12. data/app/views/govuk_publishing_components/components/_contextual_sidebar.html.erb +0 -1
  13. data/app/views/govuk_publishing_components/components/_details.html.erb +1 -4
  14. data/app/views/govuk_publishing_components/components/_document_list.html.erb +0 -2
  15. data/app/views/govuk_publishing_components/components/_govspeak.html.erb +0 -2
  16. data/app/views/govuk_publishing_components/components/_heading.html.erb +0 -1
  17. data/app/views/govuk_publishing_components/components/_hint.html.erb +0 -3
  18. data/app/views/govuk_publishing_components/components/_inset_text.html.erb +1 -3
  19. data/app/views/govuk_publishing_components/components/_lead_paragraph.html.erb +0 -2
  20. data/app/views/govuk_publishing_components/components/_metadata.html.erb +0 -3
  21. data/app/views/govuk_publishing_components/components/_notice.html.erb +0 -2
  22. data/app/views/govuk_publishing_components/components/_password_input.html.erb +1 -3
  23. data/app/views/govuk_publishing_components/components/_radio.html.erb +0 -2
  24. data/app/views/govuk_publishing_components/components/_signup_link.html.erb +0 -1
  25. data/app/views/govuk_publishing_components/components/_single_page_notification_button.html.erb +3 -4
  26. data/app/views/govuk_publishing_components/components/_step_by_step_nav.html.erb +17 -12
  27. data/app/views/govuk_publishing_components/components/docs/step_by_step_nav.yml +1 -0
  28. data/lib/govuk_publishing_components/presenters/component_wrapper_helper.rb +13 -0
  29. data/lib/govuk_publishing_components/version.rb +1 -1
  30. metadata +4 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 36483f22d5d78ac563f819c7638cd059053b38a5df71a48b6ae6d8eef6e21a2c
4
- data.tar.gz: 60063513c4f84e2107e77a4b670f2dabcd95efc6650a72dda3097deb1caf4ed9
3
+ metadata.gz: 7972dc1e95cf1c1175ee81653f3b298d0d2d930b62bbd8c1035ba110fbbdcb72
4
+ data.tar.gz: f55e702ced40190a656f098fc3f192738b1478cf989a0b532051a778a308126b
5
5
  SHA512:
6
- metadata.gz: c9932de97294ccc4e51ce64fc07cfffd11b39d882f0ed69690e0f0e19a4e7fb57af59b10932a80c8a7bd0d23a87abc8486e7f072ab7fc34c0da25f8f11b5d26a
7
- data.tar.gz: 2ded4ab1c925b4af9171cbe11412e38b9fc56dff8de8428254413115b06d370a8d29621c62c0e8d76e603c82c4042c229e41b27962d52076c8ddfe8fc9c23336
6
+ metadata.gz: a588ba7241dc601438da646c2fc3ca9f5ddc93750cdaebac5e913f9a006acb8b13f61d7fe28b30936b41ba5268817876de7c235e4016f50790d5732d313a3939
7
+ data.tar.gz: d4f317981b263f21b71a8768600f6582c4a0592c22721f858a3e712f6756dca05c86e0cac787872043703df463456a8c7fed95b63cbc0377657dbdbbe35f960e
@@ -340,6 +340,11 @@ window.GOVUK.analyticsGa4 = window.GOVUK.analyticsGa4 || {};
340
340
 
341
341
  if (isSearchResult) {
342
342
  var searchQuery = window.GOVUK.analyticsGa4.core.trackFunctions.standardiseSearchTerm(element.getAttribute('data-ga4-search-query'))
343
+
344
+ // Limit tracked search term to 500 characters
345
+ if (searchQuery) {
346
+ searchQuery = searchQuery.substring(0, 500)
347
+ }
343
348
  var variant = element.getAttribute('data-ga4-ecommerce-variant')
344
349
  DEFAULT_LIST_TITLE = 'Site search results'
345
350
  }
@@ -66,7 +66,8 @@ window.GOVUK.analyticsGa4.analyticsModules = window.GOVUK.analyticsGa4.analytics
66
66
  search_term: this.getSearchTerm(),
67
67
  tool_name: this.getToolName(),
68
68
  spelling_suggestion: this.getMetaContent('spelling-suggestion'),
69
- discovery_engine_attribution_token: this.getMetaContent('discovery-engine-attribution-token')
69
+ discovery_engine_attribution_token: this.getMetaContent('discovery-engine-attribution-token'),
70
+ canonical_url: this.getCanonicalHref()
70
71
  }
71
72
  }
72
73
  window.GOVUK.analyticsGa4.core.sendData(data)
@@ -79,6 +80,14 @@ window.GOVUK.analyticsGa4.analyticsModules = window.GOVUK.analyticsGa4.analytics
79
80
  }
80
81
  },
81
82
 
83
+ getCanonicalHref: function () {
84
+ var link = document.querySelector('link[rel=canonical]')
85
+
86
+ if (link) {
87
+ return link.href
88
+ }
89
+ },
90
+
82
91
  getLocation: function () {
83
92
  // We don't want to remove dates on search pages.
84
93
  return this.PIIRemover.stripPIIWithOverride(this.stripGaParam(document.location.href), this.stripDates, true)
@@ -8,6 +8,7 @@ This component uses the component wrapper helper. It accepts the following optio
8
8
  - `data_attributes` - accepts a hash of data attributes
9
9
  - `aria` - accepts a hash of aria attributes
10
10
  - `classes` - accepts a space separated string of classes, these should not be used for styling and must be prefixed with `js-`
11
+ - `margin_bottom` - accepts a number from `0` to `9` (`0px` to `60px`) using the [GOV.UK Frontend spacing scale](https://design-system.service.gov.uk/styles/spacing/#the-responsive-spacing-scale) (defaults to no margin)
11
12
  - `role` - accepts a space separated string of roles
12
13
  - `lang` - accepts a language attribute value
13
14
  - `open` - accepts an open attribute value (true or false)
@@ -50,7 +50,7 @@
50
50
  href: "#other-examples",
51
51
  text: "Other examples",
52
52
  items: other_examples_links
53
- } if @component_doc.other_examples.any?),
53
+ } if @component_doc.other_examples.any? or @component_doc.uses_component_wrapper_helper?),
54
54
  ].compact
55
55
  %>
56
56
  <%= render "govuk_publishing_components/components/contents_list", {
@@ -92,7 +92,7 @@
92
92
  </div>
93
93
  <% end %>
94
94
 
95
- <% if @component_doc.other_examples.any? %>
95
+ <% if @component_doc.other_examples.any? or @component_doc.uses_component_wrapper_helper? %>
96
96
  <div class="examples">
97
97
  <h2 class="component-doc-h2" id="other-examples">Other examples</h2>
98
98
 
@@ -13,8 +13,6 @@
13
13
  component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
14
14
  component_helper.set_id(id)
15
15
  component_helper.add_class("gem-c-accordion govuk-accordion")
16
- component_helper.add_class(shared_helper.get_margin_bottom)
17
-
18
16
  component_helper.add_data_attribute({ module: "govuk-accordion gem-accordion" })
19
17
  component_helper.add_data_attribute({ module: "ga4-event-tracker" }) unless disable_ga4
20
18
  component_helper.add_data_attribute({ ga4_expandable: "" }) unless disable_ga4
@@ -2,8 +2,6 @@
2
2
  add_gem_component_stylesheet("action-link")
3
3
 
4
4
  local_assigns[:margin_bottom] ||= 0
5
- shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)
6
-
7
5
  text ||= false
8
6
  nowrap_text ||= false
9
7
  href ||= false
@@ -26,7 +24,6 @@
26
24
  css_classes << "gem-c-action-link--simple-light" if simple_light
27
25
  css_classes << "gem-c-action-link--with-subtext" if subtext
28
26
  css_classes << "gem-c-action-link--mobile-subtext" if mobile_subtext
29
- css_classes << shared_helper.get_margin_bottom
30
27
 
31
28
  link_classes = %w(govuk-link gem-c-action-link__link gem-c-force-print-link-styles)
32
29
  link_classes << "govuk-link--inverse" if inverse
@@ -14,6 +14,7 @@
14
14
  minimal ||= false
15
15
  hide_heading ||= minimal
16
16
  link ||= false
17
+ local_assigns[:margin_bottom] ||= 3
17
18
 
18
19
  chart_id = "chart-id-#{SecureRandom.hex(4)}"
19
20
  table_id = "table-id-#{SecureRandom.hex(4)}"
@@ -21,10 +22,8 @@
21
22
  @external_script[:loaded] += 1
22
23
 
23
24
  chart_helper = GovukPublishingComponents::Presenters::ChartHelper.new(local_assigns)
24
- shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)
25
25
  component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
26
26
  component_helper.add_class("gem-c-chart")
27
- component_helper.add_class(shared_helper.get_margin_bottom)
28
27
  component_helper.add_class("gem-c-chart--minimal") if minimal
29
28
 
30
29
  require "chartkick"
@@ -9,13 +9,13 @@
9
9
  border_bottom ||= false
10
10
  disable_ga4 ||= false
11
11
  margin_top_until_tablet ||= false
12
+ local_assigns[:margin_bottom] ||= 6
12
13
 
13
14
  component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
14
15
  component_helper.add_class("gem-c-chat-entry")
15
16
  component_helper.add_class("gem-c-chat-entry--border-top") if border_top
16
17
  component_helper.add_class("gem-c-chat-entry--border-bottom") if border_bottom
17
18
  component_helper.add_class("gem-c-chat-entry--margin-top-until-tablet") if margin_top_until_tablet
18
- component_helper.add_class(shared_helper.get_margin_bottom)
19
19
  component_helper.add_data_attribute({ module: "ga4-link-tracker" }) unless disable_ga4
20
20
 
21
21
  unless disable_ga4
@@ -9,7 +9,6 @@
9
9
  local_assigns[:aria] ||= {}
10
10
  local_assigns[:margin_bottom] ||= 4
11
11
 
12
- shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)
13
12
  cl_helper = GovukPublishingComponents::Presenters::ContentsListHelper.new(local_assigns)
14
13
  brand_helper = GovukPublishingComponents::AppHelpers::BrandHelper.new(brand)
15
14
 
@@ -29,7 +28,6 @@
29
28
  component_helper.add_class("gem-c-contents-list #{brand_helper.brand_class}")
30
29
  component_helper.add_class("gem-c-contents-list--alternative-line-style") if alternative_line_style
31
30
  component_helper.add_class("gem-c-contents-list--custom-title") if title
32
- component_helper.add_class(shared_helper.get_margin_bottom)
33
31
  component_helper.add_data_attribute({ module: "ga4-link-tracker" }) unless disable_ga4
34
32
  component_helper.add_aria_attribute({ label: t("components.contents_list.contents") }) unless local_assigns[:aria][:label]
35
33
  component_helper.add_role("navigation")
@@ -10,9 +10,7 @@
10
10
  component_helper.set_id(id)
11
11
  component_helper.add_class("gem-c-contextual-guidance")
12
12
  component_helper.add_data_attribute({ module: "contextual-guidance" })
13
-
14
13
  %>
15
-
16
14
  <%= tag.div(**component_helper.all_attributes) do %>
17
15
  <%= tag.div class: "govuk-grid-row" do %>
18
16
  <%= tag.div class: "govuk-grid-column-two-thirds" do %>
@@ -4,7 +4,6 @@
4
4
  disable_ga4 ||= false
5
5
  request.query_parameters[:disable_ga4] = disable_ga4
6
6
  navigation = GovukPublishingComponents::Presenters::ContextualNavigation.new(content_item, request)
7
- shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)
8
7
  show_ukraine_cta = navigation.show_ukraine_cta?
9
8
  ga4_tracking_counts = OpenStruct.new(index_section_count: 0)
10
9
  ga4_tracking_counts.index_section_count = 1 if show_ukraine_cta
@@ -1,14 +1,12 @@
1
1
  <%
2
2
  add_gem_component_stylesheet("details")
3
3
 
4
- shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)
5
4
  open ||= nil
6
5
  disable_ga4 ||= false
7
6
  @ga4 ||= OpenStruct.new(index_section: 0) unless disable_ga4
8
7
  @ga4[:index_section] += 1 unless disable_ga4
9
8
  ga4_attributes ||= {}
10
-
11
- margin_bottom ||= 3
9
+ local_assigns[:margin_bottom] ||= 3
12
10
 
13
11
  unless disable_ga4
14
12
  ga4_event = {
@@ -25,7 +23,6 @@
25
23
 
26
24
  component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
27
25
  component_helper.add_class("gem-c-details govuk-details")
28
- component_helper.add_class(shared_helper.get_margin_bottom)
29
26
  component_helper.add_data_attribute({ module: "ga4-event-tracker" }) unless disable_ga4
30
27
  component_helper.add_data_attribute({ ga4_event: ga4_event }) unless disable_ga4
31
28
  component_helper.set_open(open)
@@ -2,7 +2,6 @@
2
2
  add_gem_component_stylesheet("document-list")
3
3
 
4
4
  local_assigns[:margin_bottom] ||= 5
5
- shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)
6
5
  items ||= []
7
6
 
8
7
  component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
@@ -10,7 +9,6 @@
10
9
  component_helper.add_class("gem-c-document-list--no-top-border") if local_assigns[:remove_top_border]
11
10
  component_helper.add_class("gem-c-document-list--no-top-border-first-child") if local_assigns[:remove_top_border_from_first_child]
12
11
  component_helper.add_class("gem-c-document-list--equal-item-spacing") if local_assigns[:equal_item_spacing]
13
- component_helper.add_class(shared_helper.get_margin_bottom)
14
12
 
15
13
  extra_link_classes = "govuk-link--no-underline" if local_assigns[:remove_underline]
16
14
  title_with_context_class = " gem-c-document-list__item-title--context"
@@ -6,13 +6,11 @@
6
6
  direction_class = "gem-c-govspeak--direction-#{direction}" if local_assigns.include?(:direction)
7
7
  disable_youtube_expansions = local_assigns.fetch(:disable_youtube_expansions) if local_assigns.include?(:disable_youtube_expansions)
8
8
 
9
- shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)
10
9
  component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
11
10
  component_helper.add_class("gem-c-govspeak govuk-govspeak")
12
11
  component_helper.add_class(direction_class) if direction_class
13
12
  component_helper.add_class("js-disable-youtube") if disable_youtube_expansions
14
13
  component_helper.add_class("gem-c-govspeak--inverse") if inverse
15
- component_helper.add_class(shared_helper.get_margin_bottom)
16
14
  component_helper.add_data_attribute({ module: "govspeak" })
17
15
  %>
18
16
  <%= tag.div(**component_helper.all_attributes) do %>
@@ -13,7 +13,6 @@
13
13
  classes << heading_helper.classes
14
14
  classes << brand_helper.brand_class
15
15
  classes << brand_helper.border_color_class
16
- classes << shared_helper.get_margin_bottom if [*0..9].include?(local_assigns[:margin_bottom])
17
16
 
18
17
  component_helper.add_class(classes.join(" "))
19
18
  component_helper.set_id(heading_helper.id)
@@ -4,14 +4,11 @@
4
4
  local_assigns[:id] ||= "hint-#{SecureRandom.hex(4)}"
5
5
  is_radio_label_hint ||= false
6
6
  right_to_left ||= false
7
- shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)
8
7
 
9
8
  component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
10
9
  component_helper.add_class("gem-c-hint govuk-hint")
11
10
  component_helper.add_class("govuk-radios__hint") if is_radio_label_hint
12
- component_helper.add_class(shared_helper.get_margin_bottom) if [*0..9].include?(local_assigns[:margin_bottom])
13
11
  %>
14
-
15
12
  <%= tag.div(**component_helper.all_attributes, dir: right_to_left ? "rtl" : nil) do %>
16
13
  <%= text %>
17
14
  <% end %>
@@ -3,17 +3,15 @@
3
3
 
4
4
  id ||= "inset-text-#{SecureRandom.hex(4)}"
5
5
  margin_top ||= 6
6
- margin_bottom ||= 6
6
+ local_assigns[:margin_bottom] ||= 6
7
7
 
8
8
  shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new({
9
9
  margin_top: margin_top,
10
- margin_bottom: margin_bottom
11
10
  })
12
11
 
13
12
  component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
14
13
  component_helper.add_class("gem-c-inset-text govuk-inset-text gem-c-force-print-link-styles-within")
15
14
  component_helper.add_class(shared_helper.get_margin_top)
16
- component_helper.add_class(shared_helper.get_margin_bottom)
17
15
  component_helper.set_id(id)
18
16
  %>
19
17
  <%= tag.div(**component_helper.all_attributes) do %>
@@ -3,12 +3,10 @@
3
3
 
4
4
  text ||= ""
5
5
  inverse ||= false
6
- shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)
7
6
 
8
7
  component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
9
8
  component_helper.add_class("gem-c-lead-paragraph")
10
9
  component_helper.add_class("gem-c-lead-paragraph--inverse") if inverse
11
- component_helper.add_class(shared_helper.get_margin_bottom) if [*0..9].include?(local_assigns[:margin_bottom])
12
10
  %>
13
11
  <% if text.present? %>
14
12
  <%= tag.p(**component_helper.all_attributes) do %>
@@ -16,8 +16,6 @@
16
16
  direction_class = ""
17
17
  direction_class = " direction-#{direction}" if local_assigns.include?(:direction)
18
18
 
19
- shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)
20
-
21
19
  component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
22
20
  component_helper.add_class("gem-c-metadata")
23
21
  component_helper.add_class("direction-#{direction}") if local_assigns.include?(:direction)
@@ -27,7 +25,6 @@
27
25
  component_helper.add_class("gem-c-metadata--inverse-padded") unless inverse_compress
28
26
  end
29
27
 
30
- component_helper.add_class(shared_helper.get_margin_bottom) if local_assigns[:margin_bottom]
31
28
  component_helper.add_data_attribute({ module: "metadata" })
32
29
 
33
30
  disable_ga4 ||= false
@@ -15,10 +15,8 @@
15
15
  show_banner_title ||= false
16
16
  heading_level = show_banner_title ? "h3" : "h2"
17
17
 
18
- shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)
19
18
  component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
20
19
  component_helper.add_class("govuk-notification-banner gem-c-notice")
21
- component_helper.add_class(shared_helper.get_margin_bottom)
22
20
 
23
21
  component_helper.add_aria_attribute({ label: "Notice" })
24
22
  component_helper.add_aria_attribute({ live: "polite" }) if aria_live
@@ -2,7 +2,7 @@
2
2
  add_gem_component_stylesheet("password-input")
3
3
 
4
4
  label_text ||= t("components.password_input.label")
5
-
5
+ local_assigns[:margin_bottom] ||= 3
6
6
  error_text ||= nil
7
7
  error_text_prefix ||= t("components.password_input.error_text_prefix")
8
8
 
@@ -15,7 +15,6 @@
15
15
 
16
16
  name ||= "password"
17
17
 
18
- shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)
19
18
  component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
20
19
  component_helper.add_data_attribute({
21
20
  module: "govuk-password-input",
@@ -30,7 +29,6 @@
30
29
  component_helper.add_class('govuk-form-group--error') if error_text
31
30
  component_helper.add_class('govuk-password-input')
32
31
  component_helper.add_class('gem-c-password-input')
33
- component_helper.add_class(shared_helper.get_margin_bottom)
34
32
 
35
33
  uid = SecureRandom.hex(4)
36
34
 
@@ -31,7 +31,6 @@
31
31
  hint ||= nil
32
32
  error_message ||= nil
33
33
  error_items ||= []
34
- margin_bottom = margin_bottom ||= 6
35
34
 
36
35
  has_error = error_message || error_items.any?
37
36
  hint_id = "hint-#{SecureRandom.hex(4)}" if hint
@@ -40,7 +39,6 @@
40
39
  component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
41
40
  component_helper.add_class("govuk-form-group")
42
41
  component_helper.add_class("govuk-form-group--error") if has_error
43
- component_helper.add_class(shared_helper.get_margin_bottom)
44
42
  component_helper.set_id(id)
45
43
 
46
44
  radio_classes = %w(govuk-radios)
@@ -12,7 +12,6 @@
12
12
  shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)
13
13
  component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
14
14
  component_helper.add_class("gem-c-signup-link govuk-!-display-none-print")
15
- component_helper.add_class(shared_helper.get_margin_bottom)
16
15
  component_helper.add_class("gem-c-signup-link--link-only") unless heading
17
16
  component_helper.add_class("gem-c-signup-link--with-background-and-border") if background
18
17
  %>
@@ -1,18 +1,17 @@
1
1
  <%
2
2
  add_gem_component_stylesheet("single-page-notification-button")
3
3
 
4
+ local_assigns[:margin_bottom] ||= 3
5
+
4
6
  spnb_helper = GovukPublishingComponents::Presenters::SinglePageNotificationButtonHelper.new(local_assigns)
5
7
  shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)
6
8
  component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
7
9
 
8
- wrapper_classes = %w(govuk-!-display-none-print)
9
- wrapper_classes << shared_helper.get_margin_bottom
10
-
11
10
  ga4_data_attributes = ga4_data_attributes ||= nil
12
11
  ga4_link_data_attributes = ga4_data_attributes[:ga4_link] if ga4_data_attributes
13
12
  ga4_link_data_attributes[:url] = spnb_helper.form_action if ga4_link_data_attributes
14
13
 
15
- component_helper.add_class(wrapper_classes.join(" "))
14
+ component_helper.add_class("govuk-!-display-none-print")
16
15
  component_helper.add_data_attribute({ module: ga4_data_attributes[:module] }) if ga4_data_attributes
17
16
  %>
18
17
  <% button_text = capture do %>
@@ -19,19 +19,24 @@
19
19
  step_nav_helper = GovukPublishingComponents::Presenters::StepByStepNavHelper.new
20
20
 
21
21
  disable_ga4 ||= false
22
+
23
+ component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
24
+ component_helper.add_data_attribute({
25
+ module: "gemstepnav",
26
+ show_text: t("components.step_by_step_nav.show"),
27
+ hide_text: t("components.step_by_step_nav.hide"),
28
+ show_all_text: t("components.step_by_step_nav.show_all"),
29
+ hide_all_text: t("components.step_by_step_nav.hide_all")
30
+ })
31
+ component_helper.add_data_attribute({ module: "ga4-event-tracker", ga4_expandable: "", }) unless disable_ga4
32
+ component_helper.add_data_attribute({ remember: "" }) if remember_last_step
33
+ component_helper.add_data_attribute({ id: tracking_id }) if tracking_id
34
+ component_helper.add_class("gem-c-step-nav js-hidden")
35
+ component_helper.add_class("govuk-!-display-none-print") if small
36
+ component_helper.add_class("gem-c-step-nav--large") unless small
22
37
  %>
23
38
  <% if steps %>
24
- <div
25
- data-module="gemstepnav<% unless disable_ga4 %> ga4-event-tracker<% end %>"
26
- <%= "data-ga4-expandable" unless disable_ga4 %>
27
- class="gem-c-step-nav js-hidden <% if small %>govuk-!-display-none-print<% end %> <% unless small %>gem-c-step-nav--large<% end %>"
28
- <%= "data-remember" if remember_last_step %>
29
- <%= "data-id=#{tracking_id}" if tracking_id %>
30
- data-show-text="<%= t("components.step_by_step_nav.show") %>"
31
- data-hide-text="<%= t("components.step_by_step_nav.hide") %>"
32
- data-show-all-text="<%= t("components.step_by_step_nav.show_all") %>"
33
- data-hide-all-text="<%= t("components.step_by_step_nav.hide_all") %>"
34
- >
39
+ <%= tag.div(**component_helper.all_attributes) do %>
35
40
  <ol class="gem-c-step-nav__steps">
36
41
  <% steps.each_with_index do |step, step_index| %>
37
42
  <%
@@ -115,5 +120,5 @@
115
120
  </li>
116
121
  <% end %>
117
122
  </ol>
118
- </div>
123
+ <% end %>
119
124
  <% end %>
@@ -11,6 +11,7 @@ body: |
11
11
  - creating a new component allows further iteration without impacting the accordion
12
12
 
13
13
  Background information relating to the testing and research behind this component can be found on the [Modelling Services wiki](https://gov-uk.atlassian.net/wiki/spaces/MS/pages) in Q2 to Q4, 2017/18.
14
+ uses_component_wrapper_helper: true
14
15
  accessibility_criteria: |
15
16
  The step by step navigation must:
16
17
 
@@ -14,6 +14,7 @@ module GovukPublishingComponents
14
14
  check_hidden_is_valid(@options[:hidden]) if @options.include?(:hidden)
15
15
  check_tabindex_is_valid(@options[:tabindex]) if @options.include?(:tabindex)
16
16
  check_dir_is_valid(@options[:dir]) if @options.include?(:dir)
17
+ check_margin_bottom_is_valid(@options[:margin_bottom]) if @options.include?(:margin_bottom)
17
18
  end
18
19
 
19
20
  def all_attributes
@@ -22,7 +23,10 @@ module GovukPublishingComponents
22
23
  attributes[:id] = @options[:id] unless @options[:id].blank?
23
24
  attributes[:data] = @options[:data_attributes] unless @options[:data_attributes].blank?
24
25
  attributes[:aria] = @options[:aria] unless @options[:aria].blank?
26
+
27
+ ((@options[:classes] ||= "") << " govuk-!-margin-bottom-#{@options[:margin_bottom]}").strip! if @options[:margin_bottom]
25
28
  attributes[:class] = @options[:classes] unless @options[:classes].blank?
29
+
26
30
  attributes[:role] = @options[:role] unless @options[:role].blank?
27
31
  attributes[:lang] = @options[:lang] unless @options[:lang].blank?
28
32
  attributes[:open] = @options[:open] unless @options[:open].blank?
@@ -83,6 +87,11 @@ module GovukPublishingComponents
83
87
  @options[:dir] = dir_attribute
84
88
  end
85
89
 
90
+ def set_margin_bottom(margin_bottom)
91
+ check_margin_bottom_is_valid(margin_bottom)
92
+ @options[:margin_bottom] = margin_bottom
93
+ end
94
+
86
95
  private
87
96
 
88
97
  def check_id_is_valid(id)
@@ -170,6 +179,10 @@ module GovukPublishingComponents
170
179
  end
171
180
  end
172
181
 
182
+ def check_margin_bottom_is_valid(margin_bottom)
183
+ raise(ArgumentError, "margin_bottom option (#{margin_bottom}) is not recognised") unless [*0..9].include?(margin_bottom)
184
+ end
185
+
173
186
  def check_dir_is_valid(dir_attribute)
174
187
  return if dir_attribute.nil?
175
188
 
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = "46.3.1".freeze
2
+ VERSION = "46.4.0".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk_publishing_components
3
3
  version: !ruby/object:Gem::Version
4
- version: 46.3.1
4
+ version: 46.4.0
5
5
  platform: ruby
6
+ original_platform: ''
6
7
  authors:
7
8
  - GOV.UK Dev
8
- autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-12-11 00:00:00.000000000 Z
11
+ date: 2024-12-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chartkick
@@ -2013,7 +2013,6 @@ homepage: https://github.com/alphagov/govuk_publishing_components
2013
2013
  licenses:
2014
2014
  - MIT
2015
2015
  metadata: {}
2016
- post_install_message:
2017
2016
  rdoc_options: []
2018
2017
  require_paths:
2019
2018
  - lib
@@ -2028,8 +2027,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
2028
2027
  - !ruby/object:Gem::Version
2029
2028
  version: '0'
2030
2029
  requirements: []
2031
- rubygems_version: 3.5.23
2032
- signing_key:
2030
+ rubygems_version: 3.6.0
2033
2031
  specification_version: 4
2034
2032
  summary: A gem to document components in GOV.UK frontend applications
2035
2033
  test_files: []