crown_marketplace_utils 0.1.0.beta.6 → 0.1.0.beta.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/lib/crown_marketplace_utils/helpers/gov_uk_helper/accordion.rb +91 -89
  4. data/lib/crown_marketplace_utils/helpers/gov_uk_helper/back_link.rb +24 -22
  5. data/lib/crown_marketplace_utils/helpers/gov_uk_helper/breadcrumbs.rb +56 -54
  6. data/lib/crown_marketplace_utils/helpers/gov_uk_helper/button.rb +109 -107
  7. data/lib/crown_marketplace_utils/helpers/gov_uk_helper/details.rb +33 -31
  8. data/lib/crown_marketplace_utils/helpers/gov_uk_helper/error_message.rb +53 -46
  9. data/lib/crown_marketplace_utils/helpers/gov_uk_helper/field/character_count.rb +144 -142
  10. data/lib/crown_marketplace_utils/helpers/gov_uk_helper/field/checkboxes.rb +176 -174
  11. data/lib/crown_marketplace_utils/helpers/gov_uk_helper/field/date_input.rb +126 -124
  12. data/lib/crown_marketplace_utils/helpers/gov_uk_helper/field/file_upload.rb +75 -73
  13. data/lib/crown_marketplace_utils/helpers/gov_uk_helper/field/input.rb +137 -135
  14. data/lib/crown_marketplace_utils/helpers/gov_uk_helper/field/radios.rb +176 -174
  15. data/lib/crown_marketplace_utils/helpers/gov_uk_helper/field/select.rb +111 -109
  16. data/lib/crown_marketplace_utils/helpers/gov_uk_helper/field/textarea.rb +86 -84
  17. data/lib/crown_marketplace_utils/helpers/gov_uk_helper/field.rb +181 -179
  18. data/lib/crown_marketplace_utils/helpers/gov_uk_helper/fieldset.rb +56 -54
  19. data/lib/crown_marketplace_utils/helpers/gov_uk_helper/form_group.rb +37 -35
  20. data/lib/crown_marketplace_utils/helpers/gov_uk_helper/header.rb +142 -140
  21. data/lib/crown_marketplace_utils/helpers/gov_uk_helper/hint.rb +25 -23
  22. data/lib/crown_marketplace_utils/helpers/gov_uk_helper/label.rb +69 -67
  23. data/lib/crown_marketplace_utils/helpers/gov_uk_helper/notification_banner.rb +121 -119
  24. data/lib/crown_marketplace_utils/helpers/gov_uk_helper/pagination.rb +290 -288
  25. data/lib/crown_marketplace_utils/helpers/gov_uk_helper/step_by_step_navigation.rb +187 -185
  26. data/lib/crown_marketplace_utils/helpers/gov_uk_helper/tag.rb +29 -27
  27. data/lib/crown_marketplace_utils/helpers/gov_uk_helper/warning_text.rb +39 -37
  28. data/lib/crown_marketplace_utils/helpers/gov_uk_helper.rb +31 -29
  29. data/lib/crown_marketplace_utils/version.rb +1 -1
  30. metadata +2 -2
@@ -2,224 +2,226 @@
2
2
 
3
3
  require 'action_view'
4
4
 
5
- module CrownMarketplaceUtils::Helpers
6
- module GovUkHelper
7
- # = GOV.UK Step by step navigation
8
- #
9
- # This helper 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
- # To use this component you need the following from {https://github.com/alphagov/govuk_publishing_components GOV.UK Publishing Components}.
13
- # For the SCSS components you should add:
14
- # - {https://github.com/alphagov/govuk_publishing_components/blob/main/app/assets/stylesheets/govuk_publishing_components/components/_step-by-step-nav.scss _step-by-step-nav.scss}
15
- # - {https://github.com/alphagov/govuk_publishing_components/blob/main/app/assets/stylesheets/govuk_publishing_components/components/_step-by-step-nav-related.scss _step-by-step-nav-related.scss}
16
- # - {https://github.com/alphagov/govuk_publishing_components/blob/main/app/assets/stylesheets/govuk_publishing_components/components/_step-by-step-nav-header.scss _step-by-step-nav-header.scss}
17
- # For the JavaScript you should add:
18
- # - {https://github.com/alphagov/govuk_publishing_components/blob/main/app/assets/javascripts/govuk_publishing_components/components/step-by-step-nav.js step-by-step-nav.js}
19
-
20
- module StepByStepNavigation
21
- include ActionView::Helpers
22
- include ActionView::Context
23
-
24
- # Generates the HTML for the GOV.UK Step by step navigation component (experimental)
25
- #
26
- # @param step_by_step_sections [Array] the navigation items that will be rendered to the page.
27
- # See {govuk_step_by_step_navigation_section} for more details
28
- # @param govuk_step_by_step_navigation_options [Hash] options that will be used in customising the HTML
29
- #
30
- # @option govuk_step_by_step_navigation_options [String] :classes additional CSS classes for the step by step navigation HTML
31
- # @option govuk_step_by_step_navigation_options [Hash] :attributes ({data: { module: 'govuk-step-by-step-navigation', 'show-text': 'Show', 'hide-text': 'Hide', 'show-all-text': 'Show all', 'hide-all-text': 'Hide all' } })
32
- # any additional attributes that will added as part of the HTML
33
- #
34
- # @return [ActiveSupport::SafeBuffer] the HTML for the GOV.UK Step by step navigation
35
- # which can then be rendered on the page
36
-
37
- def govuk_step_by_step_navigation(step_by_step_sections, **govuk_step_by_step_navigation_options)
38
- govuk_step_by_step_navigation_classes = ['gem-c-step-nav gem-c-step-nav--large gem-c-step-nav--active']
39
- govuk_step_by_step_navigation_classes << govuk_step_by_step_navigation_options[:classes]
40
-
41
- tag.div(class: govuk_step_by_step_navigation_classes, **govuk_step_by_step_navigation_attributes(**govuk_step_by_step_navigation_options)) do
42
- tag.ol(class: 'gem-c-step-nav__steps') do
43
- capture do
44
- step_by_step_sections.each.with_index(1) { |step_by_step_section, section_index| concat(govuk_step_by_step_navigation_section(step_by_step_section, section_index.to_s)) }
5
+ module CrownMarketplaceUtils
6
+ module Helpers
7
+ module GovUkHelper
8
+ # = GOV.UK Step by step navigation
9
+ #
10
+ # This helper is used for generating the Step by step navigation component from the
11
+ # {https://design-system.service.gov.uk/patterns/step-by-step-navigation/ GDS - Pages - Step by step navigation}
12
+ #
13
+ # To use this component you need the following from {https://github.com/alphagov/govuk_publishing_components GOV.UK Publishing Components}.
14
+ # For the SCSS components you should add:
15
+ # - {https://github.com/alphagov/govuk_publishing_components/blob/main/app/assets/stylesheets/govuk_publishing_components/components/_step-by-step-nav.scss _step-by-step-nav.scss}
16
+ # - {https://github.com/alphagov/govuk_publishing_components/blob/main/app/assets/stylesheets/govuk_publishing_components/components/_step-by-step-nav-related.scss _step-by-step-nav-related.scss}
17
+ # - {https://github.com/alphagov/govuk_publishing_components/blob/main/app/assets/stylesheets/govuk_publishing_components/components/_step-by-step-nav-header.scss _step-by-step-nav-header.scss}
18
+ # For the JavaScript you should add:
19
+ # - {https://github.com/alphagov/govuk_publishing_components/blob/main/app/assets/javascripts/govuk_publishing_components/components/step-by-step-nav.js step-by-step-nav.js}
20
+
21
+ module StepByStepNavigation
22
+ include ActionView::Helpers
23
+ include ActionView::Context
24
+
25
+ # Generates the HTML for the GOV.UK Step by step navigation component (experimental)
26
+ #
27
+ # @param step_by_step_sections [Array] the navigation items that will be rendered to the page.
28
+ # See {govuk_step_by_step_navigation_section} for more details
29
+ # @param govuk_step_by_step_navigation_options [Hash] options that will be used in customising the HTML
30
+ #
31
+ # @option govuk_step_by_step_navigation_options [String] :classes additional CSS classes for the step by step navigation HTML
32
+ # @option govuk_step_by_step_navigation_options [Hash] :attributes ({data: { module: 'govuk-step-by-step-navigation', 'show-text': 'Show', 'hide-text': 'Hide', 'show-all-text': 'Show all', 'hide-all-text': 'Hide all' } })
33
+ # any additional attributes that will added as part of the HTML
34
+ #
35
+ # @return [ActiveSupport::SafeBuffer] the HTML for the GOV.UK Step by step navigation
36
+ # which can then be rendered on the page
37
+
38
+ def govuk_step_by_step_navigation(step_by_step_sections, **govuk_step_by_step_navigation_options)
39
+ govuk_step_by_step_navigation_classes = ['gem-c-step-nav gem-c-step-nav--large gem-c-step-nav--active']
40
+ govuk_step_by_step_navigation_classes << govuk_step_by_step_navigation_options[:classes]
41
+
42
+ tag.div(class: govuk_step_by_step_navigation_classes, **govuk_step_by_step_navigation_attributes(**govuk_step_by_step_navigation_options)) do
43
+ tag.ol(class: 'gem-c-step-nav__steps') do
44
+ capture do
45
+ step_by_step_sections.each.with_index(1) { |step_by_step_section, section_index| concat(govuk_step_by_step_navigation_section(step_by_step_section, section_index.to_s)) }
46
+ end
45
47
  end
46
48
  end
47
49
  end
48
- end
49
-
50
- private
51
-
52
- # The HTML for a section within GOV.UK Step by step navigation, used by {govuk_step_by_step_navigation}
53
- #
54
- # @param step_by_step_section [Hash] the parameters that will be used to create the section
55
- # @param section_index [String] the index of the section
56
- #
57
- # @option step_by_step_section [Hash] :heading the paramaters for the section heading,
58
- # see {govuk_step_by_step_navigation_heading} for more details
59
- # @option step_by_step_section [Array] :content the paramaters for the section content,
60
- # see {govuk_step_by_step_navigation_content} for more details
61
- #
62
- # @return [ActiveSupport::SafeBuffer] the HTML for the GOV.UK Step by step navigation section
63
- # which is used in {govuk_step_by_step_navigation}
64
-
65
- def govuk_step_by_step_navigation_section(step_by_step_section, section_index)
66
- section_id = convert_to_id(step_by_step_section[:heading][:text])
67
50
 
68
- tag.li(class: 'gem-c-step-nav__step js-step', id: section_id) do
69
- capture do
70
- concat(govuk_step_by_step_navigation_heading(step_by_step_section[:heading], section_index))
71
- concat(govuk_step_by_step_navigation_content(step_by_step_section[:content], section_id, section_index))
51
+ private
52
+
53
+ # The HTML for a section within GOV.UK Step by step navigation, used by {govuk_step_by_step_navigation}
54
+ #
55
+ # @param step_by_step_section [Hash] the parameters that will be used to create the section
56
+ # @param section_index [String] the index of the section
57
+ #
58
+ # @option step_by_step_section [Hash] :heading the paramaters for the section heading,
59
+ # see {govuk_step_by_step_navigation_heading} for more details
60
+ # @option step_by_step_section [Array] :content the paramaters for the section content,
61
+ # see {govuk_step_by_step_navigation_content} for more details
62
+ #
63
+ # @return [ActiveSupport::SafeBuffer] the HTML for the GOV.UK Step by step navigation section
64
+ # which is used in {govuk_step_by_step_navigation}
65
+
66
+ def govuk_step_by_step_navigation_section(step_by_step_section, section_index)
67
+ section_id = convert_to_id(step_by_step_section[:heading][:text])
68
+
69
+ tag.li(class: 'gem-c-step-nav__step js-step', id: section_id) do
70
+ capture do
71
+ concat(govuk_step_by_step_navigation_heading(step_by_step_section[:heading], section_index))
72
+ concat(govuk_step_by_step_navigation_content(step_by_step_section[:content], section_id, section_index))
73
+ end
72
74
  end
73
75
  end
74
- end
75
-
76
- # The HTML for a section heading within GOV.UK Step by step navigation, used by {govuk_step_by_step_navigation_section}
77
- #
78
- # @param section_heading [Hash] the parameters that will be used to create the heading
79
- # @param section_index [String] the index of the section
80
- #
81
- # @option section_heading [Hash] :text text for the section heading
82
- # @option section_heading [Hash] :logic (nil) text to show instead of a number in the sidebar
83
- #
84
- # @return [ActiveSupport::SafeBuffer] the HTML for the GOV.UK Step by step navigation section heading
85
- # which is used in {govuk_step_by_step_navigation_section}
86
76
 
87
- def govuk_step_by_step_navigation_heading(section_heading, section_index)
88
- logic = section_heading[:logic]
89
-
90
- tag.div(class: 'gem-c-step-nav__header js-toggle-panel', data: { position: section_index }) do
91
- tag.h2(class: 'gem-c-step-nav__title') do
92
- capture do
93
- concat(tag.span(class: "gem-c-step-nav__circle gem-c-step-nav__circle--#{logic ? 'logic' : 'number'}") do
94
- tag.span(class: 'gem-c-step-nav__circle-inner') do
95
- tag.span(class: 'gem-c-step-nav__circle-background') do
96
- capture do
97
- concat(tag.span('Step', class: 'govuk-visually-hidden'))
98
- concat(logic || section_index)
77
+ # The HTML for a section heading within GOV.UK Step by step navigation, used by {govuk_step_by_step_navigation_section}
78
+ #
79
+ # @param section_heading [Hash] the parameters that will be used to create the heading
80
+ # @param section_index [String] the index of the section
81
+ #
82
+ # @option section_heading [Hash] :text text for the section heading
83
+ # @option section_heading [Hash] :logic (nil) text to show instead of a number in the sidebar
84
+ #
85
+ # @return [ActiveSupport::SafeBuffer] the HTML for the GOV.UK Step by step navigation section heading
86
+ # which is used in {govuk_step_by_step_navigation_section}
87
+
88
+ def govuk_step_by_step_navigation_heading(section_heading, section_index)
89
+ logic = section_heading[:logic]
90
+
91
+ tag.div(class: 'gem-c-step-nav__header js-toggle-panel', data: { position: section_index }) do
92
+ tag.h2(class: 'gem-c-step-nav__title') do
93
+ capture do
94
+ concat(tag.span(class: "gem-c-step-nav__circle gem-c-step-nav__circle--#{logic ? 'logic' : 'number'}") do
95
+ tag.span(class: 'gem-c-step-nav__circle-inner') do
96
+ tag.span(class: 'gem-c-step-nav__circle-background') do
97
+ capture do
98
+ concat(tag.span('Step', class: 'govuk-visually-hidden'))
99
+ concat(logic || section_index)
100
+ end
99
101
  end
100
102
  end
101
- end
102
- end)
103
- concat(tag.span(class: 'js-step-title') do
104
- tag.span(section_heading[:text], class: 'js-step-title-text')
105
- end)
103
+ end)
104
+ concat(tag.span(class: 'js-step-title') do
105
+ tag.span(section_heading[:text], class: 'js-step-title-text')
106
+ end)
107
+ end
106
108
  end
107
109
  end
108
110
  end
109
- end
110
111
 
111
- # The HTML for a section content within GOV.UK Step by step navigation, used by {govuk_step_by_step_navigation_section}
112
- #
113
- # @param content [Array] an array of the content items that will be rendered within the section.
114
- # Only two types of content are allowed:
115
- # - +:paragraph+ - see {govuk_step_by_step_navigation_paragraph}
116
- # - +:list+ - see {govuk_step_by_step_navigation_list}
117
- # @param section_id [String] the id of the section
118
- # @param section_index [String] the index of the section
119
- #
120
- # @option content [Symbol] :type the type of content, either +:paragraph+ or +list+
121
- # @option content [Symbol] :text the text for the paragraph. Ignored unless the +type+ is +:list+
122
- # @option content [Symbol] :items the items for the list. Ignored unless the +type+ is +:paragraph+
123
- #
124
- # @return [ActiveSupport::SafeBuffer] the HTML for the GOV.UK Step by step navigation section content
125
- # which is used in {govuk_step_by_step_navigation_section}
126
-
127
- def govuk_step_by_step_navigation_content(content, section_id, section_index)
128
- tag.div(class: 'gem-c-step-nav__panel js-panel', id: "step-panel-#{section_id}-#{section_index}") do
129
- capture do
130
- content.each do |element|
131
- concat(
132
- case element[:type]
133
- when :paragraph
134
- govuk_step_by_step_navigation_paragraph(element[:text])
135
- when :list
136
- govuk_step_by_step_navigation_list(element[:items])
137
- end
138
- )
112
+ # The HTML for a section content within GOV.UK Step by step navigation, used by {govuk_step_by_step_navigation_section}
113
+ #
114
+ # @param content [Array] an array of the content items that will be rendered within the section.
115
+ # Only two types of content are allowed:
116
+ # - +:paragraph+ - see {govuk_step_by_step_navigation_paragraph}
117
+ # - +:list+ - see {govuk_step_by_step_navigation_list}
118
+ # @param section_id [String] the id of the section
119
+ # @param section_index [String] the index of the section
120
+ #
121
+ # @option content [Symbol] :type the type of content, either +:paragraph+ or +list+
122
+ # @option content [Symbol] :text the text for the paragraph. Ignored unless the +type+ is +:list+
123
+ # @option content [Symbol] :items the items for the list. Ignored unless the +type+ is +:paragraph+
124
+ #
125
+ # @return [ActiveSupport::SafeBuffer] the HTML for the GOV.UK Step by step navigation section content
126
+ # which is used in {govuk_step_by_step_navigation_section}
127
+
128
+ def govuk_step_by_step_navigation_content(content, section_id, section_index)
129
+ tag.div(class: 'gem-c-step-nav__panel js-panel', id: "step-panel-#{section_id}-#{section_index}") do
130
+ capture do
131
+ content.each do |element|
132
+ concat(
133
+ case element[:type]
134
+ when :paragraph
135
+ govuk_step_by_step_navigation_paragraph(element[:text])
136
+ when :list
137
+ govuk_step_by_step_navigation_list(element[:items])
138
+ end
139
+ )
140
+ end
139
141
  end
140
142
  end
141
143
  end
142
- end
143
144
 
144
- # The HTML for the paragraph item within the GOV.UK Step by step navigation content, used by {govuk_step_by_step_navigation_content}
145
- #
146
- # @param text [String] the text for the paragraph
147
- #
148
- # @return [ActiveSupport::SafeBuffer] the HTML for the paragraph
149
- # which is used in {govuk_step_by_step_navigation_content}
150
-
151
- def govuk_step_by_step_navigation_paragraph(text)
152
- tag.p(
153
- text,
154
- class: 'gem-c-step-nav__paragraph',
155
- )
156
- end
145
+ # The HTML for the paragraph item within the GOV.UK Step by step navigation content, used by {govuk_step_by_step_navigation_content}
146
+ #
147
+ # @param text [String] the text for the paragraph
148
+ #
149
+ # @return [ActiveSupport::SafeBuffer] the HTML for the paragraph
150
+ # which is used in {govuk_step_by_step_navigation_content}
151
+
152
+ def govuk_step_by_step_navigation_paragraph(text)
153
+ tag.p(
154
+ text,
155
+ class: 'gem-c-step-nav__paragraph',
156
+ )
157
+ end
157
158
 
158
- # The HTML for the list items within the GOV.UK Step by step navigation content, used by {govuk_step_by_step_navigation_content}
159
- #
160
- # @param items [Array] an array of the list items,
161
- # see {govuk_step_by_step_navigation_list_item} for more details
162
- #
163
- # @return [ActiveSupport::SafeBuffer] the HTML for the list
164
- # which is used in {govuk_step_by_step_navigation_content}
165
-
166
- def govuk_step_by_step_navigation_list(items)
167
- tag.ul(class: 'gem-c-step-nav__list gem-c-step-nav__list--choice', data: { length: items.length.to_s }) do
168
- capture do
169
- items.each do |item|
170
- concat(govuk_step_by_step_navigation_list_item(item[:text], item[:no_marker]))
159
+ # The HTML for the list items within the GOV.UK Step by step navigation content, used by {govuk_step_by_step_navigation_content}
160
+ #
161
+ # @param items [Array] an array of the list items,
162
+ # see {govuk_step_by_step_navigation_list_item} for more details
163
+ #
164
+ # @return [ActiveSupport::SafeBuffer] the HTML for the list
165
+ # which is used in {govuk_step_by_step_navigation_content}
166
+
167
+ def govuk_step_by_step_navigation_list(items)
168
+ tag.ul(class: 'gem-c-step-nav__list gem-c-step-nav__list--choice', data: { length: items.length.to_s }) do
169
+ capture do
170
+ items.each do |item|
171
+ concat(govuk_step_by_step_navigation_list_item(item[:text], item[:no_marker]))
172
+ end
171
173
  end
172
174
  end
173
175
  end
174
- end
175
176
 
176
- # The HTML for a list item, used by {govuk_step_by_step_navigation_list}
177
- #
178
- # @param text [Symbol] the text of the list item
179
- # @param no_marker [Symbol] (nil) switch to hide the bullet marker
180
- #
181
- # @return [ActiveSupport::SafeBuffer] the HTML for the list item
182
- # which is used in {govuk_step_by_step_navigation_list}
177
+ # The HTML for a list item, used by {govuk_step_by_step_navigation_list}
178
+ #
179
+ # @param text [Symbol] the text of the list item
180
+ # @param no_marker [Symbol] (nil) switch to hide the bullet marker
181
+ #
182
+ # @return [ActiveSupport::SafeBuffer] the HTML for the list item
183
+ # which is used in {govuk_step_by_step_navigation_list}
183
184
 
184
- def govuk_step_by_step_navigation_list_item(text, no_marker)
185
- list_item_classes = ['gem-c-step-nav__list-item js-list-item']
186
- list_item_classes << 'gem-c-step-nav__list--no-marker' if no_marker
185
+ def govuk_step_by_step_navigation_list_item(text, no_marker)
186
+ list_item_classes = ['gem-c-step-nav__list-item js-list-item']
187
+ list_item_classes << 'gem-c-step-nav__list--no-marker' if no_marker
187
188
 
188
- tag.li(class: list_item_classes) do
189
- tag.span(text)
189
+ tag.li(class: list_item_classes) do
190
+ tag.span(text)
191
+ end
190
192
  end
191
- end
192
193
 
193
- # Converts the title text into a string to be used as the section id
194
- #
195
- # @param title [String] the section title that will be converted
196
- #
197
- # @return [String] the section id
194
+ # Converts the title text into a string to be used as the section id
195
+ #
196
+ # @param title [String] the section title that will be converted
197
+ #
198
+ # @return [String] the section id
198
199
 
199
- def convert_to_id(title)
200
- title.downcase.gsub(' ', '-').gsub('(', '').gsub(')', '')
201
- end
200
+ def convert_to_id(title)
201
+ title.downcase.gsub(' ', '-').gsub('(', '').gsub(')', '')
202
+ end
202
203
 
203
- # Generates a hash with the attributes used in {govuk_step_by_step_navigation}
204
- #
205
- # @param govuk_step_by_step_navigation_options [Hash] options that will be used in customising the HTML
206
- #
207
- # @option (see govuk_step_by_step_navigation)
208
- #
209
- # @return [Hash] contains the HTMl attributes used in {govuk_step_by_step_navigation}
204
+ # Generates a hash with the attributes used in {govuk_step_by_step_navigation}
205
+ #
206
+ # @param govuk_step_by_step_navigation_options [Hash] options that will be used in customising the HTML
207
+ #
208
+ # @option (see govuk_step_by_step_navigation)
209
+ #
210
+ # @return [Hash] contains the HTMl attributes used in {govuk_step_by_step_navigation}
210
211
 
211
- def govuk_step_by_step_navigation_attributes(**govuk_step_by_step_navigation_options)
212
- govuk_step_by_step_navigation_options[:attributes] ||= {}
213
- (govuk_step_by_step_navigation_options[:attributes][:data] ||= {}).merge!({ module: 'govuk-step-by-step-navigation' })
212
+ def govuk_step_by_step_navigation_attributes(**govuk_step_by_step_navigation_options)
213
+ govuk_step_by_step_navigation_options[:attributes] ||= {}
214
+ (govuk_step_by_step_navigation_options[:attributes][:data] ||= {}).merge!({ module: 'govuk-step-by-step-navigation' })
214
215
 
215
- DEFAULT_SHOW_HIDE_TEXT.each { |key, value| govuk_step_by_step_navigation_options[:attributes][:data][key] ||= value }
216
+ DEFAULT_SHOW_HIDE_TEXT.each { |key, value| govuk_step_by_step_navigation_options[:attributes][:data][key] ||= value }
216
217
 
217
- govuk_step_by_step_navigation_options[:attributes]
218
- end
218
+ govuk_step_by_step_navigation_options[:attributes]
219
+ end
219
220
 
220
- # Default text for the show and hide buttons which are part of each section
221
+ # Default text for the show and hide buttons which are part of each section
221
222
 
222
- DEFAULT_SHOW_HIDE_TEXT = { 'show-text': 'Show', 'hide-text': 'Hide', 'show-all-text': 'Show all', 'hide-all-text': 'Hide all' }.freeze
223
+ DEFAULT_SHOW_HIDE_TEXT = { 'show-text': 'Show', 'hide-text': 'Hide', 'show-all-text': 'Show all', 'hide-all-text': 'Hide all' }.freeze
224
+ end
223
225
  end
224
226
  end
225
227
  end
@@ -2,37 +2,39 @@
2
2
 
3
3
  require 'action_view'
4
4
 
5
- module CrownMarketplaceUtils::Helpers
6
- module GovUkHelper
7
- # = GOV.UK Tag
8
- #
9
- # This helper is used for generating the tag component from the
10
- # {https://design-system.service.gov.uk/components/tag GDS - Components - Tag}
5
+ module CrownMarketplaceUtils
6
+ module Helpers
7
+ module GovUkHelper
8
+ # = GOV.UK Tag
9
+ #
10
+ # This helper is used for generating the tag component from the
11
+ # {https://design-system.service.gov.uk/components/tag GDS - Components - Tag}
11
12
 
12
- module Tag
13
- include ActionView::Context
14
- include ActionView::Helpers::TagHelper
13
+ module Tag
14
+ include ActionView::Context
15
+ include ActionView::Helpers::TagHelper
15
16
 
16
- # Generates the HTML for the GOV.UK Tag component
17
- #
18
- # @param text [String] the text for the tag
19
- # @param colour [String] optional colour for the tag,
20
- # see {https://design-system.service.gov.uk/components/tag/#additional-colours Tag - Additional colours}
21
- # for available colours in GOV.UK Frontend
22
- # @param govuk_tag_options [Hash] options that will be used in customising the HTML
23
- #
24
- # @option govuk_tag_options [String] :classes additional CSS classes for the tag HTML
25
- # @option govuk_tag_options [Hash] :attributes ({}) any additional attributes that will added as part of the HTML
26
- #
27
- # @return [ActiveSupport::SafeBuffer] the HTML for the GOV.UK Tag
28
- # which can then be rendered on the page
17
+ # Generates the HTML for the GOV.UK Tag component
18
+ #
19
+ # @param text [String] the text for the tag
20
+ # @param colour [String] optional colour for the tag,
21
+ # see {https://design-system.service.gov.uk/components/tag/#additional-colours Tag - Additional colours}
22
+ # for available colours in GOV.UK Frontend
23
+ # @param govuk_tag_options [Hash] options that will be used in customising the HTML
24
+ #
25
+ # @option govuk_tag_options [String] :classes additional CSS classes for the tag HTML
26
+ # @option govuk_tag_options [Hash] :attributes ({}) any additional attributes that will added as part of the HTML
27
+ #
28
+ # @return [ActiveSupport::SafeBuffer] the HTML for the GOV.UK Tag
29
+ # which can then be rendered on the page
29
30
 
30
- def govuk_tag(text, colour = nil, **govuk_tag_options)
31
- govuk_tag_classes = ['govuk-tag']
32
- govuk_tag_classes << "govuk-tag--#{colour}" if colour
33
- govuk_tag_classes << govuk_tag_options[:classes]
31
+ def govuk_tag(text, colour = nil, **govuk_tag_options)
32
+ govuk_tag_classes = ['govuk-tag']
33
+ govuk_tag_classes << "govuk-tag--#{colour}" if colour
34
+ govuk_tag_classes << govuk_tag_options[:classes]
34
35
 
35
- tag.strong(text, class: govuk_tag_classes, **(govuk_tag_options[:attributes] || {}))
36
+ tag.strong(text, class: govuk_tag_classes, **(govuk_tag_options[:attributes] || {}))
37
+ end
36
38
  end
37
39
  end
38
40
  end
@@ -2,48 +2,50 @@
2
2
 
3
3
  require 'action_view'
4
4
 
5
- module CrownMarketplaceUtils::Helpers
6
- module GovUkHelper
7
- # = GOV.UK Warning text
8
- #
9
- # This helper is used for generating the warning text component from the
10
- # {https://design-system.service.gov.uk/components/warning-text GDS - Components - Warning text}
5
+ module CrownMarketplaceUtils
6
+ module Helpers
7
+ module GovUkHelper
8
+ # = GOV.UK Warning text
9
+ #
10
+ # This helper is used for generating the warning text component from the
11
+ # {https://design-system.service.gov.uk/components/warning-text GDS - Components - Warning text}
11
12
 
12
- module WarningText
13
- include ActionView::Context
14
- include ActionView::Helpers::TagHelper
15
- include ActionView::Helpers::TextHelper
13
+ module WarningText
14
+ include ActionView::Context
15
+ include ActionView::Helpers::TagHelper
16
+ include ActionView::Helpers::TextHelper
16
17
 
17
- # Generates the HTML for the GOV.UK Warning text component
18
- #
19
- # @param text [String] (nil) the text for the warning
20
- # @param govuk_warning_text_options [Hash] options that will be used in customising the HTML
21
- #
22
- # @option govuk_warning_text_options [String] :classes additional CSS classes for the tag HTML
23
- # @option govuk_warning_text_options [String] :icon_fallback_text the fallback text for the icon (default: +'Warning'+)
24
- # @option govuk_warning_text_options [Hash] :attributes ({}) any additional attributes that will added as part of the HTML
25
- #
26
- # @yield HTML that will be used in the warning text. Ignored if text is passed.
27
- #
28
- # @return [ActiveSupport::SafeBuffer] the HTML for the GOV.UK Warning text
29
- # which can then be rendered on the page
18
+ # Generates the HTML for the GOV.UK Warning text component
19
+ #
20
+ # @param text [String] (nil) the text for the warning
21
+ # @param govuk_warning_text_options [Hash] options that will be used in customising the HTML
22
+ #
23
+ # @option govuk_warning_text_options [String] :classes additional CSS classes for the tag HTML
24
+ # @option govuk_warning_text_options [String] :icon_fallback_text the fallback text for the icon (default: +'Warning'+)
25
+ # @option govuk_warning_text_options [Hash] :attributes ({}) any additional attributes that will added as part of the HTML
26
+ #
27
+ # @yield HTML that will be used in the warning text. Ignored if text is passed.
28
+ #
29
+ # @return [ActiveSupport::SafeBuffer] the HTML for the GOV.UK Warning text
30
+ # which can then be rendered on the page
30
31
 
31
- def govuk_warning_text(text = nil, **govuk_warning_text_options)
32
- govuk_warning_text_options[:class] = "govuk-warning-text #{govuk_warning_text_options[:classes]}".rstrip
32
+ def govuk_warning_text(text = nil, **govuk_warning_text_options)
33
+ govuk_warning_text_options[:class] = "govuk-warning-text #{govuk_warning_text_options[:classes]}".rstrip
33
34
 
34
- tag.div(class: govuk_warning_text_options[:class], **(govuk_warning_text_options[:attributes] || {})) do
35
- capture do
36
- concat(tag.span('!', class: 'govuk-warning-text__icon'))
37
- concat(tag.strong(class: 'govuk-warning-text__text') do
38
- capture do
39
- concat(tag.span(govuk_warning_text_options[:icon_fallback_text] || 'Warning', class: 'govuk-warning-text__assistive'))
40
- if text
41
- concat(text)
42
- else
43
- yield
35
+ tag.div(class: govuk_warning_text_options[:class], **(govuk_warning_text_options[:attributes] || {})) do
36
+ capture do
37
+ concat(tag.span('!', class: 'govuk-warning-text__icon'))
38
+ concat(tag.strong(class: 'govuk-warning-text__text') do
39
+ capture do
40
+ concat(tag.span(govuk_warning_text_options[:icon_fallback_text] || 'Warning', class: 'govuk-warning-text__assistive'))
41
+ if text
42
+ concat(text)
43
+ else
44
+ yield
45
+ end
44
46
  end
45
- end
46
- end)
47
+ end)
48
+ end
47
49
  end
48
50
  end
49
51
  end