ccs-frontend_helpers 0.1.0.rc.1 → 0.1.0.rc.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +5 -1
- data/.ruby-version +1 -0
- data/CHANGELOG.md +4 -1
- data/Gemfile.lock +71 -71
- data/lib/ccs/components/base.rb +64 -0
- data/lib/ccs/components/ccs/dashboard_section/panel.rb +55 -0
- data/lib/ccs/components/ccs/dashboard_section.rb +71 -0
- data/lib/ccs/components/ccs/footer/link.rb +53 -0
- data/lib/ccs/components/ccs/footer/meta.rb +58 -0
- data/lib/ccs/components/ccs/footer/navigation.rb +59 -0
- data/lib/ccs/components/ccs/footer.rb +93 -0
- data/lib/ccs/components/ccs/header/link.rb +58 -0
- data/lib/ccs/components/ccs/header/navigation.rb +97 -0
- data/lib/ccs/components/ccs/header/service_authentication.rb +52 -0
- data/lib/ccs/components/ccs/header.rb +108 -0
- data/lib/ccs/components/ccs/logo.rb +45 -0
- data/lib/ccs/components/govuk/accordion/section/content.rb +53 -0
- data/lib/ccs/components/govuk/accordion/section/header.rb +57 -0
- data/lib/ccs/components/govuk/accordion/section.rb +60 -0
- data/lib/ccs/components/govuk/accordion.rb +56 -0
- data/lib/ccs/components/govuk/back_link.rb +49 -0
- data/lib/ccs/components/govuk/breadcrumbs/link.rb +55 -0
- data/lib/ccs/components/govuk/breadcrumbs.rb +53 -0
- data/lib/ccs/components/govuk/button.rb +105 -0
- data/lib/ccs/components/govuk/cookie_banner/action.rb +58 -0
- data/lib/ccs/components/govuk/cookie_banner/message.rb +78 -0
- data/lib/ccs/components/govuk/cookie_banner.rb +53 -0
- data/lib/ccs/components/govuk/details.rb +51 -0
- data/lib/ccs/components/govuk/error_message.rb +58 -0
- data/lib/ccs/components/govuk/error_summary/item.rb +52 -0
- data/lib/ccs/components/govuk/error_summary.rb +68 -0
- data/lib/ccs/components/govuk/field/input/character_count.rb +127 -0
- data/lib/ccs/components/govuk/field/input/file_upload.rb +42 -0
- data/lib/ccs/components/govuk/field/input/select.rb +80 -0
- data/lib/ccs/components/govuk/field/input/text_input/fix.rb +53 -0
- data/lib/ccs/components/govuk/field/input/text_input.rb +95 -0
- data/lib/ccs/components/govuk/field/input/textarea.rb +57 -0
- data/lib/ccs/components/govuk/field/input.rb +60 -0
- data/lib/ccs/components/govuk/field/inputs/checkboxes.rb +67 -0
- data/lib/ccs/components/govuk/field/inputs/date_input/item.rb +63 -0
- data/lib/ccs/components/govuk/field/inputs/date_input.rb +87 -0
- data/lib/ccs/components/govuk/field/inputs/item/checkbox/form.rb +45 -0
- data/lib/ccs/components/govuk/field/inputs/item/checkbox/tag.rb +41 -0
- data/lib/ccs/components/govuk/field/inputs/item/checkbox.rb +48 -0
- data/lib/ccs/components/govuk/field/inputs/item/divider.rb +48 -0
- data/lib/ccs/components/govuk/field/inputs/item/radio/form.rb +42 -0
- data/lib/ccs/components/govuk/field/inputs/item/radio/tag.rb +41 -0
- data/lib/ccs/components/govuk/field/inputs/item/radio.rb +48 -0
- data/lib/ccs/components/govuk/field/inputs/item.rb +109 -0
- data/lib/ccs/components/govuk/field/inputs/radios.rb +67 -0
- data/lib/ccs/components/govuk/field/inputs.rb +55 -0
- data/lib/ccs/components/govuk/field.rb +106 -0
- data/lib/ccs/components/govuk/fieldset/legend.rb +63 -0
- data/lib/ccs/components/govuk/fieldset.rb +52 -0
- data/lib/ccs/components/govuk/footer/link.rb +53 -0
- data/lib/ccs/components/govuk/footer/meta.rb +58 -0
- data/lib/ccs/components/govuk/footer/navigation.rb +59 -0
- data/lib/ccs/components/govuk/footer.rb +129 -0
- data/lib/ccs/components/govuk/form_group.rb +58 -0
- data/lib/ccs/components/govuk/header/link.rb +54 -0
- data/lib/ccs/components/govuk/header/navigation.rb +70 -0
- data/lib/ccs/components/govuk/header.rb +105 -0
- data/lib/ccs/components/govuk/hint.rb +47 -0
- data/lib/ccs/components/govuk/inset_text.rb +50 -0
- data/lib/ccs/components/govuk/label.rb +83 -0
- data/lib/ccs/components/govuk/notification_banner.rb +105 -0
- data/lib/ccs/components/govuk/pagination/increment/next.rb +42 -0
- data/lib/ccs/components/govuk/pagination/increment/previous.rb +41 -0
- data/lib/ccs/components/govuk/pagination/increment.rb +96 -0
- data/lib/ccs/components/govuk/pagination/item/ellipsis.rb +26 -0
- data/lib/ccs/components/govuk/pagination/item/form.rb +47 -0
- data/lib/ccs/components/govuk/pagination/item/tag.rb +45 -0
- data/lib/ccs/components/govuk/pagination/item.rb +62 -0
- data/lib/ccs/components/govuk/pagination.rb +94 -0
- data/lib/ccs/components/govuk/panel.rb +60 -0
- data/lib/ccs/components/govuk/phase_banner.rb +67 -0
- data/lib/ccs/components/govuk/skip_link.rb +49 -0
- data/lib/ccs/components/govuk/step_by_step_navigation/section/content/list/item.rb +51 -0
- data/lib/ccs/components/govuk/step_by_step_navigation/section/content/list.rb +48 -0
- data/lib/ccs/components/govuk/step_by_step_navigation/section/content/paragraph.rb +43 -0
- data/lib/ccs/components/govuk/step_by_step_navigation/section/content.rb +61 -0
- data/lib/ccs/components/govuk/step_by_step_navigation/section/heading.rb +67 -0
- data/lib/ccs/components/govuk/step_by_step_navigation/section.rb +54 -0
- data/lib/ccs/components/govuk/step_by_step_navigation.rb +57 -0
- data/lib/ccs/components/govuk/summary_list/action/link.rb +57 -0
- data/lib/ccs/components/govuk/summary_list/card/actions.rb +57 -0
- data/lib/ccs/components/govuk/summary_list/card/title.rb +49 -0
- data/lib/ccs/components/govuk/summary_list/card.rb +61 -0
- data/lib/ccs/components/govuk/summary_list/row/actions.rb +57 -0
- data/lib/ccs/components/govuk/summary_list/row/key.rb +45 -0
- data/lib/ccs/components/govuk/summary_list/row/value.rb +45 -0
- data/lib/ccs/components/govuk/summary_list/row.rb +63 -0
- data/lib/ccs/components/govuk/summary_list.rb +72 -0
- data/lib/ccs/components/govuk/table/body/data_cell.rb +51 -0
- data/lib/ccs/components/govuk/table/body/head_cell.rb +50 -0
- data/lib/ccs/components/govuk/table/header/head_cell.rb +52 -0
- data/lib/ccs/components/govuk/table.rb +109 -0
- data/lib/ccs/components/govuk/tabs/panel.rb +56 -0
- data/lib/ccs/components/govuk/tabs/tab.rb +54 -0
- data/lib/ccs/components/govuk/tabs.rb +64 -0
- data/lib/ccs/components/govuk/tag.rb +49 -0
- data/lib/ccs/components/govuk/warning_text.rb +59 -0
- data/lib/ccs/frontend_helpers/ccs_frontend/dashboard_section.rb +25 -0
- data/lib/ccs/frontend_helpers/ccs_frontend/footer.rb +16 -131
- data/lib/ccs/frontend_helpers/ccs_frontend/header.rb +16 -195
- data/lib/ccs/frontend_helpers/ccs_frontend.rb +2 -4
- data/lib/ccs/frontend_helpers/govuk_frontend/accordion.rb +16 -105
- data/lib/ccs/frontend_helpers/govuk_frontend/back_link.rb +16 -29
- data/lib/ccs/frontend_helpers/govuk_frontend/breadcrumbs.rb +16 -66
- data/lib/ccs/frontend_helpers/govuk_frontend/button.rb +16 -117
- data/lib/ccs/frontend_helpers/govuk_frontend/character_count.rb +26 -0
- data/lib/ccs/frontend_helpers/govuk_frontend/checkboxes.rb +26 -0
- data/lib/ccs/frontend_helpers/govuk_frontend/cookie_banner.rb +16 -126
- data/lib/ccs/frontend_helpers/govuk_frontend/date_input.rb +26 -0
- data/lib/ccs/frontend_helpers/govuk_frontend/details.rb +18 -36
- data/lib/ccs/frontend_helpers/govuk_frontend/error_message.rb +31 -54
- data/lib/ccs/frontend_helpers/govuk_frontend/error_summary.rb +32 -86
- data/lib/ccs/frontend_helpers/govuk_frontend/fieldset.rb +18 -61
- data/lib/ccs/frontend_helpers/govuk_frontend/file_upload.rb +26 -0
- data/lib/ccs/frontend_helpers/govuk_frontend/footer.rb +16 -173
- data/lib/ccs/frontend_helpers/govuk_frontend/form_group.rb +26 -39
- data/lib/ccs/frontend_helpers/govuk_frontend/header.rb +16 -151
- data/lib/ccs/frontend_helpers/govuk_frontend/hint.rb +17 -28
- data/lib/ccs/frontend_helpers/govuk_frontend/input.rb +26 -0
- data/lib/ccs/frontend_helpers/govuk_frontend/inset_text.rb +18 -34
- data/lib/ccs/frontend_helpers/govuk_frontend/label.rb +17 -82
- data/lib/ccs/frontend_helpers/govuk_frontend/notification_banner.rb +18 -126
- data/lib/ccs/frontend_helpers/govuk_frontend/pagination.rb +16 -326
- data/lib/ccs/frontend_helpers/govuk_frontend/panel.rb +18 -41
- data/lib/ccs/frontend_helpers/govuk_frontend/phase_banner.rb +18 -39
- data/lib/ccs/frontend_helpers/govuk_frontend/radios.rb +26 -0
- data/lib/ccs/frontend_helpers/govuk_frontend/select.rb +26 -0
- data/lib/ccs/frontend_helpers/govuk_frontend/skip_link.rb +16 -30
- data/lib/ccs/frontend_helpers/govuk_frontend/step_by_step_navigation.rb +23 -204
- data/lib/ccs/frontend_helpers/govuk_frontend/summary_list.rb +16 -216
- data/lib/ccs/frontend_helpers/govuk_frontend/table.rb +16 -114
- data/lib/ccs/frontend_helpers/govuk_frontend/tabs.rb +16 -85
- data/lib/ccs/frontend_helpers/govuk_frontend/tag.rb +16 -32
- data/lib/ccs/frontend_helpers/govuk_frontend/textarea.rb +26 -0
- data/lib/ccs/frontend_helpers/govuk_frontend/warning_text.rb +18 -43
- data/lib/ccs/frontend_helpers/govuk_frontend.rb +17 -19
- data/lib/ccs/frontend_helpers/version.rb +1 -1
- metadata +110 -14
- data/lib/ccs/frontend_helpers/ccs_frontend/dashboard_panels.rb +0 -79
- data/lib/ccs/frontend_helpers/ccs_frontend/logo.rb +0 -49
- data/lib/ccs/frontend_helpers/govuk_frontend/field/character_count.rb +0 -165
- data/lib/ccs/frontend_helpers/govuk_frontend/field/checkboxes.rb +0 -200
- data/lib/ccs/frontend_helpers/govuk_frontend/field/date_input.rb +0 -153
- data/lib/ccs/frontend_helpers/govuk_frontend/field/file_upload.rb +0 -83
- data/lib/ccs/frontend_helpers/govuk_frontend/field/input.rb +0 -153
- data/lib/ccs/frontend_helpers/govuk_frontend/field/radios.rb +0 -201
- data/lib/ccs/frontend_helpers/govuk_frontend/field/select.rb +0 -124
- data/lib/ccs/frontend_helpers/govuk_frontend/field/textarea.rb +0 -106
- data/lib/ccs/frontend_helpers/govuk_frontend/field.rb +0 -213
- data/lib/ccs/frontend_helpers/shared_methods.rb +0 -27
@@ -1,75 +1,25 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
require_relative '../shared_methods'
|
3
|
+
require_relative '../../components/govuk/breadcrumbs'
|
6
4
|
|
7
5
|
module CCS
|
8
|
-
module FrontendHelpers
|
9
|
-
|
10
|
-
|
6
|
+
module FrontendHelpers::GovUKFrontend
|
7
|
+
# = GOV.UK Breadcrumbs
|
8
|
+
#
|
9
|
+
# This helper is used for generating the breadcrumbs component from the
|
10
|
+
# {https://design-system.service.gov.uk/components/breadcrumbs GDS - Components - Breadcrumbs}
|
11
|
+
|
12
|
+
module Breadcrumbs
|
13
|
+
# Generates the HTML for the GOV.UK breadcrumbs component
|
11
14
|
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
include ActionView::Context
|
18
|
-
include ActionView::Helpers::TagHelper
|
19
|
-
include ActionView::Helpers::TextHelper
|
20
|
-
include ActionView::Helpers::UrlHelper
|
21
|
-
|
22
|
-
# Generates the HTML for the GOV.UK breadcrumbs component
|
23
|
-
#
|
24
|
-
# @param govuk_breadcrumb_items [Array<Hash>] An array of links for the breadcrumbs list. See {#govuk_breadcrumb_link} for details of the items in the array.
|
25
|
-
# @param govuk_breadcrumbs_options [Hash] options that will be used in customising the HTML
|
26
|
-
#
|
27
|
-
# @option govuk_breadcrumbs_options [String] :classes additional CSS classes for the breadcrumbs HTML
|
28
|
-
# @option govuk_breadcrumbs_options [Boolean] :collapse_on_mobile indicates if it is to colapse breadcrumbs on mobile
|
29
|
-
# @option govuk_breadcrumbs_options [Hash] :attributes any additional attributes that will added as part of the HTML
|
30
|
-
#
|
31
|
-
# @return [ActiveSupport::SafeBuffer] the HTML for the GOV.UK Breadcrumbs
|
32
|
-
# which can then be rendered on the page
|
33
|
-
|
34
|
-
def govuk_breadcrumbs(govuk_breadcrumb_items, **govuk_breadcrumbs_options)
|
35
|
-
initialise_attributes_and_set_classes(govuk_breadcrumbs_options, 'govuk-breadcrumbs')
|
36
|
-
|
37
|
-
govuk_breadcrumbs_options[:attributes][:class] << ' govuk-breadcrumbs--collapse-on-mobile' if govuk_breadcrumbs_options[:collapse_on_mobile]
|
38
|
-
|
39
|
-
tag.div(**govuk_breadcrumbs_options[:attributes]) do
|
40
|
-
tag.ol(class: 'govuk-breadcrumbs__list') do
|
41
|
-
govuk_breadcrumb_items.each { |govuk_breadcrumb_item| concat(govuk_breadcrumb_link(govuk_breadcrumb_item)) }
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
private
|
47
|
-
|
48
|
-
# Generates the HTML for each link in the breadcrumbs.
|
49
|
-
# It is called by {#govuk_breadcrumbs} which will pass in the breadcrum item.
|
50
|
-
#
|
51
|
-
# @param govuk_breadcrumb_item [Hash] a hash containg options for the breadcrumb item
|
52
|
-
#
|
53
|
-
# @option govuk_breadcrumb_item [String] :text the text for the link
|
54
|
-
# @option govuk_breadcrumb_item [String] :href the URI for the link. If blank it is assumed that this item relates to current page
|
55
|
-
# @option govuk_breadcrumb_item [Hash] :attributes any additional attributes that will added as part of the HTML.
|
56
|
-
# If the link is blank then it defaults to +{ aria: { current: 'page' } }+
|
57
|
-
#
|
58
|
-
# @return [ActiveSupport::SafeBuffer] the HTML for the GOV.UK Breadcrumb list item
|
59
|
-
|
60
|
-
def govuk_breadcrumb_link(govuk_breadcrumb_item)
|
61
|
-
if govuk_breadcrumb_item[:href].present?
|
62
|
-
(govuk_breadcrumb_item[:attributes] ||= {})[:class] = 'govuk-breadcrumbs__link'
|
15
|
+
# @param (see CCS::Components::GovUK::Breadcrumbs#initialize)
|
16
|
+
#
|
17
|
+
# @option (see CCS::Components::GovUK::Breadcrumbs#initialize)
|
18
|
+
#
|
19
|
+
# @return (see CCS::Components::GovUK::Breadcrumbs#render)
|
63
20
|
|
64
|
-
|
65
|
-
|
66
|
-
end
|
67
|
-
else
|
68
|
-
tag.li(class: 'govuk-breadcrumbs__list-item', aria: { current: 'page' }) do
|
69
|
-
govuk_breadcrumb_item[:text]
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
21
|
+
def govuk_breadcrumbs(breadcrumb_links, **options)
|
22
|
+
Components::GovUK::Breadcrumbs.new(context: self, breadcrumb_links: breadcrumb_links, **options).render
|
73
23
|
end
|
74
24
|
end
|
75
25
|
end
|
@@ -1,126 +1,25 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
require_relative '../shared_methods'
|
3
|
+
require_relative '../../components/govuk/button'
|
6
4
|
|
7
5
|
module CCS
|
8
|
-
module FrontendHelpers
|
9
|
-
|
10
|
-
|
6
|
+
module FrontendHelpers::GovUKFrontend
|
7
|
+
# = GOV.UK Button
|
8
|
+
#
|
9
|
+
# This helper is used for generating the button component from the
|
10
|
+
# {https://design-system.service.gov.uk/components/button GDS - Components - Button}
|
11
|
+
|
12
|
+
module Button
|
13
|
+
# Generates the HTML for the GOV.UK button component
|
11
14
|
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
include ActionView::Context
|
18
|
-
include ActionView::Helpers::TagHelper
|
19
|
-
include ActionView::Helpers::TextHelper
|
20
|
-
include ActionView::Helpers::UrlHelper
|
21
|
-
include ActionView::Helpers::FormTagHelper
|
22
|
-
|
23
|
-
# Generates the HTML for the GOV.UK button component
|
24
|
-
#
|
25
|
-
# @param text [String] the text that will be shown in the button
|
26
|
-
# @param govuk_button_options [Hash] options that will be used in customising the HTML
|
27
|
-
#
|
28
|
-
# @option govuk_button_options [String] :classes additional CSS classes for the button HTML
|
29
|
-
# @option govuk_button_options [Boolean] :is_start_button indicates if it is a start button
|
30
|
-
# @option govuk_button_options [String] :href the URI that will be used in anchor tag
|
31
|
-
# @option govuk_button_options [ActionView::Helpers::FormBuilder] :form the form builder used to create the submit button
|
32
|
-
# @option govuk_button_options [Hash] :attributes ({ data: { module: 'govuk-button' } }) any additional attributes that will added as part of the HTML
|
33
|
-
#
|
34
|
-
# @return [ActiveSupport::SafeBuffer] the HTML for the GOV.UK Button
|
35
|
-
# which can then be rendered on the page
|
36
|
-
|
37
|
-
def govuk_button(text, **govuk_button_options)
|
38
|
-
initialise_attributes_and_set_classes(govuk_button_options, 'govuk-button')
|
39
|
-
set_data_module(govuk_button_options, 'govuk-button')
|
40
|
-
|
41
|
-
govuk_button_options[:attributes][:class] << ' govuk-button--disabled' if govuk_button_options[:attributes][:disabled]
|
42
|
-
govuk_button_options[:attributes][:class] << ' govuk-button--start' if govuk_button_options[:is_start_button]
|
43
|
-
|
44
|
-
button_method = if govuk_button_options[:href]
|
45
|
-
:govuk_button_link
|
46
|
-
elsif govuk_button_options[:form]
|
47
|
-
:govuk_button_submit
|
48
|
-
else
|
49
|
-
:govuk_button_button
|
50
|
-
end
|
51
|
-
|
52
|
-
send(button_method, text, **govuk_button_options)
|
53
|
-
end
|
54
|
-
|
55
|
-
private
|
56
|
-
|
57
|
-
# Generates the HTML for the GOV.UK button component as an anchor tag.
|
58
|
-
# It is called by {#govuk_button} which will pass in the parameters, including any defaults.
|
59
|
-
#
|
60
|
-
# @param text [String] the text that will be shown in the button
|
61
|
-
# @param govuk_button_options [Hash] options that will be used in customising the HTML
|
62
|
-
#
|
63
|
-
# @option govuk_button_options [Boolean] :is_start_button indicates if it is a start button
|
64
|
-
# @option govuk_button_options [String] :href the URI that will be used in anchor tag
|
65
|
-
# @option govuk_button_options [Hash] :attributes any additional attributes that will added as part of the HTML
|
66
|
-
#
|
67
|
-
# @return [ActiveSupport::SafeBuffer] the HTML for the GOV.UK Button as an anchor element
|
68
|
-
# which can then be rendered on the page
|
69
|
-
|
70
|
-
def govuk_button_link(text, **govuk_button_options)
|
71
|
-
govuk_button_options[:attributes][:role] = :button
|
72
|
-
govuk_button_options[:attributes][:draggable] = false
|
73
|
-
|
74
|
-
link_to(govuk_button_options[:href], **govuk_button_options[:attributes]) do
|
75
|
-
concat(text)
|
76
|
-
concat(govuk_start_button_icon) if govuk_button_options[:is_start_button]
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
# Generates the HTML for the GOV.UK button component as a button.
|
81
|
-
# It is called by {#govuk_button} which will pass in the parameters, including any defaults.
|
82
|
-
#
|
83
|
-
# @param text [String] the text that will be shown in the button
|
84
|
-
# @param govuk_button_options [Hash] options that will be used in customising the HTML
|
85
|
-
#
|
86
|
-
# @option govuk_button_options [Boolean] :is_start_button indicates if it is a start button
|
87
|
-
# @option govuk_button_options [Hash] :attributes any additional attributes that will added as part of the HTML
|
88
|
-
#
|
89
|
-
# @return [ActiveSupport::SafeBuffer] the HTML for the GOV.UK Button as a button element
|
90
|
-
# which can then be rendered on the page
|
91
|
-
|
92
|
-
def govuk_button_button(text, **govuk_button_options)
|
93
|
-
button_tag(**govuk_button_options[:attributes]) do
|
94
|
-
concat(text)
|
95
|
-
concat(govuk_start_button_icon) if govuk_button_options[:is_start_button]
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
# Generates the HTML for the GOV.UK button component as an input.
|
100
|
-
# It is called by {#govuk_button} which will pass in the parameters, including any defaults.
|
101
|
-
#
|
102
|
-
# @param text [String] the text that will be shown in the input
|
103
|
-
# @param govuk_button_options [Hash] options that will be used in customising the HTML
|
104
|
-
#
|
105
|
-
# @option govuk_button_options [ActionView::Helpers::FormBuilder] :form the form builder used to create the submit button
|
106
|
-
# @option govuk_button_options [Hash] :attributes any additional attributes that will added as part of the HTML
|
107
|
-
#
|
108
|
-
# @return [ActiveSupport::SafeBuffer] the HTML for the GOV.UK Button as an input element
|
109
|
-
# which can then be rendered on the page
|
110
|
-
|
111
|
-
def govuk_button_submit(text, **govuk_button_options)
|
112
|
-
govuk_button_options[:form].submit(text, **govuk_button_options[:attributes])
|
113
|
-
end
|
114
|
-
|
115
|
-
# Generates the arrow for the start button option as part of {#govuk_button}
|
116
|
-
#
|
117
|
-
# @return [ActiveSupport::SafeBuffer] the HTML for the arrow for the start button
|
15
|
+
# @param (see CCS::Components::GovUK::Button#initialize)
|
16
|
+
#
|
17
|
+
# @option (see CCS::Components::GovUK::Button#initialize)
|
18
|
+
#
|
19
|
+
# @return (see CCS::Components::GovUK::Button#render)
|
118
20
|
|
119
|
-
|
120
|
-
|
121
|
-
tag.path(fill: 'currentColor', d: 'M0 0h13l20 20-20 20H0l20-20z')
|
122
|
-
end
|
123
|
-
end
|
21
|
+
def govuk_button(text, **options)
|
22
|
+
Components::GovUK::Button.new(context: self, text: text, **options).render
|
124
23
|
end
|
125
24
|
end
|
126
25
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../components/govuk/field/input/character_count'
|
4
|
+
|
5
|
+
module CCS
|
6
|
+
module FrontendHelpers::GovUKFrontend
|
7
|
+
# = GOV.UK Character count
|
8
|
+
#
|
9
|
+
# This helper is used for generating the character count component from the
|
10
|
+
# {https://design-system.service.gov.uk/components/character-count GDS - Components - Character count}
|
11
|
+
|
12
|
+
module CharacterCount
|
13
|
+
# Generates the HTML for the GOV.UK Character count component
|
14
|
+
#
|
15
|
+
# @param (see CCS::Components::GovUK::Input::CharacterCount#initialize)
|
16
|
+
#
|
17
|
+
# @option (see CCS::Components::GovUK::Input::CharacterCount#initialize)
|
18
|
+
#
|
19
|
+
# @return (see CCS::Components::GovUK::Input::CharacterCount#render)
|
20
|
+
|
21
|
+
def govuk_character_count(attribute, character_count_options, **options)
|
22
|
+
Components::GovUK::Field::Input::CharacterCount.new(context: self, attribute: attribute, character_count_options: character_count_options, **options).render
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../components/govuk/field/inputs/checkboxes'
|
4
|
+
|
5
|
+
module CCS
|
6
|
+
module FrontendHelpers::GovUKFrontend
|
7
|
+
# = GOV.UK Checkboxes
|
8
|
+
#
|
9
|
+
# This helper is used for generating the checkboxes component from the
|
10
|
+
# {https://design-system.service.gov.uk/components/checkboxes GDS - Components - Checkboxes}
|
11
|
+
|
12
|
+
module Checkboxes
|
13
|
+
# Generates the HTML for the GOV.UK Checkboxes component
|
14
|
+
#
|
15
|
+
# @param (see CCS::Components::GovUK::Inputs::Checkboxes#initialize)
|
16
|
+
#
|
17
|
+
# @option (see CCS::Components::GovUK::Inputs::Checkboxes#initialize)
|
18
|
+
#
|
19
|
+
# @return (see CCS::Components::GovUK::Inputs::Checkboxes#render)
|
20
|
+
|
21
|
+
def govuk_checkboxes(attribute, checkbox_items, **options)
|
22
|
+
Components::GovUK::Field::Inputs::Checkboxes.new(context: self, attribute: attribute, checkbox_items: checkbox_items, **options).render
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -1,135 +1,25 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative '
|
3
|
+
require_relative '../../components/govuk/cookie_banner'
|
4
4
|
|
5
5
|
module CCS
|
6
|
-
module FrontendHelpers
|
7
|
-
|
8
|
-
|
6
|
+
module FrontendHelpers::GovUKFrontend
|
7
|
+
# = GOV.UK Cookie Banner
|
8
|
+
#
|
9
|
+
# This helper is used for generating the cookie banner component from the
|
10
|
+
# {https://design-system.service.gov.uk/components/cookie-banner GDS - Components - Cookie banner}
|
11
|
+
|
12
|
+
module CookieBanner
|
13
|
+
# Generates the HTML for the GOV.UK Cookie banner component
|
9
14
|
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
include ActionView::Helpers::TagHelper
|
16
|
-
include ActionView::Helpers::TextHelper
|
17
|
-
include Button
|
18
|
-
|
19
|
-
# Generates the HTML for the GOV.UK Cookie banner component
|
20
|
-
#
|
21
|
-
# @param messages [Array] the different messages you can pass into the cookie banner. See {govuk_cookie_banner_message_content}
|
22
|
-
# @param govuk_cookie_banner_options [Hash] options that will be used in customising the HTML
|
23
|
-
#
|
24
|
-
# @option govuk_cookie_banner_options [String] :classes additional CSS classes for the cookie banner HTML
|
25
|
-
# @option govuk_cookie_banner_options [Hash] :attributes any additional attributes that will added as part of the HTML
|
26
|
-
#
|
27
|
-
# @return [ActiveSupport::SafeBuffer] the HTML for the GOV.UK Cookie banner
|
28
|
-
# which can then be rendered on the page
|
29
|
-
|
30
|
-
def govuk_cookie_banner(messages, **govuk_cookie_banner_options)
|
31
|
-
determine_govuk_cookie_banner_attributes(govuk_cookie_banner_options)
|
32
|
-
|
33
|
-
tag.div(**govuk_cookie_banner_options[:attributes]) do
|
34
|
-
messages.each do |message|
|
35
|
-
initialise_attributes_and_set_classes(message, 'govuk-cookie-banner__message govuk-width-container')
|
36
|
-
|
37
|
-
concat(tag.div(**message[:attributes]) do
|
38
|
-
concat(govuk_cookie_banner_message_content(message))
|
39
|
-
concat(govuk_cookie_banner_message_actions(message[:actions])) if message[:actions]
|
40
|
-
end)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
private
|
46
|
-
|
47
|
-
# Generates the HTML for a cookie banner message content used in {govuk_cookie_banner}
|
48
|
-
#
|
49
|
-
# @param message [Hash] the options for the cookie banner message
|
50
|
-
#
|
51
|
-
# @option message [String] :heading_text the heading text that displays in the message
|
52
|
-
# @option message [ActiveSupport::SafeBuffer] :content HTML to use as content for the message
|
53
|
-
# @option message [String] :text if +:content+ is blank then this is the text used for the message
|
54
|
-
# @option message [Array] :actions the buttons and links that you want to display in the message. See {govuk_cookie_banner_message_actions}
|
55
|
-
# @option message [String] :classes additional CSS classes for the cookie message HTML
|
56
|
-
# @option message [Hash] :attributes any additional attributes that will added as part of the HTML
|
57
|
-
#
|
58
|
-
# @return [ActiveSupport::SafeBuffer] the HTML for a cookie banner message content used in {govuk_cookie_banner}
|
59
|
-
|
60
|
-
def govuk_cookie_banner_message_content(message)
|
61
|
-
tag.div(class: 'govuk-grid-row') do
|
62
|
-
tag.div(class: 'govuk-grid-column-two-thirds') do
|
63
|
-
concat(tag.h2(message[:heading_text], class: 'govuk-cookie-banner__heading govuk-heading-m')) if message[:heading_text]
|
64
|
-
concat(tag.div(class: 'govuk-cookie-banner__content') do
|
65
|
-
message[:content] || tag.p(message[:text], class: 'govuk-body')
|
66
|
-
end)
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
# rubocop:disable Metrics/AbcSize
|
72
|
-
|
73
|
-
# Generates the HTML for the cookie banner message actions used in {govuk_cookie_banner}
|
74
|
-
# It defaults to creating button unless a +href+ is set which will create a link
|
75
|
-
#
|
76
|
-
# @param message_actions [Hash] the options for the cookie banner message actions
|
77
|
-
#
|
78
|
-
# @option message_actions [String] :text the button or link text
|
79
|
-
# @option message_actions [String] :href the href for a link
|
80
|
-
# @option message_actions [String] :classes additional CSS classes for the cookie action button or link
|
81
|
-
# @option message_actions [Hash] :attributes any additional attributes that will added as part of the HTML.
|
82
|
-
# If the +:type+ key is present with a value of +:button+,
|
83
|
-
# the action will be rendered as a button
|
84
|
-
#
|
85
|
-
# @return [ActiveSupport::SafeBuffer] the HTML for the cookie banner message actions used in {govuk_cookie_banner}
|
86
|
-
|
87
|
-
def govuk_cookie_banner_message_actions(message_actions)
|
88
|
-
tag.div(class: 'govuk-button-group') do
|
89
|
-
message_actions.each do |message_action|
|
90
|
-
message_action[:attributes] ||= {}
|
91
|
-
|
92
|
-
concat(
|
93
|
-
if message_action[:href]
|
94
|
-
if message_action[:attributes][:type] == :button
|
95
|
-
govuk_button(
|
96
|
-
message_action[:text],
|
97
|
-
href: message_action[:href],
|
98
|
-
classes: message_action[:classes],
|
99
|
-
attributes: message_action[:attributes]
|
100
|
-
)
|
101
|
-
else
|
102
|
-
message_action[:attributes][:class] = "govuk-link #{message_action[:classes]}".rstrip
|
103
|
-
|
104
|
-
link_to(message_action[:text], message_action[:href], **message_action[:attributes])
|
105
|
-
end
|
106
|
-
else
|
107
|
-
govuk_button(
|
108
|
-
message_action[:text],
|
109
|
-
classes: message_action[:classes],
|
110
|
-
attributes: message_action[:attributes]
|
111
|
-
)
|
112
|
-
end
|
113
|
-
)
|
114
|
-
end
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
|
-
# rubocop:enable Metrics/AbcSize
|
119
|
-
|
120
|
-
# Sets the default attributes for {govuk_cookie_banner}
|
121
|
-
#
|
122
|
-
# @param govuk_cookie_banner_options [Hash] options that will be used in customising the HTML
|
123
|
-
#
|
124
|
-
# @option (see govuk_cookie_banner)
|
125
|
-
|
126
|
-
def determine_govuk_cookie_banner_attributes(govuk_cookie_banner_options)
|
127
|
-
initialise_attributes_and_set_classes(govuk_cookie_banner_options, 'govuk-cookie-banner')
|
15
|
+
# @param (see CCS::Components::GovUK::CookieBanner#initialize)
|
16
|
+
#
|
17
|
+
# @option (see CCS::Components::GovUK::CookieBanner#initialize)
|
18
|
+
#
|
19
|
+
# @return (see CCS::Components::GovUK::CookieBanner#render)
|
128
20
|
|
129
|
-
|
130
|
-
|
131
|
-
(govuk_cookie_banner_options[:attributes][:aria] ||= {})[:label] ||= 'Cookie banner'
|
132
|
-
end
|
21
|
+
def govuk_cookie_banner(messages, **options)
|
22
|
+
Components::GovUK::CookieBanner.new(context: self, messages: messages, **options).render
|
133
23
|
end
|
134
24
|
end
|
135
25
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../components/govuk/field/inputs/date_input'
|
4
|
+
|
5
|
+
module CCS
|
6
|
+
module FrontendHelpers::GovUKFrontend
|
7
|
+
# = GOV.UK Date Input
|
8
|
+
#
|
9
|
+
# This helper is used for generating the date input component from the
|
10
|
+
# {https://design-system.service.gov.uk/components/date-input GDS - Components - Date Input}
|
11
|
+
|
12
|
+
module DateInput
|
13
|
+
# Generates the HTML for the GOV.UK Date Input component
|
14
|
+
#
|
15
|
+
# @param (see CCS::Components::GovUK::Inputs::DateInput#initialize)
|
16
|
+
#
|
17
|
+
# @option (see CCS::Components::GovUK::Inputs::DateInput#initialize)
|
18
|
+
#
|
19
|
+
# @return (see CCS::Components::GovUK::Inputs::DateInput#render)
|
20
|
+
|
21
|
+
def govuk_date_input(attribute, **options)
|
22
|
+
Components::GovUK::Field::Inputs::DateInput.new(context: self, attribute: attribute, **options).render
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -1,45 +1,27 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
require_relative '../shared_methods'
|
3
|
+
require_relative '../../components/govuk/details'
|
6
4
|
|
7
5
|
module CCS
|
8
|
-
module FrontendHelpers
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
# {https://design-system.service.gov.uk/components/details GDS - Components - Details}
|
14
|
-
|
15
|
-
module Details
|
16
|
-
include SharedMethods
|
17
|
-
include ActionView::Context
|
18
|
-
include ActionView::Helpers::TagHelper
|
19
|
-
include ActionView::Helpers::TextHelper
|
20
|
-
|
21
|
-
# Generates the HTML for the GOV.UK Details component
|
22
|
-
#
|
23
|
-
# @param summary_text [String] the summary text for the details element
|
24
|
-
# @param govuk_details_options [Hash] options that will be used in customising the HTML
|
25
|
-
#
|
26
|
-
# @option govuk_details_options [String] :classes additional CSS classes for the details HTML
|
27
|
-
# @option govuk_details_options [Hash] :attributes ({ data: { module: 'govuk-details' } }) any additional attributes that will added as part of the HTML
|
28
|
-
#
|
29
|
-
# @yield HTML that will be contained within the 'govuk-details__text' div
|
30
|
-
#
|
31
|
-
# @return [ActiveSupport::SafeBuffer] the HTML for the GOV.UK Details
|
32
|
-
# which can then be rendered on the page
|
6
|
+
module FrontendHelpers::GovUKFrontend
|
7
|
+
# = GOV.UK Details
|
8
|
+
#
|
9
|
+
# This helper is used for generating the details component from the
|
10
|
+
# {https://design-system.service.gov.uk/components/details GDS - Components - Details}
|
33
11
|
|
34
|
-
|
35
|
-
|
36
|
-
|
12
|
+
module Details
|
13
|
+
# Generates the HTML for the GOV.UK Details component
|
14
|
+
#
|
15
|
+
# @param (see CCS::Components::GovUK::Details#initialize)
|
16
|
+
#
|
17
|
+
# @option (see CCS::Components::GovUK::Details#initialize)
|
18
|
+
#
|
19
|
+
# @yield (see CCS::Components::GovUK::Details#render)
|
20
|
+
#
|
21
|
+
# @return (see CCS::Components::GovUK::Details#render)
|
37
22
|
|
38
|
-
|
39
|
-
|
40
|
-
concat(tag.div(class: 'govuk-details__text', &block))
|
41
|
-
end
|
42
|
-
end
|
23
|
+
def govuk_details(summary_text, **options, &block)
|
24
|
+
Components::GovUK::Details.new(context: self, summary_text: summary_text, **options).render(&block)
|
43
25
|
end
|
44
26
|
end
|
45
27
|
end
|
@@ -1,66 +1,43 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
require_relative '../shared_methods'
|
3
|
+
require_relative '../../components/govuk/back_link'
|
6
4
|
|
7
5
|
module CCS
|
8
|
-
module FrontendHelpers
|
9
|
-
|
10
|
-
|
6
|
+
module FrontendHelpers::GovUKFrontend
|
7
|
+
# = GOV.UK Error Message
|
8
|
+
#
|
9
|
+
# This helper is used for generating the error message component from the
|
10
|
+
# {https://design-system.service.gov.uk/components/error-message GDS - Components - Error message}
|
11
|
+
|
12
|
+
module ErrorMessage
|
13
|
+
# Generates the HTML for the GOV.UK Error message component
|
11
14
|
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
include ActionView::Context
|
18
|
-
include ActionView::Helpers::TagHelper
|
19
|
-
include ActionView::Helpers::TextHelper
|
20
|
-
|
21
|
-
# Generates the HTML for the GOV.UK Error message component
|
22
|
-
#
|
23
|
-
# @param message [String] the message to be displayed
|
24
|
-
# @param attribute [String, Symbol] the attribute that has an error
|
25
|
-
# @param govuk_error_message_options [Hash] options that will be used in customising the HTML
|
26
|
-
#
|
27
|
-
# @option govuk_error_message_options [String] :classes additional CSS classes for the error message HTML
|
28
|
-
# @option govuk_error_message_options [String] :visually_hidden_text ('Error') visualy hidden text before the error message
|
29
|
-
# @option govuk_error_message_options [Hash] :attributes ({}) any additional attributes that will be added as part of the HTML
|
30
|
-
#
|
31
|
-
# @return [ActiveSupport::SafeBuffer] the HTML for the GOV.UK Error message
|
32
|
-
# which can then be rendered on the page
|
33
|
-
|
34
|
-
def govuk_error_message(message, attribute, **govuk_error_message_options)
|
35
|
-
initialise_attributes_and_set_classes(govuk_error_message_options, 'govuk-error-message')
|
36
|
-
|
37
|
-
govuk_error_message_options[:attributes][:id] ||= "#{attribute}-error"
|
38
|
-
visually_hidden_text = govuk_error_message_options[:visually_hidden_text] || 'Error'
|
15
|
+
# @param (see CCS::Components::GovUK::ErrorMessage#initialize)
|
16
|
+
#
|
17
|
+
# @option (see CCS::Components::GovUK::ErrorMessage#initialize)
|
18
|
+
#
|
19
|
+
# @return (see CCS::Components::GovUK::ErrorMessage#render)
|
39
20
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
end
|
44
|
-
end
|
21
|
+
def govuk_error_message(error_message, attribute, **options)
|
22
|
+
Components::GovUK::ErrorMessage.new(context: self, message: error_message, attribute: attribute, **options).render
|
23
|
+
end
|
45
24
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
# which can then be rendered on the page is returned
|
25
|
+
# Generates the HTML for the GOV.UK Error message component using the error messages in an ActiveModel
|
26
|
+
#
|
27
|
+
# @param model [ActiveModel] model that will be used to find the error message
|
28
|
+
# @param attribute [String, Symbol] the attribute that has an error
|
29
|
+
# @param options [Hash] options that will be used in customising the HTML
|
30
|
+
#
|
31
|
+
# @option (see CCS::Components::GovUK::ErrorMessage#initialize)
|
32
|
+
#
|
33
|
+
# @return [NilClass, ActiveSupport::SafeBuffer] if the error message is not on the model it will return nil,
|
34
|
+
# otherwise it returns the error message HTML
|
57
35
|
|
58
|
-
|
59
|
-
|
60
|
-
|
36
|
+
def govuk_error_message_with_model(model, attribute, **options)
|
37
|
+
error_message = model.errors[attribute].first
|
38
|
+
return unless error_message
|
61
39
|
|
62
|
-
|
63
|
-
end
|
40
|
+
Components::GovUK::ErrorMessage.new(context: self, message: error_message, attribute: attribute, **options).render
|
64
41
|
end
|
65
42
|
end
|
66
43
|
end
|