govuk_publishing_components 21.56.0 → 21.58.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +6 -1
  3. data/app/assets/javascripts/govuk_publishing_components/components/details.js +2 -2
  4. data/app/assets/javascripts/govuk_publishing_components/components/print-link.js +14 -0
  5. data/app/assets/stylesheets/govuk_publishing_components/_all_components.scss +1 -0
  6. data/app/assets/stylesheets/govuk_publishing_components/components/_action-link.scss +11 -5
  7. data/app/assets/stylesheets/govuk_publishing_components/components/_cookie-banner.scss +4 -0
  8. data/app/assets/stylesheets/govuk_publishing_components/components/_input.scss +9 -5
  9. data/app/assets/stylesheets/govuk_publishing_components/components/_list.scss +1 -0
  10. data/app/assets/stylesheets/govuk_publishing_components/components/_print-link.scss +52 -0
  11. data/app/assets/stylesheets/govuk_publishing_components/components/_search.scss +7 -2
  12. data/app/assets/stylesheets/govuk_publishing_components/components/print/_govspeak.scss +5 -1
  13. data/app/controllers/govuk_publishing_components/component_guide_controller.rb +1 -0
  14. data/app/views/govuk_publishing_components/component_guide/index.html.erb +5 -6
  15. data/app/views/govuk_publishing_components/components/_action_link.html.erb +2 -0
  16. data/app/views/govuk_publishing_components/components/_contextual_breadcrumbs.html.erb +11 -7
  17. data/app/views/govuk_publishing_components/components/_cookie_banner.html.erb +3 -1
  18. data/app/views/govuk_publishing_components/components/_input.html.erb +3 -4
  19. data/app/views/govuk_publishing_components/components/_list.html.erb +26 -0
  20. data/app/views/govuk_publishing_components/components/_print_link.html.erb +27 -0
  21. data/app/views/govuk_publishing_components/components/docs/action_link.yml +5 -0
  22. data/app/views/govuk_publishing_components/components/docs/input.yml +9 -1
  23. data/app/views/govuk_publishing_components/components/docs/list.yml +64 -0
  24. data/app/views/govuk_publishing_components/components/docs/print_link.yml +24 -0
  25. data/config/locales/en.yml +2 -0
  26. data/lib/govuk_publishing_components.rb +2 -1
  27. data/lib/govuk_publishing_components/presenters/breadcrumb_selector.rb +50 -42
  28. data/lib/govuk_publishing_components/presenters/content_breadcrumbs_based_on_ancestors.rb +41 -0
  29. data/lib/govuk_publishing_components/presenters/content_breadcrumbs_based_on_priority.rb +1 -0
  30. data/lib/govuk_publishing_components/presenters/content_breadcrumbs_based_on_taxons.rb +4 -0
  31. data/lib/govuk_publishing_components/presenters/content_breadcrumbs_based_on_topic.rb +38 -0
  32. data/lib/govuk_publishing_components/presenters/contextual_navigation.rb +15 -4
  33. data/lib/govuk_publishing_components/presenters/page_with_step_by_step_navigation.rb +3 -1
  34. data/lib/govuk_publishing_components/presenters/related_navigation_helper.rb +18 -17
  35. data/lib/govuk_publishing_components/version.rb +1 -1
  36. data/node_modules/axe-core/CHANGELOG.md +11 -0
  37. data/node_modules/axe-core/axe.js +36 -9
  38. data/node_modules/axe-core/axe.min.js +2 -2
  39. data/node_modules/axe-core/bower.json +1 -1
  40. data/node_modules/axe-core/lib/checks/color/color-contrast.js +2 -2
  41. data/node_modules/axe-core/lib/checks/lists/listitem.js +1 -1
  42. data/node_modules/axe-core/lib/checks/mobile/meta-viewport-scale.js +3 -0
  43. data/node_modules/axe-core/lib/commons/dom/is-visible.js +37 -19
  44. data/node_modules/axe-core/lib/core/public/configure.js +26 -0
  45. data/node_modules/axe-core/lib/rules/aria-input-field-name.json +1 -1
  46. data/node_modules/axe-core/package.json +12 -12
  47. data/node_modules/axe-core/sri-history.json +4 -0
  48. metadata +25 -3
  49. data/lib/govuk_publishing_components/presenters/content_breadcrumbs_based_on_parent.rb +0 -39
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3773fbe78d9426cfe8fc0d8356057ac637399673ed546c07eb436a3500e4728a
4
- data.tar.gz: dafffb370895b4a7d26cba3e3ebe5b0345d178f3e32e3c3a1e3c1f4370ce71a7
3
+ metadata.gz: e165b9cdf4f92f02644b2e82c82c8c6b116379b86d5d4508437dc8ccfd25bd81
4
+ data.tar.gz: 2be44d5b0942debce73048f3bec3786cc9398ae37de322016b253ccfe220442a
5
5
  SHA512:
6
- metadata.gz: 25c2b1ec246ffc2315f37dd9cc929f42404ed1c338e5e80f927ae045785f501af00537463ca6d91e6559dab5f265bf2d482eaed337412c47bf361a7f213fe3db
7
- data.tar.gz: 462df79e0ff9bf3dad96caf7d10f594ae6049c96b145b0c7f8788fedc75995f9f71689ca93d7bbb2eefd4f78e7f00aebf7cff77f60fe19b0a350c0ccbddede07
6
+ metadata.gz: 9a3a06af1b35ecdc351c4d1da7b65ac95bd601a9b2f6f0049e17a84b15768872e478b44c170d2e9579992fd0ca092d60c4c91c049ed2edf48c0e0a1e9f9e7b44
7
+ data.tar.gz: 457fceebbb07d07f8afa3c0ab11c7057659a7df2e6d7a409a472ecfdb5a821147cd6918c4568ded4a063a9c53ef5a9764543c0de507085f62b33f1f0aca91df1
data/Rakefile CHANGED
@@ -29,4 +29,9 @@ namespace :assets do
29
29
  end
30
30
  end
31
31
 
32
- task default: [:spec, "app:jasmine:ci"]
32
+ desc "Run RuboCop linting"
33
+ task lint: :environment do
34
+ sh "bundle exec rubocop --format clang"
35
+ end
36
+
37
+ task default: [:lint, :spec, "app:jasmine:ci"]
@@ -20,7 +20,7 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
20
20
  var detailsClick = detailsComponent.querySelector('[data-details-track-click]')
21
21
  var that = this
22
22
 
23
- $(detailsClick).click(function (e) {
23
+ detailsClick.addEventListener('click', function (event) {
24
24
  that.trackDefault(detailsComponent)
25
25
  })
26
26
  }
@@ -37,7 +37,7 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
37
37
  trackOptions = {}
38
38
  }
39
39
 
40
- trackOptions['label'] = componentStatus
40
+ trackOptions.label = componentStatus
41
41
 
42
42
  if (trackAction && trackCategory) {
43
43
  window.GOVUK.analytics.trackEvent(trackCategory, trackAction, trackOptions)
@@ -0,0 +1,14 @@
1
+ window.GOVUK = window.GOVUK || {}
2
+ window.GOVUK.Modules = window.GOVUK.Modules || {};
3
+
4
+ (function (Modules) {
5
+ 'use strict'
6
+
7
+ Modules.PrintLink = function () {
8
+ this.start = function (element) {
9
+ element[0].addEventListener('click', function () {
10
+ window.print()
11
+ })
12
+ }
13
+ }
14
+ })(window.GOVUK.Modules)
@@ -53,6 +53,7 @@
53
53
  @import "components/panel";
54
54
  @import "components/phase-banner";
55
55
  @import "components/previous-and-next-navigation";
56
+ @import "components/print-link";
56
57
  @import "components/radio";
57
58
  @import "components/related-navigation";
58
59
  @import "components/search";
@@ -118,6 +118,16 @@
118
118
  }
119
119
 
120
120
  .gem-c-action-link--dark-icon {
121
+ &:before {
122
+ // sass-lint:disable no-duplicate-properties
123
+ background: image-url("govuk_publishing_components/action-link-arrow--dark.png");
124
+ background: image-url("govuk_publishing_components/action-link-arrow--dark.svg"), linear-gradient(transparent, transparent);
125
+ // sass-lint:enable no-duplicate-properties
126
+ }
127
+ }
128
+
129
+ .gem-c-action-link--dark-icon,
130
+ .gem-c-action-link--small-icon {
121
131
  max-width: none;
122
132
 
123
133
  @include govuk-media-query($until: tablet) {
@@ -125,12 +135,8 @@
125
135
  }
126
136
 
127
137
  &:before {
128
- width: 30px;
129
138
  height: 30px;
130
- // sass-lint:disable no-duplicate-properties
131
- background: image-url("govuk_publishing_components/action-link-arrow--dark.png");
132
- background: image-url("govuk_publishing_components/action-link-arrow--dark.svg"), linear-gradient(transparent, transparent);
133
- // sass-lint:enable no-duplicate-properties
139
+ width: 35px;
134
140
  background-repeat: no-repeat;
135
141
  background-size: 25px auto;
136
142
  background-position: 0 2px;
@@ -12,6 +12,10 @@ $govuk-cookie-banner-background: govuk-colour("light-grey", "grey-4");
12
12
  background-color: $govuk-cookie-banner-background;
13
13
  }
14
14
 
15
+ .gem-c-cookie-banner--services {
16
+ display: none;
17
+ }
18
+
15
19
  .gem-c-cookie-banner__message {
16
20
  display: inline-block;
17
21
  padding-bottom: govuk-spacing(2);
@@ -10,6 +10,7 @@
10
10
  // TODO: remove these styles once static is made less aggressive
11
11
  .gem-c-input.govuk-input {
12
12
  margin: 0;
13
+ min-width: 0;
13
14
  padding: govuk-spacing(1);
14
15
 
15
16
  &.gem-c-input--search-icon {
@@ -40,16 +41,19 @@
40
41
  box-sizing: border-box;
41
42
  cursor: default; // emphasise non-editable status of prefixes and suffixes
42
43
  display: inline-block;
43
- white-space: nowrap;
44
- width: auto;
45
- text-align: center;
44
+ flex: 0 0 auto;
46
45
  height: 40px;
47
- padding: govuk-spacing(1);
46
+ margin-top: 0;
48
47
  min-width: 40px;
48
+ padding: govuk-spacing(1);
49
+ text-align: center;
50
+ white-space: nowrap;
51
+ width: auto;
52
+
49
53
  @if $govuk-typography-use-rem {
54
+ height: govuk-px-to-rem(40px);
50
55
  min-width: govuk-px-to-rem(40px);
51
56
  }
52
- margin-top: 0;
53
57
  }
54
58
 
55
59
  .gem-c-input__prefix {
@@ -0,0 +1 @@
1
+ @import "govuk/components/list/list";
@@ -0,0 +1,52 @@
1
+ .gem-c-print-link {
2
+ display: none;
3
+ margin-bottom: 2em;
4
+ margin-top: 2em;
5
+ }
6
+
7
+ .gem-c-print-link.gem-c-print-link--show-without-js {
8
+ display: block;
9
+ }
10
+
11
+ .js-enabled {
12
+ .gem-c-print-link {
13
+ display: block;
14
+ }
15
+ }
16
+
17
+ .gem-c-print-link__link {
18
+ background: image-url("govuk_publishing_components/icon-print.png") no-repeat 10px 50%;
19
+
20
+ margin-left: -10px;
21
+ padding: .5em .5em .5em 38px;
22
+
23
+ @include govuk-device-pixel-ratio($ratio: 2) {
24
+ background-image: image-url("govuk_publishing_components/icon-print-2x.png");
25
+ background-size: 16px 18px;
26
+ }
27
+
28
+ &:focus {
29
+ @include govuk-focused-text;
30
+ }
31
+ }
32
+
33
+ .gem-c-print-link__button {
34
+ @extend %govuk-body-s;
35
+ background: image-url("govuk_publishing_components/icon-print.png") no-repeat 10px 50%;
36
+ border: 0;
37
+ color: $govuk-link-colour;
38
+ cursor: pointer;
39
+ margin: 0;
40
+ margin-left: -10px;
41
+ padding: .5em .5em .5em 38px;
42
+ text-decoration: underline;
43
+
44
+ @include govuk-device-pixel-ratio($ratio: 2) {
45
+ background-image: image-url("govuk_publishing_components/icon-print-2x.png");
46
+ background-size: 16px 18px;
47
+ }
48
+
49
+ &:focus {
50
+ @include govuk-focused-text;
51
+ }
52
+ }
@@ -9,6 +9,7 @@ $large-input-size: 50px;
9
9
  .gem-c-search__label {
10
10
  @include govuk-font($size: 19, $line-height: $input-size);
11
11
  display: block;
12
+ background: govuk-colour("white");
12
13
 
13
14
  h1 {
14
15
  @include govuk-font($size: 19, $line-height: $input-size);
@@ -17,8 +18,10 @@ $large-input-size: 50px;
17
18
 
18
19
  .js-enabled & {
19
20
  position: absolute;
20
- left: govuk-spacing(3);
21
- top: 1px;
21
+ left: 2px;
22
+ top: 2px;
23
+ bottom: 2px;
24
+ padding-left: govuk-spacing(3);
22
25
  z-index: 1;
23
26
  color: $govuk-secondary-text-colour;
24
27
  }
@@ -201,6 +204,8 @@ $large-input-size: 50px;
201
204
  .gem-c-search--separate-label {
202
205
  .gem-c-search__label {
203
206
  position: relative;
207
+ top: auto;
204
208
  left: auto;
209
+ padding-left: 0;
205
210
  }
206
211
  }
@@ -7,8 +7,12 @@
7
7
  .help-notice,
8
8
  .call-to-action {
9
9
  margin: govuk-spacing(3) 0;
10
- padding: 0 govuk-spacing(3);
10
+ }
11
+
12
+ .call-to-action {
13
+ background: none;
11
14
  border: 1pt solid $govuk-border-colour;
15
+ padding: govuk-spacing(3);
12
16
  }
13
17
 
14
18
  .help-notice p {
@@ -85,6 +85,7 @@ module GovukPublishingComponents
85
85
 
86
86
  files = Dir["#{@application_path}/app/views/**/*.html.erb"]
87
87
  files.concat Dir["#{@application_path}/app/**/*.rb"]
88
+ files.concat Dir["#{@application_path}/lib/**/*.rb"]
88
89
 
89
90
  files.each do |file|
90
91
  data = File.read(file)
@@ -2,12 +2,7 @@
2
2
 
3
3
  <div class="component-markdown">
4
4
  <p>Components are packages of template, style, behaviour and documentation that live in your application.</p>
5
- <p>A component must:</p>
6
- <ul>
7
- <li><a href="https://github.com/alphagov/govuk_publishing_components/blob/master/docs/component_principles.md">meet the component principles</a></li>
8
- <li><a href="https://github.com/alphagov/govuk_publishing_components/blob/master/docs/component_conventions.md">follow component conventions</a></li>
9
- </ul>
10
- <p>See the <a href="https://github.com/alphagov/govuk_publishing_components">govuk_publishing_components gem</a> for further details, or <a href="https://docs.publishing.service.gov.uk/manual/components.html#component-guides">a list of all component guides</a>.</p>
5
+ <p>See the <a href="https://github.com/alphagov/govuk_publishing_components">govuk_publishing_components gem</a> for further details, or <a href="https://docs.publishing.service.gov.uk/manual/components.html#component-guides">a list of all component guides</a>. Read about how to <a href="https://github.com/alphagov/govuk_publishing_components/blob/master/docs/publishing-to-rubygems.md">release a new version of the gem</a>.</p>
11
6
  </div>
12
7
 
13
8
  <form role="search" data-module="filter-components" class="component-search">
@@ -86,3 +81,7 @@
86
81
  </li>
87
82
  <% end %>
88
83
  </ul>
84
+
85
+ <div class="component-markdown">
86
+ <p class="govuk-body">If you cannot find a suitable component consider extending an existing component or <a href="https://github.com/alphagov/govuk_publishing_components/blob/master/docs/develop-component.md">creating a new one</a>.</p>
87
+ </div>
@@ -11,6 +11,7 @@
11
11
  light_text ||= false
12
12
  simple ||= false
13
13
  dark_icon ||= false
14
+ small_icon ||= false
14
15
  nhs_icon ||= false
15
16
  data ||= nil
16
17
  classes ||= nil
@@ -18,6 +19,7 @@
18
19
  css_classes = %w(gem-c-action-link)
19
20
  css_classes << "gem-c-action-link--light-text" if light_text
20
21
  css_classes << "gem-c-action-link--dark-icon" if dark_icon
22
+ css_classes << "gem-c-action-link--small-icon" if small_icon
21
23
  css_classes << "gem-c-action-link--nhs" if nhs_icon
22
24
  css_classes << "gem-c-action-link--simple" if simple
23
25
  css_classes << "gem-c-action-link--with-subtext" if subtext
@@ -1,16 +1,20 @@
1
1
  <% prioritise_taxon_breadcrumbs ||= false %>
2
- <% breadcrumb_selector = GovukPublishingComponents::Presenters::BreadcrumbSelector.call(content_item, request, prioritise_taxon_breadcrumbs) %>
2
+ <% breadcrumb_selector = GovukPublishingComponents::Presenters::BreadcrumbSelector.new(content_item, request, prioritise_taxon_breadcrumbs) %>
3
3
  <% inverse ||= false %>
4
4
  <% collapse_on_mobile ||= true unless local_assigns[:collapse_on_mobile].eql?(false) %>
5
5
 
6
- <div class='gem-c-contextual-breadcrumbs'>
7
- <% if breadcrumb_selector[:step_by_step] %>
8
- <%= render 'govuk_publishing_components/components/step_by_step_nav_header',
9
- breadcrumb_selector[:breadcrumbs] %>
10
- <% elsif breadcrumb_selector[:breadcrumbs] %>
6
+ <div class="gem-c-contextual-breadcrumbs">
7
+ <% if breadcrumb_selector.step_by_step %>
8
+ <%= render 'govuk_publishing_components/components/step_by_step_nav_header', breadcrumb_selector.breadcrumbs %>
9
+ <% elsif breadcrumb_selector.breadcrumbs %>
11
10
  <%= render 'govuk_publishing_components/components/breadcrumbs',
12
- breadcrumbs: breadcrumb_selector[:breadcrumbs],
11
+ breadcrumbs: breadcrumb_selector.breadcrumbs,
13
12
  inverse: inverse,
14
13
  collapse_on_mobile: collapse_on_mobile %>
15
14
  <% end %>
15
+
16
+ <%= render(
17
+ 'govuk_publishing_components/components/step_by_step_nav_header', breadcrumb_selector.priority_breadcrumbs
18
+ ) if breadcrumb_selector.priority_breadcrumbs
19
+ %>
16
20
  </div>
@@ -5,9 +5,11 @@
5
5
  cookie_preferences_href ||= "/help/cookies"
6
6
  confirmation_message ||= raw("You’ve accepted all cookies. You can <a class='govuk-link' href='#{cookie_preferences_href}' data-module='track-click' data-track-category='cookieBanner' data-track-action='Cookie banner settings clicked from confirmation'>change your cookie settings</a> at any time.")
7
7
  services_cookies ||= nil
8
+ css_classes = %w(gem-c-cookie-banner govuk-clearfix)
9
+ css_classes << "gem-c-cookie-banner--services" if services_cookies
8
10
  %>
9
11
 
10
- <div id="<%= id %>" class="gem-c-cookie-banner govuk-clearfix" data-module="cookie-banner" role="region" aria-label="cookie banner" data-nosnippet>
12
+ <div id="<%= id %>" class="<%= css_classes.join(' ') %>" data-module="cookie-banner" role="region" aria-label="cookie banner" data-nosnippet>
11
13
  <div class="gem-c-cookie-banner__wrapper govuk-width-container">
12
14
  <div class="govuk-grid-row">
13
15
  <div class="govuk-grid-column-two-thirds">
@@ -95,15 +95,14 @@
95
95
 
96
96
  <% if prefix && suffix %>
97
97
  <%= tag.div class: "gem-c-input__wrapper" do %>
98
- <%= tag.span prefix, class: "gem-c-input__prefix", aria: { hidden: true } %>
99
- <%= input_tag %>
100
- <%= tag.span suffix, class: "gem-c-input__suffix", aria: { hidden: true } %>
98
+ <% # The line below relies on in-line styling for legacy browsers and it's whitespace-sensitive %>
99
+ <%= tag.span prefix, class: "gem-c-input__prefix", aria: { hidden: true } %><%= input_tag %><%= tag.span suffix, class: "gem-c-input__suffix", aria: { hidden: true } %>
101
100
  <% end %>
102
101
  <% elsif prefix %>
103
102
  <%= tag.div class: "gem-c-input__wrapper" do %>
104
103
  <%= tag.span prefix, class: "gem-c-input__prefix", aria: { hidden: true } %><%= input_tag %>
105
104
  <% end %>
106
- <% elsif suffix %>
105
+ <% elsif suffix %>
107
106
  <%= tag.div class: "gem-c-input__wrapper" do %>
108
107
  <%= input_tag %><%= tag.span suffix, class: "gem-c-input__suffix", aria: { hidden: true } %>
109
108
  <% end %>
@@ -0,0 +1,26 @@
1
+ <%
2
+ id ||= nil
3
+ extra_spacing ||= nil
4
+ list_type ||= "unordered"
5
+ visible_counters ||= nil
6
+ items ||= []
7
+ aria_label ||= nil
8
+
9
+ classes = %w(gem-c-list govuk-list)
10
+ classes << "govuk-list--bullet" if visible_counters && list_type === "unordered"
11
+ classes << "govuk-list--number" if visible_counters && list_type === "number"
12
+ classes << "govuk-list--spaced" if extra_spacing
13
+
14
+ # Default list type is unordered list.
15
+ list_tag = "ul"
16
+
17
+ # Set to ordered list to override default.
18
+ list_tag = "ol" if list_type === "number"
19
+ %>
20
+ <% if items.any? %>
21
+ <%= content_tag list_tag, class: classes, id: id, "aria-label": aria_label do %>
22
+ <% items.each do |item| %>
23
+ <li><%= sanitize(item) %></li>
24
+ <% end %>
25
+ <% end %>
26
+ <% end %>
@@ -0,0 +1,27 @@
1
+ <%
2
+ text ||= t('components.print_link.text')
3
+ href ||= nil
4
+ data_attributes ||= {}
5
+
6
+ require_js ||= href.nil?
7
+ data_attributes[:module] = 'print-link' if require_js
8
+ %>
9
+
10
+ <% if require_js %>
11
+ <div class="gem-c-print-link" >
12
+ <%= content_tag(:button, text, {
13
+ class: %w(gem-c-print-link__button govuk-link),
14
+ data: data_attributes
15
+ }) %>
16
+ </div>
17
+ <% else %>
18
+ <div class="gem-c-print-link gem-c-print-link--show-without-js">
19
+ <%= link_to(
20
+ text,
21
+ href,
22
+ class: %w(gem-c-print-link__link govuk-link),
23
+ rel: "alternate",
24
+ data: data_attributes
25
+ ) %>
26
+ </div>
27
+ <% end %>
@@ -75,6 +75,11 @@ examples:
75
75
  text: Getting financial help and keeping your business safe
76
76
  href: "/financial-help"
77
77
  simple: true
78
+ with_small_icon:
79
+ data:
80
+ text: Coronavirus (COVID-19)
81
+ href: "/my-test-page"
82
+ small_icon: true
78
83
  with_dark_icon:
79
84
  data:
80
85
  text: Coronavirus (COVID-19)
@@ -132,6 +132,14 @@ examples:
132
132
  text: "What is your name?"
133
133
  name: "name"
134
134
  heading_size: "l"
135
+ with_prefix:
136
+ description: To help users understand how the input should look like. Often used for units of measurement.
137
+ data:
138
+ label:
139
+ text: "Cost, in pounds"
140
+ name: "cost"
141
+ width: 10
142
+ prefix: "£"
135
143
  with_suffix:
136
144
  description: To help users understand how the input should look like. Often used for units of measurement.
137
145
  data:
@@ -145,7 +153,7 @@ examples:
145
153
  data:
146
154
  label:
147
155
  text: "Cost per item, in pounds"
148
- name: "Cost-per-item"
156
+ name: "cost-per-item"
149
157
  width: 10
150
158
  prefix: "£"
151
159
  suffix: "per item"