govuk_publishing_components 21.68.1 → 23.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/images/govuk_publishing_components/action-link-arrow--simple-light.png +0 -0
  3. data/app/assets/images/govuk_publishing_components/action-link-arrow--simple-light.svg +4 -0
  4. data/app/assets/javascripts/govuk_publishing_components/analytics.js +16 -0
  5. data/app/assets/javascripts/govuk_publishing_components/analytics/analytics.js +85 -0
  6. data/app/assets/javascripts/govuk_publishing_components/analytics/auto-track-event.js +30 -0
  7. data/app/assets/javascripts/govuk_publishing_components/analytics/custom-dimensions.js +120 -0
  8. data/app/assets/javascripts/govuk_publishing_components/analytics/download-link-tracker.js +41 -0
  9. data/app/assets/javascripts/govuk_publishing_components/analytics/ecommerce.js +101 -0
  10. data/app/assets/javascripts/govuk_publishing_components/analytics/error-tracking.js +51 -0
  11. data/app/assets/javascripts/govuk_publishing_components/analytics/external-link-tracker.js +56 -0
  12. data/app/assets/javascripts/govuk_publishing_components/analytics/google-analytics-universal-tracker.js +198 -0
  13. data/app/assets/javascripts/govuk_publishing_components/analytics/init.js +48 -0
  14. data/app/assets/javascripts/govuk_publishing_components/analytics/mailto-link-tracker.js +38 -0
  15. data/app/assets/javascripts/govuk_publishing_components/analytics/page-content.js +129 -0
  16. data/app/assets/javascripts/govuk_publishing_components/analytics/pii.js +74 -0
  17. data/app/assets/javascripts/govuk_publishing_components/analytics/print-intent.js +39 -0
  18. data/app/assets/javascripts/govuk_publishing_components/analytics/scroll-tracker.js +513 -0
  19. data/app/assets/javascripts/govuk_publishing_components/analytics/static-analytics.js +132 -0
  20. data/app/assets/javascripts/govuk_publishing_components/lib/track-click.js +61 -0
  21. data/app/assets/stylesheets/govuk_publishing_components/components/_action-link.scss +20 -10
  22. data/app/assets/stylesheets/govuk_publishing_components/components/_layout-header.scss +5 -0
  23. data/app/assets/stylesheets/govuk_publishing_components/components/_print-link.scss +23 -20
  24. data/app/assets/stylesheets/govuk_publishing_components/components/_search.scss +7 -1
  25. data/app/assets/stylesheets/govuk_publishing_components/components/_subscription-links.scss +1 -1
  26. data/app/assets/stylesheets/govuk_publishing_components/components/print/_govspeak.scss +4 -0
  27. data/app/views/govuk_publishing_components/components/_action_link.html.erb +2 -0
  28. data/app/views/govuk_publishing_components/components/_contents_list.html.erb +8 -13
  29. data/app/views/govuk_publishing_components/components/_govspeak.html.erb +8 -12
  30. data/app/views/govuk_publishing_components/components/_input.html.erb +17 -4
  31. data/app/views/govuk_publishing_components/components/_layout_for_public.html.erb +0 -1
  32. data/app/views/govuk_publishing_components/components/_layout_header.html.erb +6 -5
  33. data/app/views/govuk_publishing_components/components/_panel.html.erb +5 -2
  34. data/app/views/govuk_publishing_components/components/_print_link.html.erb +26 -11
  35. data/app/views/govuk_publishing_components/components/docs/action_link.yml +8 -0
  36. data/app/views/govuk_publishing_components/components/docs/contents_list.yml +0 -37
  37. data/app/views/govuk_publishing_components/components/docs/govspeak.yml +1 -6
  38. data/app/views/govuk_publishing_components/components/docs/input.yml +7 -3
  39. data/app/views/govuk_publishing_components/components/docs/layout_header.yml +0 -3
  40. data/app/views/govuk_publishing_components/components/docs/panel.yml +4 -0
  41. data/app/views/govuk_publishing_components/components/docs/print_link.yml +5 -0
  42. data/app/views/govuk_publishing_components/components/layout_header/_header_logo.html.erb +3 -1
  43. data/config/initializers/assets.rb +1 -0
  44. data/config/locales/et.yml +4 -0
  45. data/config/locales/fr.yml +4 -0
  46. data/lib/govuk_publishing_components/version.rb +1 -1
  47. metadata +23 -2
@@ -0,0 +1,132 @@
1
+ /* global GOVUK, $, ga */
2
+
3
+ (function () {
4
+ 'use strict'
5
+ window.GOVUK = window.GOVUK || {}
6
+ var StaticAnalytics = function (config) {
7
+ // Create universal tracker
8
+ // https://github.com/alphagov/govuk_frontend_toolkit/blob/master/docs/analytics.md
9
+ // https://github.com/alphagov/govuk_frontend_toolkit/blob/master/javascripts/govuk/analytics/analytics.js
10
+ var consentCookie = window.GOVUK.getConsentCookie()
11
+
12
+ if (!consentCookie || consentCookie.usage) {
13
+ this.analytics = new GOVUK.Analytics(config)
14
+ }
15
+
16
+ var trackingOptions = getOptionsFromCookie()
17
+
18
+ // We're setting the client ID inside a callback function because
19
+ // we don't have access to the client ID until GA returns a tracker object.
20
+ ga(function (tracker) {
21
+ this.gaClientId = tracker.get('clientId')
22
+
23
+ $(window).trigger('gaClientSet')
24
+
25
+ // Start up ecommerce tracking
26
+ GOVUK.Ecommerce.start()
27
+
28
+ // Track initial pageview
29
+ this.trackPageview(null, null, trackingOptions)
30
+
31
+ // Begin error and print tracking
32
+ GOVUK.analyticsPlugins.error({ filenameMustMatch: /gov\.uk/ })
33
+ GOVUK.analyticsPlugins.printIntent()
34
+ GOVUK.analyticsPlugins.mailtoLinkTracker()
35
+ GOVUK.analyticsPlugins.externalLinkTracker({
36
+ externalLinkUploadCustomDimension: 36
37
+ })
38
+ GOVUK.analyticsPlugins.downloadLinkTracker({
39
+ selector: 'a[href*="/government/uploads"], a[href*="assets.publishing.service.gov.uk"]'
40
+ })
41
+ }.bind(this))
42
+ }
43
+
44
+ StaticAnalytics.load = function () {
45
+ GOVUK.Analytics.load()
46
+ }
47
+
48
+ StaticAnalytics.prototype.trackPageview = function (path, title, options) {
49
+ // Add the cookie banner status as a custom dimension
50
+ var cookieBannerShown = !this.getCookie('seen_cookie_message')
51
+ var cookieBannerDimension = { dimension100: cookieBannerShown ? cookieBannerShown.toString() : 'false' }
52
+ $.extend(options, cookieBannerDimension)
53
+
54
+ var trackingOptions = GOVUK.CustomDimensions.getAndExtendDefaultTrackingOptions(options)
55
+ this.analytics.trackPageview(path, title, trackingOptions)
56
+ }
57
+
58
+ StaticAnalytics.prototype.trackEvent = function (category, action, options) {
59
+ var trackingOptions = GOVUK.CustomDimensions.getAndExtendDefaultTrackingOptions(options)
60
+ this.analytics.trackEvent(category, action, trackingOptions)
61
+ }
62
+
63
+ StaticAnalytics.prototype.setDimension = function (index, value, name, scope) {
64
+ if (typeof value === 'undefined') {
65
+ return
66
+ }
67
+ this.analytics.setDimension(index, value, name, scope)
68
+ }
69
+
70
+ StaticAnalytics.prototype.trackShare = function (network) {
71
+ var trackingOptions = GOVUK.CustomDimensions.getAndExtendDefaultTrackingOptions()
72
+ this.analytics.trackShare(network, trackingOptions)
73
+ }
74
+
75
+ StaticAnalytics.prototype.addLinkedTrackerDomain = function (trackerId, name, domain, sendPageView) {
76
+ this.analytics.addLinkedTrackerDomain(trackerId, name, domain, sendPageView)
77
+ }
78
+
79
+ StaticAnalytics.prototype.setOptionsForNextPageview = function (options) {
80
+ if (typeof options !== 'object') {
81
+ return
82
+ }
83
+
84
+ var cookieOptions = getOptionsFromCookie()
85
+
86
+ $.extend(cookieOptions, options)
87
+
88
+ this.setCookie('analytics_next_page_call', cookieOptions)
89
+ }
90
+
91
+ StaticAnalytics.prototype.setCookie = function (cookieName, object) {
92
+ if (!GOVUK.cookie) {
93
+ return
94
+ }
95
+
96
+ if (!object) {
97
+ GOVUK.cookie(cookieName, null)
98
+ } else {
99
+ // Singly-stringified JSON sometimes gets escaped when put into a cookie, but inconsistently. The command-line
100
+ // tests will escape, but browser tests will not. Double-stringify in order to get consistently-escaped strings.
101
+ GOVUK.cookie(cookieName, JSON.stringify(JSON.stringify(object)))
102
+ }
103
+ }
104
+
105
+ StaticAnalytics.prototype.getCookie = function (cookieName) {
106
+ if (!GOVUK.cookie) {
107
+ return
108
+ }
109
+
110
+ try {
111
+ return JSON.parse(JSON.parse(GOVUK.cookie(cookieName)))
112
+ } catch (error) {
113
+ return null
114
+ }
115
+ }
116
+
117
+ StaticAnalytics.prototype.stripPII = function (value) {
118
+ return this.analytics.pii.stripPII(value)
119
+ }
120
+
121
+ function getOptionsFromCookie () {
122
+ try {
123
+ var cookie = StaticAnalytics.prototype.getCookie('analytics_next_page_call')
124
+ StaticAnalytics.prototype.setCookie('analytics_next_page_call', null)
125
+ return cookie || {}
126
+ } catch (e) {
127
+ return {}
128
+ }
129
+ }
130
+
131
+ GOVUK.StaticAnalytics = StaticAnalytics
132
+ })()
@@ -0,0 +1,61 @@
1
+ //= require ../vendor/polyfills/closest.js
2
+
3
+ window.GOVUK = window.GOVUK || {}
4
+ window.GOVUK.Modules = window.GOVUK.Modules || {};
5
+
6
+ (function (Modules) {
7
+ function GemTrackClick () { }
8
+
9
+ GemTrackClick.prototype.start = function ($module) {
10
+ this.$module = $module[0]
11
+ this.$module.handleClick = this.handleClick.bind(this)
12
+
13
+ var that = this
14
+ // add a listener to the whole element
15
+ this.$module.addEventListener('click', function (e) {
16
+ that.$module.handleClick(e.target)
17
+ })
18
+ }
19
+
20
+ GemTrackClick.prototype.handleClick = function (target) {
21
+ var options = { transport: 'beacon' }
22
+
23
+ // if clicked element hasn't got the right attributes, look for a parent that matches
24
+ if (!target.hasAttribute('data-track-category') && !target.hasAttribute('data-track-action')) {
25
+ target = target.closest('[data-track-category][data-track-action]')
26
+ }
27
+
28
+ if (target) {
29
+ var category = target.getAttribute('data-track-category')
30
+ var action = target.getAttribute('data-track-action')
31
+ var label = target.getAttribute('data-track-label')
32
+ var value = target.getAttribute('data-track-value')
33
+ var dimension = target.getAttribute('data-track-dimension')
34
+ var dimensionIndex = target.getAttribute('data-track-dimension-index')
35
+ var extraOptions = target.getAttribute('data-track-options')
36
+
37
+ if (label) {
38
+ options.label = label
39
+ }
40
+
41
+ if (value) {
42
+ options.value = value
43
+ }
44
+
45
+ if (dimension && dimensionIndex) {
46
+ options['dimension' + dimensionIndex] = dimension
47
+ }
48
+
49
+ if (extraOptions) {
50
+ extraOptions = JSON.parse(extraOptions)
51
+ for (var k in extraOptions) options[k] = extraOptions[k]
52
+ }
53
+
54
+ if (window.GOVUK.analytics && window.GOVUK.analytics.trackEvent) {
55
+ window.GOVUK.analytics.trackEvent(category, action, options)
56
+ }
57
+ }
58
+ }
59
+
60
+ Modules.GemTrackClick = GemTrackClick
61
+ })(window.GOVUK.Modules)
@@ -38,10 +38,9 @@ $gem-hover-dark-background: #dddcdb;
38
38
  text-decoration: underline;
39
39
  }
40
40
 
41
- &:focus,
42
- &:active {
41
+ &:focus {
43
42
  text-decoration: none;
44
- color: govuk-colour("black");
43
+ color: $govuk-focus-text-colour;
45
44
  }
46
45
  }
47
46
 
@@ -115,6 +114,22 @@ $gem-hover-dark-background: #dddcdb;
115
114
  }
116
115
  }
117
116
 
117
+ .gem-c-action-link--simple-light {
118
+ &:before {
119
+ width: 30px;
120
+ height: 30px;
121
+ background: image-url("govuk_publishing_components/action-link-arrow--simple-light.png");
122
+ background: image-url("govuk_publishing_components/action-link-arrow--simple-light.svg"), linear-gradient(transparent, transparent);
123
+ background-repeat: no-repeat;
124
+ background-size: 25px auto;
125
+ background-position: 0 2px;
126
+ }
127
+
128
+ .gem-c-action-link__link {
129
+ text-decoration: none;
130
+ }
131
+ }
132
+
118
133
  .gem-c-action-link--dark-icon {
119
134
  &:before {
120
135
  background: image-url("govuk_publishing_components/action-link-arrow--dark.png");
@@ -177,14 +192,9 @@ $gem-hover-dark-background: #dddcdb;
177
192
  color: $gem-hover-dark-background;
178
193
  }
179
194
 
180
- &:focus,
181
- &:active {
195
+ &:focus {
182
196
  text-decoration: none;
183
- color: govuk-colour("black");
184
-
185
- &:hover {
186
- color: govuk-colour("black");
187
- }
197
+ color: $govuk-focus-text-colour;
188
198
  }
189
199
  }
190
200
 
@@ -104,11 +104,16 @@
104
104
  }
105
105
  }
106
106
 
107
+ .govuk-header__logotype {
108
+ vertical-align: middle;
109
+ }
110
+
107
111
  .gem-c-header__product-name {
108
112
  display: none;
109
113
 
110
114
  @include govuk-media-query($from: tablet) {
111
115
  display: inline-block;
116
+ vertical-align: middle;
112
117
  }
113
118
  }
114
119
 
@@ -1,7 +1,8 @@
1
+ $gem-c-print-link-background-width: 16px;
2
+ $gem-c-print-link-background-height: 18px;
3
+
1
4
  .gem-c-print-link {
2
5
  display: none;
3
- margin-bottom: 2em;
4
- margin-top: 2em;
5
6
  }
6
7
 
7
8
  .gem-c-print-link.gem-c-print-link--show-without-js {
@@ -14,39 +15,41 @@
14
15
  }
15
16
  }
16
17
 
17
- .gem-c-print-link__link {
18
- background: image-url("govuk_publishing_components/icon-print.png") no-repeat 10px 50%;
19
-
20
- margin-left: -10px;
21
- padding: .5em .5em .5em 38px;
18
+ .gem-c-print-link__link,
19
+ .gem-c-print-link__button {
20
+ background: image-url("govuk_publishing_components/icon-print.png") no-repeat govuk-spacing(2) 50%;
21
+ background-size: $gem-c-print-link-background-width $gem-c-print-link-background-height;
22
+ padding: govuk-spacing(2) govuk-spacing(2) govuk-spacing(2) (govuk-spacing(4) + $gem-c-print-link-background-width);
22
23
 
23
24
  @include govuk-device-pixel-ratio($ratio: 2) {
24
25
  background-image: image-url("govuk_publishing_components/icon-print-2x.png");
25
- background-size: 16px 18px;
26
26
  }
27
27
 
28
+ &:hover {
29
+ background-color: govuk-colour("light-grey");
30
+ }
31
+ }
32
+
33
+ .gem-c-print-link__link {
34
+ box-shadow: inset 0 0 0 1px $govuk-border-colour;
35
+ text-decoration: none;
36
+
28
37
  &:focus {
29
- @include govuk-focused-text;
38
+ border: 0;
39
+ box-shadow: 0 $govuk-focus-width $govuk-text-colour;
30
40
  }
31
41
  }
32
42
 
33
43
  .gem-c-print-link__button {
34
44
  @extend %govuk-body-s;
35
- background: image-url("govuk_publishing_components/icon-print.png") no-repeat 10px 50%;
36
- border: 0;
45
+ border: 1px solid $govuk-border-colour;
37
46
  color: $govuk-link-colour;
38
47
  cursor: pointer;
39
- margin: 0;
40
- margin-left: -10px;
41
- padding: .5em .5em .5em 38px;
42
- text-decoration: underline;
43
-
44
- @include govuk-device-pixel-ratio($ratio: 2) {
45
- background-image: image-url("govuk_publishing_components/icon-print-2x.png");
46
- background-size: 16px 18px;
47
- }
48
+ margin: govuk-spacing(0);
48
49
 
49
50
  &:focus {
50
51
  @include govuk-focused-text;
52
+ background-color: $govuk-focus-colour;
53
+ border-color: transparent;
51
54
  }
52
55
  }
@@ -36,7 +36,6 @@ $large-input-size: 50px;
36
36
 
37
37
  .gem-c-search__input[type="search"] { // overly specific to prevent some overrides from outside
38
38
  @include govuk-font($size: 19, $line-height: (28 / 19));
39
-
40
39
  padding: 6px;
41
40
  margin: 0;
42
41
  width: 100%;
@@ -71,6 +70,13 @@ $large-input-size: 50px;
71
70
  }
72
71
  }
73
72
 
73
+ @include govuk-compatibility(govuk_template) {
74
+ // ultra specific rule overrides focus styling from govuk_template
75
+ #global-header .gem-c-search__input[type="search"]:focus { // stylelint-disable selector-max-id
76
+ @extend .gem-c-search__input[type="search"]:focus; // stylelint-disable scss/at-extend-no-missing-placeholder
77
+ }
78
+ }
79
+
74
80
  .gem-c-search__submit {
75
81
  border: 0;
76
82
  cursor: pointer;
@@ -120,7 +120,7 @@
120
120
  .gem-c-subscription-links__item--link {
121
121
  padding: govuk-spacing(2) govuk-spacing(2) govuk-spacing(2) 0;
122
122
  border: 1px solid transparent;
123
- border-bottom: 1px solid govuk-colour("dark-grey");
123
+ border-bottom: 1px solid govuk-colour("dark-grey", $legacy: "grey-1");
124
124
 
125
125
  &:focus {
126
126
  border-bottom-color: transparent;
@@ -58,6 +58,10 @@
58
58
 
59
59
  .footnotes {
60
60
  border-top: 1px solid $govuk-text-colour;
61
+
62
+ a[role="doc-backlink"] {
63
+ display: none;
64
+ }
61
65
  }
62
66
 
63
67
  .legislative-list {
@@ -10,6 +10,7 @@
10
10
  mobile_subtext ||= false
11
11
  light_text ||= false
12
12
  simple ||= false
13
+ simple_light ||= false
13
14
  dark_icon ||= false
14
15
  small_icon ||= false
15
16
  nhs_icon ||= false
@@ -24,6 +25,7 @@
24
25
  css_classes << "gem-c-action-link--transparent-icon" if transparent_icon
25
26
  css_classes << "gem-c-action-link--nhs" if nhs_icon
26
27
  css_classes << "gem-c-action-link--simple" if simple
28
+ css_classes << "gem-c-action-link--simple-light" if simple_light
27
29
  css_classes << "gem-c-action-link--with-subtext" if subtext
28
30
  css_classes << "gem-c-action-link--mobile-subtext" if mobile_subtext
29
31
  css_classes << (shared_helper.get_margin_bottom)
@@ -1,13 +1,10 @@
1
1
  <%-
2
2
  cl_helper = GovukPublishingComponents::Presenters::ContentsListHelper.new(local_assigns)
3
- aria_label ||= "Contents"
3
+ aria_label ||= t("components.contents_list.contents")
4
4
  format_numbers ||= false
5
- title_lang ||= false
6
- title = local_assigns[:title].presence || t("components.contents_list.contents")
7
- hide_title ||= false
8
5
  brand ||= false
9
6
  brand_helper = GovukPublishingComponents::AppHelpers::BrandHelper.new(brand)
10
-
7
+ title_fallback = t("components.contents_list.contents", locale: I18n.locale, fallback: false, default: "en")
11
8
  classes = cl_helper.classes
12
9
  classes << brand_helper.brand_class
13
10
  -%>
@@ -21,14 +18,12 @@
21
18
  module: "track-click"
22
19
  }
23
20
  ) do %>
24
- <% unless hide_title %>
25
- <%= content_tag(
26
- :h2,
27
- class: "gem-c-contents-list__title",
28
- lang: title_lang.presence
29
- ) do %>
30
- <%= title %>
31
- <% end %>
21
+ <%= content_tag(
22
+ :h2, {class: "gem-c-contents-list__title"}.merge(
23
+ title_fallback == "en" ? {:lang => "en",} : {}
24
+ )
25
+ ) do %>
26
+ <%= t("components.contents_list.contents") %>
32
27
  <% end %>
33
28
 
34
29
  <ol class="gem-c-contents-list__list">
@@ -12,22 +12,18 @@
12
12
  <% if content.html_safe? %>
13
13
  <%= content %>
14
14
  <% else %>
15
- <% puts "
16
- You've passed in unsanitised HTML into the govspeak component as the
17
- `content` param.
15
+ <% raise "
16
+ You've passed in unsanitised HTML into the Govspeak component as the
17
+ `content` parameter.
18
18
 
19
- Passing in unsafe HTML is deprecated and will be removed in a future
20
- version. You need to pass in a block instead or use the `capture` helper.
21
-
22
- See the component guide for examples.
23
-
24
- If you're 100% sure there's no unsanitised user input in the string you
25
- could also call `.html_safe` on the string or use the `raw` helper before
26
- passing it in.
19
+ To fix this use a `do` block with the sanitize method - see
20
+ https://components.publishing.service.gov.uk/component-guide/govspeak/
21
+ for the updated documentation and
22
+ https://github.com/alphagov/govuk_publishing_components/pull/1632/
23
+ for further examples.
27
24
 
28
25
  Called from #{caller_locations.find { |l| l.to_s.include?('.erb') }}
29
26
  " %>
30
- <%= raw content %>
31
27
  <% end %>
32
28
  <% elsif block_given? %>
33
29
  <%= yield %>