govuk_publishing_components 1.5.0 → 1.6.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.
- checksums.yaml +4 -4
- data/README.md +23 -0
- data/app/assets/javascripts/govuk_publishing_components/vendor/matches-polyfill.min.js +1 -0
- data/app/controllers/govuk_publishing_components/application_controller.rb +5 -0
- data/app/models/govuk_publishing_components/component_doc_resolver.rb +12 -1
- data/app/models/govuk_publishing_components/shared_accessibility_criteria.rb +19 -0
- data/lib/govuk_publishing_components/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a8d9bbd3501a6dc341847fe5f7e1e55862a12a26
|
4
|
+
data.tar.gz: c17cb2fca96844fd7d3038656550fba5cd378e9a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f608ae560744b49d350b8d72b3ee0062a2ea899ddb76cb0219cf941d8e92336d4681695bb145d810e83670bb64afc5382eb010aa49ceba5a7e72036a68a70eb6
|
7
|
+
data.tar.gz: a2f28ab4fd0aae15e63479a7e2b5afe2c7ee819726bbddd954555b294a973f08f6413f352923e7b66c341f6d5b137effdf741703ed1e2e43a875d9526623fc9d
|
data/README.md
CHANGED
@@ -81,6 +81,29 @@ rails generate govuk_publishing_components:component [component_name]
|
|
81
81
|
|
82
82
|
This will create a template, scss file and yml documentation file for a new component. It will not create a test file as this cannot be reliably done automatically across applications, but a test file will be necessary.
|
83
83
|
|
84
|
+
## Integration with Heroku
|
85
|
+
To make the best use of the component guide we use Heroku to serve the current `master` build and whenever a [pull request is added](https://devcenter.heroku.com/articles/github-integration-review-apps)
|
86
|
+
|
87
|
+
When an app is deployed to Heroku it will be in `production` mode, so only gems that are in the main group will be installed and made available.
|
88
|
+
To ensure that we only load the guide on Heroku and not when deployed to _production_ we need to have the gem included in the main bundle group in the Gemfile.
|
89
|
+
For this use case we need `require: false` so that it's not loaded in _production_ but then we can manually `require` the gem in our `application.rb` based on the more complex environmental logic that we've specified.
|
90
|
+
|
91
|
+
First move the gem outside of the `development`, `test` groups and set require to false. ([example](https://github.com/alphagov/government-frontend/blob/5110d3d33f7a6b63f218b889a5afec90e6df810f/Gemfile#L11)):
|
92
|
+
|
93
|
+
```ruby
|
94
|
+
# Gemfile
|
95
|
+
gem 'govuk_publishing_components', require: false
|
96
|
+
```
|
97
|
+
|
98
|
+
Now we can manually require the gem ([example](https://github.com/alphagov/government-frontend/blob/5110d3d33f7a6b63f218b889a5afec90e6df810f/config/application.rb#L14)):
|
99
|
+
|
100
|
+
```ruby
|
101
|
+
# config/application.rb
|
102
|
+
if !Rails.env.production? || ENV['HEROKU_APP_NAME'].present?
|
103
|
+
require 'govuk_publishing_components'
|
104
|
+
end
|
105
|
+
```
|
106
|
+
|
84
107
|
## Licence
|
85
108
|
|
86
109
|
[MIT Licence](LICENCE.md)
|
@@ -0,0 +1 @@
|
|
1
|
+
if(window.Element&&!window.Element.prototype.matches){var proto=window.Element.prototype;proto.matches=proto.matchesSelector||proto.mozMatchesSelector||proto.msMatchesSelector||proto.oMatchesSelector||proto.webkitMatchesSelector};
|
@@ -5,11 +5,16 @@ module GovukPublishingComponents
|
|
5
5
|
include Slimmer::Headers
|
6
6
|
protect_from_forgery with: :exception
|
7
7
|
before_action :set_custom_slimmer_headers
|
8
|
+
before_action :set_x_frame_options_header
|
8
9
|
|
9
10
|
private
|
10
11
|
|
11
12
|
def set_custom_slimmer_headers
|
12
13
|
set_slimmer_headers(report_a_problem: 'false', remove_search: true)
|
13
14
|
end
|
15
|
+
|
16
|
+
def set_x_frame_options_header
|
17
|
+
response.headers["X-Frame-Options"] = "ALLOWALL"
|
18
|
+
end
|
14
19
|
end
|
15
20
|
end
|
@@ -21,10 +21,21 @@ module GovukPublishingComponents
|
|
21
21
|
component[:name],
|
22
22
|
component[:description],
|
23
23
|
component[:body],
|
24
|
-
component
|
24
|
+
combined_accessibility_criteria(component),
|
25
25
|
examples)
|
26
26
|
end
|
27
27
|
|
28
|
+
def combined_accessibility_criteria(component)
|
29
|
+
shared_accessibility_criteria = []
|
30
|
+
|
31
|
+
if component[:shared_accessibility_criteria].present?
|
32
|
+
component[:shared_accessibility_criteria].each do |criteria|
|
33
|
+
shared_accessibility_criteria << SharedAccessibilityCriteria.send(criteria) if SharedAccessibilityCriteria.respond_to? criteria
|
34
|
+
end
|
35
|
+
end
|
36
|
+
"#{component[:accessibility_criteria]}\n#{shared_accessibility_criteria.join("\n")}"
|
37
|
+
end
|
38
|
+
|
28
39
|
def fetch_component_docs
|
29
40
|
doc_files = Rails.root.join(documentation_directory, "*.yml")
|
30
41
|
Dir[doc_files].sort.map { |file| parse_documentation(file) }
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module GovukPublishingComponents
|
2
|
+
module SharedAccessibilityCriteria
|
3
|
+
def self.link
|
4
|
+
"
|
5
|
+
Links in the component must:
|
6
|
+
|
7
|
+
- accept focus
|
8
|
+
- be focusable with a keyboard
|
9
|
+
- be usable with a keyboard
|
10
|
+
- indicate when it has focus
|
11
|
+
- change in appearance when touched (in the touch-down state)
|
12
|
+
- change in appearance when hovered
|
13
|
+
- be usable with touch
|
14
|
+
- be usable with [voice commands](https://www.w3.org/WAI/perspectives/voice.html)
|
15
|
+
- have visible text
|
16
|
+
"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
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.
|
4
|
+
version: 1.6.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-09-
|
11
|
+
date: 2017-09-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -179,6 +179,7 @@ files:
|
|
179
179
|
- app/assets/javascripts/govuk_publishing_components/accessibility-test.js
|
180
180
|
- app/assets/javascripts/govuk_publishing_components/application.js
|
181
181
|
- app/assets/javascripts/govuk_publishing_components/vendor/axe.min.js
|
182
|
+
- app/assets/javascripts/govuk_publishing_components/vendor/matches-polyfill.min.js
|
182
183
|
- app/assets/stylesheets/govuk_publishing_components/application.scss
|
183
184
|
- app/controllers/govuk_publishing_components/application_controller.rb
|
184
185
|
- app/controllers/govuk_publishing_components/component_guide_controller.rb
|
@@ -186,6 +187,7 @@ files:
|
|
186
187
|
- app/models/govuk_publishing_components/component_doc.rb
|
187
188
|
- app/models/govuk_publishing_components/component_doc_resolver.rb
|
188
189
|
- app/models/govuk_publishing_components/component_example.rb
|
190
|
+
- app/models/govuk_publishing_components/shared_accessibility_criteria.rb
|
189
191
|
- app/views/govuk_publishing_components/component_guide/component_doc/_call.html.erb
|
190
192
|
- app/views/govuk_publishing_components/component_guide/component_doc/_component.html.erb
|
191
193
|
- app/views/govuk_publishing_components/component_guide/component_doc/_preview.html.erb
|