govuk_publishing_components 24.5.0 → 24.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) 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 +7 -5
  4. data/app/assets/javascripts/govuk_publishing_components/components/details.js +2 -1
  5. data/app/assets/javascripts/govuk_publishing_components/lib/cookie-functions.js +1 -0
  6. data/app/assets/javascripts/govuk_publishing_components/modules.js +3 -1
  7. data/app/assets/stylesheets/component_guide/application.scss +1 -1
  8. data/app/assets/stylesheets/govuk_publishing_components/components/_layout-for-public.scss +10 -1
  9. data/app/assets/stylesheets/govuk_publishing_components/components/_layout-header.scss +8 -7
  10. data/app/assets/stylesheets/govuk_publishing_components/components/_search.scss +15 -1
  11. data/app/assets/stylesheets/govuk_publishing_components/components/_summary-list.scss +12 -0
  12. data/app/assets/stylesheets/govuk_publishing_components/components/_title.scss +0 -5
  13. data/app/controllers/govuk_publishing_components/audit_controller.rb +21 -17
  14. data/app/controllers/govuk_publishing_components/component_guide_controller.rb +9 -0
  15. data/app/helpers/govuk_publishing_components/application_helper.rb +3 -0
  16. data/app/models/govuk_publishing_components/audit_applications.rb +3 -3
  17. data/app/models/govuk_publishing_components/audit_comparer.rb +16 -8
  18. data/app/models/govuk_publishing_components/audit_components.rb +6 -3
  19. data/app/views/govuk_publishing_components/audit/_applications.html.erb +126 -0
  20. data/app/views/govuk_publishing_components/audit/_components.html.erb +142 -0
  21. data/app/views/govuk_publishing_components/audit/show.html.erb +22 -277
  22. data/app/views/govuk_publishing_components/component_guide/index.html.erb +16 -0
  23. data/app/views/govuk_publishing_components/components/_layout_footer.html.erb +7 -2
  24. data/app/views/govuk_publishing_components/components/_layout_for_public.html.erb +48 -7
  25. data/app/views/govuk_publishing_components/components/_layout_header.html.erb +15 -12
  26. data/app/views/govuk_publishing_components/components/_summary_list.html.erb +18 -13
  27. data/app/views/govuk_publishing_components/components/_title.html.erb +6 -2
  28. data/app/views/govuk_publishing_components/components/docs/button.yml +7 -6
  29. data/app/views/govuk_publishing_components/components/docs/contextual_sidebar.yml +3 -0
  30. data/app/views/govuk_publishing_components/components/docs/layout_for_public.yml +26 -0
  31. data/app/views/govuk_publishing_components/components/docs/summary_list.yml +50 -19
  32. data/app/views/govuk_publishing_components/components/layout_header/_navigation_items.html.erb +8 -1
  33. data/config/locales/ar.yml +1 -0
  34. data/config/locales/az.yml +1 -0
  35. data/config/locales/be.yml +1 -0
  36. data/config/locales/bg.yml +1 -0
  37. data/config/locales/bn.yml +1 -0
  38. data/config/locales/cs.yml +1 -0
  39. data/config/locales/da.yml +1 -0
  40. data/config/locales/de.yml +1 -0
  41. data/config/locales/dr.yml +1 -0
  42. data/config/locales/el.yml +1 -0
  43. data/config/locales/es-419.yml +1 -0
  44. data/config/locales/es.yml +1 -0
  45. data/config/locales/fa.yml +1 -0
  46. data/config/locales/fi.yml +1 -0
  47. data/config/locales/gd.yml +1 -0
  48. data/config/locales/gu.yml +1 -0
  49. data/config/locales/he.yml +1 -0
  50. data/config/locales/hi.yml +1 -0
  51. data/config/locales/hr.yml +1 -0
  52. data/config/locales/hu.yml +1 -0
  53. data/config/locales/hy.yml +1 -0
  54. data/config/locales/id.yml +1 -0
  55. data/config/locales/is.yml +1 -0
  56. data/config/locales/it.yml +1 -0
  57. data/config/locales/ja.yml +1 -0
  58. data/config/locales/ka.yml +1 -0
  59. data/config/locales/kk.yml +1 -0
  60. data/config/locales/ko.yml +1 -0
  61. data/config/locales/lt.yml +1 -0
  62. data/config/locales/lv.yml +1 -0
  63. data/config/locales/ms.yml +1 -0
  64. data/config/locales/mt.yml +1 -0
  65. data/config/locales/nl.yml +1 -0
  66. data/config/locales/no.yml +1 -0
  67. data/config/locales/pa-pk.yml +1 -0
  68. data/config/locales/pa.yml +1 -0
  69. data/config/locales/pl.yml +1 -0
  70. data/config/locales/ps.yml +1 -0
  71. data/config/locales/pt.yml +1 -0
  72. data/config/locales/ro.yml +1 -0
  73. data/config/locales/ru.yml +1 -0
  74. data/config/locales/si.yml +1 -0
  75. data/config/locales/sk.yml +1 -0
  76. data/config/locales/sl.yml +1 -0
  77. data/config/locales/so.yml +1 -0
  78. data/config/locales/sq.yml +1 -0
  79. data/config/locales/sr.yml +1 -0
  80. data/config/locales/sv.yml +1 -0
  81. data/config/locales/sw.yml +1 -0
  82. data/config/locales/ta.yml +1 -0
  83. data/config/locales/th.yml +1 -0
  84. data/config/locales/tk.yml +1 -0
  85. data/config/locales/tr.yml +1 -0
  86. data/config/locales/uk.yml +1 -0
  87. data/config/locales/ur.yml +1 -0
  88. data/config/locales/uz.yml +1 -0
  89. data/config/locales/vi.yml +1 -0
  90. data/config/locales/zh-hk.yml +1 -0
  91. data/config/locales/zh-tw.yml +1 -0
  92. data/config/locales/zh.yml +1 -0
  93. data/lib/govuk_publishing_components/presenters/button_helper.rb +13 -2
  94. data/lib/govuk_publishing_components/presenters/contextual_navigation.rb +5 -0
  95. data/lib/govuk_publishing_components/presenters/public_layout_helper.rb +15 -31
  96. data/lib/govuk_publishing_components/version.rb +1 -1
  97. metadata +68 -6
@@ -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>