ccs-frontend_helpers 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +5 -3
  3. data/CHANGELOG.md +30 -0
  4. data/Gemfile +6 -5
  5. data/Gemfile.lock +116 -112
  6. data/README.md +11 -0
  7. data/lib/ccs/components/govuk/accordion/section/content.rb +1 -1
  8. data/lib/ccs/components/govuk/accordion.rb +11 -0
  9. data/lib/ccs/components/govuk/button.rb +4 -1
  10. data/lib/ccs/components/govuk/cookie_banner/action.rb +1 -0
  11. data/lib/ccs/components/govuk/cookie_banner/message.rb +1 -1
  12. data/lib/ccs/components/govuk/details.rb +1 -1
  13. data/lib/ccs/components/govuk/error_message.rb +5 -2
  14. data/lib/ccs/components/govuk/exit_this_page.rb +79 -0
  15. data/lib/ccs/components/govuk/field/input/character_count.rb +60 -17
  16. data/lib/ccs/components/govuk/field/input/select.rb +2 -2
  17. data/lib/ccs/components/govuk/field/inputs/checkboxes.rb +7 -6
  18. data/lib/ccs/components/govuk/field/inputs/date_input.rb +3 -3
  19. data/lib/ccs/components/govuk/field/inputs/item/checkbox.rb +1 -13
  20. data/lib/ccs/components/govuk/field/inputs/item/radio.rb +1 -13
  21. data/lib/ccs/components/govuk/field/inputs/item.rb +24 -10
  22. data/lib/ccs/components/govuk/field/inputs/radios.rb +5 -6
  23. data/lib/ccs/components/govuk/field/inputs.rb +24 -6
  24. data/lib/ccs/components/govuk/fieldset.rb +1 -1
  25. data/lib/ccs/components/govuk/footer/meta.rb +1 -1
  26. data/lib/ccs/components/govuk/footer.rb +1 -1
  27. data/lib/ccs/components/govuk/header/navigation.rb +4 -2
  28. data/lib/ccs/components/govuk/header.rb +26 -7
  29. data/lib/ccs/components/govuk/pagination/increment/next.rb +6 -3
  30. data/lib/ccs/components/govuk/pagination/increment/previous.rb +6 -3
  31. data/lib/ccs/components/govuk/pagination/increment.rb +11 -3
  32. data/lib/ccs/components/govuk/pagination/item.rb +1 -1
  33. data/lib/ccs/components/govuk/pagination.rb +2 -2
  34. data/lib/ccs/components/govuk/summary_list/action/link.rb +18 -3
  35. data/lib/ccs/components/govuk/summary_list/card/actions.rb +3 -2
  36. data/lib/ccs/components/govuk/summary_list/card.rb +1 -1
  37. data/lib/ccs/components/govuk/summary_list/row/actions.rb +3 -2
  38. data/lib/ccs/components/govuk/summary_list/row.rb +7 -2
  39. data/lib/ccs/components/govuk/summary_list.rb +1 -1
  40. data/lib/ccs/components/govuk/tabs.rb +5 -3
  41. data/lib/ccs/components/govuk/task_list/item/status.rb +64 -0
  42. data/lib/ccs/components/govuk/task_list/item/title.rb +54 -0
  43. data/lib/ccs/components/govuk/task_list/item.rb +75 -0
  44. data/lib/ccs/components/govuk/task_list.rb +52 -0
  45. data/lib/ccs/components/govuk/warning_text.rb +1 -1
  46. data/lib/ccs/frontend_helpers/govuk_frontend/character_count.rb +1 -1
  47. data/lib/ccs/frontend_helpers/govuk_frontend/error_message.rb +1 -1
  48. data/lib/ccs/frontend_helpers/govuk_frontend/exit_this_page.rb +28 -0
  49. data/lib/ccs/frontend_helpers/govuk_frontend/task_list.rb +28 -0
  50. data/lib/ccs/frontend_helpers/govuk_frontend.rb +4 -0
  51. data/lib/ccs/frontend_helpers/version.rb +1 -1
  52. data/package.json +10 -0
  53. data/yarn.lock +8 -0
  54. metadata +11 -2
@@ -15,8 +15,8 @@ module CCS
15
15
  #
16
16
  # @!attribute [r] textarea
17
17
  # @return [Textarea] The initialised textarea
18
- # @!attribute [r] fallback_hint
19
- # @return [Hint] The initialised character count fallback hint
18
+ # @!attribute [r] textarea_description
19
+ # @return [Hint] The initialised character count textarea description
20
20
  # @!attribute [r] character_count_html_options
21
21
  # @return [Hash] HTML options for the character count
22
22
 
@@ -26,7 +26,7 @@ module CCS
26
26
 
27
27
  private
28
28
 
29
- attr_reader :textarea, :fallback_hint, :character_count_html_options
29
+ attr_reader :textarea, :textarea_description, :character_count_html_options
30
30
 
31
31
  public
32
32
 
@@ -38,12 +38,12 @@ module CCS
38
38
  #
39
39
  # @option (see initialise_character_count_html_options)
40
40
 
41
- def initialize(attribute:, character_count_options:, context:, **options)
41
+ def initialize(attribute:, context:, character_count_options: {}, **options)
42
42
  character_count_attribute = options[:form] ? "#{options[:form].object_name}_#{attribute}" : attribute
43
43
 
44
44
  initialise_textarea(attribute, character_count_attribute, context, options)
45
45
  initialise_character_count_html_options(character_count_options)
46
- initialise_fallback_hint(character_count_attribute, context, character_count_options)
46
+ initialise_textarea_description(character_count_attribute, context, character_count_options)
47
47
  end
48
48
 
49
49
  # Generates the HTML for the GOV.UK Character count component
@@ -53,7 +53,7 @@ module CCS
53
53
  def render
54
54
  tag.div(**character_count_html_options) do
55
55
  concat(textarea.render)
56
- concat(fallback_hint.render)
56
+ concat(textarea_description.render)
57
57
  end
58
58
  end
59
59
 
@@ -70,7 +70,7 @@ module CCS
70
70
 
71
71
  def initialise_textarea(attribute, character_count_attribute, context, options)
72
72
  ((options[:attributes] ||= {})[:aria] ||= {})[:describedby] = [options.dig(:attributes, :aria, :describedby), "#{character_count_attribute}-info"].compact.join(' ')
73
- options[:classes] = "#{options[:classes]} govuk-js-character-count".lstrip
73
+ options[:classes] = "govuk-js-character-count #{options[:classes]}".rstrip
74
74
 
75
75
  @textarea = Textarea.new(attribute: attribute, context: context, **options)
76
76
  end
@@ -87,10 +87,16 @@ module CCS
87
87
  # If +maxwords+ is provided, the +maxlength+ option will be ignored.
88
88
  # @option character_count_options [String] :threshold the percentage value of the limit at which point the count message is displayed.
89
89
  # If this attribute is set, the count message will be hidden by default.
90
- # @option character_count_options [Hash] :fallback_hint ({}) additional parameters that will be used to create the hint containing the character count text:
90
+ # @option character_count_options [Hash] :textarea_description ({}) additional parameters that will be used to create the hint containing the character count text:
91
91
  # - +:count_message+ replaced the default text for the count message.
92
92
  # If you want the count number to appear, put %<count>s in the string and it will be replaced with the number
93
- # - +classes+ additional CSS classes for the fallback hint HTML
93
+ # - +classes+ additional CSS classes for the textarea description HTML
94
+ # @option character_count_options [Hash] :characters_under_limit Message displayed when the number of characters is under the configured maximum, maxlength
95
+ # @option character_count_options [String] :characters_at_limit_text Message displayed when the number of characters reaches the configured maximum, maxlength
96
+ # @option character_count_options [Hash] :characters_over_limit Message displayed when the number of characters is over the configured maximum, maxlength
97
+ # @option character_count_options [Hash] :words_under_limit Message displayed when the number of words is under the configured maximum, maxwords
98
+ # @option character_count_options [String] :words_at_limit_text Message displayed when the number of words reaches the configured maximum, maxwords
99
+ # @option character_count_options [Hash] :words_over_limit Message displayed when the number of words is over the configured maximum, maxwords
94
100
 
95
101
  def initialise_character_count_html_options(character_count_options)
96
102
  character_count_html_options = { class: 'govuk-character-count', data: { module: 'govuk-character-count' } }
@@ -99,10 +105,14 @@ module CCS
99
105
  character_count_html_options[:data][data_attribute] = character_count_options[data_attribute].to_s if character_count_options[data_attribute]
100
106
  end
101
107
 
108
+ get_chacrter_count_translations(character_count_options).each do |data_attribute, value|
109
+ character_count_html_options[:data][data_attribute] = value
110
+ end
111
+
102
112
  @character_count_html_options = character_count_html_options
103
113
  end
104
114
 
105
- # Initialises the charcter count fall back hint
115
+ # Initialises the charcter count textarea description
106
116
  #
107
117
  # @param character_count_attribute [String] the name of the field as it will appear in the textarea
108
118
  # @param context [ActionView::Base] the view context
@@ -110,17 +120,50 @@ module CCS
110
120
  #
111
121
  # @option (see initialise_character_count_html_options)
112
122
 
113
- def initialise_fallback_hint(character_count_attribute, context, character_count_options)
114
- fallback_hint = character_count_options[:fallback_hint] || {}
123
+ def initialise_textarea_description(character_count_attribute, context, character_count_options)
124
+ textarea_description = character_count_options[:textarea_description] || {}
115
125
 
116
- fallback_hint_length = character_count_options[:maxwords] || character_count_options[:maxlength]
117
- fallback_hint_default = "You can enter up to %<count>s #{character_count_options[:maxwords] ? 'words' : 'characters'}"
126
+ textarea_description_length = character_count_options[:maxwords] || character_count_options[:maxlength]
127
+ textarea_description_default = "You can enter up to %<count>s #{character_count_options[:maxwords] ? 'words' : 'characters'}"
118
128
 
119
- text = format(fallback_hint[:count_message] || fallback_hint_default, count: fallback_hint_length)
120
- classes = "#{fallback_hint[:classes]} govuk-character-count__message".lstrip
129
+ text = textarea_description_length ? format(textarea_description[:count_message] || textarea_description_default, count: textarea_description_length) : ''
130
+ classes = "govuk-character-count__message #{textarea_description[:classes]}".rstrip
121
131
 
122
- @fallback_hint = Hint.new(text: text, classes: classes, attributes: { id: "#{character_count_attribute}-info" }, context: context)
132
+ @textarea_description = Hint.new(text: text, classes: classes, attributes: { id: "#{character_count_attribute}-info" }, context: context)
123
133
  end
134
+
135
+ # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
136
+
137
+ # Returns the translation options for character count
138
+ #
139
+ # @param (see initialise_character_count_html_options)
140
+ #
141
+ # @option (see initialise_character_count_html_options)
142
+ #
143
+ # @return [Hash]
144
+
145
+ def get_chacrter_count_translations(character_count_options)
146
+ character_count_data_options = {}
147
+
148
+ %i[characters_at_limit words_at_limit].each do |data_attribute|
149
+ data_attribute_name = :"#{data_attribute}_text"
150
+ character_count_data_options[:"i18n.#{data_attribute.to_s.gsub('_', '-')}"] = character_count_options[data_attribute_name] if character_count_options[data_attribute_name]
151
+ end
152
+
153
+ %i[characters_under_limit characters_over_limit words_under_limit words_over_limit].each do |data_attribute|
154
+ next unless character_count_options[data_attribute]
155
+
156
+ %i[other one].each do |plural_rule|
157
+ character_count_data_options[:"i18n.#{data_attribute.to_s.gsub('_', '-')}.#{plural_rule}"] = character_count_options[data_attribute][plural_rule] if character_count_options[data_attribute][plural_rule]
158
+ end
159
+ end
160
+
161
+ character_count_data_options[:'i18n.textarea-description.other'] = character_count_options[:textarea_description][:count_message] if character_count_options.dig(:textarea_description, :count_message) && !(character_count_options[:maxwords] || character_count_options[:maxlength])
162
+
163
+ character_count_data_options
164
+ end
165
+
166
+ # rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
124
167
  end
125
168
  end
126
169
  end
@@ -38,8 +38,8 @@ module CCS
38
38
  @items = items.map do |item|
39
39
  [
40
40
  item[:text] || item[:value],
41
- item[:value],
42
- (item[:attributes] || {})
41
+ item[:value].nil? ? item[:text] : item[:value],
42
+ item[:attributes] || {}
43
43
  ]
44
44
  end
45
45
  @selected = @options[:model] ? @options[:model].send(attribute) : selected
@@ -23,7 +23,7 @@ module CCS
23
23
 
24
24
  public
25
25
 
26
- # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
26
+ # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/AbcSize
27
27
 
28
28
  # @param (see CCS::Components::GovUK::Field::Inputs#initialize)
29
29
  # @param checkbox_items [Array<Hash>] an array of options for the checkboxes.
@@ -34,17 +34,18 @@ module CCS
34
34
  def initialize(attribute:, checkbox_items:, **options)
35
35
  super(attribute: attribute, **options)
36
36
 
37
- if @options[:model] || @options[:form]
38
- values = (@options[:model] || @options[:form].object).send(attribute) || []
39
- checkbox_items.each { |checkbox_item| checkbox_item[:checked] = values.include?(checkbox_item[:value]) }
40
- end
37
+ @options[:values] ||= []
38
+ @options[:values] = (@options[:model] || @options[:form].object).send(attribute) || [] if @options[:model] || @options[:form]
39
+
40
+ checkbox_items.each { |checkbox_item| checkbox_item[:checked] = @options[:values].include?(checkbox_item[:value]) } if @options[:values].any?
41
+ checkbox_items.each { |checkbox_item| set_described_by(checkbox_item, @attribute, @error_message, @hint&.send(:options)) } unless @fieldset
41
42
 
42
43
  checkbox_item_class = @options[:form] ? Item::Checkbox::Form : Inputs::Item::Checkbox::Tag
43
44
 
44
45
  @checkbox_items = checkbox_items.map { |checkbox_item| checkbox_item[:divider] ? Item::Divider.new(divider: checkbox_item[:divider], type: 'checkboxes') : checkbox_item_class.new(attribute: attribute, form: @options[:form], context: @context, **checkbox_item) }
45
46
  end
46
47
 
47
- # rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
48
+ # rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/AbcSize
48
49
 
49
50
  # Generates the HTML for the GOV.UK Checkboxes component
50
51
  #
@@ -27,12 +27,12 @@ module CCS
27
27
  #
28
28
  # @option (see CCS::Components::GovUK::Field::Inputs#initialize)
29
29
 
30
- def initialize(attribute:, date_items: default_date_items, **options)
31
- (options[:fieldset][:attributes] ||= {})[:role] = 'group'
30
+ def initialize(attribute:, date_items: nil, **options)
31
+ (options[:fieldset][:attributes] ||= {})[:role] = 'group' if options[:fieldset]
32
32
 
33
33
  super(attribute: attribute, **options)
34
34
 
35
- # date_items ||= default_date_items
35
+ date_items = default_date_items if date_items.blank?
36
36
 
37
37
  @date_input_items = date_items.map { |date_input_item| Item.new(attribute: attribute, error_message: @error_message, model: @options[:model], form: @options[:form], context: @context, **date_input_item) }
38
38
  end
@@ -17,23 +17,11 @@ module CCS
17
17
  # @option (see CCS::Components::GovUK::Field::Items::Item#initialize))
18
18
 
19
19
  def initialize(attribute:, label:, **options)
20
- super(attribute: attribute, **options)
20
+ super(attribute: attribute, item_class: 'govuk-checkboxes__item', **options)
21
21
 
22
22
  label[:classes] = "govuk-checkboxes__label #{label[:classes]}".rstrip
23
23
  end
24
24
 
25
- # Generates the HTML to wrap arround a checkbox input
26
- #
27
- # @yield the checkbox item input HTML
28
- #
29
- # @return [ActiveSupport::SafeBuffer]
30
-
31
- def render(&block)
32
- tag.div(class: 'govuk-checkboxes__item') do
33
- super(&block)
34
- end
35
- end
36
-
37
25
  # The default attributes for the checkbox
38
26
 
39
27
  DEFAULT_ATTRIBUTES = { class: 'govuk-checkboxes__input' }.freeze
@@ -17,23 +17,11 @@ module CCS
17
17
  # @option (see CCS::Components::GovUK::Field::Items::Item#initialize))
18
18
 
19
19
  def initialize(attribute:, label:, **options)
20
- super(attribute: attribute, **options)
20
+ super(attribute: attribute, item_class: 'govuk-radios__item', **options)
21
21
 
22
22
  label[:classes] = "govuk-radios__label #{label[:classes]}".rstrip
23
23
  end
24
24
 
25
- # Generates the HTML to wrap arround a radio input
26
- #
27
- # @yield the radio item input HTML
28
- #
29
- # @return [ActiveSupport::SafeBuffer]
30
-
31
- def render(&block)
32
- tag.div(class: 'govuk-radios__item') do
33
- super(&block)
34
- end
35
- end
36
-
37
25
  # The default attributes for the radio
38
26
 
39
27
  DEFAULT_ATTRIBUTES = { class: 'govuk-radios__input' }.freeze
@@ -19,6 +19,8 @@ module CCS
19
19
  # @return [String,Symbol] The attribute of the item
20
20
  # @!attribute [r] value
21
21
  # @return [String] The value of the item
22
+ # @!attribute [r] item_class
23
+ # @return [String] The CSS class for the item
22
24
  # @!attribute [r] label
23
25
  # @return [Label] The initialised item label
24
26
  # @!attribute [r] hint
@@ -27,13 +29,19 @@ module CCS
27
29
  # @return [ActiveSupport::SafeBuffer] The conditional HTML
28
30
 
29
31
  class Item < Base
32
+ include ActionView::Context
33
+ include ActionView::Helpers
34
+
30
35
  private
31
36
 
32
- attr_reader :attribute, :value, :label, :hint, :conditional_content
37
+ attr_reader :attribute, :value, :item_class, :label, :hint, :conditional_content
33
38
 
34
39
  public
35
40
 
41
+ # rubocop:disable Metrics/ParameterLists
42
+
36
43
  # @param attribute [String,Symbol] the attribute of the item
44
+ # @param item_class [String] the CSS class for the item
37
45
  # @param value [String] the value of the item
38
46
  # @param hint [Hash] options for an item hint see {CCS::Components::GovUK::Hint#initialize Hint#initialize} for more details.
39
47
  # If no hint is given then no hint will be rendered
@@ -48,15 +56,18 @@ module CCS
48
56
  # @option conditional [ActiveSupport::SafeBuffer] content the HTML content
49
57
  # @option conditional [Hash] attributes[:id] the id of the conditional section
50
58
 
51
- def initialize(attribute:, value:, hint: nil, conditional: nil, **options)
59
+ def initialize(attribute:, value:, item_class:, hint: nil, conditional: nil, **options)
52
60
  super(**options)
53
61
 
54
62
  initialise_item_hint(attribute, value, hint) if hint
55
- initialize_item_conditional(attribute, value, conditional) if conditional
63
+ initialize_item_conditional(attribute, value, conditional) if conditional && conditional[:content]
56
64
  @attribute = attribute
57
65
  @value = value
66
+ @item_class = item_class
58
67
  end
59
68
 
69
+ # rubocop:enable Metrics/ParameterLists
70
+
60
71
  # Generates the HTML to wrap arround a input
61
72
  #
62
73
  # @yield the item input HTML
@@ -64,10 +75,14 @@ module CCS
64
75
  # @return [ActiveSupport::SafeBuffer]
65
76
 
66
77
  def render
67
- concat(yield)
68
- concat(label.render)
69
- concat(hint.render) if hint
70
- concat(conditional_content) if conditional_content
78
+ capture do
79
+ concat(tag.div(class: @item_class) do
80
+ concat(yield)
81
+ concat(label.render)
82
+ concat(hint.render) if hint
83
+ end)
84
+ concat(conditional_content) if conditional_content
85
+ end
71
86
  end
72
87
 
73
88
  private
@@ -82,8 +97,7 @@ module CCS
82
97
  hint[:attributes] ||= {}
83
98
  hint[:classes] = "govuk-#{self.class::ITEM_TYPE}__hint #{hint[:classes]}".rstrip
84
99
  hint[:attributes][:id] ||= "#{attribute}_#{value}-item-hint"
85
-
86
- (@options[:attributes][:aria] ||= {})[:describedby] = hint[:attributes][:id]
100
+ (@options[:attributes][:aria] ||= {})[:describedby] = [@options.dig(:attributes, :aria, :describedby), hint[:attributes][:id]].compact.join(' ')
87
101
 
88
102
  @hint = Hint.new(context: @context, **hint)
89
103
  end
@@ -97,7 +111,7 @@ module CCS
97
111
  def initialize_item_conditional(attribute, value, conditional)
98
112
  conditional[:attributes] ||= {}
99
113
  conditional[:attributes][:class] = "govuk-#{self.class::ITEM_TYPE}__conditional #{"govuk-#{self.class::ITEM_TYPE}__conditional--hidden" unless @options[:checked]}".rstrip
100
- conditional[:attributes][:id] ||= sanitize_to_id("#{attribute}_#{value}_conditional")
114
+ conditional[:attributes][:id] ||= sanitize_to_id("conditional-#{attribute}_#{value}")
101
115
 
102
116
  (@options[:attributes][:data] ||= {})[:'aria-controls'] = conditional[:attributes][:id]
103
117
 
@@ -23,7 +23,7 @@ module CCS
23
23
 
24
24
  public
25
25
 
26
- # rubocop:disable Metrics/CyclomaticComplexity
26
+ # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
27
27
 
28
28
  # @param (see CCS::Components::GovUK::Field::Inputs#initialize)
29
29
  # @param radio_items [Array<Hash>] an array of options for the radios.
@@ -34,17 +34,16 @@ module CCS
34
34
  def initialize(attribute:, radio_items:, **options)
35
35
  super(attribute: attribute, **options)
36
36
 
37
- if @options[:model] || @options[:form]
38
- value = (@options[:model] || @options[:form].object).send(attribute)
39
- radio_items.each { |radio_item| radio_item[:checked] = value == radio_item[:value] }
40
- end
37
+ @options[:value] = (@options[:model] || @options[:form].object).send(attribute) if @options[:model] || @options[:form]
38
+
39
+ radio_items.each { |radio_item| radio_item[:checked] = @options[:value] == radio_item[:value] } if @options[:value]
41
40
 
42
41
  radio_item_class = @options[:form] ? Item::Radio::Form : Inputs::Item::Radio::Tag
43
42
 
44
43
  @radio_items = radio_items.map { |radio_item| radio_item[:divider] ? Item::Divider.new(divider: radio_item[:divider], type: 'radios') : radio_item_class.new(attribute: attribute, form: @options[:form], context: @context, **radio_item) }
45
44
  end
46
45
 
47
- # rubocop:enable Metrics/CyclomaticComplexity
46
+ # rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
48
47
 
49
48
  # Generates the HTML for the GOV.UK Radios component
50
49
  #
@@ -27,9 +27,11 @@ module CCS
27
27
  #
28
28
  # @option (see CCS::Components::GovUK::Field#initialize)
29
29
 
30
- def initialize(attribute:, fieldset:, **options)
30
+ def initialize(attribute:, fieldset: nil, **options)
31
31
  super(attribute: attribute, **options)
32
32
 
33
+ return unless fieldset
34
+
33
35
  set_described_by(fieldset, @attribute, @error_message, options[:hint])
34
36
 
35
37
  @fieldset = Fieldset.new(context: @context, **fieldset)
@@ -41,15 +43,31 @@ module CCS
41
43
  #
42
44
  # @return [ActiveSupport::SafeBuffer]
43
45
 
44
- def render
46
+ def render(&block)
45
47
  super() do |display_error_message|
46
- fieldset.render do
47
- concat(hint.render) if hint
48
- concat(display_error_message)
49
- concat(yield)
48
+ if fieldset
49
+ fieldset.render do
50
+ field_inner_html(display_error_message, &block)
51
+ end
52
+ else
53
+ field_inner_html(display_error_message, &block)
50
54
  end
51
55
  end
52
56
  end
57
+
58
+ private
59
+
60
+ # Generates the HTML structure for the field component
61
+ #
62
+ # @yield (see CCS::Components::GovUK::Field#render)
63
+ #
64
+ # @return [ActiveSupport::SafeBuffer]
65
+
66
+ def field_inner_html(display_error_message)
67
+ concat(hint.render) if hint
68
+ concat(display_error_message)
69
+ concat(yield)
70
+ end
53
71
  end
54
72
  end
55
73
  end
@@ -41,7 +41,7 @@ module CCS
41
41
  def render
42
42
  tag.fieldset(**options[:attributes]) do
43
43
  concat(legend.render) if legend
44
- yield
44
+ yield if block_given?
45
45
  end
46
46
  end
47
47
 
@@ -44,7 +44,7 @@ module CCS
44
44
  def render
45
45
  capture do
46
46
  concat(tag.h2(visually_hidden_title, class: 'govuk-visually-hidden'))
47
- if meta_links
47
+ if meta_links.present?
48
48
  concat(tag.ul(class: 'govuk-footer__inline-list') do
49
49
  meta_links.each { |meta_link| concat(meta_link.render) }
50
50
  end)
@@ -53,7 +53,7 @@ module CCS
53
53
  def render
54
54
  tag.footer(**options[:attributes]) do
55
55
  tag.div(class: "govuk-width-container #{options[:container_classes]}".rstrip) do
56
- if navigation
56
+ if navigation.present?
57
57
  concat(tag.div(class: 'govuk-footer__navigation') do
58
58
  navigation.each { |navigation_item| concat(navigation_item.render) }
59
59
  end)
@@ -44,7 +44,9 @@ module CCS
44
44
  def initialize(navigation:, context:, menu_button: nil)
45
45
  menu_button ||= {}
46
46
  menu_button[:text] ||= 'Menu'
47
- menu_button[:label] ||= 'Show or hide menu'
47
+
48
+ menu_button[:aria] = { controls: 'navigation' }
49
+ menu_button[:aria][:label] = menu_button[:label] if menu_button[:label]
48
50
 
49
51
  @menu_button = menu_button
50
52
  @navigation_links = navigation[:items].map { |navigation_link| Link.new(context: context, **navigation_link) }
@@ -58,7 +60,7 @@ module CCS
58
60
 
59
61
  def render
60
62
  tag.nav(aria: { label: navigation_label }, class: navigation_classes) do
61
- concat(button_tag(menu_button[:text], type: :button, class: 'govuk-header__menu-button govuk-js-header-toggle', aria: { controls: 'navigation', label: menu_button[:label] }, hidden: true))
63
+ concat(button_tag(menu_button[:text], type: :button, class: 'govuk-header__menu-button govuk-js-header-toggle', aria: menu_button[:aria], hidden: true))
62
64
  concat(tag.ul(id: 'navigation', class: 'govuk-header__navigation-list') do
63
65
  navigation_links.each { |navigation_link| concat(navigation_link.render) }
64
66
  end)
@@ -35,6 +35,7 @@ module CCS
35
35
  # @option options [String] :container_classes classes for the container
36
36
  # @option options [String] :homepage_url URL of the homepage. Defaults to +/+
37
37
  # @option options [String] :product_name product name, used when the product name follows on directly from ‘GOV.UK
38
+ # @option options [Boolean] :use_tudor_crown flag to use the new tudor crown for the GOV.UK Logo
38
39
  # @option options [Hash] :attributes additional attributes that will added as part of the header HTML
39
40
 
40
41
  def initialize(navigation: nil, menu_button: nil, service: nil, **options)
@@ -43,8 +44,9 @@ module CCS
43
44
  @options[:attributes][:role] = 'banner'
44
45
  @options[:container_classes] ||= 'govuk-width-container'
45
46
  @options[:homepage_url] ||= '/'
47
+ @options[:use_tudor_crown] = true if @options[:use_tudor_crown].nil?
46
48
 
47
- @navigation = Navigation.new(navigation: navigation, menu_button: menu_button, context: @context) if navigation
49
+ @navigation = Navigation.new(navigation: navigation, menu_button: menu_button, context: @context) if navigation && navigation[:items].present?
48
50
  @service = service
49
51
  end
50
52
 
@@ -79,12 +81,7 @@ module CCS
79
81
  def header_logo
80
82
  tag.div(class: 'govuk-header__logo') do
81
83
  link_to(options[:homepage_url], class: 'govuk-header__link govuk-header__link--homepage') do
82
- concat(tag.span(class: 'govuk-header__logotype') do
83
- concat(tag.svg(class: 'govuk-header__logotype-crown', xmlns: 'http://www.w3.org/2000/svg', height: '30', width: '36', aria: { hidden: 'true' }, focusable: 'false', viewBox: '0 0 132 97') do
84
- tag.path(fill: 'currentColor', 'fill-rule': 'evenodd', d: 'M25 30.2c3.5 1.5 7.7-.2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.6 1-.9zM66 92.8c16.9 0 32.8 1.1 47.1 3.2 4-16.9 8.9-26.7 14-33.5l-9.6-3.4c1 4.9 1.1 7.2 0 10.2-1.5-1.4-3-4.3-4.2-8.7L108.6 76c2.8-2 5-3.2 7.5-3.3-4.4 9.4-10 11.9-13.6 11.2-4.3-.8-6.3-4.6-5.6-7.9 1-4.7 5.7-5.9 8-.5 4.3-8.7-3-11.4-7.6-8.8 7.1-7.2 7.9-13.5 2.1-21.1-8 6.1-8.1 12.3-4.5 20.8-4.7-5.4-12.1-2.5-9.5 6.2 3.4-5.2 7.9-2 7.2 3.1-.6 4.3-6.4 7.8-13.5 7.2-10.3-.9-10.9-8-11.2-13.8 2.5-.5 7.1 1.8 11 7.3L80.2 60c-4.1 4.4-8 5.3-12.3 5.4 1.4-4.4 8-11.6 8-11.6H55.5s6.4 7.2 7.9 11.6c-4.2-.1-8-1-12.3-5.4l1.4 16.4c3.9-5.5 8.5-7.7 10.9-7.3-.3 5.8-.9 12.8-11.1 13.8-7.2.6-12.9-2.9-13.5-7.2-.7-5 3.8-8.3 7.1-3.1 2.7-8.7-4.6-11.6-9.4-6.2 3.7-8.5 3.6-14.7-4.6-20.8-5.8 7.6-5 13.9 2.2 21.1-4.7-2.6-11.9.1-7.7 8.8 2.3-5.5 7.1-4.2 8.1.5.7 3.3-1.3 7.1-5.7 7.9-3.5.7-9-1.8-13.5-11.2 2.5.1 4.7 1.3 7.5 3.3l-4.7-15.4c-1.2 4.4-2.7 7.2-4.3 8.7-1.1-3-.9-5.3 0-10.2l-9.5 3.4c5 6.9 9.9 16.7 14 33.5 14.8-2.1 30.8-3.2 47.7-3.2z')
85
- end)
86
- concat(tag.span('GOV.UK', class: 'govuk-header__logotype-text'))
87
- end)
84
+ concat(options[:use_tudor_crown] ? tudor_crown : st_edwards_crown)
88
85
  concat(tag.span(options[:product_name], class: 'govuk-header__product-name')) if options[:product_name]
89
86
  end
90
87
  end
@@ -101,6 +98,28 @@ module CCS
101
98
  tag.span(service[:name], class: 'govuk-header__service-name')
102
99
  end
103
100
  end
101
+
102
+ # Generates the GOV.UK log with St. Edwards Crown
103
+ #
104
+ # @return [ActiveSupport::SafeBuffer]
105
+
106
+ def st_edwards_crown
107
+ tag.svg(class: 'govuk-header__logotype', xmlns: 'http://www.w3.org/2000/svg', height: '30', width: '152', aria: { label: 'GOV.UK' }, focusable: 'false', viewBox: '0 0 152 30', role: 'img') do
108
+ concat(tag.title('GOV.UK'))
109
+ concat(tag.path(d: 'M6.7 12.2c1 .4 2.1-.1 2.5-1s-.1-2.1-1-2.5c-1-.4-2.1.1-2.5 1-.4 1 0 2.1 1 2.5m-4.3 2.5c1 .4 2.1-.1 2.5-1s-.1-2.1-1-2.5c-1-.4-2.1.1-2.5 1-.5 1 0 2.1 1 2.5m-1.3 4.8c1 .4 2.1-.1 2.5-1 .4-1-.1-2.1-1-2.5-1-.4-2.1.1-2.5 1-.4 1 0 2.1 1 2.5m10.4-5.8c1 .4 2.1-.1 2.5-1s-.1-2.1-1-2.5c-1-.4-2.1.1-2.5 1s0 2.1 1 2.5m17.4-1.5c-1 .4-2.1-.1-2.5-1s.1-2.1 1-2.5c1-.4 2.1.1 2.5 1 .5 1 0 2.1-1 2.5m4.3 2.5c-1 .4-2.1-.1-2.5-1s.1-2.1 1-2.5c1-.4 2.1.1 2.5 1 .5 1 0 2.1-1 2.5m1.3 4.8c-1 .4-2.1-.1-2.5-1-.4-1 .1-2.1 1-2.5 1-.4 2.1.1 2.5 1 .4 1 0 2.1-1 2.5m-10.4-5.8c-1 .4-2.1-.1-2.5-1s.1-2.1 1-2.5c1-.4 2.1.1 2.5 1s0 2.1-1 2.5m-5.3-4.9 2.4 1.3V6.5l-2.4.8c-.1-.1-.1-.2-.2-.2s1-3 1-3h-3.4l1 3c-.1.1-.2.1-.2.2-.1.1-2.4-.7-2.4-.7v3.5L17 8.8c-.1.1 0 .2.1.3l-1.4 4.2c-.1.2-.1.4-.1.7 0 1.1.8 2.1 1.9 2.2h.6C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.3 1.1 2.2.2.8.4 1.7.4 2.7v.1zM92.9 28 87 7h4.7l4 15.7h.1l4-15.7h4.7l-5.9 21h-5.7zm28.8-3.6c.6 0 1.2-.1 1.7-.3.5-.2 1-.4 1.4-.8.4-.4.7-.8.9-1.4.2-.6.3-1.2.3-2v-13h4.1v13.6c0 1.2-.2 2.2-.6 3.1s-1 1.7-1.8 2.4c-.7.7-1.6 1.2-2.7 1.5-1 .4-2.2.5-3.4.5-1.2 0-2.4-.2-3.4-.5-1-.4-1.9-.9-2.7-1.5-.8-.7-1.3-1.5-1.8-2.4-.4-.9-.6-2-.6-3.1V6.9h4.2v13c0 .8.1 1.4.3 2 .2.6.5 1 .9 1.4.4.4.8.6 1.4.8.6.2 1.1.3 1.8.3zm13-17.4h4.2v9.1l7.4-9.1h5.2l-7.2 8.4L152 28h-4.9l-5.5-9.4-2.7 3V28h-4.2V7zm-27.6 16.1c-1.5 0-2.7 1.2-2.7 2.7s1.2 2.7 2.7 2.7 2.7-1.2 2.7-2.7-1.2-2.7-2.7-2.7z'))
110
+ end
111
+ end
112
+
113
+ # Generates the GOV.UK logo with a Tudor Crown
114
+ #
115
+ # @return [ActiveSupport::SafeBuffer]
116
+
117
+ def tudor_crown
118
+ tag.svg(class: 'govuk-header__logotype', xmlns: 'http://www.w3.org/2000/svg', height: '30', width: '148', aria: { label: 'GOV.UK' }, focusable: 'false', viewBox: '0 0 148 30', role: 'img') do
119
+ concat(tag.title('GOV.UK'))
120
+ concat(tag.path(d: 'M22.6 10.4c-1 .4-2-.1-2.4-1-.4-.9.1-2 1-2.4.9-.4 2 .1 2.4 1s-.1 2-1 2.4m-5.9 6.7c-.9.4-2-.1-2.4-1-.4-.9.1-2 1-2.4.9-.4 2 .1 2.4 1s-.1 2-1 2.4m10.8-3.7c-1 .4-2-.1-2.4-1-.4-.9.1-2 1-2.4.9-.4 2 .1 2.4 1s0 2-1 2.4m3.3 4.8c-1 .4-2-.1-2.4-1-.4-.9.1-2 1-2.4.9-.4 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4.2s.2-2.9.7-4.2c.4-1.3 1.1-2.4 2-3.4.9-1 1.9-1.7 3.1-2.3 1.2-.5 2.6-.8 4.2-.8zm0 17.6c.9 0 1.7-.2 2.4-.5s1.3-.8 1.7-1.4c.5-.6.8-1.3 1.1-2.2.2-.8.4-1.7.4-2.7v-.1c0-1-.1-1.9-.4-2.7-.2-.8-.6-1.6-1.1-2.2-.5-.6-1.1-1.1-1.7-1.4-.7-.3-1.5-.5-2.4-.5s-1.7.2-2.4.5-1.3.8-1.7 1.4c-.5.6-.8 1.3-1.1 2.2-.2.8-.4 1.7-.4 2.7v.1c0 1 .1 1.9.4 2.7.2.8.6 1.6 1.1 2.2.5.6 1.1 1.1 1.7 1.4.6.3 1.4.5 2.4.5zM88.9 28 83 7h4.7l4 15.7h.1l4-15.7h4.7l-5.9 21h-5.7zm28.8-3.6c.6 0 1.2-.1 1.7-.3.5-.2 1-.4 1.4-.8.4-.4.7-.8.9-1.4.2-.6.3-1.2.3-2v-13h4.1v13.6c0 1.2-.2 2.2-.6 3.1s-1 1.7-1.8 2.4c-.7.7-1.6 1.2-2.7 1.5-1 .4-2.2.5-3.4.5-1.2 0-2.4-.2-3.4-.5-1-.4-1.9-.9-2.7-1.5-.8-.7-1.3-1.5-1.8-2.4-.4-.9-.6-2-.6-3.1V6.9h4.2v13c0 .8.1 1.4.3 2 .2.6.5 1 .9 1.4.4.4.8.6 1.4.8.6.2 1.1.3 1.8.3zm13-17.4h4.2v9.1l7.4-9.1h5.2l-7.2 8.4L148 28h-4.9l-5.5-9.4-2.7 3V28h-4.2V7zm-27.6 16.1c-1.5 0-2.7 1.2-2.7 2.7s1.2 2.7 2.7 2.7 2.7-1.2 2.7-2.7-1.2-2.7-2.7-2.7z'))
121
+ end
122
+ end
104
123
  end
105
124
  end
106
125
  end
@@ -14,8 +14,8 @@ module CCS
14
14
  #
15
15
  # @option (see Increment#initialize)
16
16
 
17
- def initialize(text: 'Next', **options)
18
- super(type: :next, text: text, **options)
17
+ def initialize(text: nil, **options)
18
+ super(type: :next, text: text, default_text: 'Next', **options)
19
19
  end
20
20
 
21
21
  # Generates the HTML for the next link in the pagination
@@ -26,7 +26,10 @@ module CCS
26
26
  tag.div(class: 'govuk-pagination__next') do
27
27
  super() do
28
28
  concat(pagination_icon) if block_is_level
29
- concat(tag.span(text, class: pagination_text_classes))
29
+ concat(tag.span(class: pagination_text_classes) do
30
+ concat(text)
31
+ concat(tag.span(' page', class: 'govuk-visually-hidden')) if text == default_text
32
+ end)
30
33
  pagination_icon_label_text
31
34
  concat(pagination_icon) unless block_is_level
32
35
  end
@@ -14,8 +14,8 @@ module CCS
14
14
  #
15
15
  # @option (see Increment#initialize)
16
16
 
17
- def initialize(text: 'Previous', **options)
18
- super(type: :prev, text: text, **options)
17
+ def initialize(text: nil, **options)
18
+ super(type: :prev, text: text, default_text: 'Previous', **options)
19
19
  end
20
20
 
21
21
  # Generates the HTML for the previous link in the pagination
@@ -26,7 +26,10 @@ module CCS
26
26
  tag.div(class: 'govuk-pagination__prev') do
27
27
  super() do
28
28
  concat(pagination_icon)
29
- concat(tag.span(text, class: pagination_text_classes))
29
+ concat(tag.span(class: pagination_text_classes) do
30
+ concat(text)
31
+ concat(tag.span(' page', class: 'govuk-visually-hidden')) if text == default_text
32
+ end)
30
33
  pagination_icon_label_text
31
34
  end
32
35
  end