govuk_publishing_components 63.3.1 → 64.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.
Files changed (119) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-form-tracker.js +2 -0
  3. data/app/assets/javascripts/govuk_publishing_components/components/cookie-banner.js +8 -34
  4. data/app/assets/javascripts/govuk_publishing_components/dependencies.js +1 -1
  5. data/app/assets/javascripts/govuk_publishing_components/domain-config.js +5 -10
  6. data/app/assets/javascripts/govuk_publishing_components/lib/cookie-settings.js +4 -15
  7. data/app/controllers/govuk_publishing_components/application_controller.rb +0 -5
  8. data/app/models/govuk_publishing_components/audit_applications.rb +0 -4
  9. data/app/models/govuk_publishing_components/audit_comparer.rb +1 -4
  10. data/app/views/govuk_publishing_components/applications_page/show.html.erb +0 -1
  11. data/app/views/govuk_publishing_components/audit/_applications.html.erb +0 -8
  12. data/app/views/govuk_publishing_components/audit/show.html.erb +1 -6
  13. data/app/views/govuk_publishing_components/component_guide/example.html.erb +1 -1
  14. data/app/views/govuk_publishing_components/component_guide/preview.html.erb +1 -1
  15. data/app/views/govuk_publishing_components/component_guide/show.html.erb +1 -1
  16. data/app/views/govuk_publishing_components/components/_accordion.html.erb +0 -2
  17. data/app/views/govuk_publishing_components/components/_action_link.html.erb +0 -2
  18. data/app/views/govuk_publishing_components/components/_add_another.html.erb +0 -1
  19. data/app/views/govuk_publishing_components/components/_app_promo_banner.html.erb +0 -2
  20. data/app/views/govuk_publishing_components/components/_attachment.html.erb +0 -2
  21. data/app/views/govuk_publishing_components/components/_attachment_link.html.erb +0 -2
  22. data/app/views/govuk_publishing_components/components/_back_link.html.erb +0 -2
  23. data/app/views/govuk_publishing_components/components/_back_to_top_link.html.erb +0 -2
  24. data/app/views/govuk_publishing_components/components/_big_number.html.erb +0 -2
  25. data/app/views/govuk_publishing_components/components/_breadcrumbs.html.erb +0 -2
  26. data/app/views/govuk_publishing_components/components/_button.html.erb +0 -1
  27. data/app/views/govuk_publishing_components/components/_cards.html.erb +0 -1
  28. data/app/views/govuk_publishing_components/components/_character_count.html.erb +0 -3
  29. data/app/views/govuk_publishing_components/components/_checkboxes.html.erb +0 -1
  30. data/app/views/govuk_publishing_components/components/_contents_list.html.erb +0 -2
  31. data/app/views/govuk_publishing_components/components/_contents_list_with_body.html.erb +0 -1
  32. data/app/views/govuk_publishing_components/components/_contextual_guidance.html.erb +0 -2
  33. data/app/views/govuk_publishing_components/components/_contextual_sidebar.html.erb +0 -2
  34. data/app/views/govuk_publishing_components/components/_cookie_banner.html.erb +0 -2
  35. data/app/views/govuk_publishing_components/components/_cross_service_header.html.erb +0 -2
  36. data/app/views/govuk_publishing_components/components/_date_input.html.erb +0 -2
  37. data/app/views/govuk_publishing_components/components/_details.html.erb +0 -2
  38. data/app/views/govuk_publishing_components/components/_devolved_nations.html.erb +0 -2
  39. data/app/views/govuk_publishing_components/components/_document_list.html.erb +0 -2
  40. data/app/views/govuk_publishing_components/components/_emergency_banner.html.erb +0 -2
  41. data/app/views/govuk_publishing_components/components/_error_alert.html.erb +0 -2
  42. data/app/views/govuk_publishing_components/components/_error_message.html.erb +0 -2
  43. data/app/views/govuk_publishing_components/components/_error_summary.html.erb +0 -2
  44. data/app/views/govuk_publishing_components/components/_feedback.html.erb +0 -3
  45. data/app/views/govuk_publishing_components/components/_fieldset.html.erb +0 -2
  46. data/app/views/govuk_publishing_components/components/_figure.html.erb +0 -1
  47. data/app/views/govuk_publishing_components/components/_file_upload.html.erb +0 -3
  48. data/app/views/govuk_publishing_components/components/_glance_metric.html.erb +0 -2
  49. data/app/views/govuk_publishing_components/components/_global_banner.html.erb +0 -2
  50. data/app/views/govuk_publishing_components/components/_govspeak.html.erb +0 -5
  51. data/app/views/govuk_publishing_components/components/_govspeak_html_publication.html.erb +0 -2
  52. data/app/views/govuk_publishing_components/components/_heading.html.erb +0 -2
  53. data/app/views/govuk_publishing_components/components/_hint.html.erb +0 -2
  54. data/app/views/govuk_publishing_components/components/_image_card.html.erb +0 -2
  55. data/app/views/govuk_publishing_components/components/_input.html.erb +0 -2
  56. data/app/views/govuk_publishing_components/components/_inset_text.html.erb +0 -2
  57. data/app/views/govuk_publishing_components/components/_intervention.html.erb +0 -2
  58. data/app/views/govuk_publishing_components/components/_inverse_header.html.erb +0 -2
  59. data/app/views/govuk_publishing_components/components/_label.html.erb +0 -2
  60. data/app/views/govuk_publishing_components/components/_layout_footer.html.erb +0 -2
  61. data/app/views/govuk_publishing_components/components/_layout_for_admin.html.erb +0 -1
  62. data/app/views/govuk_publishing_components/components/_layout_for_public.html.erb +0 -2
  63. data/app/views/govuk_publishing_components/components/_layout_header.html.erb +0 -2
  64. data/app/views/govuk_publishing_components/components/_layout_super_navigation_header.html.erb +0 -2
  65. data/app/views/govuk_publishing_components/components/_lead_paragraph.html.erb +0 -2
  66. data/app/views/govuk_publishing_components/components/_metadata.html.erb +0 -2
  67. data/app/views/govuk_publishing_components/components/_modal_dialogue.html.erb +0 -2
  68. data/app/views/govuk_publishing_components/components/_notice.html.erb +0 -2
  69. data/app/views/govuk_publishing_components/components/_option_select.html.erb +0 -3
  70. data/app/views/govuk_publishing_components/components/_organisation_logo.html.erb +0 -2
  71. data/app/views/govuk_publishing_components/components/_pagination.html.erb +0 -1
  72. data/app/views/govuk_publishing_components/components/_panel.html.erb +0 -2
  73. data/app/views/govuk_publishing_components/components/_password_input.html.erb +0 -2
  74. data/app/views/govuk_publishing_components/components/_phase_banner.html.erb +0 -2
  75. data/app/views/govuk_publishing_components/components/_print_link.html.erb +0 -2
  76. data/app/views/govuk_publishing_components/components/_published_dates.html.erb +0 -2
  77. data/app/views/govuk_publishing_components/components/_radio.html.erb +0 -3
  78. data/app/views/govuk_publishing_components/components/_related_navigation.html.erb +0 -2
  79. data/app/views/govuk_publishing_components/components/_reorderable_list.html.erb +0 -2
  80. data/app/views/govuk_publishing_components/components/_search.html.erb +0 -3
  81. data/app/views/govuk_publishing_components/components/_search_with_autocomplete.html.erb +0 -2
  82. data/app/views/govuk_publishing_components/components/_secondary_navigation.html.erb +0 -2
  83. data/app/views/govuk_publishing_components/components/_select.html.erb +0 -2
  84. data/app/views/govuk_publishing_components/components/_select_with_search.html.erb +0 -2
  85. data/app/views/govuk_publishing_components/components/_service_navigation.html.erb +0 -2
  86. data/app/views/govuk_publishing_components/components/_share_links.html.erb +0 -2
  87. data/app/views/govuk_publishing_components/components/_signup_link.html.erb +0 -2
  88. data/app/views/govuk_publishing_components/components/_single_page_notification_button.html.erb +0 -2
  89. data/app/views/govuk_publishing_components/components/_skip_link.html.erb +0 -2
  90. data/app/views/govuk_publishing_components/components/_step_by_step_nav.html.erb +0 -2
  91. data/app/views/govuk_publishing_components/components/_step_by_step_nav_header.html.erb +0 -2
  92. data/app/views/govuk_publishing_components/components/_step_by_step_nav_related.html.erb +0 -1
  93. data/app/views/govuk_publishing_components/components/_subscription_links.html.erb +0 -2
  94. data/app/views/govuk_publishing_components/components/_success_alert.html.erb +0 -2
  95. data/app/views/govuk_publishing_components/components/_summary_banner.html.erb +0 -2
  96. data/app/views/govuk_publishing_components/components/_summary_card.html.erb +0 -2
  97. data/app/views/govuk_publishing_components/components/_summary_list.html.erb +0 -2
  98. data/app/views/govuk_publishing_components/components/_table.html.erb +0 -2
  99. data/app/views/govuk_publishing_components/components/_tabs.html.erb +0 -2
  100. data/app/views/govuk_publishing_components/components/_tag.html.erb +0 -2
  101. data/app/views/govuk_publishing_components/components/_textarea.html.erb +0 -2
  102. data/app/views/govuk_publishing_components/components/_translation_nav.html.erb +0 -2
  103. data/app/views/govuk_publishing_components/components/_warning_text.html.erb +0 -2
  104. data/app/views/govuk_publishing_components/components/docs/govspeak_html_publication.yml +0 -2
  105. data/app/views/govuk_publishing_components/components/docs/organisation_logo.yml +4 -7
  106. data/lib/govuk_publishing_components/config.rb +0 -6
  107. data/lib/govuk_publishing_components/presenters/meta_tags.rb +0 -2
  108. data/lib/govuk_publishing_components/presenters/organisation_logo_helper.rb +11 -13
  109. data/lib/govuk_publishing_components/version.rb +1 -1
  110. data/lib/govuk_publishing_components.rb +0 -5
  111. metadata +1 -9
  112. data/app/assets/javascripts/govuk_publishing_components/single-consent-functions.js +0 -59
  113. data/lib/govuk_publishing_components/app_helpers/asset_helper.rb +0 -78
  114. data/node_modules/govuk-single-consent/README.md +0 -157
  115. data/node_modules/govuk-single-consent/dist/singleconsent.cjs.js +0 -419
  116. data/node_modules/govuk-single-consent/dist/singleconsent.esm.js +0 -417
  117. data/node_modules/govuk-single-consent/dist/singleconsent.iife.js +0 -431
  118. data/node_modules/govuk-single-consent/dist/singleconsent.iife.min.js +0 -1
  119. data/node_modules/govuk-single-consent/package.json +0 -56
@@ -1,59 +0,0 @@
1
- /* global GovSingleConsent */
2
- // = require govuk-single-consent/dist/singleconsent.iife.js
3
-
4
- (function (root) {
5
- 'use strict'
6
- window.GOVUK = window.GOVUK || {}
7
-
8
- window.GOVUK.singleConsent = {
9
- init: function (callback) {
10
- if (!window.GOVUK.useSingleConsentApi) {
11
- return
12
- }
13
- callback = callback || this.apiCallback
14
- // determine where we are and set the consent api URL accordingly
15
- if (!this.url) {
16
- this.url = 'staging'
17
- var environment = window.GOVUK.loadAnalytics.getEnvironment(window.GOVUK.analyticsGa4.core.trackFunctions.getHostname())
18
- if (environment) {
19
- this.url = environment.consentApiUrl
20
- }
21
- }
22
- // create the consent API object
23
- this.consentApiObj = new GovSingleConsent(callback, this.url)
24
- },
25
-
26
- apiCallback: function (consents, consentsPreferencesSet, error) {
27
- if (error) {
28
- console.error('Single consent error: ', error, window.location)
29
- return
30
- }
31
- if (consentsPreferencesSet) {
32
- if (consents && consents.usage) {
33
- window.GOVUK.triggerEvent(window, 'cookie-consent')
34
- }
35
- } else {
36
- window.GOVUK.triggerEvent(window, 'show-cookie-banner')
37
- }
38
- },
39
-
40
- setPreferences: function (type, options) {
41
- if (window.GOVUK.useSingleConsentApi) {
42
- try {
43
- switch (type) {
44
- case 'accept':
45
- this.consentApiObj.setConsents(GovSingleConsent.ACCEPT_ALL)
46
- break
47
- case 'reject':
48
- this.consentApiObj.setConsents(GovSingleConsent.REJECT_ALL)
49
- break
50
- default:
51
- this.consentApiObj.setConsents(options)
52
- }
53
- } catch (e) {
54
- console.error('Single consent ' + type + ' error: ', e, window.location)
55
- }
56
- }
57
- }
58
- }
59
- }(window))
@@ -1,78 +0,0 @@
1
- module GovukPublishingComponents
2
- module AppHelpers
3
- module AssetHelper
4
- # This is a list of all the components that have stylesheets - so a new
5
- # component needs to be added to this list rather than being laboriously
6
- # added and removed from every single rendering application.
7
- COMPONENT_CSS_PATHS = Dir.glob("#{GovukPublishingComponents::Config.gem_directory}/app/assets/stylesheets/govuk_publishing_components/components/_*.scss").map { |path|
8
- filename = path.split("/").last
9
- component_name = filename.sub("_", "").sub(".scss", "")
10
- "govuk_publishing_components/components/_#{component_name}.css"
11
- }.freeze
12
-
13
- def add_stylesheet_path(component_path)
14
- unless is_already_used?(component_path)
15
- all_component_stylesheets_being_used << component_path
16
- end
17
- end
18
-
19
- # Used to add a component that exists in the gem to the list
20
- def add_gem_component_stylesheet(gem_component)
21
- add_stylesheet_path("govuk_publishing_components/components/_#{gem_component}.css")
22
- end
23
-
24
- # Used to add a component that exists in the application to the list
25
- def add_app_component_stylesheet(app_component)
26
- add_stylesheet_path("components/_#{app_component}.css")
27
- end
28
-
29
- # Some applications have view-specific stylesheets - use this method
30
- # to add them to the list
31
- def add_view_stylesheet(view_component)
32
- add_stylesheet_path("views/_#{view_component}.css")
33
- end
34
-
35
- def all_component_stylesheets_being_used
36
- @all_component_stylesheets_being_used ||= []
37
- end
38
-
39
- def render_component_stylesheets
40
- list_of_stylesheets = all_component_stylesheets_being_used.map do |component|
41
- stylesheet_link_tag(component, integrity: false)
42
- end
43
- raw(list_of_stylesheets.join(""))
44
- end
45
-
46
- def get_component_css_paths
47
- COMPONENT_CSS_PATHS
48
- end
49
-
50
- def application_stylesheet_in_use?
51
- GovukPublishingComponents::Config.application_stylesheet.presence
52
- end
53
-
54
- private
55
-
56
- def is_already_used?(component)
57
- (all_component_stylesheets_being_used + component_paths(css_exclude_list)).include?(component)
58
- end
59
-
60
- def css_exclude_list
61
- return [] if viewing_component_guide?
62
- return GovukPublishingComponents::Config.custom_css_exclude_list if GovukPublishingComponents::Config.custom_css_exclude_list&.any?
63
-
64
- []
65
- end
66
-
67
- def viewing_component_guide?
68
- return false unless request
69
-
70
- request.path.include?("/component-guide")
71
- end
72
-
73
- def component_paths(component_list)
74
- component_list.map { |c| "govuk_publishing_components/components/_#{c}.css" }
75
- end
76
- end
77
- end
78
- end
@@ -1,157 +0,0 @@
1
- # Single Consent client
2
-
3
- The Single Consent client is a small Javascript which can be embedded in a
4
- website to enable easily sharing a user's consent or rejection of cookies across
5
- different websites.
6
-
7
- See the [Single Consent service README](../README.md).
8
-
9
- ## Quick start
10
-
11
- See the [CommonJS example](https://github.com/alphagov/consent-api/blob/main/client/examples/commonJS-usage/index.js).
12
-
13
- Contact data-tools-team@digital.cabinet-office.gov.uk to get the URL of the API endpoint.
14
-
15
- The library provides the following static methods for finding out which types of
16
- cookies a user has consented to.
17
-
18
- - `hasConsentedToEssential`
19
- - `hasConsentedToUsage`
20
- - `hasConsentedToCampaigns`
21
- - `hasConsentedToSetting`
22
-
23
- The method `GovSingleConsent.getConsents()` provides the current state of the
24
- user's consents to all types of cookies.
25
-
26
- ### 1. Install with npm
27
-
28
- In order to set first-party cookies, the client Javascript must be served with
29
- your application.
30
-
31
- We recommend installing the Single Consent client using
32
- [node package manager (npm)](https://www.npmjs.com/).
33
-
34
- ```sh
35
- npm i govuk-single-consent
36
- ```
37
-
38
- https://www.npmjs.com/package/govuk-single-consent
39
-
40
- ### 2. Including the Javascript client
41
-
42
- The javascript client can be included in different ways. Choose one below.
43
-
44
- #### CommonJS
45
-
46
- See the [example](https://github.com/alphagov/consent-api/blob/main/client/examples/commonJS-usage/index.js).
47
-
48
- #### Typescript
49
-
50
- See the [example](https://github.com/alphagov/consent-api/blob/main/client/examples/typescript-usage/index.ts).
51
-
52
- #### HTML script tag (IIFE)
53
-
54
- The javascript client makes available the object `window.GovSingleConsent` for
55
- interacting with the API. It needs to be loaded on any page that could be an
56
- entry point to your web application, that allows modifying cookie consent, or
57
- provides a link to another domain with which you want to share cookie consent
58
- status. It is probably easiest to add the script to a base template used for all
59
- pages.
60
-
61
- On the same pages, you need to load your javascript for interacting with the
62
- `window.GovSingleConsent` object.
63
-
64
- See the following examples.
65
-
66
- - [Cookie banner script](https://github.com/alphagov/consent-api/blob/main/client/example/cookie-banner.js)
67
- - [Cooke page script](https://github.com/alphagov/consent-api/blob/main/client/example/cookies-page.js)
68
-
69
- It is common practice to add Javascript tags just before the end `</body>` tag,
70
- eg:
71
-
72
- ```html
73
- ...
74
-
75
- <script src="{path_to_client_js}/singleconsent.js"></script>
76
- <script src="{path_to_cookie_banner_script}.js"></script>
77
- <script src="{path_to_cookies_page_script}.js"></script>
78
- </body>
79
- </html>
80
- ```
81
-
82
- ### 3. Passing the base URL to the constructor
83
-
84
- You can either pass an environment string, or a custom base URL.
85
-
86
- If using an environment string, its value should be either `staging` or `production`.
87
-
88
- e.g
89
-
90
- ```javascript
91
- const dummyCallback = () => {}
92
-
93
- // With an environemnt string to the staging environment
94
- new GovSingleConsent(dummyCallback, 'staging')
95
-
96
- // With an environemnt string to the production environment
97
- new GovSingleConsent(dummyCallback, 'production')
98
-
99
- // With a custom base URL
100
- new GovSingleConsent(dummyCallback, 'http://some-development-url.com')
101
- ```
102
-
103
- ### 4. Share the user's consent to cookies via the API
104
-
105
- When the user interacts with your cookie banner or cookie settings page to
106
- consent to or reject cookies you can update the central database by invoking the
107
- following function:
108
-
109
- ```typescript
110
- exampleCookieConsentStatusObject: Consents = {
111
- essential: true,
112
- settings: false,
113
- usage: true,
114
- campaigns: false,
115
- }
116
-
117
- singleConsentObject.setConsents(exampleCookieConsentStatusObject)
118
- ```
119
-
120
- ## Content Security Policy
121
-
122
- If your website is served with a
123
- [`Content-Security-Policy` HTTP header or `<meta>` element](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP), you
124
- may need to modify it to allow the client to access the Single Consent service.
125
- The value of the header or meta element should contain the following:
126
-
127
- ```
128
- connect-src 'self' https://consent-api-nw.a.run.app/api/v1/consent [... other site URLs separated by spaces];
129
- ```
130
-
131
- ## What the library does
132
-
133
- The library manages all read/write operations with a cookie that stores the
134
- state of a user's consent.
135
-
136
- ### Callback
137
-
138
- Websites using the Consent API must provide a callback function. This will be
139
- invoked each time the consent has been updated. It will be called with three
140
- parameters:
141
-
142
- - `consents` An object describing the new consent state.
143
- - `consentsPreferencesSet` Boolean, the cookie banner must be displayed if this
144
- value is `false`.
145
- - `error` An object describing any error, otherwise `null`. If there is an
146
- error, then the `consents` object will say that the consents have been
147
- revoked.
148
-
149
- The structure of the consent data object is currently based on the
150
- [GOV.UK `cookies_policy` cookie](https://www.gov.uk/help/cookies). If your
151
- website cookies do not fall into any of the four categories listed, please
152
- contact us.
153
-
154
- ## Getting updates
155
-
156
- To be notified when there's a new release, you can watch the
157
- [consent-api Github repository](https://github.com/alphagov/consent-api).