ccs-frontend_helpers 0.1.0.rc.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +7 -0
  2. data/.rspec +2 -0
  3. data/.rubocop.yml +127 -0
  4. data/CHANGELOG.md +44 -0
  5. data/Gemfile +10 -0
  6. data/Gemfile.lock +241 -0
  7. data/LICENSE.txt +21 -0
  8. data/README.md +102 -0
  9. data/Rakefile +10 -0
  10. data/ccs-frontend_helpers.gemspec +47 -0
  11. data/lib/ccs/frontend_helpers/ccs_frontend/dashboard_panels.rb +79 -0
  12. data/lib/ccs/frontend_helpers/ccs_frontend/footer.rb +141 -0
  13. data/lib/ccs/frontend_helpers/ccs_frontend/header.rb +205 -0
  14. data/lib/ccs/frontend_helpers/ccs_frontend/logo.rb +49 -0
  15. data/lib/ccs/frontend_helpers/ccs_frontend.rb +20 -0
  16. data/lib/ccs/frontend_helpers/govuk_frontend/accordion.rb +115 -0
  17. data/lib/ccs/frontend_helpers/govuk_frontend/back_link.rb +39 -0
  18. data/lib/ccs/frontend_helpers/govuk_frontend/breadcrumbs.rb +76 -0
  19. data/lib/ccs/frontend_helpers/govuk_frontend/button.rb +127 -0
  20. data/lib/ccs/frontend_helpers/govuk_frontend/cookie_banner.rb +136 -0
  21. data/lib/ccs/frontend_helpers/govuk_frontend/details.rb +46 -0
  22. data/lib/ccs/frontend_helpers/govuk_frontend/error_message.rb +67 -0
  23. data/lib/ccs/frontend_helpers/govuk_frontend/error_summary.rb +100 -0
  24. data/lib/ccs/frontend_helpers/govuk_frontend/field/character_count.rb +165 -0
  25. data/lib/ccs/frontend_helpers/govuk_frontend/field/checkboxes.rb +200 -0
  26. data/lib/ccs/frontend_helpers/govuk_frontend/field/date_input.rb +153 -0
  27. data/lib/ccs/frontend_helpers/govuk_frontend/field/file_upload.rb +83 -0
  28. data/lib/ccs/frontend_helpers/govuk_frontend/field/input.rb +153 -0
  29. data/lib/ccs/frontend_helpers/govuk_frontend/field/radios.rb +201 -0
  30. data/lib/ccs/frontend_helpers/govuk_frontend/field/select.rb +124 -0
  31. data/lib/ccs/frontend_helpers/govuk_frontend/field/textarea.rb +106 -0
  32. data/lib/ccs/frontend_helpers/govuk_frontend/field.rb +213 -0
  33. data/lib/ccs/frontend_helpers/govuk_frontend/fieldset.rb +71 -0
  34. data/lib/ccs/frontend_helpers/govuk_frontend/footer.rb +183 -0
  35. data/lib/ccs/frontend_helpers/govuk_frontend/form_group.rb +50 -0
  36. data/lib/ccs/frontend_helpers/govuk_frontend/header.rb +161 -0
  37. data/lib/ccs/frontend_helpers/govuk_frontend/hint.rb +38 -0
  38. data/lib/ccs/frontend_helpers/govuk_frontend/inset_text.rb +44 -0
  39. data/lib/ccs/frontend_helpers/govuk_frontend/label.rb +92 -0
  40. data/lib/ccs/frontend_helpers/govuk_frontend/notification_banner.rb +136 -0
  41. data/lib/ccs/frontend_helpers/govuk_frontend/pagination.rb +336 -0
  42. data/lib/ccs/frontend_helpers/govuk_frontend/panel.rb +51 -0
  43. data/lib/ccs/frontend_helpers/govuk_frontend/phase_banner.rb +49 -0
  44. data/lib/ccs/frontend_helpers/govuk_frontend/skip_link.rb +40 -0
  45. data/lib/ccs/frontend_helpers/govuk_frontend/step_by_step_navigation.rb +215 -0
  46. data/lib/ccs/frontend_helpers/govuk_frontend/summary_list.rb +226 -0
  47. data/lib/ccs/frontend_helpers/govuk_frontend/table.rb +124 -0
  48. data/lib/ccs/frontend_helpers/govuk_frontend/tabs.rb +95 -0
  49. data/lib/ccs/frontend_helpers/govuk_frontend/tag.rb +42 -0
  50. data/lib/ccs/frontend_helpers/govuk_frontend/warning_text.rb +53 -0
  51. data/lib/ccs/frontend_helpers/govuk_frontend.rb +82 -0
  52. data/lib/ccs/frontend_helpers/shared_methods.rb +27 -0
  53. data/lib/ccs/frontend_helpers/version.rb +7 -0
  54. data/lib/ccs/frontend_helpers.rb +20 -0
  55. data/sig/ccs/frontend_helpers.rbs +6 -0
  56. metadata +241 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 688e4ab0ddc41179157be55abb6a1afe720c55e027305e840d009cfbdad580c9
4
+ data.tar.gz: c8aa5d34f38f99b2e70f4eea14d0614075bd2c6d58ed7ba1fdb92683594ad65e
5
+ SHA512:
6
+ metadata.gz: 7a3f14a98c028b451ba6d39962923eac034b9a0619adb3722d40f7f3230dd860f5ca8bffc4eb1f94292b1c6d87772df96c272a946e0c00d78fdc681f16cb3cc4
7
+ data.tar.gz: 89519f4a8a15e9a2d4517a03562e2c001635f5b79fbb1020474393f45b32f7b8f0cf22d3c1541e711e945425542416791cb4cc6c9e4608faf336e14af668277a
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,127 @@
1
+ ---
2
+ require:
3
+ - rubocop-rspec
4
+ - rubocop-rails
5
+ - rubocop-rake
6
+
7
+ AllCops:
8
+ NewCops: enable
9
+ TargetRubyVersion: 2.7
10
+ Exclude:
11
+ - 'bin/**/*'
12
+ - 'tmp/**/*'
13
+ - 'vendor/**/*'
14
+
15
+ Bundler/OrderedGems:
16
+ Enabled: false
17
+
18
+ Style/Alias:
19
+ Enabled: false
20
+
21
+ Style/FrozenStringLiteralComment:
22
+ Enabled: false
23
+
24
+ Style/NumericLiterals:
25
+ Enabled: false
26
+
27
+ Style/TrailingCommaInArrayLiteral:
28
+ Enabled: false
29
+
30
+ Style/TrailingCommaInHashLiteral:
31
+ Enabled: false
32
+
33
+ Style/TrailingCommaInArguments:
34
+ Enabled: false
35
+
36
+ Style/Documentation:
37
+ Enabled: false
38
+
39
+ Style/DoubleNegation:
40
+ Enabled: false
41
+
42
+ Style/WordArray:
43
+ Enabled: false
44
+
45
+ Style/ClassAndModuleChildren:
46
+ Enabled: false
47
+
48
+ Layout/EndOfLine:
49
+ EnforcedStyle: lf
50
+
51
+ Layout/TrailingEmptyLines:
52
+ Enabled: true
53
+
54
+ Layout/LineLength:
55
+ Max: 120
56
+ Enabled: false
57
+ AllowedPatterns:
58
+ - 'it .* do$'
59
+ - 'context .* do$'
60
+ - 'scenario .* do$'
61
+
62
+ Metrics/ClassLength:
63
+ Enabled: false
64
+
65
+ Metrics/MethodLength:
66
+ Max: 50
67
+ Exclude:
68
+
69
+ Metrics/AbcSize:
70
+ Max: 25 # TODO: Restore to '20'
71
+ Exclude:
72
+ - 'spec/**/*'
73
+
74
+ Metrics/BlockLength:
75
+ Max: 40
76
+ Exclude:
77
+ - 'spec/**/*'
78
+
79
+ RSpec/ContextWording:
80
+ Prefixes:
81
+ - when
82
+ - with
83
+ - without
84
+ - and
85
+
86
+ Metrics/ModuleLength:
87
+ Exclude:
88
+ - 'spec/ccs/frontend_helpers/**/*'
89
+
90
+ RSpec/MultipleMemoizedHelpers:
91
+ Enabled: false
92
+
93
+ RSpec/VariableName:
94
+ Enabled: false
95
+
96
+ Naming/VariableNumber:
97
+ Enabled: false
98
+
99
+ Lint/MissingSuper:
100
+ Enabled: false
101
+
102
+ Rails/HelperInstanceVariable:
103
+ Enabled: false
104
+
105
+ Style/OptionalBooleanParameter:
106
+ Enabled: false
107
+
108
+ RSpec/VerifiedDoubleReference:
109
+ Enabled: false
110
+
111
+ RSpec/NestedGroups:
112
+ Max: 5
113
+
114
+ RSpec/ExampleLength:
115
+ Exclude:
116
+ - 'spec/ccs/frontend_helpers/**/*'
117
+
118
+ Rails/DynamicFindBy:
119
+ Whitelist:
120
+ - find_by_id
121
+
122
+ RSpec/MultipleExpectations:
123
+ Max: 3
124
+
125
+ RSpec/FilePath:
126
+ CustomTransform:
127
+ GovUKFrontend: govuk_frontend
data/CHANGELOG.md ADDED
@@ -0,0 +1,44 @@
1
+ ## [0.1.0.rc.1] - 2023-02-22
2
+
3
+ Initial release of CCS Frontend Helpers.
4
+ This release contains view helpers that are used to create GOV.UK and CCS components.
5
+
6
+ The following GOV.UK helpers have been added:
7
+
8
+ - Accordion
9
+ - Back link
10
+ - Breadcrumbs
11
+ - Button
12
+ - Character count
13
+ - Checkboxes
14
+ - Cookie banner
15
+ - Date input
16
+ - Details
17
+ - Error message
18
+ - Error summary
19
+ - Fieldset
20
+ - File upload
21
+ - Footer
22
+ - Header
23
+ - Inset text
24
+ - Notification banner
25
+ - Pagination
26
+ - Panel
27
+ - Phase banner
28
+ - Radios
29
+ - Select
30
+ - Skip link
31
+ - Summary list
32
+ - Table
33
+ - Tabs
34
+ - Tag
35
+ - Text input
36
+ - Textarea
37
+ - Warning text
38
+
39
+ The following CCS helpers have been added:
40
+
41
+ - Dashboard Panels
42
+ - Logo
43
+ - Header
44
+ - Footer
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in ccs-frontend_helpers.gemspec
6
+ gemspec
7
+
8
+ gem 'rake', '~> 13.0'
9
+
10
+ gem 'rspec', '~> 3.0'
data/Gemfile.lock ADDED
@@ -0,0 +1,241 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ ccs-frontend_helpers (0.1.0.rc.1)
5
+ rails (>= 6.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actioncable (7.0.4.2)
11
+ actionpack (= 7.0.4.2)
12
+ activesupport (= 7.0.4.2)
13
+ nio4r (~> 2.0)
14
+ websocket-driver (>= 0.6.1)
15
+ actionmailbox (7.0.4.2)
16
+ actionpack (= 7.0.4.2)
17
+ activejob (= 7.0.4.2)
18
+ activerecord (= 7.0.4.2)
19
+ activestorage (= 7.0.4.2)
20
+ activesupport (= 7.0.4.2)
21
+ mail (>= 2.7.1)
22
+ net-imap
23
+ net-pop
24
+ net-smtp
25
+ actionmailer (7.0.4.2)
26
+ actionpack (= 7.0.4.2)
27
+ actionview (= 7.0.4.2)
28
+ activejob (= 7.0.4.2)
29
+ activesupport (= 7.0.4.2)
30
+ mail (~> 2.5, >= 2.5.4)
31
+ net-imap
32
+ net-pop
33
+ net-smtp
34
+ rails-dom-testing (~> 2.0)
35
+ actionpack (7.0.4.2)
36
+ actionview (= 7.0.4.2)
37
+ activesupport (= 7.0.4.2)
38
+ rack (~> 2.0, >= 2.2.0)
39
+ rack-test (>= 0.6.3)
40
+ rails-dom-testing (~> 2.0)
41
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
42
+ actiontext (7.0.4.2)
43
+ actionpack (= 7.0.4.2)
44
+ activerecord (= 7.0.4.2)
45
+ activestorage (= 7.0.4.2)
46
+ activesupport (= 7.0.4.2)
47
+ globalid (>= 0.6.0)
48
+ nokogiri (>= 1.8.5)
49
+ actionview (7.0.4.2)
50
+ activesupport (= 7.0.4.2)
51
+ builder (~> 3.1)
52
+ erubi (~> 1.4)
53
+ rails-dom-testing (~> 2.0)
54
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
55
+ activejob (7.0.4.2)
56
+ activesupport (= 7.0.4.2)
57
+ globalid (>= 0.3.6)
58
+ activemodel (7.0.4.2)
59
+ activesupport (= 7.0.4.2)
60
+ activerecord (7.0.4.2)
61
+ activemodel (= 7.0.4.2)
62
+ activesupport (= 7.0.4.2)
63
+ activestorage (7.0.4.2)
64
+ actionpack (= 7.0.4.2)
65
+ activejob (= 7.0.4.2)
66
+ activerecord (= 7.0.4.2)
67
+ activesupport (= 7.0.4.2)
68
+ marcel (~> 1.0)
69
+ mini_mime (>= 1.1.0)
70
+ activesupport (7.0.4.2)
71
+ concurrent-ruby (~> 1.0, >= 1.0.2)
72
+ i18n (>= 1.6, < 2)
73
+ minitest (>= 5.1)
74
+ tzinfo (~> 2.0)
75
+ addressable (2.8.1)
76
+ public_suffix (>= 2.0.2, < 6.0)
77
+ ast (2.4.2)
78
+ builder (3.2.4)
79
+ capybara (3.38.0)
80
+ addressable
81
+ matrix
82
+ mini_mime (>= 0.1.3)
83
+ nokogiri (~> 1.8)
84
+ rack (>= 1.6.0)
85
+ rack-test (>= 0.6.3)
86
+ regexp_parser (>= 1.5, < 3.0)
87
+ xpath (~> 3.2)
88
+ concurrent-ruby (1.2.0)
89
+ crass (1.0.6)
90
+ date (3.3.3)
91
+ diff-lcs (1.5.0)
92
+ docile (1.4.0)
93
+ erubi (1.12.0)
94
+ globalid (1.1.0)
95
+ activesupport (>= 5.0)
96
+ i18n (1.12.0)
97
+ concurrent-ruby (~> 1.0)
98
+ json (2.6.3)
99
+ loofah (2.19.1)
100
+ crass (~> 1.0.2)
101
+ nokogiri (>= 1.5.9)
102
+ mail (2.8.1)
103
+ mini_mime (>= 0.1.1)
104
+ net-imap
105
+ net-pop
106
+ net-smtp
107
+ marcel (1.0.2)
108
+ matrix (0.4.2)
109
+ method_source (1.0.0)
110
+ mini_mime (1.1.2)
111
+ minitest (5.17.0)
112
+ net-imap (0.3.4)
113
+ date
114
+ net-protocol
115
+ net-pop (0.1.2)
116
+ net-protocol
117
+ net-protocol (0.2.1)
118
+ timeout
119
+ net-smtp (0.3.3)
120
+ net-protocol
121
+ nio4r (2.5.8)
122
+ nokogiri (1.14.1-x86_64-darwin)
123
+ racc (~> 1.4)
124
+ nokogiri (1.14.1-x86_64-linux)
125
+ racc (~> 1.4)
126
+ parallel (1.22.1)
127
+ parser (3.2.1.0)
128
+ ast (~> 2.4.1)
129
+ public_suffix (5.0.1)
130
+ racc (1.6.2)
131
+ rack (2.2.6.2)
132
+ rack-test (2.0.2)
133
+ rack (>= 1.3)
134
+ rails (7.0.4.2)
135
+ actioncable (= 7.0.4.2)
136
+ actionmailbox (= 7.0.4.2)
137
+ actionmailer (= 7.0.4.2)
138
+ actionpack (= 7.0.4.2)
139
+ actiontext (= 7.0.4.2)
140
+ actionview (= 7.0.4.2)
141
+ activejob (= 7.0.4.2)
142
+ activemodel (= 7.0.4.2)
143
+ activerecord (= 7.0.4.2)
144
+ activestorage (= 7.0.4.2)
145
+ activesupport (= 7.0.4.2)
146
+ bundler (>= 1.15.0)
147
+ railties (= 7.0.4.2)
148
+ rails-dom-testing (2.0.3)
149
+ activesupport (>= 4.2.0)
150
+ nokogiri (>= 1.6)
151
+ rails-html-sanitizer (1.5.0)
152
+ loofah (~> 2.19, >= 2.19.1)
153
+ railties (7.0.4.2)
154
+ actionpack (= 7.0.4.2)
155
+ activesupport (= 7.0.4.2)
156
+ method_source
157
+ rake (>= 12.2)
158
+ thor (~> 1.0)
159
+ zeitwerk (~> 2.5)
160
+ rainbow (3.1.1)
161
+ rake (13.0.6)
162
+ regexp_parser (2.7.0)
163
+ rexml (3.2.5)
164
+ rspec (3.12.0)
165
+ rspec-core (~> 3.12.0)
166
+ rspec-expectations (~> 3.12.0)
167
+ rspec-mocks (~> 3.12.0)
168
+ rspec-core (3.12.1)
169
+ rspec-support (~> 3.12.0)
170
+ rspec-expectations (3.12.2)
171
+ diff-lcs (>= 1.2.0, < 2.0)
172
+ rspec-support (~> 3.12.0)
173
+ rspec-mocks (3.12.3)
174
+ diff-lcs (>= 1.2.0, < 2.0)
175
+ rspec-support (~> 3.12.0)
176
+ rspec-support (3.12.0)
177
+ rubocop (1.45.1)
178
+ json (~> 2.3)
179
+ parallel (~> 1.10)
180
+ parser (>= 3.2.0.0)
181
+ rainbow (>= 2.2.2, < 4.0)
182
+ regexp_parser (>= 1.8, < 3.0)
183
+ rexml (>= 3.2.5, < 4.0)
184
+ rubocop-ast (>= 1.24.1, < 2.0)
185
+ ruby-progressbar (~> 1.7)
186
+ unicode-display_width (>= 2.4.0, < 3.0)
187
+ rubocop-ast (1.26.0)
188
+ parser (>= 3.2.1.0)
189
+ rubocop-capybara (2.17.0)
190
+ rubocop (~> 1.41)
191
+ rubocop-rails (2.17.4)
192
+ activesupport (>= 4.2.0)
193
+ rack (>= 1.1)
194
+ rubocop (>= 1.33.0, < 2.0)
195
+ rubocop-rake (0.6.0)
196
+ rubocop (~> 1.0)
197
+ rubocop-rspec (2.18.1)
198
+ rubocop (~> 1.33)
199
+ rubocop-capybara (~> 2.17)
200
+ ruby-progressbar (1.11.0)
201
+ simplecov (0.22.0)
202
+ docile (~> 1.1)
203
+ simplecov-html (~> 0.11)
204
+ simplecov_json_formatter (~> 0.1)
205
+ simplecov-html (0.12.3)
206
+ simplecov_json_formatter (0.1.4)
207
+ thor (1.2.1)
208
+ timeout (0.3.1)
209
+ tzinfo (2.0.6)
210
+ concurrent-ruby (~> 1.0)
211
+ unicode-display_width (2.4.2)
212
+ webrick (1.7.0)
213
+ websocket-driver (0.7.5)
214
+ websocket-extensions (>= 0.1.0)
215
+ websocket-extensions (0.1.5)
216
+ xpath (3.2.0)
217
+ nokogiri (~> 1.8)
218
+ yard (0.9.28)
219
+ webrick (~> 1.7.0)
220
+ zeitwerk (2.6.6)
221
+
222
+ PLATFORMS
223
+ x86_64-darwin-19
224
+ x86_64-darwin-20
225
+ x86_64-linux
226
+
227
+ DEPENDENCIES
228
+ bundler (~> 2.3)
229
+ capybara (~> 3.38.0)
230
+ ccs-frontend_helpers!
231
+ rake (~> 13.0)
232
+ rspec (~> 3.0)
233
+ rubocop (~> 1.36)
234
+ rubocop-rails (~> 2.16)
235
+ rubocop-rake (~> 0.6)
236
+ rubocop-rspec (~> 2.13)
237
+ simplecov (~> 0.21)
238
+ yard (~> 0.9)
239
+
240
+ BUNDLED WITH
241
+ 2.3.12
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 tim-s-ccs
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,102 @@
1
+ # CCS Frontend Helpers
2
+
3
+ [![Ruby](https://github.com/tim-s-ccs/ccs-frontend_helpers/actions/workflows/main.yml/badge.svg)](https://github.com/tim-s-ccs/ccs-frontend_helpers/actions/workflows/main.yml)
4
+ [![Gem Version](https://badge.fury.io/rb/ccs-frontend_helpers.svg)](https://badge.fury.io/rb/ccs-frontend_helpers)
5
+
6
+ The CCS Frontend Helpers gem was created for use in the Crown Marketplace projects at the Crown Commercial Service.
7
+ This project contains two applications (both use the Ruby on Rails framework):
8
+ - [Crown Marketplace](https://github.com/Crown-Commercial-Service/crown-marketplace)
9
+ - [Crown Marketplace Legacy](https://github.com/Crown-Commercial-Service/crown-marketplace-legacy)
10
+
11
+ ## Installation
12
+
13
+ Install the gem and add to the application's Gemfile by executing:
14
+
15
+ $ bundle add ccs-frontend_helpers
16
+
17
+ If bundler is not being used to manage dependencies, install the gem by executing:
18
+
19
+ $ gem install ccs-frontend_helpers
20
+
21
+ ## Usage
22
+
23
+ To use this gem, simply add it to your Gemfile (as described above).
24
+
25
+ ### Helpers
26
+
27
+ To include the helper methods from the `GovUKFrontend` and `CCSFrontend` module, you can include the `CCS::FrontendHelpers` module in your `app/helpers/application_helper.rb` file like so:
28
+
29
+ ```ruby
30
+ module ApplicationHelper
31
+ include CCS::FrontendHelpers
32
+ end
33
+ ```
34
+
35
+ This will give you access to a variety of [GDS components](https://design-system.service.gov.uk/components) and [CCS components](https://github.com/tim-s-ccs/ts-ccs-frontend) to use in your application views.
36
+ The `GovUKFrontend` components are based on the components found in [GOV.UK Frontend v4.5.0](https://github.com/alphagov/govuk-frontend/releases/tag/v4.5.0).
37
+
38
+ Documentation for the helper methods can be found at [LINK TO RDOCS](#)
39
+
40
+ ## Development
41
+
42
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
43
+
44
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
45
+
46
+ ### Linting
47
+
48
+ The [rubocop](https://github.com/rubocop-hq/rubocop) & [rubocop-rspec](https://github.com/rubocop-hq/rubocop-rspec) gems are used to enforce standard coding styles.
49
+ Some "cops" in the standard configuration have been disabled or adjusted in [`.rubocop.yml`](https://github.com/Crown-Commercial-Service/crown-marketplace-legacy/blob/master/.rubocop.yml).
50
+ Rubocop linting is run as part of the default Rake task, but can be run individually using `rake rubocop`.
51
+
52
+ ### Testing
53
+
54
+ #### Unit testing
55
+ There is an automated RSpec-based test suite.
56
+
57
+ You can run all the unit tests with:
58
+ ```shell
59
+ bundle exec rake
60
+ ```
61
+
62
+ To run a specific unit test, use:
63
+ ```shell
64
+ bundle exec rspec /path/to/file_spec.rb
65
+ ```
66
+
67
+ All the specs are run as part of the Pull Request process.
68
+
69
+ ### Code coverage
70
+
71
+ Code coverage is measured by [simplecov](https://github.com/simplecov-ruby/simplecov)
72
+
73
+ After running the Rspec tests, open [coverage/index.html](coverage/index.html) in a browser to see the code coverage percentage.
74
+
75
+ ### Managing dependencies
76
+
77
+ We use [dependabot](https://github.com/dependabot) and [Snyk](https://app.snyk.io/org/ccs-wattsa) to help manage our dependencies.
78
+
79
+ We schedule `dependabot` to run every Sunday night which will get the latest dependency updates.
80
+
81
+ Snyk is used more for analysing security issues and it will raise PRs itself for a developer to analyse.
82
+
83
+ ## Contributing
84
+
85
+ Bug reports and pull requests are welcome on GitHub at https://github.com/tim-s-ccs/ccs-frontend_helpers.
86
+
87
+ To contribute to the project, you should checkout a new branch from `main` and make your changes.
88
+
89
+ Before pushing to the remote, you should squash your commits into a single commit.
90
+ This can be done using `git rebase -i main` and changing `pick` to `s` for the commits you want to squash (usually all but the first).
91
+ This is not required but it helps keep the commit history fairly neat and tidy
92
+
93
+ Once you have pushed your changes, you should open a Pull Request on the main branch.
94
+ This will run:
95
+ - Rubocop
96
+ - Unit tests
97
+
98
+ Once all these have passed, and the PR has been reviewed and approved by another developer, you can merge the PR.
99
+
100
+ ## Licence
101
+
102
+ The gem is available as open source under the terms of the [MIT Licence](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+ require 'rubocop/rake_task'
6
+
7
+ RSpec::Core::RakeTask.new(:spec)
8
+ RuboCop::RakeTask.new(:rubocop)
9
+
10
+ task default: %i[rubocop spec]
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/ccs/frontend_helpers/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'ccs-frontend_helpers'
7
+ spec.version = CCS::FrontendHelpers::VERSION
8
+ spec.authors = ['tim-s-ccs']
9
+ spec.email = ['timothy.south@crowncommercial.gov.uk']
10
+
11
+ spec.summary = 'Gem containing view helpers for CCS Ruby on Rails projects'
12
+ spec.description = 'Gem containing view helpers for CCS Ruby on Rails projects'
13
+ spec.homepage = 'https://github.com/tim-s-ccs/ccs-frontend_helpers'
14
+ spec.license = 'MIT'
15
+ spec.required_ruby_version = '>= 2.7.0'
16
+
17
+ # spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'"
18
+
19
+ spec.metadata['homepage_uri'] = spec.homepage
20
+ spec.metadata['source_code_uri'] = spec.homepage
21
+ spec.metadata['changelog_uri'] = "#{spec.homepage}/blob/main/CHANGELOG.md"
22
+
23
+ # Specify which files should be added to the gem when it is released.
24
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
25
+ spec.files = Dir.chdir(__dir__) do
26
+ `git ls-files -z`.split("\x0").reject do |f|
27
+ (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
28
+ end
29
+ end
30
+ spec.bindir = 'exe'
31
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
32
+ spec.require_paths = ['lib']
33
+
34
+ spec.add_dependency 'rails', '>= 6.0'
35
+
36
+ spec.add_development_dependency 'bundler', '~> 2.3'
37
+ spec.add_development_dependency 'capybara', '~> 3.38.0'
38
+ spec.add_development_dependency 'rspec', '~> 3.12'
39
+ spec.add_development_dependency 'rubocop', '~> 1.36'
40
+ spec.add_development_dependency 'rubocop-rails', '~> 2.16'
41
+ spec.add_development_dependency 'rubocop-rake', '~> 0.6'
42
+ spec.add_development_dependency 'rubocop-rspec', '~> 2.13'
43
+ spec.add_development_dependency 'simplecov', '~> 0.21'
44
+ spec.add_development_dependency 'yard', '~> 0.9'
45
+
46
+ spec.metadata['rubygems_mfa_required'] = 'true'
47
+ end
@@ -0,0 +1,79 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'action_view'
4
+
5
+ require_relative '../shared_methods'
6
+
7
+ module CCS
8
+ module FrontendHelpers
9
+ module CCSFrontend
10
+ # = CCS Dashboard Panels
11
+ #
12
+ # This helper is used for generating the dashboard panels component
13
+
14
+ module DashboardPanels
15
+ include SharedMethods
16
+ include ActionView::Context
17
+ include ActionView::Helpers::TagHelper
18
+ include ActionView::Helpers::TextHelper
19
+ include ActionView::Helpers::UrlHelper
20
+
21
+ # Generates the HTML for the CCS Dashboard Panels component
22
+ #
23
+ # @param panel_items [Array] the panel items, see {ccs_dashboard_panels_item}
24
+ # @param title_text [String] text for the title of a dashboard panels section
25
+ # @param ccs_dashboard_panels_options [Hash] options that will be used in customising the HTML
26
+ #
27
+ # @option ccs_dashboard_panels_options [String] :classes additional CSS classes for the dashboard panels HTML
28
+ # @option ccs_dashboard_panels_options [String] :width (default: 'full') the width of the dashbaord panel section
29
+ # @option ccs_dashboard_panels_options [Hash] :attributes additional attributes that will added as part of the HTML
30
+ #
31
+ # @return [ActiveSupport::SafeBuffer] the HTML for the CCS Dashboard Panels
32
+ # which can then be rendered on the page
33
+
34
+ def ccs_dashboard_panels(panel_items, title_text = nil, **ccs_dashboard_panels_options)
35
+ initialise_attributes_and_set_classes(ccs_dashboard_panels_options, 'ccs-dashboard-panels')
36
+
37
+ tag.div(**ccs_dashboard_panels_options[:attributes]) do
38
+ tag.div(class: 'govuk-grid-row') do
39
+ tag.div(class: "govuk-grid-column-#{ccs_dashboard_panels_options[:width] || 'full'}") do
40
+ if title_text
41
+ concat(tag.h2(title_text, class: 'ccs-dashboard-panels__heading govuk-heading-m'))
42
+ concat(tag.hr(class: 'ccs-dashboard-panels__heading-section-break govuk-section-break govuk-section-break--visible'))
43
+ end
44
+ concat(tag.div(class: 'ccs-dashboard-panels__container') do
45
+ tag.div(class: 'govuk-grid-row') do
46
+ panel_items.each { |panel_item| concat(ccs_dashboard_panels_item(panel_item)) }
47
+ end
48
+ end)
49
+ end
50
+ end
51
+ end
52
+ end
53
+
54
+ private
55
+
56
+ # Generates the HTML for the a dashboard panel item in {ccs_dashboard_panels}
57
+ #
58
+ # @param panel_item [Hash] options for the dashboard panel item
59
+ #
60
+ # @option panel_item [String] :title the title for the dashboard panel
61
+ # @option panel_item [String] :href the href for the dashboard panel
62
+ # @option panel_item [String] :description the description text for the dashboard panel
63
+ # @option panel_item [String] :width (default: 'one-third') the width of the dashboard panel item
64
+ # @option panel_item [Hash] :attributes additional attributes that will added as part of the HTML
65
+ #
66
+ # @return [ActiveSupport::SafeBuffer] the HTML for a panel item in {ccs_dashboard_panels}
67
+
68
+ def ccs_dashboard_panels_item(panel_item)
69
+ (panel_item[:attributes] ||= {})[:class] = "ccs-dashboard-panels__item govuk-grid-column-#{panel_item[:width] || 'one-third'}"
70
+
71
+ tag.div(**panel_item[:attributes]) do
72
+ concat(link_to(panel_item[:title], panel_item[:href], class: 'ccs-dashboard-panels__item-title'))
73
+ concat(tag.p(panel_item[:description], class: 'ccs-dashboard-panels__item-description'))
74
+ end
75
+ end
76
+ end
77
+ end
78
+ end
79
+ end