govuk_publishing_components 27.14.1 → 27.17.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/govuk_publishing_components/analytics/auto-scroll-tracker.js +24 -3
  3. data/app/assets/javascripts/govuk_publishing_components/analytics/custom-dimensions.js +52 -26
  4. data/app/assets/javascripts/govuk_publishing_components/analytics/ecommerce.js +25 -25
  5. data/app/assets/javascripts/govuk_publishing_components/analytics/explicit-cross-domain-links.js +48 -31
  6. data/app/assets/javascripts/govuk_publishing_components/components/single-page-notification-button.js +3 -3
  7. data/app/assets/stylesheets/govuk_publishing_components/components/_big-number.scss +10 -2
  8. data/app/assets/stylesheets/govuk_publishing_components/components/_layout-super-navigation-header.scss +12 -11
  9. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_tables.scss +8 -4
  10. data/app/views/govuk_publishing_components/components/_button.html.erb +1 -1
  11. data/app/views/govuk_publishing_components/components/_cookie_banner.html.erb +1 -1
  12. data/app/views/govuk_publishing_components/components/_intervention.html.erb +21 -4
  13. data/app/views/govuk_publishing_components/components/_search.html.erb +25 -9
  14. data/app/views/govuk_publishing_components/components/_single_page_notification_button.html.erb +9 -7
  15. data/app/views/govuk_publishing_components/components/_success_alert.html.erb +4 -1
  16. data/app/views/govuk_publishing_components/components/docs/intervention.yml +11 -0
  17. data/app/views/govuk_publishing_components/components/docs/layout_for_public.yml +1 -1
  18. data/app/views/govuk_publishing_components/components/docs/radio.yml +40 -33
  19. data/app/views/govuk_publishing_components/components/docs/search.yml +25 -0
  20. data/app/views/govuk_publishing_components/components/docs/success_alert.yml +6 -0
  21. data/config/i18n-tasks.yml +8 -0
  22. data/config/locales/ar.yml +134 -131
  23. data/config/locales/az.yml +131 -131
  24. data/config/locales/be.yml +136 -130
  25. data/config/locales/bg.yml +135 -131
  26. data/config/locales/bn.yml +132 -131
  27. data/config/locales/cs.yml +136 -131
  28. data/config/locales/cy.yml +129 -125
  29. data/config/locales/da.yml +132 -131
  30. data/config/locales/de.yml +135 -131
  31. data/config/locales/dr.yml +133 -131
  32. data/config/locales/el.yml +131 -131
  33. data/config/locales/en.yml +13 -12
  34. data/config/locales/es-419.yml +131 -131
  35. data/config/locales/es.yml +131 -131
  36. data/config/locales/et.yml +134 -131
  37. data/config/locales/fa.yml +130 -131
  38. data/config/locales/fi.yml +133 -131
  39. data/config/locales/fr.yml +130 -130
  40. data/config/locales/gd.yml +133 -131
  41. data/config/locales/gu.yml +131 -131
  42. data/config/locales/he.yml +131 -131
  43. data/config/locales/hi.yml +131 -131
  44. data/config/locales/hr.yml +133 -131
  45. data/config/locales/hu.yml +134 -131
  46. data/config/locales/hy.yml +135 -131
  47. data/config/locales/id.yml +132 -131
  48. data/config/locales/is.yml +131 -131
  49. data/config/locales/it.yml +131 -131
  50. data/config/locales/ja.yml +128 -131
  51. data/config/locales/ka.yml +134 -131
  52. data/config/locales/kk.yml +131 -131
  53. data/config/locales/ko.yml +13 -17
  54. data/config/locales/lt.yml +136 -131
  55. data/config/locales/lv.yml +135 -131
  56. data/config/locales/ms.yml +131 -131
  57. data/config/locales/mt.yml +133 -131
  58. data/config/locales/nl.yml +131 -131
  59. data/config/locales/no.yml +131 -131
  60. data/config/locales/pa-pk.yml +128 -132
  61. data/config/locales/pa.yml +131 -131
  62. data/config/locales/pl.yml +135 -131
  63. data/config/locales/ps.yml +128 -131
  64. data/config/locales/pt.yml +131 -131
  65. data/config/locales/ro.yml +132 -131
  66. data/config/locales/ru.yml +135 -131
  67. data/config/locales/si.yml +131 -131
  68. data/config/locales/sk.yml +136 -131
  69. data/config/locales/sl.yml +138 -131
  70. data/config/locales/so.yml +131 -131
  71. data/config/locales/sq.yml +131 -131
  72. data/config/locales/sr.yml +133 -131
  73. data/config/locales/sv.yml +131 -131
  74. data/config/locales/sw.yml +131 -131
  75. data/config/locales/ta.yml +132 -131
  76. data/config/locales/th.yml +130 -131
  77. data/config/locales/tk.yml +132 -131
  78. data/config/locales/tr.yml +132 -131
  79. data/config/locales/uk.yml +138 -131
  80. data/config/locales/ur.yml +128 -131
  81. data/config/locales/uz.yml +133 -131
  82. data/config/locales/vi.yml +131 -131
  83. data/config/locales/zh-hk.yml +130 -131
  84. data/config/locales/zh-tw.yml +130 -131
  85. data/config/locales/zh.yml +130 -131
  86. data/lib/govuk_publishing_components/presenters/button_helper.rb +24 -0
  87. data/lib/govuk_publishing_components/presenters/intervention_helper.rb +20 -2
  88. data/lib/govuk_publishing_components/presenters/single_page_notification_button_helper.rb +4 -7
  89. data/lib/govuk_publishing_components/version.rb +1 -1
  90. metadata +2 -2
@@ -11,6 +11,7 @@ module GovukPublishingComponents
11
11
  :rel,
12
12
  :data_attributes,
13
13
  :margin_bottom,
14
+ :id,
14
15
  :inline_layout,
15
16
  :target,
16
17
  :type,
@@ -49,16 +50,39 @@ module GovukPublishingComponents
49
50
  @value = local_assigns[:value]
50
51
  @classes = local_assigns[:classes]
51
52
  @aria_label = local_assigns[:aria_label]
53
+ @info_text_id = "info-text-id-#{SecureRandom.hex(4)}"
54
+ @button_id = "button-id-#{SecureRandom.hex(4)}"
52
55
  end
53
56
 
54
57
  def link?
55
58
  href.present?
56
59
  end
57
60
 
61
+ def info_text?
62
+ info_text.present?
63
+ end
64
+
65
+ def aria_labelledby
66
+ if info_text?
67
+ text = "#{@button_id} "
68
+ text << @info_text_id
69
+ text
70
+ end
71
+ end
72
+
73
+ def info_text_options
74
+ options = { class: info_text_classes }
75
+ options[:aria] = { hidden: true } if info_text?
76
+ options[:id] = @info_text_id if info_text?
77
+ options
78
+ end
79
+
58
80
  def html_options
59
81
  options = { class: css_classes }
60
82
  options[:role] = "button" if link?
61
83
  options[:type] = button_type
84
+ options[:id] = @button_id if info_text?
85
+ options[:aria] = { labelledby: aria_labelledby }
62
86
  options[:rel] = rel if rel
63
87
  options[:data] = data_attributes if data_attributes
64
88
  options[:title] = title if title
@@ -1,10 +1,17 @@
1
1
  module GovukPublishingComponents
2
2
  module Presenters
3
3
  class InterventionHelper
4
- attr_reader :query_string
5
-
6
4
  def initialize(local_assigns)
5
+ @accessible_text_suffix = I18n.t("components.intervention.accessible_link_text_suffix")
7
6
  @query_string = local_assigns[:query_string]
7
+ @suggestion_link_text = local_assigns[:suggestion_link_text]
8
+ @suggestion_link_url = local_assigns[:suggestion_link_url]
9
+ end
10
+
11
+ def accessible_text
12
+ @suggestion_link_text << @accessible_text_suffix unless @suggestion_link_text.include?(@accessible_text_suffix)
13
+
14
+ @suggestion_link_text
8
15
  end
9
16
 
10
17
  def dismiss_link
@@ -14,6 +21,17 @@ module GovukPublishingComponents
14
21
  "?hide-intervention=true"
15
22
  end
16
23
  end
24
+
25
+ def security_attr
26
+ rel = "noopener noreferrer"
27
+ rel << " external" unless @suggestion_link_url.start_with?("/", "https://gov.uk", "https://www.gov.uk")
28
+
29
+ rel
30
+ end
31
+
32
+ private
33
+
34
+ attr_reader :accessible_text_suffix, :query_string, :suggestion_link_text, :suggestion_link_url
17
35
  end
18
36
  end
19
37
  end
@@ -14,15 +14,12 @@ module GovukPublishingComponents
14
14
  end
15
15
 
16
16
  def data
17
- module_names = %w[gem-track-click]
18
- module_names << "single-page-notification-button" if js_enhancement
19
-
20
- @data_attributes[:label] = base_path
17
+ @data_attributes[:track_label] = base_path
21
18
  # data-action for tracking should have the format of e.g. "Unsubscribe-button-top", or "Subscribe-button-bottom"
22
19
  # when button_location is not present data-action will fall back to "Unsubscribe-button"/"Subscribe-button"
23
- @data_attributes[:action] = [button_type, "button", button_location].compact.join("-")
24
- @data_attributes[:module] = module_names.join(" ")
25
- @data_attributes[:category] = "Single-page-notification-button"
20
+ @data_attributes[:track_action] = [button_type, "button", button_location].compact.join("-")
21
+ @data_attributes[:module] = "single-page-notification-button" if js_enhancement
22
+ @data_attributes[:track_category] = "Single-page-notification-button"
26
23
  # This attribute is passed through to the personalisation API to ensure when a new button is returned from the API, it has the same button_location
27
24
  @data_attributes[:button_location] = button_location
28
25
  @data_attributes
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = "27.14.1".freeze
2
+ VERSION = "27.17.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: 27.14.1
4
+ version: 27.17.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GOV.UK Dev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-22 00:00:00.000000000 Z
11
+ date: 2021-12-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: govuk_app_config