govuk_publishing_components 5.0.0 → 5.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (28) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +19 -182
  3. data/app/assets/javascripts/govuk_publishing_components/components/feedback.js +152 -0
  4. data/app/assets/javascripts/govuk_publishing_components/components/step-by-step-nav.js +4 -2
  5. data/app/assets/stylesheets/govuk_publishing_components/_all_components.scss +1 -0
  6. data/app/assets/stylesheets/govuk_publishing_components/_all_components_print.scss +1 -0
  7. data/app/assets/stylesheets/govuk_publishing_components/components/_feedback.scss +136 -0
  8. data/app/assets/stylesheets/govuk_publishing_components/components/_input.scss +10 -2
  9. data/app/assets/stylesheets/govuk_publishing_components/components/print/_feedback.scss +3 -0
  10. data/app/controllers/govuk_publishing_components/application_controller.rb +1 -1
  11. data/app/models/govuk_publishing_components/component_doc.rb +5 -0
  12. data/app/views/govuk_publishing_components/component_guide/show.html.erb +1 -1
  13. data/app/views/govuk_publishing_components/components/_feedback.html.erb +115 -0
  14. data/app/views/govuk_publishing_components/components/_input.html.erb +2 -1
  15. data/app/views/govuk_publishing_components/components/_step_by_step_nav.html.erb +3 -1
  16. data/app/views/govuk_publishing_components/components/_step_by_step_nav_header.html.erb +3 -1
  17. data/app/views/govuk_publishing_components/components/_step_by_step_nav_related.html.erb +5 -2
  18. data/app/views/govuk_publishing_components/components/docs/feedback.yml +22 -0
  19. data/app/views/govuk_publishing_components/components/docs/input.yml +9 -3
  20. data/app/views/govuk_publishing_components/components/docs/step_by_step_nav.yml +23 -0
  21. data/app/views/govuk_publishing_components/components/docs/step_by_step_nav_header.yml +6 -0
  22. data/app/views/govuk_publishing_components/components/docs/step_by_step_nav_related.yml +10 -0
  23. data/app/views/layouts/govuk_publishing_components/application.html.erb +3 -1
  24. data/config/initializers/assets.rb +1 -1
  25. data/lib/govuk_publishing_components/version.rb +1 -1
  26. metadata +7 -4
  27. data/DEVELOPMENT.md +0 -15
  28. data/app/assets/stylesheets/govuk_publishing_components/component_guide_print.scss +0 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2246fa0ef19db8a5d4ce9ab9f9e58c0f7858d1504f4e7c847b45ef511ad38eea
4
- data.tar.gz: 3468abaaa41ec8bdd66820bcba7615d28d937da6dd229c4a2eaa9a33a604edb2
3
+ metadata.gz: 6484c097648ef843277296e363e464c34eb5867e38208da9d95f535465b5d3dc
4
+ data.tar.gz: b385a33cf3ae71c87a358caaa745857e648b32dbb50eb79f74de2641e09ed428
5
5
  SHA512:
6
- metadata.gz: c52ef6feed05da9b9dcc06fac40deb988d93d9b4e9cd56cc772bae21186dd993e9158e802fef751087effd37f8e85e61a9a1106061ccc15b0200fa15a6c25f1d
7
- data.tar.gz: 29bab2b37364334ef3f873394fd2859dce85568b83e7b57012e3da1eaa6adafc9398c67433633a9e8cebcedd0cf9807b6584597370ae70387a5b0a816ab1c7e6
6
+ metadata.gz: 05d509df697c8317057d110949d62e6d3457a92842eaea6427600808b5cf21c3e42802358d5824353cd72673e5aaba361f127b40c21cf0a9f6e42d85aa5e8c70
7
+ data.tar.gz: 14caa84e583f4a8463204e4092e6cf84a8dd86f4bb04e8226cf9f75315f7bab989ae4867763e0411dfaa17e6a305e2d9586d1a32f60f515afeb33eb8630640fc
data/README.md CHANGED
@@ -1,201 +1,38 @@
1
1
  # GOV.UK Publishing Components
2
2
 
3
- A gem to document components in GOV.UK frontend applications and provide shared components to applications. Components should be added to this gem if they are required in more than one application, otherwise they should be added to that application.
3
+ A gem to 1) document components in GOV.UK frontend applications and 2) provide shared components to applications.
4
4
 
5
- ![Screenshot of component guide](docs/screenshot.png)
6
-
7
- ## Write components in your application
8
-
9
- Components are packages of template, style, behaviour and documentation.
10
-
11
- A component must:
12
- * [meet the component principles](docs/component_principles.md)
13
- * [follow component conventions](docs/component_conventions.md)
14
-
15
- Components are included in templates in slightly different ways depending on whether the component is in the application itself, in static, or in the gem.
16
-
17
- A component from the application would be included in a template like this:
18
-
19
- ```erb
20
- <%= render "components/back-to-top", href: "#contents" %>
21
- ```
22
-
23
- A component from static would be included like this:
24
-
25
- ```erb
26
- <%= render "govuk_component/lead_paragraph", text: "A description is one or two leading sentences." %>
27
- ```
28
-
29
- A component from the gem would be included like this:
30
-
31
- ```erb
32
- <%= render "govuk_publishing_components/components/back_link", href: "#" %>
33
- ```
34
-
35
- ## Set up a component guide
36
-
37
- This gem creates a component guide for all your application’s components.
38
-
39
- An example guide this gem created for government-frontend:
40
- https://government-frontend.herokuapp.com/component-guide
41
-
42
- The guide includes your application’s `application.scss` and `application.js` files by default. This is [configurable](#configuration).
43
-
44
- You are encouraged to set up [Heroku review apps](https://docs.publishing.service.gov.uk/manual/review-apps.html) for your application, so that any changes to local components can be reviewed by looking at the component guide.
45
-
46
- ### Install gem
47
-
48
- Add this line to your application's Gemfile:
49
-
50
- ```ruby
51
- gem 'govuk_publishing_components'
52
- ```
53
-
54
- And then execute:
55
- ```bash
56
- $ bundle
57
- ```
58
-
59
- ### Mount the component guide
60
-
61
- Mount the component guide in your application:
62
-
63
- ```ruby
64
- # config/routes.rb
65
- mount GovukPublishingComponents::Engine, at: "/component-guide"
66
- ```
67
-
68
- If your application was government-frontend the component guide would be at:
69
- http://government-frontend.dev.gov.uk/component-guide
70
-
71
- ### Configure the gem
72
-
73
- Use a config block in an initializer:
74
-
75
- ```ruby
76
- # config/initializers/govuk_publishing_components.rb
77
- GovukPublishingComponents.configure do |c|
78
- c.component_guide_title = "My component guide"
79
-
80
- c.application_stylesheet = "custom_stylesheet" # Defaults to "application"
81
- c.application_print_stylesheet = "print" # Not included by default
82
- c.application_javascript = "custom_javascript" # Defaults to "application"
83
- end
84
- ```
85
-
86
- ### Running the gem as a standalone app
87
-
88
- If you want to work on this gem directly, without having to add it to another
89
- application, you can run it in the development vm:
90
-
91
- ```
92
- ./startup.sh
93
- ```
94
-
95
- The app should start on http://localhost:3212 or http://publishing-components.dev.gov.uk/component-guide on GOV.UK development machines.
96
-
97
- ```
98
- ./startup.sh --live
99
- ```
100
-
101
- This will run the app and point it at the production `static` instance.
102
-
103
- #### Running with bowl on the VM
104
-
105
- ```
106
- $ cd /var/govuk/govuk_publishing_components
107
- $ bundle
108
-
109
- $ cd /var/govuk/govuk-puppet/development-vm
110
- $ bowl publishing-components
111
- ```
112
-
113
- Then visit [publishing-components.dev.gov.uk/component-guide](http://publishing-components.dev.gov.uk/component-guide).
114
-
115
- #### Running locally
116
-
117
- If you don't want to run it in the development vm, you can start the app with:
118
-
119
- ```
120
- $ cd /var/govuk/govuk_publishing_components
121
- $ bundle
122
-
123
- $ PLEK_SERVICE_STATIC_URI=assets.publishing.service.gov.uk bundle exec foreman start
124
- ```
5
+ Components should be added to this gem if they are required in more than one application, otherwise they should be added to that application.
125
6
 
126
- Then visit [localhost:5000/component-guide](http://localhost:5000/component-guide).
127
-
128
- ### Test the component guide
7
+ ![Screenshot of component guide](docs/screenshot.png)
129
8
 
130
- The gem [includes integration tests](lib/govuk_publishing_components/minitest/component_guide_test.rb) to check that your component guide and examples are error free and that they meet basic accessibility needs.
9
+ ## How to
131
10
 
132
- Automated accessibility tests use [aXe](https://github.com/dequelabs/axe-core). Using our `AccessibilityTest` wrapper the gem runs the aXe suite against each example and throws JavaScript errors for any violations. These JavaScript errors can be used to fail a build in CI.
11
+ - [Install and use this gem](/docs/install-and-use.md)
12
+ - [Use a component in your application](/docs/use-components.md)
13
+ - [Generate a new component](/docs/generate-a-new-component.md)
14
+ - [Develop a component](/docs/develop-component.md)
15
+ - [Run the component guide](/docs/run-component-guide.md)
16
+ - [Move a component from an application to the gem](/docs/moving-components-upstream-into-this-gem.md)
133
17
 
134
- #### Minitest
18
+ ## Running tests
135
19
 
136
- ```ruby
137
- # component_guide_test.rb
138
- require 'govuk_publishing_components/minitest/component_guide_test'
20
+ The default rake task runs all tests:
139
21
 
140
- class ComponentGuideTest < ActionDispatch::IntegrationTest
141
- include GovukPublishingComponents::Minitest::ComponentGuideTest
142
- end
143
22
  ```
144
-
145
- #### Test files
146
-
147
- All test files for components in the gem can be run with the command `bundle exec rake`.
148
-
149
- ### Exclude accessibility rules
150
-
151
- 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.
152
-
153
- 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.
154
-
155
- For an example of this check [test/.../docs/test-component-with-duplicate-ids.yml](spec/dummy/app/views/components/docs/test-component-with-duplicate-ids.yml)
156
-
157
-
158
- ## Component generator
159
-
160
- The gem includes a component generator to stub the minimal files required for a component. The following command will create a component in the application it is run in - it will not create a component if run within the gem.
161
-
162
- ```ruby
163
- rails generate govuk_publishing_components:component [component_name]
23
+ bundle exec rake
164
24
  ```
165
25
 
166
- 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.
167
-
168
- ### Creating components in the gem
169
-
170
- Currently components in the gem must be manually created. File naming conventions should follow those in the [component conventions](docs/component_conventions.md), but a slightly different directory structure is required to avoid conflicts with components in applications.
171
-
172
- * Stylesheets go in `app/assets/stylesheets/govuk_publishing_components/components`
173
- * Print stylesheets go in `app/assets/stylesheets/govuk_publishing_components/components/print`
174
- * Scripts go in `app/assets/javascripts/govuk_publishing_components/components`
175
- * Templates go in `app/views/govuk_publishing_components/components`
176
- * Documentation goes in `app/views/govuk_publishing_components/components/docs`
177
- * Test files go in `spec/components`
178
- * Script test files go in `spec/javascripts/components`
26
+ Javascript is tested using Jasmine and the [Jasmine gem](https://github.com/pivotal/jasmine-gem). Tests can be run either in the browser or on the command line via the dummy app’s tasks:
179
27
 
180
- In addition, components in the gem can have helper files. Helper files go in `lib/govuk_publishing_components/components` and need to be required in `lib/govuk_publishing_components.rb`. Helper files should be structured as a class.
28
+ ```sh
29
+ # browser
30
+ bundle exec rake app:jasmine
181
31
 
182
- ## Automated Testing
183
- ### Visual Diff Tool
184
- The component guide includes a visual diff tool that should make it easier to spot when you are introducing visual regressions in your components.
185
-
186
- It can be run on a locally running version of the component guide, to compare it to the heroku master deploy. For example: [government-frontend.dev.gov.uk/component-guide](http://government-frontend.dev.gov.uk/component-guide) will be compared to [government-frontend.herokuapp.com/component-guide](https://government-frontend.herokuapp.com/component-guide).
187
-
188
- The tool can be run via the console using the following command:
189
- ```js
190
- window.GOVUK.VisualDiffTool()
32
+ # command line
33
+ bundle exec rake app:jasmine:ci
191
34
  ```
192
35
 
193
36
  ## Licence
194
37
 
195
38
  [MIT Licence](LICENCE.md)
196
-
197
- ## Development
198
- For documentation on how to update and develop this gem see [DEVELOPMENT.md](./DEVELOPMENT.md)
199
-
200
- ### Moving components upstream into this gem
201
- See [the documentation on how to move components into this gem](docs/moving-components-upstream-into-this-gem.md)
@@ -0,0 +1,152 @@
1
+ window.GOVUK = window.GOVUK || {};
2
+ window.GOVUK.Modules = window.GOVUK.Modules || {};
3
+
4
+ (function (Modules) {
5
+ "use strict";
6
+ window.GOVUK = window.GOVUK || {};
7
+
8
+ Modules.Feedback = function () {
9
+
10
+ this.start = function ($element) {
11
+ this.$prompt = $element.find('.js-prompt');
12
+ this.$fields = $element.find('.gem-c-feedback__form-field');
13
+ this.$forms = $element.find('.js-feedback-form');
14
+ this.$toggleForms = $element.find('.js-toggle-form');
15
+ this.$closeForms = $element.find('.js-close-form');
16
+ this.$activeForm = false;
17
+ this.$pageIsUsefulButton = $element.find('.js-page-is-useful');
18
+ this.$pageIsNotUsefulButton = $element.find('.js-page-is-not-useful');
19
+ this.$somethingIsWrongButton = $element.find('.js-something-is-wrong');
20
+ this.$promptQuestions = $element.find('.js-prompt-questions');
21
+ this.$promptSuccessMessage = $element.find('.js-prompt-success');
22
+
23
+ var that = this;
24
+ var jshiddenClass = 'js-hidden';
25
+
26
+ setInitialAriaAttributes();
27
+
28
+ this.$toggleForms.on('click', function(e) {
29
+ e.preventDefault();
30
+ toggleForm($(e.target).attr('aria-controls'));
31
+ trackEvent(getTrackEventParams($(this)));
32
+ updateAriaAttributes($(this));
33
+ });
34
+
35
+ this.$closeForms.on('click', function(e) {
36
+ e.preventDefault();
37
+ toggleForm($(e.target).attr('aria-controls'));
38
+ setInitialAriaAttributes();
39
+ });
40
+
41
+ this.$pageIsUsefulButton.on('click', function(e) {
42
+ e.preventDefault();
43
+ trackEvent(getTrackEventParams(that.$pageIsUsefulButton));
44
+ showFormSuccess();
45
+ revealInitialPrompt();
46
+ });
47
+
48
+ $element.find('form').on('submit', function(e) {
49
+ e.preventDefault();
50
+ var $form = $(this);
51
+ $.ajax({
52
+ type: "POST",
53
+ url: $form.attr('action'),
54
+ dataType: "json",
55
+ data: $form.serialize(),
56
+ beforeSend: disableSubmitFormButton($form),
57
+ timeout: 6000
58
+ }).done(function (xhr) {
59
+ trackEvent(getTrackEventParams($form));
60
+ showFormSuccess(xhr.message);
61
+ revealInitialPrompt();
62
+ setInitialAriaAttributes();
63
+ that.$activeForm.toggleClass(jshiddenClass);
64
+ }).fail(function (xhr) {
65
+ showError(xhr);
66
+ enableSubmitFormButton($form);
67
+ });
68
+ });
69
+
70
+ function disableSubmitFormButton ($form) {
71
+ $form.find('input[type="submit"]').prop('disabled', true);
72
+ }
73
+
74
+ function enableSubmitFormButton ($form) {
75
+ $form.find('input[type="submit"]').removeAttr('disabled');
76
+ }
77
+
78
+ function setInitialAriaAttributes () {
79
+ that.$forms.attr('aria-hidden', true);
80
+ that.$pageIsNotUsefulButton.attr('aria-expanded', false);
81
+ that.$somethingIsWrongButton.attr('aria-expanded', false);
82
+ }
83
+
84
+ function updateAriaAttributes (linkClicked) {
85
+ linkClicked.attr('aria-expanded', true);
86
+ $('#' + linkClicked.attr('aria-controls')).attr('aria-hidden', false);
87
+ }
88
+
89
+ function toggleForm (formId) {
90
+ that.$activeForm = $element.find('#' + formId);
91
+ that.$activeForm.toggleClass(jshiddenClass);
92
+ that.$prompt.toggleClass(jshiddenClass);
93
+
94
+ var formIsVisible = !that.$activeForm.hasClass(jshiddenClass);
95
+
96
+ if (formIsVisible) {
97
+ that.$activeForm.find('.gem-c-input').first().focus();
98
+ } else {
99
+ that.$activeForm = false;
100
+ }
101
+ }
102
+
103
+ function getTrackEventParams ($node) {
104
+ return {
105
+ category: $node.data('track-category'),
106
+ action: $node.data('track-action')
107
+ }
108
+ }
109
+
110
+ function trackEvent (trackEventParams) {
111
+ if (GOVUK.analytics && GOVUK.analytics.trackEvent) {
112
+ GOVUK.analytics.trackEvent(trackEventParams.category, trackEventParams.action);
113
+ }
114
+ }
115
+
116
+ function clearMessages () {
117
+ $element.find('.js-errors').html('').addClass(jshiddenClass);
118
+ }
119
+
120
+ function showError (error) {
121
+ var error = [
122
+ '<h2 class="gem-c-feedback__heading">',
123
+ ' Sorry, we’re unable to receive your message right now. ',
124
+ '</h2>',
125
+ '<p>If the problem persists, we have other ways for you to provide',
126
+ ' feedback on the <a href="/contact/govuk">contact page</a>.</p>'
127
+ ].join('');
128
+
129
+ if (typeof(error.responseJSON) !== 'undefined') {
130
+ error = typeof(error.responseJSON.message) == 'undefined' ? error : error.responseJSON.message;
131
+ }
132
+ var $errors = that.$activeForm.find('.js-errors');
133
+ $errors.html(error).removeClass(jshiddenClass).focus();
134
+ }
135
+
136
+ function clearAllInputs () {
137
+ that.$fields.val('');
138
+ }
139
+
140
+ function showFormSuccess () {
141
+ that.$promptQuestions.addClass(jshiddenClass);
142
+ that.$promptSuccessMessage.removeClass(jshiddenClass).focus();
143
+ }
144
+
145
+ function revealInitialPrompt () {
146
+ that.$prompt.removeClass(jshiddenClass);
147
+ that.$prompt.focus();
148
+ }
149
+ }
150
+
151
+ };
152
+ })(window.GOVUK.Modules);
@@ -49,7 +49,8 @@
49
49
 
50
50
  var $showOrHideAllButton;
51
51
 
52
- var stepNavTracker = new StepNavTracker(totalSteps, totalLinks);
52
+ var uniqueId = $element.data('id') || false;
53
+ var stepNavTracker = new StepNavTracker(totalSteps, totalLinks, uniqueId);
53
54
 
54
55
  addButtonstoSteps();
55
56
  addShowHideAllButton();
@@ -450,7 +451,7 @@
450
451
 
451
452
  // A helper that sends a custom event request to Google Analytics if
452
453
  // the GOVUK module is setup
453
- function StepNavTracker(totalSteps, totalLinks) {
454
+ function StepNavTracker(totalSteps, totalLinks, uniqueId) {
454
455
  this.track = function(category, action, options) {
455
456
  // dimension26 records the total number of expand/collapse steps in this step nav
456
457
  // dimension27 records the total number of links in this step nav
@@ -459,6 +460,7 @@
459
460
  options = options || {};
460
461
  options["dimension26"] = options["dimension26"] || totalSteps.toString();
461
462
  options["dimension27"] = options["dimension27"] || totalLinks.toString();
463
+ options["dimension96"] = options["dimension96"] || uniqueId;
462
464
  GOVUK.analytics.trackEvent(category, action, options);
463
465
  }
464
466
  }
@@ -16,3 +16,4 @@
16
16
  @import "components/step-by-step-nav";
17
17
  @import "components/step-by-step-nav-header";
18
18
  @import "components/step-by-step-nav-related";
19
+ @import "components/feedback";
@@ -9,3 +9,4 @@
9
9
 
10
10
  @import "components/print/step-by-step-nav";
11
11
  @import "components/print/step-by-step-nav-header";
12
+ @import "components/print/feedback";
@@ -0,0 +1,136 @@
1
+ // govuk_frontend_toolkit
2
+ @import 'grid_layout';
3
+ @import 'design-patterns/buttons';
4
+
5
+ .gem-c-feedback {
6
+ max-width: 960px;
7
+ margin: 0 auto;
8
+ }
9
+
10
+ // hide without js
11
+ // show with js, unless also has the js-hidden class
12
+ .gem-c-feedback__js-show {
13
+ display: none;
14
+
15
+ .js-enabled & {
16
+ display: block;
17
+
18
+ &.js-hidden {
19
+ display: none;
20
+ }
21
+ }
22
+ }
23
+
24
+ .gem-c-feedback__grid-row {
25
+ @extend %grid-row;
26
+ }
27
+
28
+ .gem-c-feedback__column-two-thirds {
29
+ @include grid-column( 2 / 3 );
30
+ }
31
+
32
+ .gem-c-feedback__prompt {
33
+ @extend %contain-floats;
34
+ background-color: $govuk-blue;
35
+ color: $white;
36
+ padding: $gutter-one-third $gutter-half 0;
37
+ outline: 0;
38
+ }
39
+
40
+ .gem-c-feedback__prompt-question,
41
+ .gem-c-feedback__prompt-success {
42
+ @include bold-16;
43
+ display: inline;
44
+
45
+ &:focus {
46
+ outline: 0;
47
+ }
48
+ }
49
+
50
+ .gem-c-feedback__prompt-link:link,
51
+ .gem-c-feedback__prompt-link:visited {
52
+ color: $white;
53
+ display: inline-block;
54
+ }
55
+
56
+ .gem-c-feedback__prompt-link--useful {
57
+ margin-right: 0.2em;
58
+ }
59
+
60
+ .gem-c-feedback__prompt-link--wrong {
61
+ float: right;
62
+ }
63
+
64
+ .gem-c-feedback__error-summary {
65
+ margin-bottom: $gutter-half;
66
+ padding: $gutter-half;
67
+ border: solid 4px $error-colour;
68
+
69
+ &:focus {
70
+ outline: solid 3px $focus-colour;
71
+ }
72
+
73
+ @include media(tablet) {
74
+ border-width: 5px;
75
+ }
76
+
77
+ // this comes from the backend so we can't put a class on it
78
+ h2,
79
+ .gem-c-feedback__heading {
80
+ @include bold-19;
81
+ margin: 0;
82
+ }
83
+
84
+ p {
85
+ @include core-16;
86
+ margin: $gutter-one-third 0;
87
+ }
88
+ }
89
+
90
+ .gem-c-feedback__error-message {
91
+ @include bold-19;
92
+ display: block;
93
+ padding: 4px 0 0;
94
+ color: $error-colour;
95
+ }
96
+
97
+ .gem-c-feedback__form {
98
+ margin-top: $gutter-half;
99
+ padding: $gutter-half 0;
100
+ border-top: $gutter-one-third solid $govuk-blue;
101
+
102
+ @include media(tablet) {
103
+ padding: $gutter 0;
104
+ }
105
+ }
106
+
107
+ .gem-c-feedback__form-heading {
108
+ @include bold-19;
109
+ margin-bottom: $gutter-half;
110
+ }
111
+
112
+ .gem-c-feedback__form-paragraph {
113
+ @include core-16;
114
+ margin-bottom: $gutter;
115
+ }
116
+
117
+ .gem-c-feedback__form-label {
118
+ @include core-16;
119
+ display: block;
120
+ padding-bottom: $gutter-half;
121
+ }
122
+
123
+ .gem-c-feedback__close {
124
+ @include core-16;
125
+ text-align: right;
126
+ margin-bottom: $gutter-one-third;
127
+
128
+ @include media(tablet) {
129
+ float: right;
130
+ padding-top: 0;
131
+ }
132
+ }
133
+
134
+ .gem-c-feedback__submit {
135
+ @include button;
136
+ }
@@ -1,10 +1,17 @@
1
- .gem-c-input {
1
+ // scss-lint:disable QualifyingElement
2
+ .gem-c-input,
3
+
4
+ // Explicitly set the input type so that we have higher specificity than
5
+ // https://github.com/alphagov/static/blob/79d29b6a4221874ead27e67d007704a6be166a57/app/assets/stylesheets/helpers/_buttons.scss#L91-L122
6
+ // This can be removed once everything is using `core_layout`.
7
+ input[type=text].gem-c-input {
2
8
  @include core-19;
3
9
 
4
10
  box-sizing: border-box;
5
11
  width: 100%;
6
12
  height: 2.10526em;
7
- margin-top: 0;
13
+
14
+ margin: 0; // Override unwanted global cascaded styles
8
15
  margin-bottom: 20px;
9
16
 
10
17
  padding: $gem-spacing-scale-1;
@@ -16,6 +23,7 @@
16
23
  // Disable inner shadow and remove rounded corners
17
24
  appearance: none;
18
25
  }
26
+ // scss-lint:enable QualifyingElement
19
27
 
20
28
  @media (min-width: 40.0625em) {
21
29
  .govuk-c-input {
@@ -14,7 +14,7 @@ module GovukPublishingComponents
14
14
  private
15
15
 
16
16
  def set_custom_slimmer_headers
17
- set_slimmer_headers(report_a_problem: 'false', remove_search: true)
17
+ set_slimmer_headers(remove_search: true)
18
18
  end
19
19
 
20
20
  def set_x_frame_options_header
@@ -53,6 +53,11 @@ module GovukPublishingComponents
53
53
  end
54
54
  end
55
55
 
56
+ def github_search_url
57
+ params = { q: "org:alphagov #{partial_path}", type: "Code" }
58
+ "https://github.com/search?#{params.to_query}"
59
+ end
60
+
56
61
  private
57
62
 
58
63
  def govspeak_to_html(govspeak)
@@ -22,7 +22,7 @@
22
22
  <div class="component-doc">
23
23
  <h2 class="component-doc-h2">How to call this component</h2>
24
24
  <%= render "govuk_publishing_components/component_guide/component_doc/call", component_doc: @component_doc, example: @component_doc.example %>
25
-
25
+ <%= link_to "Search for usage on GitHub", @component_doc.github_search_url %>
26
26
  <h2 class="component-doc-h2">How it looks</h2>
27
27
  </div>
28
28
 
@@ -0,0 +1,115 @@
1
+ <%
2
+ contact_govuk_path = "/contact/govuk"
3
+ %>
4
+
5
+ <div class="gem-c-feedback" data-module="feedback">
6
+ <div class="gem-c-feedback__prompt gem-c-feedback__js-show js-prompt" tabindex="-1">
7
+ <div class="js-prompt-questions">
8
+ <h3 class="gem-c-feedback__prompt-question">Is this page useful?</h3>
9
+
10
+ <%= link_to contact_govuk_path, {
11
+ class: 'gem-c-feedback__prompt-link gem-c-feedback__prompt-link--useful js-page-is-useful',
12
+ data: {
13
+ 'track-category' => 'yesNoFeedbackForm',
14
+ 'track-action' => 'ffYesClick'
15
+ },
16
+ } do %>
17
+ Yes <span class="visually-hidden">this page is useful</span>
18
+ <% end %>
19
+
20
+ <%= link_to contact_govuk_path, {
21
+ class: 'gem-c-feedback__prompt-link js-toggle-form js-page-is-not-useful',
22
+ data: {
23
+ 'track-category' => 'yesNoFeedbackForm',
24
+ 'track-action' => 'ffNoClick'
25
+ },
26
+ 'aria-controls': 'page-is-not-useful',
27
+ 'aria-expanded': false
28
+ } do %>
29
+ No <span class="visually-hidden">this page is not useful</span>
30
+ <% end %>
31
+
32
+ <%= link_to contact_govuk_path, {
33
+ class: 'gem-c-feedback__prompt-link gem-c-feedback__prompt-link--wrong js-toggle-form js-something-is-wrong',
34
+ data: {
35
+ 'track-category' => 'yesNoFeedbackForm',
36
+ 'track-action' => 'ffWrongClick'
37
+ },
38
+ 'aria-controls': 'something-is-wrong',
39
+ 'aria-expanded': false
40
+ } do %>
41
+ Is there anything wrong with this page?
42
+ <% end %>
43
+ </div>
44
+
45
+ <div class="gem-c-feedback__prompt-success js-prompt-success js-hidden" tabindex="-1">
46
+ Thank you for your feedback
47
+ </div>
48
+ </div>
49
+
50
+ <form action="/contact/govuk/problem_reports" id="something-is-wrong" class="gem-c-feedback__form js-feedback-form js-hidden" data-track-category="yesNoFeedbackForm" data-track-action="ffFormSubmit">
51
+ <a href="#" class="gem-c-feedback__close gem-c-feedback__js-show js-close-form" aria-controls="something-is-wrong" aria-expanded="true" role="button">Close</a>
52
+
53
+ <div class="gem-c-feedback__grid-row">
54
+ <div class="gem-c-feedback__column-two-thirds">
55
+ <div class="gem-c-feedback__error-summary gem-c-feedback__js-show js-hidden js-errors" tabindex="-1"></div>
56
+
57
+ <input type="hidden" name="url" value="<%= request.original_url -%>">
58
+ <input type="hidden" name="user_agent" value="<%= request.user_agent -%>">
59
+
60
+ <h2 class="gem-c-feedback__form-heading">Help us improve GOV.UK</h2>
61
+ <p id="feedback_explanation" class="gem-c-feedback__form-paragraph">Don’t include personal or financial information like your National Insurance number or credit card details.</p>
62
+
63
+ <%= render "govuk_publishing_components/components/input", {
64
+ label: {
65
+ text: "What were you doing?"
66
+ },
67
+ name: "what_doing"
68
+ } %>
69
+
70
+ <%= render "govuk_publishing_components/components/input", {
71
+ label: {
72
+ text: "What went wrong?"
73
+ },
74
+ name: "what_wrong"
75
+ } %>
76
+
77
+ <%# TODO: use button component once available in gem %>
78
+ <input class="gem-c-feedback__submit" type="submit" value="Send">
79
+ </div>
80
+ </div>
81
+ </form>
82
+
83
+ <form action="/contact/govuk/email-survey-signup" id="page-is-not-useful" class="gem-c-feedback__form gem-c-feedback__form--email gem-c-feedback__js-show js-feedback-form js-hidden" data-track-category="user_satisfaction_survey" data-track-action="banner_taken">
84
+ <a href="#" class="gem-c-feedback__close js-close-form" aria-controls="page-is-not-useful" aria-expanded="true" role="button">Close</a>
85
+
86
+ <div class="gem-c-feedback__grid-row">
87
+ <div class="gem-c-feedback__column-two-thirds">
88
+ <div class="gem-c-feedback__error-summary js-hidden js-errors" tabindex="-1"></div>
89
+
90
+ <input type="hidden" name="url" value="<%= request.original_url -%>">
91
+ <input type="hidden" name="user_agent" value="<%= request.user_agent -%>">
92
+
93
+ <input name="email_survey_signup[survey_id]" type="hidden" value="user_satisfaction_survey">
94
+ <input name="email_survey_signup[survey_source]" type="hidden" value="<%= request.original_url -%>">
95
+ <input name="email_survey_signup[ga_client_id]" type="hidden" value="1627485790.1515403243">
96
+
97
+ <h2 class="gem-c-feedback__form-heading">Help us improve GOV.UK</h2>
98
+ <p id="survey_explanation" class="gem-c-feedback__form-paragraph">To help us improve GOV.UK, we’d like to know more about your visit today. We’ll send you a link to a feedback form. It will take only 2 minutes to fill in. Don’t worry we won’t send you spam or share your email address with anyone.</p>
99
+
100
+ <%= render "govuk_publishing_components/components/input", {
101
+ label: {
102
+ text: "Email address"
103
+ },
104
+ name: "email_survey_signup[email_address]",
105
+ type: "email"
106
+ } %>
107
+
108
+ <%# TODO: use button component once available in gem %>
109
+ <input class="gem-c-feedback__submit" type="submit" value="Send me the survey">
110
+ <a href="https://www.smartsurvey.co.uk/s/gov-uk-banner/?c=<%= request.fullpath -%>&amp;gcl=1627485790.1515403243" id="take-survey" target="_blank" rel="noopener noreferrer">Don’t have an email address?</a>
111
+ </div>
112
+ </div>
113
+ </form>
114
+
115
+ </div>
@@ -4,6 +4,7 @@
4
4
  value ||= false
5
5
  error_message ||= false
6
6
  label ||= {}
7
+ type ||= "text"
7
8
  %>
8
9
 
9
10
  <%= render "govuk_publishing_components/components/label", {
@@ -19,7 +20,7 @@
19
20
  class="gem-c-input <%= "gem-c-input--error" if error_message %>"
20
21
  id="<%= id %>"
21
22
  name="<%= name %>"
22
- type="text"
23
+ type="<%= type %>"
23
24
 
24
25
  <% if error_message %>
25
26
  aria-describedby="<%= hint_id %>"
@@ -9,6 +9,7 @@
9
9
  step_nav_url ||= false
10
10
  step_nav_link_text ||= "Get help completing this step"
11
11
  highlight_step ||= false
12
+ tracking_id ||= false
12
13
 
13
14
  step_count = 0
14
15
  step_number = 0
@@ -17,7 +18,8 @@
17
18
  <div
18
19
  data-module="gemstepnav"
19
20
  class="gem-c-step-nav js-hidden <% unless small %>gem-c-step-nav--large<% end %>"
20
- <% if remember_last_step %>data-remember<% end %>
21
+ <%= "data-remember" if remember_last_step %>
22
+ <%= "data-id=#{tracking_id}" if tracking_id %>
21
23
  >
22
24
  <ol class="gem-c-step-nav__steps">
23
25
  <% steps.each_with_index do |step, step_index| %>
@@ -3,6 +3,7 @@
3
3
  path ||= false
4
4
  skip_link ||= false
5
5
  skip_link_text ||= "Skip content"
6
+ tracking_id ||= false
6
7
  %>
7
8
  <% if title %>
8
9
  <div class="gem-c-step-nav-header" data-module="track-click">
@@ -14,7 +15,8 @@
14
15
  data-track-action="top"
15
16
  data-track-label="<%= path %>"
16
17
  data-track-dimension="<%= title %>"
17
- data-track-dimension-index="29">
18
+ data-track-dimension-index="29"
19
+ data-track-options='{"dimension96" : "<%= tracking_id %>" }'>
18
20
  <%= title %>
19
21
  </a>
20
22
  <% else %>
@@ -1,6 +1,7 @@
1
1
  <%
2
2
  links ||= false
3
3
  pretitle ||= t("govuk_component.step_by_step_nav_related.part_of", default: "Part of")
4
+ tracking_id ||= false
4
5
  %>
5
6
  <% if links %>
6
7
  <div class="gem-c-step-nav-related" data-module="track-click">
@@ -13,7 +14,8 @@
13
14
  data-track-action="<%= pretitle %>"
14
15
  data-track-label="<%= links[0][:href] %>"
15
16
  data-track-dimension="<%= links[0][:text] %>"
16
- data-track-dimension-index="29">
17
+ data-track-dimension-index="29"
18
+ data-track-options='{"dimension96" : "<%= tracking_id %>" }'>
17
19
  <%= links[0][:text] %>
18
20
  </a>
19
21
  </h2>
@@ -28,7 +30,8 @@
28
30
  data-track-action="<%= pretitle %>"
29
31
  data-track-label="<%= link[:href] %>"
30
32
  data-track-dimension="<%= link[:text] %>"
31
- data-track-dimension-index="29">
33
+ data-track-dimension-index="29"
34
+ data-track-options='{"dimension96" : "<%= tracking_id %>" }'>
32
35
  <%= link[:text] %>
33
36
  </a>
34
37
  </li>
@@ -0,0 +1,22 @@
1
+ name: Feedback
2
+ description: Invites user feedback on the current page
3
+ body: |
4
+ This component is designed to sit at the bottom of pages on GOV.UK to allow users to submit feedback on that page. It is based on the 'improve this page' component from the Service manual, but changes have been made.
5
+
6
+ This component includes imported button styles, which is not ideal (styles are duplicated). Once the [button component](/component-guide/button) has been moved to the gem, this should be used instead.
7
+ accessibility_criteria: |
8
+ Form elements in the component must:
9
+
10
+ * accept focus
11
+ * be focusable with a keyboard
12
+ * be usable with a keyboard
13
+ * be usable with touch
14
+ * indicate when they have focus
15
+ * be recognisable as form input elements
16
+ * have correctly associated labels
17
+ * be of the appropriate type for their use, e.g. password inputs should be of type 'password'
18
+ shared_accessibility_criteria:
19
+ - link
20
+ examples:
21
+ default:
22
+ data: {}
@@ -10,13 +10,19 @@ accessibility_criteria: |
10
10
  * be keyboard focusable
11
11
  examples:
12
12
  default:
13
+ data:
14
+ label:
15
+ text: "What is your name?"
16
+ name: "name"
17
+ email_type:
13
18
  data:
14
19
  label:
15
20
  text: "What is your email address?"
16
21
  name: "address"
22
+ type: "email"
17
23
  with_error:
18
24
  data:
19
25
  label:
20
- text: "What is your email address?"
21
- name: "address"
22
- error_message: "Email address not recognised"
26
+ text: "What is your name?"
27
+ name: "name"
28
+ error_message: "Please could you provide your name"
@@ -70,6 +70,29 @@ examples:
70
70
  ]
71
71
  }
72
72
  ]
73
+ with_unique_tracking:
74
+ description: |
75
+ We need to uniquely identify each step by step navigation in Google Analytics. If this parameter is added to the component, its value is included in any tracking events, specifically in dimension96.
76
+
77
+ This includes show/hide all, show/hide step and any link clicks.
78
+ data:
79
+ tracking_id: 'this-is-the-tracking-id'
80
+ steps: [
81
+ {
82
+ title: 'Unique tracking id',
83
+ contents: [
84
+ {
85
+ type: 'list',
86
+ contents: [
87
+ {
88
+ href: '#',
89
+ text: 'This is a link'
90
+ }
91
+ ]
92
+ }
93
+ ]
94
+ }
95
+ ]
73
96
  with_a_different_heading_level:
74
97
  description: Steps have a H2 by default, but this can be changed. The heading level does not change any styling.
75
98
  data:
@@ -18,6 +18,12 @@ examples:
18
18
  data:
19
19
  title: 'Having children: step by step'
20
20
  path: /childcare-parenting/pregnancy-and-birth
21
+ with_unique_tracking:
22
+ description: We need to uniquely identify each step by step navigation in Google Analytics. If this parameter is added to the component, its value is included in any tracking events, specifically in dimension96.
23
+ data:
24
+ title: 'With a tracking id'
25
+ path: '#'
26
+ tracking_id: 'this-is-the-tracking-id'
21
27
  with_a_skip_link:
22
28
  description: This option allows the insertion of a skip link to a step by step navigation elsewhere on the page. This aids navigation when using a keyboard or screen reader. The skip link is visually hidden until it receives focus.
23
29
  data:
@@ -52,3 +52,13 @@ examples:
52
52
  text: 'Learn to drive a motorbike: step by step'
53
53
  }
54
54
  ]
55
+ with_unique_tracking:
56
+ description: We need to uniquely identify each step by step navigation in Google Analytics. If this parameter is added to the component, its value is included in any tracking events, specifically in dimension96.
57
+ data:
58
+ tracking_id: 'this-is-the-tracking-id'
59
+ links: [
60
+ {
61
+ href: '#',
62
+ text: 'With a tracking id'
63
+ }
64
+ ]
@@ -11,8 +11,10 @@
11
11
  <%= yield :title %><% if content_for(:title) %> - <% end %><%= GovukPublishingComponents::Config.component_guide_title %>
12
12
  </title>
13
13
  <%= stylesheet_link_tag "govuk_publishing_components/component_guide", media: "screen" %>
14
- <%= stylesheet_link_tag "govuk_publishing_components/component_guide_print", media: "print" %>
15
14
  <%= stylesheet_link_tag "#{GovukPublishingComponents::Config.application_stylesheet}" %>
15
+ <% if GovukPublishingComponents::Config.application_print_stylesheet %>
16
+ <%= stylesheet_link_tag "#{GovukPublishingComponents::Config.application_print_stylesheet}", media: "print" %>
17
+ <% end %>
16
18
  <%= javascript_include_tag "govuk_publishing_components/application" %>
17
19
  <%= javascript_include_tag "#{GovukPublishingComponents::Config.application_javascript}" %>
18
20
  <%= csrf_meta_tags %>
@@ -1 +1 @@
1
- Rails.application.config.assets.precompile += %w(govuk_publishing_components/component_guide.css govuk_publishing_components/component_guide_print.css)
1
+ Rails.application.config.assets.precompile += %w(govuk_publishing_components/component_guide.css)
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = '5.0.0'.freeze
2
+ VERSION = '5.1.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: 5.0.0
4
+ version: 5.1.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: 2018-02-07 00:00:00.000000000 Z
11
+ date: 2018-02-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -241,7 +241,6 @@ executables: []
241
241
  extensions: []
242
242
  extra_rdoc_files: []
243
243
  files:
244
- - DEVELOPMENT.md
245
244
  - LICENCE.md
246
245
  - README.md
247
246
  - Rakefile
@@ -250,6 +249,7 @@ files:
250
249
  - app/assets/javascripts/govuk_publishing_components/accessibility-test.js
251
250
  - app/assets/javascripts/govuk_publishing_components/application.js
252
251
  - app/assets/javascripts/govuk_publishing_components/components/error-summary.js
252
+ - app/assets/javascripts/govuk_publishing_components/components/feedback.js
253
253
  - app/assets/javascripts/govuk_publishing_components/components/step-by-step-nav.js
254
254
  - app/assets/javascripts/govuk_publishing_components/vendor/axe.min.js
255
255
  - app/assets/javascripts/govuk_publishing_components/vendor/matches-polyfill.min.js
@@ -258,9 +258,9 @@ files:
258
258
  - app/assets/stylesheets/govuk_publishing_components/_all_components.scss
259
259
  - app/assets/stylesheets/govuk_publishing_components/_all_components_print.scss
260
260
  - app/assets/stylesheets/govuk_publishing_components/component_guide.scss
261
- - app/assets/stylesheets/govuk_publishing_components/component_guide_print.scss
262
261
  - app/assets/stylesheets/govuk_publishing_components/components/_back-link.scss
263
262
  - app/assets/stylesheets/govuk_publishing_components/components/_error-summary.scss
263
+ - app/assets/stylesheets/govuk_publishing_components/components/_feedback.scss
264
264
  - app/assets/stylesheets/govuk_publishing_components/components/_fieldset.scss
265
265
  - app/assets/stylesheets/govuk_publishing_components/components/_input.scss
266
266
  - app/assets/stylesheets/govuk_publishing_components/components/_label.scss
@@ -271,6 +271,7 @@ files:
271
271
  - app/assets/stylesheets/govuk_publishing_components/components/helpers/_clearfix.scss
272
272
  - app/assets/stylesheets/govuk_publishing_components/components/helpers/_px-to-em.scss
273
273
  - app/assets/stylesheets/govuk_publishing_components/components/helpers/_variables.scss
274
+ - app/assets/stylesheets/govuk_publishing_components/components/print/_feedback.scss
274
275
  - app/assets/stylesheets/govuk_publishing_components/components/print/_step-by-step-nav-header.scss
275
276
  - app/assets/stylesheets/govuk_publishing_components/components/print/_step-by-step-nav.scss
276
277
  - app/controllers/govuk_publishing_components/application_controller.rb
@@ -289,6 +290,7 @@ files:
289
290
  - app/views/govuk_publishing_components/component_guide/show.html.erb
290
291
  - app/views/govuk_publishing_components/components/_back_link.html.erb
291
292
  - app/views/govuk_publishing_components/components/_error_summary.html.erb
293
+ - app/views/govuk_publishing_components/components/_feedback.html.erb
292
294
  - app/views/govuk_publishing_components/components/_fieldset.html.erb
293
295
  - app/views/govuk_publishing_components/components/_input.html.erb
294
296
  - app/views/govuk_publishing_components/components/_label.html.erb
@@ -298,6 +300,7 @@ files:
298
300
  - app/views/govuk_publishing_components/components/_step_by_step_nav_related.html.erb
299
301
  - app/views/govuk_publishing_components/components/docs/back_link.yml
300
302
  - app/views/govuk_publishing_components/components/docs/error_summary.yml
303
+ - app/views/govuk_publishing_components/components/docs/feedback.yml
301
304
  - app/views/govuk_publishing_components/components/docs/fieldset.yml
302
305
  - app/views/govuk_publishing_components/components/docs/input.yml
303
306
  - app/views/govuk_publishing_components/components/docs/label.yml
@@ -1,15 +0,0 @@
1
- ### Running tests
2
-
3
- The default rake task runs all tests:
4
- ```
5
- bundle exec rake
6
- ```
7
-
8
- Javascript is tested using Jasmine and the [Jasmine gem](https://github.com/pivotal/jasmine-gem). Tests can be run either in the browser or on the command line via the dummy app’s tasks:
9
- ```sh
10
- # browser
11
- bundle exec rake app:jasmine
12
-
13
- # command line
14
- bundle exec rake app:jasmine:ci
15
- ```
@@ -1,3 +0,0 @@
1
- @import "typography";
2
- @import "components/print/step-by-step-nav";
3
- @import "components/print/step-by-step-nav-header";