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

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