ccs-frontend_helpers 2.4.0 → 3.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: eb6707b6a138b2b393abd881035498389d19edb8ee6ee2b8575aedd7ce06ece2
4
- data.tar.gz: 4efdde23a7e0183371a1894b5e60c835e3f30699b9d86f8023ee287d005879bc
3
+ metadata.gz: 6bc177abb107154b6fe83789dfb5e7b26c88542792026809b2329af9ddc5baed
4
+ data.tar.gz: 9c577ff2f803f55013e01a4f583ad48a89092e16f68d97bbe58e9265ca99b326
5
5
  SHA512:
6
- metadata.gz: 7e93fec1d87edc93a450432e199367532ab4f493f6db3b8f13946c8f9674c8ce99e7609bb6d0c9c9960020dbf3306323a8d3edccb41a53c962b519f31e4742f7
7
- data.tar.gz: e78a6020d4f3526d84691d374076e4413b6500c26fdb8cd934d7b5220232b7cfe230b112ef4949ab8a3aadffef6b9efc9dd8d4db361afe4d6bc0be88706cccba
6
+ metadata.gz: fc08f641f7dbada53b10bb254449c9320e40de43a6e6d6d0e346e7fbb256ef0f65a821066398f3a4bfe89fe134d8131e2e43fc8f6ab3a9811a047edb72284a14
7
+ data.tar.gz: e894512b90e0f6d56785eee80a3dcd454689bc7a65d96b12e05358912cb5b3385d5ef425237a25ee8ce0ac51eb617d6d560e2dcaa2504befc508cf9ddcf3b00c
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.4.1
1
+ 3.4.3
data/CHANGELOG.md CHANGED
@@ -7,6 +7,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [3.0.0] - 2025-08-27
11
+
12
+ ### Added
13
+
14
+ - Updated CCS Frontend to v2.0.0
15
+
16
+ ### Removed
17
+
18
+ - The CCS Header is now just the logo as all other parts should now go in the GOV.UK Service Navigation component
19
+
20
+ ## [2.5.0] - 2025-06-30
21
+
22
+ ### Added
23
+
24
+ - Updated GOV.UK Frontend to v5.11.0
25
+
10
26
  ## [2.4.0] - 2025-05-13
11
27
 
12
28
  ### Added
data/Gemfile CHANGED
@@ -7,7 +7,7 @@ gemspec
7
7
 
8
8
  # Gems for building the package
9
9
  gem 'bundler', '~> 2.3'
10
- gem 'rake', '~> 13.2'
10
+ gem 'rake', '~> 13.3'
11
11
 
12
12
  # Gems for testing the package
13
13
  gem 'capybara', '~> 3.40.0'
@@ -16,9 +16,9 @@ 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.75'
19
+ gem 'rubocop', '~> 1.80'
20
20
  gem 'rubocop-capybara', '~> 2.22'
21
- gem 'rubocop-rails', '~> 2.31'
21
+ gem 'rubocop-rails', '~> 2.33'
22
22
  gem 'rubocop-rake', '~> 0.7'
23
23
  gem 'rubocop-rspec', '~> 3.6'
24
24
 
data/Gemfile.lock CHANGED
@@ -1,35 +1,35 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ccs-frontend_helpers (2.4.0)
4
+ ccs-frontend_helpers (3.0.0)
5
5
  rails (>= 7.2)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- actioncable (8.0.2)
11
- actionpack (= 8.0.2)
12
- activesupport (= 8.0.2)
10
+ actioncable (8.0.2.1)
11
+ actionpack (= 8.0.2.1)
12
+ activesupport (= 8.0.2.1)
13
13
  nio4r (~> 2.0)
14
14
  websocket-driver (>= 0.6.1)
15
15
  zeitwerk (~> 2.6)
16
- actionmailbox (8.0.2)
17
- actionpack (= 8.0.2)
18
- activejob (= 8.0.2)
19
- activerecord (= 8.0.2)
20
- activestorage (= 8.0.2)
21
- activesupport (= 8.0.2)
16
+ actionmailbox (8.0.2.1)
17
+ actionpack (= 8.0.2.1)
18
+ activejob (= 8.0.2.1)
19
+ activerecord (= 8.0.2.1)
20
+ activestorage (= 8.0.2.1)
21
+ activesupport (= 8.0.2.1)
22
22
  mail (>= 2.8.0)
23
- actionmailer (8.0.2)
24
- actionpack (= 8.0.2)
25
- actionview (= 8.0.2)
26
- activejob (= 8.0.2)
27
- activesupport (= 8.0.2)
23
+ actionmailer (8.0.2.1)
24
+ actionpack (= 8.0.2.1)
25
+ actionview (= 8.0.2.1)
26
+ activejob (= 8.0.2.1)
27
+ activesupport (= 8.0.2.1)
28
28
  mail (>= 2.8.0)
29
29
  rails-dom-testing (~> 2.2)
30
- actionpack (8.0.2)
31
- actionview (= 8.0.2)
32
- activesupport (= 8.0.2)
30
+ actionpack (8.0.2.1)
31
+ actionview (= 8.0.2.1)
32
+ activesupport (= 8.0.2.1)
33
33
  nokogiri (>= 1.8.5)
34
34
  rack (>= 2.2.4)
35
35
  rack-session (>= 1.0.1)
@@ -37,35 +37,35 @@ GEM
37
37
  rails-dom-testing (~> 2.2)
38
38
  rails-html-sanitizer (~> 1.6)
39
39
  useragent (~> 0.16)
40
- actiontext (8.0.2)
41
- actionpack (= 8.0.2)
42
- activerecord (= 8.0.2)
43
- activestorage (= 8.0.2)
44
- activesupport (= 8.0.2)
40
+ actiontext (8.0.2.1)
41
+ actionpack (= 8.0.2.1)
42
+ activerecord (= 8.0.2.1)
43
+ activestorage (= 8.0.2.1)
44
+ activesupport (= 8.0.2.1)
45
45
  globalid (>= 0.6.0)
46
46
  nokogiri (>= 1.8.5)
47
- actionview (8.0.2)
48
- activesupport (= 8.0.2)
47
+ actionview (8.0.2.1)
48
+ activesupport (= 8.0.2.1)
49
49
  builder (~> 3.1)
50
50
  erubi (~> 1.11)
51
51
  rails-dom-testing (~> 2.2)
52
52
  rails-html-sanitizer (~> 1.6)
53
- activejob (8.0.2)
54
- activesupport (= 8.0.2)
53
+ activejob (8.0.2.1)
54
+ activesupport (= 8.0.2.1)
55
55
  globalid (>= 0.3.6)
56
- activemodel (8.0.2)
57
- activesupport (= 8.0.2)
58
- activerecord (8.0.2)
59
- activemodel (= 8.0.2)
60
- activesupport (= 8.0.2)
56
+ activemodel (8.0.2.1)
57
+ activesupport (= 8.0.2.1)
58
+ activerecord (8.0.2.1)
59
+ activemodel (= 8.0.2.1)
60
+ activesupport (= 8.0.2.1)
61
61
  timeout (>= 0.4.0)
62
- activestorage (8.0.2)
63
- actionpack (= 8.0.2)
64
- activejob (= 8.0.2)
65
- activerecord (= 8.0.2)
66
- activesupport (= 8.0.2)
62
+ activestorage (8.0.2.1)
63
+ actionpack (= 8.0.2.1)
64
+ activejob (= 8.0.2.1)
65
+ activerecord (= 8.0.2.1)
66
+ activesupport (= 8.0.2.1)
67
67
  marcel (~> 1.0)
68
- activesupport (8.0.2)
68
+ activesupport (8.0.2.1)
69
69
  base64
70
70
  benchmark (>= 0.3)
71
71
  bigdecimal
@@ -81,9 +81,9 @@ GEM
81
81
  addressable (2.8.6)
82
82
  public_suffix (>= 2.0.2, < 6.0)
83
83
  ast (2.4.3)
84
- base64 (0.2.0)
85
- benchmark (0.4.0)
86
- bigdecimal (3.1.9)
84
+ base64 (0.3.0)
85
+ benchmark (0.4.1)
86
+ bigdecimal (3.2.2)
87
87
  builder (3.3.0)
88
88
  capybara (3.40.0)
89
89
  addressable
@@ -95,26 +95,28 @@ GEM
95
95
  regexp_parser (>= 1.5, < 3.0)
96
96
  xpath (~> 3.2)
97
97
  concurrent-ruby (1.3.5)
98
- connection_pool (2.5.0)
98
+ connection_pool (2.5.3)
99
99
  crass (1.0.6)
100
- date (3.3.4)
101
- diff-lcs (1.5.1)
100
+ date (3.4.1)
101
+ diff-lcs (1.6.2)
102
102
  docile (1.4.0)
103
- drb (2.2.1)
104
- erubi (1.13.0)
103
+ drb (2.2.3)
104
+ erb (5.0.2)
105
+ erubi (1.13.1)
105
106
  globalid (1.2.1)
106
107
  activesupport (>= 6.1)
107
108
  i18n (1.14.7)
108
109
  concurrent-ruby (~> 1.0)
109
- io-console (0.7.2)
110
- irb (1.14.0)
110
+ io-console (0.8.1)
111
+ irb (1.15.2)
112
+ pp (>= 0.6.0)
111
113
  rdoc (>= 4.0.0)
112
114
  reline (>= 0.4.2)
113
- json (2.11.3)
114
- language_server-protocol (3.17.0.4)
115
+ json (2.13.2)
116
+ language_server-protocol (3.17.0.5)
115
117
  lint_roller (1.1.0)
116
118
  logger (1.7.0)
117
- loofah (2.22.0)
119
+ loofah (2.24.1)
118
120
  crass (~> 1.0.2)
119
121
  nokogiri (>= 1.12.0)
120
122
  mail (2.8.1)
@@ -126,90 +128,97 @@ GEM
126
128
  matrix (0.4.2)
127
129
  mini_mime (1.1.5)
128
130
  minitest (5.25.5)
129
- net-imap (0.4.15)
131
+ net-imap (0.5.9)
130
132
  date
131
133
  net-protocol
132
134
  net-pop (0.1.2)
133
135
  net-protocol
134
136
  net-protocol (0.2.2)
135
137
  timeout
136
- net-smtp (0.5.0)
138
+ net-smtp (0.5.1)
137
139
  net-protocol
138
- nio4r (2.7.3)
139
- nokogiri (1.18.1-x86_64-darwin)
140
+ nio4r (2.7.4)
141
+ nokogiri (1.18.9-arm64-darwin)
140
142
  racc (~> 1.4)
141
- nokogiri (1.18.1-x86_64-linux-gnu)
143
+ nokogiri (1.18.9-x86_64-darwin)
144
+ racc (~> 1.4)
145
+ nokogiri (1.18.9-x86_64-linux-gnu)
142
146
  racc (~> 1.4)
143
147
  nokogiri-diff (0.3.0)
144
148
  nokogiri (~> 1.5)
145
149
  tdiff (~> 0.4)
146
150
  parallel (1.27.0)
147
- parser (3.3.8.0)
151
+ parser (3.3.9.0)
148
152
  ast (~> 2.4.1)
149
153
  racc
154
+ pp (0.6.2)
155
+ prettyprint
156
+ prettyprint (0.2.0)
150
157
  prism (1.4.0)
151
- psych (5.1.2)
158
+ psych (5.2.6)
159
+ date
152
160
  stringio
153
161
  public_suffix (5.0.4)
154
162
  racc (1.8.1)
155
- rack (3.1.12)
156
- rack-session (2.0.0)
163
+ rack (3.2.0)
164
+ rack-session (2.1.1)
165
+ base64 (>= 0.1.0)
157
166
  rack (>= 3.0.0)
158
- rack-test (2.1.0)
167
+ rack-test (2.2.0)
159
168
  rack (>= 1.3)
160
- rackup (2.1.0)
169
+ rackup (2.2.1)
161
170
  rack (>= 3)
162
- webrick (~> 1.8)
163
- rails (8.0.2)
164
- actioncable (= 8.0.2)
165
- actionmailbox (= 8.0.2)
166
- actionmailer (= 8.0.2)
167
- actionpack (= 8.0.2)
168
- actiontext (= 8.0.2)
169
- actionview (= 8.0.2)
170
- activejob (= 8.0.2)
171
- activemodel (= 8.0.2)
172
- activerecord (= 8.0.2)
173
- activestorage (= 8.0.2)
174
- activesupport (= 8.0.2)
171
+ rails (8.0.2.1)
172
+ actioncable (= 8.0.2.1)
173
+ actionmailbox (= 8.0.2.1)
174
+ actionmailer (= 8.0.2.1)
175
+ actionpack (= 8.0.2.1)
176
+ actiontext (= 8.0.2.1)
177
+ actionview (= 8.0.2.1)
178
+ activejob (= 8.0.2.1)
179
+ activemodel (= 8.0.2.1)
180
+ activerecord (= 8.0.2.1)
181
+ activestorage (= 8.0.2.1)
182
+ activesupport (= 8.0.2.1)
175
183
  bundler (>= 1.15.0)
176
- railties (= 8.0.2)
177
- rails-dom-testing (2.2.0)
184
+ railties (= 8.0.2.1)
185
+ rails-dom-testing (2.3.0)
178
186
  activesupport (>= 5.0.0)
179
187
  minitest
180
188
  nokogiri (>= 1.6)
181
- rails-html-sanitizer (1.6.0)
189
+ rails-html-sanitizer (1.6.2)
182
190
  loofah (~> 2.21)
183
- nokogiri (~> 1.14)
184
- railties (8.0.2)
185
- actionpack (= 8.0.2)
186
- activesupport (= 8.0.2)
191
+ nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
192
+ railties (8.0.2.1)
193
+ actionpack (= 8.0.2.1)
194
+ activesupport (= 8.0.2.1)
187
195
  irb (~> 1.13)
188
196
  rackup (>= 1.0.0)
189
197
  rake (>= 12.2)
190
198
  thor (~> 1.0, >= 1.2.2)
191
199
  zeitwerk (~> 2.6)
192
200
  rainbow (3.1.1)
193
- rake (13.2.1)
194
- rdoc (6.7.0)
201
+ rake (13.3.0)
202
+ rdoc (6.14.2)
203
+ erb
195
204
  psych (>= 4.0.0)
196
- regexp_parser (2.10.0)
197
- reline (0.5.9)
205
+ regexp_parser (2.11.2)
206
+ reline (0.6.2)
198
207
  io-console (~> 0.5)
199
- rspec (3.13.0)
208
+ rspec (3.13.1)
200
209
  rspec-core (~> 3.13.0)
201
210
  rspec-expectations (~> 3.13.0)
202
211
  rspec-mocks (~> 3.13.0)
203
- rspec-core (3.13.0)
212
+ rspec-core (3.13.4)
204
213
  rspec-support (~> 3.13.0)
205
- rspec-expectations (3.13.0)
214
+ rspec-expectations (3.13.5)
206
215
  diff-lcs (>= 1.2.0, < 2.0)
207
216
  rspec-support (~> 3.13.0)
208
- rspec-mocks (3.13.0)
217
+ rspec-mocks (3.13.5)
209
218
  diff-lcs (>= 1.2.0, < 2.0)
210
219
  rspec-support (~> 3.13.0)
211
- rspec-support (3.13.1)
212
- rubocop (1.75.5)
220
+ rspec-support (3.13.4)
221
+ rubocop (1.80.0)
213
222
  json (~> 2.3)
214
223
  language_server-protocol (~> 3.17.0.2)
215
224
  lint_roller (~> 1.1.0)
@@ -217,21 +226,21 @@ GEM
217
226
  parser (>= 3.3.0.2)
218
227
  rainbow (>= 2.2.2, < 4.0)
219
228
  regexp_parser (>= 2.9.3, < 3.0)
220
- rubocop-ast (>= 1.44.0, < 2.0)
229
+ rubocop-ast (>= 1.46.0, < 2.0)
221
230
  ruby-progressbar (~> 1.7)
222
231
  unicode-display_width (>= 2.4.0, < 4.0)
223
- rubocop-ast (1.44.1)
232
+ rubocop-ast (1.46.0)
224
233
  parser (>= 3.3.7.2)
225
234
  prism (~> 1.4)
226
235
  rubocop-capybara (2.22.1)
227
236
  lint_roller (~> 1.1)
228
237
  rubocop (~> 1.72, >= 1.72.1)
229
- rubocop-rails (2.31.0)
238
+ rubocop-rails (2.33.3)
230
239
  activesupport (>= 4.2.0)
231
240
  lint_roller (~> 1.1)
232
241
  rack (>= 1.1)
233
242
  rubocop (>= 1.75.0, < 2.0)
234
- rubocop-ast (>= 1.38.0, < 2.0)
243
+ rubocop-ast (>= 1.44.0, < 2.0)
235
244
  rubocop-rake (0.7.1)
236
245
  lint_roller (~> 1.1)
237
246
  rubocop (>= 1.72.1)
@@ -246,31 +255,33 @@ GEM
246
255
  simplecov_json_formatter (~> 0.1)
247
256
  simplecov-html (0.12.3)
248
257
  simplecov_json_formatter (0.1.4)
249
- stringio (3.1.1)
258
+ stringio (3.1.7)
250
259
  tdiff (0.4.0)
251
- thor (1.3.2)
252
- timeout (0.4.1)
260
+ thor (1.4.0)
261
+ timeout (0.4.3)
253
262
  tzinfo (2.0.6)
254
263
  concurrent-ruby (~> 1.0)
255
- unicode-display_width (3.1.4)
264
+ unicode-display_width (3.1.5)
256
265
  unicode-emoji (~> 4.0, >= 4.0.4)
257
266
  unicode-emoji (4.0.4)
258
267
  uri (1.0.3)
259
268
  useragent (0.16.11)
260
- webrick (1.8.1)
261
- websocket-driver (0.7.6)
269
+ websocket-driver (0.8.0)
270
+ base64
262
271
  websocket-extensions (>= 0.1.0)
263
272
  websocket-extensions (0.1.5)
264
273
  xpath (3.2.0)
265
274
  nokogiri (~> 1.8)
266
275
  yard (0.9.37)
267
- zeitwerk (2.6.18)
276
+ zeitwerk (2.7.3)
268
277
 
269
278
  PLATFORMS
279
+ arm64-darwin-24
270
280
  x86_64-darwin-19
271
281
  x86_64-darwin-20
272
282
  x86_64-darwin-22
273
283
  x86_64-darwin-23
284
+ x86_64-darwin-24
274
285
  x86_64-linux
275
286
 
276
287
  DEPENDENCIES
@@ -278,11 +289,11 @@ DEPENDENCIES
278
289
  capybara (~> 3.40.0)
279
290
  ccs-frontend_helpers!
280
291
  nokogiri-diff (~> 0.3.0)
281
- rake (~> 13.2)
292
+ rake (~> 13.3)
282
293
  rspec (~> 3.13)
283
- rubocop (~> 1.75)
294
+ rubocop (~> 1.80)
284
295
  rubocop-capybara (~> 2.22)
285
- rubocop-rails (~> 2.31)
296
+ rubocop-rails (~> 2.33)
286
297
  rubocop-rake (~> 0.7)
287
298
  rubocop-rspec (~> 3.6)
288
299
  simplecov (~> 0.21)
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
+ | [3.0.0](https://github.com/Crown-Commercial-Service/ccs-frontend_helpers/releases/tag/v3.0.0) | [5.11.2](https://github.com/alphagov/govuk-frontend/releases/tag/v5.11.2) | [2.0.0](https://github.com/Crown-Commercial-Service/ccs-frontend-project/releases/tag/v2.0.0) |
18
+ | [2.5.0](https://github.com/Crown-Commercial-Service/ccs-frontend_helpers/releases/tag/v2.5.0) | [5.11.0](https://github.com/alphagov/govuk-frontend/releases/tag/v5.11.0) | [1.4.1](https://github.com/Crown-Commercial-Service/ccs-frontend-project/releases/tag/v1.4.1) |
17
19
  | [2.4.0](https://github.com/Crown-Commercial-Service/ccs-frontend_helpers/releases/tag/v2.4.0) | [5.10.0](https://github.com/alphagov/govuk-frontend/releases/tag/v5.10.0) | [1.4.1](https://github.com/Crown-Commercial-Service/ccs-frontend-project/releases/tag/v1.4.1) |
18
20
  | [2.3.0](https://github.com/Crown-Commercial-Service/ccs-frontend_helpers/releases/tag/v2.3.0) | [5.9.0](https://github.com/alphagov/govuk-frontend/releases/tag/v5.9.0) | [1.4.0](https://github.com/Crown-Commercial-Service/ccs-frontend-project/releases/tag/v1.4.0) |
19
21
  | [2.2.0](https://github.com/Crown-Commercial-Service/ccs-frontend_helpers/releases/tag/v2.2.0) | [5.9.0](https://github.com/alphagov/govuk-frontend/releases/tag/v5.9.0) | [1.3.3](https://github.com/Crown-Commercial-Service/ccs-frontend-project/releases/tag/v1.3.3) |
data/bun.lock CHANGED
@@ -3,15 +3,15 @@
3
3
  "workspaces": {
4
4
  "": {
5
5
  "devDependencies": {
6
- "ccs-frontend": "^1.4.0",
7
- "govuk-frontend": "^5.10.0",
6
+ "ccs-frontend": "2.0.0",
7
+ "govuk-frontend": "5.11.2",
8
8
  },
9
9
  },
10
10
  },
11
11
  "packages": {
12
- "ccs-frontend": ["ccs-frontend@1.4.0", "", { "peerDependencies": { "govuk-frontend": "^5.9.0", "jquery": "^3.x" } }, "sha512-GX0wln6Tojcl7ZeLMPuq0uDh3jST2cV95HKLoOOYMsk783aCJXCaD9NANPHJClKGViuovw0piTIhPuM89nozBw=="],
12
+ "ccs-frontend": ["ccs-frontend@2.0.0", "", { "peerDependencies": { "govuk-frontend": "^5.11.2", "jquery": "^3.x" } }, "sha512-hPr44+qN+w8UpJ+vNxoiMV7alDpvEhJSZhJXyxJ+4gzuEQedFcgBHjyksJ+AghsKjPChH/X45EtRxyuggi4pIA=="],
13
13
 
14
- "govuk-frontend": ["govuk-frontend@5.10.0", "", {}, "sha512-9tjpB8PDwsDqutkQPJXfDalLvNOeKxzFhV7me21s/oyn7HcTg/ei/GC3Y4JvNsXauzjOkxv4eeCHntKeySkdMg=="],
14
+ "govuk-frontend": ["govuk-frontend@5.11.2", "", {}, "sha512-eHV8EMxYNjc+omFhB0HktQ3QmA3ZRdDsgRDlUIik+TpUHerR3XKXpo4zh/OGO2/C2mz65cX0XT0k4QrRFJZU8Q=="],
15
15
 
16
16
  "jquery": ["jquery@3.7.1", "", {}, "sha512-m4avr8yL8kmFN8psrbFFFmB/If14iN5o9nw/NgnnM+kybDJpRsAynV2BsfpTYrTRysYUdADVD7CkUUizgkpLfg=="],
17
17
  }
@@ -1,7 +1,5 @@
1
1
  require_relative '../base'
2
2
  require_relative 'logo'
3
- require_relative 'header/service_authentication'
4
- require_relative 'header/navigation'
5
3
 
6
4
  module CCS
7
5
  module Components
@@ -13,72 +11,42 @@ module CCS
13
11
  #
14
12
  # @!attribute [r] logo
15
13
  # @return [Logo] The initialised Logo component
16
- # @!attribute [r] service_authentication
17
- # @return [ServiceAuthentication] The initialised service authentication section
18
- # @!attribute [r] navigation
19
- # @return [Navigation] The initialised navigation section
20
- # @!attribute [r] service
21
- # @return [Hash] The options for the service section
22
14
 
23
15
  class Header < Base
24
16
  private
25
17
 
26
- attr_reader :logo, :service_authentication, :navigation, :service
18
+ attr_reader :logo
27
19
 
28
20
  public
29
21
 
30
- # @param service_authentication_items [Array<Hash>] An array of links for the service authentication section of the header.
31
- # See {Components::CCS::Header::ServiceAuthentication#initialize ServiceAuthentication#initialize} for details of the items in the array.
32
- # @param navigation [Hash] options for the navigation section of the header.
33
- # See {Components::CCS::Header::Navigation#initialize Navigation#initialize} for details of the options.
34
- # @param menu_button [Hash] options for the menu button in the header.
35
- # See {Components::CCS::Header::Navigation#initialize Navigation#initialize} for details of the options.
36
- # @param service [Hash] options for the service name
37
22
  # @param options [Hash] options that will be used in customising the HTML
38
23
  #
39
- # @option service [String] :name the name of the service, included in the header
40
- # @option service [String] :href URL for the service name anchor
41
- #
42
24
  # @option options [String] :classes additional CSS classes for the header HTML
43
25
  # @option options [String] :container_classes classes for the container
44
26
  # @option options [String] :homepage_url URL of the homepage. Defaults to +/https://www.crowncommercial.gov.uk+
45
27
  # @option options [Hash] :attributes additional attributes that will added as part of the header HTML
46
28
 
47
- def initialize(service_authentication_items: nil, navigation: nil, menu_button: nil, service: nil, **)
48
- super(**)
29
+ def initialize(**)
30
+ super
49
31
 
50
32
  @options[:container_classes] ||= 'govuk-width-container'
51
33
  @options[:homepage_url] ||= 'https://www.crowncommercial.gov.uk'
52
34
 
53
35
  @logo = Logo.new(context: @context)
54
- @service_authentication = ServiceAuthentication.new(service_authentication_items: service_authentication_items, container_classes: @options[:container_classes], context: @context) if service_authentication_items
55
- @navigation = Navigation.new(navigation: navigation, serivce_name_present: service, menu_button: menu_button, context: @context) if navigation && (navigation[:primary_items] || navigation[:secondary_items])
56
- @service = service
57
36
  end
58
37
 
59
- # rubocop:disable Metrics/AbcSize
60
-
61
38
  # Generates the HTML for the CCS Header component
62
39
  #
63
40
  # @return [ActiveSupport::SafeBuffer]
64
41
 
65
42
  def render
66
43
  tag.header(**options[:attributes]) do
67
- concat(service_authentication.render) if service_authentication
68
44
  concat(tag.div(class: "ccs-header__container #{options[:container_classes]}".rstrip) do
69
45
  concat(header_logo)
70
- if service || navigation
71
- concat(tag.div(class: 'ccs-header__content') do
72
- concat(header_service_name) if service
73
- concat(navigation.render) if navigation
74
- end)
75
- end
76
46
  end)
77
47
  end
78
48
  end
79
49
 
80
- # rubocop:enable Metrics/AbcSize
81
-
82
50
  # The default attributes for the breadcrumbs
83
51
 
84
52
  DEFAULT_ATTRIBUTES = { class: 'ccs-header', data: { module: 'ccs-header' } }.freeze
@@ -94,18 +62,6 @@ module CCS
94
62
  link_to(logo.render, options[:homepage_url], class: 'ccs-header__link ccs-header__link--homepage', aria: { label: 'Crown Commercial Service' })
95
63
  end
96
64
  end
97
-
98
- # Generates the service name section
99
- #
100
- # @return [ActiveSupport::SafeBuffer]
101
-
102
- def header_service_name
103
- if service[:href]
104
- link_to(service[:name], service[:href], class: 'ccs-header__link ccs-header__link--service-name')
105
- else
106
- tag.span(service[:name], class: 'ccs-header__link--service-name')
107
- end
108
- end
109
65
  end
110
66
  end
111
67
  end
@@ -119,8 +119,8 @@ module CCS
119
119
 
120
120
  def dot_logotype
121
121
  capture do
122
- concat(tag.circle(class: 'govuk-logo-dot', cx: '227', cy: '36', r: '7.3'))
123
- concat(tag.path(d: 'M94.7,36.1c0,1.9.2,3.6.7,5.4.5,1.7,1.2,3.2,2.1,4.5.9,1.3,2.2,2.4,3.6,3.2,1.5.8,3.2,1.2,5.3,1.2s3.6-.3,4.9-.9c1.3-.6,2.3-1.4,3.1-2.3.8-.9,1.3-2,1.6-3,.3-1.1.5-2.1.5-3v-.4h-11v-6.6h19.5v24h-7.7v-5.4c-.5.8-1.2,1.6-2,2.3-.8.7-1.7,1.3-2.7,1.8-1,.5-2.1.9-3.3,1.2-1.2.3-2.5.4-3.8.4-3.2,0-6-.6-8.4-1.7-2.5-1.1-4.5-2.7-6.2-4.7-1.7-2-3-4.4-3.8-7.1-.9-2.7-1.3-5.6-1.3-8.7s.5-6,1.5-8.7,2.4-5.1,4.2-7.1c1.8-2,4-3.6,6.5-4.7s5.4-1.7,8.6-1.7,4,.2,5.9.7c1.8.5,3.5,1.1,5.1,2,1.5.9,2.9,1.9,4,3.2,1.2,1.2,2.1,2.6,2.8,4.1l-7.7,4.3c-.5-.9-1-1.8-1.6-2.6-.6-.8-1.3-1.5-2.2-2.1-.8-.6-1.7-1-2.8-1.4-1-.3-2.2-.5-3.5-.5-2,0-3.8.4-5.3,1.2s-2.7,1.9-3.6,3.2c-.9,1.3-1.7,2.8-2.1,4.6s-.7,3.5-.7,5.3v.3h0ZM152.9,13.7c3.2,0,6.1.6,8.7,1.7,2.6,1.2,4.7,2.7,6.5,4.7,1.8,2,3.1,4.4,4.1,7.1s1.4,5.6,1.4,8.7-.5,6-1.4,8.7c-.9,2.7-2.3,5.1-4.1,7.1s-4,3.6-6.5,4.7c-2.6,1.1-5.5,1.7-8.7,1.7s-6.1-.6-8.7-1.7c-2.6-1.1-4.7-2.7-6.5-4.7-1.8-2-3.1-4.4-4.1-7.1-.9-2.7-1.4-5.6-1.4-8.7s.5-6,1.4-8.7,2.3-5.1,4.1-7.1c1.8-2,4-3.6,6.5-4.7s5.4-1.7,8.7-1.7h0ZM152.9,50.4c1.9,0,3.6-.4,5-1.1,1.4-.7,2.7-1.7,3.6-3,1-1.3,1.7-2.8,2.2-4.5.5-1.7.8-3.6.8-5.7v-.2c0-2-.3-3.9-.8-5.7-.5-1.7-1.3-3.3-2.2-4.5-1-1.3-2.2-2.3-3.6-3-1.4-.7-3.1-1.1-5-1.1s-3.6.4-5,1.1c-1.5.7-2.7,1.7-3.6,3s-1.7,2.8-2.2,4.5c-.5,1.7-.8,3.6-.8,5.7v.2c0,2.1.3,4,.8,5.7.5,1.7,1.2,3.2,2.2,4.5,1,1.3,2.2,2.3,3.6,3,1.5.7,3.1,1.1,5,1.1ZM189.1,58l-12.3-44h9.8l8.4,32.9h.3l8.2-32.9h9.7l-12.3,44M262.9,50.4c1.3,0,2.5-.2,3.6-.6,1.1-.4,2-.9,2.8-1.7.8-.8,1.4-1.7,1.9-2.9.5-1.2.7-2.5.7-4.1V14h8.6v28.5c0,2.4-.4,4.6-1.3,6.6-.9,2-2.1,3.6-3.7,5-1.6,1.4-3.4,2.4-5.6,3.2-2.2.7-4.5,1.1-7.1,1.1s-4.9-.4-7.1-1.1c-2.2-.7-4-1.8-5.6-3.2s-2.8-3-3.7-5c-.9-2-1.3-4.1-1.3-6.6V14h8.7v27.2c0,1.6.2,2.9.7,4.1.5,1.2,1.1,2.1,1.9,2.9.8.8,1.7,1.3,2.8,1.7s2.3.6,3.6.6h0ZM288.5,14h8.7v19.1l15.5-19.1h10.8l-15.1,17.6,16.1,26.4h-10.2l-11.5-19.7-5.6,6.3v13.5h-8.7'))
122
+ concat(tag.circle(class: 'govuk-logo-dot', cx: '226', cy: '36', r: '7.3'))
123
+ concat(tag.path(d: 'M93.94 41.25c.4 1.81 1.2 3.21 2.21 4.62 1 1.4 2.21 2.41 3.61 3.21s3.21 1.2 5.22 1.2 3.61-.4 4.82-1c1.4-.6 2.41-1.4 3.21-2.41.8-1 1.4-2.01 1.61-3.01s.4-2.01.4-3.01v.14h-10.86v-7.02h20.07v24.08h-8.03v-5.56c-.6.8-1.38 1.61-2.19 2.41-.8.8-1.81 1.2-2.81 1.81-1 .4-2.21.8-3.41 1.2s-2.41.4-3.81.4a18.56 18.56 0 0 1-14.65-6.63c-1.6-2.01-3.01-4.41-3.81-7.02s-1.4-5.62-1.4-8.83.4-6.02 1.4-8.83a20.45 20.45 0 0 1 19.46-13.65c3.21 0 4.01.2 5.82.8 1.81.4 3.61 1.2 5.02 2.01 1.61.8 2.81 2.01 4.01 3.21s2.21 2.61 2.81 4.21l-7.63 4.41c-.4-1-1-1.81-1.61-2.61-.6-.8-1.4-1.4-2.21-2.01-.8-.6-1.81-1-2.81-1.4-1-.4-2.21-.4-3.61-.4-2.01 0-3.81.4-5.22 1.2-1.4.8-2.61 1.81-3.61 3.21s-1.61 2.81-2.21 4.62c-.4 1.81-.6 3.71-.6 5.42s.8 5.22.8 5.22Zm57.8-27.9c3.21 0 6.22.6 8.63 1.81 2.41 1.2 4.82 2.81 6.62 4.82S170.2 24.39 171 27s1.4 5.62 1.4 8.83-.4 6.02-1.4 8.83-2.41 5.02-4.01 7.02-4.01 3.61-6.62 4.82-5.42 1.81-8.63 1.81-6.22-.6-8.63-1.81-4.82-2.81-6.42-4.82-3.21-4.41-4.01-7.02-1.4-5.62-1.4-8.83.4-6.02 1.4-8.83 2.41-5.02 4.01-7.02 4.01-3.61 6.42-4.82 5.42-1.81 8.63-1.81Zm0 36.73c1.81 0 3.61-.4 5.02-1s2.61-1.81 3.61-3.01 1.81-2.81 2.21-4.41c.4-1.81.8-3.61.8-5.62 0-2.21-.2-4.21-.8-6.02s-1.2-3.21-2.21-4.62c-1-1.2-2.21-2.21-3.61-3.01s-3.21-1-5.02-1-3.61.4-5.02 1c-1.4.8-2.61 1.81-3.61 3.01s-1.81 2.81-2.21 4.62c-.4 1.81-.8 3.61-.8 5.62 0 2.41.2 4.21.8 6.02.4 1.81 1.2 3.21 2.21 4.41s2.21 2.21 3.61 3.01c1.4.8 3.21 1 5.02 1Zm36.32 7.96-12.24-44.15h9.83l8.43 32.77h.4l8.23-32.77h9.83L200.3 58.04h-12.24Zm74.14-7.96c2.18 0 3.51-.6 3.51-.6 1.2-.6 2.01-1 2.81-1.81s1.4-1.81 1.81-2.81a13 13 0 0 0 .8-4.01V13.9h8.63v28.15c0 2.41-.4 4.62-1.4 6.62-.8 2.01-2.21 3.61-3.61 5.02s-3.41 2.41-5.62 3.21-4.62 1.2-7.02 1.2-5.02-.4-7.02-1.2c-2.21-.8-4.01-1.81-5.62-3.21s-2.81-3.01-3.61-5.02-1.4-4.21-1.4-6.62V13.9h8.63v26.95c0 1.61.2 3.01.8 4.01.4 1.2 1.2 2.21 2.01 2.81.8.8 1.81 1.4 2.81 1.81 0 0 1.34.6 3.51.6Zm34.22-36.18v18.92l15.65-18.92h10.82l-15.03 17.32 16.03 26.83h-10.21l-11.44-20.21-5.62 6.22v13.99h-8.83V13.9'))
124
124
  end
125
125
  end
126
126
  end
@@ -12,30 +12,38 @@ module CCS
12
12
  # @return [String] Text for the service navigation link
13
13
  # @!attribute [r] href
14
14
  # @return [String] The href for the service navigation link
15
+ # @!attribute [r] method
16
+ # @return [String] The method for the service navigation request which will make it a button
15
17
 
16
18
  class Link < Base
19
+ include ActionView::Helpers::UrlHelper
20
+
17
21
  private
18
22
 
19
- attr_reader :text, :href
23
+ attr_reader :text, :href, :method
20
24
 
21
25
  public
22
26
 
23
27
  # @param text [String] the text for the service navigation link
24
28
  # @param href [String] the href for the service navigation link
29
+ # @param method [String] the method for the header request which will make it a button
25
30
  # @param options [Hash] options that will be used in customising the HTML
26
31
  #
27
32
  # @option options [Boolean] :active flag to mark the navigation item as active or not
28
33
  # @option options [Hash] :attributes any additional attributes that will added as part of the HTML
29
34
 
30
- def initialize(text:, href: nil, **options)
35
+ def initialize(text:, href: nil, method: nil, **options)
31
36
  super(**options)
32
37
 
33
38
  @options[:attributes][:aria] = { current: options[:current] ? 'page' : 'true' } if options[:active] || options[:current]
34
39
 
35
40
  @text = text
36
41
  @href = href
42
+ @method = method
37
43
  end
38
44
 
45
+ # rubocop:disable Metrics/AbcSize
46
+
39
47
  # Generates the HTML for the GOV.UK Service navigation link
40
48
  #
41
49
  # @return [ActiveSupport::SafeBuffer]
@@ -43,9 +51,17 @@ module CCS
43
51
  def render
44
52
  tag.li(class: "govuk-service-navigation__item #{'govuk-service-navigation__item--active' if options[:active] || options[:current]}".rstrip) do
45
53
  if href
46
- options[:attributes][:class] = 'govuk-service-navigation__link'
54
+ if method
55
+ options[:attributes][:class] = 'govuk-service-navigation__button_as_link'
47
56
 
48
- link_to(inner_content, href, **options[:attributes])
57
+ button_to(href, method: method, **options[:attributes]) do
58
+ inner_content
59
+ end
60
+ else
61
+ options[:attributes][:class] = 'govuk-service-navigation__link'
62
+
63
+ link_to(inner_content, href, **options[:attributes])
64
+ end
49
65
  else
50
66
  options[:attributes][:class] = 'govuk-service-navigation__text'
51
67
 
@@ -54,6 +70,8 @@ module CCS
54
70
  end
55
71
  end
56
72
 
73
+ # rubocop:enable Metrics/AbcSize
74
+
57
75
  private
58
76
 
59
77
  # Generates the HTML for the inner content of the GOV.UK Service navigation link component
@@ -18,6 +18,8 @@ module CCS
18
18
  # @return [String] The id for the navigation
19
19
  # @!attribute [r] menu_button
20
20
  # @return [Hash] The options for the menu button
21
+ # @!attribute [r] collapse_navigation_on_mobile
22
+ # @return [Boolean] Flag to collapse navigation on mobile
21
23
 
22
24
  class Navigation
23
25
  include ActionView::Context
@@ -25,15 +27,16 @@ module CCS
25
27
 
26
28
  private
27
29
 
28
- attr_reader :navigation, :menu_button
30
+ attr_reader :navigation, :menu_button, :collapse_navigation_on_mobile
29
31
 
30
32
  public
31
33
 
32
- # rubocop:disable Metrics/CyclomaticComplexity
34
+ # rubocop:disable Metrics/CyclomaticComplexity, Metrics/AbcSize, Metrics/PerceivedComplexity
33
35
 
34
36
  # @param navigation [Hash] options for the navigation
35
37
  # @param context [ActionView::Base] the view context
36
38
  # @param menu_button [Hash] options for the menu button
39
+ # @param collapse_navigation_on_mobile [Boolean] flag to collapse navigation on mobile
37
40
  #
38
41
  # @option navigation [Array] :items an array of links for the navigation section.
39
42
  # See {Components::GovUK::ServiceNavigation::Link#initialize Link#initialize} for details of the items in the array.
@@ -45,7 +48,7 @@ module CCS
45
48
  # @option menu_button [String] :label text for the aria-label attribute of the button that opens the mobile navigation.
46
49
  # Defaults to +Show or hide menu+.
47
50
 
48
- def initialize(navigation:, context:, menu_button: nil)
51
+ def initialize(navigation:, context:, menu_button: nil, collapse_navigation_on_mobile: nil)
49
52
  menu_button ||= {}
50
53
  menu_button[:text] ||= 'Menu'
51
54
 
@@ -58,9 +61,11 @@ module CCS
58
61
  @navigation[:links] = navigation[:items].map { |navigation_link| Link.new(context: context, **navigation_link) }
59
62
  @navigation[:label] = navigation[:label] || menu_button[:text]
60
63
  @navigation[:class] = "govuk-service-navigation__wrapper #{navigation[:classes]}".rstrip
64
+
65
+ @collapse_navigation_on_mobile = collapse_navigation_on_mobile.nil? ? @navigation[:links].length > 1 : collapse_navigation_on_mobile
61
66
  end
62
67
 
63
- # rubocop:enable Metrics/CyclomaticComplexity
68
+ # rubocop:enable Metrics/CyclomaticComplexity, Metrics/AbcSize, Metrics/PerceivedComplexity
64
69
 
65
70
  # Generates the HTML for the GOV.UK Service Navigation navigation
66
71
  #
@@ -68,7 +73,7 @@ module CCS
68
73
 
69
74
  def render
70
75
  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))
76
+ concat(button_tag(menu_button[:text], type: :button, class: 'govuk-service-navigation__toggle govuk-js-service-navigation-toggle', aria: menu_button[:aria], hidden: true)) if collapse_navigation_on_mobile
72
77
  concat(tag.ul(id: navigation[:id], class: 'govuk-service-navigation__list') do
73
78
  navigation[:links].each { |navigation_link| concat(navigation_link.render) }
74
79
  end)
@@ -33,13 +33,14 @@ module CCS
33
33
  #
34
34
  # @option options [String] :classes additional CSS classes for the service navigation HTML
35
35
  # @option options [Hash] :attributes additional attributes that will added as part of the service navigation HTML
36
+ # @option options [Boolean] :collapse_navigation_on_mobile flag to collapse navigation on mobile
36
37
 
37
38
  def initialize(navigation: nil, menu_button: nil, service: nil, **)
38
39
  super(**)
39
40
 
40
41
  (@options[:attributes][:aria] ||= {})[:label] ||= 'Service information' if service
41
42
 
42
- @navigation = Navigation.new(navigation: navigation, menu_button: menu_button, context: @context) if navigation && navigation[:items]&.compact_blank!.present?
43
+ @navigation = Navigation.new(navigation: navigation, menu_button: menu_button, collapse_navigation_on_mobile: options[:collapse_navigation_on_mobile], context: @context) if navigation && navigation[:items]&.compact_blank!.present?
43
44
  @service = service
44
45
  end
45
46
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module CCS
4
4
  module FrontendHelpers
5
- VERSION = '2.4.0'
5
+ VERSION = '3.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.10.0",
9
- "ccs-frontend": "^1.4.0"
8
+ "govuk-frontend": "5.11.2",
9
+ "ccs-frontend": "2.0.0"
10
10
  }
11
11
  }
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ccs-frontend_helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.0
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Crown Commercial Service
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-05-13 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: rails
@@ -48,9 +48,6 @@ files:
48
48
  - lib/ccs/components/ccs/footer/meta.rb
49
49
  - lib/ccs/components/ccs/footer/navigation.rb
50
50
  - lib/ccs/components/ccs/header.rb
51
- - lib/ccs/components/ccs/header/link.rb
52
- - lib/ccs/components/ccs/header/navigation.rb
53
- - lib/ccs/components/ccs/header/service_authentication.rb
54
51
  - lib/ccs/components/ccs/logo.rb
55
52
  - lib/ccs/components/ccs/password_strength.rb
56
53
  - lib/ccs/components/ccs/password_strength/test.rb
@@ -224,7 +221,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
224
221
  - !ruby/object:Gem::Version
225
222
  version: '0'
226
223
  requirements: []
227
- rubygems_version: 3.6.2
224
+ rubygems_version: 3.6.7
228
225
  specification_version: 4
229
226
  summary: Gem containing view helpers for CCS Ruby on Rails projects
230
227
  test_files: []
@@ -1,78 +0,0 @@
1
- require_relative '../../base'
2
-
3
- module CCS
4
- module Components
5
- module CCS
6
- class Header < Base
7
- # = CCS Header link
8
- #
9
- # The individual header link item
10
- #
11
- # @!attribute [r] text
12
- # @return [String] Text for the header link
13
- # @!attribute [r] li_class
14
- # @return [String] The class for the li elements
15
- # @!attribute [r] href
16
- # @return [String] The href for the header link
17
- # @!attribute [r] method
18
- # @return [String] The method for the header request which will make it a button
19
-
20
- class Link < Base
21
- include ActionView::Helpers::UrlHelper
22
-
23
- private
24
-
25
- attr_reader :text, :li_class, :href, :method
26
-
27
- public
28
-
29
- # @param text [String] the text for the header link
30
- # @param li_class [String] class for the li elements
31
- # @param href [String] the href for the header link
32
- # @param method [String] the method for the header request which will make it a button
33
- # @param options [Hash] options that will be used in customising the HTML
34
- #
35
- # @option options [Boolean] :active flag to mark the navigation item as active or not
36
- # @option options [Hash] :attributes any additional attributes that will added as part of the HTML
37
-
38
- def initialize(text:, li_class:, href: nil, method: nil, **)
39
- super(**)
40
-
41
- @text = text
42
- @href = href
43
- @li_class = li_class
44
- @method = method
45
- end
46
-
47
- # rubocop:disable Metrics/AbcSize
48
-
49
- # Generates the HTML for the CCS Header link
50
- #
51
- # @return [ActiveSupport::SafeBuffer]
52
-
53
- def render
54
- tag.li(class: "#{li_class} #{'ccs-header__navigation-item--active' if options[:active]}".rstrip) do
55
- if href
56
- if method
57
- options[:attributes][:class] = 'ccs-header__button_as_link'
58
-
59
- button_to(href, method: method, **options[:attributes]) do
60
- text
61
- end
62
- else
63
- options[:attributes][:class] = 'ccs-header__link'
64
-
65
- link_to(text, href, **options[:attributes])
66
- end
67
- else
68
- text
69
- end
70
- end
71
- end
72
-
73
- # rubocop:enable Metrics/AbcSize
74
- end
75
- end
76
- end
77
- end
78
- end
@@ -1,99 +0,0 @@
1
- require_relative 'link'
2
-
3
- module CCS
4
- module Components
5
- module CCS
6
- class Header < Base
7
- # = CCS Header navigation
8
- #
9
- # The header navigation section
10
- #
11
- # @!attribute [r] primary_links
12
- # @return [Array<Link>] An array of the initialised primary navigation links
13
- # @!attribute [r] secondary_links
14
- # @return [Array<Link>] An array of the initialised secondary navigation links
15
- # @!attribute [r] navigation_label
16
- # @return [String] The aria label for the navigation
17
- # @!attribute [r] navigation_classes
18
- # @return [String] The classes 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 :primary_links, :secondary_links, :navigation_label, :navigation_classes, :menu_button
29
-
30
- public
31
-
32
- # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
33
-
34
- # @param navigation [Hash] options for the navigation
35
- # @param menu_button [Hash] options for the menu button
36
- # @param context [ActionView::Base] the view context
37
- #
38
- # @option navigation [Array] :primary_items an array of primary links for the navigation section.
39
- # See {Components::CCS::Header::Link#initialize Link#initialize} for details of the items in the array.
40
- # @option navigation [Array] :secondary_items an array of secondary links for the navigation section.
41
- # See {Components::CCS::Header::Link#initialize Link#initialize} for details of the items in the array.
42
- # @option navigation [String] :classes additional CSS classes for the navigation HTML
43
- # @option navigation [String] :label text for the aria-label attribute of the navigation. Defaults to the menu button text
44
- #
45
- # @option menu_button [String] :text text for the button that opens the mobile navigation menu.
46
- # By default, this is set to +Menu+.
47
- # @option menu_button [String] :label text for the aria-label attribute of the button that opens the mobile navigation.
48
- # Defaults to +Show or hide menu+.
49
-
50
- def initialize(navigation:, serivce_name_present:, context:, menu_button: nil)
51
- menu_button ||= {}
52
- menu_button[:text] ||= 'Menu'
53
- menu_button[:label] ||= 'Show or hide menu'
54
-
55
- @menu_button = menu_button
56
- @primary_links = navigation[:primary_items]&.map { |navigation_link| Link.new(li_class: LI_CLASS, context: context, **navigation_link) }
57
- @secondary_links = navigation[:secondary_items]&.map { |navigation_link| Link.new(li_class: LI_CLASS, context: context, **navigation_link) }
58
- @navigation_label = navigation[:label] || menu_button[:text]
59
- @navigation_classes = 'ccs-header__navigation'
60
- @navigation_classes << ' ccs-header__navigation--no-service-name' unless serivce_name_present
61
- @navigation_classes << " #{navigation[:classes]}" if navigation[:classes]
62
- end
63
-
64
- # rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
65
-
66
- # rubocop:disable Metrics/AbcSize
67
-
68
- # Generates the HTML for the GOV.UK Navigation
69
- #
70
- # @return [ActiveSupport::SafeBuffer]
71
-
72
- def render
73
- tag.nav(aria: { label: navigation_label }, class: navigation_classes) do
74
- concat(button_tag(menu_button[:text], type: :button, class: 'ccs-header__menu-button ccs-js-header-toggle', aria: { controls: 'navigation', label: menu_button[:label] }, hidden: true))
75
- concat(tag.div(id: 'navigation', class: 'ccs-header__navigation-lists') do
76
- if secondary_links
77
- concat(tag.ul(id: 'navigation-secondary', class: "ccs-header__navigation-secondary-list #{'ccs-header__navigation--no-second-list' unless primary_links}".rstrip) do
78
- secondary_links.each { |secondary_link| concat(secondary_link.render) }
79
- end)
80
- end
81
- if primary_links
82
- concat(tag.ul(id: 'navigation-primary', class: "ccs-header__navigation-primary-list #{'ccs-header__navigation--no-second-list' unless secondary_links}".rstrip) do
83
- primary_links.each { |primary_link| concat(primary_link.render) }
84
- end)
85
- end
86
- end)
87
- end
88
- end
89
-
90
- # rubocop:enable Metrics/AbcSize
91
-
92
- # The li class for the navigation links
93
-
94
- LI_CLASS = 'ccs-header__navigation-item'.freeze
95
- end
96
- end
97
- end
98
- end
99
- end
@@ -1,53 +0,0 @@
1
- require_relative 'link'
2
-
3
- module CCS
4
- module Components
5
- module CCS
6
- class Header < Base
7
- # = CCS Header Service Authentication
8
- #
9
- # The individual footer navigation item
10
- #
11
- # @!attribute [r] service_authentication_links
12
- # @return [Array<Link>] An array of the initialised service authentication links
13
- # @!attribute [r] container_classes
14
- # @return [String] classes for the container
15
-
16
- class ServiceAuthentication
17
- include ActionView::Context
18
- include ActionView::Helpers
19
-
20
- private
21
-
22
- attr_reader :service_authentication_links, :container_classes
23
-
24
- public
25
-
26
- # @param service_authentication_items [Array<Hash>] an array of links for the service authentication section.
27
- # See {Components::CCS::Header::Link#initialize Link#initialize} for details of the items in the array.
28
- # @param container_classes [String] classes for the container
29
- # @param context [ActionView::Base] the view context
30
-
31
- def initialize(service_authentication_items:, context:, container_classes: nil)
32
- @service_authentication_links = service_authentication_items&.map { |service_authentication_link| Link.new(li_class: 'ccs-header__service-authentication-item', active: false, context: context, **service_authentication_link) }
33
- @container_classes = container_classes
34
- end
35
-
36
- # Generates the HTML for the CCS Footer Meta sections
37
- #
38
- # @return [ActiveSupport::SafeBuffer]
39
-
40
- def render
41
- tag.div(class: 'ccs-header__service-authentication') do
42
- tag.div(class: "ccs-header__service-authentication-container #{container_classes}".rstrip) do
43
- tag.ul(class: 'ccs-header__service-authentication-list') do
44
- service_authentication_links.each { |service_authentication_link| concat(service_authentication_link.render) }
45
- end
46
- end
47
- end
48
- end
49
- end
50
- end
51
- end
52
- end
53
- end