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,160 +1,25 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
require_relative '../shared_methods'
|
3
|
+
require_relative '../../components/govuk/header'
|
6
4
|
|
7
5
|
module CCS
|
8
|
-
module FrontendHelpers
|
9
|
-
|
10
|
-
|
6
|
+
module FrontendHelpers::GovUKFrontend
|
7
|
+
# = GOV.UK Header
|
8
|
+
#
|
9
|
+
# This helper is used for generating the header component from the
|
10
|
+
# {https://design-system.service.gov.uk/components/header GDS - Components - Header}
|
11
|
+
|
12
|
+
module Header
|
13
|
+
# Generates the HTML for the GOV.UK Header component
|
11
14
|
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
include ActionView::Context
|
18
|
-
include ActionView::Helpers::FormTagHelper
|
19
|
-
include ActionView::Helpers::TagHelper
|
20
|
-
include ActionView::Helpers::TextHelper
|
21
|
-
include ActionView::Helpers::UrlHelper
|
22
|
-
|
23
|
-
# Generates the HTML for the GOV.UK Header component
|
24
|
-
#
|
25
|
-
# @param govuk_header_options [Hash] options that will be used to generate the header
|
26
|
-
#
|
27
|
-
# @option govuk_header_options [String] :classes additional CSS classes for the header HTML
|
28
|
-
# @option govuk_header_options [Hash] :attributes additional attributes that will added as part of the header HTML
|
29
|
-
# @option govuk_header_options [String] :container_classes classes for the container
|
30
|
-
# @option govuk_header_options [String] :homepage_url URL of the homepage. Defaults to +/+
|
31
|
-
# @option govuk_header_options [String] :product_name product name, used when the product name follows on directly from ‘GOV.UK
|
32
|
-
# @option govuk_header_options [Hash] :service see {govuk_header_service_name}
|
33
|
-
# @option govuk_header_options [Hash] :navigation see {govuk_header_navigation}
|
34
|
-
# @option govuk_header_options [Hash] :menu_button see {govuk_header_navigation}
|
35
|
-
#
|
36
|
-
# @return [ActiveSupport::SafeBuffer] the HTML for the GOV.UK Header
|
37
|
-
# which can then be rendered on the page
|
38
|
-
|
39
|
-
def govuk_header(**govuk_header_options)
|
40
|
-
determine_govuk_header_attributes(govuk_header_options)
|
41
|
-
|
42
|
-
tag.header(**govuk_header_options[:attributes]) do
|
43
|
-
tag.div(class: "govuk-header__container #{govuk_header_options[:container_classes] || 'govuk-width-container'}") do
|
44
|
-
concat(govuk_header_logo(**govuk_header_options))
|
45
|
-
if govuk_header_options[:service] || govuk_header_options[:navigation]
|
46
|
-
concat(tag.div(class: 'govuk-header__content') do
|
47
|
-
concat(govuk_header_service_name(govuk_header_options[:service])) if govuk_header_options[:service]
|
48
|
-
concat(govuk_header_navigation(govuk_header_options[:navigation], govuk_header_options[:menu_button])) if govuk_header_options[:navigation]
|
49
|
-
end)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
private
|
56
|
-
|
57
|
-
# Generates the logo for {govuk_header}
|
58
|
-
#
|
59
|
-
# @param govuk_header_options [Hash] options that will be used to generate the header
|
60
|
-
#
|
61
|
-
# @option (see govuk_header)
|
62
|
-
#
|
63
|
-
# @return [ActiveSupport::SafeBuffer] the HTML for the logo used in {govuk_header}
|
64
|
-
|
65
|
-
def govuk_header_logo(govuk_header_options)
|
66
|
-
tag.div(class: 'govuk-header__logo') do
|
67
|
-
link_to(govuk_header_options[:homepage_url] || '/', class: 'govuk-header__link govuk-header__link--homepage') do
|
68
|
-
concat(tag.span(class: 'govuk-header__logotype') do
|
69
|
-
concat(tag.svg(class: 'govuk-header__logotype-crown', xmlns: 'http://www.w3.org/2000/svg', height: '30', width: '36', aria: { hidden: 'true' }, focusable: 'false', viewBox: '0 0 132 97') do
|
70
|
-
tag.path(fill: 'currentColor', 'fill-rule': 'evenodd', d: 'M25 30.2c3.5 1.5 7.7-.2 9.1-3.7 1.5-3.6-.2-7.8-3.9-9.2-3.6-1.4-7.6.3-9.1 3.9-1.4 3.5.3 7.5 3.9 9zM9 39.5c3.6 1.5 7.8-.2 9.2-3.7 1.5-3.6-.2-7.8-3.9-9.1-3.6-1.5-7.6.2-9.1 3.8-1.4 3.5.3 7.5 3.8 9zM4.4 57.2c3.5 1.5 7.7-.2 9.1-3.8 1.5-3.6-.2-7.7-3.9-9.1-3.5-1.5-7.6.3-9.1 3.8-1.4 3.5.3 7.6 3.9 9.1zm38.3-21.4c3.5 1.5 7.7-.2 9.1-3.8 1.5-3.6-.2-7.7-3.9-9.1-3.6-1.5-7.6.3-9.1 3.8-1.3 3.6.4 7.7 3.9 9.1zm64.4-5.6c-3.6 1.5-7.8-.2-9.1-3.7-1.5-3.6.2-7.8 3.8-9.2 3.6-1.4 7.7.3 9.2 3.9 1.3 3.5-.4 7.5-3.9 9zm15.9 9.3c-3.6 1.5-7.7-.2-9.1-3.7-1.5-3.6.2-7.8 3.7-9.1 3.6-1.5 7.7.2 9.2 3.8 1.5 3.5-.3 7.5-3.8 9zm4.7 17.7c-3.6 1.5-7.8-.2-9.2-3.8-1.5-3.6.2-7.7 3.9-9.1 3.6-1.5 7.7.3 9.2 3.8 1.3 3.5-.4 7.6-3.9 9.1zM89.3 35.8c-3.6 1.5-7.8-.2-9.2-3.8-1.4-3.6.2-7.7 3.9-9.1 3.6-1.5 7.7.3 9.2 3.8 1.4 3.6-.3 7.7-3.9 9.1zM69.7 17.7l8.9 4.7V9.3l-8.9 2.8c-.2-.3-.5-.6-.9-.9L72.4 0H59.6l3.5 11.2c-.3.3-.6.5-.9.9l-8.8-2.8v13.1l8.8-4.7c.3.3.6.7.9.9l-5 15.4v.1c-.2.8-.4 1.6-.4 2.4 0 4.1 3.1 7.5 7 8.1h.2c.3 0 .7.1 1 .1.4 0 .7 0 1-.1h.2c4-.6 7.1-4.1 7.1-8.1 0-.8-.1-1.7-.4-2.4V34l-5.1-15.4c.4-.2.7-.6 1-.9zM66 92.8c16.9 0 32.8 1.1 47.1 3.2 4-16.9 8.9-26.7 14-33.5l-9.6-3.4c1 4.9 1.1 7.2 0 10.2-1.5-1.4-3-4.3-4.2-8.7L108.6 76c2.8-2 5-3.2 7.5-3.3-4.4 9.4-10 11.9-13.6 11.2-4.3-.8-6.3-4.6-5.6-7.9 1-4.7 5.7-5.9 8-.5 4.3-8.7-3-11.4-7.6-8.8 7.1-7.2 7.9-13.5 2.1-21.1-8 6.1-8.1 12.3-4.5 20.8-4.7-5.4-12.1-2.5-9.5 6.2 3.4-5.2 7.9-2 7.2 3.1-.6 4.3-6.4 7.8-13.5 7.2-10.3-.9-10.9-8-11.2-13.8 2.5-.5 7.1 1.8 11 7.3L80.2 60c-4.1 4.4-8 5.3-12.3 5.4 1.4-4.4 8-11.6 8-11.6H55.5s6.4 7.2 7.9 11.6c-4.2-.1-8-1-12.3-5.4l1.4 16.4c3.9-5.5 8.5-7.7 10.9-7.3-.3 5.8-.9 12.8-11.1 13.8-7.2.6-12.9-2.9-13.5-7.2-.7-5 3.8-8.3 7.1-3.1 2.7-8.7-4.6-11.6-9.4-6.2 3.7-8.5 3.6-14.7-4.6-20.8-5.8 7.6-5 13.9 2.2 21.1-4.7-2.6-11.9.1-7.7 8.8 2.3-5.5 7.1-4.2 8.1.5.7 3.3-1.3 7.1-5.7 7.9-3.5.7-9-1.8-13.5-11.2 2.5.1 4.7 1.3 7.5 3.3l-4.7-15.4c-1.2 4.4-2.7 7.2-4.3 8.7-1.1-3-.9-5.3 0-10.2l-9.5 3.4c5 6.9 9.9 16.7 14 33.5 14.8-2.1 30.8-3.2 47.7-3.2z')
|
71
|
-
end)
|
72
|
-
concat(tag.span('GOV.UK', class: 'govuk-header__logotype-text'))
|
73
|
-
end)
|
74
|
-
concat(tag.span(govuk_header_options[:product_name], class: 'govuk-header__product-name')) if govuk_header_options[:product_name]
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
# Generates the service name section for {govuk_header}
|
80
|
-
#
|
81
|
-
# @param service [Hash] options that will be used in the service name section
|
82
|
-
#
|
83
|
-
# @option service [String] :name the name of the service, included in the header
|
84
|
-
# @option service [String] :href URL for the service name anchor
|
85
|
-
#
|
86
|
-
# @return [ActiveSupport::SafeBuffer] the HTML for the service name section which is used in {govuk_header}
|
87
|
-
|
88
|
-
def govuk_header_service_name(service)
|
89
|
-
if service[:href]
|
90
|
-
link_to(service[:name], service[:href], class: 'govuk-header__link govuk-header__service-name')
|
91
|
-
else
|
92
|
-
tag.span(service[:name], class: 'govuk-header__service-name')
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
# Generates the navigation section for {govuk_header}
|
97
|
-
#
|
98
|
-
# @param navigation [Hash] options for the navigation
|
99
|
-
# @param menu_button [Hash] options for the menu button
|
100
|
-
#
|
101
|
-
# @option navigation [String] :classes additional CSS classes for the navigation HTML
|
102
|
-
# @option navigation [String] :label text for the aria-label attribute of the navigation. Defaults to the menu button text
|
103
|
-
# @option navigation [Array] :items the navigation items that will be rendered on the page (see {govuk_header_navigation_item})
|
104
|
-
#
|
105
|
-
# @option menu_button [String] :text text for the button that opens the mobile navigation menu.
|
106
|
-
# By default, this is set to +Menu+.
|
107
|
-
# @option menu_button [String] :label text for the aria-label attribute of the button that opens the mobile navigation.
|
108
|
-
# Defaults to +Show or hide menu+.
|
109
|
-
#
|
110
|
-
# @return [ActiveSupport::SafeBuffer] the HTML for the navigation section which is used in {govuk_header}
|
111
|
-
|
112
|
-
def govuk_header_navigation(navigation, menu_button)
|
113
|
-
(menu_button ||= {})[:text] ||= 'Menu'
|
114
|
-
|
115
|
-
tag.nav(aria: { label: navigation[:label] || menu_button[:text] }, class: "govuk-header__navigation #{navigation[:classes]}".rstrip) do
|
116
|
-
concat(button_tag(menu_button[:text], type: :button, class: 'govuk-header__menu-button govuk-js-header-toggle', aria: { controls: 'navigation', label: menu_button[:label] || 'Show or hide menu' }, hidden: true))
|
117
|
-
concat(tag.ul(id: 'navigation', class: 'govuk-header__navigation-list') do
|
118
|
-
navigation[:items].each { |navigation_item| concat(govuk_header_navigation_item(navigation_item)) }
|
119
|
-
end)
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
# Generates a navigation item for {govuk_header_navigation}
|
124
|
-
#
|
125
|
-
# @param navigation_item [Hash] options that will be used in customising the HTML
|
126
|
-
#
|
127
|
-
# @option navigation_item [Boolean] :active flag to mark the navigation item as active or not
|
128
|
-
# @option navigation_item [String] :text text for the navigation item
|
129
|
-
# @option navigation_item [String] :href URL of the navigation item anchor
|
130
|
-
# @option navigation_item [Hash] :attributes ({}) any additional attributes that will added as part of the HTML
|
131
|
-
#
|
132
|
-
# @return [ActiveSupport::SafeBuffer] the HTML for a navigation item which is used in {govuk_header_navigation}
|
133
|
-
|
134
|
-
def govuk_header_navigation_item(navigation_item)
|
135
|
-
tag.li(class: "govuk-header__navigation-item #{'govuk-header__navigation-item--active' if navigation_item[:active]}".rstrip) do
|
136
|
-
if navigation_item[:href]
|
137
|
-
(navigation_item[:attributes] ||= {})[:class] = 'govuk-header__link'
|
138
|
-
|
139
|
-
link_to(navigation_item[:text], navigation_item[:href], **navigation_item[:attributes])
|
140
|
-
else
|
141
|
-
navigation_item[:text]
|
142
|
-
end
|
143
|
-
end
|
144
|
-
end
|
145
|
-
|
146
|
-
# Sets the default attributes for {govuk_header}
|
147
|
-
#
|
148
|
-
# @param govuk_header_options [Hash] options that will be used in customising the HTML
|
149
|
-
#
|
150
|
-
# @option (see govuk_header)
|
151
|
-
|
152
|
-
def determine_govuk_header_attributes(govuk_header_options)
|
153
|
-
initialise_attributes_and_set_classes(govuk_header_options, 'govuk-header')
|
154
|
-
set_data_module(govuk_header_options, 'govuk-header')
|
15
|
+
# @param (see CCS::Components::GovUK::Header#initialize)
|
16
|
+
#
|
17
|
+
# @option (see CCS::Components::GovUK::Header#initialize)
|
18
|
+
#
|
19
|
+
# @return (see CCS::Components::GovUK::Header#render)
|
155
20
|
|
156
|
-
|
157
|
-
|
21
|
+
def govuk_header(**options)
|
22
|
+
Components::GovUK::Header.new(context: self, **options).render
|
158
23
|
end
|
159
24
|
end
|
160
25
|
end
|
@@ -1,37 +1,26 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
require_relative '../shared_methods'
|
3
|
+
require_relative '../../components/govuk/hint'
|
6
4
|
|
7
5
|
module CCS
|
8
|
-
module FrontendHelpers
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
# This helper is used for generating the hint text component from the Government Design Systems
|
13
|
-
|
14
|
-
module Hint
|
15
|
-
include SharedMethods
|
16
|
-
include ActionView::Context
|
17
|
-
include ActionView::Helpers::TagHelper
|
18
|
-
|
19
|
-
# Generates the HTML for the GOV.UK Hint component
|
20
|
-
#
|
21
|
-
# @param hint_text [String] the hint text
|
22
|
-
# @param govuk_hint_options [Hash] options that will be used in customising the HTML
|
23
|
-
#
|
24
|
-
# @option govuk_hint_options [String] :classes additional CSS classes for the hint HTML
|
25
|
-
# @option govuk_hint_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 Hint
|
28
|
-
# which can then be rendered on the page
|
6
|
+
module FrontendHelpers::GovUKFrontend
|
7
|
+
# = GOV.UK Hint
|
8
|
+
#
|
9
|
+
# This helper is used for generating the hint text component from the Government Design Systems
|
29
10
|
|
30
|
-
|
31
|
-
|
11
|
+
module Hint
|
12
|
+
# Generates the HTML for the GOV.UK Hint component
|
13
|
+
#
|
14
|
+
# @param (see CCS::Components::GovUK::Hint#initialize)
|
15
|
+
#
|
16
|
+
# @option (see CCS::Components::GovUK::Hint#initialize)
|
17
|
+
#
|
18
|
+
# @yield (see CCS::Components::GovUK::Hint#render)
|
19
|
+
#
|
20
|
+
# @return (see CCS::Components::GovUK::Hint#render)
|
32
21
|
|
33
|
-
|
34
|
-
|
22
|
+
def govuk_hint(text = nil, **options, &block)
|
23
|
+
Components::GovUK::Hint.new(context: self, text: text, **options).render(&block)
|
35
24
|
end
|
36
25
|
end
|
37
26
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../components/govuk/field/input/text_input'
|
4
|
+
|
5
|
+
module CCS
|
6
|
+
module FrontendHelpers::GovUKFrontend
|
7
|
+
# = GOV.UK Input
|
8
|
+
#
|
9
|
+
# This helper is used for generating the input component from the
|
10
|
+
# {https://design-system.service.gov.uk/components/text-input GDS - Components - Text Input}
|
11
|
+
|
12
|
+
module Input
|
13
|
+
# Generates the HTML for the GOV.UK Text Input component
|
14
|
+
#
|
15
|
+
# @param (see CCS::Components::GovUK::Input::TextInput#initialize)
|
16
|
+
#
|
17
|
+
# @option (see CCS::Components::GovUK::Input::TextInput#initialize)
|
18
|
+
#
|
19
|
+
# @return (see CCS::Components::GovUK::Input::TextInput#render)
|
20
|
+
|
21
|
+
def govuk_input(attribute, **options)
|
22
|
+
Components::GovUK::Field::Input::TextInput.new(context: self, attribute: attribute, **options).render
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -1,43 +1,27 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
require_relative '../shared_methods'
|
3
|
+
require_relative '../../components/govuk/inset_text'
|
6
4
|
|
7
5
|
module CCS
|
8
|
-
module FrontendHelpers
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
# {https://design-system.service.gov.uk/components/inset-text GDS - Components - Inset text}
|
14
|
-
|
15
|
-
module InsetText
|
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 Inset text component
|
22
|
-
#
|
23
|
-
# @param inset_text [String] text to use within the inset text component
|
24
|
-
# @param govuk_inset_text_options [Hash] options that will be used in customising the HTML
|
25
|
-
#
|
26
|
-
# @option govuk_inset_text_options [String] :classes additional CSS classes for the inset text HTML
|
27
|
-
# @option govuk_inset_text_options [Hash] :attributes ({}) any additional attributes that will added as part of the HTML
|
28
|
-
#
|
29
|
-
# @yield HTML that will be contained within the inset text div. Ignored if inset text is given
|
30
|
-
#
|
31
|
-
# @return [ActiveSupport::SafeBuffer] the HTML for the GOV.UK Inset text
|
32
|
-
# which can then be rendered on the page
|
6
|
+
module FrontendHelpers::GovUKFrontend
|
7
|
+
# = GOV.UK Inset Text
|
8
|
+
#
|
9
|
+
# This helper is used for generating the inset text component from the
|
10
|
+
# {https://design-system.service.gov.uk/components/inset-text GDS - Components - Inset text}
|
33
11
|
|
34
|
-
|
35
|
-
|
12
|
+
module InsetText
|
13
|
+
# Generates the HTML for the GOV.UK Inset text component
|
14
|
+
#
|
15
|
+
# @param (see CCS::Components::GovUK::InsetText#initialize)
|
16
|
+
#
|
17
|
+
# @option (see CCS::Components::GovUK::InsetText#initialize)
|
18
|
+
#
|
19
|
+
# @yield (see CCS::Components::GovUK::InsetText#render)
|
20
|
+
#
|
21
|
+
# @return (see CCS::Components::GovUK::InsetText#render)
|
36
22
|
|
37
|
-
|
38
|
-
|
39
|
-
end
|
40
|
-
end
|
23
|
+
def govuk_inset_text(text = nil, **options, &block)
|
24
|
+
Components::GovUK::InsetText.new(context: self, text: text, **options).render(&block)
|
41
25
|
end
|
42
26
|
end
|
43
27
|
end
|
@@ -1,91 +1,26 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
require_relative '../shared_methods'
|
3
|
+
require_relative '../../components/govuk/label'
|
6
4
|
|
7
5
|
module CCS
|
8
|
-
module FrontendHelpers
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
# This helper is used for generating the label component from the Government Design Systems
|
13
|
-
|
14
|
-
module Label
|
15
|
-
include SharedMethods
|
16
|
-
include ActionView::Context
|
17
|
-
include ActionView::Helpers::TagHelper
|
18
|
-
include ActionView::Helpers::TextHelper
|
19
|
-
include ActionView::Helpers::FormTagHelper
|
20
|
-
|
21
|
-
# Generates the HTML for the GOV.UK label component
|
22
|
-
#
|
23
|
-
# @param attribute [String, Symbol] the attribute of the input that requires a label
|
24
|
-
# @param label_text [String] the label text, it is ignored if a block is given
|
25
|
-
# @param govuk_label_options [Hash] options that will be used in customising the HTML
|
26
|
-
#
|
27
|
-
# @option govuk_label_options [String] :classes additional CSS classes for the label HTML
|
28
|
-
# @option govuk_label_options [Boolean] :is_page_heading (false) if the legend is also the heading it will rendered in a h1
|
29
|
-
# @option govuk_label_options [ActionView::Helpers::FormBuilder] :form (nil) optional form builder used to create the label
|
30
|
-
# @option govuk_label_options [Hash] :attributes ({}) any additional attributes that will added as part of the HTML
|
31
|
-
#
|
32
|
-
# @yield HTML that will be contained within the 'govuk-label' label. Ignored if label text is given
|
33
|
-
#
|
34
|
-
# @return [ActiveSupport::SafeBuffer] the HTML for the GOV.UK Label
|
35
|
-
# which can then be rendered on the page
|
36
|
-
|
37
|
-
def govuk_label(attribute, label_text = nil, **govuk_label_options, &block)
|
38
|
-
initialise_attributes_and_set_classes(govuk_label_options, 'govuk-label')
|
39
|
-
|
40
|
-
label_html = if govuk_label_options[:form]
|
41
|
-
govuk_label_form(attribute, label_text, **govuk_label_options, &block)
|
42
|
-
else
|
43
|
-
govuk_label_tag(attribute, label_text, **govuk_label_options, &block)
|
44
|
-
end
|
45
|
-
|
46
|
-
if govuk_label_options[:is_page_heading]
|
47
|
-
tag.h1(label_html, class: 'govuk-label-wrapper')
|
48
|
-
else
|
49
|
-
label_html
|
50
|
-
end
|
51
|
-
end
|
6
|
+
module FrontendHelpers::GovUKFrontend
|
7
|
+
# = GOV.UK label
|
8
|
+
#
|
9
|
+
# This helper is used for generating the label component from the Government Design Systems
|
52
10
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
#
|
64
|
-
# @return [ActiveSupport::SafeBuffer] the HTML for the GOV.UK Label
|
65
|
-
# which can then be rendered on the page
|
66
|
-
|
67
|
-
def govuk_label_tag(attribute, label_text, **govuk_label_options)
|
68
|
-
label_tag(attribute, **govuk_label_options[:attributes]) do
|
69
|
-
label_text || yield
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
# Generates the HTML for the GOV.UK label component
|
74
|
-
# using the inbuilt rails ActionView::Helpers::FormBuilder
|
75
|
-
#
|
76
|
-
# @param (see govuk_label)
|
77
|
-
#
|
78
|
-
# @option (see govuk_label)
|
79
|
-
#
|
80
|
-
# @yield (see govuk_label)
|
81
|
-
#
|
82
|
-
# @return (see govuk_label_tag)
|
11
|
+
module Label
|
12
|
+
# Generates the HTML for the GOV.UK label component
|
13
|
+
#
|
14
|
+
# @param (see CCS::Components::GovUK::Label#initialize)
|
15
|
+
#
|
16
|
+
# @option (see CCS::Components::GovUK::Label#initialize)
|
17
|
+
#
|
18
|
+
# @yield (see CCS::Components::GovUK::Label#render)
|
19
|
+
#
|
20
|
+
# @return (see CCS::Components::GovUK::Label#render)
|
83
21
|
|
84
|
-
|
85
|
-
|
86
|
-
label_text || yield
|
87
|
-
end
|
88
|
-
end
|
22
|
+
def govuk_label(attribute, text = nil, **options, &block)
|
23
|
+
Components::GovUK::Label.new(context: self, attribute: attribute, text: text, **options).render(&block)
|
89
24
|
end
|
90
25
|
end
|
91
26
|
end
|
@@ -1,135 +1,27 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
require_relative '../shared_methods'
|
3
|
+
require_relative '../../components/govuk/notification_banner'
|
6
4
|
|
7
5
|
module CCS
|
8
|
-
module FrontendHelpers
|
9
|
-
|
10
|
-
|
6
|
+
module FrontendHelpers::GovUKFrontend
|
7
|
+
# = GOV.UK Notification Banner
|
8
|
+
#
|
9
|
+
# This helper is used for generating the notification banner component from the
|
10
|
+
# {https://design-system.service.gov.uk/components/notification-banner GDS - Components - Notification banner}
|
11
|
+
|
12
|
+
module NotificationBanner
|
13
|
+
# Generates the HTML for the GOV.UK Notification banner component
|
11
14
|
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
include ActionView::Helpers::TextHelper
|
20
|
-
|
21
|
-
# Generates the HTML for the GOV.UK Notification banner component
|
22
|
-
#
|
23
|
-
# @param text [String] the text that will be used for the heading in the content section of the banner.
|
24
|
-
# It is ignored if a block is given
|
25
|
-
# @param success_banner [Boolean] will use the success banner options if this is set to true
|
26
|
-
# @param govuk_notification_banner_options [Hash] options that will be used in customising the HTML
|
27
|
-
#
|
28
|
-
# @option govuk_notification_banner_options [String] :classes additional CSS classes for the notification banner HTML
|
29
|
-
# @option govuk_notification_banner_options [String] :title_text ('Important') the title text shown at the top of the banner
|
30
|
-
# @option govuk_notification_banner_options [String] :title_id ('govuk-notification-banner-title') the ID for the title text
|
31
|
-
# @option govuk_notification_banner_options [String] :role ('region') the role for the banner
|
32
|
-
# @option govuk_notification_banner_options [String] :heading_level (2) the heading level for the title text
|
33
|
-
# @option govuk_notification_banner_options [Hash] :attributes ({data: { module: 'govuk-notification-banner' }, aria: { labelledby: 'govuk-notification-banner-title' }})
|
34
|
-
# any additional attributes that will added as part of the HTML
|
35
|
-
#
|
36
|
-
# @yield HTML that will be contained within the 'govuk-notification-banner__content' div
|
37
|
-
#
|
38
|
-
# @return [ActiveSupport::SafeBuffer] the HTML for the GOV.UK Notification banner
|
39
|
-
# which can then be rendered on the page
|
40
|
-
|
41
|
-
def govuk_notification_banner(text = nil, success_banner = false, **govuk_notification_banner_options)
|
42
|
-
banner_options = fetch_banner_options(success_banner, govuk_notification_banner_options)
|
43
|
-
|
44
|
-
set_banner_classes(banner_options, govuk_notification_banner_options)
|
45
|
-
set_banner_attributes(banner_options, govuk_notification_banner_options)
|
46
|
-
|
47
|
-
tag.div(**govuk_notification_banner_options[:attributes]) do
|
48
|
-
concat(tag.div(class: 'govuk-notification-banner__header') do
|
49
|
-
tag.send(:"h#{govuk_notification_banner_options[:heading_level] || 2}", banner_options[:title_text], class: 'govuk-notification-banner__title', id: banner_options[:title_id])
|
50
|
-
end)
|
51
|
-
concat(tag.div(class: 'govuk-notification-banner__content') do
|
52
|
-
if block_given?
|
53
|
-
yield
|
54
|
-
else
|
55
|
-
tag.p(text, class: 'govuk-notification-banner__heading')
|
56
|
-
end
|
57
|
-
end)
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
private
|
62
|
-
|
63
|
-
# Determines the banner options to be used for {#govuk_notification_banner}
|
64
|
-
#
|
65
|
-
# @param success_banner [Boolean] will use the success banner options if this is set to true
|
66
|
-
# @param govuk_notification_banner_options [Hash] options that will be used in customising the HTML
|
67
|
-
#
|
68
|
-
# @option govuk_notification_banner_options [String] :title_text ('Important') the title text shown at the top of the banner
|
69
|
-
# @option govuk_notification_banner_options [String] :title_id ('govuk-notification-banner-title') the ID for the title text
|
70
|
-
# @option govuk_notification_banner_options [String] :role ('region') the role for the banner
|
71
|
-
#
|
72
|
-
# @return [Hash] contains the following options used in {#govuk_notification_banner}:
|
73
|
-
# - +classes+
|
74
|
-
# - +title_text+
|
75
|
-
# - +title_id+
|
76
|
-
# - +role+
|
77
|
-
|
78
|
-
def fetch_banner_options(success_banner, govuk_notification_banner_options)
|
79
|
-
banner_options = DEFAULT_OPTIONS.dup
|
80
|
-
|
81
|
-
banner_options.merge!(SUCCESS_BANNER_OPTIONS) if success_banner
|
82
|
-
|
83
|
-
govuk_notification_banner_options.each do |key, value|
|
84
|
-
banner_options[key] = value if banner_options.key?(key)
|
85
|
-
end
|
86
|
-
|
87
|
-
banner_options
|
88
|
-
end
|
89
|
-
|
90
|
-
# Sets the banner classes to be used for {#govuk_notification_banner}
|
91
|
-
#
|
92
|
-
# @param banner_options [Hash] this is the return value from {#fetch_banner_options}
|
93
|
-
# @param govuk_notification_banner_options [Hash] options that will be used in customising the HTML
|
94
|
-
#
|
95
|
-
# @option govuk_notification_banner_options [String] :classes additional CSS classes for the notification banner HTML
|
96
|
-
|
97
|
-
def set_banner_classes(banner_options, govuk_notification_banner_options)
|
98
|
-
initialise_attributes_and_set_classes(govuk_notification_banner_options, 'govuk-notification-banner')
|
99
|
-
|
100
|
-
govuk_notification_banner_options[:attributes][:class] << banner_options[:classes].to_s
|
101
|
-
end
|
102
|
-
|
103
|
-
# Sets the HTML attributes for {#govuk_notification_banner}
|
104
|
-
#
|
105
|
-
# @param banner_options [Hash] this is the return value from {#fetch_banner_options}
|
106
|
-
# @param govuk_notification_banner_options [Hash] options that will be used in customising the HTML
|
107
|
-
#
|
108
|
-
# @option govuk_notification_banner_options [Hash] :attributes ({data: { module: 'govuk-notification-banner' }, aria: { labelledby: 'govuk-notification-banner-title' }})
|
109
|
-
# any additional attributes that will added as part of the HTML
|
110
|
-
|
111
|
-
def set_banner_attributes(banner_options, govuk_notification_banner_options)
|
112
|
-
set_data_module(govuk_notification_banner_options, 'govuk-notification-banner')
|
113
|
-
|
114
|
-
govuk_notification_banner_options[:attributes][:role] ||= banner_options[:role]
|
115
|
-
(govuk_notification_banner_options[:attributes][:aria] ||= {})[:labelledby] = banner_options[:title_id]
|
116
|
-
end
|
117
|
-
|
118
|
-
# Default options used in normal versions of {#govuk_notification_banner}
|
119
|
-
|
120
|
-
DEFAULT_OPTIONS = {
|
121
|
-
title_text: 'Important',
|
122
|
-
title_id: 'govuk-notification-banner-title',
|
123
|
-
role: 'region'
|
124
|
-
}.freeze
|
125
|
-
|
126
|
-
# Options specific for the success version of {#govuk_notification_banner}
|
15
|
+
# @param (see CCS::Components::GovUK::NotificationBanner#initialize)
|
16
|
+
#
|
17
|
+
# @option (see CCS::Components::GovUK::NotificationBanner#initialize)
|
18
|
+
#
|
19
|
+
# @yield (see CCS::Components::GovUK::NotificationBanner#render)
|
20
|
+
#
|
21
|
+
# @return (see CCS::Components::GovUK::NotificationBanner#render)
|
127
22
|
|
128
|
-
|
129
|
-
|
130
|
-
title_text: 'Success',
|
131
|
-
role: 'alert'
|
132
|
-
}.freeze
|
23
|
+
def govuk_notification_banner(text = nil, success_banner = nil, **options, &block)
|
24
|
+
Components::GovUK::NotificationBanner.new(context: self, text: text, success_banner: success_banner, **options).render(&block)
|
133
25
|
end
|
134
26
|
end
|
135
27
|
end
|