ccs-frontend_helpers 0.1.2 → 0.2.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.
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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1786ee02c965fd81738607681aab036498751bda16a9d4fba12862d8690dce63
4
- data.tar.gz: 16db55bafa1e30038a04007529b55c11e013c606a7578a383e6cefa25be47815
3
+ metadata.gz: 294fb84084e25efd871cf66bf4513023648669964b1fbc026aece725bcd64c78
4
+ data.tar.gz: cd55ae750739c51a9561871d5d2c782a067ace1b04f7014e3b41d05349db6f68
5
5
  SHA512:
6
- metadata.gz: d2ec119f59395f3d2d12a09442e9aee00098aa7cc9a2cf601564002feb5752d4b7399e6c4f091404c89b3f2e93d4ac889f35fd883fdf38142ee4ef939f1565c3
7
- data.tar.gz: 225e9d0089b818103b01709d4dbd9a68185e1da445a60d936f99c30f6c5bb7ab6c22821f51c84a447ae372d50f9b11f1430a64f9054b54e31c7fd30268129e9f
6
+ metadata.gz: d64eb288f9595343e58ec37eec080a925928b908273c1880efd409a3cde6f9015567221838496084c03d3799dd54ea7ae10328e4c545d446d0f876b0892efb9c
7
+ data.tar.gz: d1c288ab82c3c78b1049a1bf8d580b515d213d52758aedf378799262efa854880eab99e69251e0cf74502bb29af8da7fa965adf6275f8755672896dc49787a43
data/.rubocop.yml CHANGED
@@ -126,11 +126,13 @@ RSpec/MultipleExpectations:
126
126
  Max: 3
127
127
 
128
128
  RSpec/FilePath:
129
- CustomTransform:
130
- GovUKFrontend: govuk_frontend
131
- GovUK: govuk
129
+ Enabled: false
132
130
 
133
131
  RSpec/SpecFilePathFormat:
134
132
  CustomTransform:
135
133
  GovUKFrontend: govuk_frontend
136
134
  GovUK: govuk
135
+
136
+ Rails/OutputSafety:
137
+ Exclude:
138
+ - 'spec/ccs/frontend_helpers/**/*fixtures_spec.rb'
data/CHANGELOG.md CHANGED
@@ -1,3 +1,33 @@
1
+ ## [0.2.0] - 2024-03-13
2
+
3
+ ### 💥 Breaking changes
4
+
5
+ Update components to be compatible with GOV.UK Frontend v5.2
6
+
7
+ For pagination, the option to enable ellipsis is now:
8
+ ```ruby
9
+ {
10
+ ellipsis: true
11
+ }
12
+ ```
13
+ instead of:
14
+ ```ruby
15
+ {
16
+ type: :ellipsis
17
+ }
18
+ ```
19
+
20
+ ### 🏠 Internal changes
21
+
22
+ Add tests for GOV.UK Frontend fixtures
23
+
24
+ ### 🆕 New features
25
+
26
+ The following GOV.UK helpers have been added:
27
+
28
+ - Exit this page
29
+ - Task list
30
+
1
31
  ## [0.1.2] - 2023-11-16
2
32
 
3
33
  Fix issue with radios component which, when passed a model or form, would treat the value as an array.
data/Gemfile CHANGED
@@ -10,15 +10,16 @@ gem 'bundler', '~> 2.3'
10
10
  gem 'rake', '~> 13.1'
11
11
 
12
12
  # Gems for testing the package
13
- gem 'capybara', '~> 3.39.2'
14
- gem 'rspec', '~> 3.12'
13
+ gem 'capybara', '~> 3.40.0'
14
+ gem 'rspec', '~> 3.13'
15
15
  gem 'simplecov', '~> 0.21'
16
+ gem 'nokogiri-diff', '~> 0.3.0'
16
17
 
17
18
  # Gems for linting/formatting the package
18
- gem 'rubocop', '~> 1.57'
19
- gem 'rubocop-rails', '~> 2.22'
19
+ gem 'rubocop', '~> 1.62'
20
+ gem 'rubocop-rails', '~> 2.24'
20
21
  gem 'rubocop-rake', '~> 0.6'
21
- gem 'rubocop-rspec', '~> 2.25'
22
+ gem 'rubocop-rspec', '~> 2.27'
22
23
 
23
24
  # Gems for documenting the package
24
25
  gem 'yard', '~> 0.9'
data/Gemfile.lock CHANGED
@@ -1,41 +1,41 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ccs-frontend_helpers (0.1.2)
4
+ ccs-frontend_helpers (0.2.0)
5
5
  rails (>= 6.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- actioncable (7.1.2)
11
- actionpack (= 7.1.2)
12
- activesupport (= 7.1.2)
10
+ actioncable (7.1.3.2)
11
+ actionpack (= 7.1.3.2)
12
+ activesupport (= 7.1.3.2)
13
13
  nio4r (~> 2.0)
14
14
  websocket-driver (>= 0.6.1)
15
15
  zeitwerk (~> 2.6)
16
- actionmailbox (7.1.2)
17
- actionpack (= 7.1.2)
18
- activejob (= 7.1.2)
19
- activerecord (= 7.1.2)
20
- activestorage (= 7.1.2)
21
- activesupport (= 7.1.2)
16
+ actionmailbox (7.1.3.2)
17
+ actionpack (= 7.1.3.2)
18
+ activejob (= 7.1.3.2)
19
+ activerecord (= 7.1.3.2)
20
+ activestorage (= 7.1.3.2)
21
+ activesupport (= 7.1.3.2)
22
22
  mail (>= 2.7.1)
23
23
  net-imap
24
24
  net-pop
25
25
  net-smtp
26
- actionmailer (7.1.2)
27
- actionpack (= 7.1.2)
28
- actionview (= 7.1.2)
29
- activejob (= 7.1.2)
30
- activesupport (= 7.1.2)
26
+ actionmailer (7.1.3.2)
27
+ actionpack (= 7.1.3.2)
28
+ actionview (= 7.1.3.2)
29
+ activejob (= 7.1.3.2)
30
+ activesupport (= 7.1.3.2)
31
31
  mail (~> 2.5, >= 2.5.4)
32
32
  net-imap
33
33
  net-pop
34
34
  net-smtp
35
35
  rails-dom-testing (~> 2.2)
36
- actionpack (7.1.2)
37
- actionview (= 7.1.2)
38
- activesupport (= 7.1.2)
36
+ actionpack (7.1.3.2)
37
+ actionview (= 7.1.3.2)
38
+ activesupport (= 7.1.3.2)
39
39
  nokogiri (>= 1.8.5)
40
40
  racc
41
41
  rack (>= 2.2.4)
@@ -43,35 +43,35 @@ GEM
43
43
  rack-test (>= 0.6.3)
44
44
  rails-dom-testing (~> 2.2)
45
45
  rails-html-sanitizer (~> 1.6)
46
- actiontext (7.1.2)
47
- actionpack (= 7.1.2)
48
- activerecord (= 7.1.2)
49
- activestorage (= 7.1.2)
50
- activesupport (= 7.1.2)
46
+ actiontext (7.1.3.2)
47
+ actionpack (= 7.1.3.2)
48
+ activerecord (= 7.1.3.2)
49
+ activestorage (= 7.1.3.2)
50
+ activesupport (= 7.1.3.2)
51
51
  globalid (>= 0.6.0)
52
52
  nokogiri (>= 1.8.5)
53
- actionview (7.1.2)
54
- activesupport (= 7.1.2)
53
+ actionview (7.1.3.2)
54
+ activesupport (= 7.1.3.2)
55
55
  builder (~> 3.1)
56
56
  erubi (~> 1.11)
57
57
  rails-dom-testing (~> 2.2)
58
58
  rails-html-sanitizer (~> 1.6)
59
- activejob (7.1.2)
60
- activesupport (= 7.1.2)
59
+ activejob (7.1.3.2)
60
+ activesupport (= 7.1.3.2)
61
61
  globalid (>= 0.3.6)
62
- activemodel (7.1.2)
63
- activesupport (= 7.1.2)
64
- activerecord (7.1.2)
65
- activemodel (= 7.1.2)
66
- activesupport (= 7.1.2)
62
+ activemodel (7.1.3.2)
63
+ activesupport (= 7.1.3.2)
64
+ activerecord (7.1.3.2)
65
+ activemodel (= 7.1.3.2)
66
+ activesupport (= 7.1.3.2)
67
67
  timeout (>= 0.4.0)
68
- activestorage (7.1.2)
69
- actionpack (= 7.1.2)
70
- activejob (= 7.1.2)
71
- activerecord (= 7.1.2)
72
- activesupport (= 7.1.2)
68
+ activestorage (7.1.3.2)
69
+ actionpack (= 7.1.3.2)
70
+ activejob (= 7.1.3.2)
71
+ activerecord (= 7.1.3.2)
72
+ activesupport (= 7.1.3.2)
73
73
  marcel (~> 1.0)
74
- activesupport (7.1.2)
74
+ activesupport (7.1.3.2)
75
75
  base64
76
76
  bigdecimal
77
77
  concurrent-ruby (~> 1.0, >= 1.0.2)
@@ -81,41 +81,40 @@ GEM
81
81
  minitest (>= 5.1)
82
82
  mutex_m
83
83
  tzinfo (~> 2.0)
84
- addressable (2.8.4)
84
+ addressable (2.8.6)
85
85
  public_suffix (>= 2.0.2, < 6.0)
86
86
  ast (2.4.2)
87
87
  base64 (0.2.0)
88
- bigdecimal (3.1.4)
88
+ bigdecimal (3.1.6)
89
89
  builder (3.2.4)
90
- capybara (3.39.2)
90
+ capybara (3.40.0)
91
91
  addressable
92
92
  matrix
93
93
  mini_mime (>= 0.1.3)
94
- nokogiri (~> 1.8)
94
+ nokogiri (~> 1.11)
95
95
  rack (>= 1.6.0)
96
96
  rack-test (>= 0.6.3)
97
97
  regexp_parser (>= 1.5, < 3.0)
98
98
  xpath (~> 3.2)
99
- concurrent-ruby (1.2.2)
99
+ concurrent-ruby (1.2.3)
100
100
  connection_pool (2.4.1)
101
101
  crass (1.0.6)
102
102
  date (3.3.4)
103
- diff-lcs (1.5.0)
103
+ diff-lcs (1.5.1)
104
104
  docile (1.4.0)
105
- drb (2.2.0)
106
- ruby2_keywords
105
+ drb (2.2.1)
107
106
  erubi (1.12.0)
108
107
  globalid (1.2.1)
109
108
  activesupport (>= 6.1)
110
- i18n (1.14.1)
109
+ i18n (1.14.4)
111
110
  concurrent-ruby (~> 1.0)
112
- io-console (0.6.0)
113
- irb (1.9.0)
111
+ io-console (0.7.2)
112
+ irb (1.11.2)
114
113
  rdoc
115
- reline (>= 0.3.8)
116
- json (2.6.3)
114
+ reline (>= 0.4.2)
115
+ json (2.7.1)
117
116
  language_server-protocol (3.17.0.3)
118
- loofah (2.21.4)
117
+ loofah (2.22.0)
119
118
  crass (~> 1.0.2)
120
119
  nokogiri (>= 1.12.0)
121
120
  mail (2.8.1)
@@ -126,31 +125,34 @@ GEM
126
125
  marcel (1.0.2)
127
126
  matrix (0.4.2)
128
127
  mini_mime (1.1.5)
129
- minitest (5.20.0)
128
+ minitest (5.22.2)
130
129
  mutex_m (0.2.0)
131
- net-imap (0.4.4)
130
+ net-imap (0.4.10)
132
131
  date
133
132
  net-protocol
134
133
  net-pop (0.1.2)
135
134
  net-protocol
136
135
  net-protocol (0.2.2)
137
136
  timeout
138
- net-smtp (0.4.0)
137
+ net-smtp (0.4.0.1)
139
138
  net-protocol
140
- nio4r (2.5.9)
141
- nokogiri (1.15.4-x86_64-darwin)
139
+ nio4r (2.7.0)
140
+ nokogiri (1.16.2-x86_64-darwin)
142
141
  racc (~> 1.4)
143
- nokogiri (1.15.4-x86_64-linux)
142
+ nokogiri (1.16.2-x86_64-linux)
144
143
  racc (~> 1.4)
145
- parallel (1.23.0)
146
- parser (3.2.2.4)
144
+ nokogiri-diff (0.3.0)
145
+ nokogiri (~> 1.5)
146
+ tdiff (~> 0.4)
147
+ parallel (1.24.0)
148
+ parser (3.3.0.5)
147
149
  ast (~> 2.4.1)
148
150
  racc
149
- psych (5.1.1.1)
151
+ psych (5.1.2)
150
152
  stringio
151
- public_suffix (5.0.1)
153
+ public_suffix (5.0.4)
152
154
  racc (1.7.3)
153
- rack (3.0.8)
155
+ rack (3.0.9.1)
154
156
  rack-session (2.0.0)
155
157
  rack (>= 3.0.0)
156
158
  rack-test (2.1.0)
@@ -158,20 +160,20 @@ GEM
158
160
  rackup (2.1.0)
159
161
  rack (>= 3)
160
162
  webrick (~> 1.8)
161
- rails (7.1.2)
162
- actioncable (= 7.1.2)
163
- actionmailbox (= 7.1.2)
164
- actionmailer (= 7.1.2)
165
- actionpack (= 7.1.2)
166
- actiontext (= 7.1.2)
167
- actionview (= 7.1.2)
168
- activejob (= 7.1.2)
169
- activemodel (= 7.1.2)
170
- activerecord (= 7.1.2)
171
- activestorage (= 7.1.2)
172
- activesupport (= 7.1.2)
163
+ rails (7.1.3.2)
164
+ actioncable (= 7.1.3.2)
165
+ actionmailbox (= 7.1.3.2)
166
+ actionmailer (= 7.1.3.2)
167
+ actionpack (= 7.1.3.2)
168
+ actiontext (= 7.1.3.2)
169
+ actionview (= 7.1.3.2)
170
+ activejob (= 7.1.3.2)
171
+ activemodel (= 7.1.3.2)
172
+ activerecord (= 7.1.3.2)
173
+ activestorage (= 7.1.3.2)
174
+ activesupport (= 7.1.3.2)
173
175
  bundler (>= 1.15.0)
174
- railties (= 7.1.2)
176
+ railties (= 7.1.3.2)
175
177
  rails-dom-testing (2.2.0)
176
178
  activesupport (>= 5.0.0)
177
179
  minitest
@@ -179,9 +181,9 @@ GEM
179
181
  rails-html-sanitizer (1.6.0)
180
182
  loofah (~> 2.21)
181
183
  nokogiri (~> 1.14)
182
- railties (7.1.2)
183
- actionpack (= 7.1.2)
184
- activesupport (= 7.1.2)
184
+ railties (7.1.3.2)
185
+ actionpack (= 7.1.3.2)
186
+ activesupport (= 7.1.3.2)
185
187
  irb
186
188
  rackup (>= 1.0.0)
187
189
  rake (>= 12.2)
@@ -189,61 +191,62 @@ GEM
189
191
  zeitwerk (~> 2.6)
190
192
  rainbow (3.1.1)
191
193
  rake (13.1.0)
192
- rdoc (6.6.0)
194
+ rdoc (6.6.2)
193
195
  psych (>= 4.0.0)
194
- regexp_parser (2.8.2)
195
- reline (0.4.0)
196
+ regexp_parser (2.9.0)
197
+ reline (0.4.2)
196
198
  io-console (~> 0.5)
197
199
  rexml (3.2.6)
198
- rspec (3.12.0)
199
- rspec-core (~> 3.12.0)
200
- rspec-expectations (~> 3.12.0)
201
- rspec-mocks (~> 3.12.0)
202
- rspec-core (3.12.1)
203
- rspec-support (~> 3.12.0)
204
- rspec-expectations (3.12.2)
200
+ rspec (3.13.0)
201
+ rspec-core (~> 3.13.0)
202
+ rspec-expectations (~> 3.13.0)
203
+ rspec-mocks (~> 3.13.0)
204
+ rspec-core (3.13.0)
205
+ rspec-support (~> 3.13.0)
206
+ rspec-expectations (3.13.0)
205
207
  diff-lcs (>= 1.2.0, < 2.0)
206
- rspec-support (~> 3.12.0)
207
- rspec-mocks (3.12.3)
208
+ rspec-support (~> 3.13.0)
209
+ rspec-mocks (3.13.0)
208
210
  diff-lcs (>= 1.2.0, < 2.0)
209
- rspec-support (~> 3.12.0)
210
- rspec-support (3.12.0)
211
- rubocop (1.57.2)
211
+ rspec-support (~> 3.13.0)
212
+ rspec-support (3.13.1)
213
+ rubocop (1.62.1)
212
214
  json (~> 2.3)
213
215
  language_server-protocol (>= 3.17.0)
214
216
  parallel (~> 1.10)
215
- parser (>= 3.2.2.4)
217
+ parser (>= 3.3.0.2)
216
218
  rainbow (>= 2.2.2, < 4.0)
217
219
  regexp_parser (>= 1.8, < 3.0)
218
220
  rexml (>= 3.2.5, < 4.0)
219
- rubocop-ast (>= 1.28.1, < 2.0)
221
+ rubocop-ast (>= 1.31.1, < 2.0)
220
222
  ruby-progressbar (~> 1.7)
221
223
  unicode-display_width (>= 2.4.0, < 3.0)
222
- rubocop-ast (1.30.0)
223
- parser (>= 3.2.1.0)
224
- rubocop-capybara (2.19.0)
224
+ rubocop-ast (1.31.2)
225
+ parser (>= 3.3.0.4)
226
+ rubocop-capybara (2.20.0)
227
+ rubocop (~> 1.41)
228
+ rubocop-factory_bot (2.25.1)
225
229
  rubocop (~> 1.41)
226
- rubocop-factory_bot (2.24.0)
227
- rubocop (~> 1.33)
228
- rubocop-rails (2.22.1)
230
+ rubocop-rails (2.24.0)
229
231
  activesupport (>= 4.2.0)
230
232
  rack (>= 1.1)
231
233
  rubocop (>= 1.33.0, < 2.0)
234
+ rubocop-ast (>= 1.31.1, < 2.0)
232
235
  rubocop-rake (0.6.0)
233
236
  rubocop (~> 1.0)
234
- rubocop-rspec (2.25.0)
237
+ rubocop-rspec (2.27.1)
235
238
  rubocop (~> 1.40)
236
239
  rubocop-capybara (~> 2.17)
237
240
  rubocop-factory_bot (~> 2.22)
238
241
  ruby-progressbar (1.13.0)
239
- ruby2_keywords (0.0.5)
240
242
  simplecov (0.22.0)
241
243
  docile (~> 1.1)
242
244
  simplecov-html (~> 0.11)
243
245
  simplecov_json_formatter (~> 0.1)
244
246
  simplecov-html (0.12.3)
245
247
  simplecov_json_formatter (0.1.4)
246
- stringio (3.0.9)
248
+ stringio (3.1.0)
249
+ tdiff (0.4.0)
247
250
  thor (1.3.0)
248
251
  timeout (0.4.1)
249
252
  tzinfo (2.0.6)
@@ -255,8 +258,8 @@ GEM
255
258
  websocket-extensions (0.1.5)
256
259
  xpath (3.2.0)
257
260
  nokogiri (~> 1.8)
258
- yard (0.9.34)
259
- zeitwerk (2.6.12)
261
+ yard (0.9.36)
262
+ zeitwerk (2.6.13)
260
263
 
261
264
  PLATFORMS
262
265
  x86_64-darwin-19
@@ -265,14 +268,15 @@ PLATFORMS
265
268
 
266
269
  DEPENDENCIES
267
270
  bundler (~> 2.3)
268
- capybara (~> 3.39.2)
271
+ capybara (~> 3.40.0)
269
272
  ccs-frontend_helpers!
273
+ nokogiri-diff (~> 0.3.0)
270
274
  rake (~> 13.1)
271
- rspec (~> 3.12)
272
- rubocop (~> 1.57)
273
- rubocop-rails (~> 2.22)
275
+ rspec (~> 3.13)
276
+ rubocop (~> 1.62)
277
+ rubocop-rails (~> 2.24)
274
278
  rubocop-rake (~> 0.6)
275
- rubocop-rspec (~> 2.25)
279
+ rubocop-rspec (~> 2.27)
276
280
  simplecov (~> 0.21)
277
281
  yard (~> 0.9)
278
282
 
data/README.md CHANGED
@@ -8,6 +8,17 @@ This project contains two applications (both use the Ruby on Rails framework):
8
8
  - [Crown Marketplace](https://github.com/Crown-Commercial-Service/crown-marketplace)
9
9
  - [Crown Marketplace Legacy](https://github.com/Crown-Commercial-Service/crown-marketplace-legacy)
10
10
 
11
+ ## Compatibility
12
+
13
+ The following table shows the version of CCS Frontend Helpers that you should use for your targeted version of GOV.UK Frontend:
14
+
15
+ | CCS Frontend Helpers Version | Target GOV.UK Frontend Version |
16
+ | ----------------------------- | ------------------------------ |
17
+ | [0.2.0](https://github.com/tim-s-ccs/ccs-frontend_helpers/releases/tag/v0.2.0) | [5.2.0](https://github.com/alphagov/govuk-frontend/releases/tag/v5.2.0) |
18
+ | [0.1.2](https://github.com/tim-s-ccs/ccs-frontend_helpers/releases/tag/v0.1.2) | [4.7.0](https://github.com/alphagov/govuk-frontend/releases/tag/v4.7.0) |
19
+
20
+ Any other versions of GOV.UK Frontend not shown above _may_ still be compatible, but have not been specifically tested and verified.
21
+
11
22
  ## Installation
12
23
 
13
24
  Install the gem and add to the application's Gemfile by executing:
@@ -41,7 +41,7 @@ module CCS
41
41
  # @return [ActiveSupport::SafeBuffer]
42
42
 
43
43
  def render
44
- tag.div(class: 'govuk-accordion__section-content', id: "#{accordion_id}-content-#{index}", aria: { labelledby: "#{accordion_id}-heading-#{index}" }) do
44
+ tag.div(class: 'govuk-accordion__section-content', id: "#{accordion_id}-content-#{index}") do
45
45
  section[:content] || tag.p(section[:text], class: 'govuk-body')
46
46
  end
47
47
  end
@@ -28,6 +28,12 @@ module CCS
28
28
  #
29
29
  # @option options [String] :classes additional CSS classes for the accordion HTML
30
30
  # @option options [Integer] :heading_level (2) heading level, from 1 to 6
31
+ # @option options [String] :hide_all_sections_text The text content of the ‘Hide all sections’ button at the top of the accordion when all sections are expanded
32
+ # @option options [String] :hide_section_text The text content of the ‘Hide’ button within each section of the accordion, which is visible when the section is expanded
33
+ # @option options [String] :hide_section_aria_label_text Text made available to assistive technologies, like screen-readers, as the final part of the toggle’s accessible name when the section is expanded. Defaults to "Hide this section".
34
+ # @option options [String] :show_all_sections_text The text content of the ‘Show all sections’ button at the top of the accordion when at least one section is collapsed
35
+ # @option options [String] :show_section_text The text content of the ‘Show’ button within each section of the accordion, which is visible when the section is collapsed
36
+ # @option options [String] :show_section_aria_label_text Text made available to assistive technologies, like screen-readers, as the final part of the toggle’s accessible name when the section is collapsed. Defaults to "Show this section".
31
37
  # @option options [Hash] :attributes any additional attributes that will added as part of the HTML
32
38
 
33
39
  def initialize(accordion_id:, accordion_sections:, **options)
@@ -36,6 +42,11 @@ module CCS
36
42
  @options[:attributes][:id] = accordion_id
37
43
  @options[:heading_level] ||= 2
38
44
 
45
+ %i[hide_all_sections hide_section hide_section_aria_label show_all_sections show_section show_section_aria_label].each do |data_attribute|
46
+ data_attribute_name = :"#{data_attribute}_text"
47
+ @options[:attributes][:data][:"i18n.#{data_attribute.to_s.gsub('_', '-')}"] = options[data_attribute_name] if options[data_attribute_name]
48
+ end
49
+
39
50
  @accordion_sections = accordion_sections.map.with_index(1) { |accordion_section, index| Section.new(section: accordion_section, accordion_id: accordion_id, index: index, heading_level: @options[:heading_level]) }
40
51
  end
41
52
 
@@ -32,7 +32,10 @@ module CCS
32
32
  def initialize(text:, **options)
33
33
  super(**options)
34
34
 
35
- @options[:attributes][:class] << ' govuk-button--disabled' if @options[:attributes][:disabled]
35
+ if @options[:attributes][:disabled]
36
+ @options[:attributes][:aria] ||= {}
37
+ @options[:attributes][:aria][:disabled] = true
38
+ end
36
39
  @options[:attributes][:class] << ' govuk-button--start' if @options[:is_start_button]
37
40
 
38
41
  @text = text
@@ -46,6 +46,7 @@ module CCS
46
46
  if href && options[:attributes][:type] != :button
47
47
  link_to(text, href, **options[:attributes])
48
48
  else
49
+ options[:attributes][:type] ||= :button
49
50
  Button.new(text: text, href: href, context: context, **options).render
50
51
  end
51
52
  end
@@ -56,7 +56,7 @@ module CCS
56
56
  tag.div(class: 'govuk-grid-column-two-thirds') do
57
57
  concat(tag.h2(heading_text, class: 'govuk-cookie-banner__heading govuk-heading-m')) if heading_text
58
58
  concat(tag.div(class: 'govuk-cookie-banner__content') do
59
- content || tag.p(text, class: 'govuk-body')
59
+ content || tag.p(text, class: 'govuk-body') if content || text
60
60
  end)
61
61
  end
62
62
  end)
@@ -46,7 +46,7 @@ module CCS
46
46
 
47
47
  # The default attributes for the details
48
48
 
49
- DEFAULT_ATTRIBUTES = { class: 'govuk-details', data: { module: 'govuk-details' } }.freeze
49
+ DEFAULT_ATTRIBUTES = { class: 'govuk-details' }.freeze
50
50
  end
51
51
  end
52
52
  end
@@ -33,7 +33,7 @@ module CCS
33
33
  def initialize(message:, attribute:, **options)
34
34
  super(**options)
35
35
 
36
- @options[:attributes][:id] ||= "#{attribute}-error"
36
+ @options[:attributes][:id] ||= "#{attribute}-error" if attribute
37
37
 
38
38
  @message = message
39
39
  @attribute = attribute
@@ -46,7 +46,10 @@ module CCS
46
46
 
47
47
  def render
48
48
  tag.p(**options[:attributes]) do
49
- concat(tag.span("#{visually_hidden_text}: ", class: 'govuk-visually-hidden')) if visually_hidden_text.present?
49
+ if visually_hidden_text.present?
50
+ concat(tag.span("#{visually_hidden_text}:", class: 'govuk-visually-hidden'))
51
+ concat(' ')
52
+ end
50
53
  concat(message)
51
54
  end
52
55
  end
@@ -0,0 +1,79 @@
1
+ require_relative '../base'
2
+ require_relative 'button'
3
+
4
+ module CCS
5
+ module Components
6
+ module GovUK
7
+ # = GOV.UK Exit this page
8
+ #
9
+ # This is used to generate the exit this page component from the
10
+ # {https://design-system.service.gov.uk/components/exit-this-page GDS - Components - Exit this page}
11
+ #
12
+ # @!attribute [r] text
13
+ # @return [String] Text for the exit this page
14
+ # @!attribute [r] redirect_url
15
+ # @return [String] The redirect_url for the exit this page
16
+
17
+ class ExitThisPage < Base
18
+ include ActionView::Context
19
+ include ActionView::Helpers
20
+
21
+ private
22
+
23
+ attr_reader :text, :redirect_url
24
+
25
+ public
26
+
27
+ # @param text [String] the text for the exit this page
28
+ # @param redirect_url [String] the href for the exit this page
29
+ # @param options [Hash] options that will be used in customising the HTML
30
+ #
31
+ # @option options [String] :classes additional CSS classes for the exit this page HTML
32
+ # @option options [String] :activated_text Text announced by screen readers when Exit this Page has been activated via the keyboard shortcut. Defaults to "Loading."
33
+ # @option options [String] :timed_out_text Text announced by screen readers when the keyboard shortcut has timed out without successful activation. Defaults to "Exit this page expired."
34
+ # @option options [String] :press_two_more_times_text Text announced by screen readers when the user must press Shift two more times to activate the button. Defaults to "Shift, press 2 more times to exit."
35
+ # @option options [String] :press_one_more_time_text Text announced by screen readers when the user must press Shift one more time to activate the button. Defaults to "Shift, press 1 more time to exit."
36
+ # @option options [Hash] :attributes ({}) any additional attributes that will added as part of the HTML
37
+
38
+ def initialize(text: nil, redirect_url: nil, **options)
39
+ super(**options)
40
+
41
+ @text = text || default_text
42
+ @redirect_url = redirect_url || 'https://www.bbc.co.uk/weather'
43
+
44
+ %i[activated timed_out press_two_more_times press_one_more_time].each do |data_attribute|
45
+ data_attribute_name = :"#{data_attribute}_text"
46
+ @options[:attributes][:data][:"i18n.#{data_attribute.to_s.gsub('_', '-')}"] = options[data_attribute_name] if options[data_attribute_name]
47
+ end
48
+ end
49
+
50
+ # Generates the HTML for the GOV.UK Exit this page component
51
+ #
52
+ # @return [ActiveSupport::SafeBuffer]
53
+
54
+ def render
55
+ tag.div(**options[:attributes]) do
56
+ Button.new(text: text, href: redirect_url, context: context, classes: 'govuk-button--warning govuk-exit-this-page__button govuk-js-exit-this-page-button', attributes: { rel: 'nofollow noreferrer' }).render
57
+ end
58
+ end
59
+
60
+ # The default attributes for the exit this page
61
+
62
+ DEFAULT_ATTRIBUTES = { class: 'govuk-exit-this-page', data: { module: 'govuk-exit-this-page' } }.freeze
63
+
64
+ private
65
+
66
+ # Generates the default HTML for the GOV.UK exit this page component
67
+ #
68
+ # @return [ActiveSupport::SafeBuffer]
69
+
70
+ def default_text
71
+ capture do
72
+ concat(tag.span('Emergency', class: 'govuk-visually-hidden'))
73
+ concat(' Exit this page')
74
+ end
75
+ end
76
+ end
77
+ end
78
+ end
79
+ end