govuk_publishing_components 24.0.0 → 24.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/govuk_publishing_components/analytics/scroll-tracker.js +28 -0
  3. data/app/assets/javascripts/govuk_publishing_components/components/accordion.js +330 -4
  4. data/app/assets/javascripts/govuk_publishing_components/components/cookie-banner.js +26 -6
  5. data/app/assets/javascripts/govuk_publishing_components/vendor/polyfills/common.js +8 -0
  6. data/app/assets/stylesheets/component_guide/application.scss +0 -8
  7. data/app/assets/stylesheets/govuk_publishing_components/components/_accordion.scss +298 -14
  8. data/app/assets/stylesheets/govuk_publishing_components/components/_cookie-banner.scss +11 -84
  9. data/app/assets/stylesheets/govuk_publishing_components/components/_layout-header.scss +21 -5
  10. data/app/assets/stylesheets/govuk_publishing_components/components/_search.scss +17 -13
  11. data/app/assets/stylesheets/govuk_publishing_components/components/_step-by-step-nav.scss +4 -0
  12. data/app/assets/stylesheets/govuk_publishing_components/components/print/_accordion.scss +17 -9
  13. data/app/assets/stylesheets/govuk_publishing_components/govuk_frontend_support.scss +1 -11
  14. data/app/models/govuk_publishing_components/audit_applications.rb +2 -2
  15. data/app/models/govuk_publishing_components/audit_comparer.rb +2 -2
  16. data/app/models/govuk_publishing_components/component_example.rb +4 -3
  17. data/app/views/govuk_publishing_components/audit/show.html.erb +211 -199
  18. data/app/views/govuk_publishing_components/components/_accordion.html.erb +15 -22
  19. data/app/views/govuk_publishing_components/components/_attachment.html.erb +3 -3
  20. data/app/views/govuk_publishing_components/components/_breadcrumbs.html.erb +1 -1
  21. data/app/views/govuk_publishing_components/components/_contents_list.html.erb +1 -1
  22. data/app/views/govuk_publishing_components/components/_cookie_banner.html.erb +50 -39
  23. data/app/views/govuk_publishing_components/components/_highlight_boxes.html.erb +1 -1
  24. data/app/views/govuk_publishing_components/components/_image_card.html.erb +1 -1
  25. data/app/views/govuk_publishing_components/components/_layout_footer.html.erb +1 -1
  26. data/app/views/govuk_publishing_components/components/_metadata.html.erb +1 -1
  27. data/app/views/govuk_publishing_components/components/_organisation_logo.html.erb +1 -1
  28. data/app/views/govuk_publishing_components/components/_previous_and_next_navigation.html.erb +1 -1
  29. data/app/views/govuk_publishing_components/components/_share_links.html.erb +1 -1
  30. data/app/views/govuk_publishing_components/components/_step_by_step_nav_header.html.erb +1 -1
  31. data/app/views/govuk_publishing_components/components/_step_by_step_nav_related.html.erb +1 -1
  32. data/app/views/govuk_publishing_components/components/_subscription_links.html.erb +1 -1
  33. data/app/views/govuk_publishing_components/components/_taxonomy_list.html.erb +1 -1
  34. data/app/views/govuk_publishing_components/components/_translation_nav.html.erb +1 -1
  35. data/app/views/govuk_publishing_components/components/attachment/{_thumbnail_document.svg → _thumbnail_document.html.erb} +0 -0
  36. data/app/views/govuk_publishing_components/components/attachment/{_thumbnail_generic.svg → _thumbnail_generic.html.erb} +0 -0
  37. data/app/views/govuk_publishing_components/components/attachment/{_thumbnail_spreadsheet.svg → _thumbnail_spreadsheet.html.erb} +0 -0
  38. data/app/views/govuk_publishing_components/components/contextual_sidebar/_brexit_cta.html.erb +1 -1
  39. data/app/views/govuk_publishing_components/components/docs/accordion.yml +37 -3
  40. data/app/views/govuk_publishing_components/components/docs/cookie_banner.yml +9 -0
  41. data/app/views/govuk_publishing_components/components/docs/inverse_header.yml +1 -1
  42. data/app/views/govuk_publishing_components/components/layout_header/_header_logo.html.erb +1 -1
  43. data/app/views/govuk_publishing_components/components/layout_header/_navigation_items.html.erb +2 -0
  44. data/app/views/govuk_publishing_components/components/related_navigation/_section.html.erb +2 -2
  45. data/lib/govuk_publishing_components/app_helpers/table_helper.rb +2 -1
  46. data/lib/govuk_publishing_components/presenters/machine_readable/faq_page_schema.rb +1 -1
  47. data/lib/govuk_publishing_components/presenters/machine_readable/html_publication_schema.rb +1 -7
  48. data/lib/govuk_publishing_components/presenters/meta_tags.rb +1 -2
  49. data/lib/govuk_publishing_components/presenters/related_navigation_helper.rb +2 -2
  50. data/lib/govuk_publishing_components/version.rb +1 -1
  51. data/lib/tasks/govuk_publishing_components_tasks.rake +1 -1
  52. metadata +11 -10
@@ -5,43 +5,36 @@
5
5
  id ||= "default-id-#{SecureRandom.hex(4)}"
6
6
  items ||= []
7
7
  condensed ||= false
8
+ anchor_navigation ||= false
8
9
 
9
- accordion_classes = %w(gem-c-accordion govuk-accordion)
10
- accordion_classes << 'govuk-accordion--condensed' if condensed
10
+ accordion_classes = %w(gem-c-accordion)
11
+ accordion_classes << 'gem-c-accordion--condensed' if condensed
11
12
  accordion_classes << (shared_helper.get_margin_bottom)
12
13
 
13
14
  data_attributes ||= {}
14
- data_attributes[:module] = 'govuk-accordion'
15
+ data_attributes[:module] = 'gem-accordion'
16
+ data_attributes[:anchor_navigation] = anchor_navigation
15
17
  %>
16
18
  <% if items.any? %>
17
19
  <%= tag.div(class: accordion_classes, id: id, data: data_attributes) do %>
18
20
  <% items.each_with_index do |item, i| %>
19
21
  <%
20
- # Nunjucks starts a loop on 1 and the client side JavaScript also
21
- # adopts this behaviour. To prevent things from breaking, the index
22
- # here also need to be increase by one. (Nunjucks is used by GOV.UK
23
- # Frontend, which this component is based on.)
24
22
  index = i + 1
25
23
 
26
- item[:data_attributes] ||= nil
24
+ section_classes = %w(gem-c-accordion__section)
25
+ section_classes << 'gem-c-accordion__section--expanded' if item[:expanded]
27
26
 
28
- section_classes = %w(govuk-accordion__section)
29
- section_classes << 'govuk-accordion__section--expanded' if item[:expanded]
30
-
31
- summary_classes = %w(govuk-accordion__section-summary govuk-body)
27
+ summary_classes = %w(gem-c-accordion__section-summary govuk-body)
32
28
  %>
33
- <%= tag.div(class: section_classes) do %>
34
- <div class="govuk-accordion__section-header">
35
- <%=
36
- content_tag(
37
- shared_helper.get_heading_level,
38
- content_tag('span', item[:heading][:text], class: "govuk-accordion__section-button", id: "#{id}-heading-#{index}", data: item[:data_attributes]),
39
- class: 'govuk-accordion__section-heading'
40
- )
41
- %>
29
+
30
+ <%= tag.section(class: section_classes) do %>
31
+ <div class="gem-c-accordion__section-header">
32
+ <%= content_tag(shared_helper.get_heading_level, class: 'gem-c-accordion__section-heading', id: item[:heading][:id]) do %>
33
+ <%= tag.span(item[:heading][:text], id: "#{id}-heading-#{index}", data: item[:data_attributes], class: 'gem-c-accordion__section-button') %>
34
+ <% end %>
42
35
  <%= tag.div(item[:summary][:text], id: "#{id}-summary-#{index}", class: summary_classes) if item[:summary].present? %>
43
36
  </div>
44
- <%= tag.div(item[:content][:html], id: "#{id}-content-#{index}", class: "govuk-accordion__section-content", 'aria-labelledby': "#{id}-heading-#{index}") %>
37
+ <%= tag.div(item[:content][:html], id: "#{id}-content-#{index}", class: "gem-c-accordion__section-content", 'aria-label': "#{item[:heading][:text]}") %>
45
38
  <% end %>
46
39
  <% end %>
47
40
  <% end %>
@@ -41,11 +41,11 @@
41
41
  "aria-hidden": true,
42
42
  data: data_attributes do %>
43
43
  <% if attachment.document? %>
44
- <%= render "govuk_publishing_components/components/attachment/thumbnail_document.svg" %>
44
+ <%= render "govuk_publishing_components/components/attachment/thumbnail_document" %>
45
45
  <% elsif attachment.spreadsheet? %>
46
- <%= render "govuk_publishing_components/components/attachment/thumbnail_spreadsheet.svg" %>
46
+ <%= render "govuk_publishing_components/components/attachment/thumbnail_spreadsheet" %>
47
47
  <% else %>
48
- <%= render "govuk_publishing_components/components/attachment/thumbnail_generic.svg" %>
48
+ <%= render "govuk_publishing_components/components/attachment/thumbnail_generic" %>
49
49
  <% end %>
50
50
  <% end %>
51
51
  <% end %>
@@ -13,7 +13,7 @@
13
13
  <%= raw JSON.pretty_generate(breadcrumb_presenter.structured_data) %>
14
14
  </script>
15
15
 
16
- <div class="<%= classes %>" data-module="track-click">
16
+ <div class="<%= classes %>" data-module="gem-track-click">
17
17
  <ol class="govuk-breadcrumbs__list">
18
18
  <% breadcrumbs.each_with_index do |crumb, index| %>
19
19
  <% breadcrumb = GovukPublishingComponents::Presenters::Breadcrumb.new(crumb, index) %>
@@ -15,7 +15,7 @@
15
15
  "aria-label": aria_label,
16
16
  role: "navigation",
17
17
  data: {
18
- module: "track-click"
18
+ module: "gem-track-click"
19
19
  }
20
20
  ) do %>
21
21
  <%= content_tag(
@@ -1,72 +1,83 @@
1
1
  <%
2
2
  id ||= 'global-cookie-message'
3
- title ||= "Tell us whether you accept cookies"
4
- text ||= raw("We use <a class='govuk-link' href='/help/cookies'>cookies to collect information</a> about how you use GOV.UK. We use this information to make the website work as well as possible and improve government services.")
3
+ title ||= "Cookies on GOV.UK"
4
+ text ||= ["We use some essential cookies to make this website work.", "We’d like to set additional cookies to understand how you use GOV.UK, remember your settings and improve government services.", "We also use cookies set by other sites to help us deliver content from their services."]
5
+ if text.kind_of?(Array)
6
+ newtext = ""
7
+ text.each do |t|
8
+ newtext += "<p class='govuk-body'>#{t}</p>"
9
+ end
10
+ text = newtext
11
+ else
12
+ text = "<p class='govuk-body'>#{text}</p>"
13
+ end
14
+ text = raw(text)
15
+
5
16
  cookie_preferences_href ||= "/help/cookies"
6
- confirmation_message ||= raw("You’ve accepted all cookies. You can <a class='govuk-link' href='#{cookie_preferences_href}' data-module='track-click' data-track-category='cookieBanner' data-track-action='Cookie banner settings clicked from confirmation'>change your cookie settings</a> at any time.")
17
+ confirmation_message ||= raw("You can <a class='govuk-link' href='#{cookie_preferences_href}' data-module='gem-track-click' data-track-category='cookieBanner' data-track-action='Cookie banner settings clicked from confirmation'>change your cookie settings</a> at any time.")
7
18
  services_cookies ||= nil
8
19
  css_classes = %w(gem-c-cookie-banner govuk-clearfix)
9
20
  css_classes << "gem-c-cookie-banner--services" if services_cookies
10
21
  %>
11
-
12
22
  <div id="<%= id %>" class="<%= css_classes.join(' ') %>" data-module="cookie-banner" role="region" aria-label="cookie banner" data-nosnippet>
13
- <div class="gem-c-cookie-banner__wrapper govuk-width-container">
14
- <div class="govuk-grid-row">
15
- <div class="govuk-grid-column-two-thirds">
16
- <div class="gem-c-cookie-banner__message">
17
- <h2 class="govuk-heading-m"><%= title %></h2>
18
- <p class="govuk-body"><%= text %></p>
23
+ <div class="govuk-cookie-banner js-banner-wrapper" role="region" aria-label="<%= title %>">
24
+ <div class="gem-c-cookie-banner__message govuk-cookie-banner__message govuk-width-container">
25
+ <div class="govuk-grid-row">
26
+ <div class="govuk-grid-column-two-thirds">
27
+ <h2 class="govuk-cookie-banner__heading govuk-heading-m"><%= title %></h2>
28
+ <div class="govuk-cookie-banner__content">
29
+ <%= text %>
30
+ </div>
19
31
  </div>
20
- <% if services_cookies %>
21
- <div class="gem-c-cookie-banner__buttons gem-c-cookie-banner__buttons--flex">
32
+ </div>
33
+ <% if services_cookies %>
34
+ <div class="govuk-button-group">
22
35
  <%= render "govuk_publishing_components/components/button", {
36
+ name: "cookies",
23
37
  text: services_cookies.dig(:yes, :text) || "Yes",
24
- inline_layout: true,
25
- data_attributes: { module: "track-click", "accept-cookies": "true", }.merge(services_cookies.dig(:yes, :data_attributes) || {})
38
+ data_attributes: { module: "gem-track-click", "accept-cookies": "true", }.merge(services_cookies.dig(:yes, :data_attributes) || {})
26
39
  } %>
27
40
  <%= render "govuk_publishing_components/components/button", {
41
+ name: "cookies",
28
42
  text: services_cookies.dig(:no, :text) || "No",
29
- inline_layout: true,
30
- data_attributes: { module: "track-click", "hide-cookie-banner": "true", }.merge(services_cookies.dig(:no, :data_attributes) || {})
43
+ data_attributes: { module: "gem-track-click", "reject-cookies": "true", }.merge(services_cookies.dig(:no, :data_attributes) || {})
31
44
  } %>
32
45
  <% if services_cookies[:cookie_preferences] %>
33
- <%= link_to services_cookies.dig(:cookie_preferences, :text), services_cookies.dig(:cookie_preferences, :href), class: "gem-c-cookie-banner__link govuk-link" %>
46
+ <%= link_to services_cookies.dig(:cookie_preferences, :text), services_cookies.dig(:cookie_preferences, :href), class: "govuk-link" %>
34
47
  <% end %>
35
48
  </div>
36
49
  <% else %>
37
- <div class="gem-c-cookie-banner__buttons">
38
- <div class="gem-c-cookie-banner__button gem-c-cookie-banner__button-accept govuk-grid-column-full govuk-grid-column-one-half-from-desktop">
39
- <%= render "govuk_publishing_components/components/button", {
40
- text: "Accept all cookies",
41
- inline_layout: true,
50
+ <div class="govuk-button-group">
51
+ <%= render "govuk_publishing_components/components/button", {
52
+ name: "cookies",
53
+ text: "Accept additional cookies",
42
54
  data_attributes: {
43
- module: "track-click",
55
+ module: "gem-track-click",
44
56
  "accept-cookies": "true",
45
57
  "track-category": "cookieBanner",
46
- "track-action": "Cookie banner accepted"
58
+ "track-action": "Cookie banner accepted",
59
+ "cookie-types": "all",
47
60
  }
48
- } %>
49
- </div>
50
- <div class="gem-c-cookie-banner__button gem-c-cookie-banner__button-settings govuk-grid-column-full govuk-grid-column-one-half-from-desktop">
51
- <%= render "govuk_publishing_components/components/button", {
52
- text: "Set cookie preferences",
53
- href: cookie_preferences_href,
54
- inline_layout: true,
61
+ } %>
62
+ <%= render "govuk_publishing_components/components/button", {
63
+ name: "cookies",
64
+ text: "Reject additional cookies",
55
65
  data_attributes: {
56
- module: "track-click",
66
+ module: "gem-track-click",
67
+ "reject-cookies": "true",
57
68
  "track-category": "cookieBanner",
58
- "track-action": "Cookie banner settings clicked"
69
+ "track-action": "Cookie banner rejected",
59
70
  }
60
- } %>
61
- </div>
71
+ } %>
72
+ <a class="govuk-link" href="<%= cookie_preferences_href %>">View cookies</a>
62
73
  </div>
63
74
  <% end %>
64
- </div>
65
75
  </div>
66
76
  </div>
67
-
68
- <div class="gem-c-cookie-banner__confirmation govuk-width-container" tabindex="-1">
77
+ <div class="gem-c-cookie-banner__confirmation govuk-width-container" tabindex="-1" hidden>
69
78
  <p class="gem-c-cookie-banner__confirmation-message" role="alert"><%= confirmation_message %></p>
70
- <button class="gem-c-cookie-banner__hide-button" data-hide-cookie-banner="true" data-module="track-click" data-track-category="cookieBanner" data-track-action="Hide cookie banner">Hide</button>
79
+ <div class="govuk-button-group">
80
+ <button class="gem-c-cookie-banner__hide-button govuk-button" data-hide-cookie-banner="true" data-module="gem-track-click" data-track-category="cookieBanner" data-track-action="Hide cookie banner">Hide this message</button>
81
+ </div>
71
82
  </div>
72
83
  </div>
@@ -9,7 +9,7 @@
9
9
  %>
10
10
  <% if items.any? %>
11
11
  <% unless within_multitype_list %>
12
- <ol class="gem-c-highlight-boxes" <%= "data-module=track-click" if highlight_boxes_helper.data_tracking? %>>
12
+ <ol class="gem-c-highlight-boxes" <%= "data-module=gem-track-click" if highlight_boxes_helper.data_tracking? %>>
13
13
  <% end %>
14
14
  <% items.each do |content_item| %>
15
15
  <li class="gem-c-highlight-boxes__item-wrapper <%= half_width_class %>">
@@ -9,7 +9,7 @@
9
9
  %>
10
10
  <% if card_helper.href || card_helper.extra_links.any? %>
11
11
  <div class="<%= classes %> <%= brand_helper.brand_class %>"
12
- <%= "data-module=track-click" if card_helper.is_tracking? %>
12
+ <%= "data-module=gem-track-click" if card_helper.is_tracking? %>
13
13
  <%= "lang=#{card_helper.lang}" if card_helper.lang %>>
14
14
  <div class="gem-c-image-card__text-wrapper">
15
15
  <div class="gem-c-image-card__header-and-context-wrapper">
@@ -6,7 +6,7 @@
6
6
  classes << "gem-c-layout-footer--border" if with_border
7
7
  %>
8
8
  <%= tag.footer class: classes, role: "contentinfo" do %>
9
- <div class="govuk-width-container" data-module="track-click">
9
+ <div class="govuk-width-container" data-module="gem-track-click">
10
10
  <% if navigation.any? %>
11
11
  <div class="govuk-footer__navigation">
12
12
  <% navigation.each do |item| %>
@@ -16,7 +16,7 @@
16
16
  classes << "gem-c-metadata--inverse" if inverse
17
17
  %>
18
18
  <%= content_tag :div, class: classes, data: { module: "gem-toggle" } do %>
19
- <dl data-module="track-click">
19
+ <dl data-module="gem-track-click">
20
20
  <% if from.any? %>
21
21
  <dt class="gem-c-metadata__term"><%= t("govuk_component.metadata.from", default: "From") %>:</dt>
22
22
  <dd class="gem-c-metadata__definition">
@@ -26,7 +26,7 @@
26
26
  %>
27
27
  <<%= wrapping_element %>
28
28
  class="<%= wrapper_classes.join(" ") %>"
29
- <%= "data-module=track-click" if organisation[:data_attributes] %>
29
+ <%= "data-module=gem-track-click" if organisation[:data_attributes] %>
30
30
  >
31
31
  <% if organisation[:url] %>
32
32
  <%= link_to organisation[:url],
@@ -4,7 +4,7 @@
4
4
  role="navigation"
5
5
  aria-label="<%= t("govuk_component.previous_and_next_navigation.pagination", default: "Pagination") %>"
6
6
  >
7
- <ul class="gem-c-pagination__list" data-module="track-click">
7
+ <ul class="gem-c-pagination__list" data-module="gem-track-click">
8
8
  <% if local_assigns.include?(:previous_page) %>
9
9
  <li class="gem-c-pagination__item gem-c-pagination__item--previous">
10
10
  <a href="<%= previous_page[:url] %>"
@@ -14,7 +14,7 @@
14
14
  classes << brand_helper.brand_class
15
15
 
16
16
  data_attributes ||= {}
17
- data_attributes[:module] = 'track-click'
17
+ data_attributes[:module] = 'gem-track-click'
18
18
  %>
19
19
  <% if links.any? %>
20
20
  <%= tag.div(class: classes, data: data_attributes) do %>
@@ -28,7 +28,7 @@
28
28
  <%= raw JSON.pretty_generate(breadcrumb_presenter.structured_data) %>
29
29
  </script>
30
30
 
31
- <h2 class="<%= classes %>" data-module="track-click">
31
+ <h2 class="<%= classes %>" data-module="gem-track-click">
32
32
  <span class="gem-c-step-nav-header__part-of">Part of</span>
33
33
  <% if path %>
34
34
  <a href="<%= path %>"
@@ -6,7 +6,7 @@
6
6
  <% if links.any? %>
7
7
  <div
8
8
  class="gem-c-step-nav-related <%= "gem-c-step-nav-related--singular" if links.length == 1 %>"
9
- data-module="track-click">
9
+ data-module="gem-track-click">
10
10
  <h2 class="gem-c-step-nav-related__heading">
11
11
  <span class="gem-c-step-nav-related__pretitle"><%= pretitle %></span>
12
12
  <% if links.length == 1 && !always_display_as_list %>
@@ -27,7 +27,7 @@
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 %>"
30
- <%= "data-module=track-click" if sl_helper.tracking_is_present? %>
30
+ <%= "data-module=gem-track-click" if sl_helper.tracking_is_present? %>
31
31
  >
32
32
  <% if sl_helper.email_signup_link.present? %>
33
33
  <li class="gem-c-subscription-links__list-item<%= ' gem-c-subscription-links__list-item--small' if local_assigns[:small_form] == true %>" >
@@ -9,7 +9,7 @@
9
9
  taxonomy_list_helper = GovukPublishingComponents::Presenters::TaxonomyListHelper.new(image_cards)
10
10
  %>
11
11
  <% if highlight_box || document_list || image_cards %>
12
- <ul class="gem-c-taxonomy-list" data-module="track-click">
12
+ <ul class="gem-c-taxonomy-list" data-module="gem-track-click">
13
13
  <% if image_cards %>
14
14
  <% taxonomy_list_helper.image_card_data.each do |image_card| %>
15
15
  <li class="gem-c-taxonomy-list__item">
@@ -7,7 +7,7 @@
7
7
  <nav role="navigation"
8
8
  class="gem-c-translation-nav <%= translation_helper.classes %> <%= brand_helper.brand_class %>"
9
9
  aria-label="<%= t("common.translations") %>"
10
- <%= "data-module=\"track-click\"" if translation_helper.tracking_is_present? %>
10
+ <%= "data-module=\"gem-track-click\"" if translation_helper.tracking_is_present? %>
11
11
  >
12
12
  <ul class="gem-c-translation-nav__list">
13
13
  <% translation_helper.translations.each.with_index do |translation, i| %>
@@ -3,7 +3,7 @@
3
3
  <% link_path = t("components.related_navigation.transition.link_path") %>
4
4
 
5
5
  <% data_attributes = {
6
- "module": "track-click",
6
+ "module": "gem-track-click",
7
7
  "track-category": "relatedLinkClicked",
8
8
  "track-action": "1.0 Transition",
9
9
  "track-label": link_path,
@@ -4,20 +4,25 @@ govuk_frontend_components:
4
4
  - accordion
5
5
  body: |
6
6
  This component is based on the [design system accordion component](https://design-system.service.gov.uk/components/accordion/)
7
- and is currently experimental. If using this component, please feed back any research findings to the Design System team.
7
+ and is currently experimental because more research is needed to validate it. If using this component, [please feed back any research findings to the Design System team](https://design-system.service.gov.uk/components/accordion/#next-steps).
8
8
 
9
9
  accessibility_criteria: |
10
10
  The accordion must:
11
11
 
12
12
  * accept focus
13
13
  * be usable with a keyboard
14
- * indicate when they have focus
14
+ * the controls must change in appearance when keyboard focus moves to it
15
+ * the controls must indicate when the mouse is hovered over it
15
16
  * be usable with touch
16
17
  * be usable with voice commands
17
18
  * have visible text
18
19
  * indicate to users that each section can be expanded and collapsed
19
20
  * inform the user when a step has been expanded or collapsed
20
- * be readable when only the text of the page is zoomed in
21
+ * be readable when only the [text of the page is zoomed in](https://support.mozilla.org/en-US/kb/font-size-and-zoom-increase-size-of-web-pages#w_how-to-only-change-the-size-of-the-text)
22
+ * zoom in up to 300% without the text spilling off the screen
23
+ * pass colour contrast
24
+ * the accordion header button element has aria-controls set to the ID of the element containing the accordion panel content.
25
+ * section content must have aria-label / aria-labelledby with a value that refers to the button that controls display of the content.
21
26
 
22
27
  Section headings must use a button element:
23
28
 
@@ -269,6 +274,35 @@ examples:
269
274
  text: "How people read"
270
275
  content:
271
276
  html: "<p class='govuk-body'>This is the content for How people read.</p>"
277
+ with_the_anchor_link_navigation:
278
+ description: |
279
+ Some apps require custom ids per accordion section heading for linking between those specific sections, sometimes across multiple pages. An example of this is on manuals pages where multiple manuals will each include large sets of accordions and will reference between specific sections for ease of access to that content. [Live example](https://www.gov.uk/guidance/how-to-publish-on-gov-uk/creating-and-updating-pages#associations).
280
+
281
+ This feature automatically opens accordions when an anchor link is clicked within another accordion that links to either the id of an accordion section heading or an id within the content of an accordion. This will also automatically navigate to and open accordions on page load using the same rules.
282
+
283
+ This feature won't be used if the `anchor_navigation` flag isn't passed as true to mitigate performance risk from event listeners on a large number of links.
284
+
285
+ Unlike with the accordion-wide custom id attribute, any ids passed to accordion headings as part of this feature aren't stored in `localStorage` so don't need to be unique across your domain, but **should still be unique in the context of the page**.
286
+ data:
287
+ anchor_navigation: true
288
+ items:
289
+ - heading:
290
+ text: "Writing well for the web"
291
+ id: "writing-well-for-the-web"
292
+ content:
293
+ html: "<p class='govuk-body'>This is the content for Writing well for the web.</p>"
294
+ - heading:
295
+ text: "Writing well for specialists"
296
+ content:
297
+ html: "<p class='govuk-body'>This is the content for Writing well for specialists.</p>"
298
+ - heading:
299
+ text: "Know your audience"
300
+ content:
301
+ html: "<p class='govuk-body'>This is the content for Know your audience.</p>"
302
+ - heading:
303
+ text: "How people read"
304
+ content:
305
+ html: "<p class='govuk-body'>This is the content for How people read.</p>"
272
306
  condensed_layout:
273
307
  description: |
274
308
  This is for when a smaller accordion is required. Since smaller screens trigger a single column layout, this modifier only makes the accordion smaller when viewed on large screens.
@@ -1,6 +1,8 @@
1
1
  name: Cookie banner
2
2
  description: Help users manage their personal data by telling them when you store cookies on their device.
3
3
  body: |
4
+ By default the cookie banner is shown to all users with just a link to the settings page. If JS is on this is enhanced to show accept/reject buttons if preferences aren't set, or to hide the banner if they are.
5
+
4
6
  Setting `data-hide-cookie-banner="true"` on any link inside the banner will overwrite the default action and when clicked will dismiss the cookie banner for a period of 365 days (approx. 1 year).
5
7
 
6
8
  If the examples below are not showing the banner, make sure the `cookies_preferences_set` cookie is not present or is set to false.
@@ -18,6 +20,13 @@ examples:
18
20
  title: "Can we store analytics cookies on your device?"
19
21
  text: "This is some custom text in my cookie banner which lets users know what we're using cookies for. I can also include a link to the <a class='govuk-link' href='/cookies'>cookies page</a>"
20
22
  confirmation_message: "You’ve accepted all cookies."
23
+
24
+ with_multi_paragraph_custom_content:
25
+ data:
26
+ title: "Can we store analytics cookies on your device?"
27
+ text: ["This is some custom text in my cookie banner.","There are three paragraphs.","They are passed as an array"]
28
+ confirmation_message: "You’ve accepted all cookies."
29
+
21
30
  with_custom_cookie_preferences_href:
22
31
  data:
23
32
  cookie_preferences_href: "/cookies"