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,336 +1,26 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
require_relative '../shared_methods'
|
3
|
+
require_relative '../../components/govuk/pagination'
|
6
4
|
|
7
5
|
module CCS
|
8
|
-
module FrontendHelpers
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
6
|
+
module FrontendHelpers::GovUKFrontend
|
7
|
+
# = GOV.UK Pagination
|
8
|
+
#
|
9
|
+
# This helper is used for generating the pagination component from the
|
10
|
+
# {https://design-system.service.gov.uk/components/pagination GDS - Components - Pagination}
|
11
|
+
|
12
|
+
module Pagination
|
13
|
+
# Generates the HTML for the GOV.UK Pagination component
|
13
14
|
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
include ActionView::Context
|
20
|
-
include ActionView::Helpers::TagHelper
|
21
|
-
include ActionView::Helpers::TextHelper
|
22
|
-
include ActionView::Helpers::UrlHelper
|
23
|
-
|
24
|
-
# Generates the HTML for the GOV.UK Pagination component
|
25
|
-
#
|
26
|
-
# @param (see _govuk_pagination)
|
27
|
-
#
|
28
|
-
# @option (see _govuk_pagination)
|
29
|
-
#
|
30
|
-
# @return [ActiveSupport::SafeBuffer] the HTML for the GOV.UK Pagination
|
31
|
-
# which can then be rendered on the page
|
32
|
-
|
33
|
-
def govuk_pagination(**govuk_pagination_options)
|
34
|
-
_govuk_pagination(**govuk_pagination_options) do |block_is_level|
|
35
|
-
concat(govuk_pagination_previous(block_is_level, form: govuk_pagination_options[:form], **govuk_pagination_options[:previous])) if govuk_pagination_options[:previous]
|
36
|
-
concat(govuk_pagination_items(govuk_pagination_options[:items], form: govuk_pagination_options[:form])) if govuk_pagination_options[:items]
|
37
|
-
concat(govuk_pagination_next(block_is_level, form: govuk_pagination_options[:form], **govuk_pagination_options[:next])) if govuk_pagination_options[:next]
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
private
|
42
|
-
|
43
|
-
# Wrapper method used by {govuk_pagination}
|
44
|
-
#
|
45
|
-
# @param govuk_pagination_options [Hash] options that will be used in customising the HTML
|
46
|
-
#
|
47
|
-
# @option govuk_pagination_options [ActionView::Helpers::FormBuilder] :form (nil) optional form builder used to create pagination buttons
|
48
|
-
# @option govuk_pagination_options [String] :classes additional CSS classes for the pagination HTML
|
49
|
-
# @option govuk_pagination_options [Array] :items an array of items for the pagination (see: {govuk_pagination_items})
|
50
|
-
# @option govuk_pagination_options [Hash] :previous the previous link (see: {govuk_pagination_previous})
|
51
|
-
# @option govuk_pagination_options [Hash] :next the next link (see: {govuk_pagination_next})
|
52
|
-
# @option govuk_pagination_options [Hash] :attributes ({role: 'navigation', aria: { label: 'results' }})
|
53
|
-
# any additional attributes that will added as part of the HTML
|
54
|
-
#
|
55
|
-
# @yield the pagination HTML generated by {govuk_pagination}
|
56
|
-
#
|
57
|
-
# @yieldparam block_is_level [Boolean] flag to indicate if there are no items
|
58
|
-
#
|
59
|
-
# @return [ActiveSupport::SafeBuffer] the HTML for the Pagination
|
60
|
-
# which is used in {govuk_pagination}
|
61
|
-
|
62
|
-
def _govuk_pagination(**govuk_pagination_options)
|
63
|
-
initialise_attributes_and_set_classes(govuk_pagination_options, 'govuk-pagination')
|
64
|
-
|
65
|
-
block_is_level = govuk_pagination_options[:items].blank? && (govuk_pagination_options[:next].present? || govuk_pagination_options[:previous].present?)
|
66
|
-
|
67
|
-
govuk_pagination_options[:attributes][:class] << ' govuk-pagination--block' if block_is_level
|
68
|
-
|
69
|
-
govuk_pagination_options[:attributes][:role] = 'navigation'
|
70
|
-
(govuk_pagination_options[:attributes][:aria] ||= {})[:label] ||= 'results'
|
71
|
-
|
72
|
-
tag.nav(**govuk_pagination_options[:attributes]) do
|
73
|
-
yield(block_is_level)
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
# Generates the previous link for {govuk_pagination}
|
78
|
-
#
|
79
|
-
# @param (see govuk_pagination_previous_content)
|
80
|
-
#
|
81
|
-
# @option (see govuk_pagination_previous_content)
|
82
|
-
#
|
83
|
-
# @return [ActiveSupport::SafeBuffer] the HTML for the previous link which is used in {govuk_pagination}
|
84
|
-
|
85
|
-
def govuk_pagination_previous(block_is_level, **govuk_pagination_previous_options)
|
86
|
-
govuk_pagination_previous_options[:attributes] ||= {}
|
87
|
-
govuk_pagination_previous_options[:attributes][:class] = "govuk-link govuk-pagination__link #{'pagination--button_as_link' if govuk_pagination_previous_options[:form]}".rstrip
|
88
|
-
govuk_pagination_previous_options[:attributes][:rel] = 'prev'
|
89
|
-
|
90
|
-
pagination_previous_content = govuk_pagination_previous_content(block_is_level, govuk_pagination_previous_options)
|
91
|
-
|
92
|
-
tag.div(class: 'govuk-pagination__prev') do
|
93
|
-
if govuk_pagination_previous_options[:form]
|
94
|
-
govuk_pagination_previous_options[:form].button(pagination_previous_content, **govuk_pagination_previous_options[:attributes])
|
95
|
-
else
|
96
|
-
link_to(pagination_previous_content, govuk_pagination_previous_options[:href], **govuk_pagination_previous_options[:attributes])
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
# Used by {govuk_pagination_previous}
|
102
|
-
# to generate the previous link content
|
103
|
-
#
|
104
|
-
# @param block_is_level [Boolean] when there are no items, this will be true and will add extra classes
|
105
|
-
# to the link to make the next and previous pagination links level
|
106
|
-
# @param govuk_pagination_previous_options [Hash] options that will be used in customising the HTML
|
107
|
-
#
|
108
|
-
# @option govuk_pagination_previous_options [ActionView::Helpers::FormBuilder] :form (nil) optional form builder used to create previous button
|
109
|
-
# @option govuk_pagination_previous_options [String] :href the URL for the link
|
110
|
-
# @option govuk_pagination_previous_options [String] :text ('Previous') the text for the link
|
111
|
-
# @option govuk_pagination_previous_options [String] :lable_text additional text for the link when the pagination block is level
|
112
|
-
# @option govuk_pagination_previous_options [Hash] :attributes ({}) any additional attributes that will added as part of the HTML
|
113
|
-
#
|
114
|
-
# @return [ActiveSupport::SafeBuffer] the HTML for the previous link/button
|
115
|
-
|
116
|
-
def govuk_pagination_previous_content(block_is_level, govuk_pagination_previous_options)
|
117
|
-
capture do
|
118
|
-
concat(govuk_pagination_icon(:prev))
|
119
|
-
concat(tag.span(govuk_pagination_previous_options[:text] || 'Previous', class: pagination_next_and_previous_classes(block_is_level, govuk_pagination_previous_options)))
|
120
|
-
concat(govuk_pagination_icon_label_text(block_is_level, govuk_pagination_previous_options[:lable_text]))
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
# Generates the next link for {govuk_pagination}
|
125
|
-
#
|
126
|
-
# @param (see govuk_pagination_next_content)
|
127
|
-
#
|
128
|
-
# @option (see govuk_pagination_next_content)
|
129
|
-
#
|
130
|
-
# @return [ActiveSupport::SafeBuffer] the HTML for the next link which is used in {govuk_pagination}
|
131
|
-
|
132
|
-
def govuk_pagination_next(block_is_level, **govuk_pagination_next_options)
|
133
|
-
govuk_pagination_next_options[:attributes] ||= {}
|
134
|
-
govuk_pagination_next_options[:attributes][:class] = "govuk-link govuk-pagination__link #{'pagination--button_as_link' if govuk_pagination_next_options[:form]}".rstrip
|
135
|
-
govuk_pagination_next_options[:attributes][:rel] = 'next'
|
136
|
-
|
137
|
-
pagination_next_content = govuk_pagination_next_content(block_is_level, **govuk_pagination_next_options)
|
138
|
-
|
139
|
-
tag.div(class: 'govuk-pagination__next') do
|
140
|
-
if govuk_pagination_next_options[:form]
|
141
|
-
govuk_pagination_next_options[:form].button(pagination_next_content, **govuk_pagination_next_options[:attributes])
|
142
|
-
else
|
143
|
-
link_to(pagination_next_content, govuk_pagination_next_options[:href], **govuk_pagination_next_options[:attributes])
|
144
|
-
end
|
145
|
-
end
|
146
|
-
end
|
147
|
-
|
148
|
-
# Used by {govuk_pagination_next} to generate the next link content
|
149
|
-
#
|
150
|
-
# @param block_is_level [Boolean] when there are no items, this will be true and will add extra classe
|
151
|
-
# to the link to make the next and previous pagination links level
|
152
|
-
# @param govuk_pagination_next_options [Hash] options that will be used in customising the HTML
|
153
|
-
#
|
154
|
-
# @option govuk_pagination_next_options [ActionView::Helpers::FormBuilder] :form (nil) optional form builder used to create next button
|
155
|
-
# @option govuk_pagination_next_options [String] :href the URL for the link
|
156
|
-
# @option govuk_pagination_next_options [String] :text ('Next') the text for the link
|
157
|
-
# @option govuk_pagination_next_options [String] :lable_text additional text for the link when the pagination block is level
|
158
|
-
# @option govuk_pagination_next_options [Hash] :attributes ({}) any additional attributes that will added as part of the HTML
|
159
|
-
#
|
160
|
-
# @return [ActiveSupport::SafeBuffer] the HTML for the next link/button
|
161
|
-
|
162
|
-
def govuk_pagination_next_content(block_is_level, **govuk_pagination_next_options)
|
163
|
-
capture do
|
164
|
-
concat(govuk_pagination_icon(:next)) if block_is_level
|
165
|
-
concat(tag.span(govuk_pagination_next_options[:text] || 'Next', class: pagination_next_and_previous_classes(block_is_level, govuk_pagination_next_options)))
|
166
|
-
concat(govuk_pagination_icon_label_text(block_is_level, govuk_pagination_next_options[:lable_text]))
|
167
|
-
concat(govuk_pagination_icon(:next)) unless block_is_level
|
168
|
-
end
|
169
|
-
end
|
170
|
-
|
171
|
-
# Returns the classes for the previous and next link/button label
|
172
|
-
#
|
173
|
-
# @param (see govuk_pagination_next_content)
|
174
|
-
|
175
|
-
def pagination_next_and_previous_classes(block_is_level, govuk_pagination_options)
|
176
|
-
"govuk-pagination__link-title #{'govuk-pagination__link-title--decorated' if block_is_level && !govuk_pagination_options[:lable_text]}".rstrip
|
177
|
-
end
|
178
|
-
|
179
|
-
# Generates the item links for {govuk_pagination}
|
180
|
-
#
|
181
|
-
# @param (see _govuk_pagination_items)
|
182
|
-
# @param form [ActionView::Helpers::FormBuilder] optional form builder used to create the item buttons
|
183
|
-
#
|
184
|
-
# @return [ActiveSupport::SafeBuffer] the HTML for the lits of items which is used in {govuk_pagination}
|
185
|
-
|
186
|
-
def govuk_pagination_items(govuk_pagination_items, form:)
|
187
|
-
if form
|
188
|
-
_govuk_pagination_items(govuk_pagination_items) do |govuk_pagination_item|
|
189
|
-
govuk_pagination_item_number_form(form, govuk_pagination_item)
|
190
|
-
end
|
191
|
-
else
|
192
|
-
_govuk_pagination_items(govuk_pagination_items) do |govuk_pagination_item|
|
193
|
-
govuk_pagination_item_number_tag(govuk_pagination_item)
|
194
|
-
end
|
195
|
-
end
|
196
|
-
end
|
197
|
-
|
198
|
-
# Wrapper method used by {govuk_pagination_items}
|
199
|
-
# to generate the pagination items HTML
|
200
|
-
#
|
201
|
-
# @param govuk_pagination_items [Array(Hash)] an array of item hashes for the pagination.
|
202
|
-
# There are two types of item:
|
203
|
-
# - {govuk_pagination_item_ellipsis ellipsis item}
|
204
|
-
# - {govuk_pagination_item_number_tag number item}
|
205
|
-
#
|
206
|
-
# @yield the pagination number item HTML generated by {govuk_pagination_items}
|
207
|
-
#
|
208
|
-
# @yieldparam govuk_pagination_item [Hash] the current pagination item in the loop
|
209
|
-
#
|
210
|
-
# @return [ActiveSupport::SafeBuffer] the HTML for the lits of items which is
|
211
|
-
# used in {govuk_pagination_items}
|
212
|
-
|
213
|
-
def _govuk_pagination_items(govuk_pagination_items)
|
214
|
-
tag.ul(class: 'govuk-pagination__list') do
|
215
|
-
govuk_pagination_items.each do |govuk_pagination_item|
|
216
|
-
case govuk_pagination_item[:type]
|
217
|
-
when :ellipsis
|
218
|
-
concat(govuk_pagination_item_ellipsis)
|
219
|
-
when :number
|
220
|
-
concat(yield(govuk_pagination_item))
|
221
|
-
end
|
222
|
-
end
|
223
|
-
end
|
224
|
-
end
|
225
|
-
|
226
|
-
# Generates the icon for:
|
227
|
-
# - {govuk_pagination_previous}
|
228
|
-
# - {govuk_pagination_next}
|
229
|
-
#
|
230
|
-
# @param type [Symbol] the type of the pagination icon (+:prev+ or +:next+)
|
231
|
-
#
|
232
|
-
# @return [ActiveSupport::SafeBuffer]
|
233
|
-
|
234
|
-
def govuk_pagination_icon(type)
|
235
|
-
tag.svg(class: "govuk-pagination__icon govuk-pagination__icon--#{type}", xmlns: 'http://www.w3.org/2000/svg', height: '13', width: '15', aria: { hidden: 'true' }, focusable: 'false', viewBox: '0 0 15 13') do
|
236
|
-
tag.path(d: PAGINATION_ICON_PATHS[type])
|
237
|
-
end
|
238
|
-
end
|
239
|
-
|
240
|
-
# Generates the label text for:
|
241
|
-
# - {govuk_pagination_previous}
|
242
|
-
# - {govuk_pagination_next}
|
243
|
-
#
|
244
|
-
# @param block_is_level [Boolean] when there are no items, this will be true
|
245
|
-
# @param label_text [String] the additional text for the link
|
246
|
-
#
|
247
|
-
# @return [ActiveSupport::SafeBuffer]
|
248
|
-
|
249
|
-
def govuk_pagination_icon_label_text(block_is_level, label_text)
|
250
|
-
return unless block_is_level && label_text
|
251
|
-
|
252
|
-
concat(tag.span(':', class: 'govuk-visually-hidden'))
|
253
|
-
concat(tag.span(label_text, class: 'govuk-pagination__link-label'))
|
254
|
-
end
|
255
|
-
|
256
|
-
# Generates the ellipsis HTML for {govuk_pagination_items}
|
257
|
-
#
|
258
|
-
# @return [ActiveSupport::SafeBuffer] the HTML for an ellipsis item which is used in {govuk_pagination_items}
|
259
|
-
|
260
|
-
def govuk_pagination_item_ellipsis
|
261
|
-
tag.li('⋯', class: 'govuk-pagination__item govuk-pagination__item--ellipses')
|
262
|
-
end
|
263
|
-
|
264
|
-
# Generates the number item HTML for {govuk_pagination_items}
|
265
|
-
#
|
266
|
-
# @param (see _govuk_pagination_item_number)
|
267
|
-
#
|
268
|
-
# @option (see _govuk_pagination_item_number)
|
269
|
-
#
|
270
|
-
# @return [ActiveSupport::SafeBuffer] the HTML for an number item which is used in {govuk_pagination_items}
|
271
|
-
|
272
|
-
def govuk_pagination_item_number_tag(govuk_pagination_item)
|
273
|
-
_govuk_pagination_item_number(govuk_pagination_item) do
|
274
|
-
link_to(govuk_pagination_item[:number], govuk_pagination_item[:href], **govuk_pagination_item[:attributes])
|
275
|
-
end
|
276
|
-
end
|
277
|
-
|
278
|
-
# Generates the number item HTML for {govuk_pagination_items} when there is a ActionView::Helpers::FormBuilder
|
279
|
-
#
|
280
|
-
# @param form [ActionView::Helpers::FormBuilder] the form builder used to create the item button
|
281
|
-
# @param (see _govuk_pagination_item_number)
|
282
|
-
#
|
283
|
-
# @option (see _govuk_pagination_item_number)
|
284
|
-
#
|
285
|
-
# @return (see govuk_pagination_item_number_tag)
|
286
|
-
|
287
|
-
def govuk_pagination_item_number_form(form, govuk_pagination_item)
|
288
|
-
govuk_pagination_item[:classes] = 'pagination-number--button_as_link'
|
289
|
-
|
290
|
-
_govuk_pagination_item_number(govuk_pagination_item) do
|
291
|
-
form.button(govuk_pagination_item[:number], **govuk_pagination_item[:attributes])
|
292
|
-
end
|
293
|
-
end
|
294
|
-
|
295
|
-
# Wrapper method used by {govuk_pagination_item_number_tag} and {govuk_pagination_item_number_form}
|
296
|
-
# to generate the pagination number item HTML
|
297
|
-
#
|
298
|
-
# @param govuk_pagination_item [Hash] options that will be used in customising the HTML
|
299
|
-
#
|
300
|
-
# @option govuk_pagination_item [String] :href the URL for the link
|
301
|
-
# @option govuk_pagination_item [String] :number the number for the link
|
302
|
-
# @option govuk_pagination_item [String] :current is this item the current page
|
303
|
-
# @option govuk_pagination_item [Hash] :attributes ({aria: { label: 'Page <NUMBER>' } })
|
304
|
-
# any additional attributes that will added as part of the HTML
|
305
|
-
#
|
306
|
-
# @yield the pagination number item link (when {govuk_pagination_item_number_tag}) or button (when {govuk_pagination_item_number_form})
|
307
|
-
#
|
308
|
-
# @return [ActiveSupport::SafeBuffer] the HTML for an number item which is used
|
309
|
-
# in {govuk_pagination_item_number_tag} or {govuk_pagination_item_number_form}
|
310
|
-
|
311
|
-
def _govuk_pagination_item_number(govuk_pagination_item, &block)
|
312
|
-
initialise_attributes_and_set_classes(govuk_pagination_item, 'govuk-link govuk-pagination__link')
|
313
|
-
|
314
|
-
(govuk_pagination_item[:attributes][:aria] ||= {})[:label] ||= "Page #{govuk_pagination_item[:number]}"
|
315
|
-
|
316
|
-
govuk_pagination_list_classes = +'govuk-pagination__item'
|
317
|
-
|
318
|
-
if govuk_pagination_item[:current]
|
319
|
-
govuk_pagination_list_classes << ' govuk-pagination__item--current'
|
320
|
-
govuk_pagination_item[:attributes][:aria][:current] = 'page'
|
321
|
-
end
|
322
|
-
|
323
|
-
tag.li(class: govuk_pagination_list_classes, &block)
|
324
|
-
end
|
325
|
-
|
326
|
-
# The paths for the pagination next and previous icons
|
15
|
+
# @param (see CCS::Components::GovUK::Pagination#initialize)
|
16
|
+
#
|
17
|
+
# @option (see CCS::Components::GovUK::Pagination#initialize)
|
18
|
+
#
|
19
|
+
# @return (see CCS::Components::GovUK::Pagination#render)
|
327
20
|
|
328
|
-
|
329
|
-
|
330
|
-
next: 'm8.107-0.0078125-1.4136 1.414 4.2926 4.293h-12.986v2h12.896l-4.1855 3.9766 1.377 1.4492 6.7441-6.4062-6.7246-6.7266z'
|
331
|
-
}.freeze
|
21
|
+
def govuk_pagination(**options)
|
22
|
+
Components::GovUK::Pagination.new(context: self, **options).render
|
332
23
|
end
|
333
|
-
# rubocop:enable Metrics/ModuleLength
|
334
24
|
end
|
335
25
|
end
|
336
26
|
end
|
@@ -1,50 +1,27 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
require_relative '../shared_methods'
|
3
|
+
require_relative '../../components/govuk/panel'
|
6
4
|
|
7
5
|
module CCS
|
8
|
-
module FrontendHelpers
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
# {https://design-system.service.gov.uk/components/panel GDS - Components - Panel}
|
14
|
-
|
15
|
-
module Panel
|
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 Panel component
|
22
|
-
#
|
23
|
-
# @param title_text [String] title text for the panel which will be contained in haeding tags
|
24
|
-
# @param panel_text [String] text to use within the panel component
|
25
|
-
# @param govuk_panel_options [Hash] options that will be used in customising the HTML
|
26
|
-
#
|
27
|
-
# @option govuk_panel_options [String] :classes additional CSS classes for the panel HTML
|
28
|
-
# @option govuk_panel_options [Integer,String] :heading_level (default: 1) heading level for the panel title text
|
29
|
-
# @option govuk_panel_options [Hash] :attributes ({}) any additional attributes that will added as part of the HTML
|
30
|
-
#
|
31
|
-
# @yield HTML that will be contained within the panel body. Ignored if panel text is given
|
32
|
-
#
|
33
|
-
# @return [ActiveSupport::SafeBuffer] the HTML for the GOV.UK Panel
|
34
|
-
# which can then be rendered on the page
|
6
|
+
module FrontendHelpers::GovUKFrontend
|
7
|
+
# = GOV.UK Panel
|
8
|
+
#
|
9
|
+
# This helper is used for generating the panel component from the
|
10
|
+
# {https://design-system.service.gov.uk/components/panel GDS - Components - Panel}
|
35
11
|
|
36
|
-
|
37
|
-
|
12
|
+
module Panel
|
13
|
+
# Generates the HTML for the GOV.UK Panel component
|
14
|
+
#
|
15
|
+
# @param (see CCS::Components::GovUK::Panel#initialize)
|
16
|
+
#
|
17
|
+
# @option (see CCS::Components::GovUK::Panel#initialize)
|
18
|
+
#
|
19
|
+
# @yield (see CCS::Components::GovUK::Panel#render)
|
20
|
+
#
|
21
|
+
# @return (see CCS::Components::GovUK::Panel#render)
|
38
22
|
|
39
|
-
|
40
|
-
|
41
|
-
if panel_text || block_given?
|
42
|
-
concat(tag.div(class: 'govuk-panel__body') do
|
43
|
-
panel_text || yield
|
44
|
-
end)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
23
|
+
def govuk_panel(title_text, panel_text = nil, **options, &block)
|
24
|
+
Components::GovUK::Panel.new(context: self, title_text: title_text, panel_text: panel_text, **options).render(&block)
|
48
25
|
end
|
49
26
|
end
|
50
27
|
end
|
@@ -1,48 +1,27 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative '
|
3
|
+
require_relative '../../components/govuk/phase_banner'
|
4
4
|
|
5
5
|
module CCS
|
6
|
-
module FrontendHelpers
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
# {https://design-system.service.gov.uk/components/phase-banner GDS - Components - Phase banner}
|
12
|
-
|
13
|
-
module PhaseBanner
|
14
|
-
include ActionView::Helpers::TextHelper
|
15
|
-
include Tag
|
16
|
-
|
17
|
-
# Generates the HTML for the GOV.UK Phase banner component
|
18
|
-
#
|
19
|
-
# @param text [String] the text for the phase banner
|
20
|
-
# @param tag_options [Hash] paramters for the govuk tag (see {govuk_tag}).
|
21
|
-
# options are:
|
22
|
-
# - +text+
|
23
|
-
# - +colour+
|
24
|
-
# - +options+
|
25
|
-
# @param govuk_phase_banner_options [Hash] options that will be used in customising the HTML
|
26
|
-
#
|
27
|
-
# @option govuk_phase_banner_options [String] :classes additional CSS classes for the phase banner HTML
|
28
|
-
# @option govuk_phase_banner_options [Hash] :attributes ({}) any additional attributes that will added as part of the HTML
|
29
|
-
#
|
30
|
-
# @return [ActiveSupport::SafeBuffer] the HTML for the GOV.UK Phase banner
|
31
|
-
# which can then be rendered on the page
|
32
|
-
|
33
|
-
def govuk_phase_banner(text, tag_options, **govuk_phase_banner_options)
|
34
|
-
initialise_attributes_and_set_classes(govuk_phase_banner_options, 'govuk-phase-banner')
|
6
|
+
module FrontendHelpers::GovUKFrontend
|
7
|
+
# = GOV.UK Phase banner
|
8
|
+
#
|
9
|
+
# This helper is used for generating the phase banner component from the
|
10
|
+
# {https://design-system.service.gov.uk/components/phase-banner GDS - Components - Phase banner}
|
35
11
|
|
36
|
-
|
37
|
-
|
12
|
+
module PhaseBanner
|
13
|
+
# Generates the HTML for the GOV.UK Phase banner component
|
14
|
+
#
|
15
|
+
# @param (see CCS::Components::GovUK::PhaseBanner#initialize)
|
16
|
+
#
|
17
|
+
# @option (see CCS::Components::GovUK::PhaseBanner#initialize)
|
18
|
+
#
|
19
|
+
# @yield (see CCS::Components::GovUK::PhaseBanner#render)
|
20
|
+
#
|
21
|
+
# @return (see CCS::Components::GovUK::PhaseBanner#render)
|
38
22
|
|
39
|
-
|
40
|
-
|
41
|
-
concat(govuk_tag(tag_options[:text], tag_options[:colour], **tag_options[:options]))
|
42
|
-
concat(tag.span(text, class: 'govuk-phase-banner__text'))
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
23
|
+
def govuk_phase_banner(tag_options, text = nil, **options, &block)
|
24
|
+
Components::GovUK::PhaseBanner.new(context: self, tag_options: tag_options, text: text, **options).render(&block)
|
46
25
|
end
|
47
26
|
end
|
48
27
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../components/govuk/field/inputs/radios'
|
4
|
+
|
5
|
+
module CCS
|
6
|
+
module FrontendHelpers::GovUKFrontend
|
7
|
+
# = GOV.UK Radios
|
8
|
+
#
|
9
|
+
# This helper is used for generating the radios component from the
|
10
|
+
# {https://design-system.service.gov.uk/components/radios GDS - Components - Radios}
|
11
|
+
|
12
|
+
module Radios
|
13
|
+
# Generates the HTML for the GOV.UK Radios component
|
14
|
+
#
|
15
|
+
# @param (see CCS::Components::GovUK::Inputs::Radios#initialize)
|
16
|
+
#
|
17
|
+
# @option (see CCS::Components::GovUK::Inputs::Radios#initialize)
|
18
|
+
#
|
19
|
+
# @return (see CCS::Components::GovUK::Inputs::Radios#render)
|
20
|
+
|
21
|
+
def govuk_radios(attribute, radio_items, **options)
|
22
|
+
Components::GovUK::Field::Inputs::Radios.new(context: self, attribute: attribute, radio_items: radio_items, **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/input/select'
|
4
|
+
|
5
|
+
module CCS
|
6
|
+
module FrontendHelpers::GovUKFrontend
|
7
|
+
# = GOV.UK Select
|
8
|
+
#
|
9
|
+
# This helper is used for generating the select component from the
|
10
|
+
# {https://design-system.service.gov.uk/components/select GDS - Components - Select}
|
11
|
+
|
12
|
+
module Select
|
13
|
+
# Generates the HTML for the GOV.UK Select component
|
14
|
+
#
|
15
|
+
# @param (see CCS::Components::GovUK::Input::Select#initialize)
|
16
|
+
#
|
17
|
+
# @option (see CCS::Components::GovUK::Input::Select#initialize)
|
18
|
+
#
|
19
|
+
# @return (see CCS::Components::GovUK::Input::Select#render)
|
20
|
+
|
21
|
+
def govuk_select(attribute, items, **options)
|
22
|
+
Components::GovUK::Field::Input::Select.new(context: self, attribute: attribute, items: items, **options).render
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -1,39 +1,25 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
require_relative '../shared_methods'
|
3
|
+
require_relative '../../components/govuk/skip_link'
|
6
4
|
|
7
5
|
module CCS
|
8
|
-
module FrontendHelpers
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
# {https://design-system.service.gov.uk/components/skip-link GDS - Components - Skip link}
|
14
|
-
|
15
|
-
module SkipLink
|
16
|
-
include SharedMethods
|
17
|
-
include ActionView::Helpers::UrlHelper
|
18
|
-
|
19
|
-
# Generates the HTML for the GOV.UK Skip link component
|
20
|
-
#
|
21
|
-
# @param text [String] the text for the skip link
|
22
|
-
# @param href [String] the href for the skip link
|
23
|
-
# @param govuk_skip_link_options [Hash] options that will be used in customising the HTML
|
24
|
-
#
|
25
|
-
# @option govuk_skip_link_options [String] :classes additional CSS classes for the skip link HTML
|
26
|
-
# @option govuk_skip_link_options [Hash] :attributes ({}) any additional attributes that will added as part of the HTML
|
27
|
-
#
|
28
|
-
# @return [ActiveSupport::SafeBuffer] the HTML for the GOV.UK Skip link
|
29
|
-
# which can then be rendered on the page
|
6
|
+
module FrontendHelpers::GovUKFrontend
|
7
|
+
# = GOV.UK Skip Link
|
8
|
+
#
|
9
|
+
# This helper is used for generating the skip link component from the
|
10
|
+
# {https://design-system.service.gov.uk/components/skip-link GDS - Components - Skip link}
|
30
11
|
|
31
|
-
|
32
|
-
|
33
|
-
|
12
|
+
module SkipLink
|
13
|
+
# Generates the HTML for the GOV.UK Skip link component
|
14
|
+
#
|
15
|
+
# @param (see CCS::Components::GovUK::SkipLink#initialize)
|
16
|
+
#
|
17
|
+
# @option (see CCS::Components::GovUK::SkipLink#initialize)
|
18
|
+
#
|
19
|
+
# @return (see CCS::Components::GovUK::SkipLink#render)
|
34
20
|
|
35
|
-
|
36
|
-
|
21
|
+
def govuk_skip_link(text, href = nil, **options)
|
22
|
+
Components::GovUK::SkipLink.new(context: self, text: text, href: href, **options).render
|
37
23
|
end
|
38
24
|
end
|
39
25
|
end
|