govuk_design_system_formbuilder 1.2.2 → 1.2.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dd5bdfc23cbf3aba262eee3caf3b16ef7ad34f12672f089a04e92044d289762d
4
- data.tar.gz: dc41ebb9003313decf2eace4a4f3b48182d1e9b5c3b96a0c9b28a13aa17285f8
3
+ metadata.gz: b04804863d4a75157988de721c6fda535eb35df444b8a99a8830b7b9758f8e03
4
+ data.tar.gz: 162d14ae3760447cf707bc89195daa2a66ca104265258d751b1082325ed56aa8
5
5
  SHA512:
6
- metadata.gz: e28d6305d6a07625bce2360e29694a2f120f0e321bca340659cd3a05a60083fa1c8f33c535f1df87ce7733a60a65d9ab5e5bab2335510c5b6a5e6e61c755067a
7
- data.tar.gz: 86ca1256c95692912fd2255449ef7a97def4a59a5398ec691e297a6a8137e7bff13d3359ecf0daf7482ef396b2fc54cd9420c788060ece727360ce4a80af87f2
6
+ metadata.gz: 71814ceeaf1bb257102a0b4f3e04675bf44aa10a3b85837420d30295bf1b77e9f63c6498dc6d0a8560c5cfb7abcecd7ec057d7ce73a7b2f0f682849eae71a7ba
7
+ data.tar.gz: 16d9e596f3a56b25a5413aed0b996d1965cd0be1a2fb6653217cea9b41b1334f9918a75f71ea0f6ba51844b617bd0a2a3a0686c4c8fb34f05b999afce50f8f67
@@ -14,6 +14,9 @@ module GOVUKDesignSystemFormBuilder
14
14
  # * +:brand+ sets the value used to prefix all classes, used to allow the
15
15
  # builder to be branded for alternative (similar) design systems.
16
16
  #
17
+ # * +:default_caption_size+ controls the default size of caption text.
18
+ # Can be either +xl+, +l+ or +m+.
19
+ #
17
20
  # * +:default_legend_size+ controls the default size of legend text.
18
21
  # Can be either +xl+, +l+, +m+ or +s+.
19
22
  #
@@ -45,6 +48,7 @@ module GOVUKDesignSystemFormBuilder
45
48
 
46
49
  default_legend_size: 'm',
47
50
  default_legend_tag: 'h1',
51
+ default_caption_size: 'm',
48
52
  default_submit_button_text: 'Continue',
49
53
  default_radio_divider_text: 'or',
50
54
  default_error_summary_title: 'There is a problem',
@@ -3,7 +3,7 @@ module GOVUKDesignSystemFormBuilder
3
3
  class Caption < Base
4
4
  include Traits::Localisation
5
5
 
6
- def initialize(builder, object_name, attribute_name, text:, size: 'm')
6
+ def initialize(builder, object_name, attribute_name, text:, size: nil)
7
7
  super(builder, object_name, attribute_name)
8
8
 
9
9
  @text = caption_text(text)
@@ -21,7 +21,7 @@ module GOVUKDesignSystemFormBuilder
21
21
  end
22
22
 
23
23
  def caption_size_class(size)
24
- case size
24
+ case size || config.default_caption_size
25
25
  when 'xl' then %(#{brand}-caption-xl)
26
26
  when 'l' then %(#{brand}-caption-l)
27
27
  when 'm' then %(#{brand}-caption-m)
@@ -39,7 +39,7 @@ module GOVUKDesignSystemFormBuilder
39
39
 
40
40
  def label
41
41
  @builder.label(@attribute_name, label_options) do
42
- @content || safe_join([caption_element.html, @text])
42
+ @content || safe_join([caption, @text])
43
43
  end
44
44
  end
45
45
 
@@ -61,6 +61,10 @@ module GOVUKDesignSystemFormBuilder
61
61
  }
62
62
  end
63
63
 
64
+ def caption
65
+ caption_element.html unless [@radio_class, @checkbox_class].any?
66
+ end
67
+
64
68
  def radio_class(radio)
65
69
  radio ? %(#{brand}-radios__label) : nil
66
70
  end
@@ -1,3 +1,3 @@
1
1
  module GOVUKDesignSystemFormBuilder
2
- VERSION = '1.2.2'.freeze
2
+ VERSION = '1.2.3'.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.2
4
+ version: 1.2.3
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-06-25 00:00:00.000000000 Z
11
+ date: 2020-06-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionview