ccs-frontend_helpers 0.1.0.rc.1 → 0.1.0.rc.3
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 +57 -0
- data/lib/ccs/components/ccs/dashboard_section.rb +73 -0
- data/lib/ccs/components/ccs/footer/link.rb +55 -0
- data/lib/ccs/components/ccs/footer/meta.rb +59 -0
- data/lib/ccs/components/ccs/footer/navigation.rb +60 -0
- data/lib/ccs/components/ccs/footer.rb +95 -0
- data/lib/ccs/components/ccs/header/link.rb +60 -0
- data/lib/ccs/components/ccs/header/navigation.rb +98 -0
- data/lib/ccs/components/ccs/header/service_authentication.rb +53 -0
- data/lib/ccs/components/ccs/header.rb +110 -0
- data/lib/ccs/{frontend_helpers/ccs_frontend → components/ccs}/logo.rb +10 -12
- 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 +61 -0
- data/lib/ccs/components/govuk/accordion.rb +58 -0
- data/lib/ccs/components/govuk/back_link.rb +51 -0
- data/lib/ccs/components/govuk/breadcrumbs/link.rb +57 -0
- data/lib/ccs/components/govuk/breadcrumbs.rb +55 -0
- data/lib/ccs/components/govuk/button.rb +107 -0
- data/lib/ccs/components/govuk/cookie_banner/action.rb +60 -0
- data/lib/ccs/components/govuk/cookie_banner/message.rb +80 -0
- data/lib/ccs/components/govuk/cookie_banner.rb +55 -0
- data/lib/ccs/components/govuk/details.rb +53 -0
- data/lib/ccs/components/govuk/error_message.rb +60 -0
- data/lib/ccs/components/govuk/error_summary/item.rb +54 -0
- data/lib/ccs/components/govuk/error_summary.rb +70 -0
- data/lib/ccs/components/govuk/field/input/character_count.rb +129 -0
- data/lib/ccs/components/govuk/field/input/file_upload.rb +44 -0
- data/lib/ccs/components/govuk/field/input/select.rb +82 -0
- data/lib/ccs/components/govuk/field/input/text_input/fix.rb +55 -0
- data/lib/ccs/components/govuk/field/input/text_input.rb +97 -0
- data/lib/ccs/components/govuk/field/input/textarea.rb +59 -0
- data/lib/ccs/components/govuk/field/input.rb +62 -0
- data/lib/ccs/components/govuk/field/inputs/checkboxes.rb +69 -0
- data/lib/ccs/components/govuk/field/inputs/date_input/item.rb +65 -0
- data/lib/ccs/components/govuk/field/inputs/date_input.rb +89 -0
- data/lib/ccs/components/govuk/field/inputs/item/checkbox/form.rb +47 -0
- data/lib/ccs/components/govuk/field/inputs/item/checkbox/tag.rb +43 -0
- data/lib/ccs/components/govuk/field/inputs/item/checkbox.rb +50 -0
- data/lib/ccs/components/govuk/field/inputs/item/divider.rb +50 -0
- data/lib/ccs/components/govuk/field/inputs/item/radio/form.rb +44 -0
- data/lib/ccs/components/govuk/field/inputs/item/radio/tag.rb +43 -0
- data/lib/ccs/components/govuk/field/inputs/item/radio.rb +50 -0
- data/lib/ccs/components/govuk/field/inputs/item.rb +111 -0
- data/lib/ccs/components/govuk/field/inputs/radios.rb +69 -0
- data/lib/ccs/components/govuk/field/inputs.rb +57 -0
- data/lib/ccs/components/govuk/field.rb +108 -0
- data/lib/ccs/components/govuk/fieldset/legend.rb +65 -0
- data/lib/ccs/components/govuk/fieldset.rb +54 -0
- data/lib/ccs/components/govuk/footer/link.rb +55 -0
- data/lib/ccs/components/govuk/footer/meta.rb +59 -0
- data/lib/ccs/components/govuk/footer/navigation.rb +60 -0
- data/lib/ccs/components/govuk/footer.rb +131 -0
- data/lib/ccs/components/govuk/form_group.rb +60 -0
- data/lib/ccs/components/govuk/header/link.rb +56 -0
- data/lib/ccs/components/govuk/header/navigation.rb +71 -0
- data/lib/ccs/components/govuk/header.rb +107 -0
- data/lib/ccs/components/govuk/hint.rb +49 -0
- data/lib/ccs/components/govuk/inset_text.rb +52 -0
- data/lib/ccs/components/govuk/label.rb +85 -0
- data/lib/ccs/components/govuk/notification_banner.rb +107 -0
- data/lib/ccs/components/govuk/pagination/increment/next.rb +44 -0
- data/lib/ccs/components/govuk/pagination/increment/previous.rb +43 -0
- data/lib/ccs/components/govuk/pagination/increment.rb +98 -0
- data/lib/ccs/components/govuk/pagination/item/ellipsis.rb +28 -0
- data/lib/ccs/components/govuk/pagination/item/form.rb +49 -0
- data/lib/ccs/components/govuk/pagination/item/tag.rb +47 -0
- data/lib/ccs/components/govuk/pagination/item.rb +64 -0
- data/lib/ccs/components/govuk/pagination.rb +96 -0
- data/lib/ccs/components/govuk/panel.rb +62 -0
- data/lib/ccs/components/govuk/phase_banner.rb +69 -0
- data/lib/ccs/components/govuk/skip_link.rb +51 -0
- data/lib/ccs/components/govuk/step_by_step_navigation/section/content/list/item.rb +53 -0
- data/lib/ccs/components/govuk/step_by_step_navigation/section/content/list.rb +50 -0
- data/lib/ccs/components/govuk/step_by_step_navigation/section/content/paragraph.rb +45 -0
- data/lib/ccs/components/govuk/step_by_step_navigation/section/content.rb +63 -0
- data/lib/ccs/components/govuk/step_by_step_navigation/section/heading.rb +69 -0
- data/lib/ccs/components/govuk/step_by_step_navigation/section.rb +56 -0
- data/lib/ccs/components/govuk/step_by_step_navigation.rb +59 -0
- data/lib/ccs/components/govuk/summary_list/action/link.rb +59 -0
- data/lib/ccs/components/govuk/summary_list/card/actions.rb +59 -0
- data/lib/ccs/components/govuk/summary_list/card/title.rb +51 -0
- data/lib/ccs/components/govuk/summary_list/card.rb +63 -0
- data/lib/ccs/components/govuk/summary_list/row/actions.rb +59 -0
- data/lib/ccs/components/govuk/summary_list/row/key.rb +47 -0
- data/lib/ccs/components/govuk/summary_list/row/value.rb +47 -0
- data/lib/ccs/components/govuk/summary_list/row.rb +65 -0
- data/lib/ccs/components/govuk/summary_list.rb +74 -0
- data/lib/ccs/components/govuk/table/body/data_cell.rb +53 -0
- data/lib/ccs/components/govuk/table/body/head_cell.rb +52 -0
- data/lib/ccs/components/govuk/table/header/head_cell.rb +54 -0
- data/lib/ccs/components/govuk/table.rb +111 -0
- data/lib/ccs/components/govuk/tabs/panel.rb +58 -0
- data/lib/ccs/components/govuk/tabs/tab.rb +56 -0
- data/lib/ccs/components/govuk/tabs.rb +66 -0
- data/lib/ccs/components/govuk/tag.rb +51 -0
- data/lib/ccs/components/govuk/warning_text.rb +61 -0
- data/lib/ccs/frontend_helpers/ccs_frontend/dashboard_section.rb +27 -0
- data/lib/ccs/frontend_helpers/ccs_frontend/footer.rb +6 -119
- data/lib/ccs/frontend_helpers/ccs_frontend/header.rb +6 -183
- data/lib/ccs/frontend_helpers/ccs_frontend.rb +2 -4
- data/lib/ccs/frontend_helpers/govuk_frontend/accordion.rb +8 -95
- data/lib/ccs/frontend_helpers/govuk_frontend/back_link.rb +6 -17
- data/lib/ccs/frontend_helpers/govuk_frontend/breadcrumbs.rb +6 -54
- data/lib/ccs/frontend_helpers/govuk_frontend/button.rb +6 -105
- data/lib/ccs/frontend_helpers/govuk_frontend/character_count.rb +28 -0
- data/lib/ccs/frontend_helpers/govuk_frontend/checkboxes.rb +28 -0
- data/lib/ccs/frontend_helpers/govuk_frontend/cookie_banner.rb +6 -114
- data/lib/ccs/frontend_helpers/govuk_frontend/date_input.rb +28 -0
- data/lib/ccs/frontend_helpers/govuk_frontend/details.rb +7 -23
- data/lib/ccs/frontend_helpers/govuk_frontend/error_message.rb +11 -32
- data/lib/ccs/frontend_helpers/govuk_frontend/error_summary.rb +13 -65
- data/lib/ccs/frontend_helpers/govuk_frontend/fieldset.rb +7 -48
- data/lib/ccs/frontend_helpers/govuk_frontend/file_upload.rb +28 -0
- data/lib/ccs/frontend_helpers/govuk_frontend/footer.rb +6 -161
- data/lib/ccs/frontend_helpers/govuk_frontend/form_group.rb +13 -24
- data/lib/ccs/frontend_helpers/govuk_frontend/header.rb +6 -139
- data/lib/ccs/frontend_helpers/govuk_frontend/hint.rb +8 -17
- data/lib/ccs/frontend_helpers/govuk_frontend/input.rb +28 -0
- data/lib/ccs/frontend_helpers/govuk_frontend/inset_text.rb +7 -21
- data/lib/ccs/frontend_helpers/govuk_frontend/label.rb +7 -70
- data/lib/ccs/frontend_helpers/govuk_frontend/notification_banner.rb +7 -113
- data/lib/ccs/frontend_helpers/govuk_frontend/pagination.rb +6 -314
- data/lib/ccs/frontend_helpers/govuk_frontend/panel.rb +7 -28
- data/lib/ccs/frontend_helpers/govuk_frontend/phase_banner.rb +8 -27
- data/lib/ccs/frontend_helpers/govuk_frontend/radios.rb +28 -0
- data/lib/ccs/frontend_helpers/govuk_frontend/select.rb +28 -0
- data/lib/ccs/frontend_helpers/govuk_frontend/skip_link.rb +6 -18
- data/lib/ccs/frontend_helpers/govuk_frontend/step_by_step_navigation.rb +7 -186
- data/lib/ccs/frontend_helpers/govuk_frontend/summary_list.rb +6 -204
- data/lib/ccs/frontend_helpers/govuk_frontend/table.rb +6 -102
- data/lib/ccs/frontend_helpers/govuk_frontend/tabs.rb +6 -73
- data/lib/ccs/frontend_helpers/govuk_frontend/tag.rb +7 -21
- data/lib/ccs/frontend_helpers/govuk_frontend/textarea.rb +28 -0
- data/lib/ccs/frontend_helpers/govuk_frontend/warning_text.rb +7 -30
- 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/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,8 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
require_relative '../shared_methods'
|
3
|
+
require_relative '../../components/govuk/tag'
|
6
4
|
|
7
5
|
module CCS
|
8
6
|
module FrontendHelpers
|
@@ -13,28 +11,16 @@ module CCS
|
|
13
11
|
# {https://design-system.service.gov.uk/components/tag GDS - Components - Tag}
|
14
12
|
|
15
13
|
module Tag
|
16
|
-
|
17
|
-
include ActionView::Context
|
18
|
-
include ActionView::Helpers::TagHelper
|
19
|
-
|
20
|
-
# Generates the HTML for the GOV.UK Tag component
|
14
|
+
# Generates the HTML for the GOV.UK Back link component
|
21
15
|
#
|
22
|
-
# @param
|
23
|
-
# @param colour [String] optional colour for the tag,
|
24
|
-
# see {https://design-system.service.gov.uk/components/tag/#additional-colours Tag - Additional colours}
|
25
|
-
# for available colours in GOV.UK Frontend
|
26
|
-
# @param govuk_tag_options [Hash] options that will be used in customising the HTML
|
16
|
+
# @param (see CCS::Components::GovUK::Tag#initialize)
|
27
17
|
#
|
28
|
-
# @option
|
29
|
-
# @option govuk_tag_options [Hash] :attributes ({}) any additional attributes that will added as part of the HTML
|
18
|
+
# @option (see CCS::Components::GovUK::Tag#initialize)
|
30
19
|
#
|
31
|
-
# @return
|
32
|
-
# which can then be rendered on the page
|
33
|
-
|
34
|
-
def govuk_tag(text, colour = nil, **govuk_tag_options)
|
35
|
-
initialise_attributes_and_set_classes(govuk_tag_options, "govuk-tag #{"govuk-tag--#{colour}" if colour}".rstrip)
|
20
|
+
# @return (see CCS::Components::GovUK::Tag#render)
|
36
21
|
|
37
|
-
|
22
|
+
def govuk_tag(text, colour = nil, **options)
|
23
|
+
Components::GovUK::Tag.new(context: self, text: text, colour: colour, **options).render
|
38
24
|
end
|
39
25
|
end
|
40
26
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../components/govuk/field/input/textarea'
|
4
|
+
|
5
|
+
module CCS
|
6
|
+
module FrontendHelpers
|
7
|
+
module GovUKFrontend
|
8
|
+
# = GOV.UK Textarea
|
9
|
+
#
|
10
|
+
# This helper is used for generating the textarea component from the
|
11
|
+
# {https://design-system.service.gov.uk/components/textarea GDS - Components - Textarea}
|
12
|
+
|
13
|
+
module Textarea
|
14
|
+
# Generates the HTML for the GOV.UK Textarea component
|
15
|
+
#
|
16
|
+
# @param (see CCS::Components::GovUK::Input::Textarea#initialize)
|
17
|
+
#
|
18
|
+
# @option (see CCS::Components::GovUK::Input::Textarea#initialize)
|
19
|
+
#
|
20
|
+
# @return (see CCS::Components::GovUK::Input::Textarea#render)
|
21
|
+
|
22
|
+
def govuk_textarea(attribute, **options)
|
23
|
+
Components::GovUK::Field::Input::Textarea.new(context: self, attribute: attribute, **options).render
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -1,8 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
require_relative '../shared_methods'
|
3
|
+
require_relative '../../components/govuk/warning_text'
|
6
4
|
|
7
5
|
module CCS
|
8
6
|
module FrontendHelpers
|
@@ -13,39 +11,18 @@ module CCS
|
|
13
11
|
# {https://design-system.service.gov.uk/components/warning-text GDS - Components - Warning text}
|
14
12
|
|
15
13
|
module WarningText
|
16
|
-
include SharedMethods
|
17
|
-
include ActionView::Context
|
18
|
-
include ActionView::Helpers::TagHelper
|
19
|
-
include ActionView::Helpers::TextHelper
|
20
|
-
|
21
14
|
# Generates the HTML for the GOV.UK Warning text component
|
22
15
|
#
|
23
|
-
# @param
|
24
|
-
# @param govuk_warning_text_options [Hash] options that will be used in customising the HTML
|
16
|
+
# @param (see CCS::Components::GovUK::WarningText#initialize)
|
25
17
|
#
|
26
|
-
# @option
|
27
|
-
# @option govuk_warning_text_options [String] :icon_fallback_text the fallback text for the icon (default: +'Warning'+)
|
28
|
-
# @option govuk_warning_text_options [Hash] :attributes ({}) any additional attributes that will added as part of the HTML
|
18
|
+
# @option (see CCS::Components::GovUK::WarningText#initialize)
|
29
19
|
#
|
30
|
-
# @yield
|
20
|
+
# @yield (see CCS::Components::GovUK::WarningText#render)
|
31
21
|
#
|
32
|
-
# @return
|
33
|
-
# which can then be rendered on the page
|
34
|
-
|
35
|
-
def govuk_warning_text(text = nil, **govuk_warning_text_options)
|
36
|
-
initialise_attributes_and_set_classes(govuk_warning_text_options, 'govuk-warning-text')
|
22
|
+
# @return (see CCS::Components::GovUK::WarningText#render)
|
37
23
|
|
38
|
-
|
39
|
-
|
40
|
-
concat(tag.strong(class: 'govuk-warning-text__text') do
|
41
|
-
concat(tag.span(govuk_warning_text_options[:icon_fallback_text] || 'Warning', class: 'govuk-warning-text__assistive'))
|
42
|
-
if text
|
43
|
-
concat(text)
|
44
|
-
else
|
45
|
-
yield
|
46
|
-
end
|
47
|
-
end)
|
48
|
-
end
|
24
|
+
def govuk_warning_text(text = nil, **options, &block)
|
25
|
+
Components::GovUK::WarningText.new(context: self, text: text, **options).render(&block)
|
49
26
|
end
|
50
27
|
end
|
51
28
|
end
|
@@ -4,78 +4,76 @@ require_relative 'govuk_frontend/accordion'
|
|
4
4
|
require_relative 'govuk_frontend/back_link'
|
5
5
|
require_relative 'govuk_frontend/breadcrumbs'
|
6
6
|
require_relative 'govuk_frontend/button'
|
7
|
+
require_relative 'govuk_frontend/character_count'
|
8
|
+
require_relative 'govuk_frontend/checkboxes'
|
7
9
|
require_relative 'govuk_frontend/cookie_banner'
|
10
|
+
require_relative 'govuk_frontend/date_input'
|
8
11
|
require_relative 'govuk_frontend/details'
|
9
12
|
require_relative 'govuk_frontend/error_message'
|
10
13
|
require_relative 'govuk_frontend/error_summary'
|
11
|
-
require_relative 'govuk_frontend/field'
|
12
|
-
require_relative 'govuk_frontend/field/character_count'
|
13
|
-
require_relative 'govuk_frontend/field/checkboxes'
|
14
|
-
require_relative 'govuk_frontend/field/date_input'
|
15
|
-
require_relative 'govuk_frontend/field/file_upload'
|
16
|
-
require_relative 'govuk_frontend/field/input'
|
17
|
-
require_relative 'govuk_frontend/field/select'
|
18
|
-
require_relative 'govuk_frontend/field/textarea'
|
19
|
-
require_relative 'govuk_frontend/field/radios'
|
20
14
|
require_relative 'govuk_frontend/fieldset'
|
15
|
+
require_relative 'govuk_frontend/file_upload'
|
21
16
|
require_relative 'govuk_frontend/footer'
|
22
17
|
require_relative 'govuk_frontend/form_group'
|
23
18
|
require_relative 'govuk_frontend/header'
|
24
19
|
require_relative 'govuk_frontend/hint'
|
20
|
+
require_relative 'govuk_frontend/input'
|
25
21
|
require_relative 'govuk_frontend/inset_text'
|
26
22
|
require_relative 'govuk_frontend/label'
|
27
23
|
require_relative 'govuk_frontend/notification_banner'
|
28
24
|
require_relative 'govuk_frontend/pagination'
|
29
25
|
require_relative 'govuk_frontend/panel'
|
30
26
|
require_relative 'govuk_frontend/phase_banner'
|
27
|
+
require_relative 'govuk_frontend/radios'
|
28
|
+
require_relative 'govuk_frontend/select'
|
31
29
|
require_relative 'govuk_frontend/skip_link'
|
32
30
|
require_relative 'govuk_frontend/step_by_step_navigation'
|
33
31
|
require_relative 'govuk_frontend/summary_list'
|
34
32
|
require_relative 'govuk_frontend/table'
|
35
33
|
require_relative 'govuk_frontend/tabs'
|
36
34
|
require_relative 'govuk_frontend/tag'
|
35
|
+
require_relative 'govuk_frontend/textarea'
|
37
36
|
require_relative 'govuk_frontend/warning_text'
|
38
37
|
|
39
38
|
module CCS
|
40
39
|
module FrontendHelpers
|
41
40
|
# This module loads in all the GOV.UK Frontend Helper methods.
|
42
|
-
# These are a collection of view
|
41
|
+
# These are a collection of view to help render GOV.UK components
|
43
42
|
|
44
43
|
module GovUKFrontend
|
45
44
|
include Accordion
|
46
45
|
include BackLink
|
47
46
|
include Breadcrumbs
|
48
47
|
include Button
|
48
|
+
include CharacterCount
|
49
|
+
include Checkboxes
|
49
50
|
include CookieBanner
|
51
|
+
include DateInput
|
50
52
|
include Details
|
51
53
|
include ErrorMessage
|
52
54
|
include ErrorSummary
|
53
|
-
include
|
54
|
-
include Field::CharacterCount
|
55
|
-
include Field::Checkboxes
|
56
|
-
include Field::DateInput
|
57
|
-
include Field::FileUpload
|
58
|
-
include Field::Input
|
59
|
-
include Field::Radios
|
60
|
-
include Field::Select
|
61
|
-
include Field::Textarea
|
55
|
+
include FileUpload
|
62
56
|
include Fieldset
|
63
57
|
include Footer
|
64
58
|
include FormGroup
|
65
59
|
include Header
|
66
60
|
include Hint
|
61
|
+
include Input
|
67
62
|
include InsetText
|
68
63
|
include Label
|
69
64
|
include NotificationBanner
|
70
65
|
include Pagination
|
71
66
|
include Panel
|
72
67
|
include PhaseBanner
|
68
|
+
include Radios
|
69
|
+
include Select
|
73
70
|
include SkipLink
|
74
71
|
include StepByStepNavigation
|
75
72
|
include SummaryList
|
76
73
|
include Table
|
77
74
|
include Tabs
|
78
75
|
include Tag
|
76
|
+
include Textarea
|
79
77
|
include WarningText
|
80
78
|
end
|
81
79
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ccs-frontend_helpers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.0.rc.
|
4
|
+
version: 0.1.0.rc.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- tim-s-ccs
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-04-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -159,6 +159,7 @@ extra_rdoc_files: []
|
|
159
159
|
files:
|
160
160
|
- ".rspec"
|
161
161
|
- ".rubocop.yml"
|
162
|
+
- ".ruby-version"
|
162
163
|
- CHANGELOG.md
|
163
164
|
- Gemfile
|
164
165
|
- Gemfile.lock
|
@@ -166,49 +167,144 @@ files:
|
|
166
167
|
- README.md
|
167
168
|
- Rakefile
|
168
169
|
- ccs-frontend_helpers.gemspec
|
170
|
+
- lib/ccs/components/base.rb
|
171
|
+
- lib/ccs/components/ccs/dashboard_section.rb
|
172
|
+
- lib/ccs/components/ccs/dashboard_section/panel.rb
|
173
|
+
- lib/ccs/components/ccs/footer.rb
|
174
|
+
- lib/ccs/components/ccs/footer/link.rb
|
175
|
+
- lib/ccs/components/ccs/footer/meta.rb
|
176
|
+
- lib/ccs/components/ccs/footer/navigation.rb
|
177
|
+
- lib/ccs/components/ccs/header.rb
|
178
|
+
- lib/ccs/components/ccs/header/link.rb
|
179
|
+
- lib/ccs/components/ccs/header/navigation.rb
|
180
|
+
- lib/ccs/components/ccs/header/service_authentication.rb
|
181
|
+
- lib/ccs/components/ccs/logo.rb
|
182
|
+
- lib/ccs/components/govuk/accordion.rb
|
183
|
+
- lib/ccs/components/govuk/accordion/section.rb
|
184
|
+
- lib/ccs/components/govuk/accordion/section/content.rb
|
185
|
+
- lib/ccs/components/govuk/accordion/section/header.rb
|
186
|
+
- lib/ccs/components/govuk/back_link.rb
|
187
|
+
- lib/ccs/components/govuk/breadcrumbs.rb
|
188
|
+
- lib/ccs/components/govuk/breadcrumbs/link.rb
|
189
|
+
- lib/ccs/components/govuk/button.rb
|
190
|
+
- lib/ccs/components/govuk/cookie_banner.rb
|
191
|
+
- lib/ccs/components/govuk/cookie_banner/action.rb
|
192
|
+
- lib/ccs/components/govuk/cookie_banner/message.rb
|
193
|
+
- lib/ccs/components/govuk/details.rb
|
194
|
+
- lib/ccs/components/govuk/error_message.rb
|
195
|
+
- lib/ccs/components/govuk/error_summary.rb
|
196
|
+
- lib/ccs/components/govuk/error_summary/item.rb
|
197
|
+
- lib/ccs/components/govuk/field.rb
|
198
|
+
- lib/ccs/components/govuk/field/input.rb
|
199
|
+
- lib/ccs/components/govuk/field/input/character_count.rb
|
200
|
+
- lib/ccs/components/govuk/field/input/file_upload.rb
|
201
|
+
- lib/ccs/components/govuk/field/input/select.rb
|
202
|
+
- lib/ccs/components/govuk/field/input/text_input.rb
|
203
|
+
- lib/ccs/components/govuk/field/input/text_input/fix.rb
|
204
|
+
- lib/ccs/components/govuk/field/input/textarea.rb
|
205
|
+
- lib/ccs/components/govuk/field/inputs.rb
|
206
|
+
- lib/ccs/components/govuk/field/inputs/checkboxes.rb
|
207
|
+
- lib/ccs/components/govuk/field/inputs/date_input.rb
|
208
|
+
- lib/ccs/components/govuk/field/inputs/date_input/item.rb
|
209
|
+
- lib/ccs/components/govuk/field/inputs/item.rb
|
210
|
+
- lib/ccs/components/govuk/field/inputs/item/checkbox.rb
|
211
|
+
- lib/ccs/components/govuk/field/inputs/item/checkbox/form.rb
|
212
|
+
- lib/ccs/components/govuk/field/inputs/item/checkbox/tag.rb
|
213
|
+
- lib/ccs/components/govuk/field/inputs/item/divider.rb
|
214
|
+
- lib/ccs/components/govuk/field/inputs/item/radio.rb
|
215
|
+
- lib/ccs/components/govuk/field/inputs/item/radio/form.rb
|
216
|
+
- lib/ccs/components/govuk/field/inputs/item/radio/tag.rb
|
217
|
+
- lib/ccs/components/govuk/field/inputs/radios.rb
|
218
|
+
- lib/ccs/components/govuk/fieldset.rb
|
219
|
+
- lib/ccs/components/govuk/fieldset/legend.rb
|
220
|
+
- lib/ccs/components/govuk/footer.rb
|
221
|
+
- lib/ccs/components/govuk/footer/link.rb
|
222
|
+
- lib/ccs/components/govuk/footer/meta.rb
|
223
|
+
- lib/ccs/components/govuk/footer/navigation.rb
|
224
|
+
- lib/ccs/components/govuk/form_group.rb
|
225
|
+
- lib/ccs/components/govuk/header.rb
|
226
|
+
- lib/ccs/components/govuk/header/link.rb
|
227
|
+
- lib/ccs/components/govuk/header/navigation.rb
|
228
|
+
- lib/ccs/components/govuk/hint.rb
|
229
|
+
- lib/ccs/components/govuk/inset_text.rb
|
230
|
+
- lib/ccs/components/govuk/label.rb
|
231
|
+
- lib/ccs/components/govuk/notification_banner.rb
|
232
|
+
- lib/ccs/components/govuk/pagination.rb
|
233
|
+
- lib/ccs/components/govuk/pagination/increment.rb
|
234
|
+
- lib/ccs/components/govuk/pagination/increment/next.rb
|
235
|
+
- lib/ccs/components/govuk/pagination/increment/previous.rb
|
236
|
+
- lib/ccs/components/govuk/pagination/item.rb
|
237
|
+
- lib/ccs/components/govuk/pagination/item/ellipsis.rb
|
238
|
+
- lib/ccs/components/govuk/pagination/item/form.rb
|
239
|
+
- lib/ccs/components/govuk/pagination/item/tag.rb
|
240
|
+
- lib/ccs/components/govuk/panel.rb
|
241
|
+
- lib/ccs/components/govuk/phase_banner.rb
|
242
|
+
- lib/ccs/components/govuk/skip_link.rb
|
243
|
+
- lib/ccs/components/govuk/step_by_step_navigation.rb
|
244
|
+
- lib/ccs/components/govuk/step_by_step_navigation/section.rb
|
245
|
+
- lib/ccs/components/govuk/step_by_step_navigation/section/content.rb
|
246
|
+
- lib/ccs/components/govuk/step_by_step_navigation/section/content/list.rb
|
247
|
+
- lib/ccs/components/govuk/step_by_step_navigation/section/content/list/item.rb
|
248
|
+
- lib/ccs/components/govuk/step_by_step_navigation/section/content/paragraph.rb
|
249
|
+
- lib/ccs/components/govuk/step_by_step_navigation/section/heading.rb
|
250
|
+
- lib/ccs/components/govuk/summary_list.rb
|
251
|
+
- lib/ccs/components/govuk/summary_list/action/link.rb
|
252
|
+
- lib/ccs/components/govuk/summary_list/card.rb
|
253
|
+
- lib/ccs/components/govuk/summary_list/card/actions.rb
|
254
|
+
- lib/ccs/components/govuk/summary_list/card/title.rb
|
255
|
+
- lib/ccs/components/govuk/summary_list/row.rb
|
256
|
+
- lib/ccs/components/govuk/summary_list/row/actions.rb
|
257
|
+
- lib/ccs/components/govuk/summary_list/row/key.rb
|
258
|
+
- lib/ccs/components/govuk/summary_list/row/value.rb
|
259
|
+
- lib/ccs/components/govuk/table.rb
|
260
|
+
- lib/ccs/components/govuk/table/body/data_cell.rb
|
261
|
+
- lib/ccs/components/govuk/table/body/head_cell.rb
|
262
|
+
- lib/ccs/components/govuk/table/header/head_cell.rb
|
263
|
+
- lib/ccs/components/govuk/tabs.rb
|
264
|
+
- lib/ccs/components/govuk/tabs/panel.rb
|
265
|
+
- lib/ccs/components/govuk/tabs/tab.rb
|
266
|
+
- lib/ccs/components/govuk/tag.rb
|
267
|
+
- lib/ccs/components/govuk/warning_text.rb
|
169
268
|
- lib/ccs/frontend_helpers.rb
|
170
269
|
- lib/ccs/frontend_helpers/ccs_frontend.rb
|
171
|
-
- lib/ccs/frontend_helpers/ccs_frontend/
|
270
|
+
- lib/ccs/frontend_helpers/ccs_frontend/dashboard_section.rb
|
172
271
|
- lib/ccs/frontend_helpers/ccs_frontend/footer.rb
|
173
272
|
- lib/ccs/frontend_helpers/ccs_frontend/header.rb
|
174
|
-
- lib/ccs/frontend_helpers/ccs_frontend/logo.rb
|
175
273
|
- lib/ccs/frontend_helpers/govuk_frontend.rb
|
176
274
|
- lib/ccs/frontend_helpers/govuk_frontend/accordion.rb
|
177
275
|
- lib/ccs/frontend_helpers/govuk_frontend/back_link.rb
|
178
276
|
- lib/ccs/frontend_helpers/govuk_frontend/breadcrumbs.rb
|
179
277
|
- lib/ccs/frontend_helpers/govuk_frontend/button.rb
|
278
|
+
- lib/ccs/frontend_helpers/govuk_frontend/character_count.rb
|
279
|
+
- lib/ccs/frontend_helpers/govuk_frontend/checkboxes.rb
|
180
280
|
- lib/ccs/frontend_helpers/govuk_frontend/cookie_banner.rb
|
281
|
+
- lib/ccs/frontend_helpers/govuk_frontend/date_input.rb
|
181
282
|
- lib/ccs/frontend_helpers/govuk_frontend/details.rb
|
182
283
|
- lib/ccs/frontend_helpers/govuk_frontend/error_message.rb
|
183
284
|
- lib/ccs/frontend_helpers/govuk_frontend/error_summary.rb
|
184
|
-
- lib/ccs/frontend_helpers/govuk_frontend/field.rb
|
185
|
-
- lib/ccs/frontend_helpers/govuk_frontend/field/character_count.rb
|
186
|
-
- lib/ccs/frontend_helpers/govuk_frontend/field/checkboxes.rb
|
187
|
-
- lib/ccs/frontend_helpers/govuk_frontend/field/date_input.rb
|
188
|
-
- lib/ccs/frontend_helpers/govuk_frontend/field/file_upload.rb
|
189
|
-
- lib/ccs/frontend_helpers/govuk_frontend/field/input.rb
|
190
|
-
- lib/ccs/frontend_helpers/govuk_frontend/field/radios.rb
|
191
|
-
- lib/ccs/frontend_helpers/govuk_frontend/field/select.rb
|
192
|
-
- lib/ccs/frontend_helpers/govuk_frontend/field/textarea.rb
|
193
285
|
- lib/ccs/frontend_helpers/govuk_frontend/fieldset.rb
|
286
|
+
- lib/ccs/frontend_helpers/govuk_frontend/file_upload.rb
|
194
287
|
- lib/ccs/frontend_helpers/govuk_frontend/footer.rb
|
195
288
|
- lib/ccs/frontend_helpers/govuk_frontend/form_group.rb
|
196
289
|
- lib/ccs/frontend_helpers/govuk_frontend/header.rb
|
197
290
|
- lib/ccs/frontend_helpers/govuk_frontend/hint.rb
|
291
|
+
- lib/ccs/frontend_helpers/govuk_frontend/input.rb
|
198
292
|
- lib/ccs/frontend_helpers/govuk_frontend/inset_text.rb
|
199
293
|
- lib/ccs/frontend_helpers/govuk_frontend/label.rb
|
200
294
|
- lib/ccs/frontend_helpers/govuk_frontend/notification_banner.rb
|
201
295
|
- lib/ccs/frontend_helpers/govuk_frontend/pagination.rb
|
202
296
|
- lib/ccs/frontend_helpers/govuk_frontend/panel.rb
|
203
297
|
- lib/ccs/frontend_helpers/govuk_frontend/phase_banner.rb
|
298
|
+
- lib/ccs/frontend_helpers/govuk_frontend/radios.rb
|
299
|
+
- lib/ccs/frontend_helpers/govuk_frontend/select.rb
|
204
300
|
- lib/ccs/frontend_helpers/govuk_frontend/skip_link.rb
|
205
301
|
- lib/ccs/frontend_helpers/govuk_frontend/step_by_step_navigation.rb
|
206
302
|
- lib/ccs/frontend_helpers/govuk_frontend/summary_list.rb
|
207
303
|
- lib/ccs/frontend_helpers/govuk_frontend/table.rb
|
208
304
|
- lib/ccs/frontend_helpers/govuk_frontend/tabs.rb
|
209
305
|
- lib/ccs/frontend_helpers/govuk_frontend/tag.rb
|
306
|
+
- lib/ccs/frontend_helpers/govuk_frontend/textarea.rb
|
210
307
|
- lib/ccs/frontend_helpers/govuk_frontend/warning_text.rb
|
211
|
-
- lib/ccs/frontend_helpers/shared_methods.rb
|
212
308
|
- lib/ccs/frontend_helpers/version.rb
|
213
309
|
- sig/ccs/frontend_helpers.rbs
|
214
310
|
homepage: https://github.com/tim-s-ccs/ccs-frontend_helpers
|
@@ -1,79 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'action_view'
|
4
|
-
|
5
|
-
require_relative '../shared_methods'
|
6
|
-
|
7
|
-
module CCS
|
8
|
-
module FrontendHelpers
|
9
|
-
module CCSFrontend
|
10
|
-
# = CCS Dashboard Panels
|
11
|
-
#
|
12
|
-
# This helper is used for generating the dashboard panels component
|
13
|
-
|
14
|
-
module DashboardPanels
|
15
|
-
include SharedMethods
|
16
|
-
include ActionView::Context
|
17
|
-
include ActionView::Helpers::TagHelper
|
18
|
-
include ActionView::Helpers::TextHelper
|
19
|
-
include ActionView::Helpers::UrlHelper
|
20
|
-
|
21
|
-
# Generates the HTML for the CCS Dashboard Panels component
|
22
|
-
#
|
23
|
-
# @param panel_items [Array] the panel items, see {ccs_dashboard_panels_item}
|
24
|
-
# @param title_text [String] text for the title of a dashboard panels section
|
25
|
-
# @param ccs_dashboard_panels_options [Hash] options that will be used in customising the HTML
|
26
|
-
#
|
27
|
-
# @option ccs_dashboard_panels_options [String] :classes additional CSS classes for the dashboard panels HTML
|
28
|
-
# @option ccs_dashboard_panels_options [String] :width (default: 'full') the width of the dashbaord panel section
|
29
|
-
# @option ccs_dashboard_panels_options [Hash] :attributes additional attributes that will added as part of the HTML
|
30
|
-
#
|
31
|
-
# @return [ActiveSupport::SafeBuffer] the HTML for the CCS Dashboard Panels
|
32
|
-
# which can then be rendered on the page
|
33
|
-
|
34
|
-
def ccs_dashboard_panels(panel_items, title_text = nil, **ccs_dashboard_panels_options)
|
35
|
-
initialise_attributes_and_set_classes(ccs_dashboard_panels_options, 'ccs-dashboard-panels')
|
36
|
-
|
37
|
-
tag.div(**ccs_dashboard_panels_options[:attributes]) do
|
38
|
-
tag.div(class: 'govuk-grid-row') do
|
39
|
-
tag.div(class: "govuk-grid-column-#{ccs_dashboard_panels_options[:width] || 'full'}") do
|
40
|
-
if title_text
|
41
|
-
concat(tag.h2(title_text, class: 'ccs-dashboard-panels__heading govuk-heading-m'))
|
42
|
-
concat(tag.hr(class: 'ccs-dashboard-panels__heading-section-break govuk-section-break govuk-section-break--visible'))
|
43
|
-
end
|
44
|
-
concat(tag.div(class: 'ccs-dashboard-panels__container') do
|
45
|
-
tag.div(class: 'govuk-grid-row') do
|
46
|
-
panel_items.each { |panel_item| concat(ccs_dashboard_panels_item(panel_item)) }
|
47
|
-
end
|
48
|
-
end)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
private
|
55
|
-
|
56
|
-
# Generates the HTML for the a dashboard panel item in {ccs_dashboard_panels}
|
57
|
-
#
|
58
|
-
# @param panel_item [Hash] options for the dashboard panel item
|
59
|
-
#
|
60
|
-
# @option panel_item [String] :title the title for the dashboard panel
|
61
|
-
# @option panel_item [String] :href the href for the dashboard panel
|
62
|
-
# @option panel_item [String] :description the description text for the dashboard panel
|
63
|
-
# @option panel_item [String] :width (default: 'one-third') the width of the dashboard panel item
|
64
|
-
# @option panel_item [Hash] :attributes additional attributes that will added as part of the HTML
|
65
|
-
#
|
66
|
-
# @return [ActiveSupport::SafeBuffer] the HTML for a panel item in {ccs_dashboard_panels}
|
67
|
-
|
68
|
-
def ccs_dashboard_panels_item(panel_item)
|
69
|
-
(panel_item[:attributes] ||= {})[:class] = "ccs-dashboard-panels__item govuk-grid-column-#{panel_item[:width] || 'one-third'}"
|
70
|
-
|
71
|
-
tag.div(**panel_item[:attributes]) do
|
72
|
-
concat(link_to(panel_item[:title], panel_item[:href], class: 'ccs-dashboard-panels__item-title'))
|
73
|
-
concat(tag.p(panel_item[:description], class: 'ccs-dashboard-panels__item-description'))
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
@@ -1,165 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'textarea'
|
4
|
-
|
5
|
-
module CCS
|
6
|
-
module FrontendHelpers
|
7
|
-
module GovUKFrontend
|
8
|
-
module Field
|
9
|
-
# = GOV.UK Character count
|
10
|
-
#
|
11
|
-
# This helper is used for generating the character count component from the
|
12
|
-
# {https://design-system.service.gov.uk/components/character-count GDS - Components - Character count}
|
13
|
-
#
|
14
|
-
# This is a wrapper around a Textarea module and so makes use of the methods in {Textarea}
|
15
|
-
|
16
|
-
module CharacterCount
|
17
|
-
include Textarea
|
18
|
-
|
19
|
-
# Generates the HTML for the GOV.UK character count component.
|
20
|
-
# It works by warpping the govuk_textarea in HTML which will trigger the JavaScript to do the character count.
|
21
|
-
#
|
22
|
-
# @param attribute [String, Symbol] the attribute of the character count text area
|
23
|
-
# @param govuk_character_count_options [Hash] options that will be used for the parts of the form group, label, hint, textarea and the character count
|
24
|
-
#
|
25
|
-
# @option govuk_character_count_options [String] :error_message (nil) the error message to be displayed
|
26
|
-
# @option govuk_character_count_options [ActiveModel] :model (nil) optional model that can be used to find an error message
|
27
|
-
# @option govuk_character_count_options [ActionView::Helpers::FormBuilder] :form (nil) optional form builder used to create
|
28
|
-
# the textarea tag and find the error message
|
29
|
-
# @option govuk_character_count_options [Hash] :form_group see {govuk_field}
|
30
|
-
# @option govuk_character_count_options [Hash] :label see {govuk_field}
|
31
|
-
# @option govuk_character_count_options [Hash] :hint see {govuk_field}
|
32
|
-
# @option govuk_character_count_options [Hash] :textarea see {govuk_textarea}
|
33
|
-
# @option govuk_character_count_options [Hash] :character_count ({}) the options that will be used when rendering the textarea.
|
34
|
-
# See {_govuk_character_count} for more details.
|
35
|
-
#
|
36
|
-
# @return [ActiveSupport::SafeBuffer] the HTML for the GOV.UK chracter count
|
37
|
-
# which can then be rendered on the page
|
38
|
-
|
39
|
-
def govuk_character_count(attribute, **govuk_character_count_options)
|
40
|
-
character_count_attribute = govuk_character_count_options[:form] ? "#{form.object_name}_#{attribute}" : attribute
|
41
|
-
|
42
|
-
_govuk_character_count(character_count_attribute, **govuk_character_count_options) do |govuk_textarea_options|
|
43
|
-
govuk_textarea(
|
44
|
-
attribute,
|
45
|
-
error_message: govuk_character_count_options[:error_message],
|
46
|
-
model: govuk_character_count_options[:model],
|
47
|
-
form: govuk_character_count_options[:form],
|
48
|
-
**govuk_textarea_options
|
49
|
-
)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
private
|
54
|
-
|
55
|
-
# Wrapper method used by {govuk_character_count} to generate the character count HTML
|
56
|
-
#
|
57
|
-
# @param attribute [String, Symbol] the attribute of the character count
|
58
|
-
# @param govuk_character_count_options [Hash] options that will be used in customising the HTML.
|
59
|
-
# This includes everything described in {govuk_character_count}
|
60
|
-
# with the addition of the +:character_count+ which are described below
|
61
|
-
#
|
62
|
-
# @option govuk_character_count_options [String] :maxlength (required) - if +maxwords+ is set, this is not required.
|
63
|
-
# The maximum number of characters.
|
64
|
-
# If +maxwords+ is provided, the +maxlength+ option will be ignored.
|
65
|
-
# @option govuk_character_count_options [String] :maxwords (required) - if maxlength is set, this is not required.
|
66
|
-
# The maximum number of words.
|
67
|
-
# If +maxwords+ is provided, the +maxlength+ option will be ignored.
|
68
|
-
# @option govuk_character_count_options [String] :threshold the percentage value of the limit at which point the count message is displayed.
|
69
|
-
# If this attribute is set, the count message will be hidden by default.
|
70
|
-
# @option govuk_textarea_options [Hash] :fallback_hint ({}) additional parameters that will be used to create the hint containing the character count text.
|
71
|
-
# This includes all the options in {govuk_hint} plus +:count_message+.
|
72
|
-
# This will replace the default text for the count message.
|
73
|
-
# If you want the count number to appear, put %<count>s in the string and it will be replaced with the number
|
74
|
-
#
|
75
|
-
# @yield the textarea HTML generated by {govuk_character_count}
|
76
|
-
#
|
77
|
-
# @yieldparam govuk_textarea_options [Hash] the options used in the textarea called by {govuk_character_count}
|
78
|
-
#
|
79
|
-
# @return [ActiveSupport::SafeBuffer] the HTML for the chracter count which wrpas arround {govuk_character_count}
|
80
|
-
|
81
|
-
def _govuk_character_count(attribute, **govuk_character_count_options)
|
82
|
-
deep_init_hash(govuk_character_count_options, :textarea, :attributes, :aria)
|
83
|
-
govuk_character_count_options[:textarea][:attributes][:aria][:describedby] = [govuk_character_count_options.dig(:textarea, :attributes, :aria, :describedby), "#{attribute}-info"].compact.join(' ')
|
84
|
-
|
85
|
-
govuk_character_count_options[:textarea][:classes] = "#{govuk_character_count_options[:textarea][:classes]} govuk-js-character-count".lstrip
|
86
|
-
|
87
|
-
tag.div(**get_character_count_attributes(**govuk_character_count_options)) do
|
88
|
-
concat(yield(govuk_character_count_options))
|
89
|
-
concat(character_count_hint(attribute, **govuk_character_count_options))
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
# Generates the fallback hint HTML for {_govuk_character_count}
|
94
|
-
#
|
95
|
-
# @param (see _govuk_character_count)
|
96
|
-
#
|
97
|
-
# @option (see _govuk_character_count)
|
98
|
-
#
|
99
|
-
# @return [ActiveSupport::SafeBuffer] the HTML for the fullback hint used in {_govuk_character_count}
|
100
|
-
|
101
|
-
def character_count_hint(attribute, **govuk_character_count_options)
|
102
|
-
fallback_hint_length = govuk_character_count_options[:character_count][:maxwords] || govuk_character_count_options[:character_count][:maxlength]
|
103
|
-
fallback_hint_default = "You can enter up to %<count>s #{govuk_character_count_options[:character_count][:maxwords] ? 'words' : 'characters'}"
|
104
|
-
|
105
|
-
deep_init_hash(govuk_character_count_options, :character_count, :fallback_hint, :attributes)
|
106
|
-
|
107
|
-
fallback_hint_text = format(govuk_character_count_options[:character_count][:fallback_hint][:count_message] || fallback_hint_default, count: fallback_hint_length)
|
108
|
-
|
109
|
-
govuk_character_count_options[:character_count][:fallback_hint][:classes] = "#{govuk_character_count_options.dig(:character_count, :fallback_hint, :classes)} govuk-character-count__message".lstrip
|
110
|
-
govuk_character_count_options[:character_count][:fallback_hint][:attributes].merge!(id: "#{attribute}-info")
|
111
|
-
|
112
|
-
govuk_hint(fallback_hint_text, **govuk_character_count_options[:character_count][:fallback_hint])
|
113
|
-
end
|
114
|
-
|
115
|
-
# Generates a hash with the character count attributes used in {_govuk_character_count}
|
116
|
-
#
|
117
|
-
# @param govuk_character_count_options [Hash] options that will be used in customising the HTML.
|
118
|
-
# This includes everything described in {govuk_character_count}
|
119
|
-
# with the addition of the +:character_count+ which are described below
|
120
|
-
#
|
121
|
-
# @option (see _govuk_character_count)
|
122
|
-
#
|
123
|
-
# @return [Hash] contains the HTMl attributes used in {_govuk_character_count}
|
124
|
-
|
125
|
-
def get_character_count_attributes(**govuk_character_count_options)
|
126
|
-
govuk_character_count_attributes = { class: 'govuk-character-count', data: { module: 'govuk-character-count' } }
|
127
|
-
|
128
|
-
%i[maxlength threshold maxwords].each do |data_attribute|
|
129
|
-
govuk_character_count_attributes[:data][data_attribute] = govuk_character_count_options[:character_count][data_attribute].to_s if govuk_character_count_options[:character_count][data_attribute]
|
130
|
-
end
|
131
|
-
|
132
|
-
govuk_character_count_attributes
|
133
|
-
end
|
134
|
-
|
135
|
-
# Method to initialise hashes within hashes if it is not already initialised
|
136
|
-
#
|
137
|
-
# @param hash [Hash] the hash that is going to be initialised
|
138
|
-
# @param keys [Array] the keys that are going to be initialised in the hash
|
139
|
-
#
|
140
|
-
# @example When the hash is completely empty
|
141
|
-
# hash = { }
|
142
|
-
# keys = [:a, :b, :c]
|
143
|
-
#
|
144
|
-
# deep_init_hash(hash, *keys)
|
145
|
-
#
|
146
|
-
# hash = { a: { b: { c: { } } } }
|
147
|
-
#
|
148
|
-
# @example When the hash has already been initialised
|
149
|
-
# hash = { a: { b: { d: 'hello' } } }
|
150
|
-
# keys = [:a, :b, :c]
|
151
|
-
#
|
152
|
-
# deep_init_hash(hash, *keys)
|
153
|
-
#
|
154
|
-
# hash = { a: { b: { d: 'hello', c: { } } } }
|
155
|
-
|
156
|
-
def deep_init_hash(hash, *keys)
|
157
|
-
current_hash = hash
|
158
|
-
|
159
|
-
keys.each { |key| current_hash = (current_hash[key] ||= {}) }
|
160
|
-
end
|
161
|
-
end
|
162
|
-
end
|
163
|
-
end
|
164
|
-
end
|
165
|
-
end
|