govuk_design_system_formbuilder 4.0.0rc1 → 4.1.0
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 +4 -4
- data/README.md +29 -46
- data/lib/govuk_design_system_formbuilder/builder.rb +27 -14
- data/lib/govuk_design_system_formbuilder/elements/submit.rb +3 -1
- data/lib/govuk_design_system_formbuilder/traits/input.rb +15 -10
- data/lib/govuk_design_system_formbuilder/version.rb +1 -1
- metadata +15 -15
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7f5a6a3bf20a1265053dcc1412b8e1cd3a401b67000d4baea725d1e38de52115
|
|
4
|
+
data.tar.gz: 336536cec3118c2b2f408bfd17e173b12026031bf4147bf92fac910c4a73fff9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c9ccef41328fbf34c365e0d18f4709a3ef25d26ad4a22b0ca0836f36835eb14a7628b0a5100f0724fe05b422e9ae184c236648d421389e2aecaf5d39610c4279
|
|
7
|
+
data.tar.gz: e08a35440a95b29e82e62c9ab0b3c5bbb421899eb4b118331ea29d818a55c257965e0e983b311038a60956aefcbb01d2ed6a2719ae1f6fedf69d073c4da03ffa
|
data/README.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
# GOV.UK
|
|
1
|
+
# GOV.UK Form Builder for Ruby on Rails
|
|
2
2
|
|
|
3
|
-
[](https://codeclimate.com/github/
|
|
5
|
-
[](https://github.com/x-govuk/govuk-form-builder/actions)
|
|
4
|
+
[](https://codeclimate.com/github/x-govuk/govuk-form-builder/maintainability)
|
|
5
|
+
[](https://rubygems.org/gems/govuk_design_system_formbuilder)
|
|
6
6
|
[](https://rubygems.org/gems/govuk_design_system_formbuilder)
|
|
7
|
-
[](https://codeclimate.com/github/
|
|
8
|
-
[](https://codeclimate.com/github/x-govuk/govuk-form-builder/test_coverage)
|
|
8
|
+
[](https://github.com/x-govuk/govuk-form-builder/blob/main/LICENSE)
|
|
9
|
+
[](https://design-system.service.gov.uk)
|
|
10
10
|
[](https://weblog.rubyonrails.org/releases/)
|
|
11
11
|
[](https://www.ruby-lang.org/en/downloads/)
|
|
12
12
|
|
|
@@ -16,22 +16,18 @@ It is intended to make creating forms **quick**, **easy** and **familiar** for R
|
|
|
16
16
|
|
|
17
17
|
## Documentation
|
|
18
18
|
|
|
19
|
-
The gem comes with [a full guide](https://govuk-form-builder.netlify.app/) that
|
|
20
|
-
covers most aspects of day-to-day use, along with code and output examples. The
|
|
21
|
-
examples in the guide are generated from the builder itself so it will always
|
|
22
|
-
be up to date.
|
|
19
|
+
The gem comes with [a full guide](https://govuk-form-builder.netlify.app/) that covers most aspects of day-to-day use, along with code and output examples. The examples in the guide are generated from the builder itself so it will always be up to date.
|
|
23
20
|
|
|
24
21
|
[](https://app.netlify.com/sites/govuk-form-builder/deploys)
|
|
25
22
|
|
|
26
|
-
## What
|
|
23
|
+
## What’s included
|
|
27
24
|
|
|
28
25
|
* 100% compatibility with the GOV.UK Design System
|
|
29
26
|
* Full control of labels, legends, hints, captions and fieldsets
|
|
30
|
-
* No overwriting of Rails
|
|
27
|
+
* No overwriting of Rails’ default form helpers
|
|
31
28
|
* Automatic ARIA associations between hints, errors and inputs
|
|
32
29
|
* Most helpers take blocks for arbitrary content
|
|
33
|
-
* Additional params for programmatically adding hints to check box and radio
|
|
34
|
-
button collections
|
|
30
|
+
* Additional params for programmatically adding hints to check box and radio button collections
|
|
35
31
|
* Full I18n support
|
|
36
32
|
* Automatic handling of ActiveRecord validation error messages
|
|
37
33
|
* No external dependencies
|
|
@@ -40,29 +36,22 @@ be up to date.
|
|
|
40
36
|
|
|
41
37
|
## Installation
|
|
42
38
|
|
|
43
|
-
You can install the form builder gem by running the `gem install
|
|
44
|
-
govuk_design_system_formbuilder` or by adding the following line
|
|
45
|
-
to your `Gemfile`:
|
|
39
|
+
You can install the form builder gem by running the `gem install govuk_design_system_formbuilder` or by adding the following line to your `Gemfile`:
|
|
46
40
|
|
|
47
41
|
```sh
|
|
48
42
|
gem 'govuk_design_system_formbuilder'
|
|
49
43
|
```
|
|
50
44
|
|
|
51
|
-
To make full use of this tool, you will need a Rails application with the latest [GOV.UK
|
|
52
|
-
Frontend](https://github.com/alphagov/govuk-frontend) assets installed and
|
|
53
|
-
configured.
|
|
45
|
+
To make full use of this tool, you will need a Rails application with the latest [GOV.UK Frontend](https://github.com/alphagov/govuk-frontend) assets installed and configured.
|
|
54
46
|
|
|
55
|
-
To get up and running quickly and easily try kickstarting your project with a
|
|
56
|
-
pre-configured template:
|
|
47
|
+
To get up and running quickly and easily try kickstarting your project with a pre-configured template:
|
|
57
48
|
|
|
58
49
|
* [DfE Rails Template](https://github.com/DFE-Digital/rails-template)
|
|
59
50
|
* [DEFRA Ruby Template](https://github.com/DEFRA/defra-ruby-template)
|
|
60
51
|
|
|
61
52
|
## Setup
|
|
62
53
|
|
|
63
|
-
To use the form builder in an ad hoc basis you can specify it as an argument to
|
|
64
|
-
`form_for` or `form_with`. These examples are written in [Slim](https://github.com/slim-template/slim) but
|
|
65
|
-
other templating languages like ERB and [Haml](https://haml.info/) work just as well.
|
|
54
|
+
To use the form builder in an ad hoc basis you can specify it as an argument to `form_for` or `form_with`. These examples are written in [Slim](https://github.com/slim-template/slim) but other templating languages like ERB and [Haml](https://haml.info/) work just as well.
|
|
66
55
|
|
|
67
56
|
```slim
|
|
68
57
|
= form_for @some_object, builder: GOVUKDesignSystemFormBuilder::FormBuilder do |f|
|
|
@@ -92,16 +81,14 @@ Now we can get started!
|
|
|
92
81
|
:name,
|
|
93
82
|
:description,
|
|
94
83
|
label: { text: "Which department do you work for?" },
|
|
95
|
-
hint: { text: "If you don
|
|
84
|
+
hint: { text: "If you don’t know ask your manager" }
|
|
96
85
|
|
|
97
86
|
= f.govuk_submit 'Away we go!'
|
|
98
87
|
```
|
|
99
88
|
|
|
100
89
|
## Developing and running the tests
|
|
101
90
|
|
|
102
|
-
The form builder is tested with RSpec. To run all the tests first ensure that
|
|
103
|
-
the development and testing prerequisite gems are installed. At the root of a
|
|
104
|
-
freshly-cloned repo run:
|
|
91
|
+
The form builder is tested with RSpec. To run all the tests first ensure that the development and testing prerequisite gems are installed. At the root of a freshly-cloned repo run:
|
|
105
92
|
|
|
106
93
|
```sh
|
|
107
94
|
bundle
|
|
@@ -115,12 +102,9 @@ bundle exec rspec
|
|
|
115
102
|
|
|
116
103
|
## Contributing
|
|
117
104
|
|
|
118
|
-
Bug reports and feature requests are most welcome, please raise an issue or
|
|
119
|
-
submit a pull request.
|
|
105
|
+
Bug reports and feature requests are most welcome, please raise an issue or submit a pull request.
|
|
120
106
|
|
|
121
|
-
Currently we
|
|
122
|
-
ensure code meets the GOV.UK guidelines. Please ensure that any PRs also adhere
|
|
123
|
-
to this standard.
|
|
107
|
+
Currently we’re using [GOVUK Lint](https://github.com/alphagov/govuk-lint) to ensure code meets the GOV.UK guidelines. Please ensure that any PRs also adhere to this standard.
|
|
124
108
|
|
|
125
109
|
To help keep the logs clean and tidy, please configure git to use your full name:
|
|
126
110
|
|
|
@@ -130,18 +114,18 @@ git config --global user.name "Julius Hibbert"
|
|
|
130
114
|
|
|
131
115
|
## Services using this library
|
|
132
116
|
|
|
133
|
-
Approximately [100 services use this library](https://github.com/
|
|
117
|
+
Approximately [100 services use this library](https://github.com/x-govuk/govuk-form-builder/network/dependents),
|
|
134
118
|
here are a few from the <abbr title="Department for Education">DfE</abbr>, <abbr title="Ministry of Justice">MoJ</abbr>, and
|
|
135
119
|
<abbr title="Department for Business, Energy & Industrial Strategy">BEIS</abbr>.
|
|
136
120
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
121
|
+
* [Apply for teacher training](https://www.github.com/x-govuk/apply-for-teacher-training)
|
|
122
|
+
* [Teaching Vacancies](https://www.github.com/x-govuk/teaching-vacancies)
|
|
123
|
+
* [Get a teacher training adviser](https://www.github.com/x-govuk/get-teacher-training-adviser-service/)
|
|
124
|
+
* [Claim for crown court defence](https://www.github.com/ministryofjustice/Claim-for-Crown-Court-Defence)
|
|
125
|
+
* [Appeal to the tax tribunal](https://www.github.com/ministryofjustice/tax-tribunals-datacapture)
|
|
126
|
+
* [Apply to court about child arrangements](https://www.github.com/ministryofjustice/c100-application)
|
|
127
|
+
* [Trade Tariff duty calculator](https://www.github.com/trade-tariff/trade-tariff-duty-calculator)
|
|
128
|
+
* [Report your official development assistance](https://www.github.com/UKGovernmentBEIS/beis-report-official-development-assistance)
|
|
145
129
|
|
|
146
130
|
## Form building services using this library
|
|
147
131
|
|
|
@@ -150,5 +134,4 @@ here are a few from the <abbr title="Department for Education">DfE</abbr>, <abbr
|
|
|
150
134
|
|
|
151
135
|
## Thanks
|
|
152
136
|
|
|
153
|
-
This project was inspired by [Ministry of Justice
|
|
154
|
-
but is leaner, more modular and written in a more idiomatic style.
|
|
137
|
+
This project was inspired by [Ministry of Justice’s GovukElementsFormBuilder](https://github.com/ministryofjustice/govuk_elements_form_builder), but is leaner, more modular and written in a more idiomatic style.
|
|
@@ -12,6 +12,8 @@ module GOVUKDesignSystemFormBuilder
|
|
|
12
12
|
#
|
|
13
13
|
# @param width [Integer,String] sets the width of the input, can be +2+, +3+ +4+, +5+, +10+ or +20+ characters
|
|
14
14
|
# or +one-quarter+, +one-third+, +one-half+, +two-thirds+ or +full+ width of the container
|
|
15
|
+
# @param extra_letter_spacing [Boolean] when true adds space between characters to increase the readability of
|
|
16
|
+
# sequences of letters and numbers. Defaults to +false+.
|
|
15
17
|
# @param label [Hash,Proc] configures or sets the associated label content
|
|
16
18
|
# @option label text [String] the label text
|
|
17
19
|
# @option label size [String] the size of the label font, can be +xl+, +l+, +m+, +s+ or nil
|
|
@@ -50,8 +52,8 @@ module GOVUKDesignSystemFormBuilder
|
|
|
50
52
|
# = f.govuk_text_field :callsign,
|
|
51
53
|
# label: -> { tag.h3('Call-sign') }
|
|
52
54
|
#
|
|
53
|
-
def govuk_text_field(attribute_name, hint: {}, label: {}, caption: {}, width: nil, form_group: {}, prefix_text: nil, suffix_text: nil, **kwargs, &block)
|
|
54
|
-
Elements::Inputs::Text.new(self, object_name, attribute_name, hint: hint, label: label, caption: caption, width: width, form_group: form_group, prefix_text: prefix_text, suffix_text: suffix_text, **kwargs, &block).html
|
|
55
|
+
def govuk_text_field(attribute_name, hint: {}, label: {}, caption: {}, width: nil, extra_letter_spacing: false, form_group: {}, prefix_text: nil, suffix_text: nil, **kwargs, &block)
|
|
56
|
+
Elements::Inputs::Text.new(self, object_name, attribute_name, hint: hint, label: label, caption: caption, width: width, extra_letter_spacing: extra_letter_spacing, form_group: form_group, prefix_text: prefix_text, suffix_text: suffix_text, **kwargs, &block).html
|
|
55
57
|
end
|
|
56
58
|
|
|
57
59
|
# Generates a input of type +tel+
|
|
@@ -63,6 +65,8 @@ module GOVUKDesignSystemFormBuilder
|
|
|
63
65
|
# @option hint kwargs [Hash] additional arguments are applied as attributes to the hint
|
|
64
66
|
# @param width [Integer,String] sets the width of the input, can be +2+, +3+ +4+, +5+, +10+ or +20+ characters
|
|
65
67
|
# or +one-quarter+, +one-third+, +one-half+, +two-thirds+ or +full+ width of the container
|
|
68
|
+
# @param extra_letter_spacing [Boolean] when true adds space between characters to increase the readability of
|
|
69
|
+
# sequences of letters and numbers. Defaults to +false+.
|
|
66
70
|
# @param label [Hash,Proc] configures or sets the associated label content
|
|
67
71
|
# @option label text [String] the label text
|
|
68
72
|
# @option label size [String] the size of the label font, can be +xl+, +l+, +m+, +s+ or nil
|
|
@@ -102,8 +106,8 @@ module GOVUKDesignSystemFormBuilder
|
|
|
102
106
|
# = f.govuk_phone_field :work_number,
|
|
103
107
|
# label: -> { tag.h3('Work number') }
|
|
104
108
|
#
|
|
105
|
-
def govuk_phone_field(attribute_name, hint: {}, label: {}, caption: {}, width: nil, form_group: {}, prefix_text: nil, suffix_text: nil, **kwargs, &block)
|
|
106
|
-
Elements::Inputs::Phone.new(self, object_name, attribute_name, hint: hint, label: label, caption: caption, width: width, form_group: form_group, prefix_text: prefix_text, suffix_text: suffix_text, **kwargs, &block).html
|
|
109
|
+
def govuk_phone_field(attribute_name, hint: {}, label: {}, caption: {}, width: nil, extra_letter_spacing: false, form_group: {}, prefix_text: nil, suffix_text: nil, **kwargs, &block)
|
|
110
|
+
Elements::Inputs::Phone.new(self, object_name, attribute_name, hint: hint, label: label, caption: caption, width: width, extra_letter_spacing: extra_letter_spacing, form_group: form_group, prefix_text: prefix_text, suffix_text: suffix_text, **kwargs, &block).html
|
|
107
111
|
end
|
|
108
112
|
|
|
109
113
|
# Generates a input of type +email+
|
|
@@ -115,6 +119,8 @@ module GOVUKDesignSystemFormBuilder
|
|
|
115
119
|
# @option hint kwargs [Hash] additional arguments are applied as attributes to the hint
|
|
116
120
|
# @param width [Integer,String] sets the width of the input, can be +2+, +3+ +4+, +5+, +10+ or +20+ characters
|
|
117
121
|
# or +one-quarter+, +one-third+, +one-half+, +two-thirds+ or +full+ width of the container
|
|
122
|
+
# @param extra_letter_spacing [Boolean] when true adds space between characters to increase the readability of
|
|
123
|
+
# sequences of letters and numbers. Defaults to +false+.
|
|
118
124
|
# @param label [Hash,Proc] configures or sets the associated label content
|
|
119
125
|
# @option label text [String] the label text
|
|
120
126
|
# @option label size [String] the size of the label font, can be +xl+, +l+, +m+, +s+ or nil
|
|
@@ -152,8 +158,8 @@ module GOVUKDesignSystemFormBuilder
|
|
|
152
158
|
# = f.govuk_email_field :personal_email,
|
|
153
159
|
# label: -> { tag.h3('Personal email address') }
|
|
154
160
|
#
|
|
155
|
-
def govuk_email_field(attribute_name, hint: {}, label: {}, caption: {}, width: nil, form_group: {}, prefix_text: nil, suffix_text: nil, **kwargs, &block)
|
|
156
|
-
Elements::Inputs::Email.new(self, object_name, attribute_name, hint: hint, label: label, caption: caption, width: width, form_group: form_group, prefix_text: prefix_text, suffix_text: suffix_text, **kwargs, &block).html
|
|
161
|
+
def govuk_email_field(attribute_name, hint: {}, label: {}, caption: {}, width: nil, extra_letter_spacing: false, form_group: {}, prefix_text: nil, suffix_text: nil, **kwargs, &block)
|
|
162
|
+
Elements::Inputs::Email.new(self, object_name, attribute_name, hint: hint, label: label, caption: caption, width: width, extra_letter_spacing: extra_letter_spacing, form_group: form_group, prefix_text: prefix_text, suffix_text: suffix_text, **kwargs, &block).html
|
|
157
163
|
end
|
|
158
164
|
|
|
159
165
|
# Generates a input of type +password+
|
|
@@ -165,6 +171,8 @@ module GOVUKDesignSystemFormBuilder
|
|
|
165
171
|
# @option hint kwargs [Hash] additional arguments are applied as attributes to the hint
|
|
166
172
|
# @param width [Integer,String] sets the width of the input, can be +2+, +3+ +4+, +5+, +10+ or +20+ characters
|
|
167
173
|
# or +one-quarter+, +one-third+, +one-half+, +two-thirds+ or +full+ width of the container
|
|
174
|
+
# @param extra_letter_spacing [Boolean] when true adds space between characters to increase the readability of
|
|
175
|
+
# sequences of letters and numbers. Defaults to +false+.
|
|
168
176
|
# @param label [Hash,Proc] configures or sets the associated label content
|
|
169
177
|
# @option label text [String] the label text
|
|
170
178
|
# @option label size [String] the size of the label font, can be +xl+, +l+, +m+, +s+ or nil
|
|
@@ -201,8 +209,8 @@ module GOVUKDesignSystemFormBuilder
|
|
|
201
209
|
# = f.govuk_password_field :passcode,
|
|
202
210
|
# label: -> { tag.h3('What is your secret pass code?') }
|
|
203
211
|
#
|
|
204
|
-
def govuk_password_field(attribute_name, hint: {}, label: {}, width: nil, form_group: {}, caption: {}, prefix_text: nil, suffix_text: nil, **kwargs, &block)
|
|
205
|
-
Elements::Inputs::Password.new(self, object_name, attribute_name, hint: hint, label: label, caption: caption, width: width, form_group: form_group, prefix_text: prefix_text, suffix_text: suffix_text, **kwargs, &block).html
|
|
212
|
+
def govuk_password_field(attribute_name, hint: {}, label: {}, width: nil, extra_letter_spacing: false, form_group: {}, caption: {}, prefix_text: nil, suffix_text: nil, **kwargs, &block)
|
|
213
|
+
Elements::Inputs::Password.new(self, object_name, attribute_name, hint: hint, label: label, caption: caption, width: width, extra_letter_spacing: extra_letter_spacing, form_group: form_group, prefix_text: prefix_text, suffix_text: suffix_text, **kwargs, &block).html
|
|
206
214
|
end
|
|
207
215
|
|
|
208
216
|
# Generates a input of type +url+
|
|
@@ -214,6 +222,8 @@ module GOVUKDesignSystemFormBuilder
|
|
|
214
222
|
# @option hint kwargs [Hash] additional arguments are applied as attributes to the hint
|
|
215
223
|
# @param width [Integer,String] sets the width of the input, can be +2+, +3+ +4+, +5+, +10+ or +20+ characters
|
|
216
224
|
# or +one-quarter+, +one-third+, +one-half+, +two-thirds+ or +full+ width of the container
|
|
225
|
+
# @param extra_letter_spacing [Boolean] when true adds space between characters to increase the readability of
|
|
226
|
+
# sequences of letters and numbers. Defaults to +false+.
|
|
217
227
|
# @param label [Hash,Proc] configures or sets the associated label content
|
|
218
228
|
# @option label text [String] the label text
|
|
219
229
|
# @option label size [String] the size of the label font, can be +xl+, +l+, +m+, +s+ or nil
|
|
@@ -251,8 +261,8 @@ module GOVUKDesignSystemFormBuilder
|
|
|
251
261
|
# = f.govuk_url_field :work_website,
|
|
252
262
|
# label: -> { tag.h3("Enter your company's website") }
|
|
253
263
|
#
|
|
254
|
-
def govuk_url_field(attribute_name, hint: {}, label: {}, caption: {}, width: nil, form_group: {}, prefix_text: nil, suffix_text: nil, **kwargs, &block)
|
|
255
|
-
Elements::Inputs::URL.new(self, object_name, attribute_name, hint: hint, label: label, caption: caption, width: width, form_group: form_group, prefix_text: prefix_text, suffix_text: suffix_text, **kwargs, &block).html
|
|
264
|
+
def govuk_url_field(attribute_name, hint: {}, label: {}, caption: {}, width: nil, extra_letter_spacing: false, form_group: {}, prefix_text: nil, suffix_text: nil, **kwargs, &block)
|
|
265
|
+
Elements::Inputs::URL.new(self, object_name, attribute_name, hint: hint, label: label, caption: caption, width: width, extra_letter_spacing: extra_letter_spacing, form_group: form_group, prefix_text: prefix_text, suffix_text: suffix_text, **kwargs, &block).html
|
|
256
266
|
end
|
|
257
267
|
|
|
258
268
|
# Generates a input of type +number+
|
|
@@ -264,6 +274,8 @@ module GOVUKDesignSystemFormBuilder
|
|
|
264
274
|
# @option hint kwargs [Hash] additional arguments are applied as attributes to the hint
|
|
265
275
|
# @param width [Integer,String] sets the width of the input, can be +2+, +3+ +4+, +5+, +10+ or +20+ characters
|
|
266
276
|
# or +one-quarter+, +one-third+, +one-half+, +two-thirds+ or +full+ width of the container
|
|
277
|
+
# @param extra_letter_spacing [Boolean] when true adds space between characters to increase the readability of
|
|
278
|
+
# sequences of letters and numbers. Defaults to +false+.
|
|
267
279
|
# @param label [Hash,Proc] configures or sets the associated label content
|
|
268
280
|
# @option label text [String] the label text
|
|
269
281
|
# @option label size [String] the size of the label font, can be +xl+, +l+, +m+, +s+ or nil
|
|
@@ -304,8 +316,8 @@ module GOVUKDesignSystemFormBuilder
|
|
|
304
316
|
# = f.govuk_url_field :personal_best_over_100m,
|
|
305
317
|
# label: -> { tag.h3("How many seconds does it take you to run 100m?") }
|
|
306
318
|
#
|
|
307
|
-
def govuk_number_field(attribute_name, hint: {}, label: {}, caption: {}, width: nil, form_group: {}, prefix_text: nil, suffix_text: nil, **kwargs, &block)
|
|
308
|
-
Elements::Inputs::Number.new(self, object_name, attribute_name, hint: hint, label: label, caption: caption, width: width, form_group: form_group, prefix_text: prefix_text, suffix_text: suffix_text, **kwargs, &block).html
|
|
319
|
+
def govuk_number_field(attribute_name, hint: {}, label: {}, caption: {}, width: nil, extra_letter_spacing: false, form_group: {}, prefix_text: nil, suffix_text: nil, **kwargs, &block)
|
|
320
|
+
Elements::Inputs::Number.new(self, object_name, attribute_name, hint: hint, label: label, caption: caption, width: width, extra_letter_spacing: extra_letter_spacing, form_group: form_group, prefix_text: prefix_text, suffix_text: suffix_text, **kwargs, &block).html
|
|
309
321
|
end
|
|
310
322
|
|
|
311
323
|
# Generates a +textarea+ element with a label, optional hint. Also offers
|
|
@@ -845,6 +857,7 @@ module GOVUKDesignSystemFormBuilder
|
|
|
845
857
|
# @param text [String,Proc] the button text. When a +Proc+ is provided its contents will be rendered within the button element
|
|
846
858
|
# @param warning [Boolean] makes the button red ({https://design-system.service.gov.uk/components/button/#warning-buttons warning}) when true
|
|
847
859
|
# @param secondary [Boolean] makes the button grey ({https://design-system.service.gov.uk/components/button/#secondary-buttons secondary}) when true
|
|
860
|
+
# @param inverse [Boolean] inverts the colours of the button. Note this isn't yet part of the design system.
|
|
848
861
|
# @param prevent_double_click [Boolean] adds JavaScript to safeguard the
|
|
849
862
|
# form from being submitted more than once
|
|
850
863
|
# @param validate [Boolean] adds the formnovalidate to the submit button when true, this disables all
|
|
@@ -869,8 +882,8 @@ module GOVUKDesignSystemFormBuilder
|
|
|
869
882
|
# = f.govuk_submit "Proceed", prevent_double_click: true do
|
|
870
883
|
# = link_to 'Cancel', some_other_path, class: 'govuk-button__secondary'
|
|
871
884
|
#
|
|
872
|
-
def govuk_submit(text = config.default_submit_button_text, warning: false, secondary: false, prevent_double_click: true, validate: config.default_submit_validate, disabled: false, **kwargs, &block)
|
|
873
|
-
Elements::Submit.new(self, text, warning: warning, secondary: secondary, prevent_double_click: prevent_double_click, validate: validate, disabled: disabled, **kwargs, &block).html
|
|
885
|
+
def govuk_submit(text = config.default_submit_button_text, warning: false, secondary: false, inverse: false, prevent_double_click: true, validate: config.default_submit_validate, disabled: false, **kwargs, &block)
|
|
886
|
+
Elements::Submit.new(self, text, warning: warning, secondary: secondary, inverse: inverse, prevent_double_click: prevent_double_click, validate: validate, disabled: disabled, **kwargs, &block).html
|
|
874
887
|
end
|
|
875
888
|
|
|
876
889
|
# Generates three inputs for the +day+, +month+ and +year+ components of a date
|
|
@@ -5,7 +5,7 @@ module GOVUKDesignSystemFormBuilder
|
|
|
5
5
|
include Traits::HTMLClasses
|
|
6
6
|
include Traits::HTMLAttributes
|
|
7
7
|
|
|
8
|
-
def initialize(builder, text, warning:, secondary:, prevent_double_click:, validate:, disabled:, **kwargs, &block)
|
|
8
|
+
def initialize(builder, text, warning:, secondary:, inverse:, prevent_double_click:, validate:, disabled:, **kwargs, &block)
|
|
9
9
|
super(builder, nil, nil)
|
|
10
10
|
|
|
11
11
|
fail ArgumentError, 'buttons can be warning or secondary' if warning && secondary
|
|
@@ -14,6 +14,7 @@ module GOVUKDesignSystemFormBuilder
|
|
|
14
14
|
@prevent_double_click = prevent_double_click
|
|
15
15
|
@warning = warning
|
|
16
16
|
@secondary = secondary
|
|
17
|
+
@inverse = inverse
|
|
17
18
|
@validate = validate
|
|
18
19
|
@disabled = disabled
|
|
19
20
|
@html_attributes = kwargs
|
|
@@ -68,6 +69,7 @@ module GOVUKDesignSystemFormBuilder
|
|
|
68
69
|
"button--warning" => @warning,
|
|
69
70
|
"button--secondary" => @secondary,
|
|
70
71
|
"button--disabled" => @disabled,
|
|
72
|
+
"button--inverse" => @inverse,
|
|
71
73
|
).prefix(brand)
|
|
72
74
|
end
|
|
73
75
|
end
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
module GOVUKDesignSystemFormBuilder
|
|
2
2
|
module Traits
|
|
3
3
|
module Input
|
|
4
|
-
def initialize(builder, object_name, attribute_name, hint:, label:, caption:, prefix_text:, suffix_text:, width:, form_group:, **kwargs, &block)
|
|
4
|
+
def initialize(builder, object_name, attribute_name, hint:, label:, caption:, prefix_text:, suffix_text:, width:, extra_letter_spacing:, form_group:, **kwargs, &block)
|
|
5
5
|
super(builder, object_name, attribute_name, &block)
|
|
6
6
|
|
|
7
|
-
@width
|
|
8
|
-
@label
|
|
9
|
-
@caption
|
|
10
|
-
@hint
|
|
11
|
-
@prefix_text
|
|
12
|
-
@suffix_text
|
|
13
|
-
@html_attributes
|
|
14
|
-
@form_group
|
|
7
|
+
@width = width
|
|
8
|
+
@label = label
|
|
9
|
+
@caption = caption
|
|
10
|
+
@hint = hint
|
|
11
|
+
@prefix_text = prefix_text
|
|
12
|
+
@suffix_text = suffix_text
|
|
13
|
+
@html_attributes = kwargs
|
|
14
|
+
@form_group = form_group
|
|
15
|
+
@extra_letter_spacing = extra_letter_spacing
|
|
15
16
|
end
|
|
16
17
|
|
|
17
18
|
def html
|
|
@@ -53,13 +54,17 @@ module GOVUKDesignSystemFormBuilder
|
|
|
53
54
|
end
|
|
54
55
|
|
|
55
56
|
def classes
|
|
56
|
-
[%(#{brand}-input)].push(width_classes, error_classes).compact
|
|
57
|
+
[%(#{brand}-input)].push(width_classes, error_classes, extra_letter_spacing_classes).compact
|
|
57
58
|
end
|
|
58
59
|
|
|
59
60
|
def error_classes
|
|
60
61
|
%(#{brand}-input--error) if has_errors?
|
|
61
62
|
end
|
|
62
63
|
|
|
64
|
+
def extra_letter_spacing_classes
|
|
65
|
+
%(#{brand}-input--extra-letter-spacing) if @extra_letter_spacing
|
|
66
|
+
end
|
|
67
|
+
|
|
63
68
|
def width_classes
|
|
64
69
|
return if @width.blank?
|
|
65
70
|
|
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: 4.0
|
|
4
|
+
version: 4.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Peter Yates
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2023-
|
|
11
|
+
date: 2023-07-13 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: html-attributes-utils
|
|
@@ -134,14 +134,14 @@ dependencies:
|
|
|
134
134
|
requirements:
|
|
135
135
|
- - "~>"
|
|
136
136
|
- !ruby/object:Gem::Version
|
|
137
|
-
version: 4.
|
|
137
|
+
version: 4.11.0
|
|
138
138
|
type: :development
|
|
139
139
|
prerelease: false
|
|
140
140
|
version_requirements: !ruby/object:Gem::Requirement
|
|
141
141
|
requirements:
|
|
142
142
|
- - "~>"
|
|
143
143
|
- !ruby/object:Gem::Version
|
|
144
|
-
version: 4.
|
|
144
|
+
version: 4.11.0
|
|
145
145
|
- !ruby/object:Gem::Dependency
|
|
146
146
|
name: simplecov
|
|
147
147
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -260,14 +260,14 @@ dependencies:
|
|
|
260
260
|
requirements:
|
|
261
261
|
- - "~>"
|
|
262
262
|
- !ruby/object:Gem::Version
|
|
263
|
-
version: 0.
|
|
263
|
+
version: 0.24.0
|
|
264
264
|
type: :development
|
|
265
265
|
prerelease: false
|
|
266
266
|
version_requirements: !ruby/object:Gem::Requirement
|
|
267
267
|
requirements:
|
|
268
268
|
- - "~>"
|
|
269
269
|
- !ruby/object:Gem::Version
|
|
270
|
-
version: 0.
|
|
270
|
+
version: 0.24.0
|
|
271
271
|
- !ruby/object:Gem::Dependency
|
|
272
272
|
name: webrick
|
|
273
273
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -282,8 +282,8 @@ dependencies:
|
|
|
282
282
|
- - "~>"
|
|
283
283
|
- !ruby/object:Gem::Version
|
|
284
284
|
version: 1.8.1
|
|
285
|
-
description:
|
|
286
|
-
|
|
285
|
+
description: This library provides view components for the GOV.UK Design System. It
|
|
286
|
+
makes creating services more familiar for Ruby on Rails developers.
|
|
287
287
|
email:
|
|
288
288
|
- peter.yates@graphia.co.uk
|
|
289
289
|
executables: []
|
|
@@ -350,12 +350,12 @@ homepage: https://govuk-form-builder.netlify.app
|
|
|
350
350
|
licenses:
|
|
351
351
|
- MIT
|
|
352
352
|
metadata:
|
|
353
|
-
bug_tracker_uri: https://github.com/
|
|
354
|
-
changelog_uri: https://github.com/
|
|
353
|
+
bug_tracker_uri: https://github.com/x-govuk/govuk-form-builder/issues
|
|
354
|
+
changelog_uri: https://github.com/x-govuk/govuk-form-builder/releases
|
|
355
355
|
documentation_uri: https://www.rubydoc.info/gems/govuk_design_system_formbuilder/GOVUKDesignSystemFormBuilder/Builder
|
|
356
356
|
homepage_uri: https://govuk-form-builder.netlify.app
|
|
357
|
-
source_code_uri: https://github.com/
|
|
358
|
-
github_repo: https://github.com/
|
|
357
|
+
source_code_uri: https://github.com/x-govuk/govuk-form-builder
|
|
358
|
+
github_repo: https://github.com/x-govuk/govuk-form-builder
|
|
359
359
|
post_install_message:
|
|
360
360
|
rdoc_options: []
|
|
361
361
|
require_paths:
|
|
@@ -367,12 +367,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
367
367
|
version: '0'
|
|
368
368
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
369
369
|
requirements:
|
|
370
|
-
- - "
|
|
370
|
+
- - ">="
|
|
371
371
|
- !ruby/object:Gem::Version
|
|
372
|
-
version:
|
|
372
|
+
version: '0'
|
|
373
373
|
requirements: []
|
|
374
374
|
rubygems_version: 3.2.33
|
|
375
375
|
signing_key:
|
|
376
376
|
specification_version: 4
|
|
377
|
-
summary: GOV.UK
|
|
377
|
+
summary: GOV.UK Form Builder for Ryby on Rails
|
|
378
378
|
test_files: []
|