ccs-frontend_helpers 1.1.2 → 2.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c767bc0c111873e344ea2e1847d087ee44691b585a3df644631e441564e70a44
4
- data.tar.gz: 4664e304d2abf2c9250db41cc6e91d2e5cfdadd9108b357bd96ae29af5ebea78
3
+ metadata.gz: e09c05f35265d0a0818888f98fc01eac5c19d7d8383e328d6ebec40616a58fe7
4
+ data.tar.gz: a4439bb27706ccb279e5c1fc4ff4336d0a2bef57b09f5dd4f2adad2e045430e3
5
5
  SHA512:
6
- metadata.gz: cd36ec46a2dd57c7d630de462d7456f148e554f3a8c8657453799a6ac6a2f0d36d7b5178834acb2af606d576b98c1d0c430d9357c4f8d8f7a30352bf0d7eab61
7
- data.tar.gz: 976be2070da2c8d59e97cdf4a831651c1cd0060c00448d7981f96eb6d0a76ded75a934b1cb75864c0b21bb1437570c743ab89180170847f8693a33460ff082a1
6
+ metadata.gz: 79c572690bae3d82a2c72642ef22f576ab54155a03e2ef1b4c54acfb6d7eddf5da6175080c8aa05fc134ef32b2bb83dc2f9ce50cdefe19c6b530666bc18b02be
7
+ data.tar.gz: 6cbe9e413665a50a585e2728c0dd3aefa7a5f36722f2dff1e1eab0e2c5123f0f28594f0095e98b89523761bfcd1e767bbb0f8081609925e74793dbef1a355751
data/.rubocop.yml CHANGED
@@ -7,7 +7,7 @@ require:
7
7
 
8
8
  AllCops:
9
9
  NewCops: enable
10
- TargetRubyVersion: 3.0
10
+ TargetRubyVersion: 3.1
11
11
  Exclude:
12
12
  - "bin/**/*"
13
13
  - "tmp/**/*"
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.3.1
1
+ 3.3.5
data/CHANGELOG.md CHANGED
@@ -7,6 +7,27 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [2.0.0] - 2024-11-05
11
+
12
+ ### Changed
13
+
14
+ - Update minimum required Rails version to v7.0
15
+ - Updated minimum Ruby version to 3.1
16
+
17
+ ### Added
18
+
19
+ - Updated GOV.UK Frontend to v5.7.1
20
+ - Updated CCS Frontend to v1.2.0
21
+
22
+ ## [1.2.0] - 2024-09-02
23
+
24
+ ### Added
25
+
26
+ - Update to CCS Frontend v1.1.3
27
+ - Update to GOV.UK Frontend v5.6.0
28
+ - The following GOV.UK helpers have been added:
29
+ - Service navigation
30
+
10
31
  ## [1.1.1] - 2024-08-12
11
32
 
12
33
  ### Added
data/Gemfile CHANGED
@@ -16,11 +16,11 @@ gem 'simplecov', '~> 0.21'
16
16
  gem 'nokogiri-diff', '~> 0.3.0'
17
17
 
18
18
  # Gems for linting/formatting the package
19
- gem 'rubocop', '~> 1.65'
19
+ gem 'rubocop', '~> 1.68'
20
20
  gem 'rubocop-capybara', '~> 2.20'
21
- gem 'rubocop-rails', '~> 2.25'
21
+ gem 'rubocop-rails', '~> 2.27'
22
22
  gem 'rubocop-rake', '~> 0.6'
23
- gem 'rubocop-rspec', '~> 3.0'
23
+ gem 'rubocop-rspec', '~> 3.2'
24
24
 
25
25
  # Gems for documenting the package
26
26
  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 (1.1.2)
5
- rails (>= 6.0)
4
+ ccs-frontend_helpers (2.0.0)
5
+ rails (>= 7.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- actioncable (7.1.3.4)
11
- actionpack (= 7.1.3.4)
12
- activesupport (= 7.1.3.4)
10
+ actioncable (7.1.4.2)
11
+ actionpack (= 7.1.4.2)
12
+ activesupport (= 7.1.4.2)
13
13
  nio4r (~> 2.0)
14
14
  websocket-driver (>= 0.6.1)
15
15
  zeitwerk (~> 2.6)
16
- actionmailbox (7.1.3.4)
17
- actionpack (= 7.1.3.4)
18
- activejob (= 7.1.3.4)
19
- activerecord (= 7.1.3.4)
20
- activestorage (= 7.1.3.4)
21
- activesupport (= 7.1.3.4)
16
+ actionmailbox (7.1.4.2)
17
+ actionpack (= 7.1.4.2)
18
+ activejob (= 7.1.4.2)
19
+ activerecord (= 7.1.4.2)
20
+ activestorage (= 7.1.4.2)
21
+ activesupport (= 7.1.4.2)
22
22
  mail (>= 2.7.1)
23
23
  net-imap
24
24
  net-pop
25
25
  net-smtp
26
- actionmailer (7.1.3.4)
27
- actionpack (= 7.1.3.4)
28
- actionview (= 7.1.3.4)
29
- activejob (= 7.1.3.4)
30
- activesupport (= 7.1.3.4)
26
+ actionmailer (7.1.4.2)
27
+ actionpack (= 7.1.4.2)
28
+ actionview (= 7.1.4.2)
29
+ activejob (= 7.1.4.2)
30
+ activesupport (= 7.1.4.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.3.4)
37
- actionview (= 7.1.3.4)
38
- activesupport (= 7.1.3.4)
36
+ actionpack (7.1.4.2)
37
+ actionview (= 7.1.4.2)
38
+ activesupport (= 7.1.4.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.3.4)
47
- actionpack (= 7.1.3.4)
48
- activerecord (= 7.1.3.4)
49
- activestorage (= 7.1.3.4)
50
- activesupport (= 7.1.3.4)
46
+ actiontext (7.1.4.2)
47
+ actionpack (= 7.1.4.2)
48
+ activerecord (= 7.1.4.2)
49
+ activestorage (= 7.1.4.2)
50
+ activesupport (= 7.1.4.2)
51
51
  globalid (>= 0.6.0)
52
52
  nokogiri (>= 1.8.5)
53
- actionview (7.1.3.4)
54
- activesupport (= 7.1.3.4)
53
+ actionview (7.1.4.2)
54
+ activesupport (= 7.1.4.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.3.4)
60
- activesupport (= 7.1.3.4)
59
+ activejob (7.1.4.2)
60
+ activesupport (= 7.1.4.2)
61
61
  globalid (>= 0.3.6)
62
- activemodel (7.1.3.4)
63
- activesupport (= 7.1.3.4)
64
- activerecord (7.1.3.4)
65
- activemodel (= 7.1.3.4)
66
- activesupport (= 7.1.3.4)
62
+ activemodel (7.1.4.2)
63
+ activesupport (= 7.1.4.2)
64
+ activerecord (7.1.4.2)
65
+ activemodel (= 7.1.4.2)
66
+ activesupport (= 7.1.4.2)
67
67
  timeout (>= 0.4.0)
68
- activestorage (7.1.3.4)
69
- actionpack (= 7.1.3.4)
70
- activejob (= 7.1.3.4)
71
- activerecord (= 7.1.3.4)
72
- activesupport (= 7.1.3.4)
68
+ activestorage (7.1.4.2)
69
+ actionpack (= 7.1.4.2)
70
+ activejob (= 7.1.4.2)
71
+ activerecord (= 7.1.4.2)
72
+ activesupport (= 7.1.4.2)
73
73
  marcel (~> 1.0)
74
- activesupport (7.1.3.4)
74
+ activesupport (7.1.4.2)
75
75
  base64
76
76
  bigdecimal
77
77
  concurrent-ruby (~> 1.0, >= 1.0.2)
@@ -96,7 +96,7 @@ GEM
96
96
  rack-test (>= 0.6.3)
97
97
  regexp_parser (>= 1.5, < 3.0)
98
98
  xpath (~> 3.2)
99
- concurrent-ruby (1.3.3)
99
+ concurrent-ruby (1.3.4)
100
100
  connection_pool (2.4.1)
101
101
  crass (1.0.6)
102
102
  date (3.3.4)
@@ -106,13 +106,13 @@ GEM
106
106
  erubi (1.13.0)
107
107
  globalid (1.2.1)
108
108
  activesupport (>= 6.1)
109
- i18n (1.14.5)
109
+ i18n (1.14.6)
110
110
  concurrent-ruby (~> 1.0)
111
111
  io-console (0.7.2)
112
112
  irb (1.14.0)
113
113
  rdoc (>= 4.0.0)
114
114
  reline (>= 0.4.2)
115
- json (2.7.2)
115
+ json (2.7.5)
116
116
  language_server-protocol (3.17.0.3)
117
117
  loofah (2.22.0)
118
118
  crass (~> 1.0.2)
@@ -125,9 +125,9 @@ GEM
125
125
  marcel (1.0.4)
126
126
  matrix (0.4.2)
127
127
  mini_mime (1.1.5)
128
- minitest (5.24.1)
128
+ minitest (5.25.1)
129
129
  mutex_m (0.2.0)
130
- net-imap (0.4.14)
130
+ net-imap (0.4.15)
131
131
  date
132
132
  net-protocol
133
133
  net-pop (0.1.2)
@@ -137,22 +137,22 @@ GEM
137
137
  net-smtp (0.5.0)
138
138
  net-protocol
139
139
  nio4r (2.7.3)
140
- nokogiri (1.16.5-x86_64-darwin)
140
+ nokogiri (1.16.7-x86_64-darwin)
141
141
  racc (~> 1.4)
142
- nokogiri (1.16.5-x86_64-linux)
142
+ nokogiri (1.16.7-x86_64-linux)
143
143
  racc (~> 1.4)
144
144
  nokogiri-diff (0.3.0)
145
145
  nokogiri (~> 1.5)
146
146
  tdiff (~> 0.4)
147
- parallel (1.26.2)
148
- parser (3.3.4.2)
147
+ parallel (1.26.3)
148
+ parser (3.3.5.1)
149
149
  ast (~> 2.4.1)
150
150
  racc
151
151
  psych (5.1.2)
152
152
  stringio
153
153
  public_suffix (5.0.4)
154
154
  racc (1.8.1)
155
- rack (3.1.4)
155
+ rack (3.1.8)
156
156
  rack-session (2.0.0)
157
157
  rack (>= 3.0.0)
158
158
  rack-test (2.1.0)
@@ -160,20 +160,20 @@ GEM
160
160
  rackup (2.1.0)
161
161
  rack (>= 3)
162
162
  webrick (~> 1.8)
163
- rails (7.1.3.4)
164
- actioncable (= 7.1.3.4)
165
- actionmailbox (= 7.1.3.4)
166
- actionmailer (= 7.1.3.4)
167
- actionpack (= 7.1.3.4)
168
- actiontext (= 7.1.3.4)
169
- actionview (= 7.1.3.4)
170
- activejob (= 7.1.3.4)
171
- activemodel (= 7.1.3.4)
172
- activerecord (= 7.1.3.4)
173
- activestorage (= 7.1.3.4)
174
- activesupport (= 7.1.3.4)
163
+ rails (7.1.4.2)
164
+ actioncable (= 7.1.4.2)
165
+ actionmailbox (= 7.1.4.2)
166
+ actionmailer (= 7.1.4.2)
167
+ actionpack (= 7.1.4.2)
168
+ actiontext (= 7.1.4.2)
169
+ actionview (= 7.1.4.2)
170
+ activejob (= 7.1.4.2)
171
+ activemodel (= 7.1.4.2)
172
+ activerecord (= 7.1.4.2)
173
+ activestorage (= 7.1.4.2)
174
+ activesupport (= 7.1.4.2)
175
175
  bundler (>= 1.15.0)
176
- railties (= 7.1.3.4)
176
+ railties (= 7.1.4.2)
177
177
  rails-dom-testing (2.2.0)
178
178
  activesupport (>= 5.0.0)
179
179
  minitest
@@ -181,9 +181,9 @@ GEM
181
181
  rails-html-sanitizer (1.6.0)
182
182
  loofah (~> 2.21)
183
183
  nokogiri (~> 1.14)
184
- railties (7.1.3.4)
185
- actionpack (= 7.1.3.4)
186
- activesupport (= 7.1.3.4)
184
+ railties (7.1.4.2)
185
+ actionpack (= 7.1.4.2)
186
+ activesupport (= 7.1.4.2)
187
187
  irb
188
188
  rackup (>= 1.0.0)
189
189
  rake (>= 12.2)
@@ -196,8 +196,6 @@ GEM
196
196
  regexp_parser (2.9.2)
197
197
  reline (0.5.9)
198
198
  io-console (~> 0.5)
199
- rexml (3.3.4)
200
- strscan
201
199
  rspec (3.13.0)
202
200
  rspec-core (~> 3.13.0)
203
201
  rspec-expectations (~> 3.13.0)
@@ -211,29 +209,28 @@ GEM
211
209
  diff-lcs (>= 1.2.0, < 2.0)
212
210
  rspec-support (~> 3.13.0)
213
211
  rspec-support (3.13.1)
214
- rubocop (1.65.1)
212
+ rubocop (1.68.0)
215
213
  json (~> 2.3)
216
214
  language_server-protocol (>= 3.17.0)
217
215
  parallel (~> 1.10)
218
216
  parser (>= 3.3.0.2)
219
217
  rainbow (>= 2.2.2, < 4.0)
220
218
  regexp_parser (>= 2.4, < 3.0)
221
- rexml (>= 3.2.5, < 4.0)
222
- rubocop-ast (>= 1.31.1, < 2.0)
219
+ rubocop-ast (>= 1.32.2, < 2.0)
223
220
  ruby-progressbar (~> 1.7)
224
221
  unicode-display_width (>= 2.4.0, < 3.0)
225
- rubocop-ast (1.32.0)
222
+ rubocop-ast (1.33.1)
226
223
  parser (>= 3.3.1.0)
227
224
  rubocop-capybara (2.21.0)
228
225
  rubocop (~> 1.41)
229
- rubocop-rails (2.25.1)
226
+ rubocop-rails (2.27.0)
230
227
  activesupport (>= 4.2.0)
231
228
  rack (>= 1.1)
232
- rubocop (>= 1.33.0, < 2.0)
229
+ rubocop (>= 1.52.0, < 2.0)
233
230
  rubocop-ast (>= 1.31.1, < 2.0)
234
231
  rubocop-rake (0.6.0)
235
232
  rubocop (~> 1.0)
236
- rubocop-rspec (3.0.4)
233
+ rubocop-rspec (3.2.0)
237
234
  rubocop (~> 1.61)
238
235
  ruby-progressbar (1.13.0)
239
236
  simplecov (0.22.0)
@@ -243,21 +240,20 @@ GEM
243
240
  simplecov-html (0.12.3)
244
241
  simplecov_json_formatter (0.1.4)
245
242
  stringio (3.1.1)
246
- strscan (3.1.0)
247
243
  tdiff (0.4.0)
248
- thor (1.3.1)
244
+ thor (1.3.2)
249
245
  timeout (0.4.1)
250
246
  tzinfo (2.0.6)
251
247
  concurrent-ruby (~> 1.0)
252
- unicode-display_width (2.5.0)
248
+ unicode-display_width (2.6.0)
253
249
  webrick (1.8.1)
254
250
  websocket-driver (0.7.6)
255
251
  websocket-extensions (>= 0.1.0)
256
252
  websocket-extensions (0.1.5)
257
253
  xpath (3.2.0)
258
254
  nokogiri (~> 1.8)
259
- yard (0.9.36)
260
- zeitwerk (2.6.17)
255
+ yard (0.9.37)
256
+ zeitwerk (2.6.18)
261
257
 
262
258
  PLATFORMS
263
259
  x86_64-darwin-19
@@ -272,13 +268,13 @@ DEPENDENCIES
272
268
  nokogiri-diff (~> 0.3.0)
273
269
  rake (~> 13.2)
274
270
  rspec (~> 3.13)
275
- rubocop (~> 1.65)
271
+ rubocop (~> 1.68)
276
272
  rubocop-capybara (~> 2.20)
277
- rubocop-rails (~> 2.25)
273
+ rubocop-rails (~> 2.27)
278
274
  rubocop-rake (~> 0.6)
279
- rubocop-rspec (~> 3.0)
275
+ rubocop-rspec (~> 3.2)
280
276
  simplecov (~> 0.21)
281
277
  yard (~> 0.9)
282
278
 
283
279
  BUNDLED WITH
284
- 2.3.24
280
+ 2.5.20
data/README.md CHANGED
@@ -14,6 +14,8 @@ The following table shows the version of CCS Frontend Helpers that you should us
14
14
 
15
15
  | CCS Frontend Helpers Version | Target GOV.UK Frontend Version | Target CCS Frontend Version |
16
16
  | ----------------------------- | ------------------------------ | --------------------------- |
17
+ | [2.0.0](https://github.com/Crown-Commercial-Service/ccs-frontend_helpers/releases/tag/v2.0.0) | [5.7.1](https://github.com/alphagov/govuk-frontend/releases/tag/v5.7.1) | [1.2.0](https://github.com/Crown-Commercial-Service/ccs-frontend-project/releases/tag/v1.2.0) |
18
+ | [1.2.0](https://github.com/Crown-Commercial-Service/ccs-frontend_helpers/releases/tag/v1.2.0) | [5.6.0](https://github.com/alphagov/govuk-frontend/releases/tag/v5.6.0) | [1.1.3](https://github.com/Crown-Commercial-Service/ccs-frontend-project/releases/tag/v1.1.3) |
17
19
  | [1.1.2](https://github.com/Crown-Commercial-Service/ccs-frontend_helpers/releases/tag/v1.1.2) | [5.5.0](https://github.com/alphagov/govuk-frontend/releases/tag/v5.5.0) | [1.1.2](https://github.com/Crown-Commercial-Service/ccs-frontend-project/releases/tag/v1.1.2) |
18
20
  | [1.1.1](https://github.com/Crown-Commercial-Service/ccs-frontend_helpers/releases/tag/v1.1.1) | [5.4.1](https://github.com/alphagov/govuk-frontend/releases/tag/v5.4.1) | [1.1.1](https://github.com/Crown-Commercial-Service/ccs-frontend-project/releases/tag/v1.1.1) |
19
21
  | [1.1.0](https://github.com/Crown-Commercial-Service/ccs-frontend_helpers/releases/tag/v1.1.0) | [5.4.0](https://github.com/alphagov/govuk-frontend/releases/tag/v5.4.0) | [1.1.0](https://github.com/Crown-Commercial-Service/ccs-frontend-project/releases/tag/v1.1.0) |
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
11
11
  spec.description = 'Gem containing view helpers for CCS Ruby on Rails projects'
12
12
  spec.homepage = 'https://github.com/Crown-Commercial-Service/ccs-frontend_helpers'
13
13
  spec.license = 'MIT'
14
- spec.required_ruby_version = '>= 3.0.0'
14
+ spec.required_ruby_version = '>= 3.1.0'
15
15
 
16
16
  # spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'"
17
17
 
@@ -30,7 +30,7 @@ Gem::Specification.new do |spec|
30
30
  spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
31
31
  spec.require_paths = ['lib']
32
32
 
33
- spec.add_dependency 'rails', '>= 6.0'
33
+ spec.add_dependency 'rails', '>= 7.0'
34
34
 
35
35
  spec.metadata['rubygems_mfa_required'] = 'true'
36
36
  end
@@ -69,8 +69,8 @@ module CCS
69
69
  #
70
70
  # @return [ActiveSupport::SafeBuffer]
71
71
 
72
- def render(&block)
73
- form_group.render(&block)
72
+ def render(&)
73
+ form_group.render(&)
74
74
  end
75
75
 
76
76
  private
@@ -61,11 +61,11 @@ module CCS
61
61
  #
62
62
  # @return [ActiveSupport::SafeBuffer]
63
63
 
64
- def render(&block)
64
+ def render(&)
65
65
  if options[:form]
66
- options[:form].button(**options[:attributes], &block)
66
+ options[:form].button(**options[:attributes], &)
67
67
  else
68
- link_to(options[:href], **options[:attributes], &block)
68
+ link_to(options[:href], **options[:attributes], &)
69
69
  end
70
70
  end
71
71
 
@@ -50,8 +50,8 @@ module CCS
50
50
  #
51
51
  # @return [ActiveSupport::SafeBuffer]
52
52
 
53
- def render(&block)
54
- tag.li(class: li_classes, &block)
53
+ def render(&)
54
+ tag.li(class: li_classes, &)
55
55
  end
56
56
 
57
57
  # The default attributes for the pagination link
@@ -0,0 +1,74 @@
1
+ require_relative '../../base'
2
+
3
+ module CCS
4
+ module Components
5
+ module GovUK
6
+ class ServiceNavigation < Base
7
+ # = GOV.UK Service navigation link
8
+ #
9
+ # The individual service navigation link item
10
+ #
11
+ # @!attribute [r] text
12
+ # @return [String] Text for the service navigation link
13
+ # @!attribute [r] href
14
+ # @return [String] The href for the service navigation link
15
+
16
+ class Link < Base
17
+ private
18
+
19
+ attr_reader :text, :href
20
+
21
+ public
22
+
23
+ # @param text [String] the text for the service navigation link
24
+ # @param href [String] the href for the service navigation link
25
+ # @param options [Hash] options that will be used in customising the HTML
26
+ #
27
+ # @option options [Boolean] :active flag to mark the navigation item as active or not
28
+ # @option options [Hash] :attributes any additional attributes that will added as part of the HTML
29
+
30
+ def initialize(text:, href: nil, **options)
31
+ super(**options)
32
+
33
+ @options[:attributes][:aria] = { current: options[:current] ? 'page' : 'true' } if options[:active] || options[:current]
34
+
35
+ @text = text
36
+ @href = href
37
+ end
38
+
39
+ # Generates the HTML for the GOV.UK Service navigation link
40
+ #
41
+ # @return [ActiveSupport::SafeBuffer]
42
+
43
+ def render
44
+ tag.li(class: "govuk-service-navigation__item #{'govuk-service-navigation__item--active' if options[:active] || options[:current]}".rstrip) do
45
+ if href
46
+ options[:attributes][:class] = 'govuk-service-navigation__link'
47
+
48
+ link_to(inner_content, href, **options[:attributes])
49
+ else
50
+ options[:attributes][:class] = 'govuk-service-navigation__text'
51
+
52
+ tag.span(inner_content, **options[:attributes])
53
+ end
54
+ end
55
+ end
56
+
57
+ private
58
+
59
+ # Generates the HTML for the inner content of the GOV.UK Service navigation link component
60
+ #
61
+ # @return [ActiveSupport::SafeBuffer]
62
+
63
+ def inner_content
64
+ if options[:active] || options[:current]
65
+ tag.strong(text, class: 'govuk-service-navigation__active-fallback')
66
+ else
67
+ text
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,81 @@
1
+ require_relative 'link'
2
+
3
+ module CCS
4
+ module Components
5
+ module GovUK
6
+ class ServiceNavigation < Base
7
+ # = GOV.UK Service navigation navigation
8
+ #
9
+ # The service navigation navigation section
10
+ #
11
+ # @!attribute [r] navigation
12
+ # @return Array<Hash> A hash with navigation options
13
+ # @!attribute [r] navigation_label
14
+ # @return [String] The aria label for the navigation
15
+ # @!attribute [r] navigation_classes
16
+ # @return [String] The classes for the navigation
17
+ # @!attribute [r] navigation_id
18
+ # @return [String] The id for the navigation
19
+ # @!attribute [r] menu_button
20
+ # @return [Hash] The options for the menu button
21
+
22
+ class Navigation
23
+ include ActionView::Context
24
+ include ActionView::Helpers
25
+
26
+ private
27
+
28
+ attr_reader :navigation, :menu_button
29
+
30
+ public
31
+
32
+ # rubocop:disable Metrics/CyclomaticComplexity
33
+
34
+ # @param navigation [Hash] options for the navigation
35
+ # @param context [ActionView::Base] the view context
36
+ # @param menu_button [Hash] options for the menu button
37
+ #
38
+ # @option navigation [Array] :items an array of links for the navigation section.
39
+ # See {Components::GovUK::ServiceNavigation::Link#initialize Link#initialize} for details of the items in the array.
40
+ # @option navigation [String] :classes additional CSS classes for the navigation HTML
41
+ # @option navigation [String] :label text for the aria-label attribute of the navigation. Defaults to the menu button text
42
+ #
43
+ # @option menu_button [String] :text text for the button that opens the mobile navigation menu.
44
+ # By default, this is set to +Menu+.
45
+ # @option menu_button [String] :label text for the aria-label attribute of the button that opens the mobile navigation.
46
+ # Defaults to +Show or hide menu+.
47
+
48
+ def initialize(navigation:, context:, menu_button: nil)
49
+ menu_button ||= {}
50
+ menu_button[:text] ||= 'Menu'
51
+
52
+ @navigation = { id: navigation[:id] || 'navigation' }
53
+
54
+ menu_button[:aria] = { controls: @navigation[:id] }
55
+ menu_button[:aria][:label] = menu_button[:label] if menu_button[:label] && menu_button[:label] != menu_button[:text]
56
+
57
+ @menu_button = menu_button
58
+ @navigation[:links] = navigation[:items].map { |navigation_link| Link.new(context: context, **navigation_link) }
59
+ @navigation[:label] = navigation[:label] || menu_button[:text]
60
+ @navigation[:class] = "govuk-service-navigation__wrapper #{navigation[:classes]}".rstrip
61
+ end
62
+
63
+ # rubocop:enable Metrics/CyclomaticComplexity
64
+
65
+ # Generates the HTML for the GOV.UK Service Navigation navigation
66
+ #
67
+ # @return [ActiveSupport::SafeBuffer]
68
+
69
+ def render
70
+ tag.nav(aria: { label: navigation[:label] }, class: navigation[:class]) do
71
+ concat(button_tag(menu_button[:text], type: :button, class: 'govuk-service-navigation__toggle govuk-js-service-navigation-toggle', aria: menu_button[:aria], hidden: true))
72
+ concat(tag.ul(id: navigation[:id], class: 'govuk-service-navigation__list') do
73
+ navigation[:links].each { |navigation_link| concat(navigation_link.render) }
74
+ end)
75
+ end
76
+ end
77
+ end
78
+ end
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,91 @@
1
+ require_relative '../base'
2
+ require_relative 'service_navigation/navigation'
3
+
4
+ module CCS
5
+ module Components
6
+ module GovUK
7
+ # = GOV.UK Service Navigation
8
+ #
9
+ # This is used to generate the service navigation component from the
10
+ # {https://design-system.service.gov.uk/components/service-navigatio GDS - Components - Service navigation}
11
+ #
12
+ # @!attribute [r] text
13
+ # @return [String] Text for the service navigation
14
+ # @!attribute [r] href
15
+ # @return [String] The href for the service navigation
16
+
17
+ class ServiceNavigation < Base
18
+ private
19
+
20
+ attr_reader :navigation, :service
21
+
22
+ public
23
+
24
+ # @param navigation [Hash] options for the navigation section of the service navigation.
25
+ # See {Components::GovUK::ServiceNavigation::Navigation#initialize Navigation#initialize} for details of the options.
26
+ # @param menu_button [Hash] options for the menu button in the service navigation.
27
+ # See {Components::GovUK::ServiceNavigation::Navigation#initialize Navigation#initialize} for details of the options.
28
+ # @param service [Hash] options for the service name
29
+ # @param options [Hash] options that will be used in customising the HTML
30
+ #
31
+ # @option service [String] :name the name of the service, included in the service navigation
32
+ # @option service [String] :href URL for the service name anchor
33
+ #
34
+ # @option options [String] :classes additional CSS classes for the service navigation HTML
35
+ # @option options [Hash] :attributes additional attributes that will added as part of the service navigation HTML
36
+
37
+ def initialize(navigation: nil, menu_button: nil, service: nil, **options)
38
+ super(**options)
39
+
40
+ (@options[:attributes][:aria] ||= {})[:label] ||= 'Service information' if service
41
+
42
+ @navigation = Navigation.new(navigation: navigation, menu_button: menu_button, context: @context) if navigation && navigation[:items].present?
43
+ @service = service
44
+ end
45
+
46
+ # Generates the HTML for the GOV.UK Service navigation component
47
+ #
48
+ # @return [ActiveSupport::SafeBuffer]
49
+
50
+ def render
51
+ if service
52
+ tag.section(inner_content, **options[:attributes])
53
+ else
54
+ tag.div(inner_content, **options[:attributes])
55
+ end
56
+ end
57
+
58
+ # The default attributes for the service navigation
59
+
60
+ DEFAULT_ATTRIBUTES = { class: 'govuk-service-navigation', data: { module: 'govuk-service-navigation' } }.freeze
61
+
62
+ private
63
+
64
+ # Generates the HTML for the inner content of the GOV.UK Service navigation component
65
+ #
66
+ # @return [ActiveSupport::SafeBuffer]
67
+
68
+ def inner_content
69
+ tag.div(class: 'govuk-width-container') do
70
+ tag.div(class: 'govuk-service-navigation__container') do
71
+ concat(tag.span(service_navigation_service_name, class: 'govuk-service-navigation__service-name')) if service
72
+ concat(navigation.render) if navigation
73
+ end
74
+ end
75
+ end
76
+
77
+ # Generates the service name section
78
+ #
79
+ # @return [ActiveSupport::SafeBuffer]
80
+
81
+ def service_navigation_service_name
82
+ if service[:href]
83
+ link_to(service[:name], service[:href], class: 'govuk-service-navigation__link')
84
+ else
85
+ tag.span(service[:name], class: 'govuk-service-navigation__text')
86
+ end
87
+ end
88
+ end
89
+ end
90
+ end
91
+ end
@@ -21,8 +21,8 @@ module CCS
21
21
  #
22
22
  # @return (see CCS::Components::GovUK::Details#render)
23
23
 
24
- def govuk_details(summary_text, **options, &block)
25
- Components::GovUK::Details.new(context: self, summary_text: summary_text, **options).render(&block)
24
+ def govuk_details(summary_text, **options, &)
25
+ Components::GovUK::Details.new(context: self, summary_text: summary_text, **options).render(&)
26
26
  end
27
27
  end
28
28
  end
@@ -21,8 +21,8 @@ module CCS
21
21
  #
22
22
  # @return (see CCS::Components::GovUK::Fieldset#render)
23
23
 
24
- def govuk_fieldset(**options, &block)
25
- Components::GovUK::Fieldset.new(context: self, **options).render(&block)
24
+ def govuk_fieldset(**options, &)
25
+ Components::GovUK::Fieldset.new(context: self, **options).render(&)
26
26
  end
27
27
  end
28
28
  end
@@ -24,14 +24,14 @@ module CCS
24
24
  #
25
25
  # @return (see CCS::Components::GovUK::FormGroup#render)
26
26
 
27
- def govuk_form_group(attribute, **options, &block)
27
+ def govuk_form_group(attribute, **options, &)
28
28
  error_message = if options[:model]
29
29
  options[:model].errors[attribute].first
30
30
  else
31
31
  options[:error_message]
32
32
  end
33
33
 
34
- Components::GovUK::FormGroup.new(context: self, attribute: attribute, error_message: error_message, **options).render(&block)
34
+ Components::GovUK::FormGroup.new(context: self, attribute: attribute, error_message: error_message, **options).render(&)
35
35
  end
36
36
  end
37
37
  end
@@ -20,8 +20,8 @@ module CCS
20
20
  #
21
21
  # @return (see CCS::Components::GovUK::Hint#render)
22
22
 
23
- def govuk_hint(text = nil, **options, &block)
24
- Components::GovUK::Hint.new(context: self, text: text, **options).render(&block)
23
+ def govuk_hint(text = nil, **options, &)
24
+ Components::GovUK::Hint.new(context: self, text: text, **options).render(&)
25
25
  end
26
26
  end
27
27
  end
@@ -21,8 +21,8 @@ module CCS
21
21
  #
22
22
  # @return (see CCS::Components::GovUK::InsetText#render)
23
23
 
24
- def govuk_inset_text(text = nil, **options, &block)
25
- Components::GovUK::InsetText.new(context: self, text: text, **options).render(&block)
24
+ def govuk_inset_text(text = nil, **options, &)
25
+ Components::GovUK::InsetText.new(context: self, text: text, **options).render(&)
26
26
  end
27
27
  end
28
28
  end
@@ -20,8 +20,8 @@ module CCS
20
20
  #
21
21
  # @return (see CCS::Components::GovUK::Label#render)
22
22
 
23
- def govuk_label(attribute, text = nil, **options, &block)
24
- Components::GovUK::Label.new(context: self, attribute: attribute, text: text, **options).render(&block)
23
+ def govuk_label(attribute, text = nil, **options, &)
24
+ Components::GovUK::Label.new(context: self, attribute: attribute, text: text, **options).render(&)
25
25
  end
26
26
  end
27
27
  end
@@ -21,8 +21,8 @@ module CCS
21
21
  #
22
22
  # @return (see CCS::Components::GovUK::NotificationBanner#render)
23
23
 
24
- def govuk_notification_banner(text = nil, success_banner = nil, **options, &block)
25
- Components::GovUK::NotificationBanner.new(context: self, text: text, success_banner: success_banner, **options).render(&block)
24
+ def govuk_notification_banner(text = nil, success_banner = nil, **options, &)
25
+ Components::GovUK::NotificationBanner.new(context: self, text: text, success_banner: success_banner, **options).render(&)
26
26
  end
27
27
  end
28
28
  end
@@ -21,8 +21,8 @@ module CCS
21
21
  #
22
22
  # @return (see CCS::Components::GovUK::Panel#render)
23
23
 
24
- def govuk_panel(title_text, panel_text = nil, **options, &block)
25
- Components::GovUK::Panel.new(context: self, title_text: title_text, panel_text: panel_text, **options).render(&block)
24
+ def govuk_panel(title_text, panel_text = nil, **options, &)
25
+ Components::GovUK::Panel.new(context: self, title_text: title_text, panel_text: panel_text, **options).render(&)
26
26
  end
27
27
  end
28
28
  end
@@ -21,8 +21,8 @@ module CCS
21
21
  #
22
22
  # @return (see CCS::Components::GovUK::PhaseBanner#render)
23
23
 
24
- def govuk_phase_banner(tag_options, text = nil, **options, &block)
25
- Components::GovUK::PhaseBanner.new(context: self, tag_options: tag_options, text: text, **options).render(&block)
24
+ def govuk_phase_banner(tag_options, text = nil, **options, &)
25
+ Components::GovUK::PhaseBanner.new(context: self, tag_options: tag_options, text: text, **options).render(&)
26
26
  end
27
27
  end
28
28
  end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../components/govuk/service_navigation'
4
+
5
+ module CCS
6
+ module FrontendHelpers
7
+ module GovUKFrontend
8
+ # = GOV.UK Service Navigation
9
+ #
10
+ # This helper is used for generating the service navigation component from the
11
+ # {https://design-system.service.gov.uk/components/service-navigation GDS - Components - Service navigations}
12
+
13
+ module ServiceNavigation
14
+ # Generates the HTML for the GOV.UK Service navigation component
15
+ #
16
+ # @param (see CCS::Components::GovUK::ServiceNavigation#initialize)
17
+ #
18
+ # @option (see CCS::Components::GovUK::ServiceNavigation#initialize)
19
+ #
20
+ # @return (see CCS::Components::GovUK::ServiceNavigation#render)
21
+
22
+ def govuk_service_navigation(**options)
23
+ Components::GovUK::ServiceNavigation.new(context: self, **options).render
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -21,8 +21,8 @@ module CCS
21
21
  #
22
22
  # @return (see CCS::Components::GovUK::WarningText#render)
23
23
 
24
- def govuk_warning_text(text = nil, **options, &block)
25
- Components::GovUK::WarningText.new(context: self, text: text, **options).render(&block)
24
+ def govuk_warning_text(text = nil, **options, &)
25
+ Components::GovUK::WarningText.new(context: self, text: text, **options).render(&)
26
26
  end
27
27
  end
28
28
  end
@@ -28,6 +28,7 @@ require_relative 'govuk_frontend/password_input'
28
28
  require_relative 'govuk_frontend/phase_banner'
29
29
  require_relative 'govuk_frontend/radios'
30
30
  require_relative 'govuk_frontend/select'
31
+ require_relative 'govuk_frontend/service_navigation'
31
32
  require_relative 'govuk_frontend/skip_link'
32
33
  require_relative 'govuk_frontend/step_by_step_navigation'
33
34
  require_relative 'govuk_frontend/summary_list'
@@ -72,6 +73,7 @@ module CCS
72
73
  include PhaseBanner
73
74
  include Radios
74
75
  include Select
76
+ include ServiceNavigation
75
77
  include SkipLink
76
78
  include StepByStepNavigation
77
79
  include SummaryList
@@ -2,6 +2,6 @@
2
2
 
3
3
  module CCS
4
4
  module FrontendHelpers
5
- VERSION = '1.1.2'
5
+ VERSION = '2.0.0'
6
6
  end
7
7
  end
data/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "author": "CCS",
6
6
  "license": "MIT",
7
7
  "devDependencies": {
8
- "govuk-frontend": "^5.5.0",
9
- "ccs-frontend": "^1.1.2"
8
+ "govuk-frontend": "^5.7.1",
9
+ "ccs-frontend": "^1.2.0"
10
10
  }
11
11
  }
data/yarn.lock CHANGED
@@ -2,12 +2,12 @@
2
2
  # yarn lockfile v1
3
3
 
4
4
 
5
- ccs-frontend@^1.1.2:
6
- version "1.1.2"
7
- resolved "https://registry.yarnpkg.com/ccs-frontend/-/ccs-frontend-1.1.2.tgz#f8333896e7859366c417d43ada819bf0909a38f1"
8
- integrity sha512-KoBoY3VByQOT6TrJi9MIDd9j7d2FdGVNTMtm0+aBhKwL0Ee5InUG0IVArKs+9YGfaUaCrhQWdbscGHt4v1O2DA==
5
+ ccs-frontend@^1.2.0:
6
+ version "1.2.0"
7
+ resolved "https://registry.yarnpkg.com/ccs-frontend/-/ccs-frontend-1.2.0.tgz#71027647d619c169189a592de35a76858f4f50fa"
8
+ integrity sha512-7pGM3KxrHYb/MS7k1DWhJsQyNKi3WVYHNJfQbkBI2tzeRQFor04mhsjgGjv0dL9/cXn1pEvM+kcOOxVVyPxUeQ==
9
9
 
10
- govuk-frontend@^5.5.0:
11
- version "5.5.0"
12
- resolved "https://registry.yarnpkg.com/govuk-frontend/-/govuk-frontend-5.5.0.tgz#dfb2426788dbf570ef7d2742983bc54e68f17f34"
13
- integrity sha512-lNSHCOzgk6LfgelcdtJxTLK1BX/cpjCUyEB3LnzliD9o9YQckNMsbj5+jSOs2RFy6XBJ/DJqxj2TKfjBCuzpyA==
10
+ govuk-frontend@^5.7.1:
11
+ version "5.7.1"
12
+ resolved "https://registry.yarnpkg.com/govuk-frontend/-/govuk-frontend-5.7.1.tgz#d4c561ebf8c0b76130f31df8c2e4d70d340cd63f"
13
+ integrity sha512-jF1cq5rn57kxZmJRprUZhTQ31zaBBK4b5AyeJaPX3Yhg22lk90Mx/dQLvOk/ycV3wM7e0y+s4IPvb2fFaPlCGg==
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ccs-frontend_helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Crown Commercial Service
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-08-12 00:00:00.000000000 Z
11
+ date: 2024-11-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '6.0'
19
+ version: '7.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '6.0'
26
+ version: '7.0'
27
27
  description: Gem containing view helpers for CCS Ruby on Rails projects
28
28
  email:
29
29
  executables: []
@@ -119,6 +119,9 @@ files:
119
119
  - lib/ccs/components/govuk/pagination/item/tag.rb
120
120
  - lib/ccs/components/govuk/panel.rb
121
121
  - lib/ccs/components/govuk/phase_banner.rb
122
+ - lib/ccs/components/govuk/service_navigation.rb
123
+ - lib/ccs/components/govuk/service_navigation/link.rb
124
+ - lib/ccs/components/govuk/service_navigation/navigation.rb
122
125
  - lib/ccs/components/govuk/skip_link.rb
123
126
  - lib/ccs/components/govuk/step_by_step_navigation.rb
124
127
  - lib/ccs/components/govuk/step_by_step_navigation/section.rb
@@ -186,6 +189,7 @@ files:
186
189
  - lib/ccs/frontend_helpers/govuk_frontend/phase_banner.rb
187
190
  - lib/ccs/frontend_helpers/govuk_frontend/radios.rb
188
191
  - lib/ccs/frontend_helpers/govuk_frontend/select.rb
192
+ - lib/ccs/frontend_helpers/govuk_frontend/service_navigation.rb
189
193
  - lib/ccs/frontend_helpers/govuk_frontend/skip_link.rb
190
194
  - lib/ccs/frontend_helpers/govuk_frontend/step_by_step_navigation.rb
191
195
  - lib/ccs/frontend_helpers/govuk_frontend/summary_list.rb
@@ -215,14 +219,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
215
219
  requirements:
216
220
  - - ">="
217
221
  - !ruby/object:Gem::Version
218
- version: 3.0.0
222
+ version: 3.1.0
219
223
  required_rubygems_version: !ruby/object:Gem::Requirement
220
224
  requirements:
221
225
  - - ">="
222
226
  - !ruby/object:Gem::Version
223
227
  version: '0'
224
228
  requirements: []
225
- rubygems_version: 3.5.9
229
+ rubygems_version: 3.5.16
226
230
  signing_key:
227
231
  specification_version: 4
228
232
  summary: Gem containing view helpers for CCS Ruby on Rails projects