govuk_publishing_components 53.0.0 → 54.0.1

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 (117) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/stylesheets/govuk_publishing_components/components/_attachment.scss +25 -9
  3. data/app/assets/stylesheets/govuk_publishing_components/components/_govspeak-html-publication.scss +5 -14
  4. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_attachment.scss +4 -18
  5. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_call-to-action.scss +3 -12
  6. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_contact.scss +1 -2
  7. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_example.scss +2 -9
  8. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_footnotes.scss +2 -11
  9. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_form-download.scss +1 -5
  10. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_highlight-answer.scss +1 -2
  11. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_images.scss +1 -2
  12. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_information-callout.scss +2 -9
  13. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_legislative-list.scss +1 -9
  14. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_media-player.scss +1 -2
  15. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_place.scss +1 -5
  16. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_stat-headline.scss +1 -8
  17. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_steps.scss +1 -1
  18. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_tables.scss +1 -1
  19. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_typography.scss +0 -1
  20. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_warning-callout.scss +2 -9
  21. data/app/assets/stylesheets/govuk_publishing_components/components/helpers/_markdown-typography.scss +15 -55
  22. data/app/controllers/govuk_publishing_components/audit_controller.rb +1 -0
  23. data/app/controllers/govuk_publishing_components/component_guide_controller.rb +1 -1
  24. data/app/models/govuk_publishing_components/audit_applications.rb +1 -1
  25. data/app/models/govuk_publishing_components/audit_comparer.rb +1 -1
  26. data/app/models/govuk_publishing_components/audit_components.rb +1 -1
  27. data/app/views/govuk_publishing_components/components/_attachment.html.erb +2 -0
  28. data/app/views/govuk_publishing_components/components/_cookie_banner.html.erb +2 -1
  29. data/app/views/govuk_publishing_components/components/_feedback.html.erb +2 -6
  30. data/app/views/govuk_publishing_components/components/_govspeak.html.erb +3 -0
  31. data/app/views/govuk_publishing_components/components/_heading.html.erb +0 -1
  32. data/app/views/govuk_publishing_components/components/_layout_for_public.html.erb +6 -21
  33. data/app/views/govuk_publishing_components/components/_layout_super_navigation_header.html.erb +0 -1
  34. data/app/views/govuk_publishing_components/components/_metadata.html.erb +0 -3
  35. data/app/views/govuk_publishing_components/components/_radio.html.erb +0 -1
  36. data/app/views/govuk_publishing_components/components/docs/govspeak.yml +7 -4
  37. data/app/views/govuk_publishing_components/components/docs/layout_for_public.yml +0 -2
  38. data/app/views/govuk_publishing_components/components/feedback/_survey_signup_form.html.erb +0 -4
  39. data/config/locales/ar.yml +0 -1
  40. data/config/locales/az.yml +0 -1
  41. data/config/locales/be.yml +0 -1
  42. data/config/locales/bg.yml +0 -1
  43. data/config/locales/bn.yml +0 -1
  44. data/config/locales/cs.yml +0 -1
  45. data/config/locales/cy.yml +0 -1
  46. data/config/locales/da.yml +0 -1
  47. data/config/locales/de.yml +0 -1
  48. data/config/locales/dr.yml +0 -1
  49. data/config/locales/el.yml +0 -1
  50. data/config/locales/en.yml +6 -7
  51. data/config/locales/es-419.yml +1 -2
  52. data/config/locales/es.yml +1 -2
  53. data/config/locales/et.yml +0 -1
  54. data/config/locales/fa.yml +0 -1
  55. data/config/locales/fi.yml +0 -1
  56. data/config/locales/fr.yml +0 -1
  57. data/config/locales/gd.yml +0 -1
  58. data/config/locales/gu.yml +0 -1
  59. data/config/locales/he.yml +0 -1
  60. data/config/locales/hi.yml +0 -1
  61. data/config/locales/hr.yml +0 -1
  62. data/config/locales/hu.yml +0 -1
  63. data/config/locales/hy.yml +0 -1
  64. data/config/locales/id.yml +0 -1
  65. data/config/locales/is.yml +0 -1
  66. data/config/locales/it.yml +0 -1
  67. data/config/locales/ja.yml +0 -1
  68. data/config/locales/ka.yml +0 -1
  69. data/config/locales/kk.yml +0 -1
  70. data/config/locales/ko.yml +0 -1
  71. data/config/locales/lt.yml +0 -1
  72. data/config/locales/lv.yml +0 -1
  73. data/config/locales/ms.yml +0 -1
  74. data/config/locales/mt.yml +0 -1
  75. data/config/locales/nl.yml +0 -1
  76. data/config/locales/no.yml +0 -1
  77. data/config/locales/pa-pk.yml +0 -1
  78. data/config/locales/pa.yml +0 -1
  79. data/config/locales/pl.yml +0 -1
  80. data/config/locales/ps.yml +0 -1
  81. data/config/locales/pt.yml +0 -1
  82. data/config/locales/ro.yml +0 -1
  83. data/config/locales/ru.yml +0 -1
  84. data/config/locales/si.yml +0 -1
  85. data/config/locales/sk.yml +0 -1
  86. data/config/locales/sl.yml +0 -1
  87. data/config/locales/so.yml +0 -1
  88. data/config/locales/sq.yml +0 -1
  89. data/config/locales/sr.yml +0 -1
  90. data/config/locales/sv.yml +0 -1
  91. data/config/locales/sw.yml +0 -1
  92. data/config/locales/ta.yml +0 -1
  93. data/config/locales/th.yml +0 -1
  94. data/config/locales/tk.yml +0 -1
  95. data/config/locales/tr.yml +0 -1
  96. data/config/locales/uk.yml +0 -1
  97. data/config/locales/ur.yml +0 -1
  98. data/config/locales/uz.yml +0 -1
  99. data/config/locales/vi.yml +0 -1
  100. data/config/locales/zh-hk.yml +0 -1
  101. data/config/locales/zh-tw.yml +0 -1
  102. data/config/locales/zh.yml +0 -1
  103. data/lib/govuk_publishing_components/app_helpers/asset_helper.rb +35 -26
  104. data/lib/govuk_publishing_components/config.rb +3 -0
  105. data/lib/govuk_publishing_components/presenters/attachment_helper.rb +2 -6
  106. data/lib/govuk_publishing_components/presenters/checkboxes_helper.rb +2 -2
  107. data/lib/govuk_publishing_components/presenters/component_wrapper_helper.rb +14 -14
  108. data/lib/govuk_publishing_components/presenters/content_breadcrumbs_based_on_organisations.rb +1 -1
  109. data/lib/govuk_publishing_components/presenters/content_breadcrumbs_based_on_taxons.rb +1 -1
  110. data/lib/govuk_publishing_components/presenters/content_item.rb +1 -3
  111. data/lib/govuk_publishing_components/presenters/machine_readable/article_schema.rb +1 -1
  112. data/lib/govuk_publishing_components/presenters/machine_readable/government_service_schema.rb +2 -2
  113. data/lib/govuk_publishing_components/presenters/machine_readable/organisation_schema.rb +3 -3
  114. data/lib/govuk_publishing_components/presenters/meta_tags.rb +2 -2
  115. data/lib/govuk_publishing_components/presenters/page_with_step_by_step_navigation.rb +1 -1
  116. data/lib/govuk_publishing_components/version.rb +1 -1
  117. metadata +2 -2
@@ -123,7 +123,6 @@ ta:
123
123
  label:
124
124
  navigation_links_columns:
125
125
  navigation_menu_heading:
126
- navigation_search_heading:
127
126
  navigation_search_subheading:
128
127
  search_text:
129
128
  metadata:
@@ -120,7 +120,6 @@ th:
120
120
  label:
121
121
  navigation_links_columns:
122
122
  navigation_menu_heading:
123
- navigation_search_heading:
124
123
  navigation_search_subheading:
125
124
  search_text:
126
125
  metadata:
@@ -123,7 +123,6 @@ tk:
123
123
  label:
124
124
  navigation_links_columns:
125
125
  navigation_menu_heading:
126
- navigation_search_heading:
127
126
  navigation_search_subheading:
128
127
  search_text:
129
128
  metadata:
@@ -123,7 +123,6 @@ tr:
123
123
  label:
124
124
  navigation_links_columns:
125
125
  navigation_menu_heading:
126
- navigation_search_heading:
127
126
  navigation_search_subheading:
128
127
  search_text:
129
128
  metadata:
@@ -129,7 +129,6 @@ uk:
129
129
  label:
130
130
  navigation_links_columns:
131
131
  navigation_menu_heading:
132
- navigation_search_heading:
133
132
  navigation_search_subheading:
134
133
  search_text:
135
134
  metadata:
@@ -119,7 +119,6 @@ ur:
119
119
  label:
120
120
  navigation_links_columns:
121
121
  navigation_menu_heading:
122
- navigation_search_heading:
123
122
  navigation_search_subheading:
124
123
  search_text:
125
124
  metadata:
@@ -124,7 +124,6 @@ uz:
124
124
  label:
125
125
  navigation_links_columns:
126
126
  navigation_menu_heading:
127
- navigation_search_heading:
128
127
  navigation_search_subheading:
129
128
  search_text:
130
129
  metadata:
@@ -121,7 +121,6 @@ vi:
121
121
  label:
122
122
  navigation_links_columns:
123
123
  navigation_menu_heading:
124
- navigation_search_heading:
125
124
  navigation_search_subheading:
126
125
  search_text:
127
126
  metadata:
@@ -120,7 +120,6 @@ zh-hk:
120
120
  label:
121
121
  navigation_links_columns:
122
122
  navigation_menu_heading:
123
- navigation_search_heading:
124
123
  navigation_search_subheading:
125
124
  search_text:
126
125
  metadata:
@@ -120,7 +120,6 @@ zh-tw:
120
120
  label:
121
121
  navigation_links_columns:
122
122
  navigation_menu_heading:
123
- navigation_search_heading:
124
123
  navigation_search_subheading:
125
124
  search_text:
126
125
  metadata:
@@ -120,7 +120,6 @@ zh:
120
120
  label:
121
121
  navigation_links_columns:
122
122
  navigation_menu_heading:
123
- navigation_search_heading:
124
123
  navigation_search_subheading:
125
124
  search_text:
126
125
  metadata:
@@ -15,26 +15,25 @@ module GovukPublishingComponents
15
15
 
16
16
  # This is used to dedupe stylesheets.
17
17
  STATIC_STYLESHEET_LIST = %w[
18
- govuk_publishing_components/components/_breadcrumbs.css
19
- govuk_publishing_components/components/_button.css
20
- govuk_publishing_components/components/_error-message.css
21
- govuk_publishing_components/components/_heading.css
22
- govuk_publishing_components/components/_hint.css
23
- govuk_publishing_components/components/_input.css
24
- govuk_publishing_components/components/_label.css
25
- govuk_publishing_components/components/_search.css
26
- govuk_publishing_components/components/_search-with-autocomplete.css
27
- govuk_publishing_components/components/_skip-link.css
28
- govuk_publishing_components/components/_textarea.css
29
- govuk_publishing_components/components/_title.css
30
-
31
- govuk_publishing_components/components/_cookie-banner.css
32
- govuk_publishing_components/components/_cross-service-header.css
33
- govuk_publishing_components/components/_feedback.css
34
- govuk_publishing_components/components/_layout-footer.css
35
- govuk_publishing_components/components/_layout-for-public.css
36
- govuk_publishing_components/components/_layout-header.css
37
- govuk_publishing_components/components/_layout-super-navigation-header.css
18
+ breadcrumbs
19
+ button
20
+ error-message
21
+ heading
22
+ hint
23
+ input
24
+ label
25
+ search
26
+ search-with-autocomplete
27
+ skip-link
28
+ textarea
29
+ title
30
+ cookie-banner
31
+ cross-service-header
32
+ feedback
33
+ layout-footer
34
+ layout-for-public
35
+ layout-header
36
+ layout-super-navigation-header
38
37
  ].freeze
39
38
 
40
39
  def add_stylesheet_path(component_path)
@@ -81,15 +80,25 @@ module GovukPublishingComponents
81
80
  private
82
81
 
83
82
  def is_already_used?(component)
84
- if GovukPublishingComponents::Config.exclude_css_from_static && !viewing_component_guide?
85
- all_component_stylesheets_being_used.include?(component) || STATIC_STYLESHEET_LIST.include?(component)
86
- else
87
- all_component_stylesheets_being_used.include?(component)
88
- end
83
+ (all_component_stylesheets_being_used + component_paths(css_exclude_list)).include?(component)
84
+ end
85
+
86
+ def css_exclude_list
87
+ return [] if viewing_component_guide?
88
+ return GovukPublishingComponents::Config.custom_css_exclude_list if GovukPublishingComponents::Config.custom_css_exclude_list&.any?
89
+ return STATIC_STYLESHEET_LIST if GovukPublishingComponents::Config.exclude_css_from_static
90
+
91
+ []
89
92
  end
90
93
 
91
94
  def viewing_component_guide?
92
- request&.path&.include?("/component-guide")
95
+ return false unless request
96
+
97
+ request.path.include?("/component-guide")
98
+ end
99
+
100
+ def component_paths(component_list)
101
+ component_list.map { |c| "govuk_publishing_components/components/_#{c}.css" }
93
102
  end
94
103
  end
95
104
  end
@@ -18,6 +18,9 @@ module GovukPublishingComponents
18
18
  mattr_accessor :application_javascript
19
19
  self.application_javascript = "application"
20
20
 
21
+ mattr_accessor :custom_css_exclude_list
22
+ self.custom_css_exclude_list = []
23
+
21
24
  mattr_accessor :exclude_css_from_static
22
25
  self.exclude_css_from_static = true
23
26
 
@@ -47,13 +47,9 @@ module GovukPublishingComponents
47
47
  )
48
48
  end
49
49
 
50
- def content_type_abbr
51
- content_type.abbr
52
- end
50
+ delegate :abbr, to: :content_type, prefix: true
53
51
 
54
- def content_type_name
55
- content_type.name
56
- end
52
+ delegate :name, to: :content_type, prefix: true
57
53
 
58
54
  def file_size
59
55
  attachment_data[:file_size]
@@ -64,7 +64,7 @@ module GovukPublishingComponents
64
64
  end
65
65
 
66
66
  def heading_markup
67
- return unless @heading.present?
67
+ return if @heading.blank?
68
68
 
69
69
  if @is_page_heading
70
70
  content_tag(
@@ -87,7 +87,7 @@ module GovukPublishingComponents
87
87
  checkbox_id = checkbox[:id] || "#{@id}-#{index}"
88
88
  controls = checkbox[:controls]
89
89
  aria_controls = "#{checkbox_id}-conditional-#{index || rand(1..100)}" if checkbox[:conditional].present?
90
- checkbox_name = checkbox[:name].present? ? checkbox[:name] : @name
90
+ checkbox_name = checkbox[:name].presence || @name
91
91
  checked = true if checkbox[:checked].present?
92
92
  data = checkbox[:data_attributes] || {}
93
93
  data[:controls] = controls
@@ -24,24 +24,24 @@ module GovukPublishingComponents
24
24
  def all_attributes
25
25
  attributes = {}
26
26
 
27
- attributes[:id] = @options[:id] unless @options[:id].blank?
28
- attributes[:data] = @options[:data_attributes] unless @options[:data_attributes].blank?
29
- attributes[:aria] = @options[:aria] unless @options[:aria].blank?
27
+ attributes[:id] = @options[:id] if @options[:id].present?
28
+ attributes[:data] = @options[:data_attributes] if @options[:data_attributes].present?
29
+ attributes[:aria] = @options[:aria] if @options[:aria].present?
30
30
 
31
31
  ((@options[:classes] ||= "") << " govuk-!-margin-bottom-#{@options[:margin_bottom]}").strip! if @options[:margin_bottom]
32
- attributes[:class] = @options[:classes] unless @options[:classes].blank?
32
+ attributes[:class] = @options[:classes] if @options[:classes].present?
33
33
 
34
- attributes[:role] = @options[:role] unless @options[:role].blank?
35
- attributes[:lang] = @options[:lang] unless @options[:lang].blank?
36
- attributes[:open] = @options[:open] unless @options[:open].blank?
34
+ attributes[:role] = @options[:role] if @options[:role].present?
35
+ attributes[:lang] = @options[:lang] if @options[:lang].present?
36
+ attributes[:open] = @options[:open] if @options[:open].present?
37
37
  attributes[:hidden] = @options[:hidden] unless @options[:hidden].nil?
38
- attributes[:tabindex] = @options[:tabindex] unless @options[:tabindex].blank?
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?
38
+ attributes[:tabindex] = @options[:tabindex] if @options[:tabindex].present?
39
+ attributes[:dir] = @options[:dir] if @options[:dir].present?
40
+ attributes[:type] = @options[:type] if @options[:type].present?
41
+ attributes[:draggable] = @options[:draggable] if @options[:draggable].present?
42
+ attributes[:rel] = @options[:rel] if @options[:rel].present?
43
+ attributes[:target] = @options[:target] if @options[:target].present?
44
+ attributes[:title] = @options[:title] if @options[:title].present?
45
45
 
46
46
  attributes
47
47
  end
@@ -24,7 +24,7 @@ module GovukPublishingComponents
24
24
 
25
25
  def organisation_breadcrumbs_items
26
26
  first_related_organisation = ContentItem.new(content_item.related_organisations.first)
27
- return [] unless first_related_organisation.present?
27
+ return [] if first_related_organisation.blank?
28
28
 
29
29
  [{
30
30
  title: first_related_organisation.title,
@@ -14,7 +14,7 @@ module GovukPublishingComponents
14
14
  ordered_parents = all_parents.map.with_index do |parent, index|
15
15
  {
16
16
  title: parent.title,
17
- url: parent.url_override.present? ? parent.url_override : parent.base_path,
17
+ url: parent.url_override.presence || parent.base_path,
18
18
  is_page_parent: index.zero?,
19
19
  }
20
20
  end
@@ -124,9 +124,7 @@ module GovukPublishingComponents
124
124
  content_id == other.content_id
125
125
  end
126
126
 
127
- def hash
128
- content_id.hash
129
- end
127
+ delegate :hash, to: :content_id
130
128
 
131
129
  def eql?(other)
132
130
  self == other
@@ -29,7 +29,7 @@ module GovukPublishingComponents
29
29
  # Not all formats have a `body` - some have their content split over
30
30
  # multiple fields. In this case we'll skip the `articleBody` field
31
31
  def body
32
- return {} unless page.body.present?
32
+ return {} if page.body.blank?
33
33
 
34
34
  {
35
35
  "articleBody" => page.body,
@@ -25,7 +25,7 @@ module GovukPublishingComponents
25
25
  def related_services
26
26
  related_links = page.content_item.dig("links", "ordered_related_items")
27
27
 
28
- return {} unless related_links.present?
28
+ return {} if related_links.blank?
29
29
 
30
30
  {
31
31
  "isRelatedTo" => related_links.each_with_object([]) do |link, items|
@@ -43,7 +43,7 @@ module GovukPublishingComponents
43
43
  def provider
44
44
  organisations = page.content_item.dig("links", "organisations")
45
45
 
46
- return {} unless organisations.present?
46
+ return {} if organisations.blank?
47
47
 
48
48
  providers = organisations.map do |organisation|
49
49
  {
@@ -29,7 +29,7 @@ module GovukPublishingComponents
29
29
  private
30
30
 
31
31
  def members
32
- return {} unless ministers.present?
32
+ return {} if ministers.blank?
33
33
 
34
34
  members = ministers_with_grouped_roles.map do |person, roles|
35
35
  person.merge("hasOccupation" => roles)
@@ -67,7 +67,7 @@ module GovukPublishingComponents
67
67
  end
68
68
 
69
69
  def role_for_minister(minister)
70
- return {} unless minister["role"].present?
70
+ return {} if minister["role"].blank?
71
71
 
72
72
  {
73
73
  "@type" => "Role",
@@ -108,7 +108,7 @@ module GovukPublishingComponents
108
108
  def related_organisations(link_type, schema_name)
109
109
  organisations = page.content_item.dig("links", link_type)
110
110
 
111
- return {} unless organisations.present?
111
+ return {} if organisations.blank?
112
112
 
113
113
  related_orgs = organisations.map do |org|
114
114
  page = Page.new(content_item: org)
@@ -47,8 +47,8 @@ module GovukPublishingComponents
47
47
  meta_tags["govuk:updated-at"] = content_item[:updated_at] if content_item[:updated_at]
48
48
  meta_tags["govuk:public-updated-at"] = content_item[:public_updated_at] if content_item[:public_updated_at]
49
49
  primary_publisher = content_item.dig(:links, :primary_publishing_organisation)
50
- primary_publisher = primary_publisher.first[:title] unless primary_publisher.blank?
51
- meta_tags["govuk:primary-publishing-organisation"] = primary_publisher unless primary_publisher.blank?
50
+ primary_publisher = primary_publisher.first[:title] if primary_publisher.present?
51
+ meta_tags["govuk:primary-publishing-organisation"] = primary_publisher if primary_publisher.present?
52
52
 
53
53
  # Some browse topics are nested in the content item, we want to grab these for GA4 tracking.
54
54
  ga4_browse_topic = content_item.dig(:links, :ordered_related_items, 0, :links, :mainstream_browse_pages, 0, :links, :parent, 0, :title)
@@ -140,7 +140,7 @@ module GovukPublishingComponents
140
140
  end
141
141
 
142
142
  def active_step_nav_content_id
143
- @active_step_nav_content_id ||= @query_parameters["step-by-step-nav"].present? ? @query_parameters["step-by-step-nav"] : nil
143
+ @active_step_nav_content_id ||= @query_parameters["step-by-step-nav"].presence
144
144
  end
145
145
 
146
146
  def steps
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = "53.0.0".freeze
2
+ VERSION = "54.0.1".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: 53.0.0
4
+ version: 54.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - GOV.UK Dev
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-02-26 00:00:00.000000000 Z
10
+ date: 2025-03-05 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: govuk_app_config