govuk_publishing_components 34.0.0 → 34.5.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 (145) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/images/govuk_publishing_components/icon-search.svg +3 -0
  3. data/app/assets/images/govuk_publishing_components/youtube-play-icon.png +0 -0
  4. data/app/assets/images/govuk_publishing_components/youtube-play-icon.svg +4 -0
  5. data/app/assets/javascripts/govuk_publishing_components/analytics/auto-scroll-tracker.js +2 -1
  6. data/app/assets/javascripts/govuk_publishing_components/analytics/linked-domains.js +135 -0
  7. data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-core.js +1 -40
  8. data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-event-tracker.js +2 -0
  9. data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-page-views.js +4 -4
  10. data/app/assets/javascripts/govuk_publishing_components/analytics-ga4.js +0 -1
  11. data/app/assets/javascripts/govuk_publishing_components/components/cookie-banner.js +2 -2
  12. data/app/assets/javascripts/govuk_publishing_components/components/image-card.js +19 -0
  13. data/app/assets/javascripts/govuk_publishing_components/components/layout-super-navigation-header.js +12 -69
  14. data/app/assets/javascripts/govuk_publishing_components/components/step-by-step-nav.js +14 -13
  15. data/app/assets/javascripts/govuk_publishing_components/dependencies.js +3 -0
  16. data/app/assets/javascripts/govuk_publishing_components/lib/govspeak/youtube-link-enhancement.js +3 -2
  17. data/app/assets/javascripts/govuk_publishing_components/load-analytics.js +209 -0
  18. data/app/assets/javascripts/govuk_publishing_components/modules.js +7 -2
  19. data/app/assets/stylesheets/govuk_publishing_components/components/_feedback.scss +15 -19
  20. data/app/assets/stylesheets/govuk_publishing_components/components/_image-card.scss +82 -1
  21. data/app/assets/stylesheets/govuk_publishing_components/components/_input.scss +1 -1
  22. data/app/assets/stylesheets/govuk_publishing_components/components/_layout-super-navigation-header.scss +247 -412
  23. data/app/assets/stylesheets/govuk_publishing_components/components/_subscription-links.scss +0 -1
  24. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_steps.scss +26 -9
  25. data/app/assets/stylesheets/govuk_publishing_components/components/helpers/_brand-colours.scss +2 -2
  26. data/app/controllers/govuk_publishing_components/application_controller.rb +0 -13
  27. data/app/controllers/govuk_publishing_components/audit_controller.rb +1 -1
  28. data/app/models/govuk_publishing_components/audit_comparer.rb +1 -1
  29. data/app/models/govuk_publishing_components/audit_components.rb +103 -82
  30. data/app/views/govuk_publishing_components/audit/_applications.html.erb +1 -1
  31. data/app/views/govuk_publishing_components/audit/_component_contents.html.erb +47 -39
  32. data/app/views/govuk_publishing_components/audit/_components.html.erb +1 -1
  33. data/app/views/govuk_publishing_components/components/_accordion.html.erb +2 -2
  34. data/app/views/govuk_publishing_components/components/_contextual_footer.html.erb +2 -0
  35. data/app/views/govuk_publishing_components/components/_contextual_sidebar.html.erb +7 -3
  36. data/app/views/govuk_publishing_components/components/_cookie_banner.html.erb +10 -6
  37. data/app/views/govuk_publishing_components/components/_error_message.html.erb +2 -1
  38. data/app/views/govuk_publishing_components/components/_google_tag_manager_script.html.erb +2 -2
  39. data/app/views/govuk_publishing_components/components/_hint.html.erb +2 -1
  40. data/app/views/govuk_publishing_components/components/_image_card.html.erb +12 -9
  41. data/app/views/govuk_publishing_components/components/_input.html.erb +8 -2
  42. data/app/views/govuk_publishing_components/components/_label.html.erb +5 -3
  43. data/app/views/govuk_publishing_components/components/_layout_for_admin.html.erb +2 -2
  44. data/app/views/govuk_publishing_components/components/_layout_for_public.html.erb +6 -2
  45. data/app/views/govuk_publishing_components/components/_layout_super_navigation_header.html.erb +125 -145
  46. data/app/views/govuk_publishing_components/components/_related_navigation.html.erb +12 -6
  47. data/app/views/govuk_publishing_components/components/_subscription_links.html.erb +1 -1
  48. data/app/views/govuk_publishing_components/components/_textarea.html.erb +10 -2
  49. data/app/views/govuk_publishing_components/components/docs/contextual_footer.yml +43 -0
  50. data/app/views/govuk_publishing_components/components/docs/contextual_sidebar.yml +58 -0
  51. data/app/views/govuk_publishing_components/components/docs/emergency_banner.yml +3 -1
  52. data/app/views/govuk_publishing_components/components/docs/error_message.yml +13 -0
  53. data/app/views/govuk_publishing_components/components/docs/hint.yml +6 -0
  54. data/app/views/govuk_publishing_components/components/docs/image_card.yml +24 -1
  55. data/app/views/govuk_publishing_components/components/docs/input.yml +32 -0
  56. data/app/views/govuk_publishing_components/components/docs/intervention.yml +2 -1
  57. data/app/views/govuk_publishing_components/components/docs/label.yml +17 -0
  58. data/app/views/govuk_publishing_components/components/docs/layout_header.yml +1 -0
  59. data/app/views/govuk_publishing_components/components/docs/previous_and_next_navigation.yml +2 -0
  60. data/app/views/govuk_publishing_components/components/docs/related_navigation.yml +27 -0
  61. data/app/views/govuk_publishing_components/components/docs/textarea.yml +31 -0
  62. data/app/views/govuk_publishing_components/components/docs/translation_nav.yml +2 -0
  63. data/app/views/govuk_publishing_components/components/feedback/_problem_form.html.erb +2 -2
  64. data/app/views/govuk_publishing_components/components/feedback/_yes_no_banner.html.erb +1 -2
  65. data/app/views/govuk_publishing_components/components/metadata/_sentence.html.erb +4 -2
  66. data/app/views/govuk_publishing_components/components/related_navigation/_section.html.erb +18 -8
  67. data/app/views/layouts/govuk_publishing_components/application.html.erb +2 -2
  68. data/config/locales/ar.yml +14 -7
  69. data/config/locales/az.yml +14 -7
  70. data/config/locales/be.yml +14 -7
  71. data/config/locales/bg.yml +14 -7
  72. data/config/locales/bn.yml +14 -7
  73. data/config/locales/cs.yml +14 -7
  74. data/config/locales/cy.yml +14 -7
  75. data/config/locales/da.yml +14 -7
  76. data/config/locales/de.yml +14 -7
  77. data/config/locales/dr.yml +14 -7
  78. data/config/locales/el.yml +14 -7
  79. data/config/locales/en.yml +18 -18
  80. data/config/locales/es-419.yml +14 -7
  81. data/config/locales/es.yml +14 -7
  82. data/config/locales/et.yml +14 -7
  83. data/config/locales/fa.yml +14 -7
  84. data/config/locales/fi.yml +14 -7
  85. data/config/locales/fr.yml +14 -7
  86. data/config/locales/gd.yml +14 -7
  87. data/config/locales/gu.yml +14 -7
  88. data/config/locales/he.yml +14 -7
  89. data/config/locales/hi.yml +14 -7
  90. data/config/locales/hr.yml +14 -7
  91. data/config/locales/hu.yml +14 -7
  92. data/config/locales/hy.yml +14 -7
  93. data/config/locales/id.yml +14 -7
  94. data/config/locales/is.yml +14 -7
  95. data/config/locales/it.yml +14 -7
  96. data/config/locales/ja.yml +14 -7
  97. data/config/locales/ka.yml +14 -7
  98. data/config/locales/kk.yml +14 -7
  99. data/config/locales/ko.yml +14 -7
  100. data/config/locales/lt.yml +14 -7
  101. data/config/locales/lv.yml +14 -7
  102. data/config/locales/ms.yml +14 -7
  103. data/config/locales/mt.yml +14 -7
  104. data/config/locales/nl.yml +14 -7
  105. data/config/locales/no.yml +14 -7
  106. data/config/locales/pa-pk.yml +14 -7
  107. data/config/locales/pa.yml +14 -7
  108. data/config/locales/pl.yml +14 -7
  109. data/config/locales/ps.yml +14 -7
  110. data/config/locales/pt.yml +14 -7
  111. data/config/locales/ro.yml +14 -7
  112. data/config/locales/ru.yml +14 -7
  113. data/config/locales/si.yml +14 -7
  114. data/config/locales/sk.yml +14 -7
  115. data/config/locales/sl.yml +14 -7
  116. data/config/locales/so.yml +14 -7
  117. data/config/locales/sq.yml +14 -7
  118. data/config/locales/sr.yml +14 -7
  119. data/config/locales/sv.yml +14 -7
  120. data/config/locales/sw.yml +14 -7
  121. data/config/locales/ta.yml +14 -7
  122. data/config/locales/th.yml +14 -7
  123. data/config/locales/tk.yml +14 -7
  124. data/config/locales/tr.yml +14 -7
  125. data/config/locales/uk.yml +14 -7
  126. data/config/locales/ur.yml +14 -7
  127. data/config/locales/uz.yml +14 -7
  128. data/config/locales/vi.yml +14 -7
  129. data/config/locales/zh-hk.yml +14 -7
  130. data/config/locales/zh-tw.yml +14 -7
  131. data/config/locales/zh.yml +14 -7
  132. data/lib/govuk_publishing_components/presenters/image_card_helper.rb +65 -2
  133. data/lib/govuk_publishing_components/presenters/page_with_step_by_step_navigation.rb +1 -1
  134. data/lib/govuk_publishing_components/presenters/related_navigation_helper.rb +4 -0
  135. data/lib/govuk_publishing_components/version.rb +1 -1
  136. data/node_modules/axe-core/README.md +1 -1
  137. data/node_modules/axe-core/axe.d.ts +76 -24
  138. data/node_modules/axe-core/axe.js +4903 -4648
  139. data/node_modules/axe-core/axe.min.js +3 -3
  140. data/node_modules/axe-core/package.json +28 -28
  141. data/node_modules/axe-core/sri-history.json +16 -0
  142. data/node_modules/govuk-frontend/govuk/helpers/_focused.scss +5 -0
  143. data/node_modules/govuk-frontend/package.json +1 -1
  144. metadata +9 -4
  145. data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/init-ga4.js +0 -28
@@ -123,7 +123,6 @@
123
123
  .gem-c-subscription-links__item--link {
124
124
  padding: govuk-spacing(2) govuk-spacing(2) govuk-spacing(2) 0;
125
125
  border: 1px solid transparent;
126
- border-bottom: 1px solid govuk-colour("dark-grey", $legacy: "grey-1");
127
126
 
128
127
  &:focus {
129
128
  border-bottom-color: transparent;
@@ -3,21 +3,38 @@
3
3
  .steps {
4
4
  padding-left: 0;
5
5
  margin-left: 0;
6
- overflow: hidden;
7
6
 
8
7
  > li {
9
- background-position: 0 .87em;
10
- background-repeat: no-repeat;
11
- list-style-type: decimal;
8
+ list-style-type: none;
12
9
  margin-left: 0;
13
10
  padding: .75em 0 .75em 2.5em;
11
+ position: relative;
12
+
13
+ // IE doesn't render this correctly with this element as display:block
14
+ // (it leaves a space for the :before pseudo element) by setting to
15
+ // display inline block and a width of 100% it works correctly.
16
+ display: inline-block;
17
+ width: 100%;
18
+ box-sizing: border-box;
19
+
20
+ &:before {
21
+ background-color: govuk-colour("black");
22
+ border-radius: 50%;
23
+ color: govuk-colour("white");
24
+ float: left;
25
+ font-size: 80%;
26
+ height: 1.75em;
27
+ left: .3em;
28
+ line-height: 1.75em;
29
+ position: absolute;
30
+ text-align: center;
31
+ top: .9em;
32
+ width: 1.75em;
33
+ }
14
34
 
15
35
  @for $i from 1 through 30 {
16
- &:nth-child(#{$i}) {
17
- background-image: url("data:image/svg+xml, %3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 250 250' preserveAspectRatio='xMinYMin meet'%3E%3Cg%3E%3Ccircle r='50%25' cx='50%25' cy='50%25' class='circle-back'%3E%3C/circle%3E%3Ctext x='50%25' y='50%25' text-anchor='middle' dy='0.3em' font-family='nta,arial,sans-serif' font-size='8rem' fill='%23ffffff'%3E#{$i}%3C/text%3E%3C/g%3E%3C/svg%3E ");
18
- background-repeat: no-repeat;
19
- background-position: .2em .7em;
20
- background-size: 1.4em 1.4em;
36
+ &:nth-child(#{$i}):before {
37
+ content: "#{$i}";
21
38
  }
22
39
  }
23
40
  }
@@ -57,12 +57,12 @@
57
57
 
58
58
  .brand--prime-ministers-office-10-downing-street {
59
59
  .brand__color {
60
- color: govuk-colour("bright-purple");
60
+ color: govuk-colour("black");
61
61
 
62
62
  &:link,
63
63
  &:visited,
64
64
  &:active {
65
- color: govuk-colour("bright-purple");
65
+ color: govuk-colour("black");
66
66
  }
67
67
 
68
68
  &:hover,
@@ -5,19 +5,6 @@ module GovukPublishingComponents
5
5
  before_action :set_x_frame_options_header
6
6
  before_action :set_disable_slimmer_header
7
7
 
8
- if defined? content_security_policy
9
- content_security_policy do |p|
10
- # don't do anything if the app doesn't have a content security policy
11
- next unless p.directives.any?
12
-
13
- # Unfortunately the axe core script uses a dependency that uses eval
14
- # see: https://github.com/dequelabs/axe-core/issues/1175
15
- # Thus all components shown by govuk_publishing_components need this
16
- # enabled
17
- p.script_src(*p.script_src, :unsafe_eval)
18
- end
19
- end
20
-
21
8
  private
22
9
 
23
10
  def set_x_frame_options_header
@@ -34,7 +34,7 @@ module GovukPublishingComponents
34
34
  @in_application = false
35
35
  @in_application = true unless ENV["MAIN_COMPONENT_GUIDE"]
36
36
 
37
- components = AuditComponents.new(gem_path, false)
37
+ components = AuditComponents.new(gem_path)
38
38
  applications = analyse_applications(host_dir, application_dirs)
39
39
  compared_data = AuditComparer.new(components.data, applications)
40
40
 
@@ -252,7 +252,7 @@ module GovukPublishingComponents
252
252
  results = []
253
253
  found_something = false
254
254
 
255
- @gem_data[:component_listing].each do |component|
255
+ @gem_data[:component_file_details].each do |component|
256
256
  component_name = component[:name]
257
257
  locations = []
258
258
 
@@ -2,65 +2,123 @@ module GovukPublishingComponents
2
2
  class AuditComponents
3
3
  attr_reader :data
4
4
 
5
- def initialize(path, simple)
6
- @data = {
7
- gem_found: false,
8
- }
9
- @data = compile_data(path, simple) if Dir.exist?(path)
10
- end
11
-
12
- private
13
-
14
- def compile_data(path, simple)
15
- # simple is used to reduce effort (and therefore page load time) required
16
- # when loading auditing summary on the main component guide page
17
- @simple = simple
18
-
5
+ def initialize(path)
19
6
  # paths to key file locations
20
7
  @templates_path = "app/views/govuk_publishing_components/components"
21
8
  @stylesheets_path = "app/assets/stylesheets/govuk_publishing_components/components"
22
9
  @print_stylesheets_path = "app/assets/stylesheets/govuk_publishing_components/components/print"
23
10
  @javascripts_path = "app/assets/javascripts/govuk_publishing_components/components"
24
11
  @tests_path = "spec/components"
25
- @js_tests_path = "spec/javascripts/components"
12
+ @javascript_tests_path = "spec/javascripts/components"
26
13
  @helpers_path = "lib/govuk_publishing_components/presenters"
27
14
 
28
- # get all files in key file locations
29
- templates = Dir["#{path}/#{@templates_path}/*.erb"]
30
- stylesheets = Dir["#{path}/#{@stylesheets_path}/*.scss"]
31
- print_stylesheets = Dir["#{path}/#{@print_stylesheets_path}/*.scss"]
32
- javascripts = Dir["#{path}/#{@javascripts_path}/*.js"]
33
- tests = Dir["#{path}/#{@tests_path}/*.rb"]
34
- js_tests = Dir["#{path}/#{@js_tests_path}/*.js"]
35
- helpers = Dir["#{path}/#{@helpers_path}/*_helper.rb"]
36
-
15
+ @all_templates = Dir["#{path}/#{@templates_path}/*.erb"].sort
37
16
  @templates_full_path = "#{path}/#{@templates_path}/"
38
17
 
39
- # find the cleaned names of components in key file locations
40
- # i.e. will show that 'component name' has a stylesheet
41
- # standardised like this to be used later for easier comparison
42
- @components = clean_files(templates, [path, @templates_path].join("/"))
43
- @component_stylesheets = clean_files(stylesheets, [path, @stylesheets_path].join("/"))
44
- @component_print_stylesheets = clean_files(print_stylesheets, [path, @print_stylesheets_path].join("/"))
45
- @component_javascripts = clean_files(javascripts, [path, @javascripts_path].join("/"))
46
- @component_tests = clean_files(tests, [path, @tests_path].join("/"))
47
- @component_js_tests = clean_files(js_tests, [path, @js_tests_path].join("/"))
48
- @component_helpers = clean_files(helpers, [path, @helpers_path].join("/"))
18
+ @component_numbers = {
19
+ template: 0,
20
+ stylesheet: 0,
21
+ print_stylesheet: 0,
22
+ javascript: 0,
23
+ test: 0,
24
+ javascript_test: 0,
25
+ helper: 0,
26
+ }
49
27
 
28
+ @data = {
29
+ gem_found: false,
30
+ }
31
+ @data = compile_data(path) if Dir.exist?(path)
32
+ end
33
+
34
+ private
35
+
36
+ def compile_data(path)
50
37
  {
51
38
  gem_found: true,
52
- component_code: @components,
53
- component_stylesheets: @component_stylesheets,
54
- component_print_stylesheets: @component_print_stylesheets,
55
- component_javascripts: @component_javascripts,
56
- component_tests: @component_tests,
57
- component_js_tests: @component_js_tests,
58
- component_helpers: @component_helpers,
59
- components_containing_components: find_all_partials_in(templates),
60
- component_listing: list_all_component_details,
39
+ component_code: clean_files(@all_templates, @templates_full_path).sort,
40
+ components_containing_components: find_all_partials_in(@all_templates),
41
+ component_file_details: get_component_file_details(path),
42
+ component_numbers: @component_numbers,
61
43
  }
62
44
  end
63
45
 
46
+ def get_component_file_details(path)
47
+ component_templates = clean_files(@all_templates, @templates_full_path).sort
48
+ details = []
49
+ component_templates.each do |component|
50
+ component_detail = {
51
+ name: component,
52
+ link: get_component_link(component),
53
+ }
54
+ file_details = [
55
+ {
56
+ type: "template",
57
+ file: "#{[path, @templates_path].join('/')}/_#{component.gsub(' ', '_')}.html.erb",
58
+ },
59
+ {
60
+ type: "stylesheet",
61
+ file: "#{[path, @stylesheets_path].join('/')}/_#{component.gsub(' ', '-')}.scss",
62
+ },
63
+ {
64
+ type: "print_stylesheet",
65
+ file: "#{[path, @stylesheets_path].join('/')}/_#{component.gsub(' ', '-')}.scss",
66
+ },
67
+ {
68
+ type: "javascript",
69
+ file: "#{[path, @javascripts_path].join('/')}/#{component.gsub(' ', '-')}.js",
70
+ },
71
+ {
72
+ type: "test",
73
+ file: "#{[path, @tests_path].join('/')}/#{component.gsub(' ', '_')}_spec.rb",
74
+ },
75
+ {
76
+ type: "javascript_test",
77
+ file: "#{[path, @javascript_tests_path].join('/')}/#{component.gsub(' ', '-')}-spec.js",
78
+ },
79
+ {
80
+ type: "helper",
81
+ file: "#{[path, @helpers_path].join('/')}/#{component.gsub(' ', '_')}_helper.rb",
82
+ },
83
+ ]
84
+ file_details.each do |detail|
85
+ component_detail = component_detail.merge(get_component_asset_detail(detail, component))
86
+ end
87
+
88
+ details << component_detail
89
+ end
90
+
91
+ details
92
+ end
93
+
94
+ def get_component_asset_detail(detail, component)
95
+ details = {}
96
+ type = detail[:type]
97
+ file = detail[:file]
98
+ details["#{type}_exists".to_sym] = false
99
+ if File.file?(file)
100
+ # we don't have separate print stylesheets anymore
101
+ # so check the main stylesheet for print styles
102
+ if type == "print_stylesheet"
103
+ unless File.foreach(file).grep(/(media-type: print)/).empty?
104
+ details["#{type}_exists".to_sym] = true
105
+ @component_numbers[type.to_sym] += 1
106
+ end
107
+ else
108
+ @component_numbers[type.to_sym] += 1
109
+ details["#{type}_exists".to_sym] = true
110
+ details["#{type}_lines".to_sym] = count_lines_in(file)
111
+ details["#{type}_link".to_sym] = get_asset_link(type, component)
112
+ end
113
+ end
114
+
115
+ details
116
+ end
117
+
118
+ def count_lines_in(file)
119
+ File.read(file).each_line.count
120
+ end
121
+
64
122
  def clean_files(files, replace)
65
123
  files.map { |file| clean_file_name(file.gsub(replace, "")) }.sort
66
124
  end
@@ -91,8 +149,6 @@ module GovukPublishingComponents
91
149
  end
92
150
 
93
151
  def find_all_partials_in(templates)
94
- return [] if @simple
95
-
96
152
  components = []
97
153
 
98
154
  templates.each do |template|
@@ -144,52 +200,17 @@ module GovukPublishingComponents
144
200
  end
145
201
  end
146
202
 
147
- def list_all_component_details
148
- return [] if @simple
149
-
150
- all_component_information = []
151
-
152
- @components.each do |component|
153
- all_component_information << {
154
- name: component,
155
- link: get_component_link(component),
156
- stylesheet: check_component_has("stylesheet", component),
157
- print_stylesheet: check_component_has("print_stylesheet", component),
158
- javascript: check_component_has("javascript", component),
159
- tests: check_component_has("test", component),
160
- js_tests: check_component_has("js_test", component),
161
- helper: check_component_has("helper", component),
162
- }
163
- end
164
-
165
- all_component_information
166
- end
167
-
168
- def check_component_has(a_thing, component)
169
- look_in = @component_stylesheets if a_thing == "stylesheet"
170
- look_in = @component_print_stylesheets if a_thing == "print_stylesheet"
171
- look_in = @component_javascripts if a_thing == "javascript"
172
- look_in = @component_tests if a_thing == "test"
173
- look_in = @component_js_tests if a_thing == "js_test"
174
- look_in = @component_helpers if a_thing == "helper"
175
-
176
- if look_in.include?(component)
177
- return get_asset_link(a_thing, component)
178
- end
179
-
180
- false
181
- end
182
-
183
203
  def get_asset_link(a_thing, component)
184
204
  url = "https://github.com/alphagov"
185
205
  repo = "govuk_publishing_components"
186
206
  blob = "blob/main"
187
207
  link = nil
208
+ link = "#{url}/#{repo}/#{blob}/#{@templates_path}/_#{component.gsub(' ', '_')}.html.erb" if a_thing == "template"
188
209
  link = "#{url}/#{repo}/#{blob}/#{@stylesheets_path}/_#{component.gsub(' ', '-')}.scss" if a_thing == "stylesheet"
189
210
  link = "#{url}/#{repo}/#{blob}/#{@print_stylesheets_path}/_#{component.gsub(' ', '-')}.scss" if a_thing == "print_stylesheet"
190
211
  link = "#{url}/#{repo}/#{blob}/#{@javascripts_path}/#{component.gsub(' ', '-')}.js" if a_thing == "javascript"
191
212
  link = "#{url}/#{repo}/#{blob}/#{@tests_path}/#{component.gsub(' ', '_')}_spec.rb" if a_thing == "test"
192
- link = "#{url}/#{repo}/#{blob}/#{@js_tests_path}/#{component.gsub(' ', '-')}-spec.js" if a_thing == "js_test"
213
+ link = "#{url}/#{repo}/#{blob}/#{@javascript_tests_path}/#{component.gsub(' ', '-')}-spec.js" if a_thing == "javascript_test"
193
214
  link = "#{url}/#{repo}/#{blob}/#{@helpers_path}/#{component.gsub(' ', '_')}_helper.rb" if a_thing == "helper"
194
215
 
195
216
  link
@@ -12,7 +12,7 @@
12
12
  <%= render "govuk_publishing_components/components/details", {
13
13
  title: "How to use this information"
14
14
  } do %>
15
- <p class="govuk-body">This page shows information about component use on GOV.UK. This information has been cross referenced with the components in the gem to produce warnings where e.g. a print stylesheet for a component exists but has not been included in an application.</p>
15
+ <p class="govuk-body">This page shows information about component use on GOV.UK. This information has been cross referenced with the components in the gem to produce warnings where e.g. JavaScript for a component exists but has not been included in an application.</p>
16
16
  <p class="govuk-body">Warnings should be investigated, although there may be a reason why the application has been configured as it is. Note that 'code' can refer to templates or ruby code.</p>
17
17
  <% end %>
18
18
 
@@ -1,78 +1,86 @@
1
- <%
2
- total_components = components.length
3
- components_with_stylesheet = 0
4
- components_with_print_stylesheet = 0
5
- components_with_javascript = 0
6
- components_with_test = 0
7
- components_with_javascript_test = 0
8
- components_with_helper = 0
9
-
10
- components.each do |component|
11
- components_with_stylesheet += 1 if component[:stylesheet]
12
- components_with_print_stylesheet += 1 if component[:print_stylesheet]
13
- components_with_javascript += 1 if component[:javascript]
14
- components_with_test += 1 if component[:tests]
15
- components_with_javascript_test += 1 if component[:js_tests]
16
- components_with_helper += 1 if component[:helper]
17
- end
18
- %>
19
1
  <table class="govuk-table">
20
2
  <thead class="govuk-table__head">
21
3
  <tr class="govuk-table__row">
22
- <th scope="col" class="govuk-table__header sticky-table-header">Component (<%= total_components %>)</th>
23
- <th scope="col" class="govuk-table__header sticky-table-header">CSS (<%= components_with_stylesheet %>)</th>
24
- <th scope="col" class="govuk-table__header sticky-table-header">Print CSS (<%= components_with_print_stylesheet %>)</th>
25
- <th scope="col" class="govuk-table__header sticky-table-header">JS (<%= components_with_javascript %>)</th>
26
- <th scope="col" class="govuk-table__header sticky-table-header">Test (<%= components_with_test %>)</th>
27
- <th scope="col" class="govuk-table__header sticky-table-header">JS test (<%= components_with_javascript_test %>)</th>
28
- <th scope="col" class="govuk-table__header sticky-table-header">Helper (<%= components_with_helper %>)</th>
4
+ <th scope="col" class="govuk-table__header sticky-table-header">Component</th>
5
+ <th scope="col" class="govuk-table__header sticky-table-header">Template (<%= @components[:component_numbers][:template] %>)</th>
6
+ <th scope="col" class="govuk-table__header sticky-table-header">CSS (<%= @components[:component_numbers][:stylesheet] %>)</th>
7
+ <th scope="col" class="govuk-table__header sticky-table-header">Print styles (<%= @components[:component_numbers][:print_stylesheet] %>)</th>
8
+ <th scope="col" class="govuk-table__header sticky-table-header">JS (<%= @components[:component_numbers][:javascript] %>)</th>
9
+ <th scope="col" class="govuk-table__header sticky-table-header">Test (<%= @components[:component_numbers][:test] %>)</th>
10
+ <th scope="col" class="govuk-table__header sticky-table-header">JS test (<%= @components[:component_numbers][:javascript_test] %>)</th>
11
+ <th scope="col" class="govuk-table__header sticky-table-header">Helper (<%= @components[:component_numbers][:helper] %>)</th>
29
12
  </tr>
30
13
  </thead>
31
14
  <tbody class="govuk-table__body">
32
- <% components.each do |component| %>
15
+ <% @components[:component_file_details].each do |component| %>
33
16
  <tr class="govuk-table__row">
34
17
  <th scope="row" class="govuk-table__header">
35
- <a href="<%= component[:link] %>" class="govuk-link"><%= component[:name] %></a>
18
+ <a href="<%= component[:link] %>" class="govuk-link">
19
+ <%= component[:name] %>
20
+ </a>
36
21
  </th>
37
22
  <td class="govuk-table__cell">
38
- <% if component[:stylesheet] %>
23
+ <% if component[:template_exists] %>
39
24
  <strong class="govuk-tag govuk-tag--green">
40
- <a href="<%= component[:stylesheet] %>" class="govuk-link">Yes</a>
25
+ <a href="<%= component[:template_link] %>" class="govuk-link">
26
+ <%= component[:template_lines] %>
27
+ <span class="govuk-visually-hidden">lines of code in <%= component[:name] %> template</span>
28
+ </a>
41
29
  </strong>
42
30
  <% end %>
43
31
  </td>
44
32
  <td class="govuk-table__cell">
45
- <% if component[:print_stylesheet] %>
33
+ <% if component[:stylesheet_exists] %>
46
34
  <strong class="govuk-tag govuk-tag--green">
47
- <a href="<%= component[:print_stylesheet] %>" class="govuk-link">Yes</a>
35
+ <a href="<%= component[:stylesheet_link] %>" class="govuk-link">
36
+ <%= component[:stylesheet_lines] %>
37
+ <span class="govuk-visually-hidden">lines of code in <%= component[:name] %> stylesheet</span>
38
+ </a>
48
39
  </strong>
49
40
  <% end %>
50
41
  </td>
51
42
  <td class="govuk-table__cell">
52
- <% if component[:javascript] %>
43
+ <% if component[:print_stylesheet_exists] %>
44
+ <strong class="govuk-tag govuk-tag--green">Yes</strong>
45
+ <% end %>
46
+ </td>
47
+ <td class="govuk-table__cell">
48
+ <% if component[:javascript_exists] %>
53
49
  <strong class="govuk-tag govuk-tag--green">
54
- <a href="<%= component[:javascript] %>" class="govuk-link">Yes</a>
50
+ <a href="<%= component[:javascript_link] %>" class="govuk-link">
51
+ <%= component[:javascript_lines] %>
52
+ <span class="govuk-visually-hidden">lines of code in <%= component[:name] %> javascript</span>
53
+ </a>
55
54
  </strong>
56
55
  <% end %>
57
56
  </td>
58
57
  <td class="govuk-table__cell">
59
- <% if component[:tests] %>
58
+ <% if component[:test_exists] %>
60
59
  <strong class="govuk-tag govuk-tag--green">
61
- <a href="<%= component[:tests] %>" class="govuk-link">Yes</a>
60
+ <a href="<%= component[:test_link] %>" class="govuk-link">
61
+ <%= component[:test_lines] %>
62
+ <span class="govuk-visually-hidden">lines of code in <%= component[:name] %> test</span>
63
+ </a>
62
64
  </strong>
63
65
  <% end %>
64
66
  </td>
65
67
  <td class="govuk-table__cell">
66
- <% if component[:js_tests] %>
68
+ <% if component[:javascript_test_exists] %>
67
69
  <strong class="govuk-tag govuk-tag--green">
68
- <a href="<%= component[:js_tests] %>" class="govuk-link">Yes</a>
70
+ <a href="<%= component[:javascript_test_link] %>" class="govuk-link">
71
+ <%= component[:javascript_test_lines] %>
72
+ <span class="govuk-visually-hidden">lines of code in <%= component[:name] %> javascript test</span>
73
+ </a>
69
74
  </strong>
70
75
  <% end %>
71
76
  </td>
72
77
  <td class="govuk-table__cell">
73
- <% if component[:helper] %>
78
+ <% if component[:helper_exists] %>
74
79
  <strong class="govuk-tag govuk-tag--green">
75
- <a href="<%= component[:helper] %>" class="govuk-link">Yes</a>
80
+ <a href="<%= component[:helper_link] %>" class="govuk-link">
81
+ <%= component[:helper_lines] %>
82
+ <span class="govuk-visually-hidden">lines of code in <%= component[:name] %> helper</span>
83
+ </a>
76
84
  </strong>
77
85
  <% end %>
78
86
  </td>
@@ -10,7 +10,7 @@
10
10
  <% component_items = [] %>
11
11
 
12
12
  <% component_files = capture do %>
13
- <%= render partial: "component_contents", locals: { components: @components[:component_listing] } %>
13
+ <%= render partial: "component_contents" %>
14
14
  <% end %>
15
15
 
16
16
  <%
@@ -12,8 +12,8 @@
12
12
  accordion_classes << (shared_helper.get_margin_bottom)
13
13
 
14
14
  translations = {
15
- show_text: "components.accordion.show",
16
- hide_text: "components.accordion.hide",
15
+ show_text: "common.show",
16
+ hide_text: "common.hide",
17
17
  show_all_text: "components.accordion.show_all",
18
18
  hide_all_text: "components.accordion.hide_all",
19
19
  this_section_visually_hidden: "components.accordion.this_section_visually_hidden",
@@ -1,10 +1,12 @@
1
1
  <% navigation = GovukPublishingComponents::Presenters::ContextualNavigation.new(content_item, request) %>
2
+ <% ga4_tracking ||= false %>
2
3
 
3
4
  <% unless navigation.content_tagged_to_current_step_by_step? %>
4
5
  <div class="gem-c-contextual-footer">
5
6
  <%# Rendering related navigation because no step by step list %>
6
7
  <%= render 'govuk_publishing_components/components/related_navigation',
7
8
  content_item: content_item,
9
+ ga4_tracking: ga4_tracking,
8
10
  context: :footer %>
9
11
  </div>
10
12
  <% end %>
@@ -1,5 +1,9 @@
1
- <% navigation = GovukPublishingComponents::Presenters::ContextualNavigation.new(content_item, request) %>
2
- <% shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns) %>
1
+ <%
2
+ ga4_tracking ||= false
3
+ request.query_parameters[:ga4_tracking] = ga4_tracking
4
+ navigation = GovukPublishingComponents::Presenters::ContextualNavigation.new(content_item, request)
5
+ shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)
6
+ %>
3
7
 
4
8
  <div class="gem-c-contextual-sidebar">
5
9
  <% if navigation.content_tagged_to_a_reasonable_number_of_step_by_steps? %>
@@ -12,7 +16,7 @@
12
16
  <%= render 'govuk_publishing_components/components/step_by_step_nav', navigation.step_nav_helper.sidebar %>
13
17
  <% else %>
14
18
  <%# Rendering related navigation sidebar because no step by step list %>
15
- <%= render 'govuk_publishing_components/components/related_navigation', content_item: content_item, context: :sidebar %>
19
+ <%= render 'govuk_publishing_components/components/related_navigation', content_item: content_item, context: :sidebar, ga4_tracking: ga4_tracking %>
16
20
  <% end %>
17
21
 
18
22
  <% if navigation.content_tagged_to_other_step_by_steps? %>
@@ -14,9 +14,9 @@
14
14
  text = raw(text)
15
15
 
16
16
  cookie_preferences_href ||= "/help/cookies"
17
- confirmation_message ||= raw(t("components.cookie_banner.confirmation_message_html",
17
+ confirmation_message ||= raw(t("components.cookie_banner.confirmation_message.html",
18
18
  link: link_to(
19
- t("components.cookie_banner.confirmation_message_link"),
19
+ t("components.cookie_banner.confirmation_message.link"),
20
20
  cookie_preferences_href,
21
21
  class: "govuk-link",
22
22
  data: {
@@ -29,8 +29,8 @@
29
29
  css_classes = %w(gem-c-cookie-banner govuk-clearfix)
30
30
  css_classes << "gem-c-cookie-banner--services" if services_cookies
31
31
  %>
32
- <div id="<%= id %>" class="<%= css_classes.join(' ') %>" data-module="cookie-banner" role="region" aria-label="cookie banner" data-nosnippet>
33
- <div class="govuk-cookie-banner js-banner-wrapper" role="region" aria-label="<%= title %>">
32
+ <div id="<%= id %>" class="<%= css_classes.join(' ') %>" data-module="cookie-banner" data-nosnippet role="region" aria-label="<%= title %>">
33
+ <div class="govuk-cookie-banner js-banner-wrapper">
34
34
  <div class="gem-c-cookie-banner__message govuk-cookie-banner__message govuk-width-container">
35
35
  <div class="govuk-grid-row">
36
36
  <div class="govuk-grid-column-two-thirds">
@@ -79,13 +79,17 @@
79
79
  "track-action": "Cookie banner rejected",
80
80
  }
81
81
  } %>
82
- <a class="govuk-link" href="<%= cookie_preferences_href %>">View cookies</a>
82
+ <a class="govuk-link" href="<%= cookie_preferences_href %>"><%= t("components.cookie_banner.buttons.view_cookies") %></a>
83
83
  </div>
84
84
  <% end %>
85
85
  </div>
86
86
  </div>
87
87
  <div class="gem-c-cookie-banner__confirmation govuk-width-container" tabindex="-1" hidden>
88
- <p class="gem-c-cookie-banner__confirmation-message" role="alert"><%= confirmation_message %></p>
88
+ <p class="gem-c-cookie-banner__confirmation-message" role="alert">
89
+ <span class="gem-c-cookie-banner__confirmation-message__accepted" hidden><%= t("components.cookie_banner.confirmation_message.accepted") %>. </span>
90
+ <span class="gem-c-cookie-banner__confirmation-message__rejected" hidden><%= t("components.cookie_banner.confirmation_message.rejected") %>. </span>
91
+ <%= confirmation_message %>
92
+ </p>
89
93
  <div class="govuk-button-group">
90
94
  <button class="gem-c-cookie-banner__hide-button govuk-button" data-hide-cookie-banner="true" data-module="gem-track-click" data-track-category="cookieBanner" data-track-action="Hide cookie banner"><%= t("components.cookie_banner.hide") %></button>
91
95
  </div>
@@ -4,12 +4,13 @@
4
4
  css_classes = %w( gem-c-error-message govuk-error-message )
5
5
  css_classes << classes if classes
6
6
  items ||= []
7
+ right_to_left ||= false
7
8
 
8
9
  if items.any?
9
10
  errors = items.map { |item| capture { item[:text] } }
10
11
  text = raw(errors.join("<br />"))
11
12
  end
12
13
  %>
13
- <%= tag.p id: id, class: css_classes do %>
14
+ <%= tag.p id: id, class: css_classes, dir: right_to_left ? "rtl" : nil do %>
14
15
  <span class="govuk-visually-hidden">Error:</span> <%= text %>
15
16
  <% end %>
@@ -7,7 +7,7 @@
7
7
  gtm_attributes << "gtm_preview=" + gtm_preview if gtm_preview
8
8
  gtm_attributes = gtm_attributes.join('&')
9
9
  %>
10
- <script>
10
+ <%= javascript_tag nonce: true do -%>
11
11
  var doNotTrack = ( navigator.doNotTrack === '1' || navigator.doNotTrack === 'yes' || navigator.msDoNotTrack === '1' || window.doNotTrack === '1' )
12
12
  if (!doNotTrack) {
13
13
  (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
@@ -16,4 +16,4 @@ if (!doNotTrack) {
16
16
  'https://www.googletagmanager.com/gtm.js?id='+i+dl+'&<%= raw gtm_attributes %>';f.parentNode.insertBefore(j,f);
17
17
  })(window,document,'script','dataLayer','<%= gtm_id %>');
18
18
  }
19
- </script>
19
+ <% end -%>
@@ -1,11 +1,12 @@
1
1
  <%
2
2
  id ||= "hint-#{SecureRandom.hex(4)}"
3
+ right_to_left ||= false
3
4
  shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)
4
5
 
5
6
  css_classes = %w( gem-c-hint govuk-hint )
6
7
  css_classes << shared_helper.get_margin_bottom
7
8
  %>
8
9
 
9
- <%= tag.div id: id, class: css_classes do %>
10
+ <%= tag.div id: id, class: css_classes, dir: right_to_left ? "rtl" : nil do %>
10
11
  <%= text %>
11
12
  <% end %>