govuk_publishing_components 21.57.0 → 21.60.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (96) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +31 -6
  3. data/app/assets/javascripts/component_guide/accessibility-test.js +21 -21
  4. data/app/assets/javascripts/component_guide/filter-components.js +19 -19
  5. data/app/assets/javascripts/component_guide/visual-regression.js +38 -37
  6. data/app/assets/javascripts/govuk_publishing_components/components/checkboxes.js +2 -2
  7. data/app/assets/javascripts/govuk_publishing_components/components/details.js +6 -4
  8. data/app/assets/javascripts/govuk_publishing_components/components/step-by-step-nav.js +4 -4
  9. data/app/assets/javascripts/govuk_publishing_components/lib/auto-track-event.js +31 -0
  10. data/app/assets/javascripts/govuk_publishing_components/lib/cookie-functions.js +24 -24
  11. data/app/assets/javascripts/govuk_publishing_components/lib/govspeak/youtube-link-enhancement.js +17 -17
  12. data/app/assets/stylesheets/component_guide/application.scss +15 -15
  13. data/app/assets/stylesheets/govuk_publishing_components/components/_action-link.scss +1 -9
  14. data/app/assets/stylesheets/govuk_publishing_components/components/_breadcrumbs.scss +1 -1
  15. data/app/assets/stylesheets/govuk_publishing_components/components/_checkboxes.scss +4 -0
  16. data/app/assets/stylesheets/govuk_publishing_components/components/_cookie-banner.scss +1 -8
  17. data/app/assets/stylesheets/govuk_publishing_components/components/_feedback.scss +0 -1
  18. data/app/assets/stylesheets/govuk_publishing_components/components/_govspeak-html-publication.scss +4 -5
  19. data/app/assets/stylesheets/govuk_publishing_components/components/_heading.scss +3 -8
  20. data/app/assets/stylesheets/govuk_publishing_components/components/_image-card.scss +1 -1
  21. data/app/assets/stylesheets/govuk_publishing_components/components/_input.scss +1 -1
  22. data/app/assets/stylesheets/govuk_publishing_components/components/_inverse-header.scss +5 -8
  23. data/app/assets/stylesheets/govuk_publishing_components/components/_list.scss +1 -0
  24. data/app/assets/stylesheets/govuk_publishing_components/components/_radio.scss +4 -0
  25. data/app/assets/stylesheets/govuk_publishing_components/components/_related-navigation.scss +2 -2
  26. data/app/assets/stylesheets/govuk_publishing_components/components/_search.scss +7 -3
  27. data/app/assets/stylesheets/govuk_publishing_components/components/_step-by-step-nav-header.scss +0 -5
  28. data/app/assets/stylesheets/govuk_publishing_components/components/_step-by-step-nav-related.scss +1 -4
  29. data/app/assets/stylesheets/govuk_publishing_components/components/_step-by-step-nav.scss +8 -12
  30. data/app/assets/stylesheets/govuk_publishing_components/components/_table.scss +21 -24
  31. data/app/assets/stylesheets/govuk_publishing_components/components/_tabs.scss +4 -8
  32. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_attachment.scss +2 -0
  33. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_button.scss +1 -4
  34. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_charts.scss +6 -6
  35. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_contact.scss +2 -0
  36. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_footnotes.scss +2 -0
  37. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_highlight-answer.scss +2 -0
  38. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_place.scss +1 -1
  39. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_typography.scss +2 -0
  40. data/app/assets/stylesheets/govuk_publishing_components/components/helpers/_markdown-typography.scss +1 -1
  41. data/app/assets/stylesheets/govuk_publishing_components/components/print/_govspeak.scss +2 -0
  42. data/app/assets/stylesheets/govuk_publishing_components/components/print/_step-by-step-nav-header.scss +0 -4
  43. data/app/assets/stylesheets/govuk_publishing_components/components/print/_step-by-step-nav.scss +2 -10
  44. data/app/controllers/govuk_publishing_components/audit_controller.rb +52 -0
  45. data/app/controllers/govuk_publishing_components/component_guide_controller.rb +2 -1
  46. data/app/models/govuk_publishing_components/audit_applications.rb +105 -0
  47. data/app/models/govuk_publishing_components/audit_comparer.rb +185 -0
  48. data/app/models/govuk_publishing_components/audit_components.rb +158 -0
  49. data/app/views/govuk_publishing_components/audit/show.html.erb +229 -0
  50. data/app/views/govuk_publishing_components/component_guide/index.html.erb +9 -4
  51. data/app/views/govuk_publishing_components/components/_breadcrumbs.html.erb +1 -1
  52. data/app/views/govuk_publishing_components/components/_list.html.erb +26 -0
  53. data/app/views/govuk_publishing_components/components/_machine_readable_metadata.html.erb +1 -1
  54. data/app/views/govuk_publishing_components/components/_radio.html.erb +13 -5
  55. data/app/views/govuk_publishing_components/components/_step_by_step_nav_header.html.erb +2 -2
  56. data/app/views/govuk_publishing_components/components/docs/checkboxes.yml +4 -0
  57. data/app/views/govuk_publishing_components/components/docs/govspeak.yml +45 -0
  58. data/app/views/govuk_publishing_components/components/docs/heading.yml +6 -3
  59. data/app/views/govuk_publishing_components/components/docs/list.yml +64 -0
  60. data/app/views/govuk_publishing_components/components/docs/radio.yml +4 -0
  61. data/config/routes.rb +1 -0
  62. data/lib/govuk_publishing_components/presenters/checkboxes_helper.rb +15 -7
  63. data/lib/govuk_publishing_components/presenters/heading_helper.rb +21 -1
  64. data/lib/govuk_publishing_components/version.rb +1 -1
  65. data/node_modules/axe-core/package.json +145 -220
  66. data/node_modules/govuk-frontend/govuk/all.js +160 -57
  67. data/node_modules/govuk-frontend/govuk/components/character-count/character-count.js +16 -8
  68. data/node_modules/govuk-frontend/govuk/components/character-count/macro-options.json +6 -0
  69. data/node_modules/govuk-frontend/govuk/components/character-count/template.njk +1 -0
  70. data/node_modules/govuk-frontend/govuk/components/checkboxes/_index.scss +6 -5
  71. data/node_modules/govuk-frontend/govuk/components/checkboxes/checkboxes.js +68 -21
  72. data/node_modules/govuk-frontend/govuk/components/date-input/macro-options.json +1 -1
  73. data/node_modules/govuk-frontend/govuk/components/file-upload/_index.scss +0 -27
  74. data/node_modules/govuk-frontend/govuk/components/footer/_index.scss +0 -3
  75. data/node_modules/govuk-frontend/govuk/components/footer/template.njk +1 -1
  76. data/node_modules/govuk-frontend/govuk/components/header/template.njk +1 -1
  77. data/node_modules/govuk-frontend/govuk/components/hint/_index.scss +2 -2
  78. data/node_modules/govuk-frontend/govuk/components/hint/template.njk +2 -2
  79. data/node_modules/govuk-frontend/govuk/components/input/_index.scss +0 -3
  80. data/node_modules/govuk-frontend/govuk/components/input/macro-options.json +6 -0
  81. data/node_modules/govuk-frontend/govuk/components/input/template.njk +1 -0
  82. data/node_modules/govuk-frontend/govuk/components/radios/radios.js +76 -28
  83. data/node_modules/govuk-frontend/govuk/components/select/_index.scss +0 -3
  84. data/node_modules/govuk-frontend/govuk/components/skip-link/_index.scss +1 -0
  85. data/node_modules/govuk-frontend/govuk/components/textarea/_index.scss +0 -3
  86. data/node_modules/govuk-frontend/govuk/components/textarea/macro-options.json +6 -0
  87. data/node_modules/govuk-frontend/govuk/components/textarea/template.njk +1 -0
  88. data/node_modules/govuk-frontend/govuk/components/warning-text/_index.scss +4 -2
  89. data/node_modules/govuk-frontend/govuk/helpers/_colour.scss +1 -1
  90. data/node_modules/govuk-frontend/govuk/settings/_colours-applied.scss +2 -2
  91. data/node_modules/govuk-frontend/govuk/settings/_colours-palette.scss +1 -1
  92. data/node_modules/govuk-frontend/govuk/settings/_measurements.scss +4 -1
  93. data/node_modules/govuk-frontend/package.json +14 -81
  94. data/node_modules/jquery/package.json +44 -116
  95. metadata +46 -66
  96. data/Rakefile +0 -32
@@ -0,0 +1,185 @@
1
+ module GovukPublishingComponents
2
+ class AuditComparer
3
+ attr_reader :applications_data, :gem_data
4
+
5
+ def initialize(gem_data, results)
6
+ if gem_data[:gem_found]
7
+ @gem_data = gem_data
8
+ @applications_data = sort_results(results)
9
+ @gem_data[:components_by_application] = get_components_by_application || []
10
+ end
11
+ end
12
+
13
+ private
14
+
15
+ def prettify_key(key)
16
+ key.to_s.gsub("_", " ").capitalize
17
+ end
18
+
19
+ def sort_results(results)
20
+ data = []
21
+
22
+ results.each do |result|
23
+ if result[:application_found]
24
+ templates = result[:components_found].find { |c| c[:location] == "templates" }
25
+ stylesheets = result[:components_found].find { |c| c[:location] == "stylesheets" }
26
+ print_stylesheets = result[:components_found].find { |c| c[:location] == "print_stylesheets" }
27
+ javascripts = result[:components_found].find { |c| c[:location] == "javascripts" }
28
+ ruby = result[:components_found].find { |c| c[:location] == "ruby" }
29
+
30
+ @all_stylesheets = true if stylesheets[:components].include?("all")
31
+ @all_print_stylesheets = true if print_stylesheets[:components].include?("all")
32
+ @all_javascripts = true if javascripts[:components].include?("all")
33
+
34
+ templates[:components] = include_any_components_within_components(templates[:components])
35
+
36
+ warnings = []
37
+ warnings << warn_about_missing_components(result[:components_found])
38
+ warnings << warn_about_missing_assets(result[:components_found])
39
+ warnings = warnings.flatten
40
+
41
+ data << {
42
+ name: result[:name],
43
+ application_found: result[:application_found],
44
+ summary: [
45
+ {
46
+ name: "Components in templates",
47
+ value: templates[:components].flatten.uniq.sort.join(", "),
48
+ },
49
+ {
50
+ name: "Components in stylesheets",
51
+ value: stylesheets[:components].join(", "),
52
+ },
53
+ {
54
+ name: "Components in print stylesheets",
55
+ value: print_stylesheets[:components].join(", "),
56
+ },
57
+ {
58
+ name: "Components in javascripts",
59
+ value: javascripts[:components].join(", "),
60
+ },
61
+ {
62
+ name: "Components in ruby",
63
+ value: ruby[:components].join(", "),
64
+ },
65
+ ],
66
+ warnings: warnings,
67
+ warning_count: warnings.length,
68
+ }
69
+ else
70
+ data << {
71
+ name: result[:name],
72
+ application_found: result[:application_found],
73
+ }
74
+ end
75
+ end
76
+
77
+ data
78
+ end
79
+
80
+ def include_any_components_within_components(components)
81
+ @gem_data[:components_containing_components].each do |component|
82
+ components << component[:sub_components] if components.include?(component[:component])
83
+ end
84
+
85
+ components.flatten.uniq.sort
86
+ end
87
+
88
+ def create_warning(component, message)
89
+ {
90
+ component: component,
91
+ message: message,
92
+ }
93
+ end
94
+
95
+ def find_missing_items(first_group, second_group)
96
+ warnings = []
97
+
98
+ first_group.each do |first|
99
+ first_location = first[:location]
100
+
101
+ second_group.each do |second|
102
+ second_location = second[:location]
103
+ second_location = "code" if %w[templates ruby].include?(second_location)
104
+ in_current = find_missing(second[:components].clone, first[:components].clone)
105
+
106
+ next if second[:components].include?("all")
107
+
108
+ in_current.each do |component|
109
+ if @gem_data.include?("component_#{second_location}".to_sym)
110
+ warnings << create_warning(component, "Included in #{first_location} but not #{second_location}") if @gem_data["component_#{second_location}".to_sym].include?(component)
111
+ end
112
+ end
113
+ end
114
+ end
115
+
116
+ warnings
117
+ end
118
+
119
+ def warn_about_missing_assets(components)
120
+ warnings = []
121
+
122
+ code = components.select { |c| c[:location] == "templates" || c[:location] == "ruby" }
123
+ code = [
124
+ {
125
+ location: "code",
126
+ components: code.map { |c| c[:components] }.flatten.uniq.sort,
127
+ },
128
+ ]
129
+ assets = components.select { |c| c[:location] == "stylesheets" || c[:location] == "print_stylesheets" || c[:location] == "javascripts" }
130
+
131
+ warnings << find_missing_items(code, assets)
132
+ warnings << find_missing_items(assets, code)
133
+ warnings.flatten
134
+ end
135
+
136
+ def warn_about_missing_components(results)
137
+ warnings = []
138
+
139
+ results.each do |result|
140
+ location = result[:location]
141
+ result[:components].each do |component|
142
+ warnings << create_warning(component, "Included in #{location} but component does not exist") if component_does_not_exist(component)
143
+ end
144
+ end
145
+
146
+ warnings
147
+ end
148
+
149
+ def component_does_not_exist(component)
150
+ !@gem_data[:component_code].include?(component) unless component == "all"
151
+ end
152
+
153
+ def find_missing(needle, haystack)
154
+ (haystack - needle).flatten.sort
155
+ end
156
+
157
+ def get_components_by_application
158
+ results = []
159
+ found_something = false
160
+
161
+ @gem_data[:component_listing].each do |component|
162
+ found_in_applications = []
163
+
164
+ @applications_data.each do |application|
165
+ next unless application[:application_found]
166
+
167
+ name = application[:name]
168
+ found_something = true
169
+
170
+ application[:summary].each do |item|
171
+ found_in_applications << name if item[:value].include?(component[:name])
172
+ end
173
+ end
174
+
175
+ results << {
176
+ component: component[:name],
177
+ count: found_in_applications.uniq.length,
178
+ list: found_in_applications.uniq.join(", "),
179
+ }
180
+ end
181
+
182
+ results if found_something
183
+ end
184
+ end
185
+ end
@@ -0,0 +1,158 @@
1
+ module GovukPublishingComponents
2
+ class AuditComponents
3
+ attr_reader :data
4
+
5
+ def initialize(path)
6
+ @data = {
7
+ gem_found: false,
8
+ }
9
+ @data = compile_data(path) if Dir.exist?(path)
10
+ end
11
+
12
+ private
13
+
14
+ def compile_data(path)
15
+ templates_path = "app/views/govuk_publishing_components/components"
16
+ stylesheets_path = "app/assets/stylesheets/govuk_publishing_components/components"
17
+ print_stylesheets_path = "app/assets/stylesheets/govuk_publishing_components/components/print"
18
+ javascripts_path = "app/assets/javascripts/govuk_publishing_components/components"
19
+ tests_path = "spec/components"
20
+ js_tests_path = "spec/javascripts/components"
21
+
22
+ templates = Dir["#{path}/#{templates_path}/*.erb"]
23
+ stylesheets = Dir["#{path}/#{stylesheets_path}/*.scss"]
24
+ print_stylesheets = Dir["#{path}/#{print_stylesheets_path}/*.scss"]
25
+ javascripts = Dir["#{path}/#{javascripts_path}/*.js"]
26
+ tests = Dir["#{path}/#{tests_path}/*.rb"]
27
+ js_tests = Dir["#{path}/#{js_tests_path}/*.js"]
28
+
29
+ @templates_full_path = "#{path}/#{templates_path}/"
30
+
31
+ @components = find_files(templates, [path, templates_path].join("/"))
32
+ @component_stylesheets = find_files(stylesheets, [path, stylesheets_path].join("/"))
33
+ @component_print_stylesheets = find_files(print_stylesheets, [path, print_stylesheets_path].join("/"))
34
+ @component_javascripts = find_files(javascripts, [path, javascripts_path].join("/"))
35
+ @component_tests = find_files(tests, [path, tests_path].join("/"))
36
+ @component_js_tests = find_files(js_tests, [path, js_tests_path].join("/"))
37
+
38
+ {
39
+ gem_found: true,
40
+ component_code: @components,
41
+ component_stylesheets: @component_stylesheets,
42
+ component_print_stylesheets: @component_print_stylesheets,
43
+ component_javascripts: @component_javascripts,
44
+ component_tests: @component_tests,
45
+ component_js_tests: @component_js_tests,
46
+ components_containing_components: find_all_partials_in(templates),
47
+ component_listing: list_all_component_details,
48
+ }
49
+ end
50
+
51
+ def find_files(files, replace)
52
+ files.map { |file| clean_file_name(file.gsub(replace, "")) }.sort
53
+ end
54
+
55
+ def clean_file_name(name)
56
+ name.tr("/_-", " ")
57
+ .gsub(".html.erb", "")
58
+ .gsub(".erb", "")
59
+ .gsub(".scss", "")
60
+ .gsub(".js", "")
61
+ .gsub("spec", "")
62
+ .gsub(".rb", "")
63
+ .strip
64
+ end
65
+
66
+ def get_component_name_from_full_path(path)
67
+ path.gsub(/.*\K\/_/, "/")
68
+ .gsub(@templates_full_path, "")
69
+ .gsub(".html.erb", "")
70
+ .gsub(".erb", "")
71
+ .tr('\"\'', "")
72
+ end
73
+
74
+ def get_component_link(component)
75
+ "/component-guide/#{component.gsub(' ', '_')}"
76
+ end
77
+
78
+ def find_all_partials_in(templates)
79
+ components = []
80
+
81
+ templates.each do |template|
82
+ partials_found = true
83
+ components_to_search = [template]
84
+ components_found = []
85
+
86
+ while partials_found
87
+ extra_components = find_partials_in(components_to_search)
88
+
89
+ if extra_components.any?
90
+ components_found << extra_components
91
+ components_to_search = extra_components
92
+ else
93
+ partials_found = false
94
+ components_found = components_found.flatten.reject { |c| c.include?("/") }
95
+
96
+ if components_found.any?
97
+ component_name = clean_file_name(get_component_name_from_full_path(template))
98
+ components << {
99
+ component: component_name,
100
+ link: get_component_link(component_name),
101
+ sub_components: components_found.uniq.sort.map { |name| clean_file_name(name) },
102
+ }
103
+ end
104
+ end
105
+ end
106
+ end
107
+
108
+ components.sort_by { |c| c[:component] }
109
+ end
110
+
111
+ def find_partials_in(components)
112
+ extra_components = []
113
+ components.each do |component|
114
+ extra_components << components_within_component(component)
115
+ end
116
+
117
+ extra_components.flatten.uniq.sort
118
+ end
119
+
120
+ def components_within_component(file)
121
+ file = get_component_name_from_full_path(file)
122
+ file = "#{@templates_full_path}#{file}.html.erb".sub(/.*\K\//, "/_")
123
+ data = File.read(file)
124
+ match = data.scan(/["']{1}(govuk_publishing_components\/components\/[\/a-z_-]+["']{1})/)
125
+ match.flatten.uniq.map(&:to_s).sort.map do |m|
126
+ m.gsub("govuk_publishing_components/components/", "").tr('\"\'', "")
127
+ end
128
+ end
129
+
130
+ def list_all_component_details
131
+ all_component_information = []
132
+
133
+ @components.each do |component|
134
+ all_component_information << {
135
+ name: component,
136
+ link: get_component_link(component),
137
+ stylesheet: check_component_has("stylesheet", component),
138
+ print_stylesheet: check_component_has("print_stylesheet", component),
139
+ javascript: check_component_has("javascript", component),
140
+ tests: check_component_has("test", component),
141
+ js_tests: check_component_has("js_test", component),
142
+ }
143
+ end
144
+
145
+ all_component_information
146
+ end
147
+
148
+ def check_component_has(a_thing, component)
149
+ look_in = @component_stylesheets if a_thing == "stylesheet"
150
+ look_in = @component_print_stylesheets if a_thing == "print_stylesheet"
151
+ look_in = @component_javascripts if a_thing == "javascript"
152
+ look_in = @component_tests if a_thing == "test"
153
+ look_in = @component_js_tests if a_thing == "js_test"
154
+
155
+ true if look_in.include?(component)
156
+ end
157
+ end
158
+ end
@@ -0,0 +1,229 @@
1
+ <% content_for :title, "Component audit" %>
2
+
3
+ <%= render 'govuk_publishing_components/components/title', title: "Components audit", margin_top: 0; %>
4
+
5
+ <% if ENV["MAIN_COMPONENT_GUIDE"] %>
6
+ <div class="govuk-tabs" data-module="govuk-tabs">
7
+ <h2 class="govuk-tabs__title">
8
+ Contents
9
+ </h2>
10
+ <ul class="govuk-tabs__list">
11
+ <li class="govuk-tabs__list-item govuk-tabs__list-item--selected">
12
+ <a class="govuk-tabs__tab" href="#applications">
13
+ Applications
14
+ </a>
15
+ </li>
16
+ <li class="govuk-tabs__list-item">
17
+ <a class="govuk-tabs__tab" href="#components-gem">
18
+ Components
19
+ </a>
20
+ </li>
21
+ </ul>
22
+ <div class="govuk-tabs__panel" id="applications">
23
+ <h2 class="govuk-heading-l">Applications</h2>
24
+
25
+ <% if @applications.any? %>
26
+ <details class="govuk-details" data-module="govuk-details">
27
+ <summary class="govuk-details__summary">
28
+ <span class="govuk-details__summary-text">
29
+ How to use this information
30
+ </span>
31
+ </summary>
32
+ <div class="govuk-details__text">
33
+ <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>
34
+ <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>
35
+ </div>
36
+ </details>
37
+
38
+ <div class="govuk-accordion" data-module="govuk-accordion" id="accordion-with-summary-sections">
39
+ <% @applications.each_with_index do |application, index| %>
40
+ <div class="govuk-accordion__section ">
41
+ <div class="govuk-accordion__section-header">
42
+ <h2 class="govuk-accordion__section-heading">
43
+ <span class="govuk-accordion__section-button" id="accordion-with-summary-sections-heading-<%= index %>">
44
+ <%= application[:name] %>
45
+ </span>
46
+ </h2>
47
+ <div class="govuk-accordion__section-summary govuk-body" id="accordion-with-summary-sections-summary-<%= index %>">
48
+ <% if application[:application_found] %>
49
+ Warnings:
50
+ <% if application[:warning_count] > 0 %>
51
+ <strong class="govuk-tag govuk-tag--red"><%= application[:warning_count] %></strong>
52
+ <% else %>
53
+ <%= application[:warning_count] %>
54
+ <% end %>
55
+ <% else %>
56
+ <strong class="govuk-tag govuk-tag--red">Application not found</strong>
57
+ <% end %>
58
+ </div>
59
+ </div>
60
+ <div id="accordion-with-summary-sections-content-<%= index %>" class="govuk-accordion__section-content" aria-labelledby="accordion-with-summary-sections-heading-<%= index %>">
61
+ <% if application[:application_found] %>
62
+ <% application[:warnings].each do |warning| %>
63
+ <p class="govuk-body">
64
+ <strong class="govuk-tag">Warn</strong>
65
+ <strong><%= warning[:component] %></strong> - <%= warning[:message] %>
66
+ </p>
67
+ <% end %>
68
+
69
+ <h3 class="govuk-heading-m">Components used</h3>
70
+
71
+ <dl class="govuk-summary-list">
72
+ <% application[:summary].each do |item| %>
73
+ <div class="govuk-summary-list__row">
74
+ <dt class="govuk-summary-list__key">
75
+ <%= item[:name] %>
76
+ </dt>
77
+ <dd class="govuk-summary-list__value">
78
+ <% if item[:value].length > 0 %>
79
+ <%= item[:value] %>
80
+ <% else %>
81
+ None
82
+ <% end %>
83
+ </dd>
84
+ </div>
85
+ <% end %>
86
+ </dl>
87
+ <% else %>
88
+ <p class="govuk-body">This application was not found. This could be because you do not have this repository checked out locally.</p>
89
+ <% end %>
90
+ </div>
91
+ </div>
92
+ <% end %>
93
+ </div>
94
+ <% else %>
95
+ <p class="govuk-body">No applications found.</p>
96
+ <% end %>
97
+ </div>
98
+
99
+ <div class="govuk-tabs__panel govuk-tabs__panel--hidden" id="components-gem">
100
+ <h2 class="govuk-heading-l">Components</h2>
101
+
102
+ <% if @components.any? %>
103
+ <div class="govuk-accordion" data-module="govuk-accordion" id="accordion-default">
104
+ <div class="govuk-accordion__section ">
105
+ <div class="govuk-accordion__section-header">
106
+ <h2 class="govuk-accordion__section-heading">
107
+ <span class="govuk-accordion__section-button" id="accordion-default-heading-1">
108
+ Component files
109
+ </span>
110
+ </h2>
111
+ <div class="govuk-accordion__section-summary govuk-body" id="accordion-with-summary-sections-summary-1">
112
+ Lists what files each component has
113
+ </div>
114
+ </div>
115
+ <div id="accordion-default-content-1" class="govuk-accordion__section-content" aria-labelledby="accordion-default-heading-1">
116
+ <table class="govuk-table">
117
+ <thead class="govuk-table__head">
118
+ <tr class="govuk-table__row">
119
+ <th scope="col" class="govuk-table__header sticky-table-header">Component</th>
120
+ <th scope="col" class="govuk-table__header sticky-table-header">Stylesheet</th>
121
+ <th scope="col" class="govuk-table__header sticky-table-header">Print stylesheet</th>
122
+ <th scope="col" class="govuk-table__header sticky-table-header">JS</th>
123
+ <th scope="col" class="govuk-table__header sticky-table-header">Test</th>
124
+ <th scope="col" class="govuk-table__header sticky-table-header">JS test</th>
125
+ </tr>
126
+ </thead>
127
+ <tbody class="govuk-table__body">
128
+ <% @components[:component_listing].each do |component| %>
129
+ <tr class="govuk-table__row">
130
+ <th scope="row" class="govuk-table__header">
131
+ <a href="<%= component[:link] %>" class="govuk-link"><%= component[:name] %></a>
132
+ </th>
133
+ <td class="govuk-table__cell">
134
+ <% if component[:stylesheet] %>
135
+ <strong class="govuk-tag govuk-tag--green">Yes</strong>
136
+ <% end %>
137
+ </td>
138
+ <td class="govuk-table__cell">
139
+ <% if component[:print_stylesheet] %>
140
+ <strong class="govuk-tag govuk-tag--green">Yes</strong>
141
+ <% end %>
142
+ </td>
143
+ <td class="govuk-table__cell">
144
+ <% if component[:javascript] %>
145
+ <strong class="govuk-tag govuk-tag--green">Yes</strong>
146
+ <% end %>
147
+ </td>
148
+ <td class="govuk-table__cell">
149
+ <% if component[:tests] %>
150
+ <strong class="govuk-tag govuk-tag--green">Yes</strong>
151
+ <% end %>
152
+ </td>
153
+ <td class="govuk-table__cell">
154
+ <% if component[:js_tests] %>
155
+ <strong class="govuk-tag govuk-tag--green">Yes</strong>
156
+ <% end %>
157
+ </td>
158
+ </tr>
159
+ <% end %>
160
+ </tbody>
161
+ </table>
162
+ </div>
163
+ </div>
164
+
165
+ <div class="govuk-accordion__section ">
166
+ <div class="govuk-accordion__section-header">
167
+ <h2 class="govuk-accordion__section-heading">
168
+ <span class="govuk-accordion__section-button" id="accordion-default-heading-2">
169
+ Components containing components
170
+ </span>
171
+ </h2>
172
+ <div class="govuk-accordion__section-summary govuk-body" id="accordion-with-summary-sections-summary-2">
173
+ Shows which components contain other components
174
+ </div>
175
+ </div>
176
+ <div id="accordion-default-content-2" class="govuk-accordion__section-content" aria-labelledby="accordion-default-heading-2">
177
+ <dl class="govuk-summary-list">
178
+ <% @components[:components_containing_components].each do |component| %>
179
+ <div class="govuk-summary-list__row">
180
+ <dt class="govuk-summary-list__key">
181
+ <a href="<%= component[:link] %>" class="govuk-link"><%= component[:component] %></a>
182
+ </dt>
183
+ <dd class="govuk-summary-list__value">
184
+ <%= component[:sub_components].join(', ') %>
185
+ </dd>
186
+ </div>
187
+ <% end %>
188
+ </dl>
189
+ </div>
190
+ </div>
191
+ <div class="govuk-accordion__section ">
192
+ <div class="govuk-accordion__section-header">
193
+ <h2 class="govuk-accordion__section-heading">
194
+ <span class="govuk-accordion__section-button" id="accordion-default-heading-2">
195
+ Components by application
196
+ </span>
197
+ </h2>
198
+ <div class="govuk-accordion__section-summary govuk-body" id="accordion-with-summary-sections-summary-2">
199
+ Shows which applications use each component
200
+ </div>
201
+ </div>
202
+ <div id="accordion-default-content-2" class="govuk-accordion__section-content" aria-labelledby="accordion-default-heading-2">
203
+ <% if @components[:components_by_application].any? %>
204
+ <dl class="govuk-summary-list">
205
+ <% @components[:components_by_application].each do |component| %>
206
+ <div class="govuk-summary-list__row">
207
+ <dt class="govuk-summary-list__key">
208
+ <%= component[:component] %> (<%= component[:count] %>)
209
+ </dt>
210
+ <dd class="govuk-summary-list__value">
211
+ <%= component[:list] %>
212
+ </dd>
213
+ </div>
214
+ <% end %>
215
+ </dl>
216
+ <% else %>
217
+ <p class="govuk-body">Sorry, no applications found.</p>
218
+ <% end %>
219
+ </div>
220
+ </div>
221
+ </div>
222
+ <% else %>
223
+ <p class="govuk-body">No components found.</p>
224
+ <% end %>
225
+ </div>
226
+ </div>
227
+ <% else %>
228
+ <p class="govuk-body">Component auditing is only available when the component guide is running locally as a standalone app.</p>
229
+ <% end %>