govuk_publishing_components 47.0.0 → 49.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/govuk_publishing_components/rum-custom-data.js +18 -0
  3. data/app/assets/javascripts/govuk_publishing_components/vendor/lux/lux-measurer.js +0 -37
  4. data/app/assets/stylesheets/govuk_publishing_components/components/_govspeak.scss +0 -1
  5. data/app/models/govuk_publishing_components/component_wrapper_helper_options.rb +7 -2
  6. data/app/views/govuk_publishing_components/components/_attachment.html.erb +8 -7
  7. data/app/views/govuk_publishing_components/components/_attachment_link.html.erb +6 -3
  8. data/app/views/govuk_publishing_components/components/_big_number.html.erb +7 -8
  9. data/app/views/govuk_publishing_components/components/_contents_list.html.erb +0 -1
  10. data/app/views/govuk_publishing_components/components/_cross_service_header.html.erb +1 -1
  11. data/app/views/govuk_publishing_components/components/_intervention.html.erb +10 -14
  12. data/app/views/govuk_publishing_components/components/_layout_footer.html.erb +0 -1
  13. data/app/views/govuk_publishing_components/components/_layout_for_public.html.erb +1 -0
  14. data/app/views/govuk_publishing_components/components/_layout_header.html.erb +0 -1
  15. data/app/views/govuk_publishing_components/components/_layout_super_navigation_header.html.erb +9 -21
  16. data/app/views/govuk_publishing_components/components/_list.html.erb +6 -12
  17. data/app/views/govuk_publishing_components/components/_modal_dialogue.html.erb +7 -3
  18. data/app/views/govuk_publishing_components/components/_previous_and_next_navigation.html.erb +0 -1
  19. data/app/views/govuk_publishing_components/components/_search.html.erb +17 -21
  20. data/app/views/govuk_publishing_components/components/_secondary_navigation.html.erb +0 -1
  21. data/app/views/govuk_publishing_components/components/_subscription_links.html.erb +5 -11
  22. data/app/views/govuk_publishing_components/components/_success_alert.html.erb +8 -12
  23. data/app/views/govuk_publishing_components/components/_summary_card.html.erb +4 -2
  24. data/app/views/govuk_publishing_components/components/_summary_list.html.erb +6 -2
  25. data/app/views/govuk_publishing_components/components/_translation_nav.html.erb +6 -5
  26. data/app/views/govuk_publishing_components/components/_warning_text.html.erb +5 -1
  27. data/app/views/govuk_publishing_components/components/docs/attachment.yml +3 -2
  28. data/app/views/govuk_publishing_components/components/docs/attachment_link.yml +3 -2
  29. data/app/views/govuk_publishing_components/components/docs/big_number.yml +9 -5
  30. data/app/views/govuk_publishing_components/components/docs/devolved_nations.yml +3 -3
  31. data/app/views/govuk_publishing_components/components/docs/document_list.yml +1 -2
  32. data/app/views/govuk_publishing_components/components/docs/govspeak.yml +0 -6
  33. data/app/views/govuk_publishing_components/components/docs/intervention.yml +1 -0
  34. data/app/views/govuk_publishing_components/components/docs/layout_footer.yml +0 -9
  35. data/app/views/govuk_publishing_components/components/docs/layout_super_navigation_header.yml +1 -0
  36. data/app/views/govuk_publishing_components/components/docs/list.yml +3 -1
  37. data/app/views/govuk_publishing_components/components/docs/modal_dialogue.yml +1 -17
  38. data/app/views/govuk_publishing_components/components/docs/search.yml +2 -2
  39. data/app/views/govuk_publishing_components/components/docs/subscription_links.yml +1 -0
  40. data/app/views/govuk_publishing_components/components/docs/success_alert.yml +1 -0
  41. data/app/views/govuk_publishing_components/components/docs/summary_card.yml +1 -0
  42. data/app/views/govuk_publishing_components/components/docs/summary_list.yml +1 -0
  43. data/app/views/govuk_publishing_components/components/docs/translation_nav.yml +1 -0
  44. data/app/views/govuk_publishing_components/components/docs/warning_text.yml +1 -0
  45. data/app/views/govuk_publishing_components/components/layout_for_public/_account-layout.html.erb +1 -1
  46. data/app/views/govuk_publishing_components/components/layout_header/_search.html.erb +1 -1
  47. data/app/views/govuk_publishing_components/components/related_navigation/_section.html.erb +1 -2
  48. data/lib/govuk_publishing_components/presenters/component_wrapper_helper.rb +76 -1
  49. data/lib/govuk_publishing_components/presenters/devolved_nations_helper.rb +4 -4
  50. data/lib/govuk_publishing_components/version.rb +1 -1
  51. metadata +3 -3
  52. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_advisory.scss +0 -36
@@ -4,12 +4,13 @@
4
4
  brand ||= false
5
5
  brand_helper = GovukPublishingComponents::AppHelpers::BrandHelper.new(brand)
6
6
  translation_helper = GovukPublishingComponents::Presenters::TranslationNavHelper.new(local_assigns)
7
+
8
+ component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
9
+ component_helper.add_class("gem-c-translation-nav govuk-!-display-none-print #{translation_helper.classes} #{brand_helper.brand_class}")
10
+ component_helper.add_aria_attribute({ label: t("common.translations") })
7
11
  %>
8
12
  <% if translation_helper.has_translations? %>
9
- <nav role="navigation"
10
- class="gem-c-translation-nav govuk-!-display-none-print <%= translation_helper.classes %> <%= brand_helper.brand_class %>"
11
- aria-label="<%= t("common.translations") %>"
12
- >
13
+ <%= tag.nav(**component_helper.all_attributes) do %>
13
14
  <ul class="gem-c-translation-nav__list">
14
15
  <% translation_helper.translations.each.with_index do |translation, i| %>
15
16
  <li class="gem-c-translation-nav__list-item">
@@ -27,5 +28,5 @@
27
28
  </li>
28
29
  <% end %>
29
30
  </ul>
30
- </nav>
31
+ <% end %>
31
32
  <% end %>
@@ -14,9 +14,13 @@
14
14
  text_classes << "gem-c-warning-text__text--no-indent" if text_icon.empty?
15
15
  text_classes << "gem-c-warning-text__text--large" if large_font
16
16
  text_classes << "gem-c-warning-text__text--highlight" if highlight_text
17
+
18
+ component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
19
+ component_helper.set_id(id)
20
+ component_helper.add_class("gem-c-warning-text govuk-warning-text")
17
21
  %>
18
22
 
19
- <%= tag.div id: id, class: "gem-c-warning-text govuk-warning-text" do %>
23
+ <%= tag.div(**component_helper.all_attributes) do %>
20
24
  <% unless text_icon.empty? %>
21
25
  <%= tag.span text_icon, class: "govuk-warning-text__icon", "aria-hidden": "true" %>
22
26
  <% end %>
@@ -17,6 +17,7 @@ shared_accessibility_criteria:
17
17
  accessibility_criteria: |
18
18
  The thumbnail image, and the link wrapping it, must not focusable or shown to
19
19
  screenreaders.
20
+ uses_component_wrapper_helper: true
20
21
  examples:
21
22
  default:
22
23
  data:
@@ -89,7 +90,7 @@ examples:
89
90
  details_ga4_attributes: {
90
91
  index_section_count: 4
91
92
  }
92
- with_data_attributes:
93
+ with_data_attributes_on_url:
93
94
  data:
94
95
  attachment:
95
96
  title: "Department for Transport information asset register"
@@ -97,7 +98,7 @@ examples:
97
98
  filename: department-for-transport-information-asset-register.csv
98
99
  content_type: application/pdf
99
100
  file_size: 20000
100
- data_attributes:
101
+ url_data_attributes:
101
102
  gtm: "attachment-preview"
102
103
  with_margin_bottom:
103
104
  description: The component accepts a number for margin bottom 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). It defaults to no margin bottom.
@@ -14,6 +14,7 @@ accessibility_criteria: |
14
14
  Attachment links within paragraphs of text do not need to meet the 24 by 24 CSS pixels requirements.
15
15
  shared_accessibility_criteria:
16
16
  - link
17
+ uses_component_wrapper_helper: true
17
18
  examples:
18
19
  default:
19
20
  data:
@@ -58,10 +59,10 @@ examples:
58
59
  title: "Temporary snow ploughs: guidance note"
59
60
  url: https://assets.publishing.service.gov.uk/government/uploads/system/uploads/attachment_data/file/259634/temporary-snow-ploughs.pdf
60
61
  target: _blank
61
- with_data_attributes:
62
+ with_data_attributes_on_url:
62
63
  data:
63
64
  attachment:
64
65
  title: "Temporary snow ploughs: guidance note"
65
66
  url: https://assets.publishing.service.gov.uk/government/uploads/system/uploads/attachment_data/file/259634/temporary-snow-ploughs.pdf
66
- data_attributes:
67
+ url_data_attributes:
67
68
  gtm: "attachment-preview"
@@ -48,22 +48,26 @@ examples:
48
48
  data:
49
49
  number: 23
50
50
  href: "/government/organisations#ministerial_departments"
51
- with_data_attributes:
51
+ with_nested_data_attributes:
52
52
  description: |
53
- If a `href` attribute is present, `data_attributes` will apply to the `span` containing the number value (see below).
53
+ If a `href` attribute is present, `nested_data_attributes` will apply to the `a` containing the number value (see below). If a `href` is not present, it will apply to the `span` containing the number value.
54
+
55
+ For parent level data attributes, use `data_attributes` which comes from this component having the component wrapper.
54
56
 
55
57
  Note that the component does not include built in tracking. If this is required consider using the [GA4 link tracker](https://github.com/alphagov/govuk_publishing_components/blob/main/docs/analytics-ga4/trackers/ga4-link-tracker.md).
56
58
  data:
57
59
  number: 23
58
60
  label: Ministerial departments
59
61
  href: "/government/organisations#ministerial_departments"
60
- data_attributes:
62
+ nested_data_attributes:
61
63
  department-count: true
62
- with_data_attributes_but_no_link:
64
+ with_nested_data_attributes_but_no_link:
65
+ description: |
66
+ If a `href` is not present, the data attributes will be applied to the `span` containing the big number. For parent level data attributes, use `data_attributes` which comes from this component having the component wrapper.
63
67
  data:
64
68
  number: 23
65
69
  label: Ministerial departments
66
- data_attributes:
70
+ nested_data_attributes:
67
71
  department-count: true
68
72
  with_aria_attributes:
69
73
  description: Aria attributes are applied to the whole component instance
@@ -72,7 +72,7 @@ examples:
72
72
  northern_ireland:
73
73
  applicable: false
74
74
  alternative_url: /
75
- type: consultation
75
+ content_type: consultation
76
76
  applies_to_one_nation_individual_guidance_available:
77
77
  description: Specify alternative type for the content e.g. Guidance
78
78
  data:
@@ -82,7 +82,7 @@ examples:
82
82
  northern_ireland:
83
83
  applicable: false
84
84
  alternative_url: /
85
- type: detailed_guide
85
+ content_type: detailed_guide
86
86
  specific_heading level:
87
87
  description: Use a different heading level for the main link title. Defaults to `h2` if not passed.
88
88
  data:
@@ -104,5 +104,5 @@ examples:
104
104
  northern_ireland:
105
105
  applicable: false
106
106
  alternative_url: /
107
- type: detailed_guide
107
+ content_type: detailed_guide
108
108
  disable_ga4: true
@@ -246,8 +246,7 @@ examples:
246
246
  document_type: 'Statistical data set'
247
247
  with_equal_item_spacing:
248
248
  description: |
249
- The new search UI has consistently equal spacing between items in the document list, instead
250
- of the original larger bottom padding.
249
+ Use this option to add equal spacing between items in the document list.
251
250
  data:
252
251
  equal_item_spacing: true
253
252
  items:
@@ -842,12 +842,6 @@ examples:
842
842
  The water in the mouth of a blue whale weighs more than its body.
843
843
  </p>
844
844
  </div>
845
- advisory:
846
- data:
847
- block: |
848
- <h3 role="note" aria-label="Important" class="advisory">
849
- <span>This is a very important message or warning</span>
850
- </h3>
851
845
  form_download:
852
846
  data:
853
847
  block: |
@@ -21,6 +21,7 @@ shared_accessibility_criteria:
21
21
  - link
22
22
  accessibility_excluded_rules:
23
23
  - landmark-unique # aria-label attributes will be duplicated in component examples list
24
+ uses_component_wrapper_helper: true
24
25
  examples:
25
26
  default:
26
27
  data:
@@ -20,17 +20,8 @@ accessibility_criteria: |
20
20
 
21
21
  Note: This decision has been made based on prior experience seeing removal of overuse of `<nav>` elements from www.GOV.UK, which made it confusing for users of assistive technologies to know what were the most important navigation aspects of GOV.UK.
22
22
  Should be challenged if user research indicates this is an issue.
23
-
24
- - have a role of [`contentinfo`](https://www.w3.org/TR/wai-aria-1.1/#contentinfo) at the root of the component (`<footer>`)
25
-
26
- Note: This decision has been made given that most uses of this role tend to be used directly on a `<footer>` element.
27
- Assumption made is that is most predictable for users of assistive technologies.
28
- The spec indicates that `contentinfo` is useful for "Examples of information included in this region of the page are copyrights and links to privacy statements.", which may indicate that it might be better placed around the 'meta' section of this component.
29
- Should be challenged if user research indicates this is an issue.
30
23
  shared_accessibility_criteria:
31
24
  - link
32
- accessibility_excluded_rules:
33
- - landmark-contentinfo-is-top-level # The footer element can not be top level in the examples
34
25
  examples:
35
26
  default:
36
27
  data: {}
@@ -26,6 +26,7 @@ accessibility_excluded_rules:
26
26
  - duplicate-id-aria
27
27
  - landmark-no-duplicate-banner
28
28
  - landmark-unique
29
+ uses_component_wrapper_helper: true
29
30
  examples:
30
31
  default:
31
32
  with_custom_logo_link:
@@ -5,6 +5,7 @@ body: |
5
5
 
6
6
  The `items` parameter can include HTML to display - such as links or another
7
7
  list. This HTML can either be directly coded or come from another component.
8
+ uses_component_wrapper_helper: true
8
9
  accessibility_criteria: |
9
10
  The list must:
10
11
 
@@ -31,7 +32,8 @@ examples:
31
32
  unordered_list_with_aria-label:
32
33
  description: "A list with an aria-label"
33
34
  data:
34
- aria_label: "A list of delicious chocolate bars."
35
+ aria:
36
+ label: "A list of delicious chocolate bars."
35
37
  <<: *default-example-data
36
38
  unordered_list_with_bullet_points:
37
39
  description: "An unordered list with visible bullet points."
@@ -24,6 +24,7 @@ accessibility_criteria: |
24
24
  - return focus to last focused element on close
25
25
 
26
26
  display_preview: false
27
+ uses_component_wrapper_helper: true
27
28
  examples:
28
29
  default:
29
30
  embed: |
@@ -100,20 +101,3 @@ examples:
100
101
  <p class="govuk-body">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed imperdiet fringilla dictum. Morbi at vehicula augue. Pellentesque varius orci et augue pellentesque, sed elementum massa posuere. Curabitur egestas consectetur arcu, in porta lorem sagittis eu. Nulla facilisi. Sed scelerisque ligula lectus. Nulla et ligula a eros laoreet lacinia nec et ipsum. Ut sagittis sapien est, ut blandit risus laoreet at. Vestibulum vitae erat sed dolor ultricies efficitur.</p>
101
102
  <p class="govuk-body">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed imperdiet fringilla dictum. Morbi at vehicula augue. Pellentesque varius orci et augue pellentesque, sed elementum massa posuere. Curabitur egestas consectetur arcu, in porta lorem sagittis eu. Nulla facilisi. Sed scelerisque ligula lectus. Nulla et ligula a eros laoreet lacinia nec et ipsum. Ut sagittis sapien est, ut blandit risus laoreet at. Vestibulum vitae erat sed dolor ultricies efficitur.</p>
102
103
  <p class="govuk-body">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed imperdiet fringilla dictum. Morbi at vehicula augue. Pellentesque varius orci et augue pellentesque, sed elementum massa posuere. Curabitur egestas consectetur arcu, in porta lorem sagittis eu. Nulla facilisi. Sed scelerisque ligula lectus. Nulla et ligula a eros laoreet lacinia nec et ipsum. Ut sagittis sapien est, ut blandit risus laoreet at. Vestibulum vitae erat sed dolor ultricies efficitur.</p>
103
- with_data_attributes:
104
- embed: |
105
- <%= render "govuk_publishing_components/components/button", {
106
- text: "Open modal with data attributes",
107
- data_attributes: {
108
- toggle: "modal",
109
- target: "modal-with-data-attributes"
110
- }
111
- } %>
112
- <%= component %>
113
- data:
114
- id: modal-with-data-attributes
115
- data_attributes:
116
- gtm: modal
117
- block: |
118
- <h1 class="govuk-heading-l">Modal title</h1>
119
- <p class="govuk-body">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed imperdiet fringilla dictum. Morbi at vehicula augue. Pellentesque varius orci et augue pellentesque, sed elementum massa posuere. Curabitur egestas consectetur arcu, in porta lorem sagittis eu. Nulla facilisi. Sed scelerisque ligula lectus. Nulla et ligula a eros laoreet lacinia nec et ipsum. Ut sagittis sapien est, ut blandit risus laoreet at. Vestibulum vitae erat sed dolor ultricies efficitur.</p>
@@ -12,7 +12,7 @@ accessibility_criteria: |
12
12
 
13
13
  - be used inside a form with the role of 'search', to indicate it as a [search landmark](https://www.w3.org/TR/wai-aria-practices-1.1/#aria_lh_search)
14
14
  - have a clear label to identify the search functionality, which is visible to all users
15
-
15
+ uses_component_wrapper_helper: true
16
16
  examples:
17
17
  default:
18
18
  data: {}
@@ -49,7 +49,7 @@ examples:
49
49
  label_text: "Search"
50
50
  set_id_for_search_input:
51
51
  data:
52
- id: "my_unique_id"
52
+ label_id: "my_unique_id"
53
53
  large_version:
54
54
  data:
55
55
  size: "large"
@@ -14,6 +14,7 @@ accessibility_criteria: |
14
14
  - show hidden elements by default when JavaScript is disabled
15
15
  shared_accessibility_criteria:
16
16
  - link
17
+ uses_component_wrapper_helper: true
17
18
  examples:
18
19
  default:
19
20
  data:
@@ -7,6 +7,7 @@ accessibility_criteria: |
7
7
  assistive tech
8
8
  - Should have a role of ‘alert’ to communicate that is a important and
9
9
  time sensitive message
10
+ uses_component_wrapper_helper: true
10
11
  examples:
11
12
  default:
12
13
  data:
@@ -5,6 +5,7 @@ accessibility_criteria: |
5
5
  - be focusable with a keyboard
6
6
  - be usable with a keyboard
7
7
  - indicate when it has focus
8
+ uses_component_wrapper_helper: true
8
9
  examples:
9
10
  default:
10
11
  data:
@@ -9,6 +9,7 @@ shared_accessibility_criteria:
9
9
  - link
10
10
  govuk_frontend_components:
11
11
  - summary-list
12
+ uses_component_wrapper_helper: true
12
13
  examples:
13
14
  default:
14
15
  data: &default-example-data
@@ -16,6 +16,7 @@ shared_accessibility_criteria:
16
16
  - link
17
17
  accessibility_excluded_rules:
18
18
  - landmark-unique # aria-label attributes will be duplicated in component examples list
19
+ uses_component_wrapper_helper: true
19
20
  examples:
20
21
  default:
21
22
  data:
@@ -5,6 +5,7 @@ govuk_frontend_components:
5
5
  - warning-text
6
6
  accessibility_criteria: |
7
7
  All text must have a contrast ratio higher than 4.5:1 against the background colour to meet [WCAG AA](https://www.w3.org/TR/WCAG20/#visual-audio-contrast-contrast)
8
+ uses_component_wrapper_helper: true
8
9
  examples:
9
10
  default:
10
11
  data:
@@ -12,7 +12,7 @@
12
12
  <div class="govuk-grid-column-two-thirds">
13
13
  <div id="wrapper">
14
14
  <%= yield :before_content %>
15
- <main role="main" id="content">
15
+ <main id="content">
16
16
  <%= yield %>
17
17
  </main>
18
18
  </div>
@@ -21,7 +21,7 @@
21
21
  >
22
22
  <%= render "govuk_publishing_components/components/search", {
23
23
  button_text: t("components.layout_header.search_button"),
24
- id: "site-search-text",
24
+ label_id: "site-search-text",
25
25
  margin_bottom: 0,
26
26
  no_border: true,
27
27
  disable_corrections: true,
@@ -1,5 +1,4 @@
1
- <nav role="navigation"
2
- class="gem-c-related-navigation__nav-section"
1
+ <nav class="gem-c-related-navigation__nav-section"
3
2
  aria-labelledby="related-nav-<%= section_title %>-<%= random %>"
4
3
  data-module="gem-toggle">
5
4
 
@@ -14,6 +14,10 @@ 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_type_is_valid(@options[:type]) if @options.include?(:type)
18
+ check_draggable_is_valid(@options[:draggable]) if @options.include?(:draggable)
19
+ check_rel_is_valid(@options[:rel]) if @options.include?(:rel)
20
+ check_target_is_valid(@options[:target]) if @options.include?(:target)
17
21
  check_margin_bottom_is_valid(@options[:margin_bottom]) if @options.include?(:margin_bottom)
18
22
  end
19
23
 
@@ -33,6 +37,11 @@ module GovukPublishingComponents
33
37
  attributes[:hidden] = @options[:hidden] unless @options[:hidden].nil?
34
38
  attributes[:tabindex] = @options[:tabindex] unless @options[:tabindex].blank?
35
39
  attributes[:dir] = @options[:dir] unless @options[:dir].blank?
40
+ attributes[:type] = @options[:type] unless @options[:type].blank?
41
+ attributes[:draggable] = @options[:draggable] unless @options[:draggable].blank?
42
+ attributes[:rel] = @options[:rel] unless @options[:rel].blank?
43
+ attributes[:target] = @options[:target] unless @options[:target].blank?
44
+ attributes[:title] = @options[:title] unless @options[:title].blank?
36
45
 
37
46
  attributes
38
47
  end
@@ -87,6 +96,35 @@ module GovukPublishingComponents
87
96
  @options[:dir] = dir_attribute
88
97
  end
89
98
 
99
+ def set_type(type_attribute)
100
+ check_type_is_valid(type_attribute)
101
+ @options[:type] = type_attribute
102
+ end
103
+
104
+ def set_draggable(draggable_attribute)
105
+ check_draggable_is_valid(draggable_attribute)
106
+ @options[:draggable] = draggable_attribute
107
+ end
108
+
109
+ def add_rel(rel_attribute)
110
+ check_rel_is_valid(rel_attribute)
111
+ extend_string(:rel, rel_attribute)
112
+ end
113
+
114
+ def set_rel(rel_attribute)
115
+ check_rel_is_valid(rel_attribute)
116
+ @options[:rel] = rel_attribute
117
+ end
118
+
119
+ def set_target(target_attribute)
120
+ check_target_is_valid(target_attribute)
121
+ @options[:target] = target_attribute
122
+ end
123
+
124
+ def set_title(title_attribute)
125
+ @options[:title] = title_attribute
126
+ end
127
+
90
128
  def set_margin_bottom(margin_bottom)
91
129
  check_margin_bottom_is_valid(margin_bottom)
92
130
  @options[:margin_bottom] = margin_bottom
@@ -184,7 +222,7 @@ module GovukPublishingComponents
184
222
  end
185
223
 
186
224
  def check_dir_is_valid(dir_attribute)
187
- return if dir_attribute.nil?
225
+ return if dir_attribute.blank?
188
226
 
189
227
  options = %w[ltr rtl auto]
190
228
  unless options.include? dir_attribute
@@ -192,6 +230,43 @@ module GovukPublishingComponents
192
230
  end
193
231
  end
194
232
 
233
+ def check_type_is_valid(type_attribute)
234
+ return if type_attribute.blank?
235
+
236
+ options = %w[button checkbox color date datetime-local email file hidden image month number password radio range reset search submit tel text time url week]
237
+ unless options.include? type_attribute
238
+ raise(ArgumentError, "type attribute (#{type_attribute}) is not recognised")
239
+ end
240
+ end
241
+
242
+ def check_draggable_is_valid(draggable_attribute)
243
+ return if draggable_attribute.blank?
244
+
245
+ options = %w[true false]
246
+ unless options.include? draggable_attribute
247
+ raise(ArgumentError, "draggable attribute (#{draggable_attribute}) is not recognised")
248
+ end
249
+ end
250
+
251
+ def check_rel_is_valid(rel_attribute)
252
+ return if rel_attribute.blank?
253
+
254
+ options = %w[alternate author bookmark canonical dns-prefetch external expect help icon license manifest me modulepreload next nofollow noopener noreferrer opener pingback preconnect prefetch preload prerender prev privacy-policy search stylesheet tag terms-of-service]
255
+ rel_array = rel_attribute.split(" ")
256
+ unless rel_array.all? { |r| options.include? r }
257
+ raise(ArgumentError, "rel attribute (#{rel_attribute}) is not recognised")
258
+ end
259
+ end
260
+
261
+ def check_target_is_valid(target_attribute)
262
+ return if target_attribute.blank?
263
+
264
+ options = %w[_self _blank _parent _top _unfencedTop]
265
+ unless options.include? target_attribute
266
+ raise(ArgumentError, "target attribute (#{target_attribute}) is not recognised")
267
+ end
268
+ end
269
+
195
270
  def extend_string(option, string)
196
271
  ((@options[option] ||= "") << " #{string}").strip!
197
272
  end
@@ -1,11 +1,11 @@
1
1
  module GovukPublishingComponents
2
2
  module Presenters
3
3
  class DevolvedNationsHelper
4
- attr_reader :national_applicability, :type
4
+ attr_reader :national_applicability, :content_type
5
5
 
6
6
  def initialize(local_assigns)
7
7
  @national_applicability = local_assigns[:national_applicability]
8
- @type = local_assigns[:type] || "publication"
8
+ @content_type = local_assigns[:content_type] || "publication"
9
9
  end
10
10
 
11
11
  def applicable_nations_title_text(use_english_translation = nil)
@@ -42,8 +42,8 @@ module GovukPublishingComponents
42
42
  def alternative_content_text(name)
43
43
  nation = I18n.t("components.devolved_nations.#{name}")
44
44
 
45
- if I18n.exists?("components.devolved_nations.type.#{@type}")
46
- I18n.t("components.devolved_nations.type.#{@type}", nation:)
45
+ if I18n.exists?("components.devolved_nations.type.#{@content_type}")
46
+ I18n.t("components.devolved_nations.type.#{@content_type}", nation:)
47
47
  else
48
48
  I18n.t("components.devolved_nations.type.publication", nation:)
49
49
  end
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = "47.0.0".freeze
2
+ VERSION = "49.0.0".freeze
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk_publishing_components
3
3
  version: !ruby/object:Gem::Version
4
- version: 47.0.0
4
+ version: 49.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GOV.UK Dev
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-01-07 00:00:00.000000000 Z
10
+ date: 2025-01-16 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: govuk_app_config
@@ -505,6 +505,7 @@ files:
505
505
  - app/assets/javascripts/govuk_publishing_components/lib/trigger-event.js
506
506
  - app/assets/javascripts/govuk_publishing_components/load-analytics.js
507
507
  - app/assets/javascripts/govuk_publishing_components/modules.js
508
+ - app/assets/javascripts/govuk_publishing_components/rum-custom-data.js
508
509
  - app/assets/javascripts/govuk_publishing_components/rum-loader.js
509
510
  - app/assets/javascripts/govuk_publishing_components/single-consent-functions.js
510
511
  - app/assets/javascripts/govuk_publishing_components/vendor/lux/lux-measurer.js
@@ -593,7 +594,6 @@ files:
593
594
  - app/assets/stylesheets/govuk_publishing_components/components/_title.scss
594
595
  - app/assets/stylesheets/govuk_publishing_components/components/_translation-nav.scss
595
596
  - app/assets/stylesheets/govuk_publishing_components/components/_warning-text.scss
596
- - app/assets/stylesheets/govuk_publishing_components/components/govspeak/_advisory.scss
597
597
  - app/assets/stylesheets/govuk_publishing_components/components/govspeak/_attachment.scss
598
598
  - app/assets/stylesheets/govuk_publishing_components/components/govspeak/_button.scss
599
599
  - app/assets/stylesheets/govuk_publishing_components/components/govspeak/_call-to-action.scss
@@ -1,36 +0,0 @@
1
- $info-background: #d5e8f3;
2
- $high-alert-border: #cc0000;
3
-
4
- .govspeak, // Legacy class name that's still used in some content items - needs to be kept until `.govspeak` is removed from the content items.
5
- .gem-c-govspeak {
6
- .advisory {
7
- background-image: url("govuk_publishing_components/icon-important.svg");
8
- background-repeat: no-repeat;
9
- background-size: 30px 30px;
10
- background-position: 98% center;
11
- background-color: $info-background;
12
- line-height: 1.3em;
13
- margin: 0 0 1em;
14
- padding: govuk-spacing(3) govuk-spacing(8) govuk-spacing(3) govuk-spacing(3);
15
- text-align: left;
16
-
17
- p {
18
- margin: 0 .75em 0 0;
19
- min-height: 1.75em;
20
- padding-right: 3em;
21
- }
22
-
23
- strong {
24
- font-weight: 400;
25
- }
26
-
27
- &.high-alert {
28
- background-color: govuk-colour("light-grey");
29
- border: 1px solid $high-alert-border;
30
- }
31
-
32
- @include govuk-media-query($until: tablet) {
33
- margin: 0 0 1em;
34
- }
35
- }
36
- }