govuk_publishing_components 24.7.1 → 24.8.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 (21) 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/lib/cookie-functions.js +1 -0
  4. data/app/assets/stylesheets/govuk_publishing_components/components/_title.scss +0 -5
  5. data/app/controllers/govuk_publishing_components/audit_controller.rb +21 -17
  6. data/app/controllers/govuk_publishing_components/component_guide_controller.rb +9 -0
  7. data/app/helpers/govuk_publishing_components/application_helper.rb +3 -0
  8. data/app/models/govuk_publishing_components/audit_applications.rb +3 -3
  9. data/app/models/govuk_publishing_components/audit_comparer.rb +16 -8
  10. data/app/models/govuk_publishing_components/audit_components.rb +6 -3
  11. data/app/views/govuk_publishing_components/audit/_applications.html.erb +126 -0
  12. data/app/views/govuk_publishing_components/audit/_components.html.erb +142 -0
  13. data/app/views/govuk_publishing_components/audit/show.html.erb +22 -277
  14. data/app/views/govuk_publishing_components/component_guide/index.html.erb +16 -0
  15. data/app/views/govuk_publishing_components/components/_layout_footer.html.erb +7 -2
  16. data/app/views/govuk_publishing_components/components/_title.html.erb +6 -2
  17. data/app/views/govuk_publishing_components/components/docs/button.yml +7 -6
  18. data/lib/govuk_publishing_components/presenters/button_helper.rb +13 -2
  19. data/lib/govuk_publishing_components/presenters/public_layout_helper.rb +15 -31
  20. data/lib/govuk_publishing_components/version.rb +1 -1
  21. metadata +4 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '074209cc8cf7975851223f792a29424abb775b78c2ed6bce585c8e46ab68bc3a'
4
- data.tar.gz: a64f7263144e2b04dfe4db0d6b3021127af456eeb9f0684100b2cbd15c827ba4
3
+ metadata.gz: '0970bb03929bfc783d477b903ce46f8f8fa47ad800b74303f61c4f2e473a914e'
4
+ data.tar.gz: e1bc0b5d89be175278b988b30b85269b7128fc9fa5fbb3286b582bf66c91b7f0
5
5
  SHA512:
6
- metadata.gz: 17cccd57d154c927f27966026425ace752d20ca33f2ea4bf4f55916d3573cd5e025135ac3ad3626bd90b653691b908ef26d0603c7551c2d0bc03f7383f0fddfe
7
- data.tar.gz: 82364e977616a9aa28772a3486cb2c551a3272cad5be29ff6d93af3fbb6dcca86498c7d7cb61dab831649674b192b7c8c8b467e13c5cb55938428e80564b0a7c
6
+ metadata.gz: 7dfb6d556b81cc890eec0fa6884a7738d2c47b0b5bba80d0f8b35788682ba8cd0c4d9528370f7175c3b2361f47592fa405ebb43e8b5fa43954fc57bc23960dcc
7
+ data.tar.gz: 3e58e5f9b229c8c85e734b74fd2ba98db39cd9f66ba80bab12cf8ac6acc8a482a059f200d9b721e530c190a6dff73915c9641377a77afaef5506eef8d4ca9aaf
@@ -1,2 +1,5 @@
1
1
  //= require_tree ./vendor
2
2
  //= require_tree .
3
+ //= require ../govuk_publishing_components/dependencies
4
+ //= require ../govuk_publishing_components/components/accordion
5
+ //= require ../govuk_publishing_components/components/tabs
@@ -25,6 +25,7 @@
25
25
  govuk_browser_upgrade_dismisssed: 'settings',
26
26
  govuk_not_first_visit: 'settings',
27
27
  analytics_next_page_call: 'usage',
28
+ user_nation: 'settings',
28
29
  _ga: 'usage',
29
30
  _gid: 'usage',
30
31
  _gat: 'usage',
@@ -26,10 +26,5 @@
26
26
  }
27
27
 
28
28
  .gem-c-title__text {
29
- @extend %govuk-heading-xl;
30
29
  margin: 0;
31
30
  }
32
-
33
- .gem-c-title__text--long {
34
- @extend %govuk-heading-l;
35
- }
@@ -1,22 +1,7 @@
1
1
  module GovukPublishingComponents
2
2
  class AuditController < GovukPublishingComponents::ApplicationController
3
3
  def show
4
- path = Dir.pwd
5
-
6
- components = AuditComponents.new(path)
7
- applications = analyse_applications(File.expand_path("..", path))
8
- compared_data = AuditComparer.new(components.data, applications)
9
-
10
- @applications = compared_data.applications_data || []
11
- @components = compared_data.gem_data || []
12
- end
13
-
14
- private
15
-
16
- def analyse_applications(path)
17
- results = []
18
- applications = %w[
19
- calculators
4
+ application_dirs = %w[
20
5
  collections
21
6
  collections-publisher
22
7
  content-data-admin
@@ -42,10 +27,29 @@ module GovukPublishingComponents
42
27
  travel-advice-publisher
43
28
  whitehall
44
29
  ].sort
30
+ application_dirs = [GovukPublishingComponents::ApplicationHelper.get_application_name_from_path(Rails.root)] unless ENV["MAIN_COMPONENT_GUIDE"]
31
+
32
+ gem_path = Gem.loaded_specs["govuk_publishing_components"].full_gem_path
33
+ gem_path = Dir.pwd if ENV["MAIN_COMPONENT_GUIDE"]
34
+
35
+ components = AuditComponents.new(gem_path, false)
36
+ applications = analyse_applications(File.expand_path("..", gem_path), application_dirs)
37
+ compared_data = AuditComparer.new(components.data, applications, false)
38
+
39
+ @applications = compared_data.applications_data || []
40
+ @components = compared_data.gem_data || []
41
+ end
42
+
43
+ private
44
+
45
+ def analyse_applications(path, application_dirs)
46
+ results = []
47
+ @applications_found = false
45
48
 
46
- applications.each do |application|
49
+ application_dirs.each do |application|
47
50
  application_path = [path, application].join("/")
48
51
  app = AuditApplications.new(application_path, application)
52
+ @applications_found = true if app.data[:application_found]
49
53
  results << app.data
50
54
  end
51
55
 
@@ -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 %>
@@ -1,5 +1,21 @@
1
1
  <%= render 'govuk_publishing_components/components/title', title: GovukPublishingComponents::Config.component_guide_title, margin_top: 0 %>
2
2
 
3
+ <% unless ENV["MAIN_COMPONENT_GUIDE"] %>
4
+ <p class="govuk-body">
5
+ <% if @index_audit_summary[:application_found] %>
6
+ Warnings:
7
+ <% if @index_audit_summary[:warning_count] > 0 %>
8
+ <strong class="govuk-tag govuk-tag--red"><%= @index_audit_summary[:warning_count] %></strong>
9
+ <% else %>
10
+ <%= @index_audit_summary[:warning_count] %>
11
+ <% end %>
12
+ <a href="/component-guide/audit" class="govuk-link">Warning details</a>
13
+ <% else %>
14
+ <strong class="govuk-tag govuk-tag--red">Application not found</strong>
15
+ <% end %>
16
+ </p>
17
+ <% end %>
18
+
3
19
  <div class="component-markdown">
4
20
  <p>Components are packages of template, style, behaviour and documentation that live in your application.</p>
5
21
  <p>See the <a href="https://github.com/alphagov/govuk_publishing_components">govuk_publishing_components gem</a> for further details, or <a href="https://docs.publishing.service.gov.uk/manual/components.html#component-guides">a list of all component guides</a>.</p>
@@ -21,8 +21,13 @@
21
21
  width_class = "govuk-grid-column-one-third"
22
22
  end
23
23
 
24
- list_classes = %w( govuk-footer__list )
25
- list_classes << "govuk-footer__list--columns-#{item[:columns]}" if item[:columns]
24
+ # If the list has multiple columns and there is only one link.
25
+ # This is to prevent a long link wrapping in a column, which
26
+ # leaves an obvious blank space to the right.
27
+ single_item_list = (( item[:columns] == 2 || item[:columns] == 3 ) && item[:items].length == 1 )
28
+
29
+ list_classes = %w[govuk-footer__list]
30
+ list_classes << "govuk-footer__list--columns-#{item[:columns]}" if item[:columns] unless single_item_list
26
31
  %>
27
32
  <div class="<%= width_class %>">
28
33
  <h2 class="govuk-footer__heading govuk-heading-m"><%= item[:title] %></h2>
@@ -1,5 +1,6 @@
1
1
  <%
2
2
  average_title_length ||= false
3
+
3
4
  context ||= false
4
5
  context_locale ||= false
5
6
  context_text = context.is_a?(Hash) ? context[:text] : context
@@ -12,10 +13,13 @@
12
13
 
13
14
  shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)
14
15
 
15
- classes = %w(gem-c-title)
16
+ classes = %w[gem-c-title]
16
17
  classes << "gem-c-title--inverse" if inverse
17
18
  classes << (shared_helper.get_margin_top)
18
19
  classes << (shared_helper.get_margin_bottom)
20
+
21
+ heading_classes = %w[gem-c-title__text]
22
+ heading_classes << (average_title_length.present? ? 'govuk-heading-l' : 'govuk-heading-xl')
19
23
  %>
20
24
  <%= content_tag(:div, class: classes) do %>
21
25
  <% if context %>
@@ -23,7 +27,7 @@
23
27
  <%= context_href ? link_to(context_text, context_href, class: 'gem-c-title__context-link govuk-link', data: context_data) : context_text %>
24
28
  </span>
25
29
  <% end %>
26
- <h1 class="gem-c-title__text <% if average_title_length %>gem-c-title__text--<%= average_title_length %><% end %>">
30
+ <h1 class="<%= heading_classes.join(" ") %>">
27
31
  <%= title %>
28
32
  </h1>
29
33
  <% end %>
@@ -66,18 +66,19 @@ examples:
66
66
  href: "#"
67
67
  start: true
68
68
  info_text: "Sometimes you want to explain where a user is going to."
69
+ with_margin_bottom:
70
+ description: "The component accepts a number for margin bottom from 0 to 9 (0px to 60px) using the [GOV.UK Frontend spacing scale](https://design-system.service.gov.uk/styles/spacing/#the-responsive-spacing-scale). It defaults to having no margin bottom."
71
+ data:
72
+ text: "Submit"
73
+ margin_bottom: 6
69
74
  start_now_button_with_info_text_and_margin_bottom:
75
+ description: "When the component requires margin bottom and has info text, the margin is applied to the info text."
70
76
  data:
71
77
  text: "Start now"
72
78
  href: "#"
73
79
  start: true
74
80
  info_text: "Sometimes you want to explain where a user is going to and have a margin bottom"
75
- margin_bottom: true
76
- with_margin_bottom:
77
- description: "Sometimes it's useful to break up a page, for example if a button is at the bottom of a page."
78
- data:
79
- text: "Submit"
80
- margin_bottom: true
81
+ margin_bottom: 6
81
82
  extreme_text:
82
83
  data:
83
84
  text: "I'm a button with lots of text to test how the component scales at extremes."
@@ -31,7 +31,8 @@ module GovukPublishingComponents
31
31
  @info_text = local_assigns[:info_text]
32
32
  @info_text_classes = %w[gem-c-button__info-text]
33
33
  if local_assigns[:margin_bottom]
34
- @info_text_classes << "gem-c-button__info-text--bottom-margin"
34
+ margin_class = get_margin_bottom(local_assigns[:margin_bottom], true)
35
+ @info_text_classes << margin_class
35
36
  end
36
37
  @rel = local_assigns[:rel]
37
38
  @data_attributes = local_assigns[:data_attributes]
@@ -81,11 +82,21 @@ module GovukPublishingComponents
81
82
  css_classes << "gem-c-button--secondary-quiet" if secondary_quiet
82
83
  css_classes << "govuk-button--secondary" if secondary_solid
83
84
  css_classes << "govuk-button--warning" if destructive
84
- css_classes << "gem-c-button--bottom-margin" if margin_bottom && !info_text
85
+ if margin_bottom && !info_text
86
+ margin_class = get_margin_bottom(margin_bottom, false)
87
+ css_classes << margin_class
88
+ end
85
89
  css_classes << "gem-c-button--inline" if inline_layout
86
90
  css_classes << classes if classes
87
91
  css_classes.join(" ")
88
92
  end
93
+
94
+ def get_margin_bottom(margin, info_text)
95
+ legacy_class = "gem-c-button--bottom-margin"
96
+ legacy_class = "gem-c-button__info-text--bottom-margin" if info_text
97
+
98
+ [*0..9].include?(margin) ? "govuk-!-margin-bottom-#{margin}" : legacy_class
99
+ end
89
100
  end
90
101
  end
91
102
  end
@@ -3,50 +3,34 @@ module GovukPublishingComponents
3
3
  class PublicLayoutHelper
4
4
  FOOTER_NAV = [
5
5
  {
6
- title: "Prepare for Brexit",
6
+ title: "Coronavirus (COVID-19)",
7
7
  columns: 2,
8
8
  items: [
9
9
  {
10
- href: "/business-uk-leaving-eu",
11
- text: "Prepare your business or organisation for Brexit",
10
+ href: "/coronavirus",
11
+ text: "Coronavirus (COVID-19): guidance and support",
12
12
  attributes: {
13
13
  data: {
14
14
  track_category: "footerClicked",
15
- track_action: "brexitLinks",
16
- track_label: "Prepare your business or organisation for the UK leaving the EU",
17
- },
18
- },
19
- },
20
- {
21
- href: "/prepare-eu-exit",
22
- text: "Prepare for Brexit if you live in the UK",
23
- attributes: {
24
- data: {
25
- track_category: "footerClicked",
26
- track_action: "brexitLinks",
27
- track_label: "Prepare for Brexit if you live in the UK",
28
- },
29
- },
30
- },
31
- {
32
- href: "/uk-nationals-living-eu",
33
- text: "Living in Europe after Brexit",
34
- attributes: {
35
- data: {
36
- track_category: "footerClicked",
37
- track_action: "brexitLinks",
38
- track_label: "Living in Europe after Brexit",
15
+ track_action: "coronavirusLinks",
16
+ track_label: "Coronavirus (COVID-19): guidance and support",
39
17
  },
40
18
  },
41
19
  },
20
+ ],
21
+ },
22
+ {
23
+ title: "Brexit",
24
+ columns: 1,
25
+ items: [
42
26
  {
43
- href: "/staying-uk-eu-citizen",
44
- text: "Continue to live in the UK after Brexit",
27
+ href: "/transition",
28
+ text: "Check what you need to do",
45
29
  attributes: {
46
30
  data: {
47
31
  track_category: "footerClicked",
48
- track_action: "brexitLinks",
49
- track_label: "Continue to live in the UK after Brexit",
32
+ track_action: "transitionLinks",
33
+ track_label: "Check what you need to do",
50
34
  },
51
35
  },
52
36
  },
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = "24.7.1".freeze
2
+ VERSION = "24.8.0".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk_publishing_components
3
3
  version: !ruby/object:Gem::Version
4
- version: 24.7.1
4
+ version: 24.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GOV.UK Dev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-23 00:00:00.000000000 Z
11
+ date: 2021-03-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: govuk_app_config
@@ -592,6 +592,8 @@ files:
592
592
  - app/models/govuk_publishing_components/component_docs.rb
593
593
  - app/models/govuk_publishing_components/component_example.rb
594
594
  - app/models/govuk_publishing_components/shared_accessibility_criteria.rb
595
+ - app/views/govuk_publishing_components/audit/_applications.html.erb
596
+ - app/views/govuk_publishing_components/audit/_components.html.erb
595
597
  - app/views/govuk_publishing_components/audit/show.html.erb
596
598
  - app/views/govuk_publishing_components/component_guide/_application_stylesheet.html.erb
597
599
  - app/views/govuk_publishing_components/component_guide/component_doc/_call.html.erb