govuk_publishing_components 29.6.0 → 29.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3e3f8aaf064237fbd67e4b472e5e57dcafeb3a16ed3228c7b0b45114d7f68257
4
- data.tar.gz: dc5d297b2e7d409277024778eabc48a9faf2a8b68bff7f309426d028b4736f2b
3
+ metadata.gz: b74221682d0047e390f314e968edf8acd3b89efebfe41d833239d9ca44413c86
4
+ data.tar.gz: 1f87c5a4288b2a69da1e32598422162bc5017f2dab4ac577b326b582cbd9e8e9
5
5
  SHA512:
6
- metadata.gz: 38c1773770dc36ecce0857dd4516d8f6aa350542b25d3d0f946d56d664eb5661d3c53da68286b6a5a9c51344c6cd5c927a4206a9d0a2350cd47e737277e7dfb0
7
- data.tar.gz: 9b5f523c0cacffa3f6f12858dfce51f1f770000447e6d29d83d47856d2a22b51e493b64fcd930755a893293566260ade49d9b295bfb31976c946120ca9e06923
6
+ metadata.gz: 14d60ae3e9876edbbcac836010f6dbfd1655c3be4798119f79ac064cb70cfef71a612694d7b31ae6475c31f9813ca9d7775fb1ab3b3153707643bd61190e057d
7
+ data.tar.gz: 4e69c991fd6db0d47136d6a7e489fd516e1aa9c62b1422ccf87ed35164e7f6641a60fd64392281f5c99b84c4b9caef8be78bbd73faa922b604d27c227ec7080f
@@ -51,6 +51,16 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
51
51
  // giving the table a class of mc-stacked
52
52
  this.options.stacked = this.$table.classList.contains('mc-stacked')
53
53
 
54
+ // stacked charts require tables to use the th element in the table header
55
+ // if the th element is not included, then the ENABLED flag is set to false
56
+ // this will stop the chart and toggleLink from being rendered
57
+ if (this.options.stacked) {
58
+ var allTheTHsInTableHead = this.$table.querySelectorAll('thead th')
59
+ if (allTheTHsInTableHead.length === 0) {
60
+ this.ENABLED = false
61
+ }
62
+ }
63
+
54
64
  // set the negative option based on
55
65
  // giving the table a class of mc-negative
56
66
  this.options.negative = this.$table.classList.contains('mc-negative')
@@ -106,12 +116,16 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
106
116
 
107
117
  MagnaCharta.prototype.apply = function () {
108
118
  if (this.ENABLED) {
109
- this.constructChart()
110
- this.addClassesToHeader()
111
- this.applyWidths()
112
- this.insert()
113
- this.$table.classList.add('mc-hidden')
114
- this.applyOutdent()
119
+ try {
120
+ this.constructChart()
121
+ this.addClassesToHeader()
122
+ this.applyWidths()
123
+ this.insert()
124
+ this.$table.classList.add('mc-hidden')
125
+ this.applyOutdent()
126
+ } catch (error) {
127
+ console.error('MagnaCharta error:', error)
128
+ }
115
129
  }
116
130
  }
117
131
 
@@ -816,7 +816,7 @@ $button-pipe-colour: darken(govuk-colour("mid-grey"), 20%);
816
816
 
817
817
  .gem-c-layout-super-navigation-header__navigation-second-items--topics {
818
818
  @include govuk-media-query($from: "desktop") {
819
- @include columns($items: 17, $columns: 2, $selector: "li", $flow: column);
819
+ @include columns($items: 16, $columns: 2, $selector: "li", $flow: column);
820
820
  }
821
821
  }
822
822
 
@@ -13,8 +13,6 @@ module GovukPublishingComponents
13
13
  frontend
14
14
  government-frontend
15
15
  govspeak-preview
16
- govuk-account-manager-prototype
17
- govuk-coronavirus-vulnerable-people-form
18
16
  info-frontend
19
17
  licence-finder
20
18
  manuals-frontend
@@ -32,10 +30,9 @@ module GovukPublishingComponents
32
30
  gem_path = Gem.loaded_specs["govuk_publishing_components"].full_gem_path
33
31
  gem_path = Dir.pwd if ENV["MAIN_COMPONENT_GUIDE"]
34
32
  host_dir = File.expand_path("..")
35
- path = File.expand_path("..", gem_path)
36
33
 
37
34
  @in_application = false
38
- @in_application = true unless path.to_s == host_dir.to_s
35
+ @in_application = true unless ENV["MAIN_COMPONENT_GUIDE"]
39
36
 
40
37
  components = AuditComponents.new(gem_path, false)
41
38
  applications = analyse_applications(host_dir, application_dirs)
@@ -12,29 +12,40 @@ module GovukPublishingComponents
12
12
  private
13
13
 
14
14
  def compile_data(path, simple)
15
+ # simple is used to reduce effort (and therefore page load time) required
16
+ # when loading auditing summary on the main component guide page
15
17
  @simple = simple
16
- templates_path = "app/views/govuk_publishing_components/components"
17
- stylesheets_path = "app/assets/stylesheets/govuk_publishing_components/components"
18
- print_stylesheets_path = "app/assets/stylesheets/govuk_publishing_components/components/print"
19
- javascripts_path = "app/assets/javascripts/govuk_publishing_components/components"
20
- tests_path = "spec/components"
21
- js_tests_path = "spec/javascripts/components"
22
-
23
- templates = Dir["#{path}/#{templates_path}/*.erb"]
24
- stylesheets = Dir["#{path}/#{stylesheets_path}/*.scss"]
25
- print_stylesheets = Dir["#{path}/#{print_stylesheets_path}/*.scss"]
26
- javascripts = Dir["#{path}/#{javascripts_path}/*.js"]
27
- tests = Dir["#{path}/#{tests_path}/*.rb"]
28
- js_tests = Dir["#{path}/#{js_tests_path}/*.js"]
29
-
30
- @templates_full_path = "#{path}/#{templates_path}/"
31
-
32
- @components = find_files(templates, [path, templates_path].join("/"))
33
- @component_stylesheets = find_files(stylesheets, [path, stylesheets_path].join("/"))
34
- @component_print_stylesheets = find_files(print_stylesheets, [path, print_stylesheets_path].join("/"))
35
- @component_javascripts = find_files(javascripts, [path, javascripts_path].join("/"))
36
- @component_tests = find_files(tests, [path, tests_path].join("/"))
37
- @component_js_tests = find_files(js_tests, [path, js_tests_path].join("/"))
18
+
19
+ # paths to key file locations
20
+ @templates_path = "app/views/govuk_publishing_components/components"
21
+ @stylesheets_path = "app/assets/stylesheets/govuk_publishing_components/components"
22
+ @print_stylesheets_path = "app/assets/stylesheets/govuk_publishing_components/components/print"
23
+ @javascripts_path = "app/assets/javascripts/govuk_publishing_components/components"
24
+ @tests_path = "spec/components"
25
+ @js_tests_path = "spec/javascripts/components"
26
+ @helpers_path = "lib/govuk_publishing_components/presenters"
27
+
28
+ # get all files in key file locations
29
+ templates = Dir["#{path}/#{@templates_path}/*.erb"]
30
+ stylesheets = Dir["#{path}/#{@stylesheets_path}/*.scss"]
31
+ print_stylesheets = Dir["#{path}/#{@print_stylesheets_path}/*.scss"]
32
+ javascripts = Dir["#{path}/#{@javascripts_path}/*.js"]
33
+ tests = Dir["#{path}/#{@tests_path}/*.rb"]
34
+ js_tests = Dir["#{path}/#{@js_tests_path}/*.js"]
35
+ helpers = Dir["#{path}/#{@helpers_path}/*_helper.rb"]
36
+
37
+ @templates_full_path = "#{path}/#{@templates_path}/"
38
+
39
+ # find the cleaned names of components in key file locations
40
+ # i.e. will show that 'component name' has a stylesheet
41
+ # standardised like this to be used later for easier comparison
42
+ @components = clean_files(templates, [path, @templates_path].join("/"))
43
+ @component_stylesheets = clean_files(stylesheets, [path, @stylesheets_path].join("/"))
44
+ @component_print_stylesheets = clean_files(print_stylesheets, [path, @print_stylesheets_path].join("/"))
45
+ @component_javascripts = clean_files(javascripts, [path, @javascripts_path].join("/"))
46
+ @component_tests = clean_files(tests, [path, @tests_path].join("/"))
47
+ @component_js_tests = clean_files(js_tests, [path, @js_tests_path].join("/"))
48
+ @component_helpers = clean_files(helpers, [path, @helpers_path].join("/"))
38
49
 
39
50
  {
40
51
  gem_found: true,
@@ -44,12 +55,13 @@ module GovukPublishingComponents
44
55
  component_javascripts: @component_javascripts,
45
56
  component_tests: @component_tests,
46
57
  component_js_tests: @component_js_tests,
58
+ component_helpers: @component_helpers,
47
59
  components_containing_components: find_all_partials_in(templates),
48
60
  component_listing: list_all_component_details,
49
61
  }
50
62
  end
51
63
 
52
- def find_files(files, replace)
64
+ def clean_files(files, replace)
53
65
  files.map { |file| clean_file_name(file.gsub(replace, "")) }.sort
54
66
  end
55
67
 
@@ -61,6 +73,7 @@ module GovukPublishingComponents
61
73
  .gsub(".js", "")
62
74
  .gsub("spec", "")
63
75
  .gsub(".rb", "")
76
+ .gsub("helper", "")
64
77
  .strip
65
78
  end
66
79
 
@@ -72,11 +85,14 @@ module GovukPublishingComponents
72
85
  .tr('\"\'', "")
73
86
  end
74
87
 
88
+ # create link to component guide page for a given component e.g. 'component name'
75
89
  def get_component_link(component)
76
90
  "/component-guide/#{component.gsub(' ', '_')}"
77
91
  end
78
92
 
79
93
  def find_all_partials_in(templates)
94
+ return [] if @simple
95
+
80
96
  components = []
81
97
 
82
98
  templates.each do |template|
@@ -142,6 +158,7 @@ module GovukPublishingComponents
142
158
  javascript: check_component_has("javascript", component),
143
159
  tests: check_component_has("test", component),
144
160
  js_tests: check_component_has("js_test", component),
161
+ helper: check_component_has("helper", component),
145
162
  }
146
163
  end
147
164
 
@@ -154,8 +171,28 @@ module GovukPublishingComponents
154
171
  look_in = @component_javascripts if a_thing == "javascript"
155
172
  look_in = @component_tests if a_thing == "test"
156
173
  look_in = @component_js_tests if a_thing == "js_test"
174
+ look_in = @component_helpers if a_thing == "helper"
175
+
176
+ if look_in.include?(component)
177
+ return get_asset_link(a_thing, component)
178
+ end
179
+
180
+ false
181
+ end
157
182
 
158
- true if look_in.include?(component)
183
+ def get_asset_link(a_thing, component)
184
+ url = "https://github.com/alphagov"
185
+ repo = "govuk_publishing_components"
186
+ blob = "blob/main"
187
+ link = nil
188
+ link = "#{url}/#{repo}/#{blob}/#{@stylesheets_path}/_#{component.gsub(' ', '-')}.scss" if a_thing == "stylesheet"
189
+ link = "#{url}/#{repo}/#{blob}/#{@print_stylesheets_path}/_#{component.gsub(' ', '-')}.scss" if a_thing == "print_stylesheet"
190
+ link = "#{url}/#{repo}/#{blob}/#{@javascripts_path}/#{component.gsub(' ', '-')}.js" if a_thing == "javascript"
191
+ link = "#{url}/#{repo}/#{blob}/#{@tests_path}/#{component.gsub(' ', '_')}_spec.rb" if a_thing == "test"
192
+ link = "#{url}/#{repo}/#{blob}/#{@js_tests_path}/#{component.gsub(' ', '-')}-spec.js" if a_thing == "js_test"
193
+ link = "#{url}/#{repo}/#{blob}/#{@helpers_path}/#{component.gsub(' ', '_')}_helper.rb" if a_thing == "helper"
194
+
195
+ link
159
196
  end
160
197
  end
161
198
  end
@@ -32,6 +32,7 @@
32
32
 
33
33
  <% accordion_content = capture do %>
34
34
  <% if application[:application_found] %>
35
+ <% github_link = 'https://github.com/alphagov/' + application[:name] + '/blob/main/' %>
35
36
  <% application[:warnings].each do |warning| %>
36
37
  <p class="govuk-body">
37
38
  <strong class="govuk-tag">Warn</strong>
@@ -74,7 +75,9 @@
74
75
  <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
76
  <ul class="govuk-list govuk-list--bullet">
76
77
  <% application[:gem_style_references].each do |ref| %>
77
- <li><%= ref %></li>
78
+ <li>
79
+ <%= link_to ref, github_link + ref, class: 'govuk-link' %>
80
+ </li>
78
81
  <% end %>
79
82
  </ul>
80
83
  <% end %>
@@ -86,10 +89,12 @@
86
89
  margin_bottom: 4,
87
90
  heading_level: 3,
88
91
  } %>
89
- <p class="govuk-body">This shows JavaScript files that might contain jQuery, which we are trying to remove our dependency on.</p>
92
+ <p class="govuk-body">This shows JavaScript files that might contain jQuery, which we are trying to remove.</p>
90
93
  <ul class="govuk-list govuk-list--bullet">
91
94
  <% application[:jquery_references].each do |ref| %>
92
- <li><%= ref %></li>
95
+ <li>
96
+ <%= link_to ref, github_link + ref, class: 'govuk-link' %>
97
+ </li>
93
98
  <% end %>
94
99
  </ul>
95
100
  <% end %>
@@ -0,0 +1,82 @@
1
+ <%
2
+ total_components = components.length
3
+ components_with_stylesheet = 0
4
+ components_with_print_stylesheet = 0
5
+ components_with_javascript = 0
6
+ components_with_test = 0
7
+ components_with_javascript_test = 0
8
+ components_with_helper = 0
9
+
10
+ components.each do |component|
11
+ components_with_stylesheet += 1 if component[:stylesheet]
12
+ components_with_print_stylesheet += 1 if component[:print_stylesheet]
13
+ components_with_javascript += 1 if component[:javascript]
14
+ components_with_test += 1 if component[:tests]
15
+ components_with_javascript_test += 1 if component[:js_tests]
16
+ components_with_helper += 1 if component[:helper]
17
+ end
18
+ %>
19
+ <table class="govuk-table">
20
+ <thead class="govuk-table__head">
21
+ <tr class="govuk-table__row">
22
+ <th scope="col" class="govuk-table__header sticky-table-header">Component (<%= total_components %>)</th>
23
+ <th scope="col" class="govuk-table__header sticky-table-header">CSS (<%= components_with_stylesheet %>)</th>
24
+ <th scope="col" class="govuk-table__header sticky-table-header">Print CSS (<%= components_with_print_stylesheet %>)</th>
25
+ <th scope="col" class="govuk-table__header sticky-table-header">JS (<%= components_with_javascript %>)</th>
26
+ <th scope="col" class="govuk-table__header sticky-table-header">Test (<%= components_with_test %>)</th>
27
+ <th scope="col" class="govuk-table__header sticky-table-header">JS test (<%= components_with_javascript_test %>)</th>
28
+ <th scope="col" class="govuk-table__header sticky-table-header">Helper (<%= components_with_helper %>)</th>
29
+ </tr>
30
+ </thead>
31
+ <tbody class="govuk-table__body">
32
+ <% components.each do |component| %>
33
+ <tr class="govuk-table__row">
34
+ <th scope="row" class="govuk-table__header">
35
+ <a href="<%= component[:link] %>" class="govuk-link"><%= component[:name] %></a>
36
+ </th>
37
+ <td class="govuk-table__cell">
38
+ <% if component[:stylesheet] %>
39
+ <strong class="govuk-tag govuk-tag--green">
40
+ <a href="<%= component[:stylesheet] %>" class="govuk-link">Yes</a>
41
+ </strong>
42
+ <% end %>
43
+ </td>
44
+ <td class="govuk-table__cell">
45
+ <% if component[:print_stylesheet] %>
46
+ <strong class="govuk-tag govuk-tag--green">
47
+ <a href="<%= component[:print_stylesheet] %>" class="govuk-link">Yes</a>
48
+ </strong>
49
+ <% end %>
50
+ </td>
51
+ <td class="govuk-table__cell">
52
+ <% if component[:javascript] %>
53
+ <strong class="govuk-tag govuk-tag--green">
54
+ <a href="<%= component[:javascript] %>" class="govuk-link">Yes</a>
55
+ </strong>
56
+ <% end %>
57
+ </td>
58
+ <td class="govuk-table__cell">
59
+ <% if component[:tests] %>
60
+ <strong class="govuk-tag govuk-tag--green">
61
+ <a href="<%= component[:tests] %>" class="govuk-link">Yes</a>
62
+ </strong>
63
+ <% end %>
64
+ </td>
65
+ <td class="govuk-table__cell">
66
+ <% if component[:js_tests] %>
67
+ <strong class="govuk-tag govuk-tag--green">
68
+ <a href="<%= component[:js_tests] %>" class="govuk-link">Yes</a>
69
+ </strong>
70
+ <% end %>
71
+ </td>
72
+ <td class="govuk-table__cell">
73
+ <% if component[:helper] %>
74
+ <strong class="govuk-tag govuk-tag--green">
75
+ <a href="<%= component[:helper] %>" class="govuk-link">Yes</a>
76
+ </strong>
77
+ <% end %>
78
+ </td>
79
+ </tr>
80
+ <% end %>
81
+ </tbody>
82
+ </table>
@@ -1,6 +1,6 @@
1
1
  <% if @other_applications %>
2
2
  <%= render "govuk_publishing_components/components/heading", {
3
- text: "Components",
3
+ text: "Components in the gem",
4
4
  font_size: "l",
5
5
  margin_bottom: 6,
6
6
  } %>
@@ -10,52 +10,7 @@
10
10
  <% component_items = [] %>
11
11
 
12
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>
13
+ <%= render partial: "component_contents", locals: { components: @components[:component_listing] } %>
59
14
  <% end %>
60
15
 
61
16
  <%
@@ -1,5 +1,5 @@
1
1
  <%
2
- attachment = GovukPublishingComponents::Presenters::Attachment.new(attachment)
2
+ attachment = GovukPublishingComponents::Presenters::AttachmentHelper.new(attachment)
3
3
  target ||= "_self"
4
4
  hide_opendocument_metadata ||= false
5
5
  hide_order_copy_link ||= false
@@ -1,5 +1,5 @@
1
1
  <%
2
- attachment = GovukPublishingComponents::Presenters::Attachment.new(attachment)
2
+ attachment = GovukPublishingComponents::Presenters::AttachmentHelper.new(attachment)
3
3
  target ||= nil
4
4
  data_attributes ||= {}
5
5
  attributes = []
@@ -175,8 +175,6 @@ en:
175
175
  href: "/browse/childcare-parenting"
176
176
  - label: Citizenship and living in the UK
177
177
  href: "/browse/citizenship"
178
- - label: Coronavirus (COVID‑19)
179
- href: "/coronavirus"
180
178
  - label: Crime, justice and the law
181
179
  href: "/browse/justice"
182
180
  - label: Disabled people
@@ -1,6 +1,6 @@
1
1
  module GovukPublishingComponents
2
2
  module Presenters
3
- class Attachment
3
+ class AttachmentHelper
4
4
  # Various departments are taking part in a pilot to use a form
5
5
  # rather than direct email for users to request accessible formats. When the pilot
6
6
  # scheme is rolled out further this can be removed.
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = "29.6.0".freeze
2
+ VERSION = "29.7.0".freeze
3
3
  end
@@ -5,7 +5,7 @@ require "govuk_personalisation"
5
5
  require "govuk_publishing_components/config"
6
6
  require "govuk_publishing_components/engine"
7
7
  require "govuk_publishing_components/presenters/shared_helper"
8
- require "govuk_publishing_components/presenters/attachment"
8
+ require "govuk_publishing_components/presenters/attachment_helper"
9
9
  require "govuk_publishing_components/presenters/big_number_helper"
10
10
  require "govuk_publishing_components/presenters/breadcrumbs"
11
11
  require "govuk_publishing_components/presenters/breadcrumb_selector"
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: 29.6.0
4
+ version: 29.7.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: 2022-04-26 00:00:00.000000000 Z
11
+ date: 2022-05-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: govuk_app_config
@@ -636,6 +636,7 @@ files:
636
636
  - app/models/govuk_publishing_components/component_example.rb
637
637
  - app/models/govuk_publishing_components/shared_accessibility_criteria.rb
638
638
  - app/views/govuk_publishing_components/audit/_applications.html.erb
639
+ - app/views/govuk_publishing_components/audit/_component_contents.html.erb
639
640
  - app/views/govuk_publishing_components/audit/_components.html.erb
640
641
  - app/views/govuk_publishing_components/audit/show.html.erb
641
642
  - app/views/govuk_publishing_components/component_guide/_application_stylesheet.html.erb
@@ -899,7 +900,7 @@ files:
899
900
  - lib/govuk_publishing_components/config.rb
900
901
  - lib/govuk_publishing_components/engine.rb
901
902
  - lib/govuk_publishing_components/minitest/component_guide_test.rb
902
- - lib/govuk_publishing_components/presenters/attachment.rb
903
+ - lib/govuk_publishing_components/presenters/attachment_helper.rb
903
904
  - lib/govuk_publishing_components/presenters/big_number_helper.rb
904
905
  - lib/govuk_publishing_components/presenters/breadcrumb_selector.rb
905
906
  - lib/govuk_publishing_components/presenters/breadcrumbs.rb