govuk_publishing_components 21.55.3 → 21.57.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/govuk_publishing_components/components/print-link.js +14 -0
  3. data/app/assets/stylesheets/govuk_publishing_components/_all_components.scss +1 -0
  4. data/app/assets/stylesheets/govuk_publishing_components/component_support.scss +1 -0
  5. data/app/assets/stylesheets/govuk_publishing_components/components/_action-link.scss +11 -5
  6. data/app/assets/stylesheets/govuk_publishing_components/components/_cookie-banner.scss +4 -0
  7. data/app/assets/stylesheets/govuk_publishing_components/components/_feedback.scss +1 -4
  8. data/app/assets/stylesheets/govuk_publishing_components/components/_input.scss +9 -5
  9. data/app/assets/stylesheets/govuk_publishing_components/components/_print-link.scss +52 -0
  10. data/app/assets/stylesheets/govuk_publishing_components/components/_summary-list.scss +18 -5
  11. data/app/assets/stylesheets/govuk_publishing_components/components/helpers/_link.scss +17 -0
  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 +26 -16
  14. data/app/views/govuk_publishing_components/components/_action_link.html.erb +2 -0
  15. data/app/views/govuk_publishing_components/components/_contextual_breadcrumbs.html.erb +11 -7
  16. data/app/views/govuk_publishing_components/components/_cookie_banner.html.erb +3 -1
  17. data/app/views/govuk_publishing_components/components/_input.html.erb +3 -4
  18. data/app/views/govuk_publishing_components/components/_print_link.html.erb +27 -0
  19. data/app/views/govuk_publishing_components/components/_summary_list.html.erb +34 -14
  20. data/app/views/govuk_publishing_components/components/docs/action_link.yml +5 -0
  21. data/app/views/govuk_publishing_components/components/docs/input.yml +9 -1
  22. data/app/views/govuk_publishing_components/components/docs/print_link.yml +24 -0
  23. data/app/views/govuk_publishing_components/components/docs/summary_list.yml +27 -0
  24. data/config/locales/en.yml +5 -0
  25. data/lib/govuk_publishing_components.rb +2 -1
  26. data/lib/govuk_publishing_components/presenters/breadcrumb_selector.rb +50 -42
  27. data/lib/govuk_publishing_components/presenters/content_breadcrumbs_based_on_ancestors.rb +41 -0
  28. data/lib/govuk_publishing_components/presenters/content_breadcrumbs_based_on_priority.rb +1 -0
  29. data/lib/govuk_publishing_components/presenters/content_breadcrumbs_based_on_taxons.rb +4 -0
  30. data/lib/govuk_publishing_components/presenters/content_breadcrumbs_based_on_topic.rb +38 -0
  31. data/lib/govuk_publishing_components/presenters/contextual_navigation.rb +15 -4
  32. data/lib/govuk_publishing_components/presenters/page_with_step_by_step_navigation.rb +3 -1
  33. data/lib/govuk_publishing_components/presenters/related_navigation_helper.rb +18 -17
  34. data/lib/govuk_publishing_components/version.rb +1 -1
  35. data/node_modules/axe-core/CHANGELOG.md +11 -0
  36. data/node_modules/axe-core/axe.js +36 -9
  37. data/node_modules/axe-core/axe.min.js +2 -2
  38. data/node_modules/axe-core/bower.json +1 -1
  39. data/node_modules/axe-core/lib/checks/color/color-contrast.js +2 -2
  40. data/node_modules/axe-core/lib/checks/lists/listitem.js +1 -1
  41. data/node_modules/axe-core/lib/checks/mobile/meta-viewport-scale.js +3 -0
  42. data/node_modules/axe-core/lib/commons/dom/is-visible.js +37 -19
  43. data/node_modules/axe-core/lib/core/public/configure.js +26 -0
  44. data/node_modules/axe-core/lib/rules/aria-input-field-name.json +1 -1
  45. data/node_modules/axe-core/package.json +12 -12
  46. data/node_modules/axe-core/sri-history.json +4 -0
  47. metadata +9 -3
  48. 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: 417ac5b68c2937c585f441854215684db548772993c21ca5fcd4cda7a34fdf0f
4
- data.tar.gz: 206dc5df8e79d3d92c3a0bcc8e2823a41d6f61b5bfd1ecf6df1ce5dd01cd7004
3
+ metadata.gz: b8a8a82f77b41de6046e22f895906a472e9b90c3e51eb79383a12e5eb3d25c12
4
+ data.tar.gz: df29df24347079ca630904cdd8b41c30a950c42b648f11989952d68f9d0f84db
5
5
  SHA512:
6
- metadata.gz: 05bab4bb91aaf768e8998f8be4c3088600ee4c75e7bf8873d9023421e5e686937118d021efaa939f8bbc2e2020520369099dfcb1bda1c14dd5eb1883ffde045d
7
- data.tar.gz: 266f2889088edc5bf591597d3d6608fe023171e1d8b53895c5cd887b4a845e85e2ed61d690e3f7c85bb0f6e62b05c8648b87639ff3c8f53c5f7702c7c6c1bcc5
6
+ metadata.gz: 76bd5c827d4b33f2abb411af2fc2baf4028e0555bd6b53997accebc7830811fb01871da0218095ac1ec7c1992dc25282ce14088c0075262f5088bd70e5a2d990
7
+ data.tar.gz: 456965f640926944af2eb05a47927c00d612c2eaefd651a3f149bb6f374b1247d1581dce682ede9b6c552c34071dc24ecf54cc73ea9d7c1da96ac81165a22250
@@ -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";
@@ -8,6 +8,7 @@
8
8
 
9
9
  @import "govuk_publishing_components/components/helpers/variables";
10
10
  @import "govuk_publishing_components/components/helpers/brand-colours";
11
+ @import "govuk_publishing_components/components/helpers/link";
11
12
  @import "govuk_publishing_components/components/mixins/govuk-template-link-focus-override";
12
13
  @import "govuk_publishing_components/components/mixins/media-down";
13
14
  @import "govuk_publishing_components/components/mixins/margins";
@@ -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: 30px;
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);
@@ -1,8 +1,6 @@
1
1
  .gem-c-feedback {
2
2
  background: govuk-colour("white");
3
- margin: govuk-spacing(6) auto 0 auto;
4
- max-width: $govuk-page-width;
5
- position: relative;
3
+ margin-top: govuk-spacing(6);
6
4
 
7
5
  @include govuk-media-query($from: tablet) {
8
6
  margin-top: govuk-spacing(9);
@@ -182,7 +180,6 @@
182
180
  }
183
181
 
184
182
  .gem-c-feedback__form {
185
- margin: govuk-spacing(3) govuk-spacing(2) 0 govuk-spacing(2);
186
183
  padding: govuk-spacing(3) 0;
187
184
  border-top: govuk-spacing(2) solid govuk-colour("blue");
188
185
 
@@ -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,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
+ }
@@ -1,7 +1,6 @@
1
1
  @import "govuk/components/summary-list/summary-list";
2
2
 
3
3
  .gem-c-summary-list {
4
- position: relative;
5
4
  border-bottom: 1px solid $govuk-border-colour;
6
5
 
7
6
  @include govuk-font(19);
@@ -14,12 +13,26 @@
14
13
  &:nth-last-of-type(1) {
15
14
  border-bottom: 0;
16
15
  }
16
+
17
+ .govuk-summary-list {
18
+ clear: both;
19
+ }
17
20
  }
18
21
 
19
- .gem-c-summary-list__edit-section-link {
20
- position: absolute;
21
- top: 0;
22
- right: 0;
22
+ .gem-c-summary-list__group-title {
23
+ @include govuk-media-query($from: tablet) {
24
+ display: inline-block;
25
+ margin-right: govuk-spacing(3);
26
+ }
27
+ }
28
+
29
+ .gem-c-summary-list__group-actions-list {
30
+ margin-bottom: govuk-spacing(3);
31
+
32
+ @include govuk-media-query($from: tablet) {
33
+ float: right;
34
+ width: auto;
35
+ }
23
36
  }
24
37
 
25
38
  .gem-c-summary__block {
@@ -0,0 +1,17 @@
1
+ .gem-link--destructive {
2
+ @include govuk-font(19);
3
+
4
+ &:link {
5
+ color: $govuk-error-colour;
6
+ }
7
+
8
+ &:visited,
9
+ &:hover,
10
+ &:active {
11
+ color: darken($govuk-error-colour, 5%);
12
+ }
13
+
14
+ &:focus {
15
+ color: $govuk-focus-text-colour;
16
+ }
17
+ }
@@ -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 {
@@ -2,6 +2,8 @@ module GovukPublishingComponents
2
2
  class ComponentGuideController < GovukPublishingComponents::ApplicationController
3
3
  append_view_path File.join(Rails.root, "app", "views", GovukPublishingComponents::Config.component_directory_name)
4
4
 
5
+ MATCH_COMPONENTS = /(?<=govuk_publishing_components\/components\/)[\/a-zA-Z_-]+(?=['"])/.freeze
6
+
5
7
  def index
6
8
  @application_path = Rails.root
7
9
  @component_gem_path = Gem.loaded_specs["govuk_publishing_components"].full_gem_path
@@ -86,24 +88,30 @@ module GovukPublishingComponents
86
88
 
87
89
  files.each do |file|
88
90
  data = File.read(file)
89
- matches << data.scan(/(govuk_publishing_components\/components\/[a-z_-]+)/)
91
+ matches << data.scan(MATCH_COMPONENTS)
90
92
  end
91
93
 
92
- matches.flatten.uniq.map(&:to_s).sort.map { |m| m.gsub("govuk_publishing_components/components/", "") }
94
+ matches.flatten.uniq.map(&:to_s).sort
93
95
  end
94
96
 
95
- def find_all_partials_in(components)
96
- components_to_search = components
97
- partials_found = true
97
+ def find_all_partials_in(templates)
98
+ components = [templates]
99
+
100
+ templates.each do |template|
101
+ partials_found = true
102
+ components_to_search = [template]
103
+ components_found = []
98
104
 
99
- while partials_found
100
- extra_components = find_partials_in(components_to_search)
105
+ while partials_found
106
+ extra_components = find_partials_in(components_to_search)
101
107
 
102
- if extra_components.any?
103
- components << extra_components
104
- components_to_search = extra_components
105
- else
106
- partials_found = false
108
+ if extra_components.any?
109
+ components_found << extra_components
110
+ components_to_search = extra_components
111
+ else
112
+ partials_found = false
113
+ components << components_found.uniq.sort if components_found.any?
114
+ end
107
115
  end
108
116
  end
109
117
 
@@ -113,8 +121,7 @@ module GovukPublishingComponents
113
121
  def find_partials_in(components)
114
122
  extra_components = []
115
123
  components.each do |component|
116
- components_in_component = components_within_component(component)
117
- extra_components << components_in_component
124
+ extra_components << components_within_component(component)
118
125
  end
119
126
 
120
127
  extra_components.flatten.uniq.sort
@@ -132,9 +139,12 @@ module GovukPublishingComponents
132
139
  def components_within_component(component)
133
140
  filename = @component_gem_path + "/app/views/govuk_publishing_components/components/#{component}.html.erb"
134
141
  filename = filename.sub(/.*\K\//, "/_") # files begin with _ but the method may have been passed 'filename' or 'dir/partial'
142
+
143
+ return [] unless File.file?(filename)
144
+
135
145
  data = File.read(filename)
136
- match = data.scan(/(govuk_publishing_components\/components\/[\/a-z_-]+)/)
137
- match.flatten.uniq.map(&:to_s).sort.map { |m| m.gsub("govuk_publishing_components/components/", "") }
146
+ match = data.scan(MATCH_COMPONENTS)
147
+ match.flatten.uniq.map(&:to_s).sort
138
148
  end
139
149
 
140
150
  def index_breadcrumb
@@ -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,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 %>