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
@@ -3,63 +3,65 @@ require_relative 'item/divider'
3
3
  require_relative 'item/checkbox/form'
4
4
  require_relative 'item/checkbox/tag'
5
5
 
6
- module CCS::Components
7
- module GovUK
8
- class Field < Base
9
- class Inputs < Field
10
- # = GOV.UK Checkboxes
11
- #
12
- # This is used for generating the checkboxes component from the
13
- # {https://design-system.service.gov.uk/components/checkboxes GDS - Components - Checkboxes}
14
- #
15
- # @!attribute [r] checkbox_items
16
- # @return [Array<Item::Divider|Item::Checkbox|Item::Checkbox>] An array of the initialised checkbox items
6
+ module CCS
7
+ module Components
8
+ module GovUK
9
+ class Field < Base
10
+ class Inputs < Field
11
+ # = GOV.UK Checkboxes
12
+ #
13
+ # This is used for generating the checkboxes component from the
14
+ # {https://design-system.service.gov.uk/components/checkboxes GDS - Components - Checkboxes}
15
+ #
16
+ # @!attribute [r] checkbox_items
17
+ # @return [Array<Item::Divider|Item::Checkbox|Item::Checkbox>] An array of the initialised checkbox items
17
18
 
18
- class Checkboxes < Inputs
19
- private
19
+ class Checkboxes < Inputs
20
+ private
20
21
 
21
- attr_reader :checkbox_items
22
+ attr_reader :checkbox_items
22
23
 
23
- public
24
+ public
24
25
 
25
- # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
26
+ # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
26
27
 
27
- # @param (see CCS::Components::GovUK::Field::Inputs#initialize)
28
- # @param checkbox_items [Array<Hash>] an array of options for the checkboxes.
29
- # See {Components::GovUK::Field::Inputs::Item::Checkbox#initialize Checkbox#initialize} for details of the items in the array.
30
- #
31
- # @option (see CCS::Components::GovUK::Field::Inputs#initialize)
28
+ # @param (see CCS::Components::GovUK::Field::Inputs#initialize)
29
+ # @param checkbox_items [Array<Hash>] an array of options for the checkboxes.
30
+ # See {Components::GovUK::Field::Inputs::Item::Checkbox#initialize Checkbox#initialize} for details of the items in the array.
31
+ #
32
+ # @option (see CCS::Components::GovUK::Field::Inputs#initialize)
32
33
 
33
- def initialize(attribute:, checkbox_items:, **options)
34
- super(attribute: attribute, **options)
34
+ def initialize(attribute:, checkbox_items:, **options)
35
+ super(attribute: attribute, **options)
35
36
 
36
- if @options[:model] || @options[:form]
37
- values = (@options[:model] || @options[:form].object).send(attribute) || []
38
- checkbox_items.each { |checkbox_item| checkbox_item[:checked] = values.include?(checkbox_item[:value]) }
39
- end
37
+ if @options[:model] || @options[:form]
38
+ values = (@options[:model] || @options[:form].object).send(attribute) || []
39
+ checkbox_items.each { |checkbox_item| checkbox_item[:checked] = values.include?(checkbox_item[:value]) }
40
+ end
40
41
 
41
- checkbox_item_class = @options[:form] ? Item::Checkbox::Form : Inputs::Item::Checkbox::Tag
42
+ checkbox_item_class = @options[:form] ? Item::Checkbox::Form : Inputs::Item::Checkbox::Tag
42
43
 
43
- @checkbox_items = checkbox_items.map { |checkbox_item| checkbox_item[:divider] ? Item::Divider.new(divider: checkbox_item[:divider], type: 'checkboxes') : checkbox_item_class.new(attribute: attribute, form: @options[:form], context: @context, **checkbox_item) }
44
- end
44
+ @checkbox_items = checkbox_items.map { |checkbox_item| checkbox_item[:divider] ? Item::Divider.new(divider: checkbox_item[:divider], type: 'checkboxes') : checkbox_item_class.new(attribute: attribute, form: @options[:form], context: @context, **checkbox_item) }
45
+ end
45
46
 
46
- # rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
47
+ # rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
47
48
 
48
- # Generates the HTML for the GOV.UK Checkboxes component
49
- #
50
- # @return [ActiveSupport::SafeBuffer]
49
+ # Generates the HTML for the GOV.UK Checkboxes component
50
+ #
51
+ # @return [ActiveSupport::SafeBuffer]
51
52
 
52
- def render
53
- super() do
54
- tag.div(**options[:attributes]) do
55
- checkbox_items.each { |checkbox_item| concat(checkbox_item.render) }
53
+ def render
54
+ super() do
55
+ tag.div(**options[:attributes]) do
56
+ checkbox_items.each { |checkbox_item| concat(checkbox_item.render) }
57
+ end
56
58
  end
57
59
  end
58
- end
59
60
 
60
- # The default attributes for the checkboxes
61
+ # The default attributes for the checkboxes
61
62
 
62
- DEFAULT_ATTRIBUTES = { class: 'govuk-checkboxes', data: { module: 'govuk-checkboxes' } }.freeze
63
+ DEFAULT_ATTRIBUTES = { class: 'govuk-checkboxes', data: { module: 'govuk-checkboxes' } }.freeze
64
+ end
63
65
  end
64
66
  end
65
67
  end
@@ -1,59 +1,61 @@
1
1
  require_relative '../date_input'
2
2
  require_relative '../../input/text_input'
3
3
 
4
- module CCS::Components
5
- module GovUK
6
- class Field < Base
7
- class Inputs < Field
8
- class DateInput < Inputs
9
- # = GOV.UK Date Inputs item
10
- #
11
- # This is used to generate an individual date input item
12
- #
13
- # @!attribute [r] input
14
- # @return [TextInput] The initialised text input for the date item
15
-
16
- class Item
17
- include ActionView::Context
18
- include ActionView::Helpers
19
-
20
- private
21
-
22
- attr_reader :input
23
-
24
- public
25
-
26
- # rubocop:disable Metrics/ParameterLists
27
-
28
- # @param attribute [String,Symbol] the attribute for the date inputs
29
- # @param name [String] the name of the date input item
30
- # @param input [Hash] options for the input of the date input item, see {CCS::Components::GovUK::Field::Input::TextInput#initialize TextInput#initialize} for more details.
31
- # @param label [Hash] options for the label of the date input item, see {CCS::Components::GovUK::Label#initialize Label#initialize} for more details.
32
- # @param context [ActionView::Base] the view context
4
+ module CCS
5
+ module Components
6
+ module GovUK
7
+ class Field < Base
8
+ class Inputs < Field
9
+ class DateInput < Inputs
10
+ # = GOV.UK Date Inputs item
33
11
  #
34
- # @option options [Hash] error_message used as a flag to add the error classes to the item
35
- # @option options [ActiveModel] :model (nil) optional model used to create the field
36
- # @option options [ActionView::Helpers::FormBuilder] :form (nil) optional form builder used to create the field
12
+ # This is used to generate an individual date input item
13
+ #
14
+ # @!attribute [r] input
15
+ # @return [TextInput] The initialised text input for the date item
37
16
 
38
- def initialize(attribute:, name:, context:, input: {}, label: {}, **options)
39
- input[:classes] = "govuk-date-input__input #{input[:classes]}".rstrip
40
- input[:classes] << ' govuk-input--error' if options[:error_message]
41
- (input[:attributes] ||= {})[:inputmode] ||= 'numeric'
17
+ class Item
18
+ include ActionView::Context
19
+ include ActionView::Helpers
42
20
 
43
- label[:text] ||= name.capitalize
44
- label[:classes] = 'govuk-date-input__label'
21
+ private
45
22
 
46
- @input = Input::TextInput.new(attribute: "#{attribute}_#{name}", label: label, model: options[:model], form: options[:form], context: context, **input)
47
- end
23
+ attr_reader :input
48
24
 
49
- # rubocop:enable Metrics/ParameterLists
25
+ public
50
26
 
51
- # Generates the HTML for the date input item
52
- #
53
- # @return [ActiveSupport::SafeBuffer]
27
+ # rubocop:disable Metrics/ParameterLists
28
+
29
+ # @param attribute [String,Symbol] the attribute for the date inputs
30
+ # @param name [String] the name of the date input item
31
+ # @param input [Hash] options for the input of the date input item, see {CCS::Components::GovUK::Field::Input::TextInput#initialize TextInput#initialize} for more details.
32
+ # @param label [Hash] options for the label of the date input item, see {CCS::Components::GovUK::Label#initialize Label#initialize} for more details.
33
+ # @param context [ActionView::Base] the view context
34
+ #
35
+ # @option options [Hash] error_message used as a flag to add the error classes to the item
36
+ # @option options [ActiveModel] :model (nil) optional model used to create the field
37
+ # @option options [ActionView::Helpers::FormBuilder] :form (nil) optional form builder used to create the field
38
+
39
+ def initialize(attribute:, name:, context:, input: {}, label: {}, **options)
40
+ input[:classes] = "govuk-date-input__input #{input[:classes]}".rstrip
41
+ input[:classes] << ' govuk-input--error' if options[:error_message]
42
+ (input[:attributes] ||= {})[:inputmode] ||= 'numeric'
43
+
44
+ label[:text] ||= name.capitalize
45
+ label[:classes] = 'govuk-date-input__label'
46
+
47
+ @input = Input::TextInput.new(attribute: "#{attribute}_#{name}", label: label, model: options[:model], form: options[:form], context: context, **input)
48
+ end
49
+
50
+ # rubocop:enable Metrics/ParameterLists
51
+
52
+ # Generates the HTML for the date input item
53
+ #
54
+ # @return [ActiveSupport::SafeBuffer]
54
55
 
55
- def render
56
- tag.div(input.render, class: 'govuk-date-input__item')
56
+ def render
57
+ tag.div(input.render, class: 'govuk-date-input__item')
58
+ end
57
59
  end
58
60
  end
59
61
  end
@@ -1,84 +1,86 @@
1
1
  require_relative '../input'
2
2
  require_relative 'date_input/item'
3
3
 
4
- module CCS::Components
5
- module GovUK
6
- class Field < Base
7
- class Inputs < Field
8
- # = GOV.UK Date Input
9
- #
10
- # This is used for generating the date input component from the
11
- # {https://design-system.service.gov.uk/components/date-input GDS - Components - Date Input}
12
- #
13
- # @!attribute [r] date_input_items
14
- # @return [Array<DateInput::Item>] An array of the initialised date input items
15
-
16
- class DateInput < Inputs
17
- private
18
-
19
- attr_reader :date_input_items
20
-
21
- public
22
-
23
- # @param (see CCS::Components::GovUK::Field::Inputs#initialize)
24
- # @param date_items [Array<Hash>] an array of options for the date items.
25
- # See {Components::GovUK::Field::Inputs::DateInput::Item#initialize Item#initialize} for details of the items in the array.
4
+ module CCS
5
+ module Components
6
+ module GovUK
7
+ class Field < Base
8
+ class Inputs < Field
9
+ # = GOV.UK Date Input
26
10
  #
27
- # @option (see CCS::Components::GovUK::Field::Inputs#initialize)
11
+ # This is used for generating the date input component from the
12
+ # {https://design-system.service.gov.uk/components/date-input GDS - Components - Date Input}
13
+ #
14
+ # @!attribute [r] date_input_items
15
+ # @return [Array<DateInput::Item>] An array of the initialised date input items
28
16
 
29
- def initialize(attribute:, date_items: default_date_items, **options)
30
- (options[:fieldset][:attributes] ||= {})[:role] = 'group'
17
+ class DateInput < Inputs
18
+ private
31
19
 
32
- super(attribute: attribute, **options)
20
+ attr_reader :date_input_items
33
21
 
34
- # date_items ||= default_date_items
22
+ public
35
23
 
36
- @date_input_items = date_items.map { |date_input_item| Item.new(attribute: attribute, error_message: @error_message, model: @options[:model], form: @options[:form], context: @context, **date_input_item) }
37
- end
24
+ # @param (see CCS::Components::GovUK::Field::Inputs#initialize)
25
+ # @param date_items [Array<Hash>] an array of options for the date items.
26
+ # See {Components::GovUK::Field::Inputs::DateInput::Item#initialize Item#initialize} for details of the items in the array.
27
+ #
28
+ # @option (see CCS::Components::GovUK::Field::Inputs#initialize)
38
29
 
39
- # Generates the HTML for the GOV.UK date input component
40
- #
41
- # @return [ActiveSupport::SafeBuffer]
30
+ def initialize(attribute:, date_items: default_date_items, **options)
31
+ (options[:fieldset][:attributes] ||= {})[:role] = 'group'
42
32
 
43
- def render
44
- super() do
45
- tag.div(**options[:attributes]) do
46
- date_input_items.each { |date_input_item| concat(date_input_item.render) }
47
- end
48
- end
49
- end
33
+ super(attribute: attribute, **options)
34
+
35
+ # date_items ||= default_date_items
50
36
 
51
- # The default attributes for the date input
37
+ @date_input_items = date_items.map { |date_input_item| Item.new(attribute: attribute, error_message: @error_message, model: @options[:model], form: @options[:form], context: @context, **date_input_item) }
38
+ end
52
39
 
53
- DEFAULT_ATTRIBUTES = { class: 'govuk-date-input' }.freeze
40
+ # Generates the HTML for the GOV.UK date input component
41
+ #
42
+ # @return [ActiveSupport::SafeBuffer]
54
43
 
55
- private
44
+ def render
45
+ super() do
46
+ tag.div(**options[:attributes]) do
47
+ date_input_items.each { |date_input_item| concat(date_input_item.render) }
48
+ end
49
+ end
50
+ end
56
51
 
57
- # The default date items used if no date items are provided
58
- #
59
- # @return [Array<Hash>]
60
-
61
- def default_date_items
62
- [
63
- {
64
- name: 'day',
65
- input: {
66
- classes: 'govuk-input--width-2'
52
+ # The default attributes for the date input
53
+
54
+ DEFAULT_ATTRIBUTES = { class: 'govuk-date-input' }.freeze
55
+
56
+ private
57
+
58
+ # The default date items used if no date items are provided
59
+ #
60
+ # @return [Array<Hash>]
61
+
62
+ def default_date_items
63
+ [
64
+ {
65
+ name: 'day',
66
+ input: {
67
+ classes: 'govuk-input--width-2'
68
+ }
69
+ },
70
+ {
71
+ name: 'month',
72
+ input: {
73
+ classes: 'govuk-input--width-2'
74
+ }
75
+ },
76
+ {
77
+ name: 'year',
78
+ input: {
79
+ classes: 'govuk-input--width-4'
80
+ }
67
81
  }
68
- },
69
- {
70
- name: 'month',
71
- input: {
72
- classes: 'govuk-input--width-2'
73
- }
74
- },
75
- {
76
- name: 'year',
77
- input: {
78
- classes: 'govuk-input--width-4'
79
- }
80
- }
81
- ]
82
+ ]
83
+ end
82
84
  end
83
85
  end
84
86
  end
@@ -1,39 +1,41 @@
1
1
  require_relative '../checkbox'
2
2
 
3
- module CCS::Components
4
- module GovUK
5
- class Field < Base
6
- class Inputs < Field
7
- class Item < Base
8
- class Checkbox < Item
9
- # = GOV.UK Field Inputs Checkbox form tag
10
- #
11
- # This is used to generate an individual checkbox item using +form.check_box+
12
-
13
- class Form < Checkbox
14
- # @param (see CCS::Components::GovUK::Field::Items::Item::Checkbox#initialize)
3
+ module CCS
4
+ module Components
5
+ module GovUK
6
+ class Field < Base
7
+ class Inputs < Field
8
+ class Item < Base
9
+ class Checkbox < Item
10
+ # = GOV.UK Field Inputs Checkbox form tag
15
11
  #
16
- # @option (see CCS::Components::GovUK::Field::Items::Item::Checkbox#initialize)
12
+ # This is used to generate an individual checkbox item using +form.check_box+
17
13
 
18
- def initialize(attribute:, label:, **options)
19
- super(attribute: attribute, label: label, **options)
14
+ class Form < Checkbox
15
+ # @param (see CCS::Components::GovUK::Field::Items::Item::Checkbox#initialize)
16
+ #
17
+ # @option (see CCS::Components::GovUK::Field::Items::Item::Checkbox#initialize)
20
18
 
21
- (label[:attributes] ||= {})[:value] = @value
22
- label[:attributes][:for] = @options[:attributes][:id] if @options[:attributes][:id]
19
+ def initialize(attribute:, label:, **options)
20
+ super(attribute: attribute, label: label, **options)
23
21
 
24
- @options[:attributes][:multiple] = true
25
- @options[:attributes][:include_hidden] = false
22
+ (label[:attributes] ||= {})[:value] = @value
23
+ label[:attributes][:for] = @options[:attributes][:id] if @options[:attributes][:id]
26
24
 
27
- @label = Label.new(attribute: attribute, form: @options[:form], context: @context, **label)
28
- end
25
+ @options[:attributes][:multiple] = true
26
+ @options[:attributes][:include_hidden] = false
29
27
 
30
- # Generates the HTML for the checkbox input
31
- #
32
- # @return [ActiveSupport::SafeBuffer]
28
+ @label = Label.new(attribute: attribute, form: @options[:form], context: @context, **label)
29
+ end
30
+
31
+ # Generates the HTML for the checkbox input
32
+ #
33
+ # @return [ActiveSupport::SafeBuffer]
33
34
 
34
- def render
35
- super() do
36
- @options[:form].check_box(@attribute, @options[:attributes], @value)
35
+ def render
36
+ super() do
37
+ @options[:form].check_box(@attribute, @options[:attributes], @value)
38
+ end
37
39
  end
38
40
  end
39
41
  end
@@ -1,35 +1,37 @@
1
1
  require_relative '../checkbox'
2
2
 
3
- module CCS::Components
4
- module GovUK
5
- class Field < Base
6
- class Inputs < Field
7
- class Item < Base
8
- class Checkbox < Item
9
- # = GOV.UK Field Inputs Checkbox tag
10
- #
11
- # This is used to generate an individual checkbox item using +check_box_tag+
12
-
13
- class Tag < Checkbox
14
- # @param (see CCS::Components::GovUK::Field::Items::Item::Checkbox#initialize)
3
+ module CCS
4
+ module Components
5
+ module GovUK
6
+ class Field < Base
7
+ class Inputs < Field
8
+ class Item < Base
9
+ class Checkbox < Item
10
+ # = GOV.UK Field Inputs Checkbox tag
15
11
  #
16
- # @option (see CCS::Components::GovUK::Field::Items::Item::Checkbox#initialize)
12
+ # This is used to generate an individual checkbox item using +check_box_tag+
17
13
 
18
- def initialize(attribute:, label:, **options)
19
- super(attribute: attribute, label: label, **options)
14
+ class Tag < Checkbox
15
+ # @param (see CCS::Components::GovUK::Field::Items::Item::Checkbox#initialize)
16
+ #
17
+ # @option (see CCS::Components::GovUK::Field::Items::Item::Checkbox#initialize)
20
18
 
21
- @options[:attributes][:id] ||= "#{sanitize_to_id(@attribute)}_#{sanitize_to_id(@value)}"
19
+ def initialize(attribute:, label:, **options)
20
+ super(attribute: attribute, label: label, **options)
22
21
 
23
- @label = Label.new(attribute: @options[:attributes][:id], context: @context, **label)
24
- end
22
+ @options[:attributes][:id] ||= "#{sanitize_to_id(@attribute)}_#{sanitize_to_id(@value)}"
25
23
 
26
- # Generates the HTML for the checkbox input
27
- #
28
- # @return [ActiveSupport::SafeBuffer]
24
+ @label = Label.new(attribute: @options[:attributes][:id], context: @context, **label)
25
+ end
26
+
27
+ # Generates the HTML for the checkbox input
28
+ #
29
+ # @return [ActiveSupport::SafeBuffer]
29
30
 
30
- def render
31
- super() do
32
- context.check_box_tag("#{@attribute}[]", @value, @options[:checked], **@options[:attributes])
31
+ def render
32
+ super() do
33
+ context.check_box_tag("#{@attribute}[]", @value, @options[:checked], **@options[:attributes])
34
+ end
33
35
  end
34
36
  end
35
37
  end
@@ -1,45 +1,47 @@
1
1
  require_relative '../item'
2
2
 
3
- module CCS::Components
4
- module GovUK
5
- class Field < Base
6
- class Inputs < Field
7
- class Item < Base
8
- # = GOV.UK Field Inputs Checkbox
9
- #
10
- # This is used to generate an individual checkbox item
11
-
12
- class Checkbox < Item
13
- # @param (see CCS::Components::GovUK::Field::Items::Item#initialize)
14
- # label [Hash] attributes for the checkbox label, see {CCS::Components::GovUK::Label#initialize Label#initialize} for more details.
3
+ module CCS
4
+ module Components
5
+ module GovUK
6
+ class Field < Base
7
+ class Inputs < Field
8
+ class Item < Base
9
+ # = GOV.UK Field Inputs Checkbox
15
10
  #
16
- # @option (see CCS::Components::GovUK::Field::Items::Item#initialize))
11
+ # This is used to generate an individual checkbox item
17
12
 
18
- def initialize(attribute:, label:, **options)
19
- super(attribute: attribute, **options)
13
+ class Checkbox < Item
14
+ # @param (see CCS::Components::GovUK::Field::Items::Item#initialize)
15
+ # label [Hash] attributes for the checkbox label, see {CCS::Components::GovUK::Label#initialize Label#initialize} for more details.
16
+ #
17
+ # @option (see CCS::Components::GovUK::Field::Items::Item#initialize))
20
18
 
21
- label[:classes] = "govuk-checkboxes__label #{label[:classes]}".rstrip
22
- end
19
+ def initialize(attribute:, label:, **options)
20
+ super(attribute: attribute, **options)
23
21
 
24
- # Generates the HTML to wrap arround a checkbox input
25
- #
26
- # @yield the checkbox item input HTML
27
- #
28
- # @return [ActiveSupport::SafeBuffer]
22
+ label[:classes] = "govuk-checkboxes__label #{label[:classes]}".rstrip
23
+ end
29
24
 
30
- def render(&block)
31
- tag.div(class: 'govuk-checkboxes__item') do
32
- super(&block)
25
+ # Generates the HTML to wrap arround a checkbox input
26
+ #
27
+ # @yield the checkbox item input HTML
28
+ #
29
+ # @return [ActiveSupport::SafeBuffer]
30
+
31
+ def render(&block)
32
+ tag.div(class: 'govuk-checkboxes__item') do
33
+ super(&block)
34
+ end
33
35
  end
34
- end
35
36
 
36
- # The default attributes for the checkbox
37
+ # The default attributes for the checkbox
37
38
 
38
- DEFAULT_ATTRIBUTES = { class: 'govuk-checkboxes__input' }.freeze
39
+ DEFAULT_ATTRIBUTES = { class: 'govuk-checkboxes__input' }.freeze
39
40
 
40
- # The type of the input item
41
+ # The type of the input item
41
42
 
42
- ITEM_TYPE = 'checkboxes'.freeze
43
+ ITEM_TYPE = 'checkboxes'.freeze
44
+ end
43
45
  end
44
46
  end
45
47
  end