govuk_publishing_components 28.5.0 → 28.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/app/assets/javascripts/govuk_publishing_components/analytics/page-content.js +3 -3
- data/app/assets/javascripts/govuk_publishing_components/analytics/track-select-change.js +4 -3
- data/app/assets/javascripts/govuk_publishing_components/components/accordion.js +21 -291
- data/app/assets/javascripts/govuk_publishing_components/components/button.js +1 -1
- data/app/assets/javascripts/govuk_publishing_components/components/character-count.js +1 -1
- data/app/assets/javascripts/govuk_publishing_components/components/checkboxes.js +1 -1
- data/app/assets/javascripts/govuk_publishing_components/components/details.js +1 -1
- data/app/assets/javascripts/govuk_publishing_components/components/error-summary.js +1 -1
- data/app/assets/javascripts/govuk_publishing_components/components/feedback.js +7 -6
- data/app/assets/javascripts/govuk_publishing_components/components/layout-header.js +1 -1
- data/app/assets/javascripts/govuk_publishing_components/components/radio.js +1 -1
- data/app/assets/javascripts/govuk_publishing_components/components/skip-link.js +5 -0
- data/app/assets/javascripts/govuk_publishing_components/components/step-by-step-nav.js +40 -37
- data/app/assets/javascripts/govuk_publishing_components/components/tabs.js +1 -1
- data/app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js +2 -1
- data/app/assets/javascripts/govuk_publishing_components/lib/govspeak/magna-charta.js +8 -10
- data/app/assets/javascripts/govuk_publishing_components/lib/initial-focus.js +4 -3
- data/app/assets/javascripts/govuk_publishing_components/lib/toggle-input-class-on-focus.js +4 -3
- data/app/assets/javascripts/govuk_publishing_components/lib/toggle.js +4 -3
- data/app/assets/javascripts/govuk_publishing_components/vendor/lux/lux-reporter.js +1796 -911
- data/app/assets/stylesheets/govuk_publishing_components/components/_accordion.scss +1 -329
- data/app/assets/stylesheets/govuk_publishing_components/components/_share-links.scss +1 -1
- data/app/assets/stylesheets/govuk_publishing_components/components/_step-by-step-nav.scss +95 -56
- data/app/assets/stylesheets/govuk_publishing_components/components/print/_accordion.scss +6 -17
- data/app/assets/stylesheets/govuk_publishing_components/govuk_frontend_support.scss +0 -9
- data/app/models/govuk_publishing_components/component_docs.rb +1 -1
- data/app/views/govuk_publishing_components/components/_accordion.html.erb +31 -16
- data/app/views/govuk_publishing_components/components/_attachment.html.erb +3 -1
- data/app/views/govuk_publishing_components/components/_button.html.erb +4 -4
- data/app/views/govuk_publishing_components/components/_character_count.html.erb +2 -2
- data/app/views/govuk_publishing_components/components/_checkboxes.html.erb +2 -2
- data/app/views/govuk_publishing_components/components/_error_message.html.erb +1 -1
- data/app/views/govuk_publishing_components/components/_error_summary.html.erb +0 -1
- data/app/views/govuk_publishing_components/components/_input.html.erb +3 -3
- data/app/views/govuk_publishing_components/components/_inset_text.html.erb +12 -1
- data/app/views/govuk_publishing_components/components/_intervention.html.erb +2 -2
- data/app/views/govuk_publishing_components/components/_layout_footer.html.erb +1 -1
- data/app/views/govuk_publishing_components/components/_modal_dialogue.html.erb +1 -1
- data/app/views/govuk_publishing_components/components/_radio.html.erb +1 -1
- data/app/views/govuk_publishing_components/components/_search.html.erb +2 -4
- data/app/views/govuk_publishing_components/components/_select.html.erb +15 -43
- data/app/views/govuk_publishing_components/components/_skip_link.html.erb +1 -1
- data/app/views/govuk_publishing_components/components/_subscription_links.html.erb +7 -8
- data/app/views/govuk_publishing_components/components/docs/accordion.yml +2 -97
- data/app/views/govuk_publishing_components/components/docs/attachment.yml +11 -0
- data/app/views/govuk_publishing_components/components/docs/govspeak.yml +1 -1
- data/app/views/govuk_publishing_components/components/docs/inset_text.yml +6 -0
- data/app/views/govuk_publishing_components/components/docs/select.yml +1 -1
- data/app/views/govuk_publishing_components/components/docs/share_links.yml +1 -1
- data/app/views/govuk_publishing_components/components/docs/step_by_step_nav.yml +13 -13
- data/app/views/govuk_publishing_components/components/docs/tabs.yml +1 -1
- data/app/views/govuk_publishing_components/components/docs/textarea.yml +1 -1
- data/app/views/govuk_publishing_components/components/layout_header/_navigation_items.html.erb +11 -11
- data/config/initializers/assets.rb +1 -0
- data/lib/govuk_publishing_components/presenters/attachment.rb +23 -0
- data/lib/govuk_publishing_components/presenters/select_helper.rb +85 -0
- data/lib/govuk_publishing_components/version.rb +1 -1
- data/lib/govuk_publishing_components.rb +1 -1
- data/node_modules/govuk-frontend/govuk/all.js +294 -76
- data/node_modules/govuk-frontend/govuk/components/accordion/_index.scss +274 -99
- data/node_modules/govuk-frontend/govuk/components/accordion/accordion.js +169 -65
- data/node_modules/govuk-frontend/govuk/components/accordion/fixtures.json +37 -5
- data/node_modules/govuk-frontend/govuk/components/accordion/macro-options.json +4 -4
- data/node_modules/govuk-frontend/govuk/components/button/button.js +2 -2
- data/node_modules/govuk-frontend/govuk/components/character-count/character-count.js +3 -3
- data/node_modules/govuk-frontend/govuk/components/character-count/fixtures.json +15 -2
- data/node_modules/govuk-frontend/govuk/components/checkboxes/checkboxes.js +8 -10
- data/node_modules/govuk-frontend/govuk/components/checkboxes/fixtures.json +52 -15
- data/node_modules/govuk-frontend/govuk/components/cookie-banner/_index.scss +0 -2
- data/node_modules/govuk-frontend/govuk/components/cookie-banner/fixtures.json +31 -0
- data/node_modules/govuk-frontend/govuk/components/date-input/fixtures.json +25 -25
- data/node_modules/govuk-frontend/govuk/components/details/details.js +2 -2
- data/node_modules/govuk-frontend/govuk/components/error-message/_index.scss +1 -0
- data/node_modules/govuk-frontend/govuk/components/error-message/fixtures.json +8 -8
- data/node_modules/govuk-frontend/govuk/components/error-message/template.njk +2 -2
- data/node_modules/govuk-frontend/govuk/components/error-summary/error-summary.js +24 -3
- data/node_modules/govuk-frontend/govuk/components/error-summary/fixtures.json +25 -16
- data/node_modules/govuk-frontend/govuk/components/error-summary/macro-options.json +6 -0
- data/node_modules/govuk-frontend/govuk/components/error-summary/template.njk +2 -1
- data/node_modules/govuk-frontend/govuk/components/file-upload/fixtures.json +4 -4
- data/node_modules/govuk-frontend/govuk/components/footer/_index.scss +3 -37
- data/node_modules/govuk-frontend/govuk/components/footer/fixtures.json +119 -15
- data/node_modules/govuk-frontend/govuk/components/footer/macro-options.json +6 -0
- data/node_modules/govuk-frontend/govuk/components/footer/template.njk +1 -1
- data/node_modules/govuk-frontend/govuk/components/header/_index.scss +10 -4
- data/node_modules/govuk-frontend/govuk/components/header/fixtures.json +11 -11
- data/node_modules/govuk-frontend/govuk/components/header/header.js +4 -4
- data/node_modules/govuk-frontend/govuk/components/header/template.njk +4 -3
- data/node_modules/govuk-frontend/govuk/components/hint/_index.scss +1 -3
- data/node_modules/govuk-frontend/govuk/components/input/_index.scss +1 -1
- data/node_modules/govuk-frontend/govuk/components/input/fixtures.json +40 -40
- data/node_modules/govuk-frontend/govuk/components/input/template.njk +4 -3
- data/node_modules/govuk-frontend/govuk/components/notification-banner/notification-banner.js +499 -2
- data/node_modules/govuk-frontend/govuk/components/phase-banner/fixtures.json +2 -2
- data/node_modules/govuk-frontend/govuk/components/radios/_index.scss +0 -8
- data/node_modules/govuk-frontend/govuk/components/radios/fixtures.json +44 -45
- data/node_modules/govuk-frontend/govuk/components/radios/radios.js +4 -4
- data/node_modules/govuk-frontend/govuk/components/radios/template.njk +2 -9
- data/node_modules/govuk-frontend/govuk/components/select/_index.scss +6 -1
- data/node_modules/govuk-frontend/govuk/components/select/fixtures.json +3 -3
- data/node_modules/govuk-frontend/govuk/components/skip-link/_index.scss +13 -0
- data/node_modules/govuk-frontend/govuk/components/skip-link/fixtures.json +9 -9
- data/node_modules/govuk-frontend/govuk/components/skip-link/skip-link.js +1108 -0
- data/node_modules/govuk-frontend/govuk/components/skip-link/template.njk +1 -1
- data/node_modules/govuk-frontend/govuk/components/summary-list/_index.scss +20 -23
- data/node_modules/govuk-frontend/govuk/components/summary-list/fixtures.json +86 -1
- data/node_modules/govuk-frontend/govuk/components/summary-list/template.njk +1 -4
- data/node_modules/govuk-frontend/govuk/components/tabs/_index.scss +2 -2
- data/node_modules/govuk-frontend/govuk/components/tabs/tabs.js +2 -2
- data/node_modules/govuk-frontend/govuk/components/tag/_index.scss +0 -5
- data/node_modules/govuk-frontend/govuk/components/tag/fixtures.json +2 -2
- data/node_modules/govuk-frontend/govuk/components/textarea/_index.scss +1 -1
- data/node_modules/govuk-frontend/govuk/components/textarea/fixtures.json +4 -4
- data/node_modules/govuk-frontend/govuk/core/_all.scss +0 -1
- data/node_modules/govuk-frontend/govuk/core/_global-styles.scss +0 -6
- data/node_modules/govuk-frontend/govuk/core/_links.scss +0 -6
- data/node_modules/govuk-frontend/govuk/core/_lists.scss +0 -6
- data/node_modules/govuk-frontend/govuk/core/_section-break.scss +0 -6
- data/node_modules/govuk-frontend/govuk/core/_typography.scss +0 -6
- data/node_modules/govuk-frontend/govuk/objects/_all.scss +1 -0
- data/node_modules/govuk-frontend/govuk/objects/_main-wrapper.scss +15 -30
- data/node_modules/govuk-frontend/govuk/{core → objects}/_template.scss +1 -5
- data/node_modules/govuk-frontend/govuk/overrides/_display.scss +0 -6
- data/node_modules/govuk-frontend/govuk/overrides/_spacing.scss +0 -6
- data/node_modules/govuk-frontend/govuk/overrides/_text-align.scss +0 -6
- data/node_modules/govuk-frontend/govuk/overrides/_typography.scss +0 -6
- data/node_modules/govuk-frontend/govuk/overrides/_width.scss +0 -6
- data/node_modules/govuk-frontend/govuk/settings/_colours-organisations.scss +3 -0
- data/node_modules/govuk-frontend/govuk/settings/_measurements.scss +0 -10
- data/node_modules/govuk-frontend/govuk/tools/_all.scss +0 -1
- data/node_modules/govuk-frontend/package.json +1 -1
- metadata +22 -37
- data/app/assets/javascripts/govuk_publishing_components/lib/header-navigation.js +0 -100
- data/lib/govuk_publishing_components/presenters/select.rb +0 -43
- data/lib/tasks/govuk_publishing_components_tasks.rake +0 -49
- data/node_modules/govuk-frontend/govuk/tools/_iff.scss +0 -17
@@ -96,7 +96,7 @@ examples:
|
|
96
96
|
}
|
97
97
|
]
|
98
98
|
with_a_different_heading_level:
|
99
|
-
description: Steps have a
|
99
|
+
description: Steps have a `h2` by default, but this can be changed. The heading level does not change any styling.
|
100
100
|
data:
|
101
101
|
heading_level: 3
|
102
102
|
steps: [
|
@@ -164,7 +164,7 @@ examples:
|
|
164
164
|
]
|
165
165
|
remember_last_opened_step:
|
166
166
|
description: |
|
167
|
-
If steps are opened their IDs are added to an array in sessionStorage
|
167
|
+
If steps are opened their IDs are added to an array in `sessionStorage`, so that if the user returns to this page in the same session, those steps will be opened on page load. This option can technically be used together with the option to open a step by default, but this is not recommended as it could confuse users.
|
168
168
|
data:
|
169
169
|
remember_last_step: true
|
170
170
|
steps: [
|
@@ -192,9 +192,9 @@ examples:
|
|
192
192
|
Links can have the following attributes:
|
193
193
|
|
194
194
|
- style, an attribute on the parent list that controls its appearance. Defaults to optional but can be set to 'choice' (adds indent and bullets to the list)
|
195
|
-
- context
|
196
|
-
- active
|
197
|
-
- highlight_step
|
195
|
+
- `context`, an optional text field to show some extra information after the link, usually a monetary value
|
196
|
+
- `active`, whether to make the link highlighted (to indicate the current page)
|
197
|
+
- `highlight_step`, a general option to highlight the step. Usually the active link would be in the active step, but in some circumstances there might be an active step but no highlighted link.
|
198
198
|
data:
|
199
199
|
highlight_step: 2
|
200
200
|
show_step: 2
|
@@ -338,11 +338,11 @@ examples:
|
|
338
338
|
|
339
339
|
If a link is in a step by step navigation more than once and the user is on that page, the backend doesn't know which link to highlight, so it highlights both of them.
|
340
340
|
|
341
|
-
JavaScript is included in the component to solve this. It uses sessionStorage to capture the data-position attribute of non-external links when clicked, and then uses this value to decide which link to highlight after the new page loads. It uses the value of the tracking_id option to uniquely identify the current step nav in the session (if this is not passed to the component this may result in other step navs having the wrong link highlighted).
|
341
|
+
JavaScript is included in the component to solve this. It uses `sessionStorage` to capture the data-position attribute of non-external links when clicked, and then uses this value to decide which link to highlight after the new page loads. It uses the value of the `tracking_id` option to uniquely identify the current step nav in the session (if this is not passed to the component this may result in other step navs having the wrong link highlighted).
|
342
342
|
|
343
|
-
If a user has not clicked a link (i.e. has visited the page without first clicking on a step by step navigation) only the first duplicate link will be highlighted. If that link is not in the active step, the
|
343
|
+
If a user has not clicked a link (i.e. has visited the page without first clicking on a step by step navigation) only the first duplicate link will be highlighted. If that link is not in the active step, the JavaScript makes the highlighted link's parent the active step. If there is no active step, the first active link will be highlighted (but there should always be an active step).
|
344
344
|
|
345
|
-
The example below will show all non-external links highlighted if
|
345
|
+
The example below will show all non-external links highlighted if JavaScript is disabled. In the real world no more than two or three links are likely to be highlighted at once.
|
346
346
|
|
347
347
|
Changes to the active step and highlighted link are also applied on click, if the user clicks one of the other links that is to the same page (they are amended by the component to be jump links to the top of the page). Open this example using the 'preview' link and try clicking on the 'internal' links to see how it behaves.
|
348
348
|
data:
|
@@ -417,15 +417,15 @@ examples:
|
|
417
417
|
|
418
418
|
The solution is to track the step by step journey the user is on.
|
419
419
|
|
420
|
-
This has been achieved by adding a query string to all of the internal links in the step by step that contains the content_id of the step by step.
|
420
|
+
This has been achieved by adding a query string to all of the internal links in the step by step that contains the `content_id` of the step by step.
|
421
421
|
|
422
|
-
For example, if the step by step contains a link to [/check-uk-visa](/check-uk-visa), the component will
|
422
|
+
For example, if the step by step contains a link to [/check-uk-visa](/check-uk-visa), the component will render the link as [/check-uk-visa?step-by-step-nav=d8f3c2e0-d544-4664-9616-ab71323e4d18](/check-uk-visa?step-by-step-nav=d8f3c2e0-d544-4664-9616-ab71323e4d18)
|
423
423
|
|
424
424
|
As long as the user follows the links in the step by step (and not the inline links in the content), the component will know which step by step journey the user is on.
|
425
425
|
|
426
|
-
If the content item is part of multiple step by steps, the component fetches the content_id of the `active` step by step from the query string and expands that one. The other step by steps that the content item is part of are displayed as a list of titles under an "Also part of" heading.
|
426
|
+
If the content item is part of multiple step by steps, the component fetches the `content_id` of the `active` step by step from the query string and expands that one. The other step by steps that the content item is part of are displayed as a list of titles under an "Also part of" heading.
|
427
427
|
|
428
|
-
Additionally, if content designers have chosen to "hide" a step by step on a content page, but we can see that the user is following a step by step journey (the content_id of the step by step is in the querystring), the step by step will still be displayed and expanded in the sidebar, and the other step by steps that the content item is part of, but content designers have chosen to hide will also be displayed as a list of titles under an "Also part of heading".
|
428
|
+
Additionally, if content designers have chosen to "hide" a step by step on a content page, but we can see that the user is following a step by step journey (the `content_id` of the step by step is in the querystring), the step by step will still be displayed and expanded in the sidebar, and the other step by steps that the content item is part of, but content designers have chosen to hide will also be displayed as a list of titles under an "Also part of heading".
|
429
429
|
|
430
430
|
In both cases, we never show more than 5 step by steps in the list.
|
431
431
|
|
@@ -523,7 +523,7 @@ examples:
|
|
523
523
|
description: |
|
524
524
|
Steps can be optional. This is controlled by two parameters, 'optional' and 'logic'.
|
525
525
|
|
526
|
-
- Optional steps used to have a dotted line down the side but this was removed as it confused users. In some cases we may still need to record if a step is optional, so if this parameter is applied,
|
526
|
+
- Optional steps used to have a dotted line down the side but this was removed as it confused users. In some cases we may still need to record if a step is optional, so if this parameter is applied, Google Analytics tracking events will have 'optional' appended to the end of the eventLabel.
|
527
527
|
- Logic will change the number next to a step to the word 'and' or the word 'or'.
|
528
528
|
|
529
529
|
If a step is optional this should be conveyed by the text within that step.
|
@@ -2,7 +2,7 @@ name: "Tabs (experimental)"
|
|
2
2
|
description: "The tabs component lets users toggle between related sections of content."
|
3
3
|
body: |
|
4
4
|
This component is based on the [GOV.UK Design System tabs component](https://design-system.service.gov.uk/components/tabs/)
|
5
|
-
and is currently experimental. If using this component, please feed back any research findings to the Design System team](https://design-system.service.gov.uk/get-in-touch/).
|
5
|
+
and is currently experimental. If using this component, please feed back any research findings to the [GOV.UK Design System team](https://design-system.service.gov.uk/get-in-touch/).
|
6
6
|
|
7
7
|
The tabs component lets users navigate between related sections of content on a single page,
|
8
8
|
displaying one section at a time. Note that they are not intended to be used to navigate
|
data/app/views/govuk_publishing_components/components/layout_header/_navigation_items.html.erb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
<% navigation_aria_label ||= "Top level" %>
|
2
2
|
|
3
3
|
<% if navigation_items.any? %>
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
<ul id="navigation" class="govuk-header__navigation
|
4
|
+
<%= tag.nav class: "gem-c-header__nav govuk-header__navigation govuk-header__navigation--end", aria: { label: navigation_aria_label } do %>
|
5
|
+
<button
|
6
|
+
aria-controls="navigation"
|
7
|
+
aria-label="Show or hide Top Level Navigation"
|
8
|
+
class="govuk-header__menu-button govuk-js-header-toggle gem-c-header__menu-button govuk-!-display-none-print"
|
9
|
+
type="button"
|
10
|
+
data-button-name="menu"
|
11
|
+
>
|
12
|
+
<%= t("components.layout_header.menu") %>
|
13
|
+
</button>
|
14
|
+
<ul id="navigation" class="govuk-header__navigation-list">
|
15
15
|
<% navigation_items.each_with_index do |item, index| %>
|
16
16
|
<%
|
17
17
|
li_classes = %w(govuk-header__navigation-item)
|
@@ -10,6 +10,7 @@ Rails.application.config.assets.precompile += %w[
|
|
10
10
|
govuk_publishing_components/vendor/lux/lux-reporter.js
|
11
11
|
govuk_publishing_components/vendor/lux/lux-measurer.js
|
12
12
|
govuk_publishing_components/all_components.js
|
13
|
+
govuk_publishing_components/dependencies.js
|
13
14
|
govuk_publishing_components/ie.js
|
14
15
|
govuk_publishing_components/modules.js
|
15
16
|
govuk_publishing_components/vendor/modernizr.js
|
@@ -1,6 +1,16 @@
|
|
1
1
|
module GovukPublishingComponents
|
2
2
|
module Presenters
|
3
3
|
class Attachment
|
4
|
+
# DfE, DWP, DHSC, HMRC, DVSA and PHE are taking part in a pilot to use a form
|
5
|
+
# rather than direct email for users to request accessible formats. When the pilot
|
6
|
+
# scheme is rolled out further this can be removed.
|
7
|
+
EMAILS_IN_ACCESSIBLE_FORMAT_REQUEST_PILOT = %w[alternative.formats@education.gov.uk
|
8
|
+
accessible.formats@dwp.gov.uk
|
9
|
+
publications@dhsc.gov.uk
|
10
|
+
different.format@hmrc.gov.uk
|
11
|
+
gov.uk.publishing@dvsa.gov.uk
|
12
|
+
publications@phe.gov.uk].freeze
|
13
|
+
|
4
14
|
delegate :opendocument?, :document?, :spreadsheet?, to: :content_type
|
5
15
|
|
6
16
|
attr_reader :attachment_data
|
@@ -8,6 +18,7 @@ module GovukPublishingComponents
|
|
8
18
|
# Expects a hash of attachment data
|
9
19
|
# * title and url are required
|
10
20
|
# * content_type, filename, file_size, number of pages, alternative_format_contact_email can be provided
|
21
|
+
# * attachment_id and owning_document_content_id are required to use the accessible format request form
|
11
22
|
def initialize(attachment_data)
|
12
23
|
@attachment_data = attachment_data.with_indifferent_access
|
13
24
|
end
|
@@ -47,6 +58,14 @@ module GovukPublishingComponents
|
|
47
58
|
attachment_data[:alternative_format_contact_email]
|
48
59
|
end
|
49
60
|
|
61
|
+
def attachment_id
|
62
|
+
attachment_data[:attachment_id]
|
63
|
+
end
|
64
|
+
|
65
|
+
def owning_document_content_id
|
66
|
+
attachment_data[:owning_document_content_id]
|
67
|
+
end
|
68
|
+
|
50
69
|
def reference
|
51
70
|
reference = []
|
52
71
|
reference << "ISBN #{attachment_data[:isbn]}" if attachment_data[:isbn].present?
|
@@ -71,6 +90,10 @@ module GovukPublishingComponents
|
|
71
90
|
attachment_data[:command_paper_number].present? || attachment_data[:hoc_paper_number].present? || attachment_data[:unnumbered_command_paper].eql?(true) || attachment_data[:unnumbered_hoc_paper].eql?(true)
|
72
91
|
end
|
73
92
|
|
93
|
+
def display_accessible_format_request_form_link?
|
94
|
+
EMAILS_IN_ACCESSIBLE_FORMAT_REQUEST_PILOT.include?(alternative_format_contact_email) && owning_document_content_id.present? && attachment_id.present?
|
95
|
+
end
|
96
|
+
|
74
97
|
class SupportedContentType
|
75
98
|
attr_reader :content_type_data
|
76
99
|
|
@@ -0,0 +1,85 @@
|
|
1
|
+
module GovukPublishingComponents
|
2
|
+
module Presenters
|
3
|
+
class SelectHelper
|
4
|
+
attr_reader :options, :option_markup, :selected_option, :error_message, :error_id, :hint, :hint_id, :describedby
|
5
|
+
|
6
|
+
def initialize(local_assigns)
|
7
|
+
@options = local_assigns[:options] || []
|
8
|
+
@error_message = local_assigns[:error_message]
|
9
|
+
@error_id = local_assigns[:error_id] || nil
|
10
|
+
@hint = local_assigns[:hint] || nil
|
11
|
+
@hint_id = local_assigns[:hint_id] || nil
|
12
|
+
@heading_size = local_assigns[:heading_size]
|
13
|
+
@full_width = local_assigns[:full_width] || false
|
14
|
+
@option_markup = get_options
|
15
|
+
@describedby = get_describedby
|
16
|
+
end
|
17
|
+
|
18
|
+
def data_tracking?
|
19
|
+
@options.any? { |item| item[:data_attributes] && item[:data_attributes][:track_category] && item[:data_attributes][:track_action] }
|
20
|
+
end
|
21
|
+
|
22
|
+
def css_classes
|
23
|
+
classes = %w[govuk-form-group gem-c-select]
|
24
|
+
classes << "govuk-form-group--error" if @error_message
|
25
|
+
classes
|
26
|
+
end
|
27
|
+
|
28
|
+
def select_classes
|
29
|
+
classes = %w[govuk-select]
|
30
|
+
classes << "gem-c-select__select--full-width" if @full_width
|
31
|
+
classes << "govuk-select--error" if @error_id
|
32
|
+
classes
|
33
|
+
end
|
34
|
+
|
35
|
+
def label_classes
|
36
|
+
classes = %w[govuk-label]
|
37
|
+
classes << "govuk-label--#{@heading_size}" if @heading_size
|
38
|
+
classes
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def get_options
|
44
|
+
return if options.nil?
|
45
|
+
|
46
|
+
options.map do |option|
|
47
|
+
@selected_option = option[:value] if option[:selected]
|
48
|
+
[
|
49
|
+
option[:text],
|
50
|
+
option[:value],
|
51
|
+
options_data_attribute(option[:data_attributes]),
|
52
|
+
]
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def options_data_attribute(attributes)
|
57
|
+
return {} if attributes.nil?
|
58
|
+
|
59
|
+
attrs = {}
|
60
|
+
attributes.each do |key, value|
|
61
|
+
key_name = "data-#{key.to_s.split('_').join('-')}"
|
62
|
+
attrs[key_name] = value.is_a?(Hash) ? value.to_json : value
|
63
|
+
end
|
64
|
+
|
65
|
+
attrs
|
66
|
+
end
|
67
|
+
|
68
|
+
def get_describedby
|
69
|
+
describedby = %w[]
|
70
|
+
|
71
|
+
if @error_message || @error_id
|
72
|
+
@error_id ||= "error-#{SecureRandom.hex(4)}"
|
73
|
+
describedby << @error_id
|
74
|
+
end
|
75
|
+
|
76
|
+
if @hint
|
77
|
+
@hint_id ||= "hint-#{SecureRandom.hex(4)}"
|
78
|
+
describedby << @hint_id
|
79
|
+
end
|
80
|
+
|
81
|
+
describedby
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -21,7 +21,7 @@ require "govuk_publishing_components/presenters/content_breadcrumbs_based_on_pri
|
|
21
21
|
require "govuk_publishing_components/presenters/content_breadcrumbs_based_on_taxons"
|
22
22
|
require "govuk_publishing_components/presenters/content_breadcrumbs_based_on_topic"
|
23
23
|
require "govuk_publishing_components/presenters/checkboxes_helper"
|
24
|
-
require "govuk_publishing_components/presenters/
|
24
|
+
require "govuk_publishing_components/presenters/select_helper"
|
25
25
|
require "govuk_publishing_components/presenters/meta_tags"
|
26
26
|
require "govuk_publishing_components/presenters/content_item"
|
27
27
|
require "govuk_publishing_components/presenters/translation_nav_helper"
|