ccs-frontend_helpers 0.1.0.rc.7 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (157) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -5
  3. data/CHANGELOG.md +2 -4
  4. data/Gemfile +1 -15
  5. data/Gemfile.lock +80 -81
  6. data/ccs-frontend_helpers.gemspec +10 -0
  7. data/lib/ccs/frontend_helpers/ccs_frontend/dashboard_panels.rb +79 -0
  8. data/lib/ccs/frontend_helpers/ccs_frontend/footer.rb +119 -6
  9. data/lib/ccs/frontend_helpers/ccs_frontend/header.rb +183 -6
  10. data/lib/ccs/{components/ccs → frontend_helpers/ccs_frontend}/logo.rb +12 -10
  11. data/lib/ccs/frontend_helpers/ccs_frontend.rb +4 -2
  12. data/lib/ccs/frontend_helpers/govuk_frontend/accordion.rb +95 -8
  13. data/lib/ccs/frontend_helpers/govuk_frontend/back_link.rb +17 -6
  14. data/lib/ccs/frontend_helpers/govuk_frontend/breadcrumbs.rb +54 -6
  15. data/lib/ccs/frontend_helpers/govuk_frontend/button.rb +105 -6
  16. data/lib/ccs/frontend_helpers/govuk_frontend/cookie_banner.rb +114 -6
  17. data/lib/ccs/frontend_helpers/govuk_frontend/details.rb +23 -7
  18. data/lib/ccs/frontend_helpers/govuk_frontend/error_message.rb +32 -11
  19. data/lib/ccs/frontend_helpers/govuk_frontend/error_summary.rb +65 -13
  20. data/lib/ccs/frontend_helpers/govuk_frontend/field/character_count.rb +165 -0
  21. data/lib/ccs/frontend_helpers/govuk_frontend/field/checkboxes.rb +200 -0
  22. data/lib/ccs/frontend_helpers/govuk_frontend/field/date_input.rb +153 -0
  23. data/lib/ccs/frontend_helpers/govuk_frontend/field/file_upload.rb +83 -0
  24. data/lib/ccs/frontend_helpers/govuk_frontend/field/input.rb +153 -0
  25. data/lib/ccs/frontend_helpers/govuk_frontend/field/radios.rb +201 -0
  26. data/lib/ccs/frontend_helpers/govuk_frontend/field/select.rb +124 -0
  27. data/lib/ccs/frontend_helpers/govuk_frontend/field/textarea.rb +106 -0
  28. data/lib/ccs/frontend_helpers/govuk_frontend/field.rb +213 -0
  29. data/lib/ccs/frontend_helpers/govuk_frontend/fieldset.rb +48 -7
  30. data/lib/ccs/frontend_helpers/govuk_frontend/footer.rb +161 -6
  31. data/lib/ccs/frontend_helpers/govuk_frontend/form_group.rb +24 -13
  32. data/lib/ccs/frontend_helpers/govuk_frontend/header.rb +139 -6
  33. data/lib/ccs/frontend_helpers/govuk_frontend/hint.rb +17 -8
  34. data/lib/ccs/frontend_helpers/govuk_frontend/inset_text.rb +21 -7
  35. data/lib/ccs/frontend_helpers/govuk_frontend/label.rb +70 -7
  36. data/lib/ccs/frontend_helpers/govuk_frontend/notification_banner.rb +113 -7
  37. data/lib/ccs/frontend_helpers/govuk_frontend/pagination.rb +314 -6
  38. data/lib/ccs/frontend_helpers/govuk_frontend/panel.rb +28 -7
  39. data/lib/ccs/frontend_helpers/govuk_frontend/phase_banner.rb +27 -8
  40. data/lib/ccs/frontend_helpers/govuk_frontend/skip_link.rb +18 -6
  41. data/lib/ccs/frontend_helpers/govuk_frontend/step_by_step_navigation.rb +186 -7
  42. data/lib/ccs/frontend_helpers/govuk_frontend/summary_list.rb +204 -6
  43. data/lib/ccs/frontend_helpers/govuk_frontend/table.rb +100 -11
  44. data/lib/ccs/frontend_helpers/govuk_frontend/tabs.rb +73 -6
  45. data/lib/ccs/frontend_helpers/govuk_frontend/tag.rb +21 -7
  46. data/lib/ccs/frontend_helpers/govuk_frontend/warning_text.rb +30 -7
  47. data/lib/ccs/frontend_helpers/govuk_frontend.rb +19 -17
  48. data/lib/ccs/frontend_helpers/shared_methods.rb +27 -0
  49. data/lib/ccs/frontend_helpers/version.rb +1 -1
  50. metadata +142 -112
  51. data/.ruby-version +0 -1
  52. data/lib/ccs/components/base.rb +0 -64
  53. data/lib/ccs/components/ccs/dashboard_section/panel.rb +0 -57
  54. data/lib/ccs/components/ccs/dashboard_section.rb +0 -71
  55. data/lib/ccs/components/ccs/footer/link.rb +0 -55
  56. data/lib/ccs/components/ccs/footer/meta.rb +0 -59
  57. data/lib/ccs/components/ccs/footer/navigation.rb +0 -60
  58. data/lib/ccs/components/ccs/footer.rb +0 -95
  59. data/lib/ccs/components/ccs/header/link.rb +0 -60
  60. data/lib/ccs/components/ccs/header/navigation.rb +0 -98
  61. data/lib/ccs/components/ccs/header/service_authentication.rb +0 -53
  62. data/lib/ccs/components/ccs/header.rb +0 -110
  63. data/lib/ccs/components/govuk/accordion/section/content.rb +0 -53
  64. data/lib/ccs/components/govuk/accordion/section/header.rb +0 -57
  65. data/lib/ccs/components/govuk/accordion/section.rb +0 -61
  66. data/lib/ccs/components/govuk/accordion.rb +0 -58
  67. data/lib/ccs/components/govuk/back_link.rb +0 -51
  68. data/lib/ccs/components/govuk/breadcrumbs/link.rb +0 -57
  69. data/lib/ccs/components/govuk/breadcrumbs.rb +0 -55
  70. data/lib/ccs/components/govuk/button.rb +0 -107
  71. data/lib/ccs/components/govuk/cookie_banner/action.rb +0 -60
  72. data/lib/ccs/components/govuk/cookie_banner/message.rb +0 -80
  73. data/lib/ccs/components/govuk/cookie_banner.rb +0 -55
  74. data/lib/ccs/components/govuk/details.rb +0 -53
  75. data/lib/ccs/components/govuk/error_message.rb +0 -60
  76. data/lib/ccs/components/govuk/error_summary/item.rb +0 -54
  77. data/lib/ccs/components/govuk/error_summary.rb +0 -70
  78. data/lib/ccs/components/govuk/field/input/character_count.rb +0 -129
  79. data/lib/ccs/components/govuk/field/input/file_upload.rb +0 -44
  80. data/lib/ccs/components/govuk/field/input/select.rb +0 -82
  81. data/lib/ccs/components/govuk/field/input/text_input/fix.rb +0 -55
  82. data/lib/ccs/components/govuk/field/input/text_input.rb +0 -97
  83. data/lib/ccs/components/govuk/field/input/textarea.rb +0 -59
  84. data/lib/ccs/components/govuk/field/input.rb +0 -62
  85. data/lib/ccs/components/govuk/field/inputs/checkboxes.rb +0 -69
  86. data/lib/ccs/components/govuk/field/inputs/date_input/item.rb +0 -65
  87. data/lib/ccs/components/govuk/field/inputs/date_input.rb +0 -89
  88. data/lib/ccs/components/govuk/field/inputs/item/checkbox/form.rb +0 -47
  89. data/lib/ccs/components/govuk/field/inputs/item/checkbox/tag.rb +0 -43
  90. data/lib/ccs/components/govuk/field/inputs/item/checkbox.rb +0 -50
  91. data/lib/ccs/components/govuk/field/inputs/item/divider.rb +0 -50
  92. data/lib/ccs/components/govuk/field/inputs/item/radio/form.rb +0 -44
  93. data/lib/ccs/components/govuk/field/inputs/item/radio/tag.rb +0 -43
  94. data/lib/ccs/components/govuk/field/inputs/item/radio.rb +0 -50
  95. data/lib/ccs/components/govuk/field/inputs/item.rb +0 -111
  96. data/lib/ccs/components/govuk/field/inputs/radios.rb +0 -69
  97. data/lib/ccs/components/govuk/field/inputs.rb +0 -57
  98. data/lib/ccs/components/govuk/field.rb +0 -108
  99. data/lib/ccs/components/govuk/fieldset/legend.rb +0 -65
  100. data/lib/ccs/components/govuk/fieldset.rb +0 -54
  101. data/lib/ccs/components/govuk/footer/link.rb +0 -55
  102. data/lib/ccs/components/govuk/footer/meta.rb +0 -59
  103. data/lib/ccs/components/govuk/footer/navigation.rb +0 -60
  104. data/lib/ccs/components/govuk/footer.rb +0 -131
  105. data/lib/ccs/components/govuk/form_group.rb +0 -60
  106. data/lib/ccs/components/govuk/header/link.rb +0 -56
  107. data/lib/ccs/components/govuk/header/navigation.rb +0 -71
  108. data/lib/ccs/components/govuk/header.rb +0 -107
  109. data/lib/ccs/components/govuk/hint.rb +0 -49
  110. data/lib/ccs/components/govuk/inset_text.rb +0 -52
  111. data/lib/ccs/components/govuk/label.rb +0 -85
  112. data/lib/ccs/components/govuk/notification_banner.rb +0 -107
  113. data/lib/ccs/components/govuk/pagination/increment/next.rb +0 -44
  114. data/lib/ccs/components/govuk/pagination/increment/previous.rb +0 -43
  115. data/lib/ccs/components/govuk/pagination/increment.rb +0 -98
  116. data/lib/ccs/components/govuk/pagination/item/ellipsis.rb +0 -28
  117. data/lib/ccs/components/govuk/pagination/item/form.rb +0 -49
  118. data/lib/ccs/components/govuk/pagination/item/tag.rb +0 -47
  119. data/lib/ccs/components/govuk/pagination/item.rb +0 -64
  120. data/lib/ccs/components/govuk/pagination.rb +0 -96
  121. data/lib/ccs/components/govuk/panel.rb +0 -62
  122. data/lib/ccs/components/govuk/phase_banner.rb +0 -69
  123. data/lib/ccs/components/govuk/skip_link.rb +0 -51
  124. data/lib/ccs/components/govuk/step_by_step_navigation/section/content/list/item.rb +0 -53
  125. data/lib/ccs/components/govuk/step_by_step_navigation/section/content/list.rb +0 -50
  126. data/lib/ccs/components/govuk/step_by_step_navigation/section/content/paragraph.rb +0 -45
  127. data/lib/ccs/components/govuk/step_by_step_navigation/section/content.rb +0 -63
  128. data/lib/ccs/components/govuk/step_by_step_navigation/section/heading.rb +0 -69
  129. data/lib/ccs/components/govuk/step_by_step_navigation/section.rb +0 -56
  130. data/lib/ccs/components/govuk/step_by_step_navigation.rb +0 -59
  131. data/lib/ccs/components/govuk/summary_list/action/link.rb +0 -59
  132. data/lib/ccs/components/govuk/summary_list/card/actions.rb +0 -59
  133. data/lib/ccs/components/govuk/summary_list/card/title.rb +0 -51
  134. data/lib/ccs/components/govuk/summary_list/card.rb +0 -63
  135. data/lib/ccs/components/govuk/summary_list/row/actions.rb +0 -59
  136. data/lib/ccs/components/govuk/summary_list/row/key.rb +0 -47
  137. data/lib/ccs/components/govuk/summary_list/row/value.rb +0 -47
  138. data/lib/ccs/components/govuk/summary_list/row.rb +0 -67
  139. data/lib/ccs/components/govuk/summary_list.rb +0 -74
  140. data/lib/ccs/components/govuk/table/body/data_cell.rb +0 -53
  141. data/lib/ccs/components/govuk/table/body/head_cell.rb +0 -52
  142. data/lib/ccs/components/govuk/table/header/head_cell.rb +0 -54
  143. data/lib/ccs/components/govuk/table.rb +0 -111
  144. data/lib/ccs/components/govuk/tabs/panel.rb +0 -58
  145. data/lib/ccs/components/govuk/tabs/tab.rb +0 -56
  146. data/lib/ccs/components/govuk/tabs.rb +0 -66
  147. data/lib/ccs/components/govuk/tag.rb +0 -51
  148. data/lib/ccs/components/govuk/warning_text.rb +0 -61
  149. data/lib/ccs/frontend_helpers/ccs_frontend/dashboard_section.rb +0 -27
  150. data/lib/ccs/frontend_helpers/govuk_frontend/character_count.rb +0 -28
  151. data/lib/ccs/frontend_helpers/govuk_frontend/checkboxes.rb +0 -28
  152. data/lib/ccs/frontend_helpers/govuk_frontend/date_input.rb +0 -28
  153. data/lib/ccs/frontend_helpers/govuk_frontend/file_upload.rb +0 -28
  154. data/lib/ccs/frontend_helpers/govuk_frontend/input.rb +0 -28
  155. data/lib/ccs/frontend_helpers/govuk_frontend/radios.rb +0 -28
  156. data/lib/ccs/frontend_helpers/govuk_frontend/select.rb +0 -28
  157. data/lib/ccs/frontend_helpers/govuk_frontend/textarea.rb +0 -28
@@ -1,69 +0,0 @@
1
- require_relative '../base'
2
- require_relative 'tag'
3
-
4
- module CCS
5
- module Components
6
- module GovUK
7
- # = GOV.UK Phase banner
8
- #
9
- # This is used to generate the phase banner component from the
10
- # {https://design-system.service.gov.uk/components/phase-banner GDS - Components - Phase banner}
11
- #
12
- # @!attribute [r] text
13
- # @return [String] Text for the phase banner
14
- # @!attribute [r] tag_options
15
- # @return [Hash] Options for the phase banner tag
16
-
17
- class PhaseBanner < Base
18
- private
19
-
20
- attr_reader :text, :tag_options
21
-
22
- public
23
-
24
- # @param tag_options [Hash] paramters for the govuk tag (see {Components::GovUK::Tag Tag}).
25
- # options are:
26
- # - +text+
27
- # - +colour+
28
- # - +options+
29
- # @param text [String] the text for the phase banner.
30
- # If nil, then a block will be rendered
31
- # @param options [Hash] options that will be used in customising the HTML
32
- #
33
- # @option options [String] :classes additional CSS classes for the phase banner HTML
34
- # @option options [Hash] :attributes ({}) any additional attributes that will added as part of the HTML
35
-
36
- def initialize(tag_options:, text: nil, **options)
37
- super(**options)
38
-
39
- tag_options[:classes] = "govuk-phase-banner__content__tag #{tag_options[:classes]}".rstrip
40
- tag_options[:context] = @context
41
-
42
- @text = text
43
- @tag_options = tag_options
44
- end
45
-
46
- # Generates the HTML for the GOV.UK Phase banner component
47
- #
48
- # @yield HTML that will be used in the phase banner. Ignored if text is passed.
49
- #
50
- # @return [ActiveSupport::SafeBuffer]
51
-
52
- def render
53
- tag.div(**options[:attributes]) do
54
- tag.p(class: 'govuk-phase-banner__content') do
55
- concat(Tag.new(**tag_options).render)
56
- concat(tag.span(class: 'govuk-phase-banner__text') do
57
- text || yield
58
- end)
59
- end
60
- end
61
- end
62
-
63
- # The default attributes for the phase banner
64
-
65
- DEFAULT_ATTRIBUTES = { class: 'govuk-phase-banner' }.freeze
66
- end
67
- end
68
- end
69
- end
@@ -1,51 +0,0 @@
1
- require_relative '../base'
2
-
3
- module CCS
4
- module Components
5
- module GovUK
6
- # = GOV.UK Skip Link
7
- #
8
- # This is used to generate the skip link component from the
9
- # {https://design-system.service.gov.uk/components/skip-link GDS - Components - Skip link}
10
- #
11
- # @!attribute [r] text
12
- # @return [String] Text for the skip link
13
- # @!attribute [r] href
14
- # @return [String] The href for the skip link
15
-
16
- class SkipLink < Base
17
- private
18
-
19
- attr_reader :text, :href
20
-
21
- public
22
-
23
- # @param text [String] the text for the skip link
24
- # @param href [String] the href for the skip link
25
- # @param options [Hash] options that will be used in customising the HTML
26
- #
27
- # @option options [String] :classes additional CSS classes for the skip link HTML
28
- # @option options [Hash] :attributes ({}) any additional attributes that will added as part of the HTML
29
-
30
- def initialize(text:, href: nil, **options)
31
- super(**options)
32
-
33
- @text = text
34
- @href = href || '#content'
35
- end
36
-
37
- # Generates the HTML for the GOV.UK Skip link component
38
- #
39
- # @return [ActiveSupport::SafeBuffer]
40
-
41
- def render
42
- link_to(text, href, **options[:attributes])
43
- end
44
-
45
- # The default attributes for the skip link
46
-
47
- DEFAULT_ATTRIBUTES = { class: 'govuk-skip-link', data: { module: 'govuk-skip-link' } }.freeze
48
- end
49
- end
50
- end
51
- end
@@ -1,53 +0,0 @@
1
- require 'action_view'
2
-
3
- module CCS
4
- module Components
5
- module GovUK
6
- class StepByStepNavigation < Base
7
- class Section < Base
8
- class Content
9
- class List
10
- # = GOV.UK Step by step navigation section content list item
11
- #
12
- # Generates the list item HTML for the step by step navigation section content
13
- #
14
- # @!attribute [r] text
15
- # @return [String] Text for the list item
16
- # @!attribute [r] classes
17
- # @return [String] HTML classes for the list item
18
-
19
- class Item
20
- include ActionView::Context
21
- include ActionView::Helpers
22
-
23
- private
24
-
25
- attr_reader :text, :classes
26
-
27
- public
28
-
29
- # @param text [String] the text for the list item
30
- # @param no_marker [Boolean] flag to hide the bullet marker
31
-
32
- def initialize(text:, no_marker: nil)
33
- @text = text
34
- @classes = "gem-c-step-nav__list-item js-list-item #{'gem-c-step-nav__list--no-marker' if no_marker}".rstrip
35
- end
36
-
37
- # Generates the HTML for an individual the GOV.UK Step by step navigation list item
38
- #
39
- # @return [ActiveSupport::SafeBuffer]
40
-
41
- def render
42
- tag.li(class: classes) do
43
- tag.span(text)
44
- end
45
- end
46
- end
47
- end
48
- end
49
- end
50
- end
51
- end
52
- end
53
- end
@@ -1,50 +0,0 @@
1
- require 'action_view'
2
-
3
- require_relative 'list/item'
4
-
5
- module CCS
6
- module Components
7
- module GovUK
8
- class StepByStepNavigation < Base
9
- class Section < Base
10
- class Content
11
- # = GOV.UK Step by step navigation section content list
12
- #
13
- # Generates the list HTML for the step by step navigation section content
14
- #
15
- # @!attribute [r] items
16
- # @return [Item] Array of initialised list items
17
-
18
- class List
19
- include ActionView::Context
20
- include ActionView::Helpers
21
-
22
- private
23
-
24
- attr_reader :items
25
-
26
- public
27
-
28
- # @param items [Array<Hash>] An array of options for the list items
29
- # See {Components::GovUK::StepByStepNavigation::Section::Content::List::Item#initialize Item#initialize} for details of the items in the array.
30
-
31
- def initialize(items:)
32
- @items = items.map { |item| Item.new(**item) }
33
- end
34
-
35
- # Generates the HTML for the GOV.UK Step by step navigation section content list
36
- #
37
- # @return [ActiveSupport::SafeBuffer]
38
-
39
- def render
40
- tag.ul(class: 'gem-c-step-nav__list gem-c-step-nav__list--choice', data: { length: items.length.to_s }) do
41
- items.each { |item| concat(item.render) }
42
- end
43
- end
44
- end
45
- end
46
- end
47
- end
48
- end
49
- end
50
- end
@@ -1,45 +0,0 @@
1
- require 'action_view'
2
-
3
- module CCS
4
- module Components
5
- module GovUK
6
- class StepByStepNavigation < Base
7
- class Section < Base
8
- class Content
9
- # = GOV.UK Step by step navigation section content paragraph
10
- #
11
- # Generates the paragraph HTML for the step by step navigation section content
12
- #
13
- # @!attribute [r] text
14
- # @return [String] Text for the paragraph
15
-
16
- class Paragraph
17
- include ActionView::Context
18
- include ActionView::Helpers
19
-
20
- private
21
-
22
- attr_reader :text
23
-
24
- public
25
-
26
- # @param text [String] the text for the paragraph
27
-
28
- def initialize(text:)
29
- @text = text
30
- end
31
-
32
- # Generates the HTML for the GOV.UK Step by step navigation section content paragraph
33
- #
34
- # @return [ActiveSupport::SafeBuffer]
35
-
36
- def render
37
- tag.p(text, class: 'gem-c-step-nav__paragraph')
38
- end
39
- end
40
- end
41
- end
42
- end
43
- end
44
- end
45
- end
@@ -1,63 +0,0 @@
1
- require 'action_view'
2
-
3
- require_relative 'content/list'
4
- require_relative 'content/paragraph'
5
-
6
- module CCS
7
- module Components
8
- module GovUK
9
- class StepByStepNavigation < Base
10
- class Section < Base
11
- # = GOV.UK Step by step navigation section content
12
- #
13
- # The content for a navigation section
14
- #
15
- # @!attribute [r] section_id
16
- # @return [String] ID for the section content
17
- # @!attribute [r] content_items
18
- # @return [Array<Paragraph|List>] An array of the initialised content items
19
-
20
- class Content
21
- include ActionView::Context
22
- include ActionView::Helpers
23
-
24
- private
25
-
26
- attr_reader :section_id, :content_items
27
-
28
- public
29
-
30
- # @param content_items [Array<Hash>] array of content items.
31
- # If the type is +:paragraph+, see {Components::GovUK::StepByStepNavigation::Section::Content::Paragraph#initialize Paragraph#initialize}.
32
- # If the type is +:list+, see {Components::GovUK::StepByStepNavigation::Section::Content::List#initialize List#initialize}.
33
- # @param index [String] the index of the section
34
- # @param id [String] the id of the section
35
-
36
- def initialize(content_items:, index:, id:)
37
- @section_id = "step-panel-#{id}-#{index}"
38
-
39
- @content_items = content_items.map do |content_item|
40
- case content_item[:type]
41
- when :paragraph
42
- Paragraph.new(text: content_item[:text])
43
- when :list
44
- List.new(items: content_item[:items])
45
- end
46
- end
47
- end
48
-
49
- # Generates the HTML for the GOV.UK Step by step navigation section content
50
- #
51
- # @return [ActiveSupport::SafeBuffer]
52
-
53
- def render
54
- tag.div(class: 'gem-c-step-nav__panel js-panel', id: section_id) do
55
- content_items.each { |content_item| concat(content_item.render) }
56
- end
57
- end
58
- end
59
- end
60
- end
61
- end
62
- end
63
- end
@@ -1,69 +0,0 @@
1
- require 'action_view'
2
-
3
- module CCS
4
- module Components
5
- module GovUK
6
- class StepByStepNavigation < Base
7
- class Section < Base
8
- # = GOV.UK Step by step navigation section heading
9
- #
10
- # The heading for a navigation section
11
- #
12
- # @!attribute [r] text
13
- # @return [String] Text for the section heading
14
- # @!attribute [r] index
15
- # @return [String] Index of the section
16
- # @!attribute [r] logic
17
- # @return [String] Optional text to show in the sidebar
18
-
19
- class Heading
20
- include ActionView::Context
21
- include ActionView::Helpers
22
-
23
- private
24
-
25
- attr_reader :text, :index, :logic
26
-
27
- public
28
-
29
- # @param text [String] text for the section heading
30
- # @param index [String] the index of the section
31
- # @param logic [String] text to show instead of a number in the sidebar
32
-
33
- def initialize(text:, index:, logic: nil)
34
- @text = text
35
- @index = index
36
- @logic = logic
37
- end
38
-
39
- # rubocop:disable Metrics/AbcSize
40
-
41
- # Generates the HTML for the GOV.UK Step by step navigation section heading
42
- #
43
- # @return [ActiveSupport::SafeBuffer]
44
-
45
- def render
46
- tag.div(class: 'gem-c-step-nav__header js-toggle-panel', data: { position: index }) do
47
- tag.h2(class: 'gem-c-step-nav__title') do
48
- concat(tag.span(class: "gem-c-step-nav__circle gem-c-step-nav__circle--#{logic ? 'logic' : 'number'}") do
49
- tag.span(class: 'gem-c-step-nav__circle-inner') do
50
- tag.span(class: 'gem-c-step-nav__circle-background') do
51
- concat(tag.span('Step', class: 'govuk-visually-hidden'))
52
- concat(logic || index)
53
- end
54
- end
55
- end)
56
- concat(tag.span(class: 'js-step-title') do
57
- tag.span(text, class: 'js-step-title-text')
58
- end)
59
- end
60
- end
61
- end
62
-
63
- # rubocop:enable Metrics/AbcSize
64
- end
65
- end
66
- end
67
- end
68
- end
69
- end
@@ -1,56 +0,0 @@
1
- require_relative '../../base'
2
- require_relative 'section/heading'
3
- require_relative 'section/content'
4
-
5
- module CCS
6
- module Components
7
- module GovUK
8
- class StepByStepNavigation < Base
9
- # = GOV.UK Step by step navigation section
10
- #
11
- # The individual section for the step by step navigation
12
- #
13
- # @!attribute [r] heading
14
- # @return [Heading] Initialised heading for the section
15
- # @!attribute [r] content
16
- # @return [Content] Initialised content for the section
17
-
18
- class Section < Base
19
- private
20
-
21
- attr_reader :heading, :content
22
-
23
- public
24
-
25
- # @param heading [Hash] options for the section heading.
26
- # See {Components::GovUK::StepByStepNavigation::Section::Heading#initialize Heading#initialize} for details of the options.
27
- # @param content [Hash] options for the section content.
28
- # See {Components::GovUK::StepByStepNavigation::Section::Content#initialize Content#initialize} for details of the options.
29
- # @param index [String] the index of the section
30
- # @param context [ActionView::Base] the view context
31
-
32
- def initialize(heading:, content:, index:, context:)
33
- super(context: context)
34
-
35
- @options[:attributes][:class] = 'gem-c-step-nav__step js-step'
36
- @options[:attributes][:id] = heading[:text].downcase.gsub(' ', '-').gsub('(', '').gsub(')', '')
37
-
38
- @heading = Heading.new(index: index, **heading)
39
- @content = Content.new(content_items: content, index: index, id: @options[:attributes][:id])
40
- end
41
-
42
- # Generates the HTML for the GOV.UK Step by step navigation section
43
- #
44
- # @return [ActiveSupport::SafeBuffer]
45
-
46
- def render
47
- tag.li(class: @options[:attributes][:class], id: @options[:attributes][:id]) do
48
- concat(heading.render)
49
- concat(content.render)
50
- end
51
- end
52
- end
53
- end
54
- end
55
- end
56
- end
@@ -1,59 +0,0 @@
1
- require_relative '../base'
2
- require_relative 'step_by_step_navigation/section'
3
-
4
- module CCS
5
- module Components
6
- module GovUK
7
- # = GOV.UK Step by step navigation
8
- #
9
- # This is used for generating the Step by step navigation component from the
10
- # {https://design-system.service.gov.uk/patterns/step-by-step-navigation/ GDS - Pages - Step by step navigation}
11
- #
12
- # @!attribute [r] step_by_step_navigation_sections
13
- # @return [Array<Section>] An array of the initialised step by step navigation sections
14
-
15
- class StepByStepNavigation < Base
16
- private
17
-
18
- attr_reader :step_by_step_navigation_sections
19
-
20
- public
21
-
22
- # @param step_by_step_navigation_sections [Array<Hash>] An array of options for the step by step navigation section.
23
- # See {Components::GovUK::StepByStepNavigation::Section#initialize Section#initialize} for details of the items in the array.
24
- # @param options [Hash] options that will be used in customising the HTML
25
- #
26
- # @option options [String] :classes additional CSS classes for the step by step navigation HTML
27
- # @option options [Hash] :attributes ({}) any additional attributes that will added as part of the HTML
28
-
29
- def initialize(step_by_step_navigation_sections:, **options)
30
- super(**options)
31
-
32
- DEFAULT_SHOW_HIDE_TEXT.each { |key, value| @options[:attributes][:data][key] ||= value }
33
-
34
- @step_by_step_navigation_sections = step_by_step_navigation_sections.map.with_index(1) { |step_by_step_section, index| Section.new(index: index.to_s, context: @context, **step_by_step_section) }
35
- end
36
-
37
- # Generates the HTML for the GOV.UK Step by step navigation component (experimental)
38
- #
39
- # @return [ActiveSupport::SafeBuffer]
40
-
41
- def render
42
- tag.div(**options[:attributes]) do
43
- tag.ol(class: 'gem-c-step-nav__steps') do
44
- step_by_step_navigation_sections.each { |step_by_step_navigation_section| concat(step_by_step_navigation_section.render) }
45
- end
46
- end
47
- end
48
-
49
- # The default attributes for the step byt step navigation
50
-
51
- DEFAULT_ATTRIBUTES = { class: 'gem-c-step-nav gem-c-step-nav--large gem-c-step-nav--active', data: { module: 'govuk-step-by-step-navigation' } }.freeze
52
-
53
- # Default text for the show and hide buttons which are part of each section
54
-
55
- DEFAULT_SHOW_HIDE_TEXT = { 'show-text': 'Show', 'hide-text': 'Hide', 'show-all-text': 'Show all', 'hide-all-text': 'Hide all' }.freeze
56
- end
57
- end
58
- end
59
- end
@@ -1,59 +0,0 @@
1
- require_relative '../../../base'
2
-
3
- module CCS
4
- module Components
5
- module GovUK
6
- class SummaryList < Base
7
- class Action
8
- # = GOV.UK Summary list action link
9
- #
10
- # @!attribute [r] text
11
- # @return [String] Text for the action link
12
- # @!attribute [r] href
13
- # @return [String] The href for the action link
14
- # @!attribute [r] visually_hidden_text
15
- # @return [String] Visually hidden text for the action link
16
-
17
- class Link < Base
18
- private
19
-
20
- attr_reader :text, :href, :visually_hidden_text
21
-
22
- public
23
-
24
- # @param text [String] the text for the action link
25
- # @param href [String] the href for the action link
26
- # @param visually_hidden_text [String] optional visually hidden text for the action link
27
- # @param options [Hash] options that will be used in customising the HTML
28
- #
29
- # @option options [String] :classes additional CSS classes for the summary list action link HTML
30
- # @option options [Hash] :attributes any additional attributes that will added as part of the HTML
31
-
32
- def initialize(text:, href:, visually_hidden_text: nil, **options)
33
- super(**options)
34
-
35
- @text = text
36
- @href = href
37
- @visually_hidden_text = visually_hidden_text
38
- end
39
-
40
- # Generates the HTML for the GOV.UK Summary list action link
41
- #
42
- # @return [ActiveSupport::SafeBuffer]
43
-
44
- def render
45
- link_to(href, **@options[:attributes]) do
46
- concat(text)
47
- concat(tag.span(visually_hidden_text, class: 'govuk-visually-hidden')) if visually_hidden_text
48
- end
49
- end
50
-
51
- # The default attributes for the summary list action link
52
-
53
- DEFAULT_ATTRIBUTES = { class: 'govuk-link' }.freeze
54
- end
55
- end
56
- end
57
- end
58
- end
59
- end
@@ -1,59 +0,0 @@
1
- require_relative '../../../base'
2
- require_relative '../action/link'
3
-
4
- module CCS
5
- module Components
6
- module GovUK
7
- class SummaryList < Base
8
- class Card < Base
9
- # = GOV.UK Summary list card actions
10
- #
11
- # @!attribute [r] action_links
12
- # @return [Array<Action::Link>] An array of the initialised aummary list card action links
13
-
14
- class Actions < Base
15
- private
16
-
17
- attr_reader :action_links
18
-
19
- public
20
-
21
- # @param items [Array<Hash>] An array of attributes for the action links.
22
- # See {Components::GovUK::SummaryList::Action::Link#initialize Action::Link#initialize} for details of the items in the array.
23
- # @param options [Hash] options that will be used in customising the HTML
24
- #
25
- # @option options [String] :classes additional CSS classes for the summary list card actions HTML
26
-
27
- def initialize(items:, **options)
28
- super(**options)
29
-
30
- @action_links = items.map { |item| Action::Link.new(context: @context, **item) }
31
- end
32
-
33
- # Generates the HTML for the GOV.UK Summary list card actions
34
- #
35
- # @return [ActiveSupport::SafeBuffer]
36
-
37
- def render
38
- if action_links.length == 1
39
- tag.div(class: @options[:attributes][:class]) do
40
- action_links.first.render
41
- end
42
- else
43
- tag.ul(class: @options[:attributes][:class]) do
44
- action_links.each do |action_link|
45
- concat(tag.li(action_link.render, class: 'govuk-summary-card__action'))
46
- end
47
- end
48
- end
49
- end
50
-
51
- # The default attributes for the summary list card actions
52
-
53
- DEFAULT_ATTRIBUTES = { class: 'govuk-summary-card__actions' }.freeze
54
- end
55
- end
56
- end
57
- end
58
- end
59
- end
@@ -1,51 +0,0 @@
1
- require_relative '../../../base'
2
-
3
- module CCS
4
- module Components
5
- module GovUK
6
- class SummaryList < Base
7
- class Card < Base
8
- # = GOV.UK Summary list card title
9
- #
10
- # @!attribute [r] text
11
- # @return [String] Text for the title
12
- # @!attribute [r] heading_level
13
- # @return [String] Heading level for the title
14
-
15
- class Title < Base
16
- private
17
-
18
- attr_reader :text, :heading_level
19
-
20
- public
21
-
22
- # @param text [String] the text for the title
23
- # @param heading_level [String] heading level, from 1 to 6
24
- # @param options [Hash] options that will be used in customising the HTML
25
- #
26
- # @option options [String] :classes additional CSS classes for the summary list card title HTML
27
-
28
- def initialize(text:, heading_level: '2', **options)
29
- super(**options)
30
-
31
- @text = text
32
- @heading_level = heading_level
33
- end
34
-
35
- # Generates the HTML for the GOV.UK Summary list card title
36
- #
37
- # @return [ActiveSupport::SafeBuffer]
38
-
39
- def render
40
- tag.send("h#{heading_level}", text, class: @options[:attributes][:class])
41
- end
42
-
43
- # The default attributes for the summary list card title
44
-
45
- DEFAULT_ATTRIBUTES = { class: 'govuk-summary-card__title' }.freeze
46
- end
47
- end
48
- end
49
- end
50
- end
51
- end