govuk_publishing_components 21.27.1 → 21.28.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (96) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +9 -9
  3. data/app/assets/stylesheets/govuk_publishing_components/components/_previous-and-next-navigation.scss +17 -2
  4. data/app/controllers/govuk_publishing_components/component_guide_controller.rb +6 -6
  5. data/app/models/govuk_publishing_components/component_doc.rb +1 -1
  6. data/app/models/govuk_publishing_components/component_docs.rb +2 -2
  7. data/app/models/govuk_publishing_components/component_example.rb +4 -4
  8. data/app/views/govuk_publishing_components/components/_input.html.erb +11 -0
  9. data/app/views/govuk_publishing_components/components/_previous_and_next_navigation.html.erb +2 -2
  10. data/app/views/govuk_publishing_components/components/docs/button.yml +9 -1
  11. data/app/views/govuk_publishing_components/components/docs/input.yml +7 -0
  12. data/config/routes.rb +5 -5
  13. data/lib/generators/govuk_publishing_components/component_generator.rb +7 -7
  14. data/lib/govuk_publishing_components.rb +2 -2
  15. data/lib/govuk_publishing_components/app_helpers/taxon_breadcrumbs.rb +1 -1
  16. data/lib/govuk_publishing_components/engine.rb +1 -1
  17. data/lib/govuk_publishing_components/minitest/component_guide_test.rb +4 -4
  18. data/lib/govuk_publishing_components/presenters/breadcrumbs.rb +9 -9
  19. data/lib/govuk_publishing_components/presenters/button_helper.rb +20 -10
  20. data/lib/govuk_publishing_components/presenters/checkboxes_helper.rb +2 -2
  21. data/lib/govuk_publishing_components/presenters/content_breadcrumbs_based_on_parent.rb +1 -1
  22. data/lib/govuk_publishing_components/presenters/content_breadcrumbs_based_on_taxons.rb +3 -3
  23. data/lib/govuk_publishing_components/presenters/contents_list_helper.rb +5 -5
  24. data/lib/govuk_publishing_components/presenters/contextual_navigation.rb +5 -5
  25. data/lib/govuk_publishing_components/presenters/curated_taxonomy_sidebar_links.rb +5 -5
  26. data/lib/govuk_publishing_components/presenters/image_card_helper.rb +3 -3
  27. data/lib/govuk_publishing_components/presenters/machine_readable/article_schema.rb +1 -1
  28. data/lib/govuk_publishing_components/presenters/machine_readable/creative_work_schema.rb +9 -9
  29. data/lib/govuk_publishing_components/presenters/machine_readable/dataset_schema.rb +2 -2
  30. data/lib/govuk_publishing_components/presenters/machine_readable/faq_page_schema.rb +3 -3
  31. data/lib/govuk_publishing_components/presenters/machine_readable/government_service_schema.rb +10 -10
  32. data/lib/govuk_publishing_components/presenters/machine_readable/has_part_schema.rb +1 -1
  33. data/lib/govuk_publishing_components/presenters/machine_readable/is_part_of_schema.rb +1 -1
  34. data/lib/govuk_publishing_components/presenters/machine_readable/organisation_schema.rb +5 -5
  35. data/lib/govuk_publishing_components/presenters/machine_readable/person_schema.rb +3 -3
  36. data/lib/govuk_publishing_components/presenters/machine_readable/potential_search_action_schema.rb +3 -3
  37. data/lib/govuk_publishing_components/presenters/meta_tags.rb +6 -6
  38. data/lib/govuk_publishing_components/presenters/organisation_logo_helper.rb +1 -1
  39. data/lib/govuk_publishing_components/presenters/page_with_step_by_step_navigation.rb +3 -3
  40. data/lib/govuk_publishing_components/presenters/related_navigation_helper.rb +32 -32
  41. data/lib/govuk_publishing_components/presenters/schema_org.rb +13 -13
  42. data/lib/govuk_publishing_components/presenters/select.rb +1 -1
  43. data/lib/govuk_publishing_components/presenters/step_by_step_nav_helper.rb +9 -9
  44. data/lib/govuk_publishing_components/presenters/taxonomy_list_helper.rb +1 -1
  45. data/lib/govuk_publishing_components/version.rb +1 -1
  46. data/lib/tasks/govuk_publishing_components_tasks.rake +7 -7
  47. data/node_modules/axe-core/CHANGELOG.md +18 -0
  48. data/node_modules/axe-core/README.md +9 -6
  49. data/node_modules/axe-core/axe.js +71 -20
  50. data/node_modules/axe-core/axe.min.js +2 -2
  51. data/node_modules/axe-core/bower.json +1 -1
  52. data/node_modules/axe-core/doc/API.md +4 -7
  53. data/node_modules/axe-core/doc/backwards-compatibility-doc.md +2 -1
  54. data/node_modules/axe-core/doc/rule-descriptions.md +129 -91
  55. data/node_modules/axe-core/lib/checks/aria/invalidrole.js +12 -9
  56. data/node_modules/axe-core/lib/checks/keyboard/page-has-elm.js +1 -1
  57. data/node_modules/axe-core/lib/checks/language/has-lang.js +10 -5
  58. data/node_modules/axe-core/lib/checks/navigation/region.js +7 -2
  59. data/node_modules/axe-core/lib/commons/aria/index.js +6 -11
  60. data/node_modules/axe-core/lib/commons/dom/url-props-from-attribute.js +15 -6
  61. data/node_modules/axe-core/lib/core/utils/get-check-message.js +21 -0
  62. data/node_modules/axe-core/lib/rules/area-alt.json +2 -0
  63. data/node_modules/axe-core/lib/rules/aria-roles.json +1 -0
  64. data/node_modules/axe-core/lib/rules/color-contrast-matches.js +26 -0
  65. data/node_modules/axe-core/lib/rules/label-content-name-mismatch-matches.js +4 -1
  66. data/node_modules/axe-core/lib/rules/no-empty-role-matches.js +9 -0
  67. data/node_modules/axe-core/lib/rules/skip-link-matches.js +1 -1
  68. data/node_modules/axe-core/package.json +12 -12
  69. data/node_modules/axe-core/sri-history.json +4 -0
  70. data/node_modules/govuk-frontend/govuk/all.js +21 -31
  71. data/node_modules/govuk-frontend/govuk/components/button/template.njk +1 -1
  72. data/node_modules/govuk-frontend/govuk/components/character-count/macro-options.json +1 -1
  73. data/node_modules/govuk-frontend/govuk/components/checkboxes/macro-options.json +1 -1
  74. data/node_modules/govuk-frontend/govuk/components/date-input/macro-options.json +1 -1
  75. data/node_modules/govuk-frontend/govuk/components/error-summary/error-summary.js +1 -1
  76. data/node_modules/govuk-frontend/govuk/components/file-upload/macro-options.json +1 -1
  77. data/node_modules/govuk-frontend/govuk/components/footer/template.njk +1 -1
  78. data/node_modules/govuk-frontend/govuk/components/header/template.njk +1 -1
  79. data/node_modules/govuk-frontend/govuk/components/input/macro-options.json +1 -1
  80. data/node_modules/govuk-frontend/govuk/components/radios/macro-options.json +1 -1
  81. data/node_modules/govuk-frontend/govuk/components/select/macro-options.json +1 -1
  82. data/node_modules/govuk-frontend/govuk/components/skip-link/macro-options.json +2 -2
  83. data/node_modules/govuk-frontend/govuk/components/tabs/tabs.js +20 -30
  84. data/node_modules/govuk-frontend/govuk/components/tabs/template.njk +2 -2
  85. data/node_modules/govuk-frontend/govuk/components/tag/_tag.scss +47 -0
  86. data/node_modules/govuk-frontend/govuk/components/textarea/macro-options.json +1 -1
  87. data/node_modules/govuk-frontend/govuk/helpers/_spacing.scss +4 -4
  88. data/node_modules/govuk-frontend/govuk/helpers/_typography.scss +5 -5
  89. data/node_modules/govuk-frontend/govuk/helpers/_visually-hidden.scss +29 -29
  90. data/node_modules/govuk-frontend/govuk/overrides/_display.scss +6 -0
  91. data/node_modules/govuk-frontend/govuk/tools/_iff.scss +3 -1
  92. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/closest.js +1 -1
  93. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/nextElementSibling.js +10 -16
  94. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/previousElementSibling.js +10 -14
  95. data/node_modules/govuk-frontend/package.json +10 -10
  96. metadata +32 -16
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 718669d3ca082993458f73bb69023e440f3392e596eff2f2670826623e596db2
4
- data.tar.gz: b66ac15e7c2280121b46458d8c95ed281879e44c1319c7851c9c5ba9809cbd19
3
+ metadata.gz: f7b2dc33fa41b02559295b23f2f7522e698c972589c73903b390a4ca58a84680
4
+ data.tar.gz: 55e2d8eabbf367f5bf7dbd6a6946c978a2afd920f655143f8eaf3583c0e9cba7
5
5
  SHA512:
6
- metadata.gz: cb0d2c8e2d7829029c63cf41bee756d1de85ea797cf6ba13359ccff0b8b9cbcbcababfa9b31a2ac5e87a27b87794298603ad63cf95af799bf97ba602b334275d
7
- data.tar.gz: 302bbf5e0e9cf3005a47e2e2a34aead9573993e7be381efc20d9fda97d60d3401e7c60fcb15500124798c26120e1ab0d1c48fcd981391d0428f5724e6269c01b
6
+ metadata.gz: c9252c3d2e1a73bd417bf6116ad03c54dd5d56413804d094b4966d368993812be7fb6a3ea6ec75e0236529418ed1154384ea9b82634af385b9f14a97bb53cadc
7
+ data.tar.gz: ec9b64188b8f54fc56f722a98a6d0f1a2a2ae3b571cb5f4186dca925f2f1aff2392b3cc5f29a4a6518d44904a01b310877fb2c0510818b681e12b9455547cab2
data/Rakefile CHANGED
@@ -1,32 +1,32 @@
1
1
  begin
2
- require 'rspec/core/rake_task'
2
+ require "rspec/core/rake_task"
3
3
  RSpec::Core::RakeTask.new(:spec)
4
4
  rescue LoadError
5
5
  puts "Running in production mode"
6
6
  end
7
7
 
8
- APP_RAKEFILE = File.expand_path('spec/dummy/Rakefile', __dir__)
8
+ APP_RAKEFILE = File.expand_path("spec/dummy/Rakefile", __dir__)
9
9
 
10
- load 'rails/tasks/engine.rake'
11
- load 'rails/tasks/statistics.rake'
10
+ load "rails/tasks/engine.rake"
11
+ load "rails/tasks/statistics.rake"
12
12
 
13
- require 'bundler/gem_tasks'
13
+ require "bundler/gem_tasks"
14
14
 
15
15
  namespace :assets do
16
16
  desc "Test precompiling assets through dummy application"
17
17
  task :precompile do
18
- Rake::Task['app:assets:precompile'].invoke
18
+ Rake::Task["app:assets:precompile"].invoke
19
19
  end
20
20
 
21
21
  desc "Test cleaning assets through dummy application"
22
22
  task :clean do
23
- Rake::Task['app:assets:clean'].invoke
23
+ Rake::Task["app:assets:clean"].invoke
24
24
  end
25
25
 
26
26
  desc "Test clobbering assets through dummy application"
27
27
  task :clobber do
28
- Rake::Task['app:assets:clobber'].invoke
28
+ Rake::Task["app:assets:clobber"].invoke
29
29
  end
30
30
  end
31
31
 
32
- task default: [:spec, 'app:jasmine:ci']
32
+ task default: [:spec, "app:jasmine:ci"]
@@ -1,6 +1,6 @@
1
1
  .gem-c-pagination {
2
2
  display: block;
3
- margin: govuk-spacing(6) (- govuk-spacing(3) );
3
+ margin: govuk-spacing(8) 0;
4
4
  }
5
5
 
6
6
  .gem-c-pagination__list {
@@ -11,13 +11,17 @@
11
11
  .gem-c-pagination__item {
12
12
  @include govuk-font($size: 16, $line-height: (20 / 16));
13
13
  list-style: none;
14
+
15
+ &:first-child {
16
+ margin-bottom: govuk-spacing(4);
17
+ }
14
18
  }
15
19
 
16
20
  .gem-c-pagination__link {
17
21
  @extend %govuk-link;
18
22
  display: block;
19
- padding: govuk-spacing(3);
20
23
  text-decoration: none;
24
+ padding-bottom: govuk-spacing(4);
21
25
 
22
26
  &:hover,
23
27
  &:active,
@@ -32,11 +36,21 @@
32
36
 
33
37
  &:focus {
34
38
  @include govuk-focused-text;
39
+
40
+ .gem-c-pagination__link-title {
41
+ border-top-color: transparent;
42
+ }
43
+
44
+ .gem-c-pagination__link-icon {
45
+ fill: $govuk-text-colour;
46
+ }
35
47
  }
36
48
  }
37
49
 
38
50
  .gem-c-pagination__link-title {
39
51
  display: block;
52
+ border-top: 1px solid $govuk-border-colour;
53
+ padding-top: govuk-spacing(3);
40
54
  }
41
55
 
42
56
  .gem-c-pagination__link-divider {
@@ -54,6 +68,7 @@
54
68
  margin-bottom: 1px;
55
69
  height: .482em;
56
70
  width: .63em;
71
+ fill: govuk-colour("dark-grey");
57
72
  }
58
73
 
59
74
  .gem-c-pagination__link-label {
@@ -22,8 +22,8 @@ module GovukPublishingComponents
22
22
  index_breadcrumb,
23
23
  component_breadcrumb(@component_doc, @component_example),
24
24
  {
25
- title: @component_example.name
26
- }
25
+ title: @component_example.name,
26
+ },
27
27
  ]
28
28
  end
29
29
 
@@ -56,7 +56,7 @@ module GovukPublishingComponents
56
56
  components = components.flatten.uniq.sort
57
57
 
58
58
  components.map { |component|
59
- "@import 'govuk_publishing_components/components/#{print_path}_#{component.gsub('_', '-')}';" if component_has_sass_file(component.gsub('_', '-'), print_styles)
59
+ "@import 'govuk_publishing_components/components/#{print_path}_#{component.gsub('_', '-')}';" if component_has_sass_file(component.gsub("_", "-"), print_styles)
60
60
  }.join("\n").squeeze("\n").prepend(additional_files)
61
61
  end
62
62
 
@@ -83,7 +83,7 @@ module GovukPublishingComponents
83
83
  matches << data.scan(/(govuk_publishing_components\/components\/[a-z_-]+)/)
84
84
  end
85
85
 
86
- matches.flatten.uniq.map(&:to_s).sort.map { |m| m.gsub('govuk_publishing_components/components/', '') }
86
+ matches.flatten.uniq.map(&:to_s).sort.map { |m| m.gsub("govuk_publishing_components/components/", "") }
87
87
  end
88
88
 
89
89
  def component_has_sass_file(component, print_styles)
@@ -94,13 +94,13 @@ module GovukPublishingComponents
94
94
  def components_within_component(component)
95
95
  data = File.read(Pathname.new(__dir__ + "/../../views/govuk_publishing_components/components/_#{component}.html.erb"))
96
96
  match = data.scan(/(govuk_publishing_components\/components\/[a-z_-]+)/)
97
- match.flatten.uniq.map(&:to_s).sort.map { |m| m.gsub('govuk_publishing_components/components/', '') }
97
+ match.flatten.uniq.map(&:to_s).sort.map { |m| m.gsub("govuk_publishing_components/components/", "") }
98
98
  end
99
99
 
100
100
  def index_breadcrumb
101
101
  {
102
102
  title: GovukPublishingComponents::Config.component_guide_title,
103
- url: component_guide_path
103
+ url: component_guide_path,
104
104
  }
105
105
  end
106
106
 
@@ -57,7 +57,7 @@ module GovukPublishingComponents
57
57
  end
58
58
 
59
59
  def partial_path
60
- if source == 'gem'
60
+ if source == "gem"
61
61
  "govuk_publishing_components/components/#{id}"
62
62
  else
63
63
  "#{GovukPublishingComponents::Config.component_directory_name}/#{id}"
@@ -38,9 +38,9 @@ module GovukPublishingComponents
38
38
  file = Rails.root.join(@documentation_directory, "#{id}.yml")
39
39
  if !file.exist?
40
40
  file = gem_documentation_directory.join("#{id}.yml")
41
- parse_documentation(file).merge(source: 'gem')
41
+ parse_documentation(file).merge(source: "gem")
42
42
  else
43
- parse_documentation(file).merge(source: 'application')
43
+ parse_documentation(file).merge(source: "application")
44
44
  end
45
45
  end
46
46
 
@@ -1,4 +1,4 @@
1
- require 'rouge'
1
+ require "rouge"
2
2
 
3
3
  module GovukPublishingComponents
4
4
  class ComponentExample
@@ -22,7 +22,7 @@ module GovukPublishingComponents
22
22
  id.humanize
23
23
  end
24
24
 
25
- def highlight_code(string_to_format = '')
25
+ def highlight_code(string_to_format = "")
26
26
  formatter = Rouge::Formatters::HTML.new
27
27
  lexer = Rouge::Lexers::ERB.new
28
28
  formatter.format(lexer.lex(string_to_format)).html_safe
@@ -71,11 +71,11 @@ module GovukPublishingComponents
71
71
  end
72
72
 
73
73
  def right_to_left?
74
- !!context['right_to_left']
74
+ !!context["right_to_left"]
75
75
  end
76
76
 
77
77
  def dark_background?
78
- !!context['dark_background']
78
+ !!context["dark_background"]
79
79
  end
80
80
 
81
81
  def html_description
@@ -38,6 +38,15 @@
38
38
  aria_described_by << describedby if describedby
39
39
  aria_described_by = aria_described_by.join(" ")
40
40
  end
41
+
42
+ if type == "number"
43
+ type = "text"
44
+ inputmode = "numeric"
45
+ pattern = "[0-9]*"
46
+ end
47
+
48
+ inputmode ||= nil
49
+ pattern ||= nil
41
50
  %>
42
51
 
43
52
  <%= content_tag :div, class: form_group_css_classes do %>
@@ -74,6 +83,8 @@
74
83
  autofocus: autofocus,
75
84
  readonly: readonly,
76
85
  maxlength: maxlength,
86
+ inputmode: inputmode,
87
+ pattern: pattern,
77
88
  aria: {
78
89
  describedby: aria_described_by,
79
90
  controls: controls
@@ -18,7 +18,7 @@
18
18
  >
19
19
  <span class="gem-c-pagination__link-title">
20
20
  <svg class="gem-c-pagination__link-icon" xmlns="http://www.w3.org/2000/svg" height="13" width="17" viewBox="0 0 17 13">
21
- <path fill="currentColor" d="m6.5938-0.0078125-6.7266 6.7266 6.7441 6.4062 1.377-1.449-4.1856-3.9768h12.896v-2h-12.984l4.2931-4.293-1.414-1.414z"/>
21
+ <path d="m6.5938-0.0078125-6.7266 6.7266 6.7441 6.4062 1.377-1.449-4.1856-3.9768h12.896v-2h-12.984l4.2931-4.293-1.414-1.414z"/>
22
22
  </svg>
23
23
  <span class="gem-c-pagination__link-text">
24
24
  <%= previous_page[:title] %>
@@ -44,7 +44,7 @@
44
44
  >
45
45
  <span class="gem-c-pagination__link-title">
46
46
  <svg class="gem-c-pagination__link-icon" xmlns="http://www.w3.org/2000/svg" height="13" width="17" viewBox="0 0 17 13">
47
- <path fill="currentColor" d="m10.107-0.0078125-1.4136 1.414 4.2926 4.293h-12.986v2h12.896l-4.1855 3.9766 1.377 1.4492 6.7441-6.4062-6.7246-6.7266z"/>
47
+ <path d="m10.107-0.0078125-1.4136 1.414 4.2926 4.293h-12.986v2h12.896l-4.1855 3.9766 1.377 1.4492 6.7441-6.4062-6.7246-6.7266z"/>
48
48
  </svg>
49
49
  <span class="gem-c-pagination__link-text">
50
50
  <%= next_page[:title] %>
@@ -107,4 +107,12 @@ examples:
107
107
  text: "This is the button text"
108
108
  value: "this_is_the_value"
109
109
  name: "this_is_the_name"
110
-
110
+ with_js_classes:
111
+ description: Use `js-` prefixed classes only as interaction hooks – to query and operate on elements via JavaScript
112
+ data:
113
+ text: "Button"
114
+ classes: "js-selector-1 js-selector-2"
115
+ with_aria_label:
116
+ data:
117
+ text: "Button"
118
+ aria_label: "Button with custom label"
@@ -30,6 +30,13 @@ examples:
30
30
  text: "What is your email address?"
31
31
  name: "address"
32
32
  type: "email"
33
+ numeric_input:
34
+ description: If input is set to `type="number"` we set the component up as described in the [Design System guidance](https://design-system.service.gov.uk/components/text-input/#numbers) adding `inputmode` and `pattern`. These values can be overridden if necessary.
35
+ data:
36
+ label:
37
+ text: "Account number"
38
+ name: "account-number"
39
+ type: "number"
33
40
  with_an_identifier:
34
41
  description: Give the input a specific ID.
35
42
  data:
@@ -1,7 +1,7 @@
1
1
  GovukPublishingComponents::Engine.routes.draw do
2
- root to: 'component_guide#index', as: :component_guide
3
- get ':component/preview' => 'component_guide#preview', as: :component_preview_all
4
- get ':component/:example/preview' => 'component_guide#preview', as: :component_preview
5
- get ':component' => 'component_guide#show', as: :component_doc
6
- get ':component/:example' => 'component_guide#example', as: :component_example
2
+ root to: "component_guide#index", as: :component_guide
3
+ get ":component/preview" => "component_guide#preview", as: :component_preview_all
4
+ get ":component/:example/preview" => "component_guide#preview", as: :component_preview
5
+ get ":component" => "component_guide#show", as: :component_doc
6
+ get ":component/:example" => "component_guide#example", as: :component_example
7
7
  end
@@ -1,13 +1,13 @@
1
- require 'rails/generators'
2
- require 'fileutils'
1
+ require "rails/generators"
2
+ require "fileutils"
3
3
 
4
4
  module GovukPublishingComponents
5
5
  class ComponentGenerator < ::Rails::Generators::NamedBase
6
- source_root File.expand_path('templates', __dir__)
6
+ source_root File.expand_path("templates", __dir__)
7
7
 
8
8
  def copy_component_files
9
9
  @public_name = file_name.dasherize
10
- @component_prefix = 'app-c-'
10
+ @component_prefix = "app-c-"
11
11
  component_directory_name = GovukPublishingComponents::Config.component_directory_name
12
12
 
13
13
  template_dir = "app/views/#{component_directory_name}/"
@@ -18,9 +18,9 @@ module GovukPublishingComponents
18
18
  create_directory_if_not_exists(docs_dir)
19
19
  create_directory_if_not_exists(scss_dir)
20
20
 
21
- template '_component.html.erb', "#{template_dir}_#{@public_name}.html.erb"
22
- template 'component.yml.erb', "#{docs_dir}#{@public_name}.yml"
23
- template '_component.scss', "#{scss_dir}_#{@public_name}.scss"
21
+ template "_component.html.erb", "#{template_dir}_#{@public_name}.html.erb"
22
+ template "component.yml.erb", "#{docs_dir}#{@public_name}.yml"
23
+ template "_component.scss", "#{scss_dir}_#{@public_name}.scss"
24
24
  end
25
25
 
26
26
  private
@@ -34,11 +34,11 @@ require "govuk_publishing_components/app_helpers/environment"
34
34
 
35
35
  # Add view and i18n paths for usage outside of a Rails app
36
36
  ActionController::Base.append_view_path(
37
- File.expand_path("app/views", GovukPublishingComponents::Config.gem_directory)
37
+ File.expand_path("app/views", GovukPublishingComponents::Config.gem_directory),
38
38
  )
39
39
 
40
40
  I18n.load_path.unshift(
41
- *Dir.glob(File.expand_path("config/locales/*.yml", GovukPublishingComponents::Config.gem_directory))
41
+ *Dir.glob(File.expand_path("config/locales/*.yml", GovukPublishingComponents::Config.gem_directory)),
42
42
  )
43
43
 
44
44
  module GovukPublishingComponents
@@ -22,7 +22,7 @@ module GovukPublishingComponents
22
22
  ordered_parents << {
23
23
  title: "Home",
24
24
  url: "/",
25
- is_page_parent: ordered_parents.empty?
25
+ is_page_parent: ordered_parents.empty?,
26
26
  }
27
27
 
28
28
  ordered_parents.reverse
@@ -4,6 +4,6 @@ require "action_dispatch"
4
4
  module GovukPublishingComponents
5
5
  class Engine < ::Rails::Engine
6
6
  isolate_namespace GovukPublishingComponents
7
- require 'kramdown'
7
+ require "kramdown"
8
8
  end
9
9
  end
@@ -5,13 +5,13 @@ module GovukPublishingComponents
5
5
 
6
6
  included do
7
7
  test "renders all component guide preview pages without erroring" do
8
- visit '/component-guide'
8
+ visit "/component-guide"
9
9
 
10
10
  # Confirm accessibility JS test is available
11
- assert_equal 'function', evaluate_script('typeof window.GOVUK.AccessibilityTest'), "AccessibilityTest JavaScript isn’t available"
12
- assert_equal 'string', evaluate_script('typeof window.axe.version'), "aXe accessibility test library isn’t available"
11
+ assert_equal "function", evaluate_script("typeof window.GOVUK.AccessibilityTest"), "AccessibilityTest JavaScript isn’t available"
12
+ assert_equal "string", evaluate_script("typeof window.axe.version"), "aXe accessibility test library isn’t available"
13
13
 
14
- all(:css, '.component-list a').map { |el| "#{el[:href]}/preview" }.each do |component|
14
+ all(:css, ".component-list a").map { |el| "#{el[:href]}/preview" }.each do |component|
15
15
  visit component
16
16
  assert page.has_css?(".js-test-a11y-finished"), "Accessibility test did not run on #{component}"
17
17
  assert page.has_css?(".js-test-a11y-success"), "Accessibility test found violations on #{component}"
@@ -37,7 +37,7 @@ module GovukPublishingComponents
37
37
  {
38
38
  "@type" => "ListItem",
39
39
  "position" => index,
40
- "item" => list_item_item
40
+ "item" => list_item_item,
41
41
  }
42
42
  end
43
43
 
@@ -50,27 +50,27 @@ module GovukPublishingComponents
50
50
  end
51
51
 
52
52
  def aria_current
53
- 'false'
53
+ "false"
54
54
  end
55
55
 
56
56
  def tracking_data(breadcrumbs_length)
57
57
  data = {
58
- track_category: 'breadcrumbClicked',
58
+ track_category: "breadcrumbClicked",
59
59
  track_action: index,
60
60
  track_label: path,
61
61
  track_options: {
62
62
  dimension28: breadcrumbs_length.to_s,
63
- dimension29: crumb[:title]
64
- }
63
+ dimension29: crumb[:title],
64
+ },
65
65
  }
66
66
 
67
67
  is_homepage = crumb[:url] == "/"
68
68
 
69
69
  if is_homepage
70
- data[:track_category] = 'homeLinkClicked'
71
- data[:track_action] = 'homeBreadcrumb'
72
- data[:track_label] = ''
73
- data[:track_options] = '{}'
70
+ data[:track_category] = "homeLinkClicked"
71
+ data[:track_action] = "homeBreadcrumb"
72
+ data[:track_label] = ""
73
+ data[:track_options] = "{}"
74
74
  end
75
75
 
76
76
  data
@@ -1,11 +1,12 @@
1
- require 'action_view'
1
+ require "action_view"
2
2
 
3
3
  module GovukPublishingComponents
4
4
  module Presenters
5
5
  class ButtonHelper
6
6
  attr_reader :href, :text, :title, :info_text, :rel, :data_attributes,
7
7
  :margin_bottom, :inline_layout, :target, :type, :start,
8
- :secondary, :secondary_quiet, :destructive, :name, :value
8
+ :secondary, :secondary_quiet, :destructive, :name, :value,
9
+ :classes, :aria_label
9
10
 
10
11
  def initialize(local_assigns)
11
12
  @href = local_assigns[:href]
@@ -24,6 +25,13 @@ module GovukPublishingComponents
24
25
  @destructive = local_assigns[:destructive]
25
26
  @name = local_assigns[:name]
26
27
  @value = local_assigns[:value]
28
+ if local_assigns.include?(:classes)
29
+ @classes = local_assigns[:classes].split(" ")
30
+ unless @classes.all? { |c| c.start_with?("js-") }
31
+ raise(ArgumentError, "The button component expects classes to be prefixed with `js-`")
32
+ end
33
+ end
34
+ @aria_label = local_assigns[:aria_label]
27
35
  end
28
36
 
29
37
  def link?
@@ -40,6 +48,7 @@ module GovukPublishingComponents
40
48
  options[:target] = target if target
41
49
  options[:name] = name if name.present? && value.present?
42
50
  options[:value] = value if name.present? && value.present?
51
+ options[:aria] = { label: aria_label } if aria_label
43
52
  options
44
53
  end
45
54
 
@@ -50,14 +59,15 @@ module GovukPublishingComponents
50
59
  private
51
60
 
52
61
  def css_classes
53
- classes = %w(gem-c-button govuk-button)
54
- classes << "govuk-button--start" if start
55
- classes << "gem-c-button--secondary" if secondary
56
- classes << "gem-c-button--secondary-quiet" if secondary_quiet
57
- classes << "govuk-button--warning" if destructive
58
- classes << "gem-c-button--bottom-margin" if margin_bottom
59
- classes << "gem-c-button--inline" if inline_layout
60
- classes.join(" ")
62
+ css_classes = %w(gem-c-button govuk-button)
63
+ css_classes << "govuk-button--start" if start
64
+ css_classes << "gem-c-button--secondary" if secondary
65
+ css_classes << "gem-c-button--secondary-quiet" if secondary_quiet
66
+ css_classes << "govuk-button--warning" if destructive
67
+ css_classes << "gem-c-button--bottom-margin" if margin_bottom
68
+ css_classes << "gem-c-button--inline" if inline_layout
69
+ css_classes << classes if classes
70
+ css_classes.join(" ")
61
71
  end
62
72
  end
63
73
  end