ccs-frontend_helpers 0.1.0.rc.2 → 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/CHANGELOG.md +1 -1
- data/Gemfile.lock +1 -1
- data/lib/ccs/components/ccs/dashboard_section/panel.rb +43 -41
- data/lib/ccs/components/ccs/dashboard_section.rb +50 -48
- data/lib/ccs/components/ccs/footer/link.rb +41 -39
- data/lib/ccs/components/ccs/footer/meta.rb +49 -48
- data/lib/ccs/components/ccs/footer/navigation.rb +51 -50
- data/lib/ccs/components/ccs/footer.rb +69 -67
- data/lib/ccs/components/ccs/header/link.rb +47 -45
- data/lib/ccs/components/ccs/header/navigation.rb +85 -84
- data/lib/ccs/components/ccs/header/service_authentication.rb +35 -34
- data/lib/ccs/components/ccs/header.rb +87 -85
- data/lib/ccs/components/ccs/logo.rb +36 -34
- data/lib/ccs/components/govuk/accordion/section/content.rb +42 -42
- data/lib/ccs/components/govuk/accordion/section/header.rb +48 -48
- data/lib/ccs/components/govuk/accordion/section.rb +49 -48
- data/lib/ccs/components/govuk/accordion.rb +43 -41
- data/lib/ccs/components/govuk/back_link.rb +39 -37
- data/lib/ccs/components/govuk/breadcrumbs/link.rb +42 -40
- data/lib/ccs/components/govuk/breadcrumbs.rb +40 -38
- data/lib/ccs/components/govuk/button.rb +83 -81
- data/lib/ccs/components/govuk/cookie_banner/action.rb +45 -43
- data/lib/ccs/components/govuk/cookie_banner/message.rb +57 -55
- data/lib/ccs/components/govuk/cookie_banner.rb +40 -38
- data/lib/ccs/components/govuk/details.rb +38 -36
- data/lib/ccs/components/govuk/error_message.rb +46 -44
- data/lib/ccs/components/govuk/error_summary/item.rb +41 -39
- data/lib/ccs/components/govuk/error_summary.rb +49 -47
- data/lib/ccs/components/govuk/field/input/character_count.rb +101 -99
- data/lib/ccs/components/govuk/field/input/file_upload.rb +29 -27
- data/lib/ccs/components/govuk/field/input/select.rb +61 -59
- data/lib/ccs/components/govuk/field/input/text_input/fix.rb +39 -37
- data/lib/ccs/components/govuk/field/input/text_input.rb +75 -73
- data/lib/ccs/components/govuk/field/input/textarea.rb +43 -41
- data/lib/ccs/components/govuk/field/input.rb +46 -44
- data/lib/ccs/components/govuk/field/inputs/checkboxes.rb +43 -41
- data/lib/ccs/components/govuk/field/inputs/date_input/item.rb +48 -46
- data/lib/ccs/components/govuk/field/inputs/date_input.rb +68 -66
- data/lib/ccs/components/govuk/field/inputs/item/checkbox/form.rb +29 -27
- data/lib/ccs/components/govuk/field/inputs/item/checkbox/tag.rb +26 -24
- data/lib/ccs/components/govuk/field/inputs/item/checkbox.rb +32 -30
- data/lib/ccs/components/govuk/field/inputs/item/divider.rb +39 -37
- data/lib/ccs/components/govuk/field/inputs/item/radio/form.rb +27 -25
- data/lib/ccs/components/govuk/field/inputs/item/radio/tag.rb +26 -24
- data/lib/ccs/components/govuk/field/inputs/item/radio.rb +32 -30
- data/lib/ccs/components/govuk/field/inputs/item.rb +100 -98
- data/lib/ccs/components/govuk/field/inputs/radios.rb +43 -41
- data/lib/ccs/components/govuk/field/inputs.rb +42 -40
- data/lib/ccs/components/govuk/field.rb +90 -88
- data/lib/ccs/components/govuk/fieldset/legend.rb +50 -48
- data/lib/ccs/components/govuk/fieldset.rb +40 -38
- data/lib/ccs/components/govuk/footer/link.rb +41 -39
- data/lib/ccs/components/govuk/footer/meta.rb +49 -48
- data/lib/ccs/components/govuk/footer/navigation.rb +51 -50
- data/lib/ccs/components/govuk/footer.rb +105 -103
- data/lib/ccs/components/govuk/form_group.rb +45 -43
- data/lib/ccs/components/govuk/header/link.rb +41 -39
- data/lib/ccs/components/govuk/header/navigation.rb +54 -53
- data/lib/ccs/components/govuk/header.rb +84 -82
- data/lib/ccs/components/govuk/hint.rb +33 -31
- data/lib/ccs/components/govuk/inset_text.rb +39 -37
- data/lib/ccs/components/govuk/label.rb +61 -59
- data/lib/ccs/components/govuk/notification_banner.rb +83 -81
- data/lib/ccs/components/govuk/pagination/increment/next.rb +29 -27
- data/lib/ccs/components/govuk/pagination/increment/previous.rb +28 -26
- data/lib/ccs/components/govuk/pagination/increment.rb +78 -76
- data/lib/ccs/components/govuk/pagination/item/ellipsis.rb +17 -15
- data/lib/ccs/components/govuk/pagination/item/form.rb +34 -32
- data/lib/ccs/components/govuk/pagination/item/tag.rb +33 -31
- data/lib/ccs/components/govuk/pagination/item.rb +47 -45
- data/lib/ccs/components/govuk/pagination.rb +69 -67
- data/lib/ccs/components/govuk/panel.rb +49 -47
- data/lib/ccs/components/govuk/phase_banner.rb +50 -48
- data/lib/ccs/components/govuk/skip_link.rb +39 -37
- data/lib/ccs/components/govuk/step_by_step_navigation/section/content/list/item.rb +40 -38
- data/lib/ccs/components/govuk/step_by_step_navigation/section/content/list.rb +30 -28
- data/lib/ccs/components/govuk/step_by_step_navigation/section/content/paragraph.rb +28 -26
- data/lib/ccs/components/govuk/step_by_step_navigation/section/content.rb +47 -45
- data/lib/ccs/components/govuk/step_by_step_navigation/section/heading.rb +49 -47
- data/lib/ccs/components/govuk/step_by_step_navigation/section.rb +44 -42
- data/lib/ccs/components/govuk/step_by_step_navigation.rb +41 -39
- data/lib/ccs/components/govuk/summary_list/action/link.rb +46 -44
- data/lib/ccs/components/govuk/summary_list/card/actions.rb +38 -36
- data/lib/ccs/components/govuk/summary_list/card/title.rb +37 -35
- data/lib/ccs/components/govuk/summary_list/card.rb +48 -46
- data/lib/ccs/components/govuk/summary_list/row/actions.rb +38 -36
- data/lib/ccs/components/govuk/summary_list/row/key.rb +30 -28
- data/lib/ccs/components/govuk/summary_list/row/value.rb +30 -28
- data/lib/ccs/components/govuk/summary_list/row.rb +47 -45
- data/lib/ccs/components/govuk/summary_list.rb +48 -46
- data/lib/ccs/components/govuk/table/body/data_cell.rb +38 -36
- data/lib/ccs/components/govuk/table/body/head_cell.rb +37 -35
- data/lib/ccs/components/govuk/table/header/head_cell.rb +39 -37
- data/lib/ccs/components/govuk/table.rb +83 -81
- data/lib/ccs/components/govuk/tabs/panel.rb +47 -45
- data/lib/ccs/components/govuk/tabs/tab.rb +42 -40
- data/lib/ccs/components/govuk/tabs.rb +48 -46
- data/lib/ccs/components/govuk/tag.rb +39 -37
- data/lib/ccs/components/govuk/warning_text.rb +49 -47
- data/lib/ccs/frontend_helpers/ccs_frontend/dashboard_section.rb +16 -14
- data/lib/ccs/frontend_helpers/ccs_frontend/footer.rb +17 -15
- data/lib/ccs/frontend_helpers/ccs_frontend/header.rb +17 -15
- data/lib/ccs/frontend_helpers/ccs_frontend.rb +1 -1
- data/lib/ccs/frontend_helpers/govuk_frontend/accordion.rb +17 -15
- data/lib/ccs/frontend_helpers/govuk_frontend/back_link.rb +17 -15
- data/lib/ccs/frontend_helpers/govuk_frontend/breadcrumbs.rb +17 -15
- data/lib/ccs/frontend_helpers/govuk_frontend/button.rb +17 -15
- data/lib/ccs/frontend_helpers/govuk_frontend/character_count.rb +17 -15
- data/lib/ccs/frontend_helpers/govuk_frontend/checkboxes.rb +17 -15
- data/lib/ccs/frontend_helpers/govuk_frontend/cookie_banner.rb +17 -15
- data/lib/ccs/frontend_helpers/govuk_frontend/date_input.rb +17 -15
- data/lib/ccs/frontend_helpers/govuk_frontend/details.rb +19 -17
- data/lib/ccs/frontend_helpers/govuk_frontend/error_message.rb +32 -30
- data/lib/ccs/frontend_helpers/govuk_frontend/error_summary.rb +38 -36
- data/lib/ccs/frontend_helpers/govuk_frontend/fieldset.rb +19 -17
- data/lib/ccs/frontend_helpers/govuk_frontend/file_upload.rb +17 -15
- data/lib/ccs/frontend_helpers/govuk_frontend/footer.rb +17 -15
- data/lib/ccs/frontend_helpers/govuk_frontend/form_group.rb +27 -25
- data/lib/ccs/frontend_helpers/govuk_frontend/header.rb +17 -15
- data/lib/ccs/frontend_helpers/govuk_frontend/hint.rb +18 -16
- data/lib/ccs/frontend_helpers/govuk_frontend/input.rb +17 -15
- data/lib/ccs/frontend_helpers/govuk_frontend/inset_text.rb +19 -17
- data/lib/ccs/frontend_helpers/govuk_frontend/label.rb +18 -16
- data/lib/ccs/frontend_helpers/govuk_frontend/notification_banner.rb +19 -17
- data/lib/ccs/frontend_helpers/govuk_frontend/pagination.rb +17 -15
- data/lib/ccs/frontend_helpers/govuk_frontend/panel.rb +19 -17
- data/lib/ccs/frontend_helpers/govuk_frontend/phase_banner.rb +19 -17
- data/lib/ccs/frontend_helpers/govuk_frontend/radios.rb +17 -15
- data/lib/ccs/frontend_helpers/govuk_frontend/select.rb +17 -15
- data/lib/ccs/frontend_helpers/govuk_frontend/skip_link.rb +17 -15
- data/lib/ccs/frontend_helpers/govuk_frontend/step_by_step_navigation.rb +24 -22
- data/lib/ccs/frontend_helpers/govuk_frontend/summary_list.rb +17 -15
- data/lib/ccs/frontend_helpers/govuk_frontend/table.rb +17 -15
- data/lib/ccs/frontend_helpers/govuk_frontend/tabs.rb +17 -15
- data/lib/ccs/frontend_helpers/govuk_frontend/tag.rb +17 -15
- data/lib/ccs/frontend_helpers/govuk_frontend/textarea.rb +17 -15
- data/lib/ccs/frontend_helpers/govuk_frontend/warning_text.rb +19 -17
- data/lib/ccs/frontend_helpers/version.rb +1 -1
- metadata +2 -2
@@ -1,41 +1,43 @@
|
|
1
1
|
require_relative '../item'
|
2
2
|
|
3
|
-
module CCS
|
4
|
-
module
|
5
|
-
|
6
|
-
class
|
7
|
-
|
8
|
-
|
9
|
-
# This generates the HTML for the pagination item using a link tag
|
10
|
-
#
|
11
|
-
# @!attribute [r] href
|
12
|
-
# @return [String] URL for the pagination item
|
13
|
-
|
14
|
-
class Tag < Item
|
15
|
-
private
|
16
|
-
|
17
|
-
attr_reader :href
|
18
|
-
|
19
|
-
public
|
20
|
-
|
21
|
-
# @param (see CCS::Components::GovUK::Pagination::Item)
|
22
|
-
# @param href [String] the URL for the pagination item
|
3
|
+
module CCS
|
4
|
+
module Components
|
5
|
+
module GovUK
|
6
|
+
class Pagination < Base
|
7
|
+
class Item < Base
|
8
|
+
# = GOV.UK Pagination Item tag
|
23
9
|
#
|
24
|
-
#
|
10
|
+
# This generates the HTML for the pagination item using a link tag
|
11
|
+
#
|
12
|
+
# @!attribute [r] href
|
13
|
+
# @return [String] URL for the pagination item
|
25
14
|
|
26
|
-
|
27
|
-
|
15
|
+
class Tag < Item
|
16
|
+
private
|
28
17
|
|
29
|
-
|
30
|
-
end
|
18
|
+
attr_reader :href
|
31
19
|
|
32
|
-
|
33
|
-
|
34
|
-
|
20
|
+
public
|
21
|
+
|
22
|
+
# @param (see CCS::Components::GovUK::Pagination::Item)
|
23
|
+
# @param href [String] the URL for the pagination item
|
24
|
+
#
|
25
|
+
# @option (see CCS::Components::GovUK::Pagination::Item)
|
26
|
+
|
27
|
+
def initialize(href:, **options)
|
28
|
+
super(**options)
|
29
|
+
|
30
|
+
@href = href
|
31
|
+
end
|
32
|
+
|
33
|
+
# Generates the HTML for the GOV.UK Pagination item link
|
34
|
+
#
|
35
|
+
# @return [ActiveSupport::SafeBuffer]
|
35
36
|
|
36
|
-
|
37
|
-
|
38
|
-
|
37
|
+
def render
|
38
|
+
super() do
|
39
|
+
link_to(number, href, **@options[:attributes])
|
40
|
+
end
|
39
41
|
end
|
40
42
|
end
|
41
43
|
end
|
@@ -1,61 +1,63 @@
|
|
1
1
|
require_relative '../../base'
|
2
2
|
|
3
|
-
module CCS
|
4
|
-
module
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
# This generates the HTML for the pagination item
|
9
|
-
#
|
10
|
-
# @!attribute [r] number
|
11
|
-
# @return [String] The number for the item
|
12
|
-
# @!attribute [r] li_classes
|
13
|
-
# @return [String] HTML classes for pagination item +li+ element
|
14
|
-
|
15
|
-
class Item < Base
|
16
|
-
private
|
17
|
-
|
18
|
-
attr_reader :number, :li_classes
|
19
|
-
|
20
|
-
public
|
21
|
-
|
22
|
-
# @param number [String] the number for the item
|
23
|
-
# @param current [Boolean] flag to indicate if this item is the current page
|
3
|
+
module CCS
|
4
|
+
module Components
|
5
|
+
module GovUK
|
6
|
+
class Pagination < Base
|
7
|
+
# = GOV.UK Pagination Item
|
24
8
|
#
|
25
|
-
#
|
26
|
-
#
|
27
|
-
#
|
9
|
+
# This generates the HTML for the pagination item
|
10
|
+
#
|
11
|
+
# @!attribute [r] number
|
12
|
+
# @return [String] The number for the item
|
13
|
+
# @!attribute [r] li_classes
|
14
|
+
# @return [String] HTML classes for pagination item +li+ element
|
28
15
|
|
29
|
-
|
30
|
-
|
16
|
+
class Item < Base
|
17
|
+
private
|
31
18
|
|
32
|
-
|
19
|
+
attr_reader :number, :li_classes
|
33
20
|
|
34
|
-
|
21
|
+
public
|
35
22
|
|
36
|
-
|
23
|
+
# @param number [String] the number for the item
|
24
|
+
# @param current [Boolean] flag to indicate if this item is the current page
|
25
|
+
#
|
26
|
+
# @option options [String] :classes additional CSS classes for the item HTML
|
27
|
+
# @option options [Symbol] :type the type of item. If the value is +:ellipsis+ then an ellipsis will be rendered
|
28
|
+
# @option options [Hash] :attributes any additional attributes that will added as part of the HTML
|
37
29
|
|
38
|
-
|
39
|
-
|
40
|
-
@options[:attributes][:aria][:current] = 'page'
|
41
|
-
end
|
30
|
+
def initialize(number:, current: false, **options)
|
31
|
+
super(**options)
|
42
32
|
|
43
|
-
|
44
|
-
end
|
33
|
+
@number = number
|
45
34
|
|
46
|
-
|
47
|
-
#
|
48
|
-
# @yield the HTML for the pagination item link/button
|
49
|
-
#
|
50
|
-
# @return [ActiveSupport::SafeBuffer]
|
35
|
+
(@options[:attributes][:aria] ||= {})[:label] ||= "Page #{@number}"
|
51
36
|
|
52
|
-
|
53
|
-
tag.li(class: li_classes, &block)
|
54
|
-
end
|
37
|
+
li_classes = 'govuk-pagination__item'
|
55
38
|
|
56
|
-
|
39
|
+
if current
|
40
|
+
li_classes << ' govuk-pagination__item--current'
|
41
|
+
@options[:attributes][:aria][:current] = 'page'
|
42
|
+
end
|
57
43
|
|
58
|
-
|
44
|
+
@li_classes = li_classes
|
45
|
+
end
|
46
|
+
|
47
|
+
# Generates the HTML for the GOV.UK Pagination item
|
48
|
+
#
|
49
|
+
# @yield the HTML for the pagination item link/button
|
50
|
+
#
|
51
|
+
# @return [ActiveSupport::SafeBuffer]
|
52
|
+
|
53
|
+
def render(&block)
|
54
|
+
tag.li(class: li_classes, &block)
|
55
|
+
end
|
56
|
+
|
57
|
+
# The default attributes for the pagination link
|
58
|
+
|
59
|
+
DEFAULT_ATTRIBUTES = { class: 'govuk-link govuk-pagination__link' }.freeze
|
60
|
+
end
|
59
61
|
end
|
60
62
|
end
|
61
63
|
end
|
@@ -5,89 +5,91 @@ require_relative 'pagination/item/ellipsis'
|
|
5
5
|
require_relative 'pagination/item/tag'
|
6
6
|
require_relative 'pagination/item/form'
|
7
7
|
|
8
|
-
module CCS
|
9
|
-
module
|
10
|
-
|
11
|
-
|
12
|
-
# This helper is used for generating the pagination component from the
|
13
|
-
# {https://design-system.service.gov.uk/components/pagination GDS - Components - Pagination}
|
14
|
-
#
|
15
|
-
# @!attribute [r] pagination_previous
|
16
|
-
# @return [Increment::Previous] Initialised pagination previous
|
17
|
-
# @!attribute [r] pagination_items
|
18
|
-
# @return [Array<Item::Ellipsis|Item::Tag|Item::Form>] An array of the initialised pagination items
|
19
|
-
# @!attribute [r] pagination_next
|
20
|
-
# @return [Increment::Next] Initialised pagination next
|
21
|
-
|
22
|
-
class Pagination < Base
|
23
|
-
private
|
24
|
-
|
25
|
-
attr_reader :pagination_previous, :pagination_items, :pagination_next
|
26
|
-
|
27
|
-
public
|
28
|
-
|
29
|
-
# rubocop:disable Metrics/CyclomaticComplexity
|
30
|
-
|
31
|
-
# @param pagination_previous [Hash] attributes for the pagination previous, see {CCS::Components::GovUK::Pagination::Increment::Previous#initialize Previous#initialize} for more details.
|
32
|
-
# @param pagination_items [Array<Hash>] An array of options for the pagination items.
|
33
|
-
# See {CCS::Components::GovUK::Pagination::Item::Tag#initialize Item::Tag#initialize} and
|
34
|
-
# {CCS::Components::GovUK::Pagination::Item::Form#initialize Item::Form#initialize} for details of the items in the array.
|
35
|
-
# @param pagination_next [Hash] attributes for the pagination next, see {CCS::Components::GovUK::Pagination::Increment::Next#initialize Next#initialize} for more details.
|
36
|
-
# @param options [Hash] options that will be used in customising the HTML
|
8
|
+
module CCS
|
9
|
+
module Components
|
10
|
+
module GovUK
|
11
|
+
# = GOV.UK Pagination
|
37
12
|
#
|
38
|
-
#
|
39
|
-
#
|
40
|
-
#
|
13
|
+
# This helper is used for generating the pagination component from the
|
14
|
+
# {https://design-system.service.gov.uk/components/pagination GDS - Components - Pagination}
|
15
|
+
#
|
16
|
+
# @!attribute [r] pagination_previous
|
17
|
+
# @return [Increment::Previous] Initialised pagination previous
|
18
|
+
# @!attribute [r] pagination_items
|
19
|
+
# @return [Array<Item::Ellipsis|Item::Tag|Item::Form>] An array of the initialised pagination items
|
20
|
+
# @!attribute [r] pagination_next
|
21
|
+
# @return [Increment::Next] Initialised pagination next
|
41
22
|
|
42
|
-
|
43
|
-
|
23
|
+
class Pagination < Base
|
24
|
+
private
|
44
25
|
|
45
|
-
|
26
|
+
attr_reader :pagination_previous, :pagination_items, :pagination_next
|
46
27
|
|
47
|
-
|
48
|
-
@options[:attributes][:role] = 'navigation'
|
49
|
-
(@options[:attributes][:aria] ||= {})[:label] ||= 'results'
|
28
|
+
public
|
50
29
|
|
51
|
-
|
52
|
-
@pagination_next = Increment::Next.new(block_is_level: block_is_level, form: @options[:form], context: @context, **pagination_next) if pagination_next
|
53
|
-
initialize_pagination_items(pagination_items, @options[:form])
|
54
|
-
end
|
30
|
+
# rubocop:disable Metrics/CyclomaticComplexity
|
55
31
|
|
56
|
-
|
32
|
+
# @param pagination_previous [Hash] attributes for the pagination previous, see {CCS::Components::GovUK::Pagination::Increment::Previous#initialize Previous#initialize} for more details.
|
33
|
+
# @param pagination_items [Array<Hash>] An array of options for the pagination items.
|
34
|
+
# See {CCS::Components::GovUK::Pagination::Item::Tag#initialize Item::Tag#initialize} and
|
35
|
+
# {CCS::Components::GovUK::Pagination::Item::Form#initialize Item::Form#initialize} for details of the items in the array.
|
36
|
+
# @param pagination_next [Hash] attributes for the pagination next, see {CCS::Components::GovUK::Pagination::Increment::Next#initialize Next#initialize} for more details.
|
37
|
+
# @param options [Hash] options that will be used in customising the HTML
|
38
|
+
#
|
39
|
+
# @option options [String] :classes additional CSS classes for the pagination HTML
|
40
|
+
# @option options [ActionView::Helpers::FormBuilder] :form form builder used to create pagination buttons
|
41
|
+
# @option options [Hash] :attributes any additional attributes that will added as part of the HTML
|
57
42
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
43
|
+
def initialize(pagination_previous: nil, pagination_items: nil, pagination_next: nil, **options)
|
44
|
+
super(**options)
|
45
|
+
|
46
|
+
block_is_level = pagination_items.blank? && (pagination_previous.present? || pagination_next.present?)
|
47
|
+
|
48
|
+
@options[:attributes][:class] << ' govuk-pagination--block' if block_is_level
|
49
|
+
@options[:attributes][:role] = 'navigation'
|
50
|
+
(@options[:attributes][:aria] ||= {})[:label] ||= 'results'
|
51
|
+
|
52
|
+
@pagination_previous = Increment::Previous.new(block_is_level: block_is_level, form: @options[:form], context: @context, **pagination_previous) if pagination_previous
|
53
|
+
@pagination_next = Increment::Next.new(block_is_level: block_is_level, form: @options[:form], context: @context, **pagination_next) if pagination_next
|
54
|
+
initialize_pagination_items(pagination_items, @options[:form])
|
55
|
+
end
|
56
|
+
|
57
|
+
# rubocop:enable Metrics/CyclomaticComplexity
|
58
|
+
|
59
|
+
# Generates the HTML for the GOV.UK pagination component
|
60
|
+
#
|
61
|
+
# @return [ActiveSupport::SafeBuffer]
|
62
|
+
|
63
|
+
def render
|
64
|
+
tag.nav(**options[:attributes]) do
|
65
|
+
concat(pagination_previous.render) if pagination_previous
|
66
|
+
if pagination_items
|
67
|
+
concat(tag.ul(class: 'govuk-pagination__list') do
|
68
|
+
pagination_items.each { |pagination_item| concat(pagination_item.render) }
|
69
|
+
end)
|
70
|
+
end
|
71
|
+
concat(pagination_next.render) if pagination_next
|
69
72
|
end
|
70
|
-
concat(pagination_next.render) if pagination_next
|
71
73
|
end
|
72
|
-
end
|
73
74
|
|
74
|
-
|
75
|
+
# The default attributes for the pagination
|
75
76
|
|
76
|
-
|
77
|
+
DEFAULT_ATTRIBUTES = { class: 'govuk-pagination' }.freeze
|
77
78
|
|
78
|
-
|
79
|
+
private
|
79
80
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
81
|
+
# Initialises the pagination items
|
82
|
+
#
|
83
|
+
# @param pagination_items [Array<Hash>] An array of options for the pagination items
|
84
|
+
# @param form [ActionView::Helpers::FormBuilder] form builder used to create pagination buttons
|
84
85
|
|
85
|
-
|
86
|
-
|
86
|
+
def initialize_pagination_items(pagination_items, form)
|
87
|
+
return unless pagination_items
|
87
88
|
|
88
|
-
|
89
|
+
pagination_item_class = form ? Item::Form : Item::Tag
|
89
90
|
|
90
|
-
|
91
|
+
@pagination_items = pagination_items.map { |pagination_item| pagination_item[:type] == :ellipsis ? Item::Ellipsis : pagination_item_class.new(form: form, context: context, **pagination_item) }
|
92
|
+
end
|
91
93
|
end
|
92
94
|
end
|
93
95
|
end
|
@@ -1,60 +1,62 @@
|
|
1
1
|
require_relative '../base'
|
2
2
|
|
3
|
-
module CCS
|
4
|
-
module
|
5
|
-
|
6
|
-
|
7
|
-
# This is used to generate the panel component from the
|
8
|
-
# {https://design-system.service.gov.uk/components/panel GDS - Components - Panel}
|
9
|
-
#
|
10
|
-
# @!attribute [r] title_text
|
11
|
-
# @return [String] Text for the panel title
|
12
|
-
# @!attribute [r] panel_text
|
13
|
-
# @return [String] Text that will be used for the panel content
|
14
|
-
|
15
|
-
class Panel < Base
|
16
|
-
private
|
17
|
-
|
18
|
-
attr_reader :title_text, :panel_text
|
19
|
-
|
20
|
-
public
|
21
|
-
|
22
|
-
# @param title_text [String] title text for the panel which will be contained in haeding tags
|
23
|
-
# @param panel_text [String] text to use within the panel component.
|
24
|
-
# If nil, then a block will be rendered
|
25
|
-
# @param options [Hash] options that will be used in customising the HTML
|
3
|
+
module CCS
|
4
|
+
module Components
|
5
|
+
module GovUK
|
6
|
+
# = GOV.UK Panel
|
26
7
|
#
|
27
|
-
#
|
28
|
-
#
|
29
|
-
#
|
8
|
+
# This is used to generate the panel component from the
|
9
|
+
# {https://design-system.service.gov.uk/components/panel GDS - Components - Panel}
|
10
|
+
#
|
11
|
+
# @!attribute [r] title_text
|
12
|
+
# @return [String] Text for the panel title
|
13
|
+
# @!attribute [r] panel_text
|
14
|
+
# @return [String] Text that will be used for the panel content
|
30
15
|
|
31
|
-
|
32
|
-
|
16
|
+
class Panel < Base
|
17
|
+
private
|
33
18
|
|
34
|
-
|
35
|
-
@panel_text = panel_text
|
36
|
-
end
|
19
|
+
attr_reader :title_text, :panel_text
|
37
20
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
21
|
+
public
|
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
|
+
# If nil, then a block will be rendered
|
26
|
+
# @param options [Hash] options that will be used in customising the HTML
|
27
|
+
#
|
28
|
+
# @option options [String] :classes additional CSS classes for the panel HTML
|
29
|
+
# @option options [Integer,String] :heading_level (default: 1) heading level for the panel title text
|
30
|
+
# @option options [Hash] :attributes ({}) any additional attributes that will added as part of the HTML
|
31
|
+
|
32
|
+
def initialize(title_text:, panel_text: nil, **options)
|
33
|
+
super(**options)
|
34
|
+
|
35
|
+
@title_text = title_text
|
36
|
+
@panel_text = panel_text
|
37
|
+
end
|
38
|
+
|
39
|
+
# Generates the HTML for the GOV.UK Panel component
|
40
|
+
#
|
41
|
+
# @yield HTML that will be contained within the panel body. Ignored if panel text is given
|
42
|
+
#
|
43
|
+
# @return [ActiveSupport::SafeBuffer]
|
44
|
+
|
45
|
+
def render
|
46
|
+
tag.div(**options[:attributes]) do
|
47
|
+
concat(tag.send(:"h#{options[:heading_level] || 1}", title_text, class: 'govuk-panel__title'))
|
48
|
+
if panel_text || block_given?
|
49
|
+
concat(tag.div(class: 'govuk-panel__body') do
|
50
|
+
panel_text || yield
|
51
|
+
end)
|
52
|
+
end
|
51
53
|
end
|
52
54
|
end
|
53
|
-
end
|
54
55
|
|
55
|
-
|
56
|
+
# The default attributes for the panel
|
56
57
|
|
57
|
-
|
58
|
+
DEFAULT_ATTRIBUTES = { class: 'govuk-panel govuk-panel--confirmation' }.freeze
|
59
|
+
end
|
58
60
|
end
|
59
61
|
end
|
60
62
|
end
|
@@ -1,67 +1,69 @@
|
|
1
1
|
require_relative '../base'
|
2
2
|
require_relative 'tag'
|
3
3
|
|
4
|
-
module CCS
|
5
|
-
module
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
4
|
+
module CCS
|
5
|
+
module Components
|
6
|
+
module GovUK
|
7
|
+
# = GOV.UK Phase banner
|
8
|
+
#
|
9
|
+
# This is used to generate the phase banner component from the
|
10
|
+
# {https://design-system.service.gov.uk/components/phase-banner GDS - Components - Phase banner}
|
11
|
+
#
|
12
|
+
# @!attribute [r] text
|
13
|
+
# @return [String] Text for the phase banner
|
14
|
+
# @!attribute [r] tag_options
|
15
|
+
# @return [Hash] Options for the phase banner tag
|
15
16
|
|
16
|
-
|
17
|
-
|
17
|
+
class PhaseBanner < Base
|
18
|
+
private
|
18
19
|
|
19
|
-
|
20
|
+
attr_reader :text, :tag_options
|
20
21
|
|
21
|
-
|
22
|
+
public
|
22
23
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
24
|
+
# @param tag_options [Hash] paramters for the govuk tag (see {Components::GovUK::Tag Tag}).
|
25
|
+
# options are:
|
26
|
+
# - +text+
|
27
|
+
# - +colour+
|
28
|
+
# - +options+
|
29
|
+
# @param text [String] the text for the phase banner.
|
30
|
+
# If nil, then a block will be rendered
|
31
|
+
# @param options [Hash] options that will be used in customising the HTML
|
32
|
+
#
|
33
|
+
# @option options [String] :classes additional CSS classes for the phase banner HTML
|
34
|
+
# @option options [Hash] :attributes ({}) any additional attributes that will added as part of the HTML
|
34
35
|
|
35
|
-
|
36
|
-
|
36
|
+
def initialize(tag_options:, text: nil, **options)
|
37
|
+
super(**options)
|
37
38
|
|
38
|
-
|
39
|
-
|
39
|
+
tag_options[:classes] = "govuk-phase-banner__content__tag #{tag_options[:classes]}".rstrip
|
40
|
+
tag_options[:context] = @context
|
40
41
|
|
41
|
-
|
42
|
-
|
43
|
-
|
42
|
+
@text = text
|
43
|
+
@tag_options = tag_options
|
44
|
+
end
|
44
45
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
46
|
+
# Generates the HTML for the GOV.UK Phase banner component
|
47
|
+
#
|
48
|
+
# @yield HTML that will be used in the phase banner. Ignored if text is passed.
|
49
|
+
#
|
50
|
+
# @return [ActiveSupport::SafeBuffer]
|
50
51
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
52
|
+
def render
|
53
|
+
tag.div(**options[:attributes]) do
|
54
|
+
tag.p(class: 'govuk-phase-banner__content') do
|
55
|
+
concat(Tag.new(**tag_options).render)
|
56
|
+
concat(tag.span(class: 'govuk-phase-banner__text') do
|
57
|
+
text || yield
|
58
|
+
end)
|
59
|
+
end
|
58
60
|
end
|
59
61
|
end
|
60
|
-
end
|
61
62
|
|
62
|
-
|
63
|
+
# The default attributes for the phase banner
|
63
64
|
|
64
|
-
|
65
|
+
DEFAULT_ATTRIBUTES = { class: 'govuk-phase-banner' }.freeze
|
66
|
+
end
|
65
67
|
end
|
66
68
|
end
|
67
69
|
end
|