govuk_design_system_formbuilder 1.2.6 → 1.2.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (29) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/lib/govuk_design_system_formbuilder.rb +1 -1
  4. data/lib/govuk_design_system_formbuilder/base.rb +1 -1
  5. data/lib/govuk_design_system_formbuilder/containers/character_count.rb +1 -1
  6. data/lib/govuk_design_system_formbuilder/containers/check_boxes.rb +1 -1
  7. data/lib/govuk_design_system_formbuilder/containers/fieldset.rb +1 -1
  8. data/lib/govuk_design_system_formbuilder/containers/form_group.rb +1 -1
  9. data/lib/govuk_design_system_formbuilder/containers/radios.rb +1 -1
  10. data/lib/govuk_design_system_formbuilder/containers/supplemental.rb +1 -1
  11. data/lib/govuk_design_system_formbuilder/elements/check_boxes/collection_check_box.rb +1 -3
  12. data/lib/govuk_design_system_formbuilder/elements/check_boxes/fieldset_check_box.rb +1 -1
  13. data/lib/govuk_design_system_formbuilder/elements/date.rb +3 -3
  14. data/lib/govuk_design_system_formbuilder/elements/error_message.rb +3 -3
  15. data/lib/govuk_design_system_formbuilder/elements/error_summary.rb +3 -3
  16. data/lib/govuk_design_system_formbuilder/elements/inputs/email.rb +0 -2
  17. data/lib/govuk_design_system_formbuilder/elements/inputs/number.rb +0 -2
  18. data/lib/govuk_design_system_formbuilder/elements/inputs/password.rb +0 -2
  19. data/lib/govuk_design_system_formbuilder/elements/inputs/phone.rb +0 -2
  20. data/lib/govuk_design_system_formbuilder/elements/inputs/text.rb +0 -2
  21. data/lib/govuk_design_system_formbuilder/elements/inputs/url.rb +0 -2
  22. data/lib/govuk_design_system_formbuilder/elements/label.rb +2 -2
  23. data/lib/govuk_design_system_formbuilder/elements/legend.rb +1 -1
  24. data/lib/govuk_design_system_formbuilder/elements/radios/collection_radio_button.rb +2 -4
  25. data/lib/govuk_design_system_formbuilder/elements/radios/fieldset_radio_button.rb +1 -1
  26. data/lib/govuk_design_system_formbuilder/elements/text_area.rb +10 -10
  27. data/lib/govuk_design_system_formbuilder/traits/conditional.rb +1 -1
  28. data/lib/govuk_design_system_formbuilder/version.rb +1 -1
  29. metadata +6 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c59892549c7150380bda02c9c078026fee857d2e8edacf90e7c4ca4f9be3613f
4
- data.tar.gz: 70687f4b813f7b61aa4312e8a7d59ae883cfa4c1bd3d1b3e4a1318b3354d23b2
3
+ metadata.gz: 73f7852a0c839a3c662b7c5551c2e3e96d37c32fde6af4ad861cfd37f8c0d79f
4
+ data.tar.gz: 3252d8a1c64a4457de52ad87c2a7c9e5945b7400e7ee279c8e3910ee8f4a0cc4
5
5
  SHA512:
6
- metadata.gz: 3f868193dc418ed5cebefad1456918b95be96108001b68ddedd523e7df151544e49691f675615ae9617e6a05e35891e7790ea7624cdf50b84a98811162b86660
7
- data.tar.gz: c7183ad3f84bef8c71d4f303a4c3637f725b7a851732c777774e301178a24ebaac2f971c26e4ca4c70a34c2829e3f94f431c419e752ba535062be941d8fbc1c2
6
+ metadata.gz: 9dd6efdac09f58e06bb8241aacc420bfb016960320cbbf4c9496ed163a5f2ff1f63c79d5f5dca381b7da4f5efa5c75997a8a10542755de3f8a67adb19393756e
7
+ data.tar.gz: b8ea6181c35e29784d8ebcb00bdb1a9d32d5970b26d260336413aaa8b475bee0a7ff085b64e05cb385014563ea7fb8799847c59d2408726a1fdd5b733b55b844
data/README.md CHANGED
@@ -7,10 +7,10 @@
7
7
  [![Test Coverage](https://api.codeclimate.com/v1/badges/fde73b5dc9476197281b/test_coverage)](https://codeclimate.com/github/DFE-Digital/govuk_design_system_formbuilder/test_coverage)
8
8
  [![Dependabot Status](https://api.dependabot.com/badges/status?host=github&repo=DFE-Digital/govuk_design_system_formbuilder)](https://dependabot.com)
9
9
  [![GitHub license](https://img.shields.io/github/license/DFE-Digital/govuk_design_system_formbuilder)](https://github.com/DFE-Digital/govuk_design_system_formbuilder/blob/master/LICENSE)
10
- [![GOV.UK Design System Version](https://img.shields.io/badge/GOV.UK%20Design%20System-3.8.0-brightgreen)](https://design-system.service.gov.uk)
10
+ [![GOV.UK Design System Version](https://img.shields.io/badge/GOV.UK%20Design%20System-3.8.1-brightgreen)](https://design-system.service.gov.uk)
11
11
 
12
12
  This gem provides a easy-to-use form builder that generates forms that are
13
- fully-compliant with version 3.8.0 of the [GOV.UK Design System](https://design-system.service.gov.uk/),
13
+ fully-compliant with version 3.8.1 of the [GOV.UK Design System](https://design-system.service.gov.uk/),
14
14
  minimising the amount of markup you need to write.
15
15
 
16
16
  In addition to the basic markup, the more-advanced functionality of the Design
@@ -88,7 +88,7 @@ module GOVUKDesignSystemFormBuilder
88
88
  end
89
89
 
90
90
  class FormBuilder < ActionView::Helpers::FormBuilder
91
- delegate :content_tag, :tag, :safe_join, :safe_concat, :capture, :link_to, :raw, to: :@template
91
+ delegate :content_tag, :tag, :safe_join, :link_to, :capture, to: :@template
92
92
 
93
93
  include GOVUKDesignSystemFormBuilder::Builder
94
94
  end
@@ -8,7 +8,7 @@ module GOVUKDesignSystemFormBuilder
8
8
  end
9
9
 
10
10
  class Base
11
- delegate :capture, :content_tag, :safe_join, :tag, :raw, :link_to, to: :@builder
11
+ delegate :content_tag, :safe_join, :tag, :link_to, :capture, to: :@builder
12
12
  delegate :config, to: GOVUKDesignSystemFormBuilder
13
13
 
14
14
  def initialize(builder, object_name, attribute_name, &block)
@@ -14,7 +14,7 @@ module GOVUKDesignSystemFormBuilder
14
14
  def html
15
15
  return yield unless limit?
16
16
 
17
- content_tag('div', **options) { yield }
17
+ tag.div(**options) { yield }
18
18
  end
19
19
 
20
20
  private
@@ -8,7 +8,7 @@ module GOVUKDesignSystemFormBuilder
8
8
  end
9
9
 
10
10
  def html
11
- content_tag('div', **options) { yield }
11
+ tag.div(**options) { yield }
12
12
  end
13
13
 
14
14
  private
@@ -11,7 +11,7 @@ module GOVUKDesignSystemFormBuilder
11
11
  end
12
12
 
13
13
  def html
14
- content_tag('fieldset', **options) do
14
+ tag.fieldset(**options) do
15
15
  safe_join([legend_element, (@block_content || yield)])
16
16
  end
17
17
  end
@@ -8,7 +8,7 @@ module GOVUKDesignSystemFormBuilder
8
8
  end
9
9
 
10
10
  def html
11
- content_tag('div', class: classes) { yield }
11
+ tag.div(class: classes) { yield }
12
12
  end
13
13
 
14
14
  private
@@ -11,7 +11,7 @@ module GOVUKDesignSystemFormBuilder
11
11
  end
12
12
 
13
13
  def html
14
- content_tag('div', **options) { yield }
14
+ tag.div(**options) { yield }
15
15
  end
16
16
 
17
17
  private
@@ -10,7 +10,7 @@ module GOVUKDesignSystemFormBuilder
10
10
  def html
11
11
  return nil if @content.blank?
12
12
 
13
- content_tag('div', id: supplemental_id) { @content }
13
+ tag.div(id: supplemental_id) { @content }
14
14
  end
15
15
 
16
16
  private
@@ -2,8 +2,6 @@ module GOVUKDesignSystemFormBuilder
2
2
  module Elements
3
3
  module CheckBoxes
4
4
  class CollectionCheckBox < Base
5
- using PrefixableArray
6
-
7
5
  include Traits::CollectionItem
8
6
  include Traits::Hint
9
7
 
@@ -18,7 +16,7 @@ module GOVUKDesignSystemFormBuilder
18
16
  end
19
17
 
20
18
  def html
21
- content_tag('div', class: %(#{brand}-checkboxes__item)) do
19
+ tag.div(class: %(#{brand}-checkboxes__item)) do
22
20
  safe_join([check_box, label_element, hint_element])
23
21
  end
24
22
  end
@@ -30,7 +30,7 @@ module GOVUKDesignSystemFormBuilder
30
30
  private
31
31
 
32
32
  def item
33
- content_tag('div', class: %(#{brand}-checkboxes__item)) do
33
+ tag.div(class: %(#{brand}-checkboxes__item)) do
34
34
  safe_join([check_box, label_element, hint_element])
35
35
  end
36
36
  end
@@ -35,7 +35,7 @@ module GOVUKDesignSystemFormBuilder
35
35
  end
36
36
 
37
37
  def date
38
- content_tag('div', class: %(#{brand}-date-input)) do
38
+ tag.div(class: %(#{brand}-date-input)) do
39
39
  safe_join([day, month, year])
40
40
  end
41
41
  end
@@ -61,8 +61,8 @@ module GOVUKDesignSystemFormBuilder
61
61
  def date_part(segment, width:, link_errors: false)
62
62
  value = @builder.object.try(@attribute_name).try(segment)
63
63
 
64
- content_tag('div', class: %w(date-input__item).prefix(brand)) do
65
- content_tag('div', class: %w(form-group).prefix(brand)) do
64
+ tag.div(class: %(#{brand}-date-input__item)) do
65
+ tag.div(class: %(#{brand}-form-group)) do
66
66
  safe_join([label(segment, link_errors), input(segment, link_errors, width, value)])
67
67
  end
68
68
  end
@@ -12,14 +12,14 @@ module GOVUKDesignSystemFormBuilder
12
12
  def html
13
13
  return nil unless has_errors?
14
14
 
15
- content_tag('span', class: %(#{brand}-error-message), id: error_id) do
16
- safe_join([prefix, message])
15
+ tag.span(class: %(#{brand}-error-message), id: error_id) do
16
+ safe_join([hidden_prefix, message])
17
17
  end
18
18
  end
19
19
 
20
20
  private
21
21
 
22
- def prefix
22
+ def hidden_prefix
23
23
  tag.span('Error: ', class: %(#{brand}-visually-hidden))
24
24
  end
25
25
 
@@ -12,7 +12,7 @@ module GOVUKDesignSystemFormBuilder
12
12
  def html
13
13
  return nil unless object_has_errors?
14
14
 
15
- content_tag('div', class: summary_class, **summary_options) do
15
+ tag.div(class: summary_class, **summary_options) do
16
16
  safe_join([title, summary])
17
17
  end
18
18
  end
@@ -24,8 +24,8 @@ module GOVUKDesignSystemFormBuilder
24
24
  end
25
25
 
26
26
  def summary
27
- content_tag('div', class: summary_class('body')) do
28
- content_tag('ul', class: [%(#{brand}-list), summary_class('list')]) do
27
+ tag.div(class: summary_class('body')) do
28
+ tag.ul(class: [%(#{brand}-list), summary_class('list')]) do
29
29
  safe_join(list)
30
30
  end
31
31
  end
@@ -2,8 +2,6 @@ module GOVUKDesignSystemFormBuilder
2
2
  module Elements
3
3
  module Inputs
4
4
  class Email < Base
5
- using PrefixableArray
6
-
7
5
  include Traits::Input
8
6
  include Traits::Error
9
7
  include Traits::Hint
@@ -2,8 +2,6 @@ module GOVUKDesignSystemFormBuilder
2
2
  module Elements
3
3
  module Inputs
4
4
  class Number < Base
5
- using PrefixableArray
6
-
7
5
  include Traits::Input
8
6
  include Traits::Error
9
7
  include Traits::Hint
@@ -2,8 +2,6 @@ module GOVUKDesignSystemFormBuilder
2
2
  module Elements
3
3
  module Inputs
4
4
  class Password < Base
5
- using PrefixableArray
6
-
7
5
  include Traits::Input
8
6
  include Traits::Error
9
7
  include Traits::Hint
@@ -2,8 +2,6 @@ module GOVUKDesignSystemFormBuilder
2
2
  module Elements
3
3
  module Inputs
4
4
  class Phone < Base
5
- using PrefixableArray
6
-
7
5
  include Traits::Input
8
6
  include Traits::Error
9
7
  include Traits::Hint
@@ -2,8 +2,6 @@ module GOVUKDesignSystemFormBuilder
2
2
  module Elements
3
3
  module Inputs
4
4
  class Text < Base
5
- using PrefixableArray
6
-
7
5
  include Traits::Input
8
6
  include Traits::Error
9
7
  include Traits::Hint
@@ -2,8 +2,6 @@ module GOVUKDesignSystemFormBuilder
2
2
  module Elements
3
3
  module Inputs
4
4
  class URL < Base
5
- using PrefixableArray
6
-
7
5
  include Traits::Input
8
6
  include Traits::Error
9
7
  include Traits::Hint
@@ -44,10 +44,10 @@ module GOVUKDesignSystemFormBuilder
44
44
  end
45
45
 
46
46
  def retrieve_text(option_text, hidden)
47
- text = [option_text, localised_text(:label), @attribute_name.capitalize].compact.first.to_s
47
+ text = [option_text, localised_text(:label), @attribute_name.capitalize].compact.first
48
48
 
49
49
  if hidden
50
- tag.span(text, class: %w(visually-hidden).prefix(brand))
50
+ tag.span(text, class: %(#{brand}-visually-hidden))
51
51
  else
52
52
  text
53
53
  end
@@ -31,7 +31,7 @@ module GOVUKDesignSystemFormBuilder
31
31
 
32
32
  def content
33
33
  if @text.present?
34
- content_tag('legend', class: classes) do
34
+ tag.legend(class: classes) do
35
35
  content_tag(@tag, class: heading_classes) do
36
36
  safe_join([caption_element, @text])
37
37
  end
@@ -2,8 +2,6 @@ module GOVUKDesignSystemFormBuilder
2
2
  module Elements
3
3
  module Radios
4
4
  class CollectionRadioButton < Base
5
- using PrefixableArray
6
-
7
5
  include Traits::Hint
8
6
  include Traits::CollectionItem
9
7
 
@@ -23,7 +21,7 @@ module GOVUKDesignSystemFormBuilder
23
21
  end
24
22
 
25
23
  def html
26
- content_tag('div', class: %(#{brand}-radios__item)) do
24
+ tag.div(class: %(#{brand}-radios__item)) do
27
25
  safe_join([radio, label_element, hint_element])
28
26
  end
29
27
  end
@@ -38,7 +36,7 @@ module GOVUKDesignSystemFormBuilder
38
36
  {
39
37
  id: field_id(link_errors: @link_errors),
40
38
  aria: { describedby: hint_id },
41
- class: %w(radios__input).prefix(brand)
39
+ class: %(#{brand}-radios__input)
42
40
  }
43
41
  end
44
42
 
@@ -29,7 +29,7 @@ module GOVUKDesignSystemFormBuilder
29
29
  private
30
30
 
31
31
  def radio
32
- content_tag('div', class: %(#{brand}-radios__item)) do
32
+ tag.div(class: %(#{brand}-radios__item)) do
33
33
  safe_join([input, label_element, hint_element])
34
34
  end
35
35
  end
@@ -11,15 +11,15 @@ module GOVUKDesignSystemFormBuilder
11
11
  def initialize(builder, object_name, attribute_name, hint_text:, label:, caption:, rows:, max_words:, max_chars:, threshold:, form_group_classes:, **kwargs, &block)
12
12
  super(builder, object_name, attribute_name, &block)
13
13
 
14
- @label = label
15
- @caption = caption
16
- @hint_text = hint_text
17
- @max_words = max_words
18
- @max_chars = max_chars
19
- @threshold = threshold
20
- @rows = rows
14
+ @label = label
15
+ @caption = caption
16
+ @hint_text = hint_text
17
+ @max_words = max_words
18
+ @max_chars = max_chars
19
+ @threshold = threshold
20
+ @rows = rows
21
21
  @form_group_classes = form_group_classes
22
- @html_attributes = kwargs
22
+ @html_attributes = kwargs
23
23
  end
24
24
 
25
25
  def html
@@ -42,7 +42,7 @@ module GOVUKDesignSystemFormBuilder
42
42
 
43
43
  def classes
44
44
  %w(textarea).prefix(brand).tap do |classes|
45
- classes.push(%(#{brand}-textarea--error)) if has_errors?
45
+ classes.push(%(#{brand}-textarea--error)) if has_errors?
46
46
  classes.push(%(#{brand}-js-character-count)) if limit?
47
47
  end
48
48
  end
@@ -79,7 +79,7 @@ module GOVUKDesignSystemFormBuilder
79
79
  def limit_description
80
80
  return nil unless limit?
81
81
 
82
- content_tag('span', id: limit_id, class: limit_description_classes, aria: { live: 'polite' }) do
82
+ tag.span(id: limit_id, class: limit_description_classes, aria: { live: 'polite' }) do
83
83
  "You can enter up to #{limit_quantity} #{limit_type}"
84
84
  end
85
85
  end
@@ -8,7 +8,7 @@ module GOVUKDesignSystemFormBuilder
8
8
  end
9
9
 
10
10
  def wrap_conditional(block)
11
- content_tag('div', class: conditional_classes, id: conditional_id) do
11
+ tag.div(class: conditional_classes, id: conditional_id) do
12
12
  capture { block.call }
13
13
  end
14
14
  end
@@ -1,3 +1,3 @@
1
1
  module GOVUKDesignSystemFormBuilder
2
- VERSION = '1.2.6'.freeze
2
+ VERSION = '1.2.7'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk_design_system_formbuilder
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.6
4
+ version: 1.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Yates
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-29 00:00:00.000000000 Z
11
+ date: 2020-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionview
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - '='
60
60
  - !ruby/object:Gem::Version
61
- version: 3.16.0
61
+ version: 3.17.0
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - '='
67
67
  - !ruby/object:Gem::Version
68
- version: 3.16.0
68
+ version: 3.17.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: pry
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -176,14 +176,14 @@ dependencies:
176
176
  requirements:
177
177
  - - "~>"
178
178
  - !ruby/object:Gem::Version
179
- version: 3.20.0
179
+ version: 3.21.0
180
180
  type: :development
181
181
  prerelease: false
182
182
  version_requirements: !ruby/object:Gem::Requirement
183
183
  requirements:
184
184
  - - "~>"
185
185
  - !ruby/object:Gem::Version
186
- version: 3.20.0
186
+ version: 3.21.0
187
187
  - !ruby/object:Gem::Dependency
188
188
  name: rubypants
189
189
  requirement: !ruby/object:Gem::Requirement