govuk_publishing_components 5.5.6 → 5.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8fbefd48d42ae5e9eb0cfb75f99b26e2ad3d75e6a8ca5f650fdace56ab097738
4
- data.tar.gz: 1fd1d1c8c29e5a7f3f98403ae90c6ce69da5da001517f41e781a83e28e1478c7
3
+ metadata.gz: a741268b6b87bdca3271b0988eef9a43ec7e9b01ad03b59a0bdcdc1611c72278
4
+ data.tar.gz: e5bd85deb2d496c428100b9e3711a78982e42b39d7aff181b5802e6b1e2a4cf7
5
5
  SHA512:
6
- metadata.gz: a576f5fa1d962ac57fc9fadb5ee503b15a359d3c6d6b060560ba88c0078bbd66a76953d870a87a55abf40afdab2ce843a7ee4ae74a9016b0999784b128fff4ca
7
- data.tar.gz: 3c3bbe4ac3b8f36a078fb80faf562408422c05e6db0af3e7bb2e73add1d884b776a6251edbc7d8a5cf4c2134801c9241ec19878bba312a3739c29547cd083f29
6
+ metadata.gz: 17e7019b89f86cec1c4e3a80f89495e34ba94ae01350308d23f4795138d673f69112edc8b65668b2337696dcdf62d4cdf2499d0a1b95bc5e315e32a3c0c76812
7
+ data.tar.gz: cc2f4a5a5124f7e8ba80db9b995f0c14c673b3fcdb5222c08565087ccfafc5a23ed2a15203b5abf5d3cab97e28cd449c799475a1cfb56d2310db545fe0ccb367
@@ -0,0 +1 @@
1
+ //= require_tree ./components
@@ -13,6 +13,5 @@
13
13
  //= require govuk/modules
14
14
  //= require ../history-support
15
15
  //= require ../current-location
16
- //= require_tree ./components
17
16
  //= require_tree ./vendor
18
17
  //= require_tree .
@@ -19,11 +19,13 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
19
19
  this.$somethingIsWrongButton = $element.find('.js-something-is-wrong');
20
20
  this.$promptQuestions = $element.find('.js-prompt-questions');
21
21
  this.$promptSuccessMessage = $element.find('.js-prompt-success');
22
+ this.$somethingIsWrongForm = $element.find('#something-is-wrong');
22
23
 
23
24
  var that = this;
24
25
  var jshiddenClass = 'js-hidden';
25
26
 
26
27
  setInitialAriaAttributes();
28
+ setHiddenValues();
27
29
 
28
30
  this.$toggleForms.on('click', function(e) {
29
31
  e.preventDefault();
@@ -83,6 +85,11 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
83
85
  that.$somethingIsWrongButton.attr('aria-expanded', false);
84
86
  }
85
87
 
88
+ function setHiddenValues () {
89
+ that.$somethingIsWrongForm.append('<input type="hidden" name="javascript_enabled" value="true"/>');
90
+ that.$somethingIsWrongForm.append($('<input type="hidden" name="referrer">').val(document.referrer || "unknown"));
91
+ }
92
+
86
93
  function updateAriaAttributes (linkClicked) {
87
94
  linkClicked.attr('aria-expanded', true);
88
95
  $('#' + linkClicked.attr('aria-controls')).attr('aria-hidden', false);
@@ -22,18 +22,10 @@
22
22
  }
23
23
 
24
24
  .gem-c-document-list--bottom-margin {
25
- margin-bottom: $gutter-half;
26
-
27
- @include media(tablet) {
28
- margin-bottom: $gutter * 1.5;
29
- }
25
+ margin-bottom: $gutter-two-thirds;
30
26
  }
31
27
 
32
28
  .gem-c-document-list--top-margin {
33
- margin-top: $gutter-half;
34
-
35
- @include media(tablet) {
36
- margin-top: $gutter * 1.5;
37
- }
29
+ margin-top: $gutter-two-thirds;
38
30
  }
39
31
 
@@ -0,0 +1,20 @@
1
+ <% navigation = GovukPublishingComponents::Presenters::ContextualNavigation.new(content_item, request.path) %>
2
+
3
+ <% if navigation.step_nav_helper.show_header? %>
4
+ <!-- Rendering step by step nav -->
5
+ <%= render 'govuk_publishing_components/components/step_by_step_nav_header', navigation.step_nav_helper.header %>
6
+ <% else %>
7
+ <% if navigation.should_present_taxonomy_navigation? %>
8
+ <!-- Rendering taxonomy breadcrumbs -->
9
+ <% if navigation.taxon_breadcrumbs.any? %>
10
+ <%= render 'govuk_component/breadcrumbs',
11
+ breadcrumbs: navigation.taxon_breadcrumbs[:breadcrumbs],
12
+ collapse_on_mobile: true %>
13
+ <% end %>
14
+ <% else %>
15
+ <!-- Rendering normal breadcrumbs -->
16
+ <% if navigation.breadcrumbs.any? %>
17
+ <%= render 'govuk_component/breadcrumbs', breadcrumbs: navigation.breadcrumbs %>
18
+ <% end %>
19
+ <% end %>
20
+ <% end %>
@@ -0,0 +1,19 @@
1
+ <% navigation = GovukPublishingComponents::Presenters::ContextualNavigation.new(content_item, request.path) %>
2
+
3
+ <% if navigation.step_nav_helper.show_related_links? %>
4
+ <!-- rendering step by step related items -->
5
+ <%= render 'govuk_publishing_components/components/step_by_step_nav_related', links: navigation.step_nav_helper.related_links %>
6
+
7
+ <% if navigation.step_nav_helper.show_sidebar? %>
8
+ <!-- rendering step by step sidebar -->
9
+ <%= render 'govuk_publishing_components/components/step_by_step_nav', navigation.step_nav_helper.sidebar %>
10
+ <% end %>
11
+ <% else %>
12
+ <% if navigation.should_present_taxonomy_navigation? %>
13
+ <!-- rendering taxonomy sidebar -->
14
+ <%= render partial: 'govuk_component/taxonomy_sidebar', locals: navigation.taxonomy_sidebar %>
15
+ <% else %>
16
+ <!-- rendering related navigation sidebar -->
17
+ <%= render 'govuk_publishing_components/components/related_navigation', content_item %>
18
+ <% end %>
19
+ <% end %>
@@ -0,0 +1,25 @@
1
+ name: Contextual breadcrumbs
2
+ description: Breadcrumbs that shows different things depending on the page
3
+ body: |
4
+ This is a complex component that calls other components. For more accurate
5
+ preview with real data, see the [contextual navigation preview][preview].
6
+
7
+ There are 3 main variants of the component:
8
+
9
+ - Step by step, which uses the [step by step header][header]
10
+ - Parent breadcrumb, which uses the `parent` link of the page with the [breadcrumbs component][breadcrumbs]
11
+ - Taxon breadcrumb, which uses the `taxons` link of the page with the [breadcrumbs component][breadcrumbs]
12
+
13
+ It must always used [together with the contextual sidebar][sidebar].
14
+
15
+ [preview]: https://govuk-publishing-components.herokuapp.com/contextual-navigation
16
+ [header]: /component-guide/step_by_step_nav_header
17
+ [sidebar]: /component-guide/contextual_sidebar
18
+ [breadcrumbs]: https://govuk-static.herokuapp.com/component-guide/breadcrumbs
19
+ accessibility_criteria: |
20
+ Components called by this component must be accessible
21
+ examples:
22
+ default:
23
+ data:
24
+ content_item:
25
+ title: "A content item"
@@ -0,0 +1,27 @@
1
+ name: Contextual sidebar
2
+ description: Sidebar that shows different things depending on the page
3
+ body: |
4
+ This is a complex component that calls other components. For more accurate
5
+ preview with real data, see the [contextual navigation preview][preview].
6
+
7
+ There are 4 main variants of the component:
8
+
9
+ - Step by step, which uses the [step by step nav][step-by-step]
10
+ - Taxonomy, which uses the new taxonomy in the [taxonomy-sidebar component][taxonomy-sidebar]
11
+ - Mainstream, which uses related links in the [related navigation component][related_navigation]
12
+ - Related navigation, which uses legacy taxonomies in the [related navigation component][related_navigation]
13
+
14
+ It must always used [together with the contextual breadcrumbs][contextual_breadcrumbs].
15
+
16
+ [preview]: https://govuk-publishing-components.herokuapp.com/contextual-navigation
17
+ [step-by-step]: /component-guide/step_by_step_nav
18
+ [related_navigation]: /component-guide/related_navigation
19
+ [taxonomy-sidebar]: https://govuk-static.herokuapp.com/component-guide/taxonomy_sidebar
20
+ [contextual_breadcrumbs]: /component-guide/contextual_breadcrumbs
21
+ accessibility_criteria: |
22
+ Components called by this component must be accessible
23
+ examples:
24
+ default:
25
+ data:
26
+ content_item:
27
+ title: "A content item"
@@ -2,6 +2,8 @@ require "govuk_publishing_components/config"
2
2
  require "govuk_publishing_components/engine"
3
3
  require "govuk_publishing_components/presenters/step_by_step_nav_helper"
4
4
  require "govuk_publishing_components/presenters/related_navigation_helper"
5
+ require "govuk_publishing_components/presenters/contextual_navigation"
6
+ require "govuk_publishing_components/presenters/navigation_type"
5
7
 
6
8
  require "govuk_publishing_components/app_helpers/step_nav"
7
9
  require "govuk_publishing_components/app_helpers/step_nav_helper"
@@ -0,0 +1,60 @@
1
+ require 'govuk_navigation_helpers'
2
+
3
+ module GovukPublishingComponents
4
+ module Presenters
5
+ # @private
6
+ class ContextualNavigation
7
+ attr_reader :content_item, :request_path
8
+
9
+ # @param content_item A content item hash with strings as keys
10
+ # @param request_path `request.path`
11
+ def initialize(content_item, request_path)
12
+ @content_item = content_item
13
+ @request_path = request_path
14
+ end
15
+
16
+ def taxonomy_sidebar
17
+ nav_helper.taxonomy_sidebar
18
+ end
19
+
20
+ def taxon_breadcrumbs
21
+ nav_helper.taxon_breadcrumbs
22
+ end
23
+
24
+ def breadcrumbs
25
+ if content_item["schema_name"] == "specialist_document"
26
+ parent_finder = content_item.dig("links", "finder", 0)
27
+ return [] unless parent_finder
28
+
29
+ [
30
+ {
31
+ title: "Home",
32
+ url: "/",
33
+ },
34
+ {
35
+ title: parent_finder['title'],
36
+ url: parent_finder['base_path'],
37
+ }
38
+ ]
39
+ else
40
+ nav_helper.breadcrumbs[:breadcrumbs]
41
+ end
42
+ end
43
+
44
+ def should_present_taxonomy_navigation?
45
+ navigation = GovukPublishingComponents::Presenters::NavigationType.new(content_item)
46
+ navigation.should_present_taxonomy_navigation?
47
+ end
48
+
49
+ def step_nav_helper
50
+ @step_nav_helper ||= GovukPublishingComponents::AppHelpers::StepNavHelper.new(content_item, request_path)
51
+ end
52
+
53
+ private
54
+
55
+ def nav_helper
56
+ @nav_helper ||= GovukNavigationHelpers::NavigationHelper.new(content_item)
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,33 @@
1
+ module GovukPublishingComponents
2
+ module Presenters
3
+ # @private
4
+ class NavigationType
5
+ GUIDANCE_SCHEMAS =
6
+ %w{answer contact guide detailed_guide document_collection publication}.freeze
7
+
8
+ def initialize(content_item)
9
+ @content_item = content_item
10
+ end
11
+
12
+ def should_present_taxonomy_navigation?
13
+ !content_is_tagged_to_browse_pages? &&
14
+ content_is_tagged_to_a_live_taxon? &&
15
+ content_schema_is_guidance?
16
+ end
17
+
18
+ private
19
+
20
+ def content_is_tagged_to_a_live_taxon?
21
+ @content_item.dig("links", "taxons").to_a.any? { |taxon| taxon["phase"] == "live" }
22
+ end
23
+
24
+ def content_is_tagged_to_browse_pages?
25
+ @content_item.dig("links", "mainstream_browse_pages").present?
26
+ end
27
+
28
+ def content_schema_is_guidance?
29
+ GUIDANCE_SCHEMAS.include? @content_item["schema_name"]
30
+ end
31
+ end
32
+ end
33
+ end
@@ -141,8 +141,8 @@ module GovukPublishingComponents
141
141
  contacts = filter_link_type("related", "contact")
142
142
  return [] unless contacts.any?
143
143
  [
144
- title: "Other contacts",
145
- links: build_links_for_sidebar(contacts).map
144
+ "title" => "Other contacts",
145
+ "links" => build_links_for_sidebar(contacts)
146
146
  ]
147
147
  end
148
148
 
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = '5.5.6'.freeze
2
+ VERSION = '5.6.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.5.6
4
+ version: 5.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GOV.UK Dev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-15 00:00:00.000000000 Z
11
+ date: 2018-03-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -108,6 +108,20 @@ dependencies:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: govuk_navigation_helpers
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: 9.2.1
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 9.2.1
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: govuk-lint
113
127
  requirement: !ruby/object:Gem::Requirement
@@ -289,6 +303,7 @@ files:
289
303
  - app/assets/config/govuk_publishing_components_manifest.js
290
304
  - app/assets/javascripts/current-location.js
291
305
  - app/assets/javascripts/govuk_publishing_components/accessibility-test.js
306
+ - app/assets/javascripts/govuk_publishing_components/all_components.js
292
307
  - app/assets/javascripts/govuk_publishing_components/application.js
293
308
  - app/assets/javascripts/govuk_publishing_components/components/error-summary.js
294
309
  - app/assets/javascripts/govuk_publishing_components/components/feedback.js
@@ -334,6 +349,8 @@ files:
334
349
  - app/views/govuk_publishing_components/component_guide/preview.html.erb
335
350
  - app/views/govuk_publishing_components/component_guide/show.html.erb
336
351
  - app/views/govuk_publishing_components/components/_back_link.html.erb
352
+ - app/views/govuk_publishing_components/components/_contextual_breadcrumbs.html.erb
353
+ - app/views/govuk_publishing_components/components/_contextual_sidebar.html.erb
337
354
  - app/views/govuk_publishing_components/components/_document_list.html.erb
338
355
  - app/views/govuk_publishing_components/components/_error_summary.html.erb
339
356
  - app/views/govuk_publishing_components/components/_feedback.html.erb
@@ -347,6 +364,8 @@ files:
347
364
  - app/views/govuk_publishing_components/components/_step_by_step_nav_header.html.erb
348
365
  - app/views/govuk_publishing_components/components/_step_by_step_nav_related.html.erb
349
366
  - app/views/govuk_publishing_components/components/docs/back_link.yml
367
+ - app/views/govuk_publishing_components/components/docs/contextual_breadcrumbs.yml
368
+ - app/views/govuk_publishing_components/components/docs/contextual_sidebar.yml
350
369
  - app/views/govuk_publishing_components/components/docs/document_list.yml
351
370
  - app/views/govuk_publishing_components/components/docs/error_summary.yml
352
371
  - app/views/govuk_publishing_components/components/docs/feedback.yml
@@ -375,6 +394,8 @@ files:
375
394
  - lib/govuk_publishing_components/config.rb
376
395
  - lib/govuk_publishing_components/engine.rb
377
396
  - lib/govuk_publishing_components/minitest/component_guide_test.rb
397
+ - lib/govuk_publishing_components/presenters/contextual_navigation.rb
398
+ - lib/govuk_publishing_components/presenters/navigation_type.rb
378
399
  - lib/govuk_publishing_components/presenters/related_navigation_helper.rb
379
400
  - lib/govuk_publishing_components/presenters/step_by_step_nav_helper.rb
380
401
  - lib/govuk_publishing_components/version.rb