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,57 +1,59 @@
1
1
  require_relative '../base'
2
2
  require_relative 'step_by_step_navigation/section'
3
3
 
4
- module CCS::Components
5
- module GovUK
6
- # = GOV.UK Step by step navigation
7
- #
8
- # This is used for generating the Step by step navigation component from the
9
- # {https://design-system.service.gov.uk/patterns/step-by-step-navigation/ GDS - Pages - Step by step navigation}
10
- #
11
- # @!attribute [r] step_by_step_navigation_sections
12
- # @return [Array<Section>] An array of the initialised step by step navigation sections
13
-
14
- class StepByStepNavigation < Base
15
- private
16
-
17
- attr_reader :step_by_step_navigation_sections
18
-
19
- public
20
-
21
- # @param step_by_step_navigation_sections [Array<Hash>] An array of options for the step by step navigation section.
22
- # See {Components::GovUK::StepByStepNavigation::Section#initialize Section#initialize} for details of the items in the array.
23
- # @param options [Hash] options that will be used in customising the HTML
4
+ module CCS
5
+ module Components
6
+ module GovUK
7
+ # = GOV.UK Step by step navigation
24
8
  #
25
- # @option options [String] :classes additional CSS classes for the step by step navigation HTML
26
- # @option options [Hash] :attributes ({}) any additional attributes that will added as part of the HTML
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
27
14
 
28
- def initialize(step_by_step_navigation_sections:, **options)
29
- super(**options)
15
+ class StepByStepNavigation < Base
16
+ private
30
17
 
31
- DEFAULT_SHOW_HIDE_TEXT.each { |key, value| @options[:attributes][:data][key] ||= value }
18
+ attr_reader :step_by_step_navigation_sections
32
19
 
33
- @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) }
34
- end
20
+ public
35
21
 
36
- # Generates the HTML for the GOV.UK Step by step navigation component (experimental)
37
- #
38
- # @return [ActiveSupport::SafeBuffer]
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 }
39
33
 
40
- def render
41
- tag.div(**options[:attributes]) do
42
- tag.ol(class: 'gem-c-step-nav__steps') do
43
- step_by_step_navigation_sections.each { |step_by_step_navigation_section| concat(step_by_step_navigation_section.render) }
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
44
46
  end
45
47
  end
46
- end
47
48
 
48
- # The default attributes for the step byt step navigation
49
+ # The default attributes for the step byt step navigation
49
50
 
50
- 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
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
51
52
 
52
- # Default text for the show and hide buttons which are part of each section
53
+ # Default text for the show and hide buttons which are part of each section
53
54
 
54
- DEFAULT_SHOW_HIDE_TEXT = { 'show-text': 'Show', 'hide-text': 'Hide', 'show-all-text': 'Show all', 'hide-all-text': 'Hide all' }.freeze
55
+ DEFAULT_SHOW_HIDE_TEXT = { 'show-text': 'Show', 'hide-text': 'Hide', 'show-all-text': 'Show all', 'hide-all-text': 'Hide all' }.freeze
56
+ end
55
57
  end
56
58
  end
57
59
  end
@@ -1,55 +1,57 @@
1
1
  require_relative '../../../base'
2
2
 
3
- module CCS::Components
4
- module GovUK
5
- class SummaryList < Base
6
- class Action
7
- # = GOV.UK Summary list action link
8
- #
9
- # @!attribute [r] text
10
- # @return [String] Text for the action link
11
- # @!attribute [r] href
12
- # @return [String] The href for the action link
13
- # @!attribute [r] visually_hidden_text
14
- # @return [String] Visually hidden text for the action link
15
-
16
- class Link < Base
17
- private
18
-
19
- attr_reader :text, :href, :visually_hidden_text
20
-
21
- public
22
-
23
- # @param text [String] the text for the action link
24
- # @param href [String] the href for the action link
25
- # @param visually_hidden_text [String] optional visually hidden text for the action link
26
- # @param options [Hash] options that will be used in customising the HTML
3
+ module CCS
4
+ module Components
5
+ module GovUK
6
+ class SummaryList < Base
7
+ class Action
8
+ # = GOV.UK Summary list action link
27
9
  #
28
- # @option options [String] :classes additional CSS classes for the summary list action link HTML
29
- # @option options [Hash] :attributes any additional attributes that will added as part of the HTML
30
-
31
- def initialize(text:, href:, visually_hidden_text: nil, **options)
32
- super(**options)
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
33
39
 
34
- @text = text
35
- @href = href
36
- @visually_hidden_text = visually_hidden_text
37
- end
40
+ # Generates the HTML for the GOV.UK Summary list action link
41
+ #
42
+ # @return [ActiveSupport::SafeBuffer]
38
43
 
39
- # Generates the HTML for the GOV.UK Summary list action link
40
- #
41
- # @return [ActiveSupport::SafeBuffer]
42
-
43
- def render
44
- link_to(href, **@options[:attributes]) do
45
- concat(text)
46
- concat(tag.span(visually_hidden_text, class: 'govuk-visually-hidden')) if visually_hidden_text
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
47
49
  end
48
- end
49
50
 
50
- # The default attributes for the summary list action link
51
+ # The default attributes for the summary list action link
51
52
 
52
- DEFAULT_ATTRIBUTES = { class: 'govuk-link' }.freeze
53
+ DEFAULT_ATTRIBUTES = { class: 'govuk-link' }.freeze
54
+ end
53
55
  end
54
56
  end
55
57
  end
@@ -1,55 +1,57 @@
1
1
  require_relative '../../../base'
2
2
  require_relative '../action/link'
3
3
 
4
- module CCS::Components
5
- module GovUK
6
- class SummaryList < Base
7
- class Card < Base
8
- # = GOV.UK Summary list card actions
9
- #
10
- # @!attribute [r] action_links
11
- # @return [Array<Action::Link>] An array of the initialised aummary list card action links
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
12
13
 
13
- class Actions < Base
14
- private
14
+ class Actions < Base
15
+ private
15
16
 
16
- attr_reader :action_links
17
+ attr_reader :action_links
17
18
 
18
- public
19
+ public
19
20
 
20
- # @param items [Array<Hash>] An array of attributes for the action links.
21
- # See {Components::GovUK::SummaryList::Action::Link#initialize Action::Link#initialize} for details of the items in the array.
22
- # @param options [Hash] options that will be used in customising the HTML
23
- #
24
- # @option options [String] :classes additional CSS classes for the summary list card actions HTML
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
25
26
 
26
- def initialize(items:, **options)
27
- super(**options)
27
+ def initialize(items:, **options)
28
+ super(**options)
28
29
 
29
- @action_links = items.map { |item| Action::Link.new(context: @context, **item) }
30
- end
30
+ @action_links = items.map { |item| Action::Link.new(context: @context, **item) }
31
+ end
31
32
 
32
- # Generates the HTML for the GOV.UK Summary list card actions
33
- #
34
- # @return [ActiveSupport::SafeBuffer]
33
+ # Generates the HTML for the GOV.UK Summary list card actions
34
+ #
35
+ # @return [ActiveSupport::SafeBuffer]
35
36
 
36
- def render
37
- if action_links.length == 1
38
- tag.div(class: @options[:attributes][:class]) do
39
- action_links.first.render
40
- end
41
- else
42
- tag.ul(class: @options[:attributes][:class]) do
43
- action_links.each do |action_link|
44
- concat(tag.li(action_link.render, class: 'govuk-summary-card__action'))
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
45
47
  end
46
48
  end
47
49
  end
48
- end
49
50
 
50
- # The default attributes for the summary list card actions
51
+ # The default attributes for the summary list card actions
51
52
 
52
- DEFAULT_ATTRIBUTES = { class: 'govuk-summary-card__actions' }.freeze
53
+ DEFAULT_ATTRIBUTES = { class: 'govuk-summary-card__actions' }.freeze
54
+ end
53
55
  end
54
56
  end
55
57
  end
@@ -1,47 +1,49 @@
1
1
  require_relative '../../../base'
2
2
 
3
- module CCS::Components
4
- module GovUK
5
- class SummaryList < Base
6
- class Card < Base
7
- # = GOV.UK Summary list card title
8
- #
9
- # @!attribute [r] text
10
- # @return [String] Text for the title
11
- # @!attribute [r] heading_level
12
- # @return [String] Heading level for the title
13
-
14
- class Title < Base
15
- private
16
-
17
- attr_reader :text, :heading_level
18
-
19
- public
20
-
21
- # @param text [String] the text for the title
22
- # @param heading_level [String] heading level, from 1 to 6
23
- # @param options [Hash] options that will be used in customising the HTML
3
+ module CCS
4
+ module Components
5
+ module GovUK
6
+ class SummaryList < Base
7
+ class Card < Base
8
+ # = GOV.UK Summary list card title
24
9
  #
25
- # @option options [String] :classes additional CSS classes for the summary list card title HTML
10
+ # @!attribute [r] text
11
+ # @return [String] Text for the title
12
+ # @!attribute [r] heading_level
13
+ # @return [String] Heading level for the title
26
14
 
27
- def initialize(text:, heading_level: '2', **options)
28
- super(**options)
15
+ class Title < Base
16
+ private
29
17
 
30
- @text = text
31
- @heading_level = heading_level
32
- end
18
+ attr_reader :text, :heading_level
33
19
 
34
- # Generates the HTML for the GOV.UK Summary list card title
35
- #
36
- # @return [ActiveSupport::SafeBuffer]
20
+ public
37
21
 
38
- def render
39
- tag.send("h#{heading_level}", text, class: @options[:attributes][:class])
40
- end
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)
41
30
 
42
- # The default attributes for the summary list card title
31
+ @text = text
32
+ @heading_level = heading_level
33
+ end
43
34
 
44
- DEFAULT_ATTRIBUTES = { class: 'govuk-summary-card__title' }.freeze
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
45
47
  end
46
48
  end
47
49
  end
@@ -2,59 +2,61 @@ require_relative '../../base'
2
2
  require_relative 'card/title'
3
3
  require_relative 'card/actions'
4
4
 
5
- module CCS::Components
6
- module GovUK
7
- class SummaryList < Base
8
- # = GOV.UK Summary card
9
- #
10
- # This is used for generating the summary cards component from the
11
- # {https://design-system.service.gov.uk/components/summary-list/#summary-cards GDS - Components - Summary cards}
12
- #
13
- # @!attribute [r] title
14
- # @return [Title] Initialised summary card title
15
- # @!attribute [r] actions
16
- # @return [Actions] Initialised summary card actions
17
-
18
- class Card < Base
19
- private
20
-
21
- attr_reader :title, :actions
22
-
23
- public
24
-
25
- # @param title [Hash] attributes for the title, see {CCS::Components::GovUK::SummaryList::Card::Title#initialize Title#initialize} for more details.
26
- # @param actions [Hash] attributes for the actions, see {CCS::Components::GovUK::SummaryList::Card::Actions#initialize Actions#initialize} for more details.
27
- # @param options [Hash] options that will be used in customising the HTML
5
+ module CCS
6
+ module Components
7
+ module GovUK
8
+ class SummaryList < Base
9
+ # = GOV.UK Summary card
28
10
  #
29
- # @option options [String] :classes additional CSS classes for the summary card HTML
30
- # @option options [Hash] :attributes any additional attributes that will be added as part of the HTML
11
+ # This is used for generating the summary cards component from the
12
+ # {https://design-system.service.gov.uk/components/summary-list/#summary-cards GDS - Components - Summary cards}
13
+ #
14
+ # @!attribute [r] title
15
+ # @return [Title] Initialised summary card title
16
+ # @!attribute [r] actions
17
+ # @return [Actions] Initialised summary card actions
31
18
 
32
- def initialize(title: nil, actions: nil, **options)
33
- super(**options)
19
+ class Card < Base
20
+ private
34
21
 
35
- @title = Title.new(context: @context, **title) if title
36
- @actions = Actions.new(context: @context, **actions) if actions
37
- end
22
+ attr_reader :title, :actions
38
23
 
39
- # Generates the HTML for the GOV.UK Summary card
40
- #
41
- # @yield the HTML for the summary list
42
- #
43
- # @return [ActiveSupport::SafeBuffer]
44
-
45
- def render(&block)
46
- tag.div(**@options[:attributes]) do
47
- concat(tag.div(class: 'govuk-summary-card__title-wrapper') do
48
- concat(title.render) if title
49
- concat(actions.render) if actions
50
- end)
51
- concat(tag.div(class: 'govuk-summary-card__content', &block))
24
+ public
25
+
26
+ # @param title [Hash] attributes for the title, see {CCS::Components::GovUK::SummaryList::Card::Title#initialize Title#initialize} for more details.
27
+ # @param actions [Hash] attributes for the actions, see {CCS::Components::GovUK::SummaryList::Card::Actions#initialize Actions#initialize} for more details.
28
+ # @param options [Hash] options that will be used in customising the HTML
29
+ #
30
+ # @option options [String] :classes additional CSS classes for the summary card HTML
31
+ # @option options [Hash] :attributes any additional attributes that will be added as part of the HTML
32
+
33
+ def initialize(title: nil, actions: nil, **options)
34
+ super(**options)
35
+
36
+ @title = Title.new(context: @context, **title) if title
37
+ @actions = Actions.new(context: @context, **actions) if actions
52
38
  end
53
- end
54
39
 
55
- # The default attributes for the summary card
40
+ # Generates the HTML for the GOV.UK Summary card
41
+ #
42
+ # @yield the HTML for the summary list
43
+ #
44
+ # @return [ActiveSupport::SafeBuffer]
45
+
46
+ def render(&block)
47
+ tag.div(**@options[:attributes]) do
48
+ concat(tag.div(class: 'govuk-summary-card__title-wrapper') do
49
+ concat(title.render) if title
50
+ concat(actions.render) if actions
51
+ end)
52
+ concat(tag.div(class: 'govuk-summary-card__content', &block))
53
+ end
54
+ end
56
55
 
57
- DEFAULT_ATTRIBUTES = { class: 'govuk-summary-card' }.freeze
56
+ # The default attributes for the summary card
57
+
58
+ DEFAULT_ATTRIBUTES = { class: 'govuk-summary-card' }.freeze
59
+ end
58
60
  end
59
61
  end
60
62
  end
@@ -1,55 +1,57 @@
1
1
  require_relative '../../../base'
2
2
  require_relative '../action/link'
3
3
 
4
- module CCS::Components
5
- module GovUK
6
- class SummaryList < Base
7
- class Row < Base
8
- # = GOV.UK Summary list row actions
9
- #
10
- # @!attribute [r] action_links
11
- # @return [Array<Action::Link>] An array of the initialised aummary list row action links
4
+ module CCS
5
+ module Components
6
+ module GovUK
7
+ class SummaryList < Base
8
+ class Row < Base
9
+ # = GOV.UK Summary list row actions
10
+ #
11
+ # @!attribute [r] action_links
12
+ # @return [Array<Action::Link>] An array of the initialised aummary list row action links
12
13
 
13
- class Actions < Base
14
- private
14
+ class Actions < Base
15
+ private
15
16
 
16
- attr_reader :action_links
17
+ attr_reader :action_links
17
18
 
18
- public
19
+ public
19
20
 
20
- # @param items [Array<Hash>] An array of attributes for the action links.
21
- # See {Components::GovUK::SummaryList::Action::Link#initialize Action::Link#initialize} for details of the items in the array.
22
- # @param options [Hash] options that will be used in customising the HTML
23
- #
24
- # @option options [String] :classes additional CSS classes for the summary list row actions HTML
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 row actions HTML
25
26
 
26
- def initialize(items:, **options)
27
- super(**options)
27
+ def initialize(items:, **options)
28
+ super(**options)
28
29
 
29
- @action_links = items.map { |item| Action::Link.new(context: @context, **item) }
30
- end
30
+ @action_links = items.map { |item| Action::Link.new(context: @context, **item) }
31
+ end
31
32
 
32
- # Generates the HTML for the GOV.UK Summary list row actions
33
- #
34
- # @return [ActiveSupport::SafeBuffer]
35
-
36
- def render
37
- tag.dd(class: @options[:attributes][:class]) do
38
- if action_links.length == 1
39
- action_links.first.render
40
- else
41
- tag.ul(class: 'govuk-summary-list__actions-list') do
42
- action_links.each do |action_link|
43
- concat(tag.li(action_link.render, class: 'govuk-summary-list__actions-list-item'))
33
+ # Generates the HTML for the GOV.UK Summary list row actions
34
+ #
35
+ # @return [ActiveSupport::SafeBuffer]
36
+
37
+ def render
38
+ tag.dd(class: @options[:attributes][:class]) do
39
+ if action_links.length == 1
40
+ action_links.first.render
41
+ else
42
+ tag.ul(class: 'govuk-summary-list__actions-list') do
43
+ action_links.each do |action_link|
44
+ concat(tag.li(action_link.render, class: 'govuk-summary-list__actions-list-item'))
45
+ end
44
46
  end
45
47
  end
46
48
  end
47
49
  end
48
- end
49
50
 
50
- # The default attributes for the summary list row actions
51
+ # The default attributes for the summary list row actions
51
52
 
52
- DEFAULT_ATTRIBUTES = { class: 'govuk-summary-list__actions' }.freeze
53
+ DEFAULT_ATTRIBUTES = { class: 'govuk-summary-list__actions' }.freeze
54
+ end
53
55
  end
54
56
  end
55
57
  end