govuk_publishing_components 9.17.1 → 9.18.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
  SHA256:
3
- metadata.gz: '0796e351924444317ecadbc052a85faa05ce5a70d56c3bf1b279ff926cd5c0c9'
4
- data.tar.gz: fa07de0760276ae69b0cce55d2b38fb85d304b0afd508921733d1e6bbee789cd
3
+ metadata.gz: 1bc16e5c509fef3c4df8d29124a2223cf2f56d548493deea7578249650bd5e63
4
+ data.tar.gz: f99801097df93fa76824e915dc2fb166cc4169af3d6826ae1b6e6398bed99af8
5
5
  SHA512:
6
- metadata.gz: 20c41f50f46d27d668cf5ed2c476c3b55e2fe3c54507827c36344b683a9ed47efbb3b4ed18910a0636b336dbcf245f6051d2da7ebb38b2af187251e0d4b2003e
7
- data.tar.gz: 4eb742dd6d5e6864afe9d128e81fe103ec062527e41025af4196d80bfe52ba29426241070057502ee92af0869700cd7d303b19f7408052fe4e6d5aaac4e59cfc
6
+ metadata.gz: da9871ca56d90218af756734c900ee93d18095eac44e166695a78d485a042aa031b2c3c3752ccc97778a6a8f248fefaeb935c0e7126da9f2c079a555d2690b37
7
+ data.tar.gz: 103bf20d66caae335fd95d3ef6558f29520bee61c4d9396c3b7c3165ebec0351a871b7ca0a659db17045e36d6ce548f4a0a150c67afa1f5683795946325ab601
@@ -4,7 +4,7 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
4
4
  (function (GOVUK) {
5
5
  'use strict'
6
6
 
7
- GOVUK.Modules.SuccessAlert = function () {
7
+ GOVUK.Modules.InitialFocus = function () {
8
8
  this.start = function (element) {
9
9
  element.focus()
10
10
  }
@@ -29,6 +29,7 @@
29
29
  @import "components/metadata";
30
30
  @import "components/notice";
31
31
  @import "components/organisation-logo";
32
+ @import "components/panel";
32
33
  @import "components/phase-banner";
33
34
  @import "components/previous-and-next-navigation";
34
35
  @import "components/radio";
@@ -40,6 +41,7 @@
40
41
  @import "components/step-by-step-nav";
41
42
  @import "components/subscription-links";
42
43
  @import "components/success-alert";
44
+ @import "components/error-alert";
43
45
  @import "components/tabs";
44
46
  @import "components/taxonomy-navigation";
45
47
  @import "components/taxonomy-list";
@@ -0,0 +1,33 @@
1
+ .gem-c-error-alert {
2
+ color: $gem-text-colour;
3
+ padding: $gem-spacing-scale-3;
4
+ border: $gem-border-width-mobile solid $gem-error-colour;
5
+
6
+ @include media(tablet) {
7
+ padding: $gem-spacing-scale-4;
8
+ border-width: $gem-border-width-tablet;
9
+ }
10
+ }
11
+
12
+ .gem-c-error-alert__message {
13
+ @include bold-19;
14
+ }
15
+
16
+ .gem-c-error-summary__title {
17
+ margin-top: 0;
18
+ margin-bottom: $gem-spacing-scale-3;
19
+
20
+ @include media(tablet) {
21
+ margin-bottom: $gem-spacing-scale-4;
22
+ }
23
+
24
+ @include bold-24;
25
+ }
26
+
27
+ .gem-c-error-summary__body {
28
+ @include core-19;
29
+ }
30
+
31
+ .gem-c-error-alert:focus {
32
+ outline: $gem-focus-width solid $gem-focus-colour;
33
+ }
@@ -0,0 +1,6 @@
1
+ // This component relies on styles from GOV.UK Frontend
2
+
3
+ // Specify the functions used to resolve assets paths in SCSS
4
+ $govuk-font-url-function: "font-url";
5
+
6
+ @import "../../../../node_modules/govuk-frontend/components/panel/panel";
@@ -1,8 +1,8 @@
1
- <% navigation = GovukPublishingComponents::Presenters::ContextualNavigation.new(content_item, request.path) %>
1
+ <% navigation = GovukPublishingComponents::Presenters::ContextualNavigation.new(content_item, request) %>
2
2
  <% prioritise_taxon_breadcrumbs ||= false %>
3
3
 
4
4
  <div class='gem-c-contextual-breadcrumbs'>
5
- <% if navigation.content_tagged_to_single_step_by_step? %>
5
+ <% if navigation.content_tagged_to_current_step_by_step? %>
6
6
  <!-- Rendering step by step nav breadcrumbs because there's 1 step by step -->
7
7
  <%= render 'govuk_publishing_components/components/step_by_step_nav_header',
8
8
  navigation.step_nav_helper.header %>
@@ -1,4 +1,4 @@
1
- <% navigation = GovukPublishingComponents::Presenters::ContextualNavigation.new(content_item, request.path) %>
1
+ <% navigation = GovukPublishingComponents::Presenters::ContextualNavigation.new(content_item, request) %>
2
2
 
3
3
  <div class="gem-c-contextual-sidebar">
4
4
  <% if navigation.content_tagged_to_a_reasonable_number_of_step_by_steps? %>
@@ -6,7 +6,7 @@
6
6
  <%= render 'govuk_publishing_components/components/step_by_step_nav_related', links: navigation.step_nav_helper.related_links %>
7
7
  <% end %>
8
8
 
9
- <% if navigation.content_tagged_to_single_step_by_step? %>
9
+ <% if navigation.content_tagged_to_current_step_by_step? %>
10
10
  <!-- Rendering step by step sidebar because there's 1 step by step list -->
11
11
  <%= render 'govuk_publishing_components/components/step_by_step_nav', navigation.step_nav_helper.sidebar %>
12
12
  <% elsif navigation.content_tagged_to_mainstream_browse_pages? %>
@@ -22,4 +22,12 @@
22
22
  <!-- Rendering related navigation sidebar because no browse, no related links, no live taxons -->
23
23
  <%= render 'govuk_publishing_components/components/related_navigation', content_item %>
24
24
  <% end %>
25
+
26
+ <% if navigation.content_tagged_to_other_step_by_steps? %>
27
+ <!-- Rendering step by step related items because there are a few but not too many of them -->
28
+ <%= render 'govuk_publishing_components/components/step_by_step_nav_related', {
29
+ pretitle: "Also part of",
30
+ links: navigation.step_nav_helper.also_part_of_step_nav
31
+ } %>
32
+ <% end %>
25
33
  </div>
@@ -0,0 +1,10 @@
1
+ <% description ||= nil %>
2
+
3
+ <%= tag.div class: "gem-c-error-alert", data: { module: "initial-focus" }, role: "alert", tabindex: "-1" do %>
4
+ <% if description.present? %>
5
+ <%= tag.h2 message, class: "gem-c-error-summary__title" %>
6
+ <%= tag.p description, class: "gem-c-error-summary__body" %>
7
+ <% else %>
8
+ <%= tag.p message, class: "gem-c-error-alert__message" %>
9
+ <% end %>
10
+ <% end %>
@@ -0,0 +1,13 @@
1
+ <%
2
+ description ||= false
3
+ %>
4
+ <div class="gem-c-panel govuk-panel govuk-panel--confirmation">
5
+ <h2 class="govuk-panel__title">
6
+ <%= title %>
7
+ </h2>
8
+ <div class="govuk-panel__body">
9
+ <% if description %>
10
+ <%= description %>
11
+ <% end %>
12
+ </div>
13
+ </div>
@@ -9,6 +9,7 @@
9
9
  step_nav_url ||= false
10
10
  highlight_step ||= false
11
11
  tracking_id ||= false
12
+ step_nav_content_id ||= tracking_id
12
13
 
13
14
  step_count = 0
14
15
  step_number = 0
@@ -70,6 +71,7 @@
70
71
  <div class="gem-c-step-nav__panel js-panel" id="step-panel-<%= id %>-<%= step_index + 1 %>">
71
72
  <%
72
73
  in_substep = false
74
+ options[:step_nav_content_id] = step_nav_content_id
73
75
  options[:step_index] = step_index
74
76
  options[:link_index] = 0
75
77
  %>
@@ -1,15 +1,10 @@
1
1
  <% description ||= nil %>
2
2
 
3
- <div
4
- class="gem-c-success-alert"
5
- data-module="success-alert"
6
- role="alert"
7
- tabindex="-1"
8
- >
3
+ <%= tag.div class: "gem-c-success-alert", data: { module: "initial-focus" }, role: "alert", tabindex: "-1" do %>
9
4
  <% if description.present? %>
10
- <h2 class="gem-c-success-summary__title"><%= message %></h2>
11
- <p class="gem-c-success-summary__body"><%= description %></p>
5
+ <%= tag.h2 message, class: "gem-c-success-summary__title" %>
6
+ <%= tag.p description, class: "gem-c-success-summary__body" %>
12
7
  <% else %>
13
- <p class="gem-c-success-alert__message"><%= message %></p>
8
+ <%= tag.p message, class: "gem-c-success-alert__message" %>
14
9
  <% end %>
15
- </div>
10
+ <% end %>
@@ -27,10 +27,7 @@
27
27
 
28
28
  <%= content_tag :div, class: form_group_css_classes do %>
29
29
  <% if label %>
30
- <%= render "govuk_publishing_components/components/label", {
31
- text: label[:text],
32
- html_for: id
33
- } %>
30
+ <%= render "govuk_publishing_components/components/label", { html_for: id }.merge(label) %>
34
31
  <% end %>
35
32
 
36
33
  <% if hint %>
@@ -0,0 +1,23 @@
1
+ name: Error Alert
2
+ description: Used at the top of the page, to summarise a unsuccessful user action.
3
+ accessibility_criteria: |
4
+ - should be focused on page load, to ensure the message is noticed by
5
+ assistive tech
6
+ - Should have a role of ‘alert’ to communicate that is a important and
7
+ time sensitive message
8
+ examples:
9
+ default:
10
+ data:
11
+ message: Message to alert the user to a unsuccessful action goes here
12
+ with_message_and_description:
13
+ data:
14
+ message: Message to alert the user to a unsuccessful action goes here
15
+ description: A further description
16
+ long_example:
17
+ data:
18
+ message: |
19
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut aliquet
20
+ dignissim dui, ac laoreet tortor vulputate nec. Aenean quis turpis
21
+ orci. Proin semper porttitor ipsum, vel maximus justo rutrum vel.
22
+ Morbi volutpat facilisis libero. Donec posuere eget odio non egestas.
23
+ Nullam sed neque quis turpis.
@@ -0,0 +1,13 @@
1
+ name: Panel
2
+ description: Used on confirmation or results pages to highlight important content.
3
+ govuk_frontend_components:
4
+ - panel
5
+ accessibility_criteria: |
6
+ - have a text colour contrast ratio of more than 4.5:1 with its background to be visually distinct
7
+ examples:
8
+ default:
9
+ data:
10
+ title: Application complete
11
+ description: |
12
+ Your reference number<br>
13
+ <strong>HDJ2123F</strong>
@@ -2,13 +2,14 @@ module GovukPublishingComponents
2
2
  module Presenters
3
3
  # @private
4
4
  class ContextualNavigation
5
- attr_reader :content_item, :request_path
5
+ attr_reader :content_item, :request_path, :query_parameters
6
6
 
7
7
  # @param content_item A content item hash with strings as keys
8
8
  # @param request_path `request.path`
9
- def initialize(content_item, request_path)
9
+ def initialize(content_item, request)
10
10
  @content_item = content_item
11
- @request_path = simple_smart_answer? ? content_item['base_path'] : request_path
11
+ @request_path = simple_smart_answer? ? content_item['base_path'] : request.path
12
+ @query_parameters = request.query_parameters
12
13
  end
13
14
 
14
15
  def simple_smart_answer?
@@ -55,7 +56,7 @@ module GovukPublishingComponents
55
56
  content_item.dig("links", "taxons").to_a.any? { |taxon| taxon["phase"] == "live" }
56
57
  end
57
58
 
58
- def content_tagged_to_single_step_by_step?
59
+ def content_tagged_to_current_step_by_step?
59
60
  # TODO: remove indirection here
60
61
  step_nav_helper.show_header?
61
62
  end
@@ -64,8 +65,12 @@ module GovukPublishingComponents
64
65
  step_nav_helper.show_related_links?
65
66
  end
66
67
 
68
+ def content_tagged_to_other_step_by_steps?
69
+ step_nav_helper.show_also_part_of_step_nav?
70
+ end
71
+
67
72
  def step_nav_helper
68
- @step_nav_helper ||= PageWithStepByStepNavigation.new(content_item, request_path)
73
+ @step_nav_helper ||= PageWithStepByStepNavigation.new(content_item, request_path, query_parameters)
69
74
  end
70
75
  end
71
76
  end
@@ -3,9 +3,10 @@ module GovukPublishingComponents
3
3
  # @private
4
4
  # Only used by the step by step component
5
5
  class PageWithStepByStepNavigation
6
- def initialize(content_store_response, current_path)
6
+ def initialize(content_store_response, current_path, query_parameters = {})
7
7
  @content_item = content_store_response.to_h
8
8
  @current_path = current_path
9
+ @query_parameters = query_parameters
9
10
  end
10
11
 
11
12
  def step_navs
@@ -15,32 +16,36 @@ module GovukPublishingComponents
15
16
  end
16
17
 
17
18
  def show_sidebar?
18
- show_header? && first_step_nav.steps.present?
19
+ show_header? && current_step_nav.steps.present?
19
20
  end
20
21
 
21
22
  def show_header?
22
- step_navs.count == 1
23
+ step_navs.count == 1 || active_step_by_step?
23
24
  end
24
25
 
25
26
  def show_related_links?
26
- step_navs.any? && step_navs.count < 5
27
+ step_navs.any? && (step_navs.count < 5 || active_step_by_step?)
28
+ end
29
+
30
+ def show_also_part_of_step_nav?
31
+ active_step_by_step? && also_part_of_step_nav.any?
27
32
  end
28
33
 
29
34
  def related_links
30
- step_navs.map do |step_nav|
31
- {
32
- href: step_nav.base_path,
33
- text: step_nav.title,
34
- tracking_id: step_nav.content_id
35
- }
36
- end
35
+ step_by_step_navs = active_step_by_step? ? [active_step_by_step] : step_navs
36
+ format_related_links(step_by_step_navs)
37
+ end
38
+
39
+ def also_part_of_step_nav
40
+ step_by_step_navs = step_navs.delete_if { |step_nav| step_nav.content_id == active_step_by_step.content_id }
41
+ format_related_links(step_by_step_navs)
37
42
  end
38
43
 
39
44
  def sidebar
40
45
  if show_sidebar?
41
- @sidebar ||= first_step_nav.content.tap do |sb|
46
+ @sidebar ||= current_step_nav.content.tap do |sb|
42
47
  configure_for_sidebar(sb)
43
- sb.merge!(small: true, heading_level: 3, tracking_id: first_step_nav.content_id)
48
+ sb.merge!(small: true, heading_level: 3, tracking_id: current_step_nav.content_id)
44
49
  end
45
50
  end
46
51
  end
@@ -48,23 +53,37 @@ module GovukPublishingComponents
48
53
  def header
49
54
  if show_header?
50
55
  {
51
- title: first_step_nav.title,
52
- path: first_step_nav.base_path,
53
- tracking_id: first_step_nav.content_id
56
+ title: current_step_nav.title,
57
+ path: current_step_nav.base_path,
58
+ tracking_id: current_step_nav.content_id
54
59
  }
55
60
  else
56
61
  {}
57
62
  end
58
63
  end
59
64
 
65
+ def active_step_by_step?
66
+ active_step_nav_content_id.present? && active_step_by_step.present?
67
+ end
68
+
69
+ def active_step_by_step
70
+ @active_step_navs ||= step_navs.select { |step_nav| step_nav.content_id == active_step_nav_content_id }
71
+ @active_step_navs.first
72
+ end
73
+
60
74
  private
61
75
 
62
76
  attr_reader :content_item, :current_path
63
77
 
64
- def first_step_nav
78
+ def current_step_nav
79
+ return active_step_by_step if active_step_by_step?
65
80
  step_navs.first
66
81
  end
67
82
 
83
+ def active_step_nav_content_id
84
+ @active_step_nav_content_id ||= @query_parameters['step-by-step-nav'].present? ? @query_parameters['step-by-step-nav'] : nil
85
+ end
86
+
68
87
  def steps
69
88
  @steps ||= step_nav[:steps]
70
89
  end
@@ -89,6 +108,16 @@ module GovukPublishingComponents
89
108
  end
90
109
  step_nav_content
91
110
  end
111
+
112
+ def format_related_links(step_by_step_navs)
113
+ step_by_step_navs.map do |step_nav|
114
+ {
115
+ href: step_nav.base_path,
116
+ text: step_nav.title,
117
+ tracking_id: step_nav.content_id
118
+ }
119
+ end
120
+ end
92
121
  end
93
122
 
94
123
  # @private
@@ -93,7 +93,23 @@ module GovukPublishingComponents
93
93
  end
94
94
 
95
95
  def link_href(active, href)
96
- active ? "#content" : href
96
+ return "#content" if active
97
+ return href if external_url?(href)
98
+ link_with_step_nav_query_parameter(href)
99
+ end
100
+
101
+ def external_url?(href)
102
+ href.start_with?('http')
103
+ end
104
+
105
+ def link_with_step_nav_query_parameter(href)
106
+ step_nav_content_id = @options[:step_nav_content_id]
107
+ return href if step_nav_content_id.blank?
108
+ uri = URI.parse(href)
109
+ exisiting_query_params = uri.query.present? ? CGI.parse(uri.query) : {}
110
+ new_query_params = exisiting_query_params.merge("step-by-step-nav" => step_nav_content_id)
111
+ uri.query = new_query_params.to_query
112
+ uri.to_s
97
113
  end
98
114
 
99
115
  def link_text(active, text)
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = '9.17.1'.freeze
2
+ VERSION = '9.18.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: 9.17.1
4
+ version: 9.18.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-09-05 00:00:00.000000000 Z
11
+ date: 2018-09-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: govuk_app_config
@@ -326,9 +326,9 @@ files:
326
326
  - app/assets/javascripts/govuk_publishing_components/components/copy-to-clipboard.js
327
327
  - app/assets/javascripts/govuk_publishing_components/components/error-summary.js
328
328
  - app/assets/javascripts/govuk_publishing_components/components/feedback.js
329
+ - app/assets/javascripts/govuk_publishing_components/components/initial-focus.js
329
330
  - app/assets/javascripts/govuk_publishing_components/components/radio.js
330
331
  - app/assets/javascripts/govuk_publishing_components/components/step-by-step-nav.js
331
- - app/assets/javascripts/govuk_publishing_components/components/success-alert.js
332
332
  - app/assets/javascripts/govuk_publishing_components/lib/current-location.js
333
333
  - app/assets/javascripts/govuk_publishing_components/lib/toggle-input-class-on-focus.js
334
334
  - app/assets/javascripts/govuk_publishing_components/lib/toggle.js
@@ -345,6 +345,7 @@ files:
345
345
  - app/assets/stylesheets/govuk_publishing_components/components/_copy-to-clipboard.scss
346
346
  - app/assets/stylesheets/govuk_publishing_components/components/_details.scss
347
347
  - app/assets/stylesheets/govuk_publishing_components/components/_document-list.scss
348
+ - app/assets/stylesheets/govuk_publishing_components/components/_error-alert.scss
348
349
  - app/assets/stylesheets/govuk_publishing_components/components/_error-message.scss
349
350
  - app/assets/stylesheets/govuk_publishing_components/components/_error-summary.scss
350
351
  - app/assets/stylesheets/govuk_publishing_components/components/_feedback.scss
@@ -366,6 +367,7 @@ files:
366
367
  - app/assets/stylesheets/govuk_publishing_components/components/_metadata.scss
367
368
  - app/assets/stylesheets/govuk_publishing_components/components/_notice.scss
368
369
  - app/assets/stylesheets/govuk_publishing_components/components/_organisation-logo.scss
370
+ - app/assets/stylesheets/govuk_publishing_components/components/_panel.scss
369
371
  - app/assets/stylesheets/govuk_publishing_components/components/_phase-banner.scss
370
372
  - app/assets/stylesheets/govuk_publishing_components/components/_previous-and-next-navigation.scss
371
373
  - app/assets/stylesheets/govuk_publishing_components/components/_radio.scss
@@ -448,6 +450,7 @@ files:
448
450
  - app/views/govuk_publishing_components/components/_copy_to_clipboard.html.erb
449
451
  - app/views/govuk_publishing_components/components/_details.html.erb
450
452
  - app/views/govuk_publishing_components/components/_document_list.html.erb
453
+ - app/views/govuk_publishing_components/components/_error_alert.html.erb
451
454
  - app/views/govuk_publishing_components/components/_error_message.html.erb
452
455
  - app/views/govuk_publishing_components/components/_error_summary.html.erb
453
456
  - app/views/govuk_publishing_components/components/_feedback.html.erb
@@ -473,6 +476,7 @@ files:
473
476
  - app/views/govuk_publishing_components/components/_metadata.html.erb
474
477
  - app/views/govuk_publishing_components/components/_notice.html.erb
475
478
  - app/views/govuk_publishing_components/components/_organisation_logo.html.erb
479
+ - app/views/govuk_publishing_components/components/_panel.html.erb
476
480
  - app/views/govuk_publishing_components/components/_phase_banner.html.erb
477
481
  - app/views/govuk_publishing_components/components/_previous_and_next_navigation.html.erb
478
482
  - app/views/govuk_publishing_components/components/_radio.html.erb
@@ -501,6 +505,7 @@ files:
501
505
  - app/views/govuk_publishing_components/components/docs/copy_to_clipboard.yml
502
506
  - app/views/govuk_publishing_components/components/docs/details.yml
503
507
  - app/views/govuk_publishing_components/components/docs/document_list.yml
508
+ - app/views/govuk_publishing_components/components/docs/error_alert.yml
504
509
  - app/views/govuk_publishing_components/components/docs/error_message.yml
505
510
  - app/views/govuk_publishing_components/components/docs/error_summary.yml
506
511
  - app/views/govuk_publishing_components/components/docs/feedback.yml
@@ -526,6 +531,7 @@ files:
526
531
  - app/views/govuk_publishing_components/components/docs/metadata.yml
527
532
  - app/views/govuk_publishing_components/components/docs/notice.yml
528
533
  - app/views/govuk_publishing_components/components/docs/organisation_logo.yml
534
+ - app/views/govuk_publishing_components/components/docs/panel.yml
529
535
  - app/views/govuk_publishing_components/components/docs/phase_banner.yml
530
536
  - app/views/govuk_publishing_components/components/docs/previous_and_next_navigation.yml
531
537
  - app/views/govuk_publishing_components/components/docs/radio.yml