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,103 +1,105 @@
1
1
  require_relative '../base'
2
2
 
3
- module CCS::Components
4
- module GovUK
5
- # = GOV.UK Button
6
- #
7
- # This is used to generate the button component from the
8
- # {https://design-system.service.gov.uk/components/button GDS - Components - Button}
9
- #
10
- # @!attribute [r] text
11
- # @return [String] Text for the button
12
- # @!attribute [r] render_method
13
- # @return [String] The method that will be used to render the button
14
-
15
- class Button < Base
16
- private
17
-
18
- attr_reader :text, :render_method
19
-
20
- public
21
-
22
- # @param text [String] the text that will be shown in the button
23
- # @param options [Hash] options that will be used in customising the HTML
3
+ module CCS
4
+ module Components
5
+ module GovUK
6
+ # = GOV.UK Button
24
7
  #
25
- # @option options [String] :classes additional CSS classes for the button HTML
26
- # @option options [Boolean] :is_start_button indicates if it is a start button
27
- # @option options [String] :href the URI that will be used in anchor tag
28
- # @option options [ActionView::Helpers::FormBuilder] :form the form builder used to create the submit button
29
- # @option options [Hash] :attributes ({}) any additional attributes that will added as part of the HTML
30
-
31
- def initialize(text:, **options)
32
- super(**options)
33
-
34
- @options[:attributes][:class] << ' govuk-button--disabled' if @options[:attributes][:disabled]
35
- @options[:attributes][:class] << ' govuk-button--start' if @options[:is_start_button]
36
-
37
- @text = text
38
- @render_method = :"render_#{if @options[:href]
39
- :link
40
- elsif @options[:form]
41
- :submit
42
- else
43
- :button
44
- end}"
45
- end
46
-
47
- # Generates the HTML for the GOV.UK Back link component
8
+ # This is used to generate the button component from the
9
+ # {https://design-system.service.gov.uk/components/button GDS - Components - Button}
48
10
  #
49
- # @return [ActiveSupport::SafeBuffer]
11
+ # @!attribute [r] text
12
+ # @return [String] Text for the button
13
+ # @!attribute [r] render_method
14
+ # @return [String] The method that will be used to render the button
15
+
16
+ class Button < Base
17
+ private
18
+
19
+ attr_reader :text, :render_method
20
+
21
+ public
22
+
23
+ # @param text [String] the text that will be shown in the button
24
+ # @param options [Hash] options that will be used in customising the HTML
25
+ #
26
+ # @option options [String] :classes additional CSS classes for the button HTML
27
+ # @option options [Boolean] :is_start_button indicates if it is a start button
28
+ # @option options [String] :href the URI that will be used in anchor tag
29
+ # @option options [ActionView::Helpers::FormBuilder] :form the form builder used to create the submit button
30
+ # @option options [Hash] :attributes ({}) any additional attributes that will added as part of the HTML
31
+
32
+ def initialize(text:, **options)
33
+ super(**options)
34
+
35
+ @options[:attributes][:class] << ' govuk-button--disabled' if @options[:attributes][:disabled]
36
+ @options[:attributes][:class] << ' govuk-button--start' if @options[:is_start_button]
37
+
38
+ @text = text
39
+ @render_method = :"render_#{if @options[:href]
40
+ :link
41
+ elsif @options[:form]
42
+ :submit
43
+ else
44
+ :button
45
+ end}"
46
+ end
50
47
 
51
- def render
52
- send(@render_method)
53
- end
48
+ # Generates the HTML for the GOV.UK Back link component
49
+ #
50
+ # @return [ActiveSupport::SafeBuffer]
54
51
 
55
- # The default attributes for the button
52
+ def render
53
+ send(@render_method)
54
+ end
56
55
 
57
- DEFAULT_ATTRIBUTES = { class: 'govuk-button', data: { module: 'govuk-button' } }.freeze
56
+ # The default attributes for the button
58
57
 
59
- private
58
+ DEFAULT_ATTRIBUTES = { class: 'govuk-button', data: { module: 'govuk-button' } }.freeze
60
59
 
61
- # Generates the HTML for the GOV.UK button component as an anchor tag.
62
- #
63
- # @return [ActiveSupport::SafeBuffer]
60
+ private
61
+
62
+ # Generates the HTML for the GOV.UK button component as an anchor tag.
63
+ #
64
+ # @return [ActiveSupport::SafeBuffer]
64
65
 
65
- def render_link
66
- @options[:attributes][:role] = :button
67
- @options[:attributes][:draggable] = false
66
+ def render_link
67
+ @options[:attributes][:role] = :button
68
+ @options[:attributes][:draggable] = false
68
69
 
69
- link_to(@options[:href], **@options[:attributes]) do
70
- concat(text)
71
- concat(start_button_icon) if @options[:is_start_button]
70
+ link_to(@options[:href], **@options[:attributes]) do
71
+ concat(text)
72
+ concat(start_button_icon) if @options[:is_start_button]
73
+ end
72
74
  end
73
- end
74
75
 
75
- # Generates the HTML for the GOV.UK button component as a button.
76
- #
77
- # @return [ActiveSupport::SafeBuffer]
76
+ # Generates the HTML for the GOV.UK button component as a button.
77
+ #
78
+ # @return [ActiveSupport::SafeBuffer]
78
79
 
79
- def render_button
80
- button_tag(**@options[:attributes]) do
81
- concat(text)
82
- concat(start_button_icon) if @options[:is_start_button]
80
+ def render_button
81
+ button_tag(**@options[:attributes]) do
82
+ concat(text)
83
+ concat(start_button_icon) if @options[:is_start_button]
84
+ end
83
85
  end
84
- end
85
86
 
86
- # Generates the HTML for the GOV.UK button component as an input.
87
- #
88
- # @return [ActiveSupport::SafeBuffer]
87
+ # Generates the HTML for the GOV.UK button component as an input.
88
+ #
89
+ # @return [ActiveSupport::SafeBuffer]
89
90
 
90
- def render_submit
91
- @options[:form].submit(text, **@options[:attributes])
92
- end
91
+ def render_submit
92
+ @options[:form].submit(text, **@options[:attributes])
93
+ end
93
94
 
94
- # Generates the arrow if the button is a start button
95
- #
96
- # @return [ActiveSupport::SafeBuffer]
95
+ # Generates the arrow if the button is a start button
96
+ #
97
+ # @return [ActiveSupport::SafeBuffer]
97
98
 
98
- def start_button_icon
99
- tag.svg(class: 'govuk-button__start-icon', xmlns: 'http://www.w3.org/2000/svg', width: 17.5, height: 19, viewBox: '0 0 33 40', aria: { hidden: true }, focusable: false) do
100
- tag.path(fill: 'currentColor', d: 'M0 0h13l20 20-20 20H0l20-20z')
99
+ def start_button_icon
100
+ tag.svg(class: 'govuk-button__start-icon', xmlns: 'http://www.w3.org/2000/svg', width: 17.5, height: 19, viewBox: '0 0 33 40', aria: { hidden: true }, focusable: false) do
101
+ tag.path(fill: 'currentColor', d: 'M0 0h13l20 20-20 20H0l20-20z')
102
+ end
101
103
  end
102
104
  end
103
105
  end
@@ -1,57 +1,59 @@
1
1
  require_relative '../../base'
2
2
  require_relative '../button'
3
3
 
4
- module CCS::Components
5
- module GovUK
6
- class CookieBanner < Base
7
- # = GOV.UK Cookie Banner Action
8
- #
9
- # The individual cookie banner action.
10
- # It defaults to creating button unless a +href+ is set which will create a link
11
- #
12
- # @!attribute [r] text
13
- # @return [String] Text for the action
14
- # @!attribute [r] href
15
- # @return [String] The href for the action
16
-
17
- class Action < Base
18
- private
19
-
20
- attr_reader :text, :href
21
-
22
- public
23
-
24
- # @param text [String] the button or link text
25
- # @param href [String] the href for a link
26
- # @param options [Hash] options that will be used in customising the HTML
4
+ module CCS
5
+ module Components
6
+ module GovUK
7
+ class CookieBanner < Base
8
+ # = GOV.UK Cookie Banner Action
27
9
  #
28
- # @option options [String] : classes additional CSS classes for the cookie action button or link
29
- # @option options [Hash] :attributes any additional attributes that will added as part of the HTML.
30
- # If the +:type+ key is present with a value of +:button+,
31
- # the action will be rendered as a button
10
+ # The individual cookie banner action.
11
+ # It defaults to creating button unless a +href+ is set which will create a link
12
+ #
13
+ # @!attribute [r] text
14
+ # @return [String] Text for the action
15
+ # @!attribute [r] href
16
+ # @return [String] The href for the action
32
17
 
33
- def initialize(text:, href: nil, **options)
34
- super(**options)
18
+ class Action < Base
19
+ private
35
20
 
36
- @text = text
37
- @href = href
38
- end
21
+ attr_reader :text, :href
39
22
 
40
- # Generates the HTML for a cookie banner message action
41
- #
42
- # @return [ActiveSupport::SafeBuffer]
23
+ public
24
+
25
+ # @param text [String] the button or link text
26
+ # @param href [String] the href for a 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 cookie action button or link
30
+ # @option options [Hash] :attributes any additional attributes that will added as part of the HTML.
31
+ # If the +:type+ key is present with a value of +:button+,
32
+ # the action will be rendered as a button
33
+
34
+ def initialize(text:, href: nil, **options)
35
+ super(**options)
43
36
 
44
- def render
45
- if href && options[:attributes][:type] != :button
46
- link_to(text, href, **options[:attributes])
47
- else
48
- Button.new(text: text, href: href, context: context, **options).render
37
+ @text = text
38
+ @href = href
49
39
  end
50
- end
51
40
 
52
- # The default attributes for the cookie banner action
41
+ # Generates the HTML for a cookie banner message action
42
+ #
43
+ # @return [ActiveSupport::SafeBuffer]
44
+
45
+ def render
46
+ if href && options[:attributes][:type] != :button
47
+ link_to(text, href, **options[:attributes])
48
+ else
49
+ Button.new(text: text, href: href, context: context, **options).render
50
+ end
51
+ end
53
52
 
54
- DEFAULT_ATTRIBUTES = { class: 'govuk-link' }.freeze
53
+ # The default attributes for the cookie banner action
54
+
55
+ DEFAULT_ATTRIBUTES = { class: 'govuk-link' }.freeze
56
+ end
55
57
  end
56
58
  end
57
59
  end
@@ -1,77 +1,79 @@
1
1
  require_relative '../../base'
2
2
  require_relative 'action'
3
3
 
4
- module CCS::Components
5
- module GovUK
6
- class CookieBanner < Base
7
- # = GOV.UK Cookie Banner Message
8
- #
9
- # The individual cookie banner message
10
- #
11
- # @!attribute [r] heading_text
12
- # @return [String] Heading text for the message
13
- # @!attribute [r] content
14
- # @return [ActiveSupport::SafeBuffer] HTML for the message
15
- # @!attribute [r] text
16
- # @return [String] Text for the message
17
- # @!attribute [r] actions
18
- # @return [Array<Action>] Array of initialised cookie banner actions
4
+ module CCS
5
+ module Components
6
+ module GovUK
7
+ class CookieBanner < Base
8
+ # = GOV.UK Cookie Banner Message
9
+ #
10
+ # The individual cookie banner message
11
+ #
12
+ # @!attribute [r] heading_text
13
+ # @return [String] Heading text for the message
14
+ # @!attribute [r] content
15
+ # @return [ActiveSupport::SafeBuffer] HTML for the message
16
+ # @!attribute [r] text
17
+ # @return [String] Text for the message
18
+ # @!attribute [r] actions
19
+ # @return [Array<Action>] Array of initialised cookie banner actions
19
20
 
20
- class Message < Base
21
- private
21
+ class Message < Base
22
+ private
22
23
 
23
- attr_reader :heading_text, :content, :text, :actions
24
+ attr_reader :heading_text, :content, :text, :actions
24
25
 
25
- public
26
+ public
26
27
 
27
- # @param heading_text [String] the heading text that displays in the message
28
- # @param content [ActiveSupport::SafeBuffer] HTML to use as content for the message
29
- # @param text [String] if +:content+ is blank then this is the text used for the message
30
- # @param actions [Array<Hash>] the buttons and/or links that you want to display in the message.
31
- # See {Components::GovUK::CookieBanner::Action#initialize Action#initialize} for details of the items in the array.
32
- # @param options [Hash] options that will be used in customising the HTML
33
- #
34
- # @option options [String] :classes additional CSS classes for the cookie message HTML
35
- # @option options [Hash] :attributes any additional attributes that will added as part of the HTML
28
+ # @param heading_text [String] the heading text that displays in the message
29
+ # @param content [ActiveSupport::SafeBuffer] HTML to use as content for the message
30
+ # @param text [String] if +:content+ is blank then this is the text used for the message
31
+ # @param actions [Array<Hash>] the buttons and/or links that you want to display in the message.
32
+ # See {Components::GovUK::CookieBanner::Action#initialize Action#initialize} for details of the items in the array.
33
+ # @param options [Hash] options that will be used in customising the HTML
34
+ #
35
+ # @option options [String] :classes additional CSS classes for the cookie message HTML
36
+ # @option options [Hash] :attributes any additional attributes that will added as part of the HTML
36
37
 
37
- def initialize(heading_text: nil, content: nil, text: nil, actions: nil, **options)
38
- super(**options)
38
+ def initialize(heading_text: nil, content: nil, text: nil, actions: nil, **options)
39
+ super(**options)
39
40
 
40
- @heading_text = heading_text
41
- @content = content
42
- @text = text
43
- @actions = actions.map { |action| Action.new(context: @context, **action) } if actions
44
- end
41
+ @heading_text = heading_text
42
+ @content = content
43
+ @text = text
44
+ @actions = actions.map { |action| Action.new(context: @context, **action) } if actions
45
+ end
45
46
 
46
- # rubocop:disable Metrics/AbcSize
47
+ # rubocop:disable Metrics/AbcSize
47
48
 
48
- # Generates the HTML for the GOV.UK Cookie Banner Message
49
- #
50
- # @return [ActiveSupport::SafeBuffer]
49
+ # Generates the HTML for the GOV.UK Cookie Banner Message
50
+ #
51
+ # @return [ActiveSupport::SafeBuffer]
51
52
 
52
- def render
53
- tag.div(**options[:attributes]) do
54
- concat(tag.div(class: 'govuk-grid-row') do
55
- tag.div(class: 'govuk-grid-column-two-thirds') do
56
- concat(tag.h2(heading_text, class: 'govuk-cookie-banner__heading govuk-heading-m')) if heading_text
57
- concat(tag.div(class: 'govuk-cookie-banner__content') do
58
- content || tag.p(text, class: 'govuk-body')
53
+ def render
54
+ tag.div(**options[:attributes]) do
55
+ concat(tag.div(class: 'govuk-grid-row') do
56
+ tag.div(class: 'govuk-grid-column-two-thirds') do
57
+ concat(tag.h2(heading_text, class: 'govuk-cookie-banner__heading govuk-heading-m')) if heading_text
58
+ concat(tag.div(class: 'govuk-cookie-banner__content') do
59
+ content || tag.p(text, class: 'govuk-body')
60
+ end)
61
+ end
62
+ end)
63
+ if actions
64
+ concat(tag.div(class: 'govuk-button-group') do
65
+ actions.each { |action| concat(action.render) }
59
66
  end)
60
67
  end
61
- end)
62
- if actions
63
- concat(tag.div(class: 'govuk-button-group') do
64
- actions.each { |action| concat(action.render) }
65
- end)
66
68
  end
67
69
  end
68
- end
69
70
 
70
- # rubocop:enable Metrics/AbcSize
71
+ # rubocop:enable Metrics/AbcSize
71
72
 
72
- # The default attributes for the cookie banner message
73
+ # The default attributes for the cookie banner message
73
74
 
74
- DEFAULT_ATTRIBUTES = { class: 'govuk-cookie-banner__message govuk-width-container' }.freeze
75
+ DEFAULT_ATTRIBUTES = { class: 'govuk-cookie-banner__message govuk-width-container' }.freeze
76
+ end
75
77
  end
76
78
  end
77
79
  end
@@ -1,53 +1,55 @@
1
1
  require_relative '../base'
2
2
  require_relative 'cookie_banner/message'
3
3
 
4
- module CCS::Components
5
- module GovUK
6
- # = GOV.UK Cookie Banner
7
- #
8
- # This is used to generate the cookie banner component from the
9
- # {https://design-system.service.gov.uk/components/cookie-banner GDS - Components - Cookie banner}
10
- #
11
- # @!attribute [r] messages
12
- # @return [Array<Message>] An array of the initialised cookie banner messages
13
-
14
- class CookieBanner < Base
15
- private
16
-
17
- attr_reader :messages
18
-
19
- public
20
-
21
- # @param messages [Array<Hash>] An array of messages for the cookie banner.
22
- # See {Components::GovUK::CookieBanner::Message#initialize Message#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 Cookie Banner
24
8
  #
25
- # @option options [String] :classes additional CSS classes for the cookie banner HTML
26
- # @option options [Hash] :attributes any additional attributes that will added as part of the HTML
9
+ # This is used to generate the cookie banner component from the
10
+ # {https://design-system.service.gov.uk/components/cookie-banner GDS - Components - Cookie banner}
11
+ #
12
+ # @!attribute [r] messages
13
+ # @return [Array<Message>] An array of the initialised cookie banner messages
27
14
 
28
- def initialize(messages:, **options)
29
- super(**options)
15
+ class CookieBanner < Base
16
+ private
30
17
 
31
- (@options[:attributes][:data] ||= {})[:nosnippet] = 'true'
32
- @options[:attributes][:role] = 'region'
33
- (@options[:attributes][:aria] ||= {})[:label] ||= 'Cookie banner'
18
+ attr_reader :messages
34
19
 
35
- @messages = messages.map { |message| Message.new(context: @context, **message) }
36
- end
20
+ public
37
21
 
38
- # Generates the HTML for the GOV.UK Cookie banner component
39
- #
40
- # @return [ActiveSupport::SafeBuffer]
22
+ # @param messages [Array<Hash>] An array of messages for the cookie banner.
23
+ # See {Components::GovUK::CookieBanner::Message#initialize Message#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 cookie banner HTML
27
+ # @option options [Hash] :attributes any additional attributes that will added as part of the HTML
28
+
29
+ def initialize(messages:, **options)
30
+ super(**options)
31
+
32
+ (@options[:attributes][:data] ||= {})[:nosnippet] = 'true'
33
+ @options[:attributes][:role] = 'region'
34
+ (@options[:attributes][:aria] ||= {})[:label] ||= 'Cookie banner'
41
35
 
42
- def render
43
- tag.div(**options[:attributes]) do
44
- messages.each { |message| concat(message.render) }
36
+ @messages = messages.map { |message| Message.new(context: @context, **message) }
45
37
  end
46
- end
47
38
 
48
- # The default attributes for the cookie banner
39
+ # Generates the HTML for the GOV.UK Cookie banner component
40
+ #
41
+ # @return [ActiveSupport::SafeBuffer]
42
+
43
+ def render
44
+ tag.div(**options[:attributes]) do
45
+ messages.each { |message| concat(message.render) }
46
+ end
47
+ end
49
48
 
50
- DEFAULT_ATTRIBUTES = { class: 'govuk-cookie-banner' }.freeze
49
+ # The default attributes for the cookie banner
50
+
51
+ DEFAULT_ATTRIBUTES = { class: 'govuk-cookie-banner' }.freeze
52
+ end
51
53
  end
52
54
  end
53
55
  end
@@ -1,51 +1,53 @@
1
1
  require_relative '../base'
2
2
 
3
- module CCS::Components
4
- module GovUK
5
- # = GOV.UK Details
6
- #
7
- # This is used to generate the details component from the
8
- # {https://design-system.service.gov.uk/components/details GDS - Components - Details}
9
- #
10
- # @!attribute [r] summary_text
11
- # @return [String] Summary text for the details element
3
+ module CCS
4
+ module Components
5
+ module GovUK
6
+ # = GOV.UK Details
7
+ #
8
+ # This is used to generate the details component from the
9
+ # {https://design-system.service.gov.uk/components/details GDS - Components - Details}
10
+ #
11
+ # @!attribute [r] summary_text
12
+ # @return [String] Summary text for the details element
12
13
 
13
- class Details < Base
14
- private
14
+ class Details < Base
15
+ private
15
16
 
16
- attr_reader :summary_text
17
+ attr_reader :summary_text
17
18
 
18
- public
19
+ public
19
20
 
20
- # @param summary_text [String] the summary text for the details element
21
- # @param options [Hash] options that will be used in customising the HTML
22
- #
23
- # @option options [String] :classes additional CSS classes for the details HTML
24
- # @option options [Hash] :attributes ({ data: { module: 'govuk-details' } }) any additional attributes that will added as part of the HTML
21
+ # @param summary_text [String] the summary text for the details element
22
+ # @param options [Hash] options that will be used in customising the HTML
23
+ #
24
+ # @option options [String] :classes additional CSS classes for the details HTML
25
+ # @option options [Hash] :attributes ({ data: { module: 'govuk-details' } }) any additional attributes that will added as part of the HTML
25
26
 
26
- def initialize(summary_text:, **options)
27
- super(**options)
28
-
29
- @summary_text = summary_text
30
- end
27
+ def initialize(summary_text:, **options)
28
+ super(**options)
31
29
 
32
- # Generates the HTML for the GOV.UK Details component
33
- #
34
- # @yield HTML that will be contained within the 'govuk-details__text' div
35
- #
36
- # @return [ActiveSupport::SafeBuffer] the HTML for the GOV.UK Details
37
- # which can then be rendered on the page
30
+ @summary_text = summary_text
31
+ end
38
32
 
39
- def render(&block)
40
- tag.details(**options[:attributes]) do
41
- concat(tag.summary(tag.span(summary_text, class: 'govuk-details__summary-text'), class: 'govuk-details__summary'))
42
- concat(tag.div(class: 'govuk-details__text', &block))
33
+ # Generates the HTML for the GOV.UK Details component
34
+ #
35
+ # @yield HTML that will be contained within the 'govuk-details__text' div
36
+ #
37
+ # @return [ActiveSupport::SafeBuffer] the HTML for the GOV.UK Details
38
+ # which can then be rendered on the page
39
+
40
+ def render(&block)
41
+ tag.details(**options[:attributes]) do
42
+ concat(tag.summary(tag.span(summary_text, class: 'govuk-details__summary-text'), class: 'govuk-details__summary'))
43
+ concat(tag.div(class: 'govuk-details__text', &block))
44
+ end
43
45
  end
44
- end
45
46
 
46
- # The default attributes for the details
47
+ # The default attributes for the details
47
48
 
48
- DEFAULT_ATTRIBUTES = { class: 'govuk-details', data: { module: 'govuk-details' } }.freeze
49
+ DEFAULT_ATTRIBUTES = { class: 'govuk-details', data: { module: 'govuk-details' } }.freeze
50
+ end
49
51
  end
50
52
  end
51
53
  end