govuk_publishing_components 24.4.1 → 24.7.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/govuk_publishing_components/components/accordion.js +7 -5
  3. data/app/assets/javascripts/govuk_publishing_components/components/details.js +2 -1
  4. data/app/assets/javascripts/govuk_publishing_components/components/reorderable-list.js +108 -0
  5. data/app/assets/javascripts/govuk_publishing_components/lib/header-navigation.js +6 -2
  6. data/app/assets/javascripts/govuk_publishing_components/modules.js +3 -1
  7. data/app/assets/stylesheets/component_guide/application.scss +1 -1
  8. data/app/assets/stylesheets/govuk_publishing_components/_all_components.scss +1 -0
  9. data/app/assets/stylesheets/govuk_publishing_components/_all_components_print.scss +1 -1
  10. data/app/assets/stylesheets/govuk_publishing_components/components/_layout-for-public.scss +10 -1
  11. data/app/assets/stylesheets/govuk_publishing_components/components/_layout-header.scss +8 -7
  12. data/app/assets/stylesheets/govuk_publishing_components/components/_reorderable-list.scss +117 -0
  13. data/app/assets/stylesheets/govuk_publishing_components/components/_search.scss +15 -1
  14. data/app/assets/stylesheets/govuk_publishing_components/components/_summary-list.scss +12 -0
  15. data/app/views/govuk_publishing_components/components/_layout_for_public.html.erb +48 -7
  16. data/app/views/govuk_publishing_components/components/_layout_header.html.erb +15 -12
  17. data/app/views/govuk_publishing_components/components/_list.html.erb +5 -5
  18. data/app/views/govuk_publishing_components/components/_reorderable_list.html.erb +45 -0
  19. data/app/views/govuk_publishing_components/components/_search.html.erb +27 -16
  20. data/app/views/govuk_publishing_components/components/_summary_list.html.erb +73 -31
  21. data/app/views/govuk_publishing_components/components/docs/contextual_sidebar.yml +3 -0
  22. data/app/views/govuk_publishing_components/components/docs/layout_for_public.yml +26 -0
  23. data/app/views/govuk_publishing_components/components/docs/reorderable_list.yml +85 -0
  24. data/app/views/govuk_publishing_components/components/docs/search.yml +10 -0
  25. data/app/views/govuk_publishing_components/components/docs/summary_list.yml +50 -19
  26. data/app/views/govuk_publishing_components/components/layout_header/_navigation_items.html.erb +8 -1
  27. data/app/views/govuk_publishing_components/components/layout_header/_search.html.erb +17 -3
  28. data/config/locales/ar.yml +1 -0
  29. data/config/locales/az.yml +1 -0
  30. data/config/locales/be.yml +1 -0
  31. data/config/locales/bg.yml +1 -0
  32. data/config/locales/bn.yml +1 -0
  33. data/config/locales/cs.yml +1 -0
  34. data/config/locales/da.yml +1 -0
  35. data/config/locales/de.yml +1 -0
  36. data/config/locales/dr.yml +1 -0
  37. data/config/locales/el.yml +1 -0
  38. data/config/locales/en.yml +24 -16
  39. data/config/locales/es-419.yml +1 -0
  40. data/config/locales/es.yml +1 -0
  41. data/config/locales/fa.yml +1 -0
  42. data/config/locales/fi.yml +1 -0
  43. data/config/locales/gd.yml +1 -0
  44. data/config/locales/gu.yml +1 -0
  45. data/config/locales/he.yml +1 -0
  46. data/config/locales/hi.yml +1 -0
  47. data/config/locales/hr.yml +1 -0
  48. data/config/locales/hu.yml +1 -0
  49. data/config/locales/hy.yml +1 -0
  50. data/config/locales/id.yml +1 -0
  51. data/config/locales/is.yml +1 -0
  52. data/config/locales/it.yml +1 -0
  53. data/config/locales/ja.yml +1 -0
  54. data/config/locales/ka.yml +1 -0
  55. data/config/locales/kk.yml +1 -0
  56. data/config/locales/ko.yml +1 -0
  57. data/config/locales/lt.yml +1 -0
  58. data/config/locales/lv.yml +1 -0
  59. data/config/locales/ms.yml +1 -0
  60. data/config/locales/mt.yml +1 -0
  61. data/config/locales/nl.yml +1 -0
  62. data/config/locales/no.yml +1 -0
  63. data/config/locales/pa-pk.yml +1 -0
  64. data/config/locales/pa.yml +1 -0
  65. data/config/locales/pl.yml +1 -0
  66. data/config/locales/ps.yml +1 -0
  67. data/config/locales/pt.yml +1 -0
  68. data/config/locales/ro.yml +1 -0
  69. data/config/locales/ru.yml +1 -0
  70. data/config/locales/si.yml +1 -0
  71. data/config/locales/sk.yml +1 -0
  72. data/config/locales/sl.yml +1 -0
  73. data/config/locales/so.yml +1 -0
  74. data/config/locales/sq.yml +1 -0
  75. data/config/locales/sr.yml +1 -0
  76. data/config/locales/sv.yml +1 -0
  77. data/config/locales/sw.yml +1 -0
  78. data/config/locales/ta.yml +1 -0
  79. data/config/locales/th.yml +1 -0
  80. data/config/locales/tk.yml +1 -0
  81. data/config/locales/tr.yml +1 -0
  82. data/config/locales/uk.yml +1 -0
  83. data/config/locales/ur.yml +1 -0
  84. data/config/locales/uz.yml +1 -0
  85. data/config/locales/vi.yml +1 -0
  86. data/config/locales/zh-hk.yml +1 -0
  87. data/config/locales/zh-tw.yml +1 -0
  88. data/config/locales/zh.yml +1 -0
  89. data/lib/govuk_publishing_components/presenters/contextual_navigation.rb +5 -0
  90. data/lib/govuk_publishing_components/version.rb +1 -1
  91. data/node_modules/sortablejs/LICENSE +21 -0
  92. data/node_modules/sortablejs/README.md +815 -0
  93. data/node_modules/sortablejs/Sortable.js +3721 -0
  94. data/node_modules/sortablejs/Sortable.min.js +2 -0
  95. data/node_modules/sortablejs/modular/sortable.complete.esm.js +3713 -0
  96. data/node_modules/sortablejs/modular/sortable.core.esm.js +3710 -0
  97. data/node_modules/sortablejs/modular/sortable.esm.js +3711 -0
  98. data/node_modules/sortablejs/package.json +56 -0
  99. metadata +78 -6
@@ -27,3 +27,29 @@ examples:
27
27
  description: This allows the header to be omitted which is currently used when rendering CSV previews from Whitehall
28
28
  data:
29
29
  omit_header: true
30
+ navigation:
31
+ description: Passes the navigation through to the [header component](/component-guide/layout_header/).
32
+ data:
33
+ show_search: false
34
+ navigation_items:
35
+ - text: Navigation item 1
36
+ href: "item-1"
37
+ active: true
38
+ - text: Navigation item 2
39
+ href: "item-2"
40
+ - text: Hidden on desktop
41
+ href: "item-3"
42
+ show_only_in_collapsed_menu: true
43
+ with_global_banner:
44
+ description: This allows the HTML for the global banner to be added to the page. This is only the slot for the global banner - the markup for the banner needs to be passed in.
45
+ data:
46
+ global_bar: <div class="govuk-!-padding-top-5 govuk-!-padding-bottom-3">This is the global bar slot</div>
47
+ with_emergency_banner:
48
+ description: This allows the HTML for the emergency banner to be added to the page in the correct place. This is only the slot for the emergency banner - the markup for the banner needs to be passed in.
49
+ data:
50
+ emergency_banner: <div class="govuk-!-padding-top-3 govuk-!-padding-bottom-3">This is the emergency banner slot</div>
51
+ with_global_and_emergency_banner:
52
+ description: Both global banner and emergency banner should be usable together.
53
+ data:
54
+ emergency_banner: <div class="govuk-!-padding-top-3 govuk-!-padding-bottom-3">This is the emergency banner slot</div>
55
+ global_bar: <div class="govuk-!-padding-top-5 govuk-!-padding-bottom-3">This is the global bar slot</div>
@@ -0,0 +1,85 @@
1
+ name: Reorderable list
2
+ description: A list of items that can be reordered
3
+ body: |
4
+ List items can be reordered by drag and drop or by using the up/down buttons.
5
+ On small viewports the drag and drop feature is disabled to prevent being triggered
6
+ when scrolling on touch devices.
7
+
8
+ This component uses SortableJS - a JavaScript library for drag and drop interactions.
9
+ When JavaScript is disabled a set of inputs will be shown allowing users to provide
10
+ an order index for each item.
11
+
12
+ When this component is embedded into a form and that form is submit you will receive a
13
+ parameter of `ordering` (which can be customised with the `input_name` option).
14
+ This will contain item ids and ordering positions in a hash.
15
+
16
+ For example, for two items with id "a" and "b" that are ordered accordingly,
17
+ you'd receive a submission of `ordering[a]=1&ordering[b]=2`, which Rails can
18
+ translate to `"ordering" => { "a" => "1", "b" => "2" }`.
19
+
20
+ accessibility_criteria: |
21
+ Buttons in this component must:
22
+
23
+ * be keyboard focusable
24
+ * inform the user about which item they operate on
25
+ * preserve focus after interacting with them
26
+ examples:
27
+ default:
28
+ data:
29
+ items:
30
+ - id: "ce99dd60-67dc-11eb-ae93-0242ac130002"
31
+ title: "Budget 2018"
32
+ - id: "d321cb86-67dc-11eb-ae93-0242ac130002"
33
+ title: "Budget 2018 (web)"
34
+ - id: "63a6d29e-6b6d-4157-9067-84c1a390e352"
35
+ title: "Impact on households: distributional analysis to accompany Budget 2018"
36
+ - id: "0a4d377d-68f4-472f-b2e3-ef71dc750f85"
37
+ title: "Table 2.1: Budget 2018 policy decisions"
38
+ - id: "5ebd75d7-6c37-4b93-b444-1b7c49757fb9"
39
+ title: "Table 2.2: Measures announced at Autumn Budget 2017 or earlier that will take effect from November 2018 or later (£ million)"
40
+ with_description:
41
+ data:
42
+ items:
43
+ - id: "ce99dd60-67dc-11eb-ae93-0242ac130002"
44
+ title: "Budget 2018"
45
+ description: "PDF, 2.56MB, 48 pages"
46
+ - id: "d321cb86-67dc-11eb-ae93-0242ac130002"
47
+ title: "Budget 2018 (web)"
48
+ description: "HTML attachment"
49
+ - id: "63a6d29e-6b6d-4157-9067-84c1a390e352"
50
+ title: "Impact on households: distributional analysis to accompany Budget 2018"
51
+ description: "PDF, 592KB, 48 pages"
52
+ - id: "0a4d377d-68f4-472f-b2e3-ef71dc750f85"
53
+ title: "Table 2.1: Budget 2018 policy decisions"
54
+ description: "MS Excel Spreadsheet, 248KB"
55
+ - id: "5ebd75d7-6c37-4b93-b444-1b7c49757fb9"
56
+ title: "Table 2.2: Measures announced at Autumn Budget 2017 or earlier that will take effect from November 2018 or later (£ million)"
57
+ description: "MS Excel Spreadsheet, 248KB"
58
+ within_form:
59
+ embed: |
60
+ <form>
61
+ <%= component %>
62
+ <button class="govuk-button" type="submit">Save order</button>
63
+ </form>
64
+ data:
65
+ items:
66
+ - id: "ce99dd60-67dc-11eb-ae93-0242ac130002"
67
+ title: "Budget 2018"
68
+ - id: "d321cb86-67dc-11eb-ae93-0242ac130002"
69
+ title: "Budget 2018 (web)"
70
+ - id: "63a6d29e-6b6d-4157-9067-84c1a390e352"
71
+ title: "Impact on households: distributional analysis to accompany Budget 2018"
72
+ - id: "0a4d377d-68f4-472f-b2e3-ef71dc750f85"
73
+ title: "Table 2.1: Budget 2018 policy decisions"
74
+ - id: "5ebd75d7-6c37-4b93-b444-1b7c49757fb9"
75
+ title: "Table 2.2: Measures announced at Autumn Budget 2017 or earlier that will take effect from November 2018 or later (£ million)"
76
+ with_custom_input_name:
77
+ data:
78
+ input_name: "attachments[ordering]"
79
+ items:
80
+ - id: "5ebd75d7-6c37-4b93-b444-1b7c49757fb9"
81
+ title: "Budget 2018"
82
+ description: "PDF, 2.56MB, 48 pages"
83
+ - id: "0a4d377d-68f4-472f-b2e3-ef71dc750f85"
84
+ title: "Budget 2020"
85
+ description: "PDF, 2.56MB, 48 pages"
@@ -51,6 +51,16 @@ examples:
51
51
  with_aria_controls_attribute:
52
52
  description: |
53
53
  The aria-controls attribute is a 'relationship attribute' which denotes which elements in a page an interactive element or set of elements has control over and affects.
54
+
54
55
  For places like the finders where the page is updated dynamically after value changes to the input.
55
56
  data:
56
57
  aria_controls: "wrapper"
58
+ with_custom_button_text:
59
+ description: |
60
+ The search box component may be used multiple times on a page -- for example, on a [guidance and regulation finder results page](https://www.gov.uk/search/guidance-and-regulation?keywords=bananas&order=relevance) there is both the sitewide search in the header and also for the specific finder.
61
+
62
+ To avoid confusion, the text inside the button should be different for each form. This can be done by setting the `button_text` parameter.
63
+
64
+ This is visually hidden text -- to check for changes use a screen reader or inspect the button element.
65
+ data:
66
+ button_text: "Search absolutely everywhere"
@@ -35,6 +35,7 @@ examples:
35
35
  borderless: true
36
36
 
37
37
  with_edit_on_section:
38
+ description: For all links shown in the component, see the <a href="/component-guide/summary_list/with_customised_links">with customised links example</a> for guidance.
38
39
  data:
39
40
  <<: *default-example-data
40
41
  edit:
@@ -43,6 +44,7 @@ examples:
43
44
  gtm: "edit-title-summary-body"
44
45
 
45
46
  with_delete_on_section:
47
+ description: For all links shown in the component, see the <a href="/component-guide/summary_list/with_customised_links">with customised links example</a> for guidance.
46
48
  data:
47
49
  <<: *default-example-data
48
50
  delete:
@@ -51,6 +53,7 @@ examples:
51
53
  gtm: "delete-title-summary-body"
52
54
 
53
55
  with_edit_and_delete_on_section:
56
+ description: For all links shown in the component, see the <a href="/component-guide/summary_list/with_customised_links">with customised links example</a> for guidance.
54
57
  data:
55
58
  <<: *default-example-data
56
59
  edit:
@@ -62,32 +65,45 @@ examples:
62
65
  data_attributes:
63
66
  gtm: "delete-title-summary-body"
64
67
 
68
+ with_customised_links:
69
+ description: |
70
+ For all links shown in the component, visually hidden text containing the name of the thing it refers to is automatically appended. This offers a better experience for screen reader users by making the link text unique and more explicit. In the example below, the link text would be `Change Title, summary and body`.
71
+
72
+ The text of the link can be customised using the `link_text` option. Take care that the provided `link_text` still makes sense to screen readers when combined with the title. For instance, `Reorder` link text and `Items` title becomes `Reorder Items`, which reads fine, but link text of `Summary` would read as `Summary Items`, which does not make sense.
73
+
74
+ To override this behaviour, use `link_text_no_enhance` on the link in question, as shown. This will remove the visually hidden text, allowing you to add your own. The component will render a `span` element with a class of `govuk-visually-hidden` included in a passed [capture block](https://apidock.com/rails/ActionView/Helpers/CaptureHelper/capture) as the `link_text` parameter.
75
+ data:
76
+ title: "Title, summary and body"
77
+ items:
78
+ - field: "Title"
79
+ value: "Rural conservation techniques"
80
+ edit:
81
+ href: "edit-title"
82
+ text: "Edit"
83
+ data_attributes:
84
+ gtm: "edit-title"
85
+ - field: "Body"
86
+ value: "Following the land use committee change to overreaching rural byelaws in 2009, further policies were adopted."
87
+ edit:
88
+ href: "edit-body"
89
+ link_text: "Edit"
90
+ delete:
91
+ href: "delete-body"
92
+ link_text: "Remove"
93
+ link_text_no_enhance: true
94
+ edit:
95
+ href: "edit-title-summary-body"
96
+ link_text: Edit this document <span class="govuk-visually-hidden">my hidden text for screenreaders</span>
97
+ link_text_no_enhance: true
98
+
65
99
  with_custom_section_heading:
66
100
  data:
67
101
  <<: *default-example-data
68
102
  heading_level: 2
69
103
  heading_size: l
70
104
 
71
- with_custom_link_on_section:
72
- description: |
73
- Take care that the provided `link_text` still makes sense to screen readers when combined with the title.
74
- For instance, `Reorder` link text and `Items` title becomes `Reorder Items`, which reads fine, but link text
75
- of `Summary` would read as `Summary Items`, which does not make sense.
76
- data:
77
- edit:
78
- href: "custom-link"
79
- link_text: "Reorder"
80
- title: "Items"
81
- items:
82
- - field: "Item 1"
83
- value: "Value 2"
84
- - field: "Item 2"
85
- value: "Value 2"
86
- - field: "Item 3"
87
- value: "Value 3"
88
-
89
105
  with_edit_on_individual_items:
90
- description: The link text can be optionally modified using the 'link_text' parameter, as for the edit link in previous examples.
106
+ description: For all links shown in the component, see the <a href="/component-guide/summary_list/with_customised_links">with customised links example</a> for guidance.
91
107
  data:
92
108
  title: "Title, summary and body"
93
109
  items:
@@ -113,6 +129,21 @@ examples:
113
129
  href: "delete-body"
114
130
  link_text: "Remove"
115
131
 
132
+ wide_title_layout:
133
+ description: Allows a slightly adjusted layout for longer text in the field name.
134
+ data:
135
+ title: Privacy settings
136
+ wide_title: true
137
+ items:
138
+ - field: "GOV.UK can use cookies while you’re signed in"
139
+ value: "No"
140
+ edit:
141
+ href: "edit-cookies"
142
+ - field: "GOV.UK can send you feedback emails"
143
+ value: "Yes"
144
+ edit:
145
+ href: "edit-feedback"
146
+
116
147
  with_block:
117
148
  description: Use the summary list with a block when you need to show an empty state message or load another component.
118
149
  data:
@@ -1,7 +1,14 @@
1
1
  <% navigation_aria_label ||= "Top level" %>
2
2
 
3
3
  <% if navigation_items.any? %>
4
- <button role="button" class="govuk-header__menu-button gem-c-header__menu-button govuk-js-header-toggle" aria-controls="navigation" aria-label="Show or hide Top Level Navigation">Menu</button>
4
+ <button
5
+ aria-controls="navigation"
6
+ aria-label="Show or hide Top Level Navigation"
7
+ class="govuk-header__menu-button govuk-js-header-toggle gem-c-header__menu-button"
8
+ type="button"
9
+ >
10
+ Menu
11
+ </button>
5
12
  <%= tag.nav class: "gem-c-header__nav", aria: { label: navigation_aria_label } do %>
6
13
  <ul id="navigation" class="govuk-header__navigation govuk-header__navigation--end">
7
14
  <% navigation_items.each_with_index do |item, index| %>
@@ -1,8 +1,22 @@
1
- <button class="search-toggle js-header-toggle" data-search-toggle-for="search">Show search</button>
2
- <form id="search" class="gem-c-layout-header__search-form govuk-clearfix" action="/search" method="get" role="search">
1
+ <button
2
+ class="search-toggle js-header-toggle"
3
+ data-search-toggle-for="search"
4
+ data-show-text="<%= t("components.layout_header.show_button") %>"
5
+ data-hide-text="<%= t("components.layout_header.hide_button") %>"
6
+ >
7
+ <%= t("components.layout_header.show_button") %>
8
+ </button>
9
+ <form
10
+ action="/search"
11
+ class="gem-c-layout-header__search-form govuk-clearfix"
12
+ id="search"
13
+ method="get"
14
+ role="search"
15
+ >
3
16
  <%= render "govuk_publishing_components/components/search", {
17
+ button_text: t("components.layout_header.search_button"),
4
18
  id: "site-search-text",
19
+ margin_bottom: 0,
5
20
  no_border: true,
6
- margin_bottom: 0
7
21
  } %>
8
22
  </form>
@@ -0,0 +1 @@
1
+ ar:
@@ -0,0 +1 @@
1
+ az:
@@ -0,0 +1 @@
1
+ be:
@@ -0,0 +1 @@
1
+ bg:
@@ -0,0 +1 @@
1
+ bn:
@@ -0,0 +1 @@
1
+ cs:
@@ -0,0 +1 @@
1
+ da:
@@ -0,0 +1 @@
1
+ de:
@@ -0,0 +1 @@
1
+ dr:
@@ -0,0 +1 @@
1
+ el:
@@ -4,11 +4,11 @@
4
4
  #
5
5
  # To use the locales, use `I18n.t`:
6
6
  #
7
- # I18n.t 'hello'
7
+ # I18n.t "hello"
8
8
  #
9
9
  # In views, this is aliased to just `t`:
10
10
  #
11
- # <%= t('hello') %>
11
+ # <%= t("hello") %>
12
12
  #
13
13
  # To use a different locale, set it with `I18n.locale`:
14
14
  #
@@ -31,11 +31,11 @@ en:
31
31
  article_schema:
32
32
  scoped_search_description: "Search within %{title}"
33
33
  back_link:
34
- back: 'Back'
34
+ back: "Back"
35
35
  checkboxes:
36
- or: 'or'
36
+ or: "or"
37
37
  contents_list:
38
- contents: Contents
38
+ contents: "Contents"
39
39
  feedback:
40
40
  is_this_page_useful: "Is this page useful?"
41
41
  yes: "Yes"
@@ -54,10 +54,14 @@ en:
54
54
  what_wrong: "What went wrong?"
55
55
  send_me_survey: "Send me the survey"
56
56
  send: "Send"
57
+ layout_header:
58
+ search_button: "Search GOV.UK"
59
+ show_button: "Show search"
60
+ hide_button: "Hide search"
57
61
  organisation_schema:
58
62
  all_content_search_description: "Find all content from %{organisation}"
59
63
  radio:
60
- or: 'or'
64
+ or: "or"
61
65
  related_navigation:
62
66
  collections: "Collection"
63
67
  external_links: "Elsewhere on the web"
@@ -76,22 +80,26 @@ en:
76
80
  link_path: "/transition"
77
81
  link_text: "Check what you need to do"
78
82
  take_action_list:
79
- red: Check
80
- amber: Change
81
- green: Go
82
- aria_label: Brexit campaign slogan, Check, Change, Go.
83
+ red: "Check"
84
+ amber: "Change"
85
+ green: "Go"
86
+ aria_label: "Brexit campaign slogan, Check, Change, Go."
83
87
  related_footer_navigation:
84
88
  collections: "Collections"
85
89
  policies: "Policies"
86
90
  statistical_data_sets: "Statistical data sets"
87
91
  topical_events: "Topical events"
92
+ search_box:
93
+ search_button: "Search"
94
+ label: "Search on GOV.UK"
95
+ input_title: "Search"
88
96
  show_password:
89
- show: Show
90
- hide: Hide
91
- show_password: Show password
92
- hide_password: Hide password
93
- announce_show: Your password is shown
94
- announce_hide: Your password is hidden
97
+ show: "Show"
98
+ hide: "Hide"
99
+ show_password: "Show password"
100
+ hide_password: "Hide password"
101
+ announce_show: "Your password is shown"
102
+ announce_hide: "Your password is hidden"
95
103
  print_link:
96
104
  text: "Print this page"
97
105
  skip_link:
@@ -0,0 +1 @@
1
+ es-419:
@@ -0,0 +1 @@
1
+ es:
@@ -0,0 +1 @@
1
+ fa:
@@ -0,0 +1 @@
1
+ fi:
@@ -0,0 +1 @@
1
+ gd:
@@ -0,0 +1 @@
1
+ gu:
@@ -0,0 +1 @@
1
+ he:
@@ -0,0 +1 @@
1
+ hi:
@@ -0,0 +1 @@
1
+ hr:
@@ -0,0 +1 @@
1
+ hu:
@@ -0,0 +1 @@
1
+ hy:
@@ -0,0 +1 @@
1
+ id:
@@ -0,0 +1 @@
1
+ is:
@@ -0,0 +1 @@
1
+ it: