govuk_publishing_components 24.7.1 → 24.9.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/component_guide/application.js +3 -0
  3. data/app/assets/javascripts/govuk_publishing_components/components/accordion.js +35 -4
  4. data/app/assets/javascripts/govuk_publishing_components/lib/cookie-functions.js +1 -0
  5. data/app/assets/javascripts/govuk_publishing_components/lib/govspeak/magna-charta.js +1 -1
  6. data/app/assets/stylesheets/govuk_publishing_components/components/_action-link.scss +0 -2
  7. data/app/assets/stylesheets/govuk_publishing_components/components/_button.scss +0 -8
  8. data/app/assets/stylesheets/govuk_publishing_components/components/_contextual-sidebar.scss +0 -37
  9. data/app/assets/stylesheets/govuk_publishing_components/components/_highlight-boxes.scss +1 -2
  10. data/app/assets/stylesheets/govuk_publishing_components/components/_image-card.scss +0 -4
  11. data/app/assets/stylesheets/govuk_publishing_components/components/_layout-header.scss +1 -11
  12. data/app/assets/stylesheets/govuk_publishing_components/components/_previous-and-next-navigation.scss +0 -1
  13. data/app/assets/stylesheets/govuk_publishing_components/components/_print-link.scss +0 -1
  14. data/app/assets/stylesheets/govuk_publishing_components/components/_related-navigation.scss +0 -1
  15. data/app/assets/stylesheets/govuk_publishing_components/components/_share-links.scss +0 -1
  16. data/app/assets/stylesheets/govuk_publishing_components/components/_step-by-step-nav-related.scss +0 -4
  17. data/app/assets/stylesheets/govuk_publishing_components/components/_subscription-links.scss +0 -1
  18. data/app/assets/stylesheets/govuk_publishing_components/components/_success-alert.scss +1 -32
  19. data/app/assets/stylesheets/govuk_publishing_components/components/_title.scss +0 -5
  20. data/app/assets/stylesheets/govuk_publishing_components/components/_translation-nav.scss +0 -4
  21. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_button.scss +16 -2
  22. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_charts.scss +0 -1
  23. data/app/assets/stylesheets/govuk_publishing_components/govuk_frontend_support.scss +15 -0
  24. data/app/controllers/govuk_publishing_components/audit_controller.rb +21 -17
  25. data/app/controllers/govuk_publishing_components/component_guide_controller.rb +9 -0
  26. data/app/helpers/govuk_publishing_components/application_helper.rb +3 -0
  27. data/app/models/govuk_publishing_components/audit_applications.rb +3 -3
  28. data/app/models/govuk_publishing_components/audit_comparer.rb +16 -8
  29. data/app/models/govuk_publishing_components/audit_components.rb +6 -3
  30. data/app/views/govuk_publishing_components/audit/_applications.html.erb +126 -0
  31. data/app/views/govuk_publishing_components/audit/_components.html.erb +142 -0
  32. data/app/views/govuk_publishing_components/audit/show.html.erb +22 -277
  33. data/app/views/govuk_publishing_components/component_guide/index.html.erb +18 -2
  34. data/app/views/govuk_publishing_components/component_guide/show.html.erb +1 -1
  35. data/app/views/govuk_publishing_components/components/_accordion.html.erb +25 -0
  36. data/app/views/govuk_publishing_components/components/_highlight_boxes.html.erb +1 -1
  37. data/app/views/govuk_publishing_components/components/_image_card.html.erb +14 -11
  38. data/app/views/govuk_publishing_components/components/_layout_footer.html.erb +7 -2
  39. data/app/views/govuk_publishing_components/components/_layout_header.html.erb +2 -2
  40. data/app/views/govuk_publishing_components/components/_previous_and_next_navigation.html.erb +2 -2
  41. data/app/views/govuk_publishing_components/components/_print_link.html.erb +2 -2
  42. data/app/views/govuk_publishing_components/components/_share_links.html.erb +1 -1
  43. data/app/views/govuk_publishing_components/components/_step_by_step_nav_related.html.erb +4 -4
  44. data/app/views/govuk_publishing_components/components/_subscription_links.html.erb +3 -3
  45. data/app/views/govuk_publishing_components/components/_success_alert.html.erb +24 -8
  46. data/app/views/govuk_publishing_components/components/_title.html.erb +6 -2
  47. data/app/views/govuk_publishing_components/components/_translation_nav.html.erb +1 -1
  48. data/app/views/govuk_publishing_components/components/contextual_sidebar/_brexit_cta.html.erb +9 -27
  49. data/app/views/govuk_publishing_components/components/docs/accordion.yml +73 -73
  50. data/app/views/govuk_publishing_components/components/docs/button.yml +7 -6
  51. data/app/views/govuk_publishing_components/components/docs/image_card.yml +12 -0
  52. data/app/views/govuk_publishing_components/components/docs/modal_dialogue.yml +3 -0
  53. data/app/views/govuk_publishing_components/components/docs/success_alert.yml +17 -1
  54. data/app/views/govuk_publishing_components/components/feedback/_yes_no_banner.html.erb +1 -1
  55. data/app/views/govuk_publishing_components/components/related_navigation/_section.html.erb +2 -1
  56. data/config/locales/cy.yml +0 -5
  57. data/config/locales/en.yml +12 -6
  58. data/lib/govuk_publishing_components/presenters/button_helper.rb +13 -2
  59. data/lib/govuk_publishing_components/presenters/contextual_navigation.rb +0 -4
  60. data/lib/govuk_publishing_components/presenters/public_layout_helper.rb +15 -31
  61. data/lib/govuk_publishing_components/presenters/shared_helper.rb +10 -0
  62. data/lib/govuk_publishing_components/version.rb +1 -1
  63. metadata +24 -2
@@ -13,6 +13,7 @@ module GovukPublishingComponents
13
13
  @components_in_use_sass = components_in_use_sass(false)
14
14
  @components_in_use_print_sass = components_in_use_sass(true)
15
15
  @components_in_use_js = components_in_use_js
16
+ @index_audit_summary = index_audit_summary
16
17
  end
17
18
 
18
19
  def show
@@ -161,5 +162,13 @@ module GovukPublishingComponents
161
162
  h[:url] = component_doc_path(component_doc.id) if component_example
162
163
  end
163
164
  end
165
+
166
+ def index_audit_summary
167
+ components_gem_path = Gem.loaded_specs["govuk_publishing_components"].full_gem_path
168
+ components = AuditComponents.new(components_gem_path, true)
169
+ application = AuditApplications.new(@application_path, GovukPublishingComponents::ApplicationHelper.get_application_name_from_path(@application_path))
170
+ compared_data = AuditComparer.new(components.data, [application.data], true)
171
+ compared_data.applications_data[0]
172
+ end
164
173
  end
165
174
  end
@@ -1,4 +1,7 @@
1
1
  module GovukPublishingComponents
2
2
  module ApplicationHelper
3
+ def self.get_application_name_from_path(path)
4
+ path.to_s.split("/")[-1]
5
+ end
3
6
  end
4
7
  end
@@ -86,8 +86,8 @@ module GovukPublishingComponents
86
86
  gem_style_references = find_code_references(file, src, /gem-c-[-_a-zA-Z]+/)
87
87
  @gem_style_references << gem_style_references if gem_style_references
88
88
  end
89
- rescue StandardError
90
- puts "File #{file} not found"
89
+ rescue StandardError => e
90
+ puts e.message
91
91
  end
92
92
 
93
93
  components_found.flatten.uniq.sort
@@ -108,7 +108,7 @@ module GovukPublishingComponents
108
108
  end
109
109
 
110
110
  def find_code_references(file, src, regex)
111
- clean_file_path = /(?<=#{Regexp.escape(@path)}\/)[\/a-zA-Z_-]+.[a-zA-Z.]+/
111
+ clean_file_path = /(?<=#{Regexp.escape(@path.to_s)}\/)[\/a-zA-Z_-]+.[a-zA-Z.]+/
112
112
 
113
113
  return file[clean_file_path] if regex.match?(src)
114
114
  end
@@ -2,10 +2,10 @@ module GovukPublishingComponents
2
2
  class AuditComparer
3
3
  attr_reader :applications_data, :gem_data
4
4
 
5
- def initialize(gem_data, results)
5
+ def initialize(gem_data, results, simple)
6
6
  if gem_data[:gem_found]
7
7
  @gem_data = gem_data
8
- @applications_data = sort_results(results)
8
+ @applications_data = sort_results(results, simple)
9
9
  @gem_data[:components_by_application] = get_components_by_application || []
10
10
  end
11
11
  end
@@ -16,7 +16,8 @@ module GovukPublishingComponents
16
16
  key.to_s.gsub("_", " ").capitalize
17
17
  end
18
18
 
19
- def sort_results(results)
19
+ def sort_results(results, simple)
20
+ @simple = simple
20
21
  data = []
21
22
 
22
23
  results.each do |result|
@@ -40,10 +41,9 @@ module GovukPublishingComponents
40
41
  warnings << warn_about_jquery_references(result[:jquery_references])
41
42
  warnings = warnings.flatten
42
43
 
43
- data << {
44
- name: result[:name],
45
- application_found: result[:application_found],
46
- summary: [
44
+ summary = []
45
+ unless @simple
46
+ summary = [
47
47
  {
48
48
  name: "Components in templates",
49
49
  value: templates[:components].flatten.uniq.sort.join(", "),
@@ -64,7 +64,13 @@ module GovukPublishingComponents
64
64
  name: "Components in ruby",
65
65
  value: ruby[:components].join(", "),
66
66
  },
67
- ],
67
+ ]
68
+ end
69
+
70
+ data << {
71
+ name: result[:name],
72
+ application_found: result[:application_found],
73
+ summary: summary,
68
74
  warnings: warnings,
69
75
  warning_count: warnings.length,
70
76
  gem_style_references: result[:gem_style_references],
@@ -180,6 +186,8 @@ module GovukPublishingComponents
180
186
  end
181
187
 
182
188
  def get_components_by_application
189
+ return [] if @simple
190
+
183
191
  results = []
184
192
  found_something = false
185
193
 
@@ -2,16 +2,17 @@ module GovukPublishingComponents
2
2
  class AuditComponents
3
3
  attr_reader :data
4
4
 
5
- def initialize(path)
5
+ def initialize(path, simple)
6
6
  @data = {
7
7
  gem_found: false,
8
8
  }
9
- @data = compile_data(path) if Dir.exist?(path)
9
+ @data = compile_data(path, simple) if Dir.exist?(path)
10
10
  end
11
11
 
12
12
  private
13
13
 
14
- def compile_data(path)
14
+ def compile_data(path, simple)
15
+ @simple = simple
15
16
  templates_path = "app/views/govuk_publishing_components/components"
16
17
  stylesheets_path = "app/assets/stylesheets/govuk_publishing_components/components"
17
18
  print_stylesheets_path = "app/assets/stylesheets/govuk_publishing_components/components/print"
@@ -128,6 +129,8 @@ module GovukPublishingComponents
128
129
  end
129
130
 
130
131
  def list_all_component_details
132
+ return [] if @simple
133
+
131
134
  all_component_information = []
132
135
 
133
136
  @components.each do |component|
@@ -0,0 +1,126 @@
1
+ <%
2
+ title = "Applications"
3
+ title = "This application" unless ENV["MAIN_COMPONENT_GUIDE"]
4
+ %>
5
+ <%= render "govuk_publishing_components/components/heading", {
6
+ text: title,
7
+ font_size: "l",
8
+ margin_bottom: 6
9
+ } %>
10
+
11
+ <% if @applications.any? %>
12
+ <%= render "govuk_publishing_components/components/details", {
13
+ title: "How to use this information"
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>
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
+ <% end %>
18
+
19
+ <%
20
+ accordion_content = nil
21
+ summary = nil
22
+ %>
23
+ <% application_items = @applications.map do |application| %>
24
+ <%
25
+ summary = '<strong class="govuk-tag govuk-tag--red">Application not found</strong>'
26
+
27
+ if application[:application_found]
28
+ summary = "Warnings: 0"
29
+ summary = "Warnings: <strong class=\"govuk-tag govuk-tag--red\">#{application[:warning_count]}</strong>" if application[:warning_count] > 0
30
+ end
31
+ %>
32
+
33
+ <% accordion_content = capture do %>
34
+ <% if application[:application_found] %>
35
+ <% application[:warnings].each do |warning| %>
36
+ <p class="govuk-body">
37
+ <strong class="govuk-tag">Warn</strong>
38
+ <strong><%= warning[:component] %></strong> - <%= warning[:message] %>
39
+ </p>
40
+ <% end %>
41
+
42
+ <%= render "govuk_publishing_components/components/heading", {
43
+ text: "Components used",
44
+ font_size: "m",
45
+ margin_bottom: 4,
46
+ heading_level: 3,
47
+ } %>
48
+
49
+ <dl class="govuk-summary-list">
50
+ <% application[:summary].each do |item| %>
51
+ <div class="govuk-summary-list__row">
52
+ <dt class="govuk-summary-list__key">
53
+ <%= item[:name] %>
54
+ </dt>
55
+ <dd class="govuk-summary-list__value">
56
+ <% if item[:value].length > 0 %>
57
+ <%= item[:value] %>
58
+ <% else %>
59
+ None
60
+ <% end %>
61
+ </dd>
62
+ </div>
63
+ <% end %>
64
+ </dl>
65
+
66
+ <% if application[:gem_style_references].any? %>
67
+ <%= render "govuk_publishing_components/components/heading", {
68
+ text: "Component references",
69
+ font_size: "m",
70
+ margin_bottom: 4,
71
+ heading_level: 3,
72
+ } %>
73
+
74
+ <p class="govuk-body">This shows instances of `gem-c-` classes found in the application. If a reference is found in a stylesheet or in code a warning is created, as this could be a style override or hard coded component markup.</p>
75
+ <ul class="govuk-list govuk-list--bullet">
76
+ <% application[:gem_style_references].each do |ref| %>
77
+ <li><%= ref %></li>
78
+ <% end %>
79
+ </ul>
80
+ <% end %>
81
+
82
+ <% if application[:jquery_references].any? %>
83
+ <%= render "govuk_publishing_components/components/heading", {
84
+ text: "jQuery references",
85
+ font_size: "m",
86
+ margin_bottom: 4,
87
+ heading_level: 3,
88
+ } %>
89
+ <p class="govuk-body">This shows JavaScript files that might contain jQuery, which we are trying to remove our dependency on.</p>
90
+ <ul class="govuk-list govuk-list--bullet">
91
+ <% application[:jquery_references].each do |ref| %>
92
+ <li><%= ref %></li>
93
+ <% end %>
94
+ </ul>
95
+ <% end %>
96
+ <% else %>
97
+ <p class="govuk-body">This application was not found. This could be because you do not have this repository checked out locally.</p>
98
+ <% end %>
99
+ <% end %>
100
+
101
+ <%
102
+ {
103
+ heading: {
104
+ text: application[:name]
105
+ },
106
+ summary: {
107
+ text: sanitize(summary)
108
+ },
109
+ content: {
110
+ html: sanitize(accordion_content)
111
+ },
112
+ }
113
+ %>
114
+ <% end %>
115
+
116
+ <% if ENV["MAIN_COMPONENT_GUIDE"] %>
117
+ <%= render "govuk_publishing_components/components/accordion", {
118
+ items: application_items
119
+ } %>
120
+ <% else %>
121
+ <p class="govuk-body"><%= sanitize(summary) %></p>
122
+ <%= accordion_content %>
123
+ <% end %>
124
+ <% else %>
125
+ <p class="govuk-body">No applications found.</p>
126
+ <% end %>
@@ -0,0 +1,142 @@
1
+ <% if @applications_found %>
2
+ <%= render "govuk_publishing_components/components/heading", {
3
+ text: "Components",
4
+ font_size: "l",
5
+ margin_bottom: 6,
6
+ } %>
7
+ <% end %>
8
+
9
+ <% if @components.any? %>
10
+ <% component_items = [] %>
11
+
12
+ <% component_files = capture do %>
13
+ <table class="govuk-table">
14
+ <thead class="govuk-table__head">
15
+ <tr class="govuk-table__row">
16
+ <th scope="col" class="govuk-table__header sticky-table-header">Component</th>
17
+ <th scope="col" class="govuk-table__header sticky-table-header">Stylesheet</th>
18
+ <th scope="col" class="govuk-table__header sticky-table-header">Print stylesheet</th>
19
+ <th scope="col" class="govuk-table__header sticky-table-header">JS</th>
20
+ <th scope="col" class="govuk-table__header sticky-table-header">Test</th>
21
+ <th scope="col" class="govuk-table__header sticky-table-header">JS test</th>
22
+ </tr>
23
+ </thead>
24
+ <tbody class="govuk-table__body">
25
+ <% @components[:component_listing].each do |component| %>
26
+ <tr class="govuk-table__row">
27
+ <th scope="row" class="govuk-table__header">
28
+ <a href="<%= component[:link] %>" class="govuk-link"><%= component[:name] %></a>
29
+ </th>
30
+ <td class="govuk-table__cell">
31
+ <% if component[:stylesheet] %>
32
+ <strong class="govuk-tag govuk-tag--green">Yes</strong>
33
+ <% end %>
34
+ </td>
35
+ <td class="govuk-table__cell">
36
+ <% if component[:print_stylesheet] %>
37
+ <strong class="govuk-tag govuk-tag--green">Yes</strong>
38
+ <% end %>
39
+ </td>
40
+ <td class="govuk-table__cell">
41
+ <% if component[:javascript] %>
42
+ <strong class="govuk-tag govuk-tag--green">Yes</strong>
43
+ <% end %>
44
+ </td>
45
+ <td class="govuk-table__cell">
46
+ <% if component[:tests] %>
47
+ <strong class="govuk-tag govuk-tag--green">Yes</strong>
48
+ <% end %>
49
+ </td>
50
+ <td class="govuk-table__cell">
51
+ <% if component[:js_tests] %>
52
+ <strong class="govuk-tag govuk-tag--green">Yes</strong>
53
+ <% end %>
54
+ </td>
55
+ </tr>
56
+ <% end %>
57
+ </tbody>
58
+ </table>
59
+ <% end %>
60
+
61
+ <%
62
+ component_items << {
63
+ heading: {
64
+ text: "Component files",
65
+ },
66
+ summary: {
67
+ text: "Lists what files each component has",
68
+ },
69
+ content: {
70
+ html: component_files
71
+ },
72
+ }
73
+ %>
74
+
75
+ <% components_within_components = capture do %>
76
+ <dl class="govuk-summary-list">
77
+ <% @components[:components_containing_components].each do |component| %>
78
+ <div class="govuk-summary-list__row">
79
+ <dt class="govuk-summary-list__key">
80
+ <a href="<%= component[:link] %>" class="govuk-link"><%= component[:component] %></a>
81
+ </dt>
82
+ <dd class="govuk-summary-list__value">
83
+ <%= component[:sub_components].join(', ') %>
84
+ </dd>
85
+ </div>
86
+ <% end %>
87
+ </dl>
88
+ <% end %>
89
+
90
+ <%
91
+ component_items << {
92
+ heading: {
93
+ text: "Components containing other components",
94
+ },
95
+ summary: {
96
+ text: "Shows which components contain other components",
97
+ },
98
+ content: {
99
+ html: components_within_components
100
+ },
101
+ }
102
+ %>
103
+
104
+ <% if @applications_found %>
105
+ <% components_by_application = capture do %>
106
+ <% if @components[:components_by_application].any? %>
107
+ <dl class="govuk-summary-list">
108
+ <% @components[:components_by_application].each do |component| %>
109
+ <div class="govuk-summary-list__row">
110
+ <dt class="govuk-summary-list__key">
111
+ <%= component[:component] %> (<%= component[:count] %>)
112
+ </dt>
113
+ <dd class="govuk-summary-list__value">
114
+ <%= component[:list] %>
115
+ </dd>
116
+ </div>
117
+ <% end %>
118
+ </dl>
119
+ <% end %>
120
+ <% end %>
121
+
122
+ <%
123
+ component_items << {
124
+ heading: {
125
+ text: "Components by application",
126
+ },
127
+ summary: {
128
+ text: "Shows which applications use each component",
129
+ },
130
+ content: {
131
+ html: components_by_application
132
+ },
133
+ }
134
+ %>
135
+ <% end %>
136
+
137
+ <%= render "govuk_publishing_components/components/accordion", {
138
+ items: component_items
139
+ } %>
140
+ <% else %>
141
+ <p class="govuk-body">No components found.</p>
142
+ <% end %>
@@ -2,284 +2,29 @@
2
2
 
3
3
  <%= render 'govuk_publishing_components/components/title', title: "Components audit", margin_top: 0; %>
4
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
- <%= render "govuk_publishing_components/components/heading", {
24
- text: "Applications",
25
- font_size: "l",
26
- margin_bottom: 6
27
- } %>
28
-
29
- <% if @applications.any? %>
30
- <details class="govuk-details" data-module="govuk-details">
31
- <summary class="govuk-details__summary">
32
- <span class="govuk-details__summary-text">
33
- How to use this information
34
- </span>
35
- </summary>
36
- <div class="govuk-details__text">
37
- <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>
38
- <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>
39
- </div>
40
- </details>
41
-
42
- <% #application_items = [] %>
43
- <% application_items = @applications.map do |application| %>
44
- <%
45
- summary = '<strong class="govuk-tag govuk-tag--red">Application not found</strong>'
46
-
47
- if application[:application_found]
48
- summary = "Warnings: 0"
49
- if application[:warning_count] > 0
50
- summary = "Warnings: <strong class=\"govuk-tag govuk-tag--red\">#{application[:warning_count]}</strong>"
51
- end
52
- end
53
- %>
54
-
55
- <% accordion_content = capture do %>
56
- <% if application[:application_found] %>
57
- <% application[:warnings].each do |warning| %>
58
- <p class="govuk-body">
59
- <strong class="govuk-tag">Warn</strong>
60
- <strong><%= warning[:component] %></strong> - <%= warning[:message] %>
61
- </p>
62
- <% end %>
63
-
64
- <%= render "govuk_publishing_components/components/heading", {
65
- text: "Components used",
66
- font_size: "m",
67
- margin_bottom: 4,
68
- heading_level: 3,
69
- } %>
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
-
88
- <% if application[:gem_style_references].any? %>
89
- <%= render "govuk_publishing_components/components/heading", {
90
- text: "Component references",
91
- font_size: "m",
92
- margin_bottom: 4,
93
- heading_level: 3,
94
- } %>
95
-
96
- <p class="govuk-body">This shows instances of `gem-c-` classes found in the application. If a reference is found in a stylesheet or in code a warning is created, as this could be a style override or hard coded component markup.</p>
97
- <ul class="govuk-list govuk-list--bullet">
98
- <% application[:gem_style_references].each do |ref| %>
99
- <li><%= ref %></li>
100
- <% end %>
101
- </ul>
102
- <% end %>
103
-
104
- <% if application[:jquery_references].any? %>
105
- <%= render "govuk_publishing_components/components/heading", {
106
- text: "jQuery references",
107
- font_size: "m",
108
- margin_bottom: 4,
109
- heading_level: 3,
110
- } %>
111
- <p class="govuk-body">This shows JavaScript files that might contain jQuery, which we are trying to remove our dependency on.</p>
112
- <ul class="govuk-list govuk-list--bullet">
113
- <% application[:jquery_references].each do |ref| %>
114
- <li><%= ref %></li>
115
- <% end %>
116
- </ul>
117
- <% end %>
118
- <% else %>
119
- <p class="govuk-body">This application was not found. This could be because you do not have this repository checked out locally.</p>
120
- <% end %>
121
- <% end %>
122
-
123
- <%
124
- {
125
- heading: {
126
- text: application[:name]
127
- },
128
- summary: {
129
- text: sanitize(summary)
130
- },
131
- content: {
132
- html: sanitize(accordion_content)
133
- },
134
- }
135
- %>
136
- <% end %>
137
-
138
- <%= render "govuk_publishing_components/components/accordion", {
139
- items: application_items
140
- } %>
141
- <% else %>
142
- <p class="govuk-body">No applications found.</p>
143
- <% end %>
144
- </div>
145
-
146
- <div class="govuk-tabs__panel govuk-tabs__panel--hidden" id="components-gem">
147
- <%= render "govuk_publishing_components/components/heading", {
148
- text: "Components",
149
- font_size: "l",
150
- margin_bottom: 6,
151
- } %>
152
-
153
- <% if @components.any? %>
154
- <% component_files = capture do %>
155
- <table class="govuk-table">
156
- <thead class="govuk-table__head">
157
- <tr class="govuk-table__row">
158
- <th scope="col" class="govuk-table__header sticky-table-header">Component</th>
159
- <th scope="col" class="govuk-table__header sticky-table-header">Stylesheet</th>
160
- <th scope="col" class="govuk-table__header sticky-table-header">Print stylesheet</th>
161
- <th scope="col" class="govuk-table__header sticky-table-header">JS</th>
162
- <th scope="col" class="govuk-table__header sticky-table-header">Test</th>
163
- <th scope="col" class="govuk-table__header sticky-table-header">JS test</th>
164
- </tr>
165
- </thead>
166
- <tbody class="govuk-table__body">
167
- <% @components[:component_listing].each do |component| %>
168
- <tr class="govuk-table__row">
169
- <th scope="row" class="govuk-table__header">
170
- <a href="<%= component[:link] %>" class="govuk-link"><%= component[:name] %></a>
171
- </th>
172
- <td class="govuk-table__cell">
173
- <% if component[:stylesheet] %>
174
- <strong class="govuk-tag govuk-tag--green">Yes</strong>
175
- <% end %>
176
- </td>
177
- <td class="govuk-table__cell">
178
- <% if component[:print_stylesheet] %>
179
- <strong class="govuk-tag govuk-tag--green">Yes</strong>
180
- <% end %>
181
- </td>
182
- <td class="govuk-table__cell">
183
- <% if component[:javascript] %>
184
- <strong class="govuk-tag govuk-tag--green">Yes</strong>
185
- <% end %>
186
- </td>
187
- <td class="govuk-table__cell">
188
- <% if component[:tests] %>
189
- <strong class="govuk-tag govuk-tag--green">Yes</strong>
190
- <% end %>
191
- </td>
192
- <td class="govuk-table__cell">
193
- <% if component[:js_tests] %>
194
- <strong class="govuk-tag govuk-tag--green">Yes</strong>
195
- <% end %>
196
- </td>
197
- </tr>
198
- <% end %>
199
- </tbody>
200
- </table>
201
- <% end %>
202
-
203
- <% components_within_components = capture do %>
204
- <dl class="govuk-summary-list">
205
- <% @components[:components_containing_components].each do |component| %>
206
- <div class="govuk-summary-list__row">
207
- <dt class="govuk-summary-list__key">
208
- <a href="<%= component[:link] %>" class="govuk-link"><%= component[:component] %></a>
209
- </dt>
210
- <dd class="govuk-summary-list__value">
211
- <%= component[:sub_components].join(', ') %>
212
- </dd>
213
- </div>
214
- <% end %>
215
- </dl>
216
- <% end %>
217
-
218
- <% components_by_application = capture do %>
219
- <% if @components[:components_by_application].any? %>
220
- <dl class="govuk-summary-list">
221
- <% @components[:components_by_application].each do |component| %>
222
- <div class="govuk-summary-list__row">
223
- <dt class="govuk-summary-list__key">
224
- <%= component[:component] %> (<%= component[:count] %>)
225
- </dt>
226
- <dd class="govuk-summary-list__value">
227
- <%= component[:list] %>
228
- </dd>
229
- </div>
230
- <% end %>
231
- </dl>
232
- <% else %>
233
- <p class="govuk-body">Sorry, no applications found.</p>
234
- <% end %>
235
- <% end %>
5
+ <% applications = capture do %>
6
+ <%= render "applications" %>
7
+ <% end %>
236
8
 
237
- <%
238
- component_items = [
239
- {
240
- heading: {
241
- text: "Component files",
242
- },
243
- summary: {
244
- text: "Lists what files each component has",
245
- },
246
- content: {
247
- html: component_files
248
- },
249
- },
250
- {
251
- heading: {
252
- text: "Components containing other components",
253
- },
254
- summary: {
255
- text: "Shows which components contain other components",
256
- },
257
- content: {
258
- html: components_within_components
259
- },
260
- },
261
- {
262
- heading: {
263
- text: "Components by application",
264
- },
265
- summary: {
266
- text: "Shows which applications use each component",
267
- },
268
- content: {
269
- html: components_by_application
270
- },
271
- },
272
- ]
273
- %>
9
+ <% components = capture do %>
10
+ <%= render "components" %>
11
+ <% end %>
274
12
 
275
- <%= render "govuk_publishing_components/components/accordion", {
276
- items: component_items
277
- } %>
278
- <% else %>
279
- <p class="govuk-body">No components found.</p>
280
- <% end %>
281
- </div>
282
- </div>
13
+ <% if @applications_found %>
14
+ <%= render "govuk_publishing_components/components/tabs", {
15
+ tabs: [
16
+ {
17
+ id: "applications",
18
+ label: "Applications",
19
+ content: applications,
20
+ },
21
+ {
22
+ id: "components-gem",
23
+ label: "Components",
24
+ content: components,
25
+ }
26
+ ]
27
+ } %>
283
28
  <% else %>
284
- <p class="govuk-body">Component auditing is only available when the component guide is running locally as a standalone app.</p>
29
+ <%= render "components" %>
285
30
  <% end %>