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