govuk_publishing_components 9.8.0 → 9.9.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: a5448e205e6135944563a216db12b37c143b57016d6bafd80ade3b31bdb8625e
4
- data.tar.gz: d108ec91620a235bb335674ffa4549a76a253867c7f18d460be47689babc507c
3
+ metadata.gz: 960ab5d3187352fb644a25d13ceb60199a064d4c34855ef09b5b076d040a848b
4
+ data.tar.gz: 0e2eb87f4c638266e06b83cd870db71d5b19ad3cf1feb4ee0716013dbb76028e
5
5
  SHA512:
6
- metadata.gz: 0dcd90698c861c27e9f3fd036526ad256a20f5896096b8b7b99bc63464f2f754be2267cabb07772686b794b785f68958510e7158fe21cdebadd23412c00f9932
7
- data.tar.gz: 40c868822baa69b8d497dcfc3408e8c1c96c677cb0d5a830e232bb8fcf9a2b2f94e214fd0dbb0c84b8763a4ef8106908a1d210a626fab9187391c5785652ae26
6
+ metadata.gz: cc87b549d4daf795a20093462c3133915a5fa119ed50c599ee0ef4bb379a8c5a8716cf2cfa2eda55df0a0083f5fc8067132d56b77c62d892af7441f4c8243f1e
7
+ data.tar.gz: 9ad12968cacfe966653c7ef523462b40a9891066b0e97b0db927919e2d6e210882386b24bb4a789c54b8c52bd86a6af1c77f52b8317ed72d7e06a6c1989134a0
@@ -15,6 +15,19 @@
15
15
  padding: 0;
16
16
  }
17
17
 
18
+ .gem-c-step-nav-related--singular {
19
+ margin-bottom: $gutter-one-third + 3;
20
+
21
+ .gem-c-step-nav-related__heading {
22
+ @include _core-font-generator(19px, 19px, 19px, 1.4, 1.4, false, bold);
23
+ margin-top: $gutter-two-thirds;
24
+ }
25
+
26
+ .gem-c-step-nav-related__pretitle {
27
+ margin-bottom: $gutter-one-quarter;
28
+ }
29
+ }
30
+
18
31
  .gem-c-step-nav-related__pretitle {
19
32
  display: block;
20
33
  margin-bottom: $gutter-half;
@@ -0,0 +1 @@
1
+ // This component relies on styles from GOV.UK Frontend
@@ -1,29 +1,11 @@
1
- <%
2
- start ||= false
3
- href ||= false
4
- info_text ||= false
5
- rel ||= false
6
- text ||= ""
7
- margin_bottom ||= false
8
- data_attributes ||= false
9
- title ||= false
10
- css_classes = %w(gem-c-button govuk-button)
11
- css_classes << "govuk-button--start" if start
12
- css_classes << "gem-c-button--bottom-margin" if margin_bottom
13
- css_classes = css_classes.join(" ")
14
- html_options = { class: css_classes }
15
- html_options[:role] = "button" if href
16
- html_options[:rel] = rel if rel
17
- html_options[:data] = data_attributes if data_attributes
18
- html_options[:title] = title if title
19
- %>
20
- <% if href %>
21
- <%= link_to(text, href, html_options) %>
1
+ <% button = GovukPublishingComponents::Presenters::ButtonHelper.new(local_assigns) %>
2
+
3
+ <% if button.link? %>
4
+ <%= link_to button.text, button.href, button.html_options %>
22
5
  <% else %>
23
- <%= button_tag(text, html_options) %>
6
+ <%= button_tag button.text, button.html_options %>
24
7
  <% end %>
25
- <% if info_text %>
26
- <span class="gem-c-button__info-text">
27
- <%= info_text %>
28
- </span>
8
+
9
+ <% if button.info_text %>
10
+ <%= tag.span button.info_text, class: "gem-c-button__info-text" %>
29
11
  <% end %>
@@ -55,7 +55,7 @@
55
55
  <%= logic %>
56
56
  <% else %>
57
57
  <% step_number += 1 %>
58
- <span class="visuallyhidden">Step</span> <%= step_number %>
58
+ <span class="visuallyhidden">Step</span> <%= step_number %><span class="visuallyhidden" aria-hidden="true">:</span>
59
59
  <% end %>
60
60
  </span>
61
61
  </span>
@@ -3,7 +3,9 @@
3
3
  pretitle ||= t("govuk_component.step_by_step_nav_related.part_of", default: "Part of")
4
4
  %>
5
5
  <% if links.any? %>
6
- <div class="gem-c-step-nav-related" data-module="track-click">
6
+ <div
7
+ class="gem-c-step-nav-related <%= "gem-c-step-nav-related--singular" if links.length == 1 %>"
8
+ data-module="track-click">
7
9
  <h2 class="gem-c-step-nav-related__heading">
8
10
  <span class="gem-c-step-nav-related__pretitle"><%= pretitle %></span>
9
11
  <% if links.length == 1 %>
@@ -0,0 +1,31 @@
1
+ <%
2
+ tabs ||= []
3
+ %>
4
+ <% if tabs.count > 1 %>
5
+ <div class="govuk-tabs gem-c-tabs" data-module="tabs">
6
+ <h2 class="govuk-tabs__title">
7
+ Contents
8
+ </h2>
9
+ <ul class="govuk-tabs__list">
10
+ <% tabs.each do |tab| %>
11
+ <li class="govuk-tabs__list-item">
12
+ <a class="govuk-tabs__tab" href="#<%= tab[:id] %>">
13
+ <%= tab[:title] %>
14
+ </a>
15
+ </li>
16
+ <% end %>
17
+ </ul>
18
+ <% tabs.each do |tab| %>
19
+ <section class="govuk-tabs__panel" id="<%= tab[:id] %>">
20
+ <h2 class="govuk-heading-l"><%= tab[:title] %></h2>
21
+ <%= tab[:content] %>
22
+ </section>
23
+ <% end %>
24
+ </div>
25
+ <% end %>
26
+ <% if tabs.count == 1 %>
27
+ <section id="<%= tabs[0][:id] %>">
28
+ <h2 class="govuk-heading-l"><%= tabs[0][:title] %></h2>
29
+ <%= tabs[0][:content] %>
30
+ </section>
31
+ <% end %>
@@ -47,3 +47,10 @@ examples:
47
47
  base_path: "/foo"
48
48
  details: {}
49
49
  schema: :person
50
+ organisation_schema:
51
+ data:
52
+ content_item:
53
+ title: "Ministry of Organisation"
54
+ base_path: "/foo"
55
+ details: {}
56
+ schema: :organisation
@@ -4,7 +4,6 @@ part_of_admin_layout: true
4
4
  govuk_frontend_components:
5
5
  - select
6
6
  accessibility_criteria: |
7
- The component must:
8
7
  - accept focus
9
8
  - be focusable with a keyboard
10
9
  - be usable with a keyboard
@@ -0,0 +1,42 @@
1
+ name: "Tabs (experimental)"
2
+ description: "The tabs component lets users toggle between related sections of content."
3
+ part_of_admin_layout: true
4
+ body: |
5
+ This component is based on the [design system tabs component](https://design-system.service.gov.uk/components/tabs/)
6
+ and is currently experimental. If using this component, please feed back any research findings to the
7
+ design team.
8
+
9
+ The tabs component lets users navigate between related sections of content on a single page,
10
+ displaying one section at a time. Note that they are not intended to be used to navigate
11
+ between different pages.
12
+
13
+ The content block MUST be passed as a block to avoid the risk of unsanitised HTML.
14
+ accessibility_criteria: |
15
+ - Tabs must:
16
+ * accept focus
17
+ * be usable with a keyboard
18
+ * indicate when they have focus
19
+ * be usable with touch
20
+ * be usable with voice commands
21
+ * have visible text
22
+
23
+ examples:
24
+ default:
25
+ data:
26
+ tabs:
27
+ - id: "tab1"
28
+ title: "First section"
29
+ content: |
30
+ <p>Fusce at dictum tellus, ac accumsan est. Nulla vitae turpis in nulla gravida tincidunt. Duis lectus felis, tempus id bibendum sit amet, posuere ut elit. Donec enim odio, eleifend in urna a, sagittis egestas est. Proin id ex ultricies, porta eros id, vehicula quam. Morbi non sagittis velit.</p>
31
+ - id: "tab2"
32
+ title: "Second section"
33
+ content: |
34
+ <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam congue elementum commodo. Vestibulum elit turpis, efficitur quis posuere vitae, commodo vitae augue. Donec ut pharetra ligula. Phasellus ac mauris eu felis bibendum dapibus rutrum sed quam. Pellentesque posuere ante id consequat pretium.</p>
35
+ single_item:
36
+ description: If only an individual item is supplied to the component (if the list is created dynamically, for example) it will be rendered without tabs.
37
+ data:
38
+ tabs:
39
+ - id: "singletab"
40
+ title: "Single piece of content"
41
+ content: |
42
+ Here is a single piece of content, there should be no tabs.
@@ -1,6 +1,7 @@
1
1
  require "govuk_publishing_components/config"
2
2
  require "govuk_publishing_components/engine"
3
3
  require "govuk_publishing_components/presenters/breadcrumbs"
4
+ require "govuk_publishing_components/presenters/button_helper"
4
5
  require "govuk_publishing_components/presenters/contextual_navigation"
5
6
  require "govuk_publishing_components/presenters/related_navigation_helper"
6
7
  require "govuk_publishing_components/presenters/step_by_step_nav_helper"
@@ -0,0 +1,43 @@
1
+ require 'action_view'
2
+
3
+ module GovukPublishingComponents
4
+ module Presenters
5
+ class ButtonHelper
6
+ attr_reader :href, :text, :title, :info_text, :rel, :data_attributes,
7
+ :start, :margin_bottom
8
+
9
+ def initialize(local_assigns)
10
+ @href = local_assigns[:href]
11
+ @text = local_assigns[:text]
12
+ @title = local_assigns[:title]
13
+ @info_text = local_assigns[:info_text]
14
+ @rel = local_assigns[:rel]
15
+ @data_attributes = local_assigns[:data_attributes]
16
+ @start = local_assigns[:start]
17
+ @margin_bottom = local_assigns[:margin_bottom]
18
+ end
19
+
20
+ def link?
21
+ href.present?
22
+ end
23
+
24
+ def html_options
25
+ options = { class: css_classes }
26
+ options[:role] = "button" if link?
27
+ options[:rel] = rel if rel
28
+ options[:data] = data_attributes if data_attributes
29
+ options[:title] = title if title
30
+ options
31
+ end
32
+
33
+ private
34
+
35
+ def css_classes
36
+ classes = %w(gem-c-button govuk-button)
37
+ classes << "govuk-button--start" if start
38
+ classes << "gem-c-button--bottom-margin" if margin_bottom
39
+ classes.join(" ")
40
+ end
41
+ end
42
+ end
43
+ end
@@ -29,7 +29,7 @@ module GovukPublishingComponents
29
29
  "url" => page.logo_url,
30
30
  }
31
31
  }
32
- }.merge(image_schema).merge(author_schema).merge(body)
32
+ }.merge(image_schema).merge(author_schema).merge(body).merge(is_part_of)
33
33
  end
34
34
 
35
35
  private
@@ -67,6 +67,37 @@ module GovukPublishingComponents
67
67
  def publishing_organisation
68
68
  page.content_item.dig("links", "primary_publishing_organisation").to_a.first
69
69
  end
70
+
71
+ def is_part_of
72
+ return {} unless linked_step_by_steps.any?
73
+ {
74
+ "isPartOf" => step_by_step_schemas
75
+ }
76
+ end
77
+
78
+ def linked_step_by_steps
79
+ # We could include `related_to_step_navs` eventually too, but initially
80
+ # link to those that we render in the "step_by_step_nav_related" component
81
+ @step_by_steps ||= page.content_item.dig("links", "part_of_step_navs").to_a
82
+ end
83
+
84
+ def step_by_step_schemas
85
+ linked_step_by_steps.map do |step_by_step|
86
+ step_by_step_page = linked_page(step_by_step)
87
+ structured_data = HowToSchema.new(step_by_step_page.canonical_url).structured_data
88
+
89
+ structured_data.merge(image_schema)
90
+ end
91
+ end
92
+
93
+ def linked_page(step_by_step)
94
+ Page.new(
95
+ content_item: step_by_step,
96
+ schema: :article,
97
+ logo_url: page.logo_url,
98
+ image_placeholders: page.image_placeholders
99
+ )
100
+ end
70
101
  end
71
102
  end
72
103
  end
@@ -0,0 +1,20 @@
1
+ module GovukPublishingComponents
2
+ module Presenters
3
+ class HowToSchema
4
+ attr_reader :how_to_url
5
+
6
+ def initialize(how_to_url)
7
+ @how_to_url = how_to_url
8
+ end
9
+
10
+ def structured_data
11
+ # http://schema.org/HowTo - minimal
12
+ {
13
+ "@context" => "http://schema.org",
14
+ "@type" => "HowTo",
15
+ "sameAs" => how_to_url
16
+ }
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,25 @@
1
+ module GovukPublishingComponents
2
+ module Presenters
3
+ class OrganisationSchema
4
+ attr_reader :page
5
+
6
+ def initialize(page)
7
+ @page = page
8
+ end
9
+
10
+ def structured_data
11
+ # http://schema.org/GovernmentOrganization
12
+ {
13
+ "@context" => "http://schema.org",
14
+ "@type" => "GovernmentOrganization",
15
+ "mainEntityOfPage" => {
16
+ "@type" => "WebPage",
17
+ "@id" => page.canonical_url,
18
+ },
19
+ "name" => page.title,
20
+ "description" => page.body
21
+ }
22
+ end
23
+ end
24
+ end
25
+ end
@@ -16,7 +16,7 @@ module GovukPublishingComponents
16
16
  end
17
17
 
18
18
  def body
19
- local_assigns[:body] || content_item["details"]["body"]
19
+ local_assigns[:body] || content_item.dig("details", "body")
20
20
  end
21
21
 
22
22
  def title
@@ -1,6 +1,8 @@
1
1
  require 'govuk_publishing_components/presenters/machine_readable/page'
2
2
  require 'govuk_publishing_components/presenters/machine_readable/article_schema'
3
+ require 'govuk_publishing_components/presenters/machine_readable/how_to_schema'
3
4
  require 'govuk_publishing_components/presenters/machine_readable/news_article_schema'
5
+ require 'govuk_publishing_components/presenters/machine_readable/organisation_schema'
4
6
  require 'govuk_publishing_components/presenters/machine_readable/person_schema'
5
7
 
6
8
  module GovukPublishingComponents
@@ -19,6 +21,8 @@ module GovukPublishingComponents
19
21
  NewsArticleSchema.new(page).structured_data
20
22
  elsif page.schema == :person
21
23
  PersonSchema.new(page).structured_data
24
+ elsif page.schema == :organisation
25
+ OrganisationSchema.new(page).structured_data
22
26
  else
23
27
  raise "#{page.schema} is not supported"
24
28
  end
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = '9.8.0'.freeze
2
+ VERSION = '9.9.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.8.0
4
+ version: 9.9.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-08-01 00:00:00.000000000 Z
11
+ date: 2018-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: govuk_app_config
@@ -377,6 +377,7 @@ files:
377
377
  - app/assets/stylesheets/govuk_publishing_components/components/_step-by-step-nav.scss
378
378
  - app/assets/stylesheets/govuk_publishing_components/components/_subscription-links.scss
379
379
  - app/assets/stylesheets/govuk_publishing_components/components/_success-alert.scss
380
+ - app/assets/stylesheets/govuk_publishing_components/components/_tabs.scss
380
381
  - app/assets/stylesheets/govuk_publishing_components/components/_taxonomy-navigation.scss
381
382
  - app/assets/stylesheets/govuk_publishing_components/components/_textarea.scss
382
383
  - app/assets/stylesheets/govuk_publishing_components/components/_title.scss
@@ -480,6 +481,7 @@ files:
480
481
  - app/views/govuk_publishing_components/components/_step_by_step_nav_related.html.erb
481
482
  - app/views/govuk_publishing_components/components/_subscription-links.html.erb
482
483
  - app/views/govuk_publishing_components/components/_success_alert.html.erb
484
+ - app/views/govuk_publishing_components/components/_tabs.html.erb
483
485
  - app/views/govuk_publishing_components/components/_taxonomy_navigation.html.erb
484
486
  - app/views/govuk_publishing_components/components/_textarea.html.erb
485
487
  - app/views/govuk_publishing_components/components/_title.html.erb
@@ -529,6 +531,7 @@ files:
529
531
  - app/views/govuk_publishing_components/components/docs/step_by_step_nav_related.yml
530
532
  - app/views/govuk_publishing_components/components/docs/subscription-links.yml
531
533
  - app/views/govuk_publishing_components/components/docs/success_alert.yml
534
+ - app/views/govuk_publishing_components/components/docs/tabs.yml
532
535
  - app/views/govuk_publishing_components/components/docs/taxonomy_navigation.yml
533
536
  - app/views/govuk_publishing_components/components/docs/textarea.yml
534
537
  - app/views/govuk_publishing_components/components/docs/title.yml
@@ -552,6 +555,7 @@ files:
552
555
  - lib/govuk_publishing_components/engine.rb
553
556
  - lib/govuk_publishing_components/minitest/component_guide_test.rb
554
557
  - lib/govuk_publishing_components/presenters/breadcrumbs.rb
558
+ - lib/govuk_publishing_components/presenters/button_helper.rb
555
559
  - lib/govuk_publishing_components/presenters/content_breadcrumbs_based_on_parent.rb
556
560
  - lib/govuk_publishing_components/presenters/content_breadcrumbs_based_on_taxons.rb
557
561
  - lib/govuk_publishing_components/presenters/content_item.rb
@@ -562,7 +566,9 @@ files:
562
566
  - lib/govuk_publishing_components/presenters/highlight_boxes_helper.rb
563
567
  - lib/govuk_publishing_components/presenters/image_card_helper.rb
564
568
  - lib/govuk_publishing_components/presenters/machine_readable/article_schema.rb
569
+ - lib/govuk_publishing_components/presenters/machine_readable/how_to_schema.rb
565
570
  - lib/govuk_publishing_components/presenters/machine_readable/news_article_schema.rb
571
+ - lib/govuk_publishing_components/presenters/machine_readable/organisation_schema.rb
566
572
  - lib/govuk_publishing_components/presenters/machine_readable/page.rb
567
573
  - lib/govuk_publishing_components/presenters/machine_readable/person_schema.rb
568
574
  - lib/govuk_publishing_components/presenters/meta_tags.rb