govuk_design_system_formbuilder 1.1.0.beta.1 → 1.1.0.beta.2

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: b9c9499b630e3696a4d327de2e886f683126009aaf04a40d415c52d03fd48fdf
4
- data.tar.gz: ae9a0f7b5c079b689da3e719031632a4007ad51b7e7bf4800575d8ba8b529b61
3
+ metadata.gz: 82e501f7e5b7cd7dd736262ffb97f54c0aeead0342d27d8a349d05f13839b58b
4
+ data.tar.gz: ea1da5f05bb735f6fdd4d0f12dc0baefde84b07e54dc493625407f0315c9cf3f
5
5
  SHA512:
6
- metadata.gz: 32d92bf557aec39313728bb51ac4e43ac4a0ba983749a9bce6b9f2b8a107062ecdbd413bb1fb1583844781230f6c8e33f5f3c4eac84d7cbf432bdf0137e6e89d
7
- data.tar.gz: ef4303cf4ea3ee8082f2597f8cf7f5d84e2b3182dd566fc9c77ad9bc3e21867be362356eb3b94519d132bbed8471c473e9ad023ce38fb4aa97208ecf195001df
6
+ metadata.gz: c7244ee3061ca5184f18fd12ed6b98e74eb842d465fe77becae6322728d95b7acfe4b444ce37c48df2a687129bd52b5b5d85bd1d11c3662b42408f1d1c4d7d87
7
+ data.tar.gz: 3546f3587c2df1aea3c66dc50e835a228e0735d653bf41982ff13651c2a06310431336484b1872635c7f37ba0e2206f992a343c5022e4eec12edcbfeff9529a5
@@ -36,7 +36,7 @@ module GOVUKDesignSystemFormBuilder
36
36
  end
37
37
 
38
38
  def legend_text
39
- [@legend.dig(:text), localised_text('fieldset')].compact.first
39
+ [@legend.dig(:text), localised_text(:legend)].compact.first
40
40
  end
41
41
 
42
42
  def fieldset_classes
@@ -23,7 +23,7 @@ module GOVUKDesignSystemFormBuilder
23
23
  def hint_text(supplied)
24
24
  [
25
25
  supplied.presence,
26
- localised_text('hint')
26
+ localised_text(:hint)
27
27
  ].compact.first
28
28
  end
29
29
 
@@ -37,7 +37,7 @@ module GOVUKDesignSystemFormBuilder
37
37
  end
38
38
 
39
39
  def label_text(option_text, hidden)
40
- text = [option_text, @value, localised_text('label'), @attribute_name.capitalize].compact.first.to_s
40
+ text = [option_text, @value, localised_text(:label), @attribute_name.capitalize].compact.first.to_s
41
41
 
42
42
  if hidden
43
43
  tag.span(text, class: %w(govuk-visually-hidden))
@@ -14,7 +14,27 @@ module GOVUKDesignSystemFormBuilder
14
14
  def localisation_key(context)
15
15
  return nil unless @object_name.present? && @attribute_name.present?
16
16
 
17
- ['helpers', context, @object_name, @attribute_name].join('.')
17
+ schema(context)
18
+ end
19
+
20
+ def schema(context)
21
+ schema_root(context)
22
+ .push(@object_name, @attribute_name)
23
+ .map { |e| e == :__context__ ? context : e }
24
+ .join('.')
25
+ end
26
+
27
+ def schema_root(context)
28
+ contextual_schema = case context
29
+ when :legend
30
+ config.localisation_schema_legend
31
+ when :hint
32
+ config.localisation_schema_hint
33
+ when :label
34
+ config.localisation_schema_label
35
+ end
36
+
37
+ (contextual_schema || config.localisation_schema_fallback).dup
18
38
  end
19
39
  end
20
40
  end
@@ -1,3 +1,3 @@
1
1
  module GOVUKDesignSystemFormBuilder
2
- VERSION = '1.1.0.beta.1'.freeze
2
+ VERSION = '1.1.0.beta.2'.freeze
3
3
  end
@@ -52,12 +52,47 @@ require 'govuk_design_system_formbuilder/containers/supplemental'
52
52
  module GOVUKDesignSystemFormBuilder
53
53
  include ActiveSupport::Configurable
54
54
 
55
+ # @!group Defaults
56
+
57
+ # Default form builder configuration
58
+ #
59
+ # * +:default_legend_size+ controls the default size of legend text.
60
+ # Can be either +xl+, +l+, +m+ or +s+.
61
+ #
62
+ # * +:default_legend_tag+ controls the default tag that legends are
63
+ # wrapped in. Defaults to +h1+.
64
+ #
65
+ # * +:default_submit_button_text+ sets the value assigned to +govuk_submit+,
66
+ # defaults to 'Continue'.
67
+ #
68
+ # * +:default_submit_button_text+ sets the text used to divide the last radio
69
+ # button in radio button fieldsets. As per the GOV.UK Design System spec,
70
+ # it defaults to 'or'.
71
+ #
72
+ # * +:default_error_summary_title+ sets the text used in error summary
73
+ # blocks. As per the GOV.UK Design System spec, it defaults to
74
+ # 'There is a problem'.
75
+ #
76
+ # * +:localisation_schema_fallback+ sets the prefix elements for the array
77
+ # used to build the localisation string. The final two elements are always
78
+ # are the object name and attribute name. The _special_ value +__context__+,
79
+ # is used as a placeholder for the context (label, fieldset or hint).
80
+ #
81
+ # * +:localisation_schema_legend+, +:localisation_schema_hint+ and
82
+ # +:localisation_schema_label+ each override the schema root for their
83
+ # particular context, allowing them to be independently customised.
84
+ # ===
55
85
  DEFAULTS = {
56
86
  default_legend_size: 'm',
57
87
  default_legend_tag: 'h1',
58
88
  default_submit_button_text: 'Continue',
59
89
  default_radio_divider_text: 'or',
60
- default_error_summary_title: 'There is a problem'
90
+ default_error_summary_title: 'There is a problem',
91
+
92
+ localisation_schema_fallback: %i(helpers __context__),
93
+ localisation_schema_label: nil,
94
+ localisation_schema_hint: nil,
95
+ localisation_schema_legend: nil
61
96
  }.freeze
62
97
 
63
98
  DEFAULTS.keys.each { |k| config_accessor(k) { DEFAULTS[k] } }
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.1.0.beta.1
4
+ version: 1.1.0.beta.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Yates
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-17 00:00:00.000000000 Z
11
+ date: 2019-12-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionview