consentful 0.1.0.pre1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +28 -0
  4. data/Rakefile +6 -0
  5. data/app/assets/stylesheets/consentful/application.css +15 -0
  6. data/app/assets/stylesheets/consentful/consent.scss +518 -0
  7. data/app/components/consentful/banner.html.erb +53 -0
  8. data/app/components/consentful/banner.rb +27 -0
  9. data/app/components/consentful/modal.html.erb +19 -0
  10. data/app/components/consentful/modal.rb +21 -0
  11. data/app/components/consentful/preferences.html.erb +167 -0
  12. data/app/components/consentful/preferences.rb +48 -0
  13. data/app/components/consentful/service_detail.html.erb +99 -0
  14. data/app/components/consentful/service_detail.rb +18 -0
  15. data/app/components/consentful/toggle.html.erb +30 -0
  16. data/app/components/consentful/toggle.rb +30 -0
  17. data/app/controllers/concerns/consentful/visitor_cookie.rb +52 -0
  18. data/app/controllers/consentful/admin/base_controller.rb +27 -0
  19. data/app/controllers/consentful/admin/categories_controller.rb +46 -0
  20. data/app/controllers/consentful/admin/copy_versions_controller.rb +113 -0
  21. data/app/controllers/consentful/admin/dashboard_controller.rb +11 -0
  22. data/app/controllers/consentful/admin/records_controller.rb +11 -0
  23. data/app/controllers/consentful/admin/services_controller.rb +80 -0
  24. data/app/controllers/consentful/application_controller.rb +9 -0
  25. data/app/controllers/consentful/consent_controller.rb +132 -0
  26. data/app/helpers/consentful/application_helper.rb +4 -0
  27. data/app/helpers/consentful/consent_helper.rb +23 -0
  28. data/app/javascript/consentful/controllers/banner_controller.js +92 -0
  29. data/app/javascript/consentful/controllers/clipboard_copy_controller.js +30 -0
  30. data/app/javascript/consentful/controllers/modal_controller.js +50 -0
  31. data/app/javascript/consentful/controllers/modal_trigger_controller.js +9 -0
  32. data/app/javascript/consentful/controllers/preferences_controller.js +182 -0
  33. data/app/javascript/consentful/index.js +42 -0
  34. data/app/javascript/consentful/state.js +91 -0
  35. data/app/jobs/consentful/application_job.rb +4 -0
  36. data/app/mailers/consentful/application_mailer.rb +6 -0
  37. data/app/models/consentful/application_record.rb +8 -0
  38. data/app/models/consentful/consent_category.rb +21 -0
  39. data/app/models/consentful/consent_copy_version.rb +49 -0
  40. data/app/models/consentful/consent_record.rb +33 -0
  41. data/app/models/consentful/consent_service.rb +38 -0
  42. data/app/models/consentful/consent_state.rb +80 -0
  43. data/app/models/consentful/consent_visitor_link.rb +26 -0
  44. data/app/presenters/consentful/consent_record_presenter.rb +73 -0
  45. data/app/services/consentful/dashboard_report.rb +45 -0
  46. data/app/services/consentful/sar_lookup.rb +47 -0
  47. data/app/views/consentful/admin/categories/edit.html.erb +22 -0
  48. data/app/views/consentful/admin/categories/index.html.erb +17 -0
  49. data/app/views/consentful/admin/copy_versions/_form.html.erb +34 -0
  50. data/app/views/consentful/admin/copy_versions/edit.html.erb +2 -0
  51. data/app/views/consentful/admin/copy_versions/index.html.erb +34 -0
  52. data/app/views/consentful/admin/copy_versions/new.html.erb +2 -0
  53. data/app/views/consentful/admin/copy_versions/show.html.erb +24 -0
  54. data/app/views/consentful/admin/dashboard/show.html.erb +35 -0
  55. data/app/views/consentful/admin/records/index.html.erb +35 -0
  56. data/app/views/consentful/admin/services/_form.html.erb +42 -0
  57. data/app/views/consentful/admin/services/edit.html.erb +2 -0
  58. data/app/views/consentful/admin/services/index.html.erb +27 -0
  59. data/app/views/consentful/admin/services/new.html.erb +2 -0
  60. data/app/views/consentful/consent/preferences.html.erb +14 -0
  61. data/app/views/layouts/consentful/admin.html.erb +66 -0
  62. data/app/views/layouts/consentful/application.html.erb +17 -0
  63. data/config/routes.rb +25 -0
  64. data/db/migrate/20260522100000_create_consent_categories.rb +19 -0
  65. data/db/migrate/20260522100100_create_consent_services.rb +38 -0
  66. data/db/migrate/20260522100200_create_consent_copy_versions.rb +30 -0
  67. data/db/migrate/20260522100300_create_consent_records.rb +22 -0
  68. data/db/migrate/20260522100400_create_consent_visitor_links.rb +21 -0
  69. data/lib/consentful/configuration.rb +100 -0
  70. data/lib/consentful/engine.rb +5 -0
  71. data/lib/consentful/seed_starter.rb +57 -0
  72. data/lib/consentful/version.rb +3 -0
  73. data/lib/consentful.rb +27 -0
  74. data/lib/generators/consentful/install_generator.rb +29 -0
  75. data/lib/generators/consentful/templates/consentful.rb +35 -0
  76. data/lib/tasks/consentful_tasks.rake +9 -0
  77. metadata +149 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: e13b7d585e3bdd7280ee42ce354366d2263a0b9196b9b339458665d70d3e1f87
4
+ data.tar.gz: 772a2b8441e450d903dc5ca606894ff1d0cb8f9a1704304dda9fb20c945d0185
5
+ SHA512:
6
+ metadata.gz: fd9ab07491ff571ee16a01d5fc5aa8690bce6947bebe9df090ef116239472dcc9d63c39d428642789bfcc298a4c6dc153e1c17722001a43761bcff3b6778b966
7
+ data.tar.gz: 55c54f81dd38c2036f561dcebc1699a43094deba9c20955a8c8555a5cffe0942ec520e4a583fd1f4c3247c650e4be1f312d19bfb30c870a11eff2fef56d84e4e
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright John Arnold
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,28 @@
1
+ # Consentful
2
+ Short description and motivation.
3
+
4
+ ## Usage
5
+ How to use my plugin.
6
+
7
+ ## Installation
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem "consentful"
12
+ ```
13
+
14
+ And then execute:
15
+ ```bash
16
+ $ bundle
17
+ ```
18
+
19
+ Or install it yourself as:
20
+ ```bash
21
+ $ gem install consentful
22
+ ```
23
+
24
+ ## Contributing
25
+ Contribution directions go here.
26
+
27
+ ## License
28
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/setup"
2
+
3
+ APP_RAKEFILE = File.expand_path("spec/dummy/Rakefile", __dir__)
4
+ load "rails/tasks/engine.rake"
5
+
6
+ require "bundler/gem_tasks"
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10
+ * files in this directory. Styles in this file should be added after the last require_* statement.
11
+ * It is generally better to create a new file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,518 @@
1
+ // Consentful — self-contained styles for the consent banner, modal and
2
+ // preference centre. Override any of the palette variables before importing
3
+ // (e.g. `@import "consentful/consent";`) to theme the widget to your brand.
4
+
5
+ $blue-dark: #002b49 !default;
6
+ $blue-light: #0481b7 !default;
7
+ $gold: #ac8c30 !default;
8
+ $gold-dark: #9a8340 !default;
9
+ $grey-49: #494949 !default;
10
+ $grey-8c: #8c8c8c !default;
11
+ $grey-ea: #eaeaea !default;
12
+ $grey-f2: #f2f2f2 !default;
13
+ $white: #ffffff !default;
14
+
15
+ .c-consent {
16
+ &__hidden {
17
+ display: none !important;
18
+ }
19
+ }
20
+
21
+ .c-consent-toggle {
22
+ display: inline-flex;
23
+ align-items: center;
24
+ gap: 0.5rem;
25
+ user-select: none;
26
+ cursor: pointer;
27
+
28
+ &--disabled {
29
+ cursor: not-allowed;
30
+ }
31
+
32
+ &__pill-wrap {
33
+ position: relative;
34
+ display: inline-block;
35
+ width: 2.75rem;
36
+ height: 1.5rem;
37
+ }
38
+
39
+ &__input {
40
+ position: absolute;
41
+ width: 1px;
42
+ height: 1px;
43
+ padding: 0;
44
+ margin: -1px;
45
+ overflow: hidden;
46
+ clip: rect(0, 0, 0, 0);
47
+ white-space: nowrap;
48
+ border: 0;
49
+ }
50
+
51
+ &__pill {
52
+ position: absolute;
53
+ inset: 0;
54
+ border-radius: 9999px;
55
+ background-color: $blue-dark;
56
+ transition: background-color 0.15s ease;
57
+ }
58
+
59
+ &__input:checked + &__pill {
60
+ background-color: $blue-light;
61
+ }
62
+
63
+ &__input:disabled + &__pill {
64
+ opacity: 0.6;
65
+ }
66
+
67
+ &__knob {
68
+ position: absolute;
69
+ top: 0.125rem;
70
+ left: 0.125rem;
71
+ width: 1.25rem;
72
+ height: 1.25rem;
73
+ border-radius: 9999px;
74
+ background-color: $white;
75
+ transition: transform 0.15s ease;
76
+ pointer-events: none;
77
+ }
78
+
79
+ &__input:checked ~ &__knob {
80
+ transform: translateX(1.25rem);
81
+ }
82
+
83
+ &__icon {
84
+ position: absolute;
85
+ top: 0.375rem;
86
+ width: 0.75rem;
87
+ height: 0.75rem;
88
+ pointer-events: none;
89
+
90
+ &--off {
91
+ left: 0.25rem;
92
+ color: $white;
93
+ }
94
+
95
+ &--on {
96
+ left: 1.5rem;
97
+ color: $blue-light;
98
+ display: none;
99
+ }
100
+ }
101
+
102
+ &__input:checked ~ &__icon--off {
103
+ display: none;
104
+ }
105
+
106
+ &__input:checked ~ &__icon--on {
107
+ display: inline;
108
+ }
109
+
110
+ &__label {
111
+ font-size: 0.875rem;
112
+ font-weight: 500;
113
+ color: $blue-dark;
114
+ }
115
+ }
116
+
117
+ .c-consent-banner {
118
+ position: fixed;
119
+ bottom: 0;
120
+ left: 0;
121
+ right: 0;
122
+ z-index: 1100;
123
+ background-color: $white;
124
+ border-top: 1px solid $grey-ea;
125
+ box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.1);
126
+
127
+ &__inner {
128
+ max-width: 1500px;
129
+ margin: 0 auto;
130
+ padding: 1rem 1.5rem;
131
+ display: flex;
132
+ flex-direction: column;
133
+ gap: 1rem;
134
+
135
+ @media (min-width: 1024px) {
136
+ flex-direction: row;
137
+ align-items: center;
138
+ }
139
+ }
140
+
141
+ &__text {
142
+ flex: 1;
143
+ min-width: 0;
144
+ }
145
+
146
+ &__title {
147
+ font-size: 1.125rem;
148
+ font-weight: 700;
149
+ color: $blue-dark;
150
+ margin-bottom: 0.25rem;
151
+ }
152
+
153
+ &__body {
154
+ font-size: 0.875rem;
155
+ color: $blue-dark;
156
+ margin-bottom: 0.75rem;
157
+ }
158
+
159
+ &__toggles {
160
+ display: flex;
161
+ flex-wrap: wrap;
162
+ align-items: center;
163
+ column-gap: 1.5rem;
164
+ row-gap: 0.5rem;
165
+ margin-bottom: 0.75rem;
166
+ }
167
+
168
+ &__link {
169
+ display: inline-block;
170
+ font-size: 0.875rem;
171
+ color: $blue-light;
172
+
173
+ &:hover {
174
+ text-decoration: underline;
175
+ }
176
+ }
177
+
178
+ &__actions {
179
+ display: flex;
180
+ flex-wrap: wrap;
181
+ gap: 0.5rem;
182
+ flex-shrink: 0;
183
+
184
+ @media (min-width: 1024px) {
185
+ flex-wrap: nowrap;
186
+ }
187
+ }
188
+ }
189
+
190
+ .c-consent-action {
191
+ padding: 0.75rem 1.5rem;
192
+ font-size: 0.875rem;
193
+ font-weight: 600;
194
+ color: $white;
195
+ background-color: $gold-dark;
196
+ border: 0;
197
+ border-radius: 0.25rem;
198
+ cursor: pointer;
199
+ transition: background-color 0.15s ease;
200
+
201
+ &:hover {
202
+ background-color: $gold;
203
+ }
204
+ }
205
+
206
+ .c-consent-modal {
207
+ position: fixed;
208
+ inset: 0;
209
+ z-index: 1200;
210
+ background-color: rgba(0, 0, 0, 0.6);
211
+ display: flex;
212
+ align-items: center;
213
+ justify-content: center;
214
+ padding: 1rem;
215
+
216
+ &__dialog {
217
+ width: 100%;
218
+ max-width: 768px;
219
+ }
220
+ }
221
+
222
+ .c-consent-preferences {
223
+ background-color: $white;
224
+ display: flex;
225
+ flex-direction: column;
226
+
227
+ &--modal {
228
+ border-radius: 0.5rem;
229
+ box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
230
+ overflow: hidden;
231
+ max-height: 90vh;
232
+ }
233
+
234
+ &--page {
235
+ min-height: 100vh;
236
+ }
237
+
238
+ &__header {
239
+ background-color: $blue-dark;
240
+ color: $white;
241
+ padding: 1rem 1.5rem;
242
+ display: flex;
243
+ align-items: center;
244
+ justify-content: space-between;
245
+ flex-shrink: 0;
246
+ }
247
+
248
+ &__header-title {
249
+ font-size: 1.125rem;
250
+ font-weight: 700;
251
+ }
252
+
253
+ &__close {
254
+ background: none;
255
+ border: 0;
256
+ color: $white;
257
+ cursor: pointer;
258
+ padding: 0.25rem;
259
+
260
+ &:hover {
261
+ opacity: 0.75;
262
+ }
263
+ }
264
+
265
+ &__body {
266
+ flex: 1;
267
+ min-height: 0;
268
+
269
+ .c-consent-preferences--modal & {
270
+ overflow-y: auto;
271
+ }
272
+ }
273
+
274
+ &__intro {
275
+ padding: 1.5rem 1.5rem 0.5rem;
276
+ }
277
+
278
+ &__page-title {
279
+ font-size: 1.5rem;
280
+ font-weight: 700;
281
+ color: $blue-dark;
282
+ margin-bottom: 1rem;
283
+ }
284
+
285
+ &__intro-body {
286
+ font-size: 0.875rem;
287
+ color: $blue-dark;
288
+ margin-bottom: 1rem;
289
+ }
290
+
291
+ &__tabs {
292
+ padding: 0 1.5rem;
293
+ border-bottom: 1px solid $grey-ea;
294
+ display: flex;
295
+ gap: 2rem;
296
+ }
297
+
298
+ &__tab {
299
+ padding: 0.75rem 0;
300
+ font-size: 0.875rem;
301
+ font-weight: 600;
302
+ color: $blue-dark;
303
+ background: none;
304
+ border: 0;
305
+ border-bottom: 2px solid transparent;
306
+ cursor: pointer;
307
+
308
+ &--active {
309
+ color: $blue-light;
310
+ border-bottom-color: $blue-light;
311
+ }
312
+
313
+ &:hover:not(&--active) {
314
+ color: $blue-light;
315
+ }
316
+ }
317
+
318
+ &__panel {
319
+ padding: 1rem 1.5rem;
320
+ display: flex;
321
+ flex-direction: column;
322
+ gap: 0.75rem;
323
+ }
324
+
325
+ &__reference {
326
+ padding: 0.75rem 1.5rem;
327
+ background-color: $grey-f2;
328
+ border-top: 1px solid $grey-ea;
329
+ font-size: 0.75rem;
330
+ color: $grey-49;
331
+ flex-shrink: 0;
332
+ }
333
+
334
+ &__reference-code {
335
+ color: $blue-dark;
336
+ font-family: SFMono-Regular, Menlo, Consolas, monospace;
337
+ }
338
+
339
+ &__copy-button {
340
+ margin-left: 0.5rem;
341
+ background: none;
342
+ border: 0;
343
+ color: $blue-light;
344
+ cursor: pointer;
345
+ font-size: inherit;
346
+
347
+ &:hover {
348
+ text-decoration: underline;
349
+ }
350
+ }
351
+
352
+ &__footer {
353
+ padding: 1rem 1.5rem;
354
+ border-top: 1px solid $grey-ea;
355
+ background-color: $white;
356
+ display: flex;
357
+ flex-wrap: wrap;
358
+ align-items: center;
359
+ justify-content: flex-end;
360
+ gap: 0.5rem;
361
+ flex-shrink: 0;
362
+ }
363
+ }
364
+
365
+ .c-consent-category {
366
+ border: 1px solid $grey-ea;
367
+ border-radius: 0.25rem;
368
+
369
+ &__header {
370
+ display: flex;
371
+ align-items: flex-start;
372
+ gap: 0.75rem;
373
+ padding: 1rem;
374
+ }
375
+
376
+ &__heading {
377
+ flex: 1;
378
+ min-width: 0;
379
+ }
380
+
381
+ &__title {
382
+ font-size: 1rem;
383
+ font-weight: 700;
384
+ color: $blue-dark;
385
+ }
386
+
387
+ &__blurb {
388
+ font-size: 0.875rem;
389
+ color: $grey-49;
390
+ margin-top: 0.25rem;
391
+ }
392
+
393
+ &__chevron {
394
+ padding: 0.25rem;
395
+ color: $blue-dark;
396
+ background: none;
397
+ border: 0;
398
+ cursor: pointer;
399
+
400
+ &:hover {
401
+ color: $blue-light;
402
+ }
403
+ }
404
+
405
+ &__body {
406
+ border-top: 1px solid $grey-ea;
407
+ }
408
+ }
409
+
410
+ .c-consent-service {
411
+ &__row {
412
+ display: flex;
413
+ align-items: center;
414
+ gap: 0.75rem;
415
+ padding: 0.5rem 1rem;
416
+ border-bottom: 1px solid $grey-ea;
417
+
418
+ &:last-child {
419
+ border-bottom: 0;
420
+ }
421
+ }
422
+
423
+ &__name {
424
+ flex: 1;
425
+ font-size: 0.875rem;
426
+ color: $blue-dark;
427
+ }
428
+
429
+ &__info {
430
+ background: none;
431
+ border: 0;
432
+ color: $grey-8c;
433
+ cursor: pointer;
434
+
435
+ &:hover {
436
+ color: $blue-light;
437
+ }
438
+ }
439
+
440
+ &__detail {
441
+ background-color: $grey-f2;
442
+ padding: 1rem 1.5rem;
443
+ font-size: 0.875rem;
444
+ color: $blue-dark;
445
+ }
446
+
447
+ &__detail-section {
448
+ margin-bottom: 0.75rem;
449
+
450
+ &:last-child {
451
+ margin-bottom: 0;
452
+ }
453
+ }
454
+
455
+ &__detail-label {
456
+ font-size: 0.75rem;
457
+ color: $grey-49;
458
+ margin-bottom: 0.25rem;
459
+ }
460
+
461
+ &__detail-value {
462
+ margin: 0;
463
+ }
464
+
465
+ &__detail-link {
466
+ color: $blue-light;
467
+
468
+ &:hover {
469
+ text-decoration: underline;
470
+ }
471
+ }
472
+
473
+ &__chips {
474
+ display: flex;
475
+ flex-wrap: wrap;
476
+ gap: 0.25rem;
477
+ }
478
+
479
+ &__chip {
480
+ display: inline-block;
481
+ padding: 0.25rem 0.5rem;
482
+ border: 1px solid $grey-ea;
483
+ border-radius: 0.25rem;
484
+ font-size: 0.75rem;
485
+
486
+ &--mono {
487
+ font-family: SFMono-Regular, Menlo, Consolas, monospace;
488
+ }
489
+ }
490
+ }
491
+
492
+ .c-consent-services-card {
493
+ border: 1px solid $grey-ea;
494
+ border-radius: 0.25rem;
495
+
496
+ &__header {
497
+ display: flex;
498
+ align-items: center;
499
+ gap: 0.75rem;
500
+ padding: 1rem;
501
+ }
502
+
503
+ &__heading {
504
+ flex: 1;
505
+ min-width: 0;
506
+ }
507
+
508
+ &__name {
509
+ font-size: 1rem;
510
+ font-weight: 700;
511
+ color: $blue-dark;
512
+ }
513
+
514
+ &__category {
515
+ font-size: 0.75rem;
516
+ color: $grey-49;
517
+ }
518
+ }
@@ -0,0 +1,53 @@
1
+ <div
2
+ data-controller="consentful--banner"
3
+ data-consentful--banner-expected-version-id-value="<%= version.id %>"
4
+ data-consentful--banner-submit-path-value="<%= submit_path %>"
5
+ data-consentful--banner-categories-value="<%= category_data.to_json %>"
6
+ class="c-consent-banner c-consent__hidden"
7
+ >
8
+ <div class="c-consent-banner__inner">
9
+ <div class="c-consent-banner__text">
10
+ <h2 class="c-consent-banner__title"><%= version.banner_title %></h2>
11
+ <p class="c-consent-banner__body"><%= version.banner_body %></p>
12
+
13
+ <div class="c-consent-banner__toggles">
14
+ <% categories.each do |category| %>
15
+ <%= render Consentful::Toggle.new(
16
+ id_scope: "banner",
17
+ name: "categories[#{category.key}]",
18
+ value: "true",
19
+ checked: category.required?,
20
+ disabled: category.required?,
21
+ label: category.name,
22
+ label_position: :left,
23
+ data: {
24
+ "consentful--banner-target": "categoryToggle",
25
+ "category-key": category.key
26
+ }
27
+ ) %>
28
+ <% end %>
29
+ </div>
30
+
31
+ <%= link_to version.manage_label.presence || "More Information",
32
+ preferences_path,
33
+ class: "c-consent-banner__link",
34
+ data: {
35
+ "consentful--banner-target": "manageLink",
36
+ controller: "consentful--modal-trigger",
37
+ action: "click->consentful--modal-trigger#open"
38
+ } %>
39
+ </div>
40
+
41
+ <div class="c-consent-banner__actions">
42
+ <button type="button" data-action="consentful--banner#save" class="c-consent-action">
43
+ <%= version.save_label.presence || "Save Settings" %>
44
+ </button>
45
+ <button type="button" data-action="consentful--banner#reject" class="c-consent-action">
46
+ <%= version.reject_label.presence || "Deny" %>
47
+ </button>
48
+ <button type="button" data-action="consentful--banner#accept" class="c-consent-action">
49
+ <%= version.accept_label.presence || "Accept All" %>
50
+ </button>
51
+ </div>
52
+ </div>
53
+ </div>
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Consentful
4
+ class Banner < ViewComponent::Base
5
+ def initialize(version:, categories:, preferences_path:, submit_path:)
6
+ super()
7
+ @version = version
8
+ @categories = categories
9
+ @preferences_path = preferences_path
10
+ @submit_path = submit_path
11
+ end
12
+
13
+ def render?
14
+ @version.present?
15
+ end
16
+
17
+ private
18
+
19
+ attr_reader :version, :categories, :preferences_path, :submit_path
20
+
21
+ def category_data
22
+ categories.map do |category|
23
+ { key: category.key, name: category.name, required: category.required? }
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,19 @@
1
+ <div
2
+ id="consent-modal-root"
3
+ data-controller="consentful--modal"
4
+ data-action="click->consentful--modal#closeFromBackdrop"
5
+ class="c-consent-modal c-consent__hidden"
6
+ role="dialog"
7
+ aria-modal="true"
8
+ aria-labelledby="consent-modal-title"
9
+ >
10
+ <div class="c-consent-modal__dialog" data-consentful--modal-target="dialog">
11
+ <%= render Consentful::Preferences.new(
12
+ version: version,
13
+ categories: categories,
14
+ visitor_uuid: visitor_uuid,
15
+ submit_path: submit_path,
16
+ variant: :modal
17
+ ) %>
18
+ </div>
19
+ </div>
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Consentful
4
+ class Modal < ViewComponent::Base
5
+ def initialize(version:, categories:, visitor_uuid:, submit_path:)
6
+ super()
7
+ @version = version
8
+ @categories = categories
9
+ @visitor_uuid = visitor_uuid
10
+ @submit_path = submit_path
11
+ end
12
+
13
+ def render?
14
+ @version.present?
15
+ end
16
+
17
+ private
18
+
19
+ attr_reader :version, :categories, :visitor_uuid, :submit_path
20
+ end
21
+ end