ccs-frontend_helpers 0.1.0.rc.1 → 0.1.0.rc.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (156) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +5 -1
  3. data/.ruby-version +1 -0
  4. data/CHANGELOG.md +4 -1
  5. data/Gemfile.lock +71 -71
  6. data/lib/ccs/components/base.rb +64 -0
  7. data/lib/ccs/components/ccs/dashboard_section/panel.rb +55 -0
  8. data/lib/ccs/components/ccs/dashboard_section.rb +71 -0
  9. data/lib/ccs/components/ccs/footer/link.rb +53 -0
  10. data/lib/ccs/components/ccs/footer/meta.rb +58 -0
  11. data/lib/ccs/components/ccs/footer/navigation.rb +59 -0
  12. data/lib/ccs/components/ccs/footer.rb +93 -0
  13. data/lib/ccs/components/ccs/header/link.rb +58 -0
  14. data/lib/ccs/components/ccs/header/navigation.rb +97 -0
  15. data/lib/ccs/components/ccs/header/service_authentication.rb +52 -0
  16. data/lib/ccs/components/ccs/header.rb +108 -0
  17. data/lib/ccs/components/ccs/logo.rb +45 -0
  18. data/lib/ccs/components/govuk/accordion/section/content.rb +53 -0
  19. data/lib/ccs/components/govuk/accordion/section/header.rb +57 -0
  20. data/lib/ccs/components/govuk/accordion/section.rb +60 -0
  21. data/lib/ccs/components/govuk/accordion.rb +56 -0
  22. data/lib/ccs/components/govuk/back_link.rb +49 -0
  23. data/lib/ccs/components/govuk/breadcrumbs/link.rb +55 -0
  24. data/lib/ccs/components/govuk/breadcrumbs.rb +53 -0
  25. data/lib/ccs/components/govuk/button.rb +105 -0
  26. data/lib/ccs/components/govuk/cookie_banner/action.rb +58 -0
  27. data/lib/ccs/components/govuk/cookie_banner/message.rb +78 -0
  28. data/lib/ccs/components/govuk/cookie_banner.rb +53 -0
  29. data/lib/ccs/components/govuk/details.rb +51 -0
  30. data/lib/ccs/components/govuk/error_message.rb +58 -0
  31. data/lib/ccs/components/govuk/error_summary/item.rb +52 -0
  32. data/lib/ccs/components/govuk/error_summary.rb +68 -0
  33. data/lib/ccs/components/govuk/field/input/character_count.rb +127 -0
  34. data/lib/ccs/components/govuk/field/input/file_upload.rb +42 -0
  35. data/lib/ccs/components/govuk/field/input/select.rb +80 -0
  36. data/lib/ccs/components/govuk/field/input/text_input/fix.rb +53 -0
  37. data/lib/ccs/components/govuk/field/input/text_input.rb +95 -0
  38. data/lib/ccs/components/govuk/field/input/textarea.rb +57 -0
  39. data/lib/ccs/components/govuk/field/input.rb +60 -0
  40. data/lib/ccs/components/govuk/field/inputs/checkboxes.rb +67 -0
  41. data/lib/ccs/components/govuk/field/inputs/date_input/item.rb +63 -0
  42. data/lib/ccs/components/govuk/field/inputs/date_input.rb +87 -0
  43. data/lib/ccs/components/govuk/field/inputs/item/checkbox/form.rb +45 -0
  44. data/lib/ccs/components/govuk/field/inputs/item/checkbox/tag.rb +41 -0
  45. data/lib/ccs/components/govuk/field/inputs/item/checkbox.rb +48 -0
  46. data/lib/ccs/components/govuk/field/inputs/item/divider.rb +48 -0
  47. data/lib/ccs/components/govuk/field/inputs/item/radio/form.rb +42 -0
  48. data/lib/ccs/components/govuk/field/inputs/item/radio/tag.rb +41 -0
  49. data/lib/ccs/components/govuk/field/inputs/item/radio.rb +48 -0
  50. data/lib/ccs/components/govuk/field/inputs/item.rb +109 -0
  51. data/lib/ccs/components/govuk/field/inputs/radios.rb +67 -0
  52. data/lib/ccs/components/govuk/field/inputs.rb +55 -0
  53. data/lib/ccs/components/govuk/field.rb +106 -0
  54. data/lib/ccs/components/govuk/fieldset/legend.rb +63 -0
  55. data/lib/ccs/components/govuk/fieldset.rb +52 -0
  56. data/lib/ccs/components/govuk/footer/link.rb +53 -0
  57. data/lib/ccs/components/govuk/footer/meta.rb +58 -0
  58. data/lib/ccs/components/govuk/footer/navigation.rb +59 -0
  59. data/lib/ccs/components/govuk/footer.rb +129 -0
  60. data/lib/ccs/components/govuk/form_group.rb +58 -0
  61. data/lib/ccs/components/govuk/header/link.rb +54 -0
  62. data/lib/ccs/components/govuk/header/navigation.rb +70 -0
  63. data/lib/ccs/components/govuk/header.rb +105 -0
  64. data/lib/ccs/components/govuk/hint.rb +47 -0
  65. data/lib/ccs/components/govuk/inset_text.rb +50 -0
  66. data/lib/ccs/components/govuk/label.rb +83 -0
  67. data/lib/ccs/components/govuk/notification_banner.rb +105 -0
  68. data/lib/ccs/components/govuk/pagination/increment/next.rb +42 -0
  69. data/lib/ccs/components/govuk/pagination/increment/previous.rb +41 -0
  70. data/lib/ccs/components/govuk/pagination/increment.rb +96 -0
  71. data/lib/ccs/components/govuk/pagination/item/ellipsis.rb +26 -0
  72. data/lib/ccs/components/govuk/pagination/item/form.rb +47 -0
  73. data/lib/ccs/components/govuk/pagination/item/tag.rb +45 -0
  74. data/lib/ccs/components/govuk/pagination/item.rb +62 -0
  75. data/lib/ccs/components/govuk/pagination.rb +94 -0
  76. data/lib/ccs/components/govuk/panel.rb +60 -0
  77. data/lib/ccs/components/govuk/phase_banner.rb +67 -0
  78. data/lib/ccs/components/govuk/skip_link.rb +49 -0
  79. data/lib/ccs/components/govuk/step_by_step_navigation/section/content/list/item.rb +51 -0
  80. data/lib/ccs/components/govuk/step_by_step_navigation/section/content/list.rb +48 -0
  81. data/lib/ccs/components/govuk/step_by_step_navigation/section/content/paragraph.rb +43 -0
  82. data/lib/ccs/components/govuk/step_by_step_navigation/section/content.rb +61 -0
  83. data/lib/ccs/components/govuk/step_by_step_navigation/section/heading.rb +67 -0
  84. data/lib/ccs/components/govuk/step_by_step_navigation/section.rb +54 -0
  85. data/lib/ccs/components/govuk/step_by_step_navigation.rb +57 -0
  86. data/lib/ccs/components/govuk/summary_list/action/link.rb +57 -0
  87. data/lib/ccs/components/govuk/summary_list/card/actions.rb +57 -0
  88. data/lib/ccs/components/govuk/summary_list/card/title.rb +49 -0
  89. data/lib/ccs/components/govuk/summary_list/card.rb +61 -0
  90. data/lib/ccs/components/govuk/summary_list/row/actions.rb +57 -0
  91. data/lib/ccs/components/govuk/summary_list/row/key.rb +45 -0
  92. data/lib/ccs/components/govuk/summary_list/row/value.rb +45 -0
  93. data/lib/ccs/components/govuk/summary_list/row.rb +63 -0
  94. data/lib/ccs/components/govuk/summary_list.rb +72 -0
  95. data/lib/ccs/components/govuk/table/body/data_cell.rb +51 -0
  96. data/lib/ccs/components/govuk/table/body/head_cell.rb +50 -0
  97. data/lib/ccs/components/govuk/table/header/head_cell.rb +52 -0
  98. data/lib/ccs/components/govuk/table.rb +109 -0
  99. data/lib/ccs/components/govuk/tabs/panel.rb +56 -0
  100. data/lib/ccs/components/govuk/tabs/tab.rb +54 -0
  101. data/lib/ccs/components/govuk/tabs.rb +64 -0
  102. data/lib/ccs/components/govuk/tag.rb +49 -0
  103. data/lib/ccs/components/govuk/warning_text.rb +59 -0
  104. data/lib/ccs/frontend_helpers/ccs_frontend/dashboard_section.rb +25 -0
  105. data/lib/ccs/frontend_helpers/ccs_frontend/footer.rb +16 -131
  106. data/lib/ccs/frontend_helpers/ccs_frontend/header.rb +16 -195
  107. data/lib/ccs/frontend_helpers/ccs_frontend.rb +2 -4
  108. data/lib/ccs/frontend_helpers/govuk_frontend/accordion.rb +16 -105
  109. data/lib/ccs/frontend_helpers/govuk_frontend/back_link.rb +16 -29
  110. data/lib/ccs/frontend_helpers/govuk_frontend/breadcrumbs.rb +16 -66
  111. data/lib/ccs/frontend_helpers/govuk_frontend/button.rb +16 -117
  112. data/lib/ccs/frontend_helpers/govuk_frontend/character_count.rb +26 -0
  113. data/lib/ccs/frontend_helpers/govuk_frontend/checkboxes.rb +26 -0
  114. data/lib/ccs/frontend_helpers/govuk_frontend/cookie_banner.rb +16 -126
  115. data/lib/ccs/frontend_helpers/govuk_frontend/date_input.rb +26 -0
  116. data/lib/ccs/frontend_helpers/govuk_frontend/details.rb +18 -36
  117. data/lib/ccs/frontend_helpers/govuk_frontend/error_message.rb +31 -54
  118. data/lib/ccs/frontend_helpers/govuk_frontend/error_summary.rb +32 -86
  119. data/lib/ccs/frontend_helpers/govuk_frontend/fieldset.rb +18 -61
  120. data/lib/ccs/frontend_helpers/govuk_frontend/file_upload.rb +26 -0
  121. data/lib/ccs/frontend_helpers/govuk_frontend/footer.rb +16 -173
  122. data/lib/ccs/frontend_helpers/govuk_frontend/form_group.rb +26 -39
  123. data/lib/ccs/frontend_helpers/govuk_frontend/header.rb +16 -151
  124. data/lib/ccs/frontend_helpers/govuk_frontend/hint.rb +17 -28
  125. data/lib/ccs/frontend_helpers/govuk_frontend/input.rb +26 -0
  126. data/lib/ccs/frontend_helpers/govuk_frontend/inset_text.rb +18 -34
  127. data/lib/ccs/frontend_helpers/govuk_frontend/label.rb +17 -82
  128. data/lib/ccs/frontend_helpers/govuk_frontend/notification_banner.rb +18 -126
  129. data/lib/ccs/frontend_helpers/govuk_frontend/pagination.rb +16 -326
  130. data/lib/ccs/frontend_helpers/govuk_frontend/panel.rb +18 -41
  131. data/lib/ccs/frontend_helpers/govuk_frontend/phase_banner.rb +18 -39
  132. data/lib/ccs/frontend_helpers/govuk_frontend/radios.rb +26 -0
  133. data/lib/ccs/frontend_helpers/govuk_frontend/select.rb +26 -0
  134. data/lib/ccs/frontend_helpers/govuk_frontend/skip_link.rb +16 -30
  135. data/lib/ccs/frontend_helpers/govuk_frontend/step_by_step_navigation.rb +23 -204
  136. data/lib/ccs/frontend_helpers/govuk_frontend/summary_list.rb +16 -216
  137. data/lib/ccs/frontend_helpers/govuk_frontend/table.rb +16 -114
  138. data/lib/ccs/frontend_helpers/govuk_frontend/tabs.rb +16 -85
  139. data/lib/ccs/frontend_helpers/govuk_frontend/tag.rb +16 -32
  140. data/lib/ccs/frontend_helpers/govuk_frontend/textarea.rb +26 -0
  141. data/lib/ccs/frontend_helpers/govuk_frontend/warning_text.rb +18 -43
  142. data/lib/ccs/frontend_helpers/govuk_frontend.rb +17 -19
  143. data/lib/ccs/frontend_helpers/version.rb +1 -1
  144. metadata +110 -14
  145. data/lib/ccs/frontend_helpers/ccs_frontend/dashboard_panels.rb +0 -79
  146. data/lib/ccs/frontend_helpers/ccs_frontend/logo.rb +0 -49
  147. data/lib/ccs/frontend_helpers/govuk_frontend/field/character_count.rb +0 -165
  148. data/lib/ccs/frontend_helpers/govuk_frontend/field/checkboxes.rb +0 -200
  149. data/lib/ccs/frontend_helpers/govuk_frontend/field/date_input.rb +0 -153
  150. data/lib/ccs/frontend_helpers/govuk_frontend/field/file_upload.rb +0 -83
  151. data/lib/ccs/frontend_helpers/govuk_frontend/field/input.rb +0 -153
  152. data/lib/ccs/frontend_helpers/govuk_frontend/field/radios.rb +0 -201
  153. data/lib/ccs/frontend_helpers/govuk_frontend/field/select.rb +0 -124
  154. data/lib/ccs/frontend_helpers/govuk_frontend/field/textarea.rb +0 -106
  155. data/lib/ccs/frontend_helpers/govuk_frontend/field.rb +0 -213
  156. data/lib/ccs/frontend_helpers/shared_methods.rb +0 -27
@@ -1,94 +1,25 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'action_view'
4
-
5
- require_relative '../shared_methods'
3
+ require_relative '../../components/govuk/tabs'
6
4
 
7
5
  module CCS
8
- module FrontendHelpers
9
- module GovUKFrontend
10
- # = GOV.UK Tabs
6
+ module FrontendHelpers::GovUKFrontend
7
+ # = GOV.UK Tabs
8
+ #
9
+ # This helper is used for generating the tabs component from the
10
+ # {https://design-system.service.gov.uk/components/tabs GDS - Components - Tabs}
11
+
12
+ module Tabs
13
+ # Generates the HTML for the GOV.UK Tabs component
11
14
  #
12
- # This helper is used for generating the tabs component from the
13
- # {https://design-system.service.gov.uk/components/tabs GDS - Components - Tabs}
14
-
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
-
23
- # Generates the HTML for the GOV.UK Tabs component
24
- #
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}
54
- #
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
58
- #
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
15
+ # @param (see CCS::Components::GovUK::Tabs#initialize)
16
+ #
17
+ # @option (see CCS::Components::GovUK::Tabs#initialize)
18
+ #
19
+ # @return (see CCS::Components::GovUK::Tabs#render)
87
20
 
88
- tag.div(**panel_item[:attributes]) do
89
- panel_item[:content] || tag.p(panel_item[:text], class: 'govuk-body')
90
- end
91
- end
21
+ def govuk_tabs(items, title = nil, **options)
22
+ Components::GovUK::Tabs.new(context: self, items: items, title: title, **options).render
92
23
  end
93
24
  end
94
25
  end
@@ -1,41 +1,25 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'action_view'
4
-
5
- require_relative '../shared_methods'
3
+ require_relative '../../components/govuk/tag'
6
4
 
7
5
  module CCS
8
- module FrontendHelpers
9
- module GovUKFrontend
10
- # = GOV.UK Tag
11
- #
12
- # This helper is used for generating the tag component from the
13
- # {https://design-system.service.gov.uk/components/tag GDS - Components - Tag}
14
-
15
- module Tag
16
- include SharedMethods
17
- include ActionView::Context
18
- include ActionView::Helpers::TagHelper
19
-
20
- # Generates the HTML for the GOV.UK Tag component
21
- #
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
27
- #
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
30
- #
31
- # @return [ActiveSupport::SafeBuffer] the HTML for the GOV.UK Tag
32
- # which can then be rendered on the page
6
+ module FrontendHelpers::GovUKFrontend
7
+ # = GOV.UK Tag
8
+ #
9
+ # This helper is used for generating the tag component from the
10
+ # {https://design-system.service.gov.uk/components/tag GDS - Components - Tag}
33
11
 
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)
12
+ module Tag
13
+ # Generates the HTML for the GOV.UK Back link component
14
+ #
15
+ # @param (see CCS::Components::GovUK::Tag#initialize)
16
+ #
17
+ # @option (see CCS::Components::GovUK::Tag#initialize)
18
+ #
19
+ # @return (see CCS::Components::GovUK::Tag#render)
36
20
 
37
- tag.strong(text, **govuk_tag_options[:attributes])
38
- end
21
+ def govuk_tag(text, colour = nil, **options)
22
+ Components::GovUK::Tag.new(context: self, text: text, colour: colour, **options).render
39
23
  end
40
24
  end
41
25
  end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../components/govuk/field/input/textarea'
4
+
5
+ module CCS
6
+ module FrontendHelpers::GovUKFrontend
7
+ # = GOV.UK Textarea
8
+ #
9
+ # This helper is used for generating the textarea component from the
10
+ # {https://design-system.service.gov.uk/components/textarea GDS - Components - Textarea}
11
+
12
+ module Textarea
13
+ # Generates the HTML for the GOV.UK Textarea component
14
+ #
15
+ # @param (see CCS::Components::GovUK::Input::Textarea#initialize)
16
+ #
17
+ # @option (see CCS::Components::GovUK::Input::Textarea#initialize)
18
+ #
19
+ # @return (see CCS::Components::GovUK::Input::Textarea#render)
20
+
21
+ def govuk_textarea(attribute, **options)
22
+ Components::GovUK::Field::Input::Textarea.new(context: self, attribute: attribute, **options).render
23
+ end
24
+ end
25
+ end
26
+ end
@@ -1,52 +1,27 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'action_view'
4
-
5
- require_relative '../shared_methods'
3
+ require_relative '../../components/govuk/warning_text'
6
4
 
7
5
  module CCS
8
- module FrontendHelpers
9
- module GovUKFrontend
10
- # = GOV.UK Warning text
11
- #
12
- # This helper is used for generating the warning text component from the
13
- # {https://design-system.service.gov.uk/components/warning-text GDS - Components - Warning text}
14
-
15
- module WarningText
16
- include SharedMethods
17
- include ActionView::Context
18
- include ActionView::Helpers::TagHelper
19
- include ActionView::Helpers::TextHelper
20
-
21
- # Generates the HTML for the GOV.UK Warning text component
22
- #
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
25
- #
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
29
- #
30
- # @yield HTML that will be used in the warning text. Ignored if text is passed.
31
- #
32
- # @return [ActiveSupport::SafeBuffer] the HTML for the GOV.UK Warning text
33
- # which can then be rendered on the page
6
+ module FrontendHelpers::GovUKFrontend
7
+ # = GOV.UK Warning text
8
+ #
9
+ # This helper is used for generating the warning text component from the
10
+ # {https://design-system.service.gov.uk/components/warning-text GDS - Components - Warning text}
34
11
 
35
- def govuk_warning_text(text = nil, **govuk_warning_text_options)
36
- initialise_attributes_and_set_classes(govuk_warning_text_options, 'govuk-warning-text')
12
+ module WarningText
13
+ # Generates the HTML for the GOV.UK Warning text component
14
+ #
15
+ # @param (see CCS::Components::GovUK::WarningText#initialize)
16
+ #
17
+ # @option (see CCS::Components::GovUK::WarningText#initialize)
18
+ #
19
+ # @yield (see CCS::Components::GovUK::WarningText#render)
20
+ #
21
+ # @return (see CCS::Components::GovUK::WarningText#render)
37
22
 
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
49
- end
23
+ def govuk_warning_text(text = nil, **options, &block)
24
+ Components::GovUK::WarningText.new(context: self, text: text, **options).render(&block)
50
25
  end
51
26
  end
52
27
  end
@@ -4,78 +4,76 @@ 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'
7
9
  require_relative 'govuk_frontend/cookie_banner'
10
+ require_relative 'govuk_frontend/date_input'
8
11
  require_relative 'govuk_frontend/details'
9
12
  require_relative 'govuk_frontend/error_message'
10
13
  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'
20
14
  require_relative 'govuk_frontend/fieldset'
15
+ require_relative 'govuk_frontend/file_upload'
21
16
  require_relative 'govuk_frontend/footer'
22
17
  require_relative 'govuk_frontend/form_group'
23
18
  require_relative 'govuk_frontend/header'
24
19
  require_relative 'govuk_frontend/hint'
20
+ require_relative 'govuk_frontend/input'
25
21
  require_relative 'govuk_frontend/inset_text'
26
22
  require_relative 'govuk_frontend/label'
27
23
  require_relative 'govuk_frontend/notification_banner'
28
24
  require_relative 'govuk_frontend/pagination'
29
25
  require_relative 'govuk_frontend/panel'
30
26
  require_relative 'govuk_frontend/phase_banner'
27
+ require_relative 'govuk_frontend/radios'
28
+ require_relative 'govuk_frontend/select'
31
29
  require_relative 'govuk_frontend/skip_link'
32
30
  require_relative 'govuk_frontend/step_by_step_navigation'
33
31
  require_relative 'govuk_frontend/summary_list'
34
32
  require_relative 'govuk_frontend/table'
35
33
  require_relative 'govuk_frontend/tabs'
36
34
  require_relative 'govuk_frontend/tag'
35
+ require_relative 'govuk_frontend/textarea'
37
36
  require_relative 'govuk_frontend/warning_text'
38
37
 
39
38
  module CCS
40
39
  module FrontendHelpers
41
40
  # This module loads in all the GOV.UK Frontend Helper methods.
42
- # These are a collection of view helpers to help render GOV.UK components
41
+ # These are a collection of view to help render GOV.UK components
43
42
 
44
43
  module GovUKFrontend
45
44
  include Accordion
46
45
  include BackLink
47
46
  include Breadcrumbs
48
47
  include Button
48
+ include CharacterCount
49
+ include Checkboxes
49
50
  include CookieBanner
51
+ include DateInput
50
52
  include Details
51
53
  include ErrorMessage
52
54
  include ErrorSummary
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
55
+ include FileUpload
62
56
  include Fieldset
63
57
  include Footer
64
58
  include FormGroup
65
59
  include Header
66
60
  include Hint
61
+ include Input
67
62
  include InsetText
68
63
  include Label
69
64
  include NotificationBanner
70
65
  include Pagination
71
66
  include Panel
72
67
  include PhaseBanner
68
+ include Radios
69
+ include Select
73
70
  include SkipLink
74
71
  include StepByStepNavigation
75
72
  include SummaryList
76
73
  include Table
77
74
  include Tabs
78
75
  include Tag
76
+ include Textarea
79
77
  include WarningText
80
78
  end
81
79
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module CCS
4
4
  module FrontendHelpers
5
- VERSION = '0.1.0.rc.1'
5
+ VERSION = '0.1.0.rc.2'
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.1
4
+ version: 0.1.0.rc.2
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-02-23 00:00:00.000000000 Z
11
+ date: 2023-04-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -159,6 +159,7 @@ extra_rdoc_files: []
159
159
  files:
160
160
  - ".rspec"
161
161
  - ".rubocop.yml"
162
+ - ".ruby-version"
162
163
  - CHANGELOG.md
163
164
  - Gemfile
164
165
  - Gemfile.lock
@@ -166,49 +167,144 @@ files:
166
167
  - README.md
167
168
  - Rakefile
168
169
  - 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
169
268
  - lib/ccs/frontend_helpers.rb
170
269
  - lib/ccs/frontend_helpers/ccs_frontend.rb
171
- - lib/ccs/frontend_helpers/ccs_frontend/dashboard_panels.rb
270
+ - lib/ccs/frontend_helpers/ccs_frontend/dashboard_section.rb
172
271
  - lib/ccs/frontend_helpers/ccs_frontend/footer.rb
173
272
  - lib/ccs/frontend_helpers/ccs_frontend/header.rb
174
- - lib/ccs/frontend_helpers/ccs_frontend/logo.rb
175
273
  - lib/ccs/frontend_helpers/govuk_frontend.rb
176
274
  - lib/ccs/frontend_helpers/govuk_frontend/accordion.rb
177
275
  - lib/ccs/frontend_helpers/govuk_frontend/back_link.rb
178
276
  - lib/ccs/frontend_helpers/govuk_frontend/breadcrumbs.rb
179
277
  - 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
180
280
  - lib/ccs/frontend_helpers/govuk_frontend/cookie_banner.rb
281
+ - lib/ccs/frontend_helpers/govuk_frontend/date_input.rb
181
282
  - lib/ccs/frontend_helpers/govuk_frontend/details.rb
182
283
  - lib/ccs/frontend_helpers/govuk_frontend/error_message.rb
183
284
  - 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
193
285
  - lib/ccs/frontend_helpers/govuk_frontend/fieldset.rb
286
+ - lib/ccs/frontend_helpers/govuk_frontend/file_upload.rb
194
287
  - lib/ccs/frontend_helpers/govuk_frontend/footer.rb
195
288
  - lib/ccs/frontend_helpers/govuk_frontend/form_group.rb
196
289
  - lib/ccs/frontend_helpers/govuk_frontend/header.rb
197
290
  - lib/ccs/frontend_helpers/govuk_frontend/hint.rb
291
+ - lib/ccs/frontend_helpers/govuk_frontend/input.rb
198
292
  - lib/ccs/frontend_helpers/govuk_frontend/inset_text.rb
199
293
  - lib/ccs/frontend_helpers/govuk_frontend/label.rb
200
294
  - lib/ccs/frontend_helpers/govuk_frontend/notification_banner.rb
201
295
  - lib/ccs/frontend_helpers/govuk_frontend/pagination.rb
202
296
  - lib/ccs/frontend_helpers/govuk_frontend/panel.rb
203
297
  - 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
204
300
  - lib/ccs/frontend_helpers/govuk_frontend/skip_link.rb
205
301
  - lib/ccs/frontend_helpers/govuk_frontend/step_by_step_navigation.rb
206
302
  - lib/ccs/frontend_helpers/govuk_frontend/summary_list.rb
207
303
  - lib/ccs/frontend_helpers/govuk_frontend/table.rb
208
304
  - lib/ccs/frontend_helpers/govuk_frontend/tabs.rb
209
305
  - lib/ccs/frontend_helpers/govuk_frontend/tag.rb
306
+ - lib/ccs/frontend_helpers/govuk_frontend/textarea.rb
210
307
  - lib/ccs/frontend_helpers/govuk_frontend/warning_text.rb
211
- - lib/ccs/frontend_helpers/shared_methods.rb
212
308
  - lib/ccs/frontend_helpers/version.rb
213
309
  - sig/ccs/frontend_helpers.rbs
214
310
  homepage: https://github.com/tim-s-ccs/ccs-frontend_helpers
@@ -1,79 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'action_view'
4
-
5
- require_relative '../shared_methods'
6
-
7
- module CCS
8
- module FrontendHelpers
9
- module CCSFrontend
10
- # = CCS Dashboard Panels
11
- #
12
- # This helper is used for generating the dashboard panels component
13
-
14
- module DashboardPanels
15
- include SharedMethods
16
- include ActionView::Context
17
- include ActionView::Helpers::TagHelper
18
- include ActionView::Helpers::TextHelper
19
- include ActionView::Helpers::UrlHelper
20
-
21
- # Generates the HTML for the CCS Dashboard Panels component
22
- #
23
- # @param panel_items [Array] the panel items, see {ccs_dashboard_panels_item}
24
- # @param title_text [String] text for the title of a dashboard panels section
25
- # @param ccs_dashboard_panels_options [Hash] options that will be used in customising the HTML
26
- #
27
- # @option ccs_dashboard_panels_options [String] :classes additional CSS classes for the dashboard panels HTML
28
- # @option ccs_dashboard_panels_options [String] :width (default: 'full') the width of the dashbaord panel section
29
- # @option ccs_dashboard_panels_options [Hash] :attributes additional attributes that will added as part of the HTML
30
- #
31
- # @return [ActiveSupport::SafeBuffer] the HTML for the CCS Dashboard Panels
32
- # which can then be rendered on the page
33
-
34
- def ccs_dashboard_panels(panel_items, title_text = nil, **ccs_dashboard_panels_options)
35
- initialise_attributes_and_set_classes(ccs_dashboard_panels_options, 'ccs-dashboard-panels')
36
-
37
- tag.div(**ccs_dashboard_panels_options[:attributes]) do
38
- tag.div(class: 'govuk-grid-row') do
39
- tag.div(class: "govuk-grid-column-#{ccs_dashboard_panels_options[:width] || 'full'}") do
40
- if title_text
41
- concat(tag.h2(title_text, class: 'ccs-dashboard-panels__heading govuk-heading-m'))
42
- concat(tag.hr(class: 'ccs-dashboard-panels__heading-section-break govuk-section-break govuk-section-break--visible'))
43
- end
44
- concat(tag.div(class: 'ccs-dashboard-panels__container') do
45
- tag.div(class: 'govuk-grid-row') do
46
- panel_items.each { |panel_item| concat(ccs_dashboard_panels_item(panel_item)) }
47
- end
48
- end)
49
- end
50
- end
51
- end
52
- end
53
-
54
- private
55
-
56
- # Generates the HTML for the a dashboard panel item in {ccs_dashboard_panels}
57
- #
58
- # @param panel_item [Hash] options for the dashboard panel item
59
- #
60
- # @option panel_item [String] :title the title for the dashboard panel
61
- # @option panel_item [String] :href the href for the dashboard panel
62
- # @option panel_item [String] :description the description text for the dashboard panel
63
- # @option panel_item [String] :width (default: 'one-third') the width of the dashboard panel item
64
- # @option panel_item [Hash] :attributes additional attributes that will added as part of the HTML
65
- #
66
- # @return [ActiveSupport::SafeBuffer] the HTML for a panel item in {ccs_dashboard_panels}
67
-
68
- def ccs_dashboard_panels_item(panel_item)
69
- (panel_item[:attributes] ||= {})[:class] = "ccs-dashboard-panels__item govuk-grid-column-#{panel_item[:width] || 'one-third'}"
70
-
71
- tag.div(**panel_item[:attributes]) do
72
- concat(link_to(panel_item[:title], panel_item[:href], class: 'ccs-dashboard-panels__item-title'))
73
- concat(tag.p(panel_item[:description], class: 'ccs-dashboard-panels__item-description'))
74
- end
75
- end
76
- end
77
- end
78
- end
79
- end