govuk_publishing_components 8.1.0 → 8.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/stylesheets/component_guide/application.scss +10 -0
  3. data/app/assets/stylesheets/govuk_publishing_components/_all_components.scss +9 -5
  4. data/app/assets/stylesheets/govuk_publishing_components/_all_components_print.scss +3 -2
  5. data/app/assets/stylesheets/govuk_publishing_components/components/_lead-paragraph.scss +12 -0
  6. data/app/assets/stylesheets/govuk_publishing_components/components/_phase-banner.scss +7 -0
  7. data/app/assets/stylesheets/govuk_publishing_components/components/_previous-and-next-navigation.scss +77 -0
  8. data/app/assets/stylesheets/govuk_publishing_components/components/_title.scss +46 -0
  9. data/app/assets/stylesheets/govuk_publishing_components/components/_translation-nav.scss +2 -0
  10. data/app/assets/stylesheets/govuk_publishing_components/components/print/_title.scss +7 -0
  11. data/app/controllers/govuk_publishing_components/component_guide_controller.rb +9 -9
  12. data/app/models/govuk_publishing_components/component_doc.rb +32 -20
  13. data/app/models/govuk_publishing_components/{component_doc_resolver.rb → component_docs.rb} +2 -27
  14. data/app/models/govuk_publishing_components/component_example.rb +4 -4
  15. data/app/views/govuk_publishing_components/component_guide/component_doc/_component.html.erb +1 -8
  16. data/app/views/govuk_publishing_components/component_guide/component_doc/_component_output.html.erb +7 -0
  17. data/app/views/govuk_publishing_components/component_guide/component_doc/_preview.html.erb +7 -0
  18. data/app/views/govuk_publishing_components/component_guide/example.html.erb +1 -1
  19. data/app/views/govuk_publishing_components/component_guide/index.html.erb +1 -1
  20. data/app/views/govuk_publishing_components/component_guide/show.html.erb +2 -2
  21. data/app/views/govuk_publishing_components/components/_government_navigation.html.erb +53 -0
  22. data/app/views/govuk_publishing_components/components/_lead_paragraph.html.erb +13 -0
  23. data/app/views/govuk_publishing_components/components/_machine_readable_metadata.html.erb +21 -1
  24. data/app/views/govuk_publishing_components/components/_phase_banner.html.erb +22 -0
  25. data/app/views/govuk_publishing_components/components/_previous_and_next_navigation.html.erb +58 -0
  26. data/app/views/govuk_publishing_components/components/_title.html.erb +23 -0
  27. data/app/views/govuk_publishing_components/components/docs/breadcrumbs.yml +1 -0
  28. data/app/views/govuk_publishing_components/components/docs/government_navigation.yml +18 -0
  29. data/app/views/govuk_publishing_components/components/docs/inverse_header.yml +10 -10
  30. data/app/views/govuk_publishing_components/components/docs/lead_paragraph.yml +22 -0
  31. data/app/views/govuk_publishing_components/components/docs/meta_tags.yml +1 -0
  32. data/app/views/govuk_publishing_components/components/docs/phase_banner.yml +21 -0
  33. data/app/views/govuk_publishing_components/components/docs/previous_and_next_navigation.yml +64 -0
  34. data/app/views/govuk_publishing_components/components/docs/title.yml +63 -0
  35. data/lib/govuk_publishing_components.rb +1 -0
  36. data/lib/govuk_publishing_components/presenters/machine_readable/article_schema.rb +72 -0
  37. data/lib/govuk_publishing_components/presenters/machine_readable/news_article_schema.rb +16 -0
  38. data/lib/govuk_publishing_components/presenters/machine_readable/page.rb +47 -0
  39. data/lib/govuk_publishing_components/presenters/sanitisation.rb +13 -0
  40. data/lib/govuk_publishing_components/presenters/schema_org.rb +13 -101
  41. data/lib/govuk_publishing_components/version.rb +1 -1
  42. metadata +23 -3
@@ -3,3 +3,10 @@
3
3
  <div class="component-guide-preview component-guide-preview--violation" data-module="test-a11y-violation" data-content="Accessibility Issues"></div>
4
4
  <div class="component-guide-preview component-guide-preview--warning" data-module="test-a11y-warning" data-content="Potential accessibility issues: need manual check"></div>
5
5
  </div>
6
+
7
+ <% if component_doc.display_html? %>
8
+ <div class="component-guide-preview component-call component-highlight component-output" data-content="HTML OUTPUT">
9
+ <% html_output = render "govuk_publishing_components/component_guide/component_doc/component_output", example: example, component_doc: component_doc %>
10
+ <pre><code><%= raw example.highlight_code(html_output.strip) %></code></pre>
11
+ </div>
12
+ <% end %>
@@ -1,5 +1,5 @@
1
1
  <% content_for :title, "#{@component_example.name} example - #{@component_doc.name} component" %>
2
- <%= render 'govuk_component/title', title: @component_example.name, context: "#{@component_doc.name} example" %>
2
+ <%= render 'govuk_publishing_components/components/title', title: @component_example.name, context: "#{@component_doc.name} example" %>
3
3
 
4
4
  <div class="component-show">
5
5
  <div class="component-doc">
@@ -1,4 +1,4 @@
1
- <%= render 'govuk_component/title', title: GovukPublishingComponents::Config.component_guide_title %>
1
+ <%= render 'govuk_publishing_components/components/title', title: GovukPublishingComponents::Config.component_guide_title %>
2
2
 
3
3
  <div class="govuk-govspeak">
4
4
  <p>Components are packages of template, style, behaviour and documentation that live in your application.</p>
@@ -1,5 +1,5 @@
1
1
  <% content_for :title, "#{@component_doc.name} component" %>
2
- <%= render 'govuk_component/title', title: @component_doc.name, context: "Component" %>
2
+ <%= render 'govuk_publishing_components/components/title', title: @component_doc.name, context: "Component" %>
3
3
 
4
4
  <div class="component-show">
5
5
  <div class="grid-row">
@@ -10,7 +10,7 @@
10
10
  <p><a class="component-violation__link" href="https://github.com/alphagov/govuk_publishing_components/blob/master/docs/accessibility_acceptance_criteria.md">Please define accessibility acceptance criteria for this component.</a></p>
11
11
  </div>
12
12
  <% end %>
13
- <%= render 'govuk_component/lead_paragraph', text: @component_doc.description %>
13
+ <%= render 'govuk_publishing_components/components/lead_paragraph', text: @component_doc.description %>
14
14
  <% if @component_doc.body.present? %>
15
15
  <div class="component-body">
16
16
  <%= render 'govuk_component/govspeak', content: @component_doc.html_body %>
@@ -0,0 +1,53 @@
1
+ <%
2
+ active ||= nil
3
+ %>
4
+
5
+ <nav id="proposition-menu" class="no-proposition-name">
6
+ <ul id="proposition-links">
7
+ <li>
8
+ <a class="<%= 'active' if active == 'departments' %>" href="/government/organisations">
9
+ <%= t("govuk_component.government_navigation.departments", default: "Departments") %>
10
+ </a>
11
+ </li>
12
+ <li>
13
+ <a class="<%= 'active' if active == 'worldwide' %>" href="/government/world">
14
+ <%= t("govuk_component.government_navigation.worldwide", default: "Worldwide") %>
15
+ </a>
16
+ </li>
17
+ <li>
18
+ <a class="<%= 'active' if active == 'how-government-works' %>" href="/government/how-government-works">
19
+ <%= t("govuk_component.government_navigation.how-government-works", default: "How government works") %>
20
+ </a>
21
+ </li>
22
+ <li>
23
+ <a class="<%= 'active' if active == 'get-involved' %>" href="/government/get-involved">
24
+ <%= t("govuk_component.government_navigation.get-involved", default: "Get involved") %>
25
+ </a>
26
+ </li>
27
+ <li class="clear-child">
28
+ <a class="<%= 'active' if active == 'policies' %>" href="/government/policies">
29
+ <%= t("govuk_component.government_navigation.policies", default: "Policies") %>
30
+ </a>
31
+ </li>
32
+ <li>
33
+ <a class="<%= 'active' if active == 'publications' %>" href="/government/publications">
34
+ <%= t("govuk_component.government_navigation.publications", default: "Publications") %>
35
+ </a>
36
+ </li>
37
+ <li>
38
+ <a class="<%= 'active' if active == 'consultations' %>" href="/government/publications?publication_filter_option=consultations">
39
+ <%= t("govuk_component.government_navigation.consultations", default: "Consultations") %>
40
+ </a>
41
+ </li>
42
+ <li>
43
+ <a class="<%= 'active' if active == 'statistics' %>" href="/government/statistics">
44
+ <%= t("govuk_component.government_navigation.statistics", default: "Statistics") %>
45
+ </a>
46
+ </li>
47
+ <li>
48
+ <a class="<%= 'active' if active == 'announcements' %>" href="/government/announcements">
49
+ <%= t("govuk_component.government_navigation.announcements", default: "Announcements") %>
50
+ </a>
51
+ </li>
52
+ </ul>
53
+ </nav>
@@ -0,0 +1,13 @@
1
+ <%
2
+ text ||= ""
3
+ inverse ||= false
4
+ # Replace the space between the last 2 words with a non-breaking space, so
5
+ # we'll never have a dangling word in a paragraph.
6
+ text = GovukPublishingComponents::Presenters::Sanitisation.sub_safely(text, /\s([\w\.\?\!\:]+)$/, '&nbsp;\1')
7
+ %>
8
+
9
+ <% if text.present? %>
10
+ <p class="gem-c-lead-paragraph <% if inverse %>gem-c-lead-paragraph--inverse<% end %>">
11
+ <%= text %>
12
+ </p>
13
+ <% end %>
@@ -1,5 +1,25 @@
1
- <% structured_data = GovukPublishingComponents::Presenters::SchemaOrg.new(local_assigns).structured_data %>
1
+ <% page = GovukPublishingComponents::Presenters::Page.new(local_assigns) %>
2
+ <% structured_data = GovukPublishingComponents::Presenters::SchemaOrg.new(page).structured_data %>
2
3
 
3
4
  <script type="application/ld+json">
4
5
  <%= raw structured_data.to_json %>
5
6
  </script>
7
+
8
+ <link rel="canonical" href="<%= page.canonical_url %>" />
9
+
10
+ <meta property="og:site_name" content="GOV.UK" />
11
+ <meta property="og:type" content="article" />
12
+ <meta property="og:url" content="<%= page.canonical_url %>" />
13
+ <meta property="og:title" content="<%= page.title %>" />
14
+ <meta property="og:description" content="<%= strip_tags(page.description) %>" />
15
+
16
+ <% if page.has_image? %>
17
+ <meta property="og:image" content="<%= page.image_url %>" />
18
+ <meta property="og:image:alt" content="<%= page.image_alt_text %>" />
19
+
20
+ <meta name="twitter:card" content="summary_large_image" />
21
+ <meta name="twitter:image" content="<%= page.image_url %>" />
22
+ <meta name="twitter:image:alt" content="<%= page.image_alt_text %>" />
23
+ <% else %>
24
+ <meta name="twitter:card" content="summary" />
25
+ <% end %>
@@ -0,0 +1,22 @@
1
+ <%
2
+ phase ||= nil
3
+
4
+ unless phase.in?(%w[alpha beta])
5
+ raise ArgumentError, "The phase banner component expects a `phase` (`beta` or `alpha`), #{phase.inspect} given"
6
+ end
7
+ %>
8
+
9
+ <div class="gem-c-phase-banner">
10
+ <p>
11
+ <strong class="phase-tag"><%= phase %></strong>
12
+ <span>
13
+ <% if local_assigns[:message] %>
14
+ <%= local_assigns[:message] %>
15
+ <% elsif phase == "beta" %>
16
+ This part of GOV.UK is being rebuilt &ndash; <a href="/help/beta">find out what beta means</a>
17
+ <% elsif phase == "alpha" %>
18
+ This part of GOV.UK is being built &ndash; <a href="/service-manual/phases/ideal-alphas">find out what alpha means</a>
19
+ <% end %>
20
+ </span>
21
+ </p>
22
+ </div>
@@ -0,0 +1,58 @@
1
+ <% if local_assigns.include?(:next_page) || local_assigns.include?(:previous_page) %>
2
+ <nav
3
+ class="gem-c-pagination"
4
+ role="navigation"
5
+ aria-label="<%= t("govuk_component.previous_and_next_navigation.pagination", default: "Pagination") %>"
6
+ >
7
+ <ul class="gem-c-pagination__list" data-module="track-click">
8
+ <% if local_assigns.include?(:previous_page) %>
9
+ <li class="gem-c-pagination__item gem-c-pagination__item--previous">
10
+ <a href="<%= previous_page[:url] %>"
11
+ class="gem-c-pagination__link"
12
+ rel="prev"
13
+ data-track-category="contentsClicked"
14
+ data-track-action="previous"
15
+ data-track-label="<%= previous_page[:url] %>"
16
+ data-track-dimension="previous"
17
+ data-track-dimension-index="29"
18
+ >
19
+ <span class="gem-c-pagination__link-title">
20
+ <svg class="gem-c-pagination__link-icon" xmlns="http://www.w3.org/2000/svg" height="13" width="17" viewBox="0 0 17 13">
21
+ <path fill="currentColor" d="m6.5938-0.0078125-6.7266 6.7266 6.7441 6.4062 1.377-1.449-4.1856-3.9768h12.896v-2h-12.984l4.2931-4.293-1.414-1.414z"/>
22
+ </svg>
23
+ <%= previous_page[:title] %>
24
+ </span>
25
+ <% if previous_page[:label].present? %>
26
+ <span class="visually-hidden">:</span>
27
+ <span class="gem-c-pagination__link-label"><%= previous_page[:label] %></span>
28
+ <% end %>
29
+ </a>
30
+ </li>
31
+ <% end %>
32
+ <% if local_assigns.include?(:next_page) %>
33
+ <li class="gem-c-pagination__item gem-c-pagination__item--next">
34
+ <a href="<%= next_page[:url] %>"
35
+ class="gem-c-pagination__link"
36
+ rel="next"
37
+ data-track-category="contentsClicked"
38
+ data-track-action="next"
39
+ data-track-label="<%= next_page[:url] %>"
40
+ data-track-dimension="next"
41
+ data-track-dimension-index="29"
42
+ >
43
+ <span class="gem-c-pagination__link-title">
44
+ <%= next_page[:title] %>
45
+ <svg class="gem-c-pagination__link-icon" xmlns="http://www.w3.org/2000/svg" height="13" width="17" viewBox="0 0 17 13">
46
+ <path fill="currentColor" d="m10.107-0.0078125-1.4136 1.414 4.2926 4.293h-12.986v2h12.896l-4.1855 3.9766 1.377 1.4492 6.7441-6.4062-6.7246-6.7266z"/>
47
+ </svg>
48
+ </span>
49
+ <% if next_page[:label].present? %>
50
+ <span class="visually-hidden">:</span>
51
+ <span class="gem-c-pagination__link-label"><%= next_page[:label] %></span>
52
+ <% end %>
53
+ </a>
54
+ </li>
55
+ <% end %>
56
+ </ul>
57
+ </nav>
58
+ <% end %>
@@ -0,0 +1,23 @@
1
+ <%
2
+ average_title_length ||= false
3
+ context ||= false
4
+ context_text = context.is_a?(Hash) ? context[:text] : context
5
+ context_href = context.is_a?(Hash) ? context[:href] : false
6
+ context_data = context.is_a?(Hash) ? context[:data] : false
7
+
8
+ inverse ||= false
9
+ margin_bottom ||= 1
10
+ margin_bottom_class = "gem-c-title--bottom-margin" if margin_bottom == 1
11
+ %>
12
+ <div class="gem-c-title
13
+ <% if inverse %>gem-c-title--inverse<% end %>
14
+ <%= margin_bottom_class %>">
15
+ <% if context %>
16
+ <p class="gem-c-title__context">
17
+ <%= context_href ? link_to(context_text, context_href, class: 'gem-c-title__context-link', data: context_data) : context_text %>
18
+ </p>
19
+ <% end %>
20
+ <h1 class="gem-c-title__text <% if average_title_length %>gem-c-title__text--<%= average_title_length %><% end %>">
21
+ <%= title %>
22
+ </h1>
23
+ </div>
@@ -7,6 +7,7 @@ shared_accessibility_criteria:
7
7
  accessibility_criteria:
8
8
  The breadcrumb links must have a text contrast ratio higher than 4.5:1 against the background colour to meet WCAG AA
9
9
  (this especially applies when [using the inverse flag](/component-guide/breadcrumbs/inverse)).
10
+ display_html: true
10
11
  examples:
11
12
  default:
12
13
  data:
@@ -0,0 +1,18 @@
1
+ name: Government navigation
2
+ description: Navigation placed in the header by Slimmer and used by pages which sit
3
+ under the /government path. This is a markup only component and is not available
4
+ for preview here. It can be passed a string to mark a link as being active.
5
+ accessibility_criteria: |
6
+ The government navigation component must:
7
+
8
+ - Be identified as a [navigation landmark](https://www.w3.org/TR/wai-aria-practices-1.1/#aria_lh_navigation)
9
+ shared_accessibility_criteria:
10
+ - link
11
+ accessibility_excluded_rules:
12
+ - 'duplicate-id' # ids used in this component are for slimmer to use when moving this component into the header
13
+ examples:
14
+ default:
15
+ data: {}
16
+ with_active_item:
17
+ data:
18
+ active: departments
@@ -13,8 +13,8 @@ examples:
13
13
  default:
14
14
  data:
15
15
  block: |
16
- <div class="pub-c-title pub-c-title--inverse">
17
- <h1 class="pub-c-title__text ">
16
+ <div class="gem-c-title gem-c-title--inverse">
17
+ <h1 class="gem-c-title__text ">
18
18
  Education, Training and Skills
19
19
  </h1>
20
20
  </div>
@@ -23,8 +23,8 @@ examples:
23
23
  data:
24
24
  full_width: true
25
25
  block: |
26
- <div class="pub-c-title pub-c-title--inverse">
27
- <h1 class="pub-c-title__text ">
26
+ <div class="gem-c-title gem-c-title--inverse">
27
+ <h1 class="gem-c-title__text ">
28
28
  Education, Training and Skills
29
29
  </h1>
30
30
  </div>
@@ -32,9 +32,9 @@ examples:
32
32
  description: "The inverse header component is used on HTMl publications. [See example on GOV.UK here](https://www.gov.uk/government/publications/ln5-0at-jackson-homes-scopwick-ltd-environmental-permit-application-advertisement/ln5-0at-jackson-homes-scopwick-ltd-environmental-permit-application)"
33
33
  data:
34
34
  block: |
35
- <div class="pub-c-title pub-c-title--inverse pub-c-title--bottom-margin">
36
- <p class="pub-c-title__context">Notice</p>
37
- <h1 class="pub-c-title__text">
35
+ <div class="gem-c-title gem-c-title--inverse gem-c-title--bottom-margin">
36
+ <p class="gem-c-title__context">Notice</p>
37
+ <h1 class="gem-c-title__text">
38
38
  LN5 0AT, Jackson Homes (Scopwick) Ltd: environmental permit application
39
39
  </h1>
40
40
  </div>
@@ -53,11 +53,11 @@ examples:
53
53
  </li>
54
54
  </ol>
55
55
  </div>
56
- <div class="pub-c-title pub-c-title--inverse">
57
- <h1 class="pub-c-title__text ">
56
+ <div class="gem-c-title gem-c-title--inverse">
57
+ <h1 class="gem-c-title__text ">
58
58
  Education, Training and Skills
59
59
  </h1>
60
60
  </div>
61
- <p class="pub-c-lead-paragraph pub-c-lead-paragraph--inverse">
61
+ <p class="gem-c-lead-paragraph gem-c-lead-paragraph--inverse">
62
62
  Schools and academies, further and higher education, apprenticeships and other skills training, student funding, early&nbsp;years.
63
63
  </p>
@@ -0,0 +1,22 @@
1
+ name: Lead paragraph
2
+ description: The opening paragraph of content. Typically a content item’s description field.
3
+ accessibility_criteria: |
4
+ The lead paragraph must be visually distinct from other paragraphs.
5
+
6
+ The lead paragraph must have a text contrast ratio higher than 4.5:1 against the background colour to meet WCAG AA (this especially applies when [placed on a darker background](/component-guide/lead_paragraph/on_topic_page)).
7
+ examples:
8
+ default:
9
+ data:
10
+ text: 'UK Visas and Immigration is making changes to the Immigration Rules affecting various categories.'
11
+ right_to_left:
12
+ data:
13
+ text: 'قرارات تحقيقات وزارة الدفاع في الانتهاكات المزعومة للمادة ٢ والمادة ٣ من المعاهدة الاوروبية لحقوق الانسان خلال العمليات العسكرية في العراق.'
14
+ context:
15
+ right_to_left: true
16
+ on_topic_page:
17
+ description: Lead paragraphs need to support being placed on a blue background to work with the new taxonomy topic page designs
18
+ data:
19
+ text: Schools and academies, further and higher education, apprenticeships and other skills training, student funding, early years.
20
+ inverse: true
21
+ context:
22
+ dark_background: true
@@ -7,6 +7,7 @@ body: |
7
7
  The code which reads the meta tags can be found <a href="https://github.com/alphagov/static/blob/master/app/assets/javascripts/analytics/static-analytics.js#L76-L96">in static-analytics.js</a>.
8
8
  accessibility_criteria: |
9
9
  The analytics meta tags component should not be visible to any users.
10
+ display_html: true
10
11
  examples:
11
12
  with_organisations:
12
13
  data:
@@ -0,0 +1,21 @@
1
+ name: Phase (alpha & beta) banner
2
+ description: |
3
+ A banner that indicates content is in a alpha or beta phase, with an optional explanation
4
+ accessibility_criteria: |
5
+ The label must:
6
+
7
+ - have a text contrast ratio higher than 4.5:1 against the background colour to meet WCAG AA
8
+ shared_accessibility_criteria:
9
+ - link
10
+ examples:
11
+ default:
12
+ data:
13
+ phase: alpha
14
+ beta_banner:
15
+ data:
16
+ phase: beta
17
+ with_message:
18
+ data:
19
+ phase: beta
20
+ message: This is an optional different message to explain what the state means in this
21
+ context which can take <a href='https://www.gov.uk'>HTML</a>
@@ -0,0 +1,64 @@
1
+ name: Previous and next navigation
2
+ description: Navigational links that allow users to navigate within a series of pages
3
+ or elements.
4
+ body: |
5
+ This component accepts 2 optional parameters, previous and next.
6
+
7
+ Each optional parameter accepts:
8
+
9
+ - an URL for the link
10
+ - a title for the URL
11
+ - a label that can add extra info (ie page number) that will be displayed under the title
12
+
13
+ If one of the 2 parameters is nil, no link will appear.
14
+ accessibility_criteria: |
15
+ Icons in the component must not be announced by screen readers.
16
+
17
+ The component must:
18
+
19
+ - identify itself as pagination navigation
20
+ - provide a distinction between the navigation text and label text of the links both visually and for screenreaders
21
+
22
+ shared_accessibility_criteria:
23
+ - link
24
+ examples:
25
+ only_previous:
26
+ data:
27
+ previous_page:
28
+ url: previous-page
29
+ title: Previous page
30
+ label: 1 of 3
31
+ only_next:
32
+ data:
33
+ next_page:
34
+ url: next-page
35
+ title: Next page
36
+ label: Tax disc
37
+ both_previous_and_next:
38
+ data:
39
+ previous_page:
40
+ url: previous-page
41
+ title: Previous page
42
+ label: 1 of 3
43
+ next_page:
44
+ url: next-page
45
+ title: Next page
46
+ label: 3 of 3
47
+ both_previous_and_next_no_labels:
48
+ data:
49
+ previous_page:
50
+ url: previous-page
51
+ title: Previous page
52
+ next_page:
53
+ url: next-page
54
+ title: Next page
55
+ become_a_lorry_bus_driver_example:
56
+ data:
57
+ previous_page:
58
+ url: previous-page
59
+ title: Previous
60
+ label: Applying for a provisional lorry or bus licence
61
+ next_page:
62
+ url: next-page
63
+ title: Next
64
+ label: 'Driver CPC part 1 test: theory'