govuk_publishing_components 1.12.1 → 2.0.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
  SHA1:
3
- metadata.gz: 1dfd2d6f3dd09f61826bb8efa761a6967c2f38c3
4
- data.tar.gz: 6701db53f1595abf1a985288ebb40b50d4eca892
3
+ metadata.gz: e4dc58d36544b1596c32214fd0f900a58e3f9eca
4
+ data.tar.gz: 3c758cf643c55aed354257f7ff90bea0bb2ec3ba
5
5
  SHA512:
6
- metadata.gz: 231cdf8a06f6a0cfdad9cac0472bd67bb1af5360ff408f5371094c75d874726a2fefdcf902c053a623b7c83e6789b403f033c418d97bff30af248c160055a493
7
- data.tar.gz: 56a0713b941833ea54d0b84d07865e4a7ba48cdbc339ab31d298d730aabcced4f9bb4a55513c7972257d6cffc26b0be9de3011a90103155b691fcf576cf02940
6
+ metadata.gz: a88f615ce939922932f1e09a7e11dca0c314263a0cf5f28b75eb99cf98746119ea6537819de7c96284373e5d30f52b3d70ca4e66c2772a59b84a1f4f3981080f
7
+ data.tar.gz: d5ed207ce42a0c003d499e9b806a521ccd23f75b71ef400f43515d2841e8ec4ae6e89d8d80caed66f2e78c7cfb97b664f5f69f785b1efe97e551991c91392dbc
data/README.md CHANGED
@@ -112,6 +112,15 @@ class ComponentGuideTest < ActionDispatch::IntegrationTest
112
112
  end
113
113
  ```
114
114
 
115
+ ### Exclude accessibility rules
116
+
117
+ Sometimes you will have a component that will throw an error due to it being in isolation, for example radio buttons not being in a fieldset.
118
+
119
+ For this case you can add `accessibility_excluded_rules` to your components' documentation yml file with the rules you want to exclude. These rules can be found in brackets in the error messages displayed.
120
+
121
+ For an example of this check [test/.../docs/test-component-with-duplicate-ids.yml](test/dummy/app/views/components/docs/test-component-with-duplicate-ids.yml)
122
+
123
+
115
124
  ## Component generator
116
125
 
117
126
  The gem includes a component generator to stub the minimal files required for a component.
data/Rakefile CHANGED
@@ -18,14 +18,19 @@ end
18
18
 
19
19
  namespace :assets do
20
20
  desc "Test precompiling assets through dummy application"
21
-
22
21
  task :precompile do
23
22
  Rake::Task['app:assets:precompile'].invoke
24
23
  end
25
24
 
25
+ desc "Test cleaning assets through dummy application"
26
26
  task :clean do
27
27
  Rake::Task['app:assets:clean'].invoke
28
28
  end
29
+
30
+ desc "Test clobbering assets through dummy application"
31
+ task :clobber do
32
+ Rake::Task['app:assets:clobber'].invoke
33
+ end
29
34
  end
30
35
 
31
36
  task default: [:spec, 'app:jasmine:ci']
@@ -6,18 +6,25 @@
6
6
  return
7
7
  }
8
8
 
9
- if (!document.querySelector(selector)) {
9
+ var element = document.querySelector(selector)
10
+
11
+ if (!element) {
10
12
  return callback()
11
13
  }
12
14
 
15
+ var dataDisabledRules = element.getAttribute('data-excluded-rules')
16
+ var disabledRules = dataDisabledRules ? JSON.parse(dataDisabledRules) : []
17
+
18
+ var axeRules = {}
19
+
20
+ disabledRules.forEach(function (rule) {
21
+ axeRules[rule] = { enabled: false }
22
+ })
23
+
13
24
  var axeOptions = {
14
25
  restoreScroll: true,
15
26
  include: [selector],
16
- rules: {
17
- "duplicate-id": {
18
- enabled: false
19
- }
20
- }
27
+ rules: axeRules
21
28
  }
22
29
 
23
30
  // TODO: Remove when aXe core patched
@@ -50,7 +57,7 @@
50
57
  '\n' + 'Accessibility issues at ' +
51
58
  url + '\n\n' +
52
59
  violations.map(function (violation) {
53
- var help = 'Problem: ' + violation.help
60
+ var help = 'Problem: ' + violation.help + ' (' + violation.id + ')'
54
61
  var helpUrl = 'Try fixing it with this help: ' + _formatHelpUrl(violation.helpUrl)
55
62
  var htmlAndTarget = violation.nodes.map(_renderNode).join('\n\n')
56
63
 
@@ -84,6 +91,7 @@
84
91
  }
85
92
  })
86
93
  return {
94
+ 'id': result.id,
87
95
  'summary': result.help,
88
96
  'selectors': cssSelector,
89
97
  'url': _formatHelpUrl(result.helpUrl)
@@ -125,7 +133,7 @@
125
133
  var wrapper = activeElParent.querySelector(resultContainerSelector)
126
134
 
127
135
  if (wrapper) {
128
- var resultHTML = '<h3>' + result.summary + ' <a href="' + result.url + '">(see guidance)</a></h3>' +
136
+ var resultHTML = '<h3>(' + result.id + ') ' + result.summary + ' <a href="' + result.url + '">(see guidance)</a></h3>' +
129
137
  '<p>' + selectorObj.reasons.join('<br />') + '</p>' +
130
138
  '<p>Element can be found using the selector:<br /><span class="selector">' +
131
139
  selectorObj.selector +
@@ -5,14 +5,24 @@ module GovukPublishingComponents
5
5
  :description,
6
6
  :body,
7
7
  :accessibility_criteria,
8
+ :accessibility_excluded_rules,
8
9
  :examples
9
10
 
10
- def initialize(id, name, description, body, accessibility_criteria, examples)
11
+ def initialize(
12
+ id,
13
+ name,
14
+ description,
15
+ body,
16
+ accessibility_criteria,
17
+ accessibility_excluded_rules,
18
+ examples
19
+ )
11
20
  @id = id
12
21
  @name = name
13
22
  @description = description
14
23
  @body = body
15
24
  @accessibility_criteria = accessibility_criteria
25
+ @accessibility_excluded_rules = accessibility_excluded_rules
16
26
  @examples = examples
17
27
  end
18
28
 
@@ -17,12 +17,15 @@ module GovukPublishingComponents
17
17
  ComponentExample.new(id.to_s, example["data"], example["context"], example["description"])
18
18
  }
19
19
 
20
- ComponentDoc.new(component[:id],
21
- component[:name],
22
- component[:description],
23
- component[:body],
24
- combined_accessibility_criteria(component),
25
- examples)
20
+ ComponentDoc.new(
21
+ component[:id],
22
+ component[:name],
23
+ component[:description],
24
+ component[:body],
25
+ combined_accessibility_criteria(component),
26
+ component[:accessibility_excluded_rules],
27
+ examples
28
+ )
26
29
  end
27
30
 
28
31
  def combined_accessibility_criteria(component)
@@ -1,4 +1,4 @@
1
- <div data-module="test-a11y">
1
+ <div data-module="test-a11y" data-excluded-rules="<%= @component_doc.accessibility_excluded_rules %>">
2
2
  <%= render "govuk_publishing_components/component_guide/component_doc/component", component_doc: @component_doc, example: example, preview_page: false %>
3
3
  <div class="component-guide-preview component-guide-preview--violation" data-module="test-a11y-violation" data-content="Accessibility Issues"></div>
4
4
  <div class="component-guide-preview component-guide-preview--warning" data-module="test-a11y-warning" data-content="Potential accessibility issues: need manual check"></div>
@@ -3,7 +3,7 @@
3
3
  <% if @component_examples.length > 1 %>
4
4
  <h2 class="preview-title"><a href="<%= component_example_path(@component_doc.id, example.id) %>"><%= example.name %></a></h2>
5
5
  <% end %>
6
- <div data-module="test-a11y">
6
+ <div data-module="test-a11y" data-excluded-rules="<%= @component_doc.accessibility_excluded_rules %>">
7
7
  <%= render "govuk_publishing_components/component_guide/component_doc/component", component_doc: @component_doc, example: example, preview_page: true %>
8
8
  </div>
9
9
  </div>
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = '1.12.1'.freeze
2
+ VERSION = '2.0.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: 1.12.1
4
+ version: 2.0.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: 2017-10-18 00:00:00.000000000 Z
11
+ date: 2017-11-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -164,6 +164,20 @@ dependencies:
164
164
  - - "~>"
165
165
  - !ruby/object:Gem::Version
166
166
  version: 2.4.0
167
+ - !ruby/object:Gem::Dependency
168
+ name: uglifier
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: 1.3.0
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: 1.3.0
167
181
  - !ruby/object:Gem::Dependency
168
182
  name: webmock
169
183
  requirement: !ruby/object:Gem::Requirement