govuk_publishing_components 24.9.3 → 24.10.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/govuk_publishing_components/analytics/pii.js +1 -1
  3. data/app/assets/javascripts/govuk_publishing_components/analytics/scroll-tracker.js +13 -248
  4. data/app/assets/javascripts/govuk_publishing_components/components/accordion.js +1 -2
  5. data/app/assets/javascripts/govuk_publishing_components/components/cookie-banner.js +1 -0
  6. data/app/assets/javascripts/govuk_publishing_components/components/show-password.js +12 -0
  7. data/app/assets/javascripts/govuk_publishing_components/lib/trigger-event.js +18 -0
  8. data/app/assets/stylesheets/govuk_publishing_components/components/_accordion.scss +34 -34
  9. data/app/assets/stylesheets/govuk_publishing_components/components/_govspeak.scss +1 -0
  10. data/app/assets/stylesheets/govuk_publishing_components/components/_metadata.scss +15 -18
  11. data/app/assets/stylesheets/govuk_publishing_components/components/_notice.scss +4 -2
  12. data/app/assets/stylesheets/govuk_publishing_components/components/_search.scss +4 -4
  13. data/app/assets/stylesheets/govuk_publishing_components/components/_step-by-step-nav.scss +20 -20
  14. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_advisory.scss +27 -24
  15. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_attachment.scss +1 -1
  16. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_button.scss +1 -0
  17. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_call-to-action.scss +1 -0
  18. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_charts.scss +1 -0
  19. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_contact.scss +1 -0
  20. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_example.scss +1 -0
  21. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_footnotes.scss +1 -0
  22. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_form-download.scss +19 -16
  23. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_fraction.scss +1 -0
  24. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_highlight-answer.scss +30 -27
  25. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_images.scss +1 -0
  26. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_information-callout.scss +1 -0
  27. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_legislative-list.scss +1 -0
  28. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_place.scss +26 -21
  29. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_stat-headline.scss +1 -0
  30. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_steps.scss +19 -16
  31. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_summary.scss +21 -18
  32. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_tables.scss +1 -0
  33. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_typography.scss +1 -0
  34. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_warning-callout.scss +1 -0
  35. data/app/assets/stylesheets/govuk_publishing_components/components/helpers/_px-to-em.scss +2 -0
  36. data/app/views/govuk_publishing_components/components/_government_navigation.html.erb +7 -7
  37. data/app/views/govuk_publishing_components/components/_layout_header.html.erb +1 -1
  38. data/app/views/govuk_publishing_components/components/_metadata.html.erb +9 -8
  39. data/app/views/govuk_publishing_components/components/_notice.html.erb +1 -1
  40. data/app/views/govuk_publishing_components/components/_phase_banner.html.erb +1 -5
  41. data/app/views/govuk_publishing_components/components/_previous_and_next_navigation.html.erb +1 -1
  42. data/app/views/govuk_publishing_components/components/_radio.html.erb +6 -11
  43. data/app/views/govuk_publishing_components/components/_show_password.html.erb +2 -0
  44. data/app/views/govuk_publishing_components/components/_step_by_step_nav.html.erb +4 -4
  45. data/app/views/govuk_publishing_components/components/_step_by_step_nav_related.html.erb +1 -1
  46. data/app/views/govuk_publishing_components/components/_subscription_links.html.erb +1 -1
  47. data/app/views/govuk_publishing_components/components/_success_alert.html.erb +1 -1
  48. data/app/views/govuk_publishing_components/components/docs/phase_banner.yml +2 -2
  49. data/app/views/govuk_publishing_components/components/docs/show_password.yml +10 -0
  50. data/app/views/govuk_publishing_components/components/layout_header/_navigation_items.html.erb +1 -1
  51. data/app/views/govuk_publishing_components/components/metadata/_sentence.html.erb +2 -2
  52. data/app/views/govuk_publishing_components/components/related_navigation/_section.html.erb +2 -2
  53. data/config/locales/en.yml +11 -3
  54. data/lib/govuk_publishing_components/presenters/breadcrumb_selector.rb +5 -0
  55. data/lib/govuk_publishing_components/presenters/contextual_navigation.rb +4 -0
  56. data/lib/govuk_publishing_components/version.rb +1 -1
  57. metadata +17 -3
  58. data/app/assets/javascripts/component_guide/visual-regression.js +0 -71
@@ -10,7 +10,7 @@
10
10
 
11
11
  shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)
12
12
 
13
- css_classes = %w(gem-c-notice)
13
+ css_classes = %w[gem-c-notice]
14
14
  css_classes << (shared_helper.get_margin_bottom)
15
15
 
16
16
  aria_attributes = aria_live ? {label: 'Notice', live: 'polite'} : {label: 'Notice'}
@@ -4,10 +4,6 @@ phase ||= nil
4
4
  message ||= nil
5
5
  inverse ||= false
6
6
 
7
- unless phase.in?(%w[alpha beta])
8
- raise ArgumentError, "The phase banner component expects a `phase` (`beta` or `alpha`), #{phase.inspect} given"
9
- end
10
-
11
7
  unless message.present?
12
8
  if phase == "beta"
13
9
  message = raw("This part of GOV.UK is being rebuilt &ndash; <a class=\"govuk-link\" href=\"/help/beta\">find out what beta means</a>")
@@ -23,7 +19,7 @@ container_css_classes << "gem-c-phase-banner--inverse" if inverse
23
19
  <%= tag.div class: container_css_classes do %>
24
20
  <%= tag.p class: "govuk-phase-banner__content" do %>
25
21
  <%= tag.strong app_name, class: "govuk-phase-banner__content__app-name" if app_name %>
26
- <%= tag.strong phase, class: "govuk-tag govuk-phase-banner__content__tag" %>
22
+ <%= tag.strong phase, class: "govuk-tag govuk-phase-banner__content__tag" if phase %>
27
23
  <%= tag.span message, class: "govuk-phase-banner__text" if message %>
28
24
  <% end %>
29
25
  <% end %>
@@ -2,7 +2,7 @@
2
2
  <nav
3
3
  class="gem-c-pagination"
4
4
  role="navigation"
5
- aria-label="<%= t("govuk_component.previous_and_next_navigation.pagination", default: "Pagination") %>"
5
+ aria-label="<%= t("components.previous_and_next_navigation.pagination", default: "Pagination") %>"
6
6
  >
7
7
  <ul class="gem-c-pagination__list" data-module="gem-track-click">
8
8
  <% if local_assigns.include?(:previous_page) %>
@@ -11,6 +11,9 @@
11
11
  small ||= false
12
12
  inline ||= false
13
13
  is_page_heading ||= false
14
+ heading_level = is_page_heading ? 'h1' : shared_helper.get_heading_level
15
+ heading_classes = %w(govuk-fieldset__heading)
16
+ heading_classes << "gem-c-radio__heading-text" if heading_level == 'h1'
14
17
 
15
18
  if ['s', 'm', 'l', 'xl'].include?(heading_size)
16
19
  size = heading_size
@@ -46,20 +49,12 @@
46
49
  %>
47
50
  <%= tag.div id: id, class: form_group_css_classes do %>
48
51
  <%= tag.fieldset class: "govuk-fieldset", "aria-describedby": aria do %>
49
-
50
52
  <% if heading.present? %>
51
- <% if is_page_heading %>
52
- <%= tag.legend class: legend_classes do %>
53
- <%= tag.span(heading_caption, class: "govuk-caption-#{size}") if heading_caption.present? %>
54
- <%= tag.h1 heading, class: "gem-c-radio__heading-text govuk-fieldset__heading" %>
55
- <% end %>
56
- <% else %>
57
- <%= tag.legend class: legend_classes do %>
58
- <%= content_tag(shared_helper.get_heading_level, heading, class: "govuk-fieldset__heading") %>
59
- <% end %>
53
+ <%= tag.legend class: legend_classes do %>
54
+ <%= tag.span(heading_caption, class: "govuk-caption-#{size}") if heading_caption.present? %>
55
+ <%= content_tag(heading_level, heading, class: heading_classes) %>
60
56
  <% end %>
61
57
  <% end %>
62
-
63
58
  <% if description.present? %>
64
59
  <%= tag.div description, class: "govuk-body" %>
65
60
  <% end %>
@@ -9,6 +9,7 @@
9
9
  hint ||= nil
10
10
  error_message ||= nil
11
11
  error_items ||= nil
12
+ data ||= nil
12
13
 
13
14
  if !label
14
15
  raise ArgumentError, "This component requires a label"
@@ -37,6 +38,7 @@
37
38
  error_items: error_items,
38
39
  type: "password",
39
40
  autocomplete: autocomplete,
41
+ data: data,
40
42
  } %>
41
43
  <% end %>
42
44
  <% end %>
@@ -22,10 +22,10 @@
22
22
  class="gem-c-step-nav js-hidden <% unless small %>gem-c-step-nav--large<% end %>"
23
23
  <%= "data-remember" if remember_last_step %>
24
24
  <%= "data-id=#{tracking_id}" if tracking_id %>
25
- data-show-text="<%= t("govuk_component.step_by_step_nav.show", default: "show") %>"
26
- data-hide-text="<%= t("govuk_component.step_by_step_nav.hide", default: "hide") %>"
27
- data-show-all-text="<%= t("govuk_component.step_by_step_nav.show_all", default: "Show all steps") %>"
28
- data-hide-all-text="<%= t("govuk_component.step_by_step_nav.hide_all", default: "Hide all steps") %>"
25
+ data-show-text="<%= t("components.step_by_step_nav.show", default: "show") %>"
26
+ data-hide-text="<%= t("components.step_by_step_nav.hide", default: "hide") %>"
27
+ data-show-all-text="<%= t("components.step_by_step_nav.show_all", default: "Show all steps") %>"
28
+ data-hide-all-text="<%= t("components.step_by_step_nav.hide_all", default: "Hide all steps") %>"
29
29
  >
30
30
  <ol class="gem-c-step-nav__steps">
31
31
  <% steps.each_with_index do |step, step_index| %>
@@ -1,6 +1,6 @@
1
1
  <%
2
2
  links ||= []
3
- pretitle ||= t("govuk_component.step_by_step_nav_related.part_of", default: "Part of")
3
+ pretitle ||= t("components.step_by_step_nav_related.part_of", default: "Part of")
4
4
  always_display_as_list ||= false
5
5
  %>
6
6
  <% if links.any? %>
@@ -23,7 +23,7 @@
23
23
  <% if sl_helper.component_data_is_valid? %>
24
24
  <%= tag.section class: css_classes, data: data do %>
25
25
  <% unless hide_heading %>
26
- <h2 class="gem-c-subscription-links__hidden-header visuallyhidden"><%= t("govuk_component.subscription_links.subscriptions", default: "Subscriptions") %></h2>
26
+ <h2 class="gem-c-subscription-links__hidden-header visuallyhidden"><%= t("components.subscription_links.subscriptions", default: "Subscriptions") %></h2>
27
27
  <% end %>
28
28
  <ul
29
29
  class="gem-c-subscription-links__list<%= ' gem-c-subscription-links__list--small' if local_assigns[:small_form] == true %>"
@@ -13,7 +13,7 @@
13
13
  module: "initial-focus",
14
14
  } do %>
15
15
  <div class="govuk-notification-banner__header">
16
- <%= tag.h2 t("govuk_component.success_alert.success", default: "Success"), class: "govuk-notification-banner__title", id: title_id %>
16
+ <%= tag.h2 t("components.success_alert.success", default: "Success"), class: "govuk-notification-banner__title", id: title_id %>
17
17
  </div>
18
18
  <div class="govuk-notification-banner__content">
19
19
  <% if description.present? %>
@@ -1,6 +1,6 @@
1
- name: Phase (alpha & beta) banner
1
+ name: Phase banner
2
2
  description: |
3
- A banner that indicates content is in a alpha or beta phase, with an optional explanation
3
+ A banner that indicates content is in a certain phase (usually alpha or beta), with an optional explanation
4
4
  accessibility_criteria: |
5
5
  The label must:
6
6
 
@@ -79,3 +79,13 @@ examples:
79
79
  error_items:
80
80
  - text: Look I keep telling you
81
81
  - text: This isn't your password
82
+ with_data_attributes:
83
+ description: Data attributes can be passed to add to the input element. If the data attribute starts with `data-button-` this attribute will be applied to the show/hide button, instead of the input. Note that if JS is disabled, all attributes are added to the input.
84
+ data:
85
+ label:
86
+ text: Your password
87
+ data:
88
+ example_1: value
89
+ example_2: thing
90
+ button_example_1: wotsit
91
+ button_example_2: doodad
@@ -7,7 +7,7 @@
7
7
  class="govuk-header__menu-button govuk-js-header-toggle gem-c-header__menu-button"
8
8
  type="button"
9
9
  >
10
- Menu
10
+ <%= t("components.layout_header.menu") %>
11
11
  </button>
12
12
  <%= tag.nav class: "gem-c-header__nav", aria: { label: navigation_aria_label } do %>
13
13
  <ul id="navigation" class="govuk-header__navigation govuk-header__navigation--end">
@@ -13,8 +13,8 @@
13
13
  class="gem-c-metadata__definition-link"
14
14
  data-controls="toggle-<%= toggle_id %>"
15
15
  data-expanded="false"
16
- data-toggled-text="<%= t("govuk_component.metadata.toggle_less", default: "Show fewer") %>">
17
- <%= t("govuk_component.metadata.toggle_more", number: remaining.length, default: "+ #{remaining.length} more") %>
16
+ data-toggled-text="<%= t("components.metadata.toggle_less", default: "Show fewer") %>">
17
+ <%= t("components.metadata.toggle_more", number: remaining.length, default: "+ #{remaining.length} more") %>
18
18
  </a>
19
19
  </div>
20
20
  <span id="toggle-<%= toggle_id %>" class="gem-c-metadata__toggle-items js-hidden"><%= remaining.to_sentence.html_safe %></span>
@@ -54,8 +54,8 @@
54
54
  class="gem-c-related-navigation__toggle"
55
55
  data-controls="toggle_<%= section_title %>"
56
56
  data-expanded="false"
57
- data-toggled-text="<%= t("govuk_component.metadata.toggle_less", default: "Show fewer") %>">
58
- <%= t("govuk_component.metadata.toggle_more",
57
+ data-toggled-text="<%= t("components.metadata.toggle_less", default: "Show fewer") %>">
58
+ <%= t("components.metadata.toggle_more",
59
59
  number: related_nav_helper.remaining_link_count(links),
60
60
  default: "+ #{related_nav_helper.remaining_link_count(links)} more") %>
61
61
  </a>
@@ -44,8 +44,8 @@ en:
44
44
  contents: "Contents"
45
45
  feedback:
46
46
  is_this_page_useful: "Is this page useful?"
47
- yes: "Yes"
48
- no: "No"
47
+ "yes": "Yes"
48
+ "no": "No"
49
49
  maybe: "Maybe"
50
50
  is_useful: "this page is useful"
51
51
  is_not_useful: "this page is not useful"
@@ -65,8 +65,16 @@ en:
65
65
  show_button: "Show search"
66
66
  hide_button: "Hide search"
67
67
  top_level: "Top level"
68
- nav_items_aria_label: "Show or hide Top Level Navigation"
69
68
  menu: "Menu"
69
+ metadata:
70
+ from: "From"
71
+ part_of: "Part of"
72
+ history: "History"
73
+ published: "Published"
74
+ last_updated: "Last updated"
75
+ see_all_updates: "See all updates"
76
+ toggle_less: "Show fewer"
77
+ toggle_more: "+ %{number} more"
70
78
  organisation_schema:
71
79
  all_content_search_description: "Find all content from %{organisation}"
72
80
  radio:
@@ -60,6 +60,11 @@ module GovukPublishingComponents
60
60
  step_by_step: false,
61
61
  breadcrumbs: navigation.breadcrumbs,
62
62
  }
63
+ elsif navigation.content_is_travel_advice?
64
+ {
65
+ step_by_step: false,
66
+ breadcrumbs: navigation.breadcrumbs,
67
+ }
63
68
  elsif navigation.content_has_a_topic?
64
69
  {
65
70
  step_by_step: false,
@@ -16,6 +16,10 @@ module GovukPublishingComponents
16
16
  content_item["document_type"] == "simple_smart_answer"
17
17
  end
18
18
 
19
+ def content_is_travel_advice?
20
+ content_item["document_type"] == "travel_advice"
21
+ end
22
+
19
23
  def html_publication_with_parent?
20
24
  (content_item["document_type"] == "html_publication") && parent_api_path
21
25
  end
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = "24.9.3".freeze
2
+ VERSION = "24.10.3".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: 24.9.3
4
+ version: 24.10.3
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: 2021-04-22 00:00:00.000000000 Z
11
+ date: 2021-05-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: govuk_app_config
@@ -164,6 +164,20 @@ dependencies:
164
164
  - - "~>"
165
165
  - !ruby/object:Gem::Version
166
166
  version: '2'
167
+ - !ruby/object:Gem::Dependency
168
+ name: i18n-coverage
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
167
181
  - !ruby/object:Gem::Dependency
168
182
  name: jasmine
169
183
  requirement: !ruby/object:Gem::Requirement
@@ -416,7 +430,6 @@ files:
416
430
  - app/assets/javascripts/component_guide/filter-components.js
417
431
  - app/assets/javascripts/component_guide/vendor/bind-polyfill.js
418
432
  - app/assets/javascripts/component_guide/vendor/matches-polyfill.min.js
419
- - app/assets/javascripts/component_guide/visual-regression.js
420
433
  - app/assets/javascripts/govuk_publishing_components/all_components.js
421
434
  - app/assets/javascripts/govuk_publishing_components/analytics.js
422
435
  - app/assets/javascripts/govuk_publishing_components/analytics/analytics.js
@@ -469,6 +482,7 @@ files:
469
482
  - app/assets/javascripts/govuk_publishing_components/lib/toggle-input-class-on-focus.js
470
483
  - app/assets/javascripts/govuk_publishing_components/lib/toggle.js
471
484
  - app/assets/javascripts/govuk_publishing_components/lib/track-click.js
485
+ - app/assets/javascripts/govuk_publishing_components/lib/trigger-event.js
472
486
  - app/assets/javascripts/govuk_publishing_components/modules.js
473
487
  - app/assets/javascripts/govuk_publishing_components/vendor/html5shiv-printshiv.js
474
488
  - app/assets/javascripts/govuk_publishing_components/vendor/json2.js
@@ -1,71 +0,0 @@
1
- (function (window, document) {
2
- window.GOVUK = window.GOVUK || {}
3
-
4
- window.GOVUK.VisualDiffTool = function (currentWindowLocation) {
5
- var visualDiffSelector = 'visual-diff'
6
- var existingIframe = document.getElementById(visualDiffSelector)
7
- var windowLocation = currentWindowLocation || window.location
8
-
9
- if (existingIframe) {
10
- existingIframe.parentNode.removeChild(existingIframe)
11
- document.body.style.filter = null
12
- } else {
13
- var iframe = document.createElement('iframe')
14
- iframe.id = visualDiffSelector
15
- iframe.setAttribute('scrolling', 'no')
16
- _setElementStyles(iframe, {
17
- width: '100%',
18
- height: document.body.scrollHeight + 'px',
19
- position: 'absolute',
20
- top: '0',
21
- 'pointer-events': 'none',
22
- border: '0'
23
- })
24
- iframe.style.setProperty('z-index', '999', 'important')
25
-
26
- // For browsers that support it, do mix-blend-mode diff
27
- if ('mix-blend-mode' in document.body.style) {
28
- _setElementStyles(iframe, { 'mix-blend-mode': 'difference' })
29
- document.body.style.filter = 'invert(100%)'
30
- } else {
31
- // Else do a simple overlay of the live page for comparison (IE and Edge)
32
- _setElementStyles(iframe, { opacity: '0.7' })
33
- }
34
-
35
- iframe.src = _processComparisonURL(windowLocation)
36
-
37
- if (iframe.src) {
38
- document.body.appendChild(iframe)
39
- console.log('comparing to ' + iframe.src)
40
- }
41
- }
42
- }
43
-
44
- var _processComparisonURL = function (url) {
45
- var appName
46
- var href = url.href
47
- var host = url.host
48
-
49
- if (href.includes('dev.gov.uk/component-guide')) {
50
- appName = host.split('.')[0]
51
- return _forceHTTPS(href.replace(host, appName + '.herokuapp.com'))
52
- } else if (href.includes('dev.gov.uk')) {
53
- return _forceHTTPS(href.replace(host, 'www.gov.uk'))
54
- } else if (href.includes('-pr-')) {
55
- appName = host.split('-pr')[0]
56
- return _forceHTTPS(href.replace(host, appName + '.herokuapp.com'))
57
- } else {
58
- throw new Error('Visual Diff Tool: You need to run this tool against a page running on your local dev environment')
59
- }
60
- }
61
-
62
- var _forceHTTPS = function (href) {
63
- return href.replace('http://', 'https://')
64
- }
65
-
66
- var _setElementStyles = function (element, styles) {
67
- for (var style in styles) {
68
- element.style[style] = styles[style]
69
- }
70
- }
71
- })(window, document)