ccs-frontend_helpers 0.1.0.rc.6 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (156) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -5
  3. data/CHANGELOG.md +1 -4
  4. data/Gemfile.lock +77 -75
  5. data/ccs-frontend_helpers.gemspec +1 -1
  6. data/lib/ccs/frontend_helpers/ccs_frontend/dashboard_panels.rb +79 -0
  7. data/lib/ccs/frontend_helpers/ccs_frontend/footer.rb +119 -6
  8. data/lib/ccs/frontend_helpers/ccs_frontend/header.rb +183 -6
  9. data/lib/ccs/{components/ccs → frontend_helpers/ccs_frontend}/logo.rb +12 -10
  10. data/lib/ccs/frontend_helpers/ccs_frontend.rb +4 -2
  11. data/lib/ccs/frontend_helpers/govuk_frontend/accordion.rb +95 -8
  12. data/lib/ccs/frontend_helpers/govuk_frontend/back_link.rb +17 -6
  13. data/lib/ccs/frontend_helpers/govuk_frontend/breadcrumbs.rb +54 -6
  14. data/lib/ccs/frontend_helpers/govuk_frontend/button.rb +105 -6
  15. data/lib/ccs/frontend_helpers/govuk_frontend/cookie_banner.rb +114 -6
  16. data/lib/ccs/frontend_helpers/govuk_frontend/details.rb +23 -7
  17. data/lib/ccs/frontend_helpers/govuk_frontend/error_message.rb +32 -11
  18. data/lib/ccs/frontend_helpers/govuk_frontend/error_summary.rb +65 -13
  19. data/lib/ccs/frontend_helpers/govuk_frontend/field/character_count.rb +165 -0
  20. data/lib/ccs/frontend_helpers/govuk_frontend/field/checkboxes.rb +200 -0
  21. data/lib/ccs/frontend_helpers/govuk_frontend/field/date_input.rb +153 -0
  22. data/lib/ccs/frontend_helpers/govuk_frontend/field/file_upload.rb +83 -0
  23. data/lib/ccs/frontend_helpers/govuk_frontend/field/input.rb +153 -0
  24. data/lib/ccs/frontend_helpers/govuk_frontend/field/radios.rb +201 -0
  25. data/lib/ccs/frontend_helpers/govuk_frontend/field/select.rb +124 -0
  26. data/lib/ccs/frontend_helpers/govuk_frontend/field/textarea.rb +106 -0
  27. data/lib/ccs/frontend_helpers/govuk_frontend/field.rb +213 -0
  28. data/lib/ccs/frontend_helpers/govuk_frontend/fieldset.rb +48 -7
  29. data/lib/ccs/frontend_helpers/govuk_frontend/footer.rb +161 -6
  30. data/lib/ccs/frontend_helpers/govuk_frontend/form_group.rb +24 -13
  31. data/lib/ccs/frontend_helpers/govuk_frontend/header.rb +139 -6
  32. data/lib/ccs/frontend_helpers/govuk_frontend/hint.rb +17 -8
  33. data/lib/ccs/frontend_helpers/govuk_frontend/inset_text.rb +21 -7
  34. data/lib/ccs/frontend_helpers/govuk_frontend/label.rb +70 -7
  35. data/lib/ccs/frontend_helpers/govuk_frontend/notification_banner.rb +113 -7
  36. data/lib/ccs/frontend_helpers/govuk_frontend/pagination.rb +314 -6
  37. data/lib/ccs/frontend_helpers/govuk_frontend/panel.rb +28 -7
  38. data/lib/ccs/frontend_helpers/govuk_frontend/phase_banner.rb +27 -8
  39. data/lib/ccs/frontend_helpers/govuk_frontend/skip_link.rb +18 -6
  40. data/lib/ccs/frontend_helpers/govuk_frontend/step_by_step_navigation.rb +186 -7
  41. data/lib/ccs/frontend_helpers/govuk_frontend/summary_list.rb +204 -6
  42. data/lib/ccs/frontend_helpers/govuk_frontend/table.rb +102 -6
  43. data/lib/ccs/frontend_helpers/govuk_frontend/tabs.rb +73 -6
  44. data/lib/ccs/frontend_helpers/govuk_frontend/tag.rb +21 -7
  45. data/lib/ccs/frontend_helpers/govuk_frontend/warning_text.rb +30 -7
  46. data/lib/ccs/frontend_helpers/govuk_frontend.rb +19 -17
  47. data/lib/ccs/frontend_helpers/shared_methods.rb +27 -0
  48. data/lib/ccs/frontend_helpers/version.rb +1 -1
  49. metadata +18 -114
  50. data/.ruby-version +0 -1
  51. data/lib/ccs/components/base.rb +0 -64
  52. data/lib/ccs/components/ccs/dashboard_section/panel.rb +0 -57
  53. data/lib/ccs/components/ccs/dashboard_section.rb +0 -71
  54. data/lib/ccs/components/ccs/footer/link.rb +0 -55
  55. data/lib/ccs/components/ccs/footer/meta.rb +0 -59
  56. data/lib/ccs/components/ccs/footer/navigation.rb +0 -60
  57. data/lib/ccs/components/ccs/footer.rb +0 -95
  58. data/lib/ccs/components/ccs/header/link.rb +0 -60
  59. data/lib/ccs/components/ccs/header/navigation.rb +0 -98
  60. data/lib/ccs/components/ccs/header/service_authentication.rb +0 -53
  61. data/lib/ccs/components/ccs/header.rb +0 -110
  62. data/lib/ccs/components/govuk/accordion/section/content.rb +0 -53
  63. data/lib/ccs/components/govuk/accordion/section/header.rb +0 -57
  64. data/lib/ccs/components/govuk/accordion/section.rb +0 -61
  65. data/lib/ccs/components/govuk/accordion.rb +0 -58
  66. data/lib/ccs/components/govuk/back_link.rb +0 -51
  67. data/lib/ccs/components/govuk/breadcrumbs/link.rb +0 -57
  68. data/lib/ccs/components/govuk/breadcrumbs.rb +0 -55
  69. data/lib/ccs/components/govuk/button.rb +0 -107
  70. data/lib/ccs/components/govuk/cookie_banner/action.rb +0 -60
  71. data/lib/ccs/components/govuk/cookie_banner/message.rb +0 -80
  72. data/lib/ccs/components/govuk/cookie_banner.rb +0 -55
  73. data/lib/ccs/components/govuk/details.rb +0 -53
  74. data/lib/ccs/components/govuk/error_message.rb +0 -60
  75. data/lib/ccs/components/govuk/error_summary/item.rb +0 -54
  76. data/lib/ccs/components/govuk/error_summary.rb +0 -70
  77. data/lib/ccs/components/govuk/field/input/character_count.rb +0 -129
  78. data/lib/ccs/components/govuk/field/input/file_upload.rb +0 -44
  79. data/lib/ccs/components/govuk/field/input/select.rb +0 -82
  80. data/lib/ccs/components/govuk/field/input/text_input/fix.rb +0 -55
  81. data/lib/ccs/components/govuk/field/input/text_input.rb +0 -97
  82. data/lib/ccs/components/govuk/field/input/textarea.rb +0 -59
  83. data/lib/ccs/components/govuk/field/input.rb +0 -62
  84. data/lib/ccs/components/govuk/field/inputs/checkboxes.rb +0 -69
  85. data/lib/ccs/components/govuk/field/inputs/date_input/item.rb +0 -65
  86. data/lib/ccs/components/govuk/field/inputs/date_input.rb +0 -89
  87. data/lib/ccs/components/govuk/field/inputs/item/checkbox/form.rb +0 -47
  88. data/lib/ccs/components/govuk/field/inputs/item/checkbox/tag.rb +0 -43
  89. data/lib/ccs/components/govuk/field/inputs/item/checkbox.rb +0 -50
  90. data/lib/ccs/components/govuk/field/inputs/item/divider.rb +0 -50
  91. data/lib/ccs/components/govuk/field/inputs/item/radio/form.rb +0 -44
  92. data/lib/ccs/components/govuk/field/inputs/item/radio/tag.rb +0 -43
  93. data/lib/ccs/components/govuk/field/inputs/item/radio.rb +0 -50
  94. data/lib/ccs/components/govuk/field/inputs/item.rb +0 -111
  95. data/lib/ccs/components/govuk/field/inputs/radios.rb +0 -69
  96. data/lib/ccs/components/govuk/field/inputs.rb +0 -57
  97. data/lib/ccs/components/govuk/field.rb +0 -108
  98. data/lib/ccs/components/govuk/fieldset/legend.rb +0 -65
  99. data/lib/ccs/components/govuk/fieldset.rb +0 -54
  100. data/lib/ccs/components/govuk/footer/link.rb +0 -55
  101. data/lib/ccs/components/govuk/footer/meta.rb +0 -59
  102. data/lib/ccs/components/govuk/footer/navigation.rb +0 -60
  103. data/lib/ccs/components/govuk/footer.rb +0 -131
  104. data/lib/ccs/components/govuk/form_group.rb +0 -60
  105. data/lib/ccs/components/govuk/header/link.rb +0 -56
  106. data/lib/ccs/components/govuk/header/navigation.rb +0 -71
  107. data/lib/ccs/components/govuk/header.rb +0 -107
  108. data/lib/ccs/components/govuk/hint.rb +0 -49
  109. data/lib/ccs/components/govuk/inset_text.rb +0 -52
  110. data/lib/ccs/components/govuk/label.rb +0 -85
  111. data/lib/ccs/components/govuk/notification_banner.rb +0 -107
  112. data/lib/ccs/components/govuk/pagination/increment/next.rb +0 -44
  113. data/lib/ccs/components/govuk/pagination/increment/previous.rb +0 -43
  114. data/lib/ccs/components/govuk/pagination/increment.rb +0 -98
  115. data/lib/ccs/components/govuk/pagination/item/ellipsis.rb +0 -28
  116. data/lib/ccs/components/govuk/pagination/item/form.rb +0 -49
  117. data/lib/ccs/components/govuk/pagination/item/tag.rb +0 -47
  118. data/lib/ccs/components/govuk/pagination/item.rb +0 -64
  119. data/lib/ccs/components/govuk/pagination.rb +0 -96
  120. data/lib/ccs/components/govuk/panel.rb +0 -62
  121. data/lib/ccs/components/govuk/phase_banner.rb +0 -69
  122. data/lib/ccs/components/govuk/skip_link.rb +0 -51
  123. data/lib/ccs/components/govuk/step_by_step_navigation/section/content/list/item.rb +0 -53
  124. data/lib/ccs/components/govuk/step_by_step_navigation/section/content/list.rb +0 -50
  125. data/lib/ccs/components/govuk/step_by_step_navigation/section/content/paragraph.rb +0 -45
  126. data/lib/ccs/components/govuk/step_by_step_navigation/section/content.rb +0 -63
  127. data/lib/ccs/components/govuk/step_by_step_navigation/section/heading.rb +0 -69
  128. data/lib/ccs/components/govuk/step_by_step_navigation/section.rb +0 -56
  129. data/lib/ccs/components/govuk/step_by_step_navigation.rb +0 -59
  130. data/lib/ccs/components/govuk/summary_list/action/link.rb +0 -59
  131. data/lib/ccs/components/govuk/summary_list/card/actions.rb +0 -59
  132. data/lib/ccs/components/govuk/summary_list/card/title.rb +0 -51
  133. data/lib/ccs/components/govuk/summary_list/card.rb +0 -63
  134. data/lib/ccs/components/govuk/summary_list/row/actions.rb +0 -59
  135. data/lib/ccs/components/govuk/summary_list/row/key.rb +0 -47
  136. data/lib/ccs/components/govuk/summary_list/row/value.rb +0 -47
  137. data/lib/ccs/components/govuk/summary_list/row.rb +0 -67
  138. data/lib/ccs/components/govuk/summary_list.rb +0 -74
  139. data/lib/ccs/components/govuk/table/body/data_cell.rb +0 -53
  140. data/lib/ccs/components/govuk/table/body/head_cell.rb +0 -52
  141. data/lib/ccs/components/govuk/table/header/head_cell.rb +0 -54
  142. data/lib/ccs/components/govuk/table.rb +0 -111
  143. data/lib/ccs/components/govuk/tabs/panel.rb +0 -58
  144. data/lib/ccs/components/govuk/tabs/tab.rb +0 -56
  145. data/lib/ccs/components/govuk/tabs.rb +0 -66
  146. data/lib/ccs/components/govuk/tag.rb +0 -51
  147. data/lib/ccs/components/govuk/warning_text.rb +0 -61
  148. data/lib/ccs/frontend_helpers/ccs_frontend/dashboard_section.rb +0 -27
  149. data/lib/ccs/frontend_helpers/govuk_frontend/character_count.rb +0 -28
  150. data/lib/ccs/frontend_helpers/govuk_frontend/checkboxes.rb +0 -28
  151. data/lib/ccs/frontend_helpers/govuk_frontend/date_input.rb +0 -28
  152. data/lib/ccs/frontend_helpers/govuk_frontend/file_upload.rb +0 -28
  153. data/lib/ccs/frontend_helpers/govuk_frontend/input.rb +0 -28
  154. data/lib/ccs/frontend_helpers/govuk_frontend/radios.rb +0 -28
  155. data/lib/ccs/frontend_helpers/govuk_frontend/select.rb +0 -28
  156. data/lib/ccs/frontend_helpers/govuk_frontend/textarea.rb +0 -28
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative '../../components/govuk/tabs'
3
+ require 'action_view'
4
+
5
+ require_relative '../shared_methods'
4
6
 
5
7
  module CCS
6
8
  module FrontendHelpers
@@ -11,16 +13,81 @@ module CCS
11
13
  # {https://design-system.service.gov.uk/components/tabs GDS - Components - Tabs}
12
14
 
13
15
  module Tabs
16
+ include SharedMethods
17
+ include ActionView::Context
18
+ include ActionView::Helpers::FormTagHelper
19
+ include ActionView::Helpers::TagHelper
20
+ include ActionView::Helpers::TextHelper
21
+ include ActionView::Helpers::UrlHelper
22
+
14
23
  # Generates the HTML for the GOV.UK Tabs component
15
24
  #
16
- # @param (see CCS::Components::GovUK::Tabs#initialize)
25
+ # @param items [Array] array of tab items. See {govuk_tabs_list_item}
26
+ # @param title [NilClass,String] title for the tabs table of contents
27
+ # @param govuk_tabs_options [Hash] options that will be used in customising the HTML
28
+ #
29
+ # @option govuk_tabs_options [String] :classes additional CSS classes for the tabs HTML
30
+ # @option govuk_tabs_options [String] :id_prefix prefix id for each tab item if no id is specified on each item
31
+ # @option govuk_tabs_options [Hash] :attributes ({}) any additional attributes that will be added as part of the HTML
32
+ #
33
+ # @return [ActiveSupport::SafeBuffer] the HTML for the GOV.UK Tabs
34
+ # which can then be rendered on the page
35
+
36
+ def govuk_tabs(items, title = 'Contents', **govuk_tabs_options)
37
+ initialise_attributes_and_set_classes(govuk_tabs_options, 'govuk-tabs')
38
+ set_data_module(govuk_tabs_options, 'govuk-tabs')
39
+
40
+ id_prefix = govuk_tabs_options[:id_prefix] || sanitize_to_id(title.downcase)
41
+
42
+ tag.div(**govuk_tabs_options[:attributes]) do
43
+ concat(tag.h2(title, class: 'govuk-tabs__title'))
44
+ concat(tag.ul(class: 'govuk-tabs__lis') do
45
+ items.each.with_index(1) { |list_item, index| concat(govuk_tabs_list_item(list_item, index, id_prefix)) }
46
+ end)
47
+ items.each.with_index(1) { |panel_item, index| concat(govuk_tabs_panel_item(panel_item[:panel], index)) }
48
+ end
49
+ end
50
+
51
+ private
52
+
53
+ # Generates the HTML for a tab list item used in {govuk_tabs}
17
54
  #
18
- # @option (see CCS::Components::GovUK::Tabs#initialize)
55
+ # @param list_item [Hash] options used to form the tab
56
+ # @param index [Integer] the index of the tab
57
+ # @param id_prefix [String] prefix id for a tab item if no id is specified
19
58
  #
20
- # @return (see CCS::Components::GovUK::Tabs#render)
59
+ # @option list_item [String] :label the text label of a tab item
60
+ # @option list_item [Hash] :panel content for panel. See {govuk_tabs_panel_item}
61
+ # @option list_item [Hash] :attributes ({}) any additional attributes that will be added as part of the tab link HTML
62
+ #
63
+ # @return [ActiveSupport::SafeBuffer] the HTML for a tab list item used in {govuk_tabs}
64
+
65
+ def govuk_tabs_list_item(list_item, index, id_prefix)
66
+ (list_item[:attributes] ||= {})[:class] = 'govuk-tabs__tab'
67
+ (list_item[:panel][:attributes] ||= {})[:id] ||= "#{id_prefix}-#{index}"
68
+
69
+ tag.li(class: "govuk-tabs__list-item #{'govuk-tabs__list-item--selected' if index == 1}".rstrip) do
70
+ link_to(list_item[:label], "##{list_item[:panel][:attributes][:id]}", **list_item[:attributes])
71
+ end
72
+ end
73
+
74
+ # Generates the HTML for a tab panel used in {govuk_tabs}
75
+ #
76
+ # @param panel_item [Hash] options used to form the tab panel
77
+ # @param index [Integer] the index of the tab
78
+ #
79
+ # @option panel_item [ActiveSupport::SafeBuffer] :content HTML to use within the each tab panel
80
+ # @option panel_item [String] :text if +:content+ is blank then this is the text within the panel
81
+ # @option panel_item [Hash] :attributes ({}) any additional attributes that will be added as part of the tab panel HTML
82
+ #
83
+ # @return [ActiveSupport::SafeBuffer] the HTML for a tab panel used in {govuk_tabs}
84
+
85
+ def govuk_tabs_panel_item(panel_item, index)
86
+ panel_item[:attributes][:class] = "govuk-tabs__panel #{'govuk-tabs__panel--hidden' if index > 1}".rstrip
21
87
 
22
- def govuk_tabs(items, title = nil, **options)
23
- Components::GovUK::Tabs.new(context: self, items: items, title: title, **options).render
88
+ tag.div(**panel_item[:attributes]) do
89
+ panel_item[:content] || tag.p(panel_item[:text], class: 'govuk-body')
90
+ end
24
91
  end
25
92
  end
26
93
  end
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative '../../components/govuk/tag'
3
+ require 'action_view'
4
+
5
+ require_relative '../shared_methods'
4
6
 
5
7
  module CCS
6
8
  module FrontendHelpers
@@ -11,16 +13,28 @@ module CCS
11
13
  # {https://design-system.service.gov.uk/components/tag GDS - Components - Tag}
12
14
 
13
15
  module Tag
14
- # Generates the HTML for the GOV.UK Back link component
16
+ include SharedMethods
17
+ include ActionView::Context
18
+ include ActionView::Helpers::TagHelper
19
+
20
+ # Generates the HTML for the GOV.UK Tag component
15
21
  #
16
- # @param (see CCS::Components::GovUK::Tag#initialize)
22
+ # @param text [String] the text for the tag
23
+ # @param colour [String] optional colour for the tag,
24
+ # see {https://design-system.service.gov.uk/components/tag/#additional-colours Tag - Additional colours}
25
+ # for available colours in GOV.UK Frontend
26
+ # @param govuk_tag_options [Hash] options that will be used in customising the HTML
17
27
  #
18
- # @option (see CCS::Components::GovUK::Tag#initialize)
28
+ # @option govuk_tag_options [String] :classes additional CSS classes for the tag HTML
29
+ # @option govuk_tag_options [Hash] :attributes ({}) any additional attributes that will added as part of the HTML
19
30
  #
20
- # @return (see CCS::Components::GovUK::Tag#render)
31
+ # @return [ActiveSupport::SafeBuffer] the HTML for the GOV.UK Tag
32
+ # which can then be rendered on the page
33
+
34
+ def govuk_tag(text, colour = nil, **govuk_tag_options)
35
+ initialise_attributes_and_set_classes(govuk_tag_options, "govuk-tag #{"govuk-tag--#{colour}" if colour}".rstrip)
21
36
 
22
- def govuk_tag(text, colour = nil, **options)
23
- Components::GovUK::Tag.new(context: self, text: text, colour: colour, **options).render
37
+ tag.strong(text, **govuk_tag_options[:attributes])
24
38
  end
25
39
  end
26
40
  end
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative '../../components/govuk/warning_text'
3
+ require 'action_view'
4
+
5
+ require_relative '../shared_methods'
4
6
 
5
7
  module CCS
6
8
  module FrontendHelpers
@@ -11,18 +13,39 @@ module CCS
11
13
  # {https://design-system.service.gov.uk/components/warning-text GDS - Components - Warning text}
12
14
 
13
15
  module WarningText
16
+ include SharedMethods
17
+ include ActionView::Context
18
+ include ActionView::Helpers::TagHelper
19
+ include ActionView::Helpers::TextHelper
20
+
14
21
  # Generates the HTML for the GOV.UK Warning text component
15
22
  #
16
- # @param (see CCS::Components::GovUK::WarningText#initialize)
23
+ # @param text [String] (nil) the text for the warning
24
+ # @param govuk_warning_text_options [Hash] options that will be used in customising the HTML
17
25
  #
18
- # @option (see CCS::Components::GovUK::WarningText#initialize)
26
+ # @option govuk_warning_text_options [String] :classes additional CSS classes for the tag HTML
27
+ # @option govuk_warning_text_options [String] :icon_fallback_text the fallback text for the icon (default: +'Warning'+)
28
+ # @option govuk_warning_text_options [Hash] :attributes ({}) any additional attributes that will added as part of the HTML
19
29
  #
20
- # @yield (see CCS::Components::GovUK::WarningText#render)
30
+ # @yield HTML that will be used in the warning text. Ignored if text is passed.
21
31
  #
22
- # @return (see CCS::Components::GovUK::WarningText#render)
32
+ # @return [ActiveSupport::SafeBuffer] the HTML for the GOV.UK Warning text
33
+ # which can then be rendered on the page
34
+
35
+ def govuk_warning_text(text = nil, **govuk_warning_text_options)
36
+ initialise_attributes_and_set_classes(govuk_warning_text_options, 'govuk-warning-text')
23
37
 
24
- def govuk_warning_text(text = nil, **options, &block)
25
- Components::GovUK::WarningText.new(context: self, text: text, **options).render(&block)
38
+ tag.div(**govuk_warning_text_options[:attributes]) do
39
+ concat(tag.span('!', class: 'govuk-warning-text__icon'))
40
+ concat(tag.strong(class: 'govuk-warning-text__text') do
41
+ concat(tag.span(govuk_warning_text_options[:icon_fallback_text] || 'Warning', class: 'govuk-warning-text__assistive'))
42
+ if text
43
+ concat(text)
44
+ else
45
+ yield
46
+ end
47
+ end)
48
+ end
26
49
  end
27
50
  end
28
51
  end
@@ -4,76 +4,78 @@ require_relative 'govuk_frontend/accordion'
4
4
  require_relative 'govuk_frontend/back_link'
5
5
  require_relative 'govuk_frontend/breadcrumbs'
6
6
  require_relative 'govuk_frontend/button'
7
- require_relative 'govuk_frontend/character_count'
8
- require_relative 'govuk_frontend/checkboxes'
9
7
  require_relative 'govuk_frontend/cookie_banner'
10
- require_relative 'govuk_frontend/date_input'
11
8
  require_relative 'govuk_frontend/details'
12
9
  require_relative 'govuk_frontend/error_message'
13
10
  require_relative 'govuk_frontend/error_summary'
11
+ require_relative 'govuk_frontend/field'
12
+ require_relative 'govuk_frontend/field/character_count'
13
+ require_relative 'govuk_frontend/field/checkboxes'
14
+ require_relative 'govuk_frontend/field/date_input'
15
+ require_relative 'govuk_frontend/field/file_upload'
16
+ require_relative 'govuk_frontend/field/input'
17
+ require_relative 'govuk_frontend/field/select'
18
+ require_relative 'govuk_frontend/field/textarea'
19
+ require_relative 'govuk_frontend/field/radios'
14
20
  require_relative 'govuk_frontend/fieldset'
15
- require_relative 'govuk_frontend/file_upload'
16
21
  require_relative 'govuk_frontend/footer'
17
22
  require_relative 'govuk_frontend/form_group'
18
23
  require_relative 'govuk_frontend/header'
19
24
  require_relative 'govuk_frontend/hint'
20
- require_relative 'govuk_frontend/input'
21
25
  require_relative 'govuk_frontend/inset_text'
22
26
  require_relative 'govuk_frontend/label'
23
27
  require_relative 'govuk_frontend/notification_banner'
24
28
  require_relative 'govuk_frontend/pagination'
25
29
  require_relative 'govuk_frontend/panel'
26
30
  require_relative 'govuk_frontend/phase_banner'
27
- require_relative 'govuk_frontend/radios'
28
- require_relative 'govuk_frontend/select'
29
31
  require_relative 'govuk_frontend/skip_link'
30
32
  require_relative 'govuk_frontend/step_by_step_navigation'
31
33
  require_relative 'govuk_frontend/summary_list'
32
34
  require_relative 'govuk_frontend/table'
33
35
  require_relative 'govuk_frontend/tabs'
34
36
  require_relative 'govuk_frontend/tag'
35
- require_relative 'govuk_frontend/textarea'
36
37
  require_relative 'govuk_frontend/warning_text'
37
38
 
38
39
  module CCS
39
40
  module FrontendHelpers
40
41
  # This module loads in all the GOV.UK Frontend Helper methods.
41
- # These are a collection of view to help render GOV.UK components
42
+ # These are a collection of view helpers to help render GOV.UK components
42
43
 
43
44
  module GovUKFrontend
44
45
  include Accordion
45
46
  include BackLink
46
47
  include Breadcrumbs
47
48
  include Button
48
- include CharacterCount
49
- include Checkboxes
50
49
  include CookieBanner
51
- include DateInput
52
50
  include Details
53
51
  include ErrorMessage
54
52
  include ErrorSummary
55
- include FileUpload
53
+ include Field
54
+ include Field::CharacterCount
55
+ include Field::Checkboxes
56
+ include Field::DateInput
57
+ include Field::FileUpload
58
+ include Field::Input
59
+ include Field::Radios
60
+ include Field::Select
61
+ include Field::Textarea
56
62
  include Fieldset
57
63
  include Footer
58
64
  include FormGroup
59
65
  include Header
60
66
  include Hint
61
- include Input
62
67
  include InsetText
63
68
  include Label
64
69
  include NotificationBanner
65
70
  include Pagination
66
71
  include Panel
67
72
  include PhaseBanner
68
- include Radios
69
- include Select
70
73
  include SkipLink
71
74
  include StepByStepNavigation
72
75
  include SummaryList
73
76
  include Table
74
77
  include Tabs
75
78
  include Tag
76
- include Textarea
77
79
  include WarningText
78
80
  end
79
81
  end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CCS
4
+ module FrontendHelpers
5
+ # This module contains methods that are shared between the helpers
6
+
7
+ module SharedMethods
8
+ # Initialises the attributes and sets the class attribute for a helper
9
+ #
10
+ # @param options [Hash] the options for a helper
11
+ # @param default_class [String] the default class for a helper
12
+
13
+ def initialise_attributes_and_set_classes(options, default_class)
14
+ (options[:attributes] ||= {})[:class] = "#{default_class} #{options[:classes]}".rstrip
15
+ end
16
+
17
+ # Initialises the data-module attribute for a helper
18
+ #
19
+ # @param options [Hash] the options for a helper
20
+ # @param data_module [String] the name of the data module
21
+
22
+ def set_data_module(options, data_module)
23
+ (options[:attributes][:data] ||= {})[:module] = data_module
24
+ end
25
+ end
26
+ end
27
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module CCS
4
4
  module FrontendHelpers
5
- VERSION = '0.1.0.rc.6'
5
+ VERSION = '0.1.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ccs-frontend_helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.rc.6
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - tim-s-ccs
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-04-20 00:00:00.000000000 Z
11
+ date: 2023-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 3.39.0
47
+ version: 3.38.0
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 3.39.0
54
+ version: 3.38.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -159,7 +159,6 @@ extra_rdoc_files: []
159
159
  files:
160
160
  - ".rspec"
161
161
  - ".rubocop.yml"
162
- - ".ruby-version"
163
162
  - CHANGELOG.md
164
163
  - Gemfile
165
164
  - Gemfile.lock
@@ -167,144 +166,49 @@ files:
167
166
  - README.md
168
167
  - Rakefile
169
168
  - ccs-frontend_helpers.gemspec
170
- - lib/ccs/components/base.rb
171
- - lib/ccs/components/ccs/dashboard_section.rb
172
- - lib/ccs/components/ccs/dashboard_section/panel.rb
173
- - lib/ccs/components/ccs/footer.rb
174
- - lib/ccs/components/ccs/footer/link.rb
175
- - lib/ccs/components/ccs/footer/meta.rb
176
- - lib/ccs/components/ccs/footer/navigation.rb
177
- - lib/ccs/components/ccs/header.rb
178
- - lib/ccs/components/ccs/header/link.rb
179
- - lib/ccs/components/ccs/header/navigation.rb
180
- - lib/ccs/components/ccs/header/service_authentication.rb
181
- - lib/ccs/components/ccs/logo.rb
182
- - lib/ccs/components/govuk/accordion.rb
183
- - lib/ccs/components/govuk/accordion/section.rb
184
- - lib/ccs/components/govuk/accordion/section/content.rb
185
- - lib/ccs/components/govuk/accordion/section/header.rb
186
- - lib/ccs/components/govuk/back_link.rb
187
- - lib/ccs/components/govuk/breadcrumbs.rb
188
- - lib/ccs/components/govuk/breadcrumbs/link.rb
189
- - lib/ccs/components/govuk/button.rb
190
- - lib/ccs/components/govuk/cookie_banner.rb
191
- - lib/ccs/components/govuk/cookie_banner/action.rb
192
- - lib/ccs/components/govuk/cookie_banner/message.rb
193
- - lib/ccs/components/govuk/details.rb
194
- - lib/ccs/components/govuk/error_message.rb
195
- - lib/ccs/components/govuk/error_summary.rb
196
- - lib/ccs/components/govuk/error_summary/item.rb
197
- - lib/ccs/components/govuk/field.rb
198
- - lib/ccs/components/govuk/field/input.rb
199
- - lib/ccs/components/govuk/field/input/character_count.rb
200
- - lib/ccs/components/govuk/field/input/file_upload.rb
201
- - lib/ccs/components/govuk/field/input/select.rb
202
- - lib/ccs/components/govuk/field/input/text_input.rb
203
- - lib/ccs/components/govuk/field/input/text_input/fix.rb
204
- - lib/ccs/components/govuk/field/input/textarea.rb
205
- - lib/ccs/components/govuk/field/inputs.rb
206
- - lib/ccs/components/govuk/field/inputs/checkboxes.rb
207
- - lib/ccs/components/govuk/field/inputs/date_input.rb
208
- - lib/ccs/components/govuk/field/inputs/date_input/item.rb
209
- - lib/ccs/components/govuk/field/inputs/item.rb
210
- - lib/ccs/components/govuk/field/inputs/item/checkbox.rb
211
- - lib/ccs/components/govuk/field/inputs/item/checkbox/form.rb
212
- - lib/ccs/components/govuk/field/inputs/item/checkbox/tag.rb
213
- - lib/ccs/components/govuk/field/inputs/item/divider.rb
214
- - lib/ccs/components/govuk/field/inputs/item/radio.rb
215
- - lib/ccs/components/govuk/field/inputs/item/radio/form.rb
216
- - lib/ccs/components/govuk/field/inputs/item/radio/tag.rb
217
- - lib/ccs/components/govuk/field/inputs/radios.rb
218
- - lib/ccs/components/govuk/fieldset.rb
219
- - lib/ccs/components/govuk/fieldset/legend.rb
220
- - lib/ccs/components/govuk/footer.rb
221
- - lib/ccs/components/govuk/footer/link.rb
222
- - lib/ccs/components/govuk/footer/meta.rb
223
- - lib/ccs/components/govuk/footer/navigation.rb
224
- - lib/ccs/components/govuk/form_group.rb
225
- - lib/ccs/components/govuk/header.rb
226
- - lib/ccs/components/govuk/header/link.rb
227
- - lib/ccs/components/govuk/header/navigation.rb
228
- - lib/ccs/components/govuk/hint.rb
229
- - lib/ccs/components/govuk/inset_text.rb
230
- - lib/ccs/components/govuk/label.rb
231
- - lib/ccs/components/govuk/notification_banner.rb
232
- - lib/ccs/components/govuk/pagination.rb
233
- - lib/ccs/components/govuk/pagination/increment.rb
234
- - lib/ccs/components/govuk/pagination/increment/next.rb
235
- - lib/ccs/components/govuk/pagination/increment/previous.rb
236
- - lib/ccs/components/govuk/pagination/item.rb
237
- - lib/ccs/components/govuk/pagination/item/ellipsis.rb
238
- - lib/ccs/components/govuk/pagination/item/form.rb
239
- - lib/ccs/components/govuk/pagination/item/tag.rb
240
- - lib/ccs/components/govuk/panel.rb
241
- - lib/ccs/components/govuk/phase_banner.rb
242
- - lib/ccs/components/govuk/skip_link.rb
243
- - lib/ccs/components/govuk/step_by_step_navigation.rb
244
- - lib/ccs/components/govuk/step_by_step_navigation/section.rb
245
- - lib/ccs/components/govuk/step_by_step_navigation/section/content.rb
246
- - lib/ccs/components/govuk/step_by_step_navigation/section/content/list.rb
247
- - lib/ccs/components/govuk/step_by_step_navigation/section/content/list/item.rb
248
- - lib/ccs/components/govuk/step_by_step_navigation/section/content/paragraph.rb
249
- - lib/ccs/components/govuk/step_by_step_navigation/section/heading.rb
250
- - lib/ccs/components/govuk/summary_list.rb
251
- - lib/ccs/components/govuk/summary_list/action/link.rb
252
- - lib/ccs/components/govuk/summary_list/card.rb
253
- - lib/ccs/components/govuk/summary_list/card/actions.rb
254
- - lib/ccs/components/govuk/summary_list/card/title.rb
255
- - lib/ccs/components/govuk/summary_list/row.rb
256
- - lib/ccs/components/govuk/summary_list/row/actions.rb
257
- - lib/ccs/components/govuk/summary_list/row/key.rb
258
- - lib/ccs/components/govuk/summary_list/row/value.rb
259
- - lib/ccs/components/govuk/table.rb
260
- - lib/ccs/components/govuk/table/body/data_cell.rb
261
- - lib/ccs/components/govuk/table/body/head_cell.rb
262
- - lib/ccs/components/govuk/table/header/head_cell.rb
263
- - lib/ccs/components/govuk/tabs.rb
264
- - lib/ccs/components/govuk/tabs/panel.rb
265
- - lib/ccs/components/govuk/tabs/tab.rb
266
- - lib/ccs/components/govuk/tag.rb
267
- - lib/ccs/components/govuk/warning_text.rb
268
169
  - lib/ccs/frontend_helpers.rb
269
170
  - lib/ccs/frontend_helpers/ccs_frontend.rb
270
- - lib/ccs/frontend_helpers/ccs_frontend/dashboard_section.rb
171
+ - lib/ccs/frontend_helpers/ccs_frontend/dashboard_panels.rb
271
172
  - lib/ccs/frontend_helpers/ccs_frontend/footer.rb
272
173
  - lib/ccs/frontend_helpers/ccs_frontend/header.rb
174
+ - lib/ccs/frontend_helpers/ccs_frontend/logo.rb
273
175
  - lib/ccs/frontend_helpers/govuk_frontend.rb
274
176
  - lib/ccs/frontend_helpers/govuk_frontend/accordion.rb
275
177
  - lib/ccs/frontend_helpers/govuk_frontend/back_link.rb
276
178
  - lib/ccs/frontend_helpers/govuk_frontend/breadcrumbs.rb
277
179
  - lib/ccs/frontend_helpers/govuk_frontend/button.rb
278
- - lib/ccs/frontend_helpers/govuk_frontend/character_count.rb
279
- - lib/ccs/frontend_helpers/govuk_frontend/checkboxes.rb
280
180
  - lib/ccs/frontend_helpers/govuk_frontend/cookie_banner.rb
281
- - lib/ccs/frontend_helpers/govuk_frontend/date_input.rb
282
181
  - lib/ccs/frontend_helpers/govuk_frontend/details.rb
283
182
  - lib/ccs/frontend_helpers/govuk_frontend/error_message.rb
284
183
  - lib/ccs/frontend_helpers/govuk_frontend/error_summary.rb
184
+ - lib/ccs/frontend_helpers/govuk_frontend/field.rb
185
+ - lib/ccs/frontend_helpers/govuk_frontend/field/character_count.rb
186
+ - lib/ccs/frontend_helpers/govuk_frontend/field/checkboxes.rb
187
+ - lib/ccs/frontend_helpers/govuk_frontend/field/date_input.rb
188
+ - lib/ccs/frontend_helpers/govuk_frontend/field/file_upload.rb
189
+ - lib/ccs/frontend_helpers/govuk_frontend/field/input.rb
190
+ - lib/ccs/frontend_helpers/govuk_frontend/field/radios.rb
191
+ - lib/ccs/frontend_helpers/govuk_frontend/field/select.rb
192
+ - lib/ccs/frontend_helpers/govuk_frontend/field/textarea.rb
285
193
  - lib/ccs/frontend_helpers/govuk_frontend/fieldset.rb
286
- - lib/ccs/frontend_helpers/govuk_frontend/file_upload.rb
287
194
  - lib/ccs/frontend_helpers/govuk_frontend/footer.rb
288
195
  - lib/ccs/frontend_helpers/govuk_frontend/form_group.rb
289
196
  - lib/ccs/frontend_helpers/govuk_frontend/header.rb
290
197
  - lib/ccs/frontend_helpers/govuk_frontend/hint.rb
291
- - lib/ccs/frontend_helpers/govuk_frontend/input.rb
292
198
  - lib/ccs/frontend_helpers/govuk_frontend/inset_text.rb
293
199
  - lib/ccs/frontend_helpers/govuk_frontend/label.rb
294
200
  - lib/ccs/frontend_helpers/govuk_frontend/notification_banner.rb
295
201
  - lib/ccs/frontend_helpers/govuk_frontend/pagination.rb
296
202
  - lib/ccs/frontend_helpers/govuk_frontend/panel.rb
297
203
  - lib/ccs/frontend_helpers/govuk_frontend/phase_banner.rb
298
- - lib/ccs/frontend_helpers/govuk_frontend/radios.rb
299
- - lib/ccs/frontend_helpers/govuk_frontend/select.rb
300
204
  - lib/ccs/frontend_helpers/govuk_frontend/skip_link.rb
301
205
  - lib/ccs/frontend_helpers/govuk_frontend/step_by_step_navigation.rb
302
206
  - lib/ccs/frontend_helpers/govuk_frontend/summary_list.rb
303
207
  - lib/ccs/frontend_helpers/govuk_frontend/table.rb
304
208
  - lib/ccs/frontend_helpers/govuk_frontend/tabs.rb
305
209
  - lib/ccs/frontend_helpers/govuk_frontend/tag.rb
306
- - lib/ccs/frontend_helpers/govuk_frontend/textarea.rb
307
210
  - lib/ccs/frontend_helpers/govuk_frontend/warning_text.rb
211
+ - lib/ccs/frontend_helpers/shared_methods.rb
308
212
  - lib/ccs/frontend_helpers/version.rb
309
213
  - sig/ccs/frontend_helpers.rbs
310
214
  homepage: https://github.com/tim-s-ccs/ccs-frontend_helpers
@@ -326,9 +230,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
326
230
  version: 2.7.0
327
231
  required_rubygems_version: !ruby/object:Gem::Requirement
328
232
  requirements:
329
- - - ">"
233
+ - - ">="
330
234
  - !ruby/object:Gem::Version
331
- version: 1.3.1
235
+ version: '0'
332
236
  requirements: []
333
237
  rubygems_version: 3.1.6
334
238
  signing_key:
data/.ruby-version DELETED
@@ -1 +0,0 @@
1
- 2.7.7
@@ -1,64 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module CCS
4
- # Components for the GOV.UK Frontend and CCS Frontend using an Object Oriented pattern
5
- # These are then used in the {CCS::FrontendHelpers FrontendHelpers}
6
- # to create view helpers that can be used in a Ruby on Rails project
7
-
8
- module Components
9
- # Component base class that all components will inherit from.
10
- #
11
- # It's main purpose is to handle the initialisation of the options
12
- # which is very similar between components
13
- #
14
- # @!attribute [r] options
15
- # @return [Hash] Options for the component which defaults to +{ attributes: {} }+
16
- # where +attributes+ are HTML attributes
17
- # @!attribute [r] context
18
- # @return [ActionView::Base] View context where the components are being rendered
19
-
20
- class Base
21
- private
22
-
23
- attr_accessor :options, :context
24
-
25
- public
26
-
27
- delegate :button_tag, :concat, :label_tag, :link_to, :tag, to: :context
28
-
29
- # @param context [ActionView::Base] the view context where the components are being rendered
30
- # @param options [Hash] options for the component
31
-
32
- def initialize(context:, **options)
33
- options[:attributes] ||= {}
34
- options[:attributes][:class] = "#{default_attributes[:class]} #{options[:classes]}".strip if default_attributes[:class] || options[:classes]
35
- (options[:attributes][:data] ||= {})[:module] = default_attributes[:data][:module] if default_attributes.dig(:data, :module)
36
-
37
- @context = context
38
- @options = options
39
- end
40
-
41
- # The default attributes for the component
42
-
43
- DEFAULT_ATTRIBUTES = {}.freeze
44
-
45
- private
46
-
47
- # The default attributes for the component
48
- #
49
- # @return [Hash]
50
-
51
- def default_attributes
52
- self.class::DEFAULT_ATTRIBUTES
53
- end
54
-
55
- # Sanitizes string used as HTML tag id
56
- #
57
- # @return [String]
58
-
59
- def sanitize_to_id(...)
60
- @context.send(:sanitize_to_id, ...)
61
- end
62
- end
63
- end
64
- end
@@ -1,57 +0,0 @@
1
- require_relative '../../base'
2
-
3
- module CCS
4
- module Components
5
- module CCS
6
- class DashboardSection < Base
7
- # = CCS Dashboard Section Panel
8
- #
9
- # The individual panel within a dashboard section
10
- #
11
- # @!attribute [r] title
12
- # @return [String] Text for the panel title
13
- # @!attribute [r] href
14
- # @return [String] The href for the panel
15
- # @!attribute [r] description
16
- # @return [String] Description text for the panel
17
-
18
- class Panel < Base
19
- private
20
-
21
- attr_reader :title, :href, :description
22
-
23
- public
24
-
25
- # @param title [String] the text for the panel title
26
- # @param href [String] the href for the panel
27
- # @param description [String] the description text for the panel
28
- # @param options [Hash] options that will be used in customising the HTML
29
- #
30
- # @option options [String] :width (default: 'one-third') the width of the panel
31
- # @option options [Hash] :attributes any additional attributes that will added as part of the HTML.
32
-
33
- def initialize(title:, href:, description:, **options)
34
- super(**options)
35
-
36
- @options[:attributes][:class] = "ccs-dashboard-section__panel govuk-grid-column-#{@options[:width] || 'one-third'}"
37
-
38
- @title = title
39
- @href = href
40
- @description = description
41
- end
42
-
43
- # Generates the HTML for the CCS Dashboard Section Panel
44
- #
45
- # @return [ActiveSupport::SafeBuffer]
46
-
47
- def render
48
- tag.div(**options[:attributes]) do
49
- concat(link_to(title, href, class: 'ccs-dashboard-section__panel-title'))
50
- concat(tag.p(description, class: 'ccs-dashboard-section__panel-description'))
51
- end
52
- end
53
- end
54
- end
55
- end
56
- end
57
- end