govuk_publishing_components 27.8.0 → 27.9.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (28) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/govuk_publishing_components/analytics/google-analytics-universal-tracker.js +9 -0
  3. data/app/assets/javascripts/govuk_publishing_components/analytics/init.js +12 -8
  4. data/app/assets/javascripts/govuk_publishing_components/components/intervention.js +1 -0
  5. data/app/assets/javascripts/govuk_publishing_components/components/layout-super-navigation-header.js +20 -40
  6. data/app/assets/stylesheets/govuk_publishing_components/components/_intervention.scss +13 -10
  7. data/app/assets/stylesheets/govuk_publishing_components/components/_layout-for-public.scss +0 -12
  8. data/app/assets/stylesheets/govuk_publishing_components/components/_layout-super-navigation-header.scss +434 -366
  9. data/app/assets/stylesheets/govuk_publishing_components/components/_search.scss +17 -10
  10. data/app/assets/stylesheets/govuk_publishing_components/components/print/_layout-super-navigation-header.scss +2 -2
  11. data/app/assets/stylesheets/govuk_publishing_components/components/print/_organisation-logo.scss +3 -0
  12. data/app/views/govuk_publishing_components/components/_intervention.html.erb +39 -26
  13. data/app/views/govuk_publishing_components/components/_layout_for_public.html.erb +1 -4
  14. data/app/views/govuk_publishing_components/components/_layout_super_navigation_header.html.erb +80 -74
  15. data/app/views/govuk_publishing_components/components/_search.html.erb +1 -0
  16. data/app/views/govuk_publishing_components/components/docs/intervention.yml +45 -6
  17. data/app/views/govuk_publishing_components/components/docs/layout_for_public.yml +0 -8
  18. data/app/views/govuk_publishing_components/components/docs/layout_super_navigation_header.yml +12 -3
  19. data/app/views/govuk_publishing_components/components/docs/title.yml +0 -11
  20. data/app/views/govuk_publishing_components/components/layout_for_public/_account-layout.html.erb +1 -1
  21. data/app/views/govuk_publishing_components/components/layout_for_public/_account-navigation.html.erb +0 -9
  22. data/app/views/govuk_publishing_components/components/search/_search_icon.html.erb +28 -0
  23. data/config/locales/en.yml +3 -14
  24. data/lib/govuk_publishing_components/presenters/intervention_helper.rb +19 -0
  25. data/lib/govuk_publishing_components/version.rb +1 -1
  26. data/lib/govuk_publishing_components.rb +1 -0
  27. metadata +5 -3
  28. data/app/views/govuk_publishing_components/components/layout_for_public/_account-feedback-footer.html.erb +0 -18
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a177d643883dea8f63ce0c6931e9170ab46e4d50e3499b430c9a67ddb84cb2ca
4
- data.tar.gz: e9b25ea90b6d0fd6269df2acf19a8d724884635ad0dbd84b4279e574737a30ac
3
+ metadata.gz: 1972033395616c1023a78e4452ac636b90a5bc7f9c7739c2a1d258e76691b900
4
+ data.tar.gz: 0c9ce6602fc0811249802d4c4db210ac2df342d35ce2b6bc2a796315d5b0213f
5
5
  SHA512:
6
- metadata.gz: b1279ab602818802cf978a9742a8ba40ccdeef9478307c8f724dfa9d8b024ba33945b7dd8eaaa1f758f48c6a70d61957a3b1936db692d04b4c5fb439a7d7bc2d
7
- data.tar.gz: 81a267c76307c65fc8a0cca680d82421e18e9e494a1d3a31b252563a05d6b88b38c3d1bb60c1b66bac958f7be668b918b2b9aab53b19f94ab599512e7bd6a5e8
6
+ metadata.gz: 0ea760c12bc9de04e792adfa8f37c6ffbb2a14ec58bde29a4419afcc7bdc72e7ef47b8c2f7408fddf8a2b0f494aad26947d4d5d2b896c485f72bbea2f37cebdf
7
+ data.tar.gz: c27b47624a8c10554bf33af5099f5aebc14144410692823e84c7f59a4abb009d82ec9ac1b54c707e30dcd71423e465ced00e405df1abf0ffc325db1f1d9743b0
@@ -36,11 +36,20 @@
36
36
  fieldsObject = { cookieDomain: fieldsObject }
37
37
  }
38
38
 
39
+ function setLinkedDomains () {
40
+ var domains = window.GOVUK.analyticsVars.primaryLinkedDomains
41
+ if (domains && domains.length > 0) {
42
+ sendToGa('require', 'linker')
43
+ sendToGa('linker:autoLink', domains)
44
+ }
45
+ }
46
+
39
47
  configureProfile()
40
48
  anonymizeIp()
41
49
  disableAdFeatures()
42
50
  stripTitlePII()
43
51
  stripLocationPII()
52
+ setLinkedDomains()
44
53
  }
45
54
 
46
55
  GoogleAnalyticsUniversalTracker.load = function () {
@@ -3,9 +3,12 @@ var analyticsInit = function () {
3
3
 
4
4
  var analyticsVars = window.GOVUK.analyticsVars || false
5
5
  if (analyticsVars) {
6
- var gaProperty = window.GOVUK.analyticsVars.gaProperty || false
7
- var gaPropertyCrossDomain = window.GOVUK.analyticsVars.gaPropertyCrossDomain || false
8
- var linkedDomains = window.GOVUK.analyticsVars.linkedDomains || false
6
+ // the property naming convention here isn't consistent, but used in static and
7
+ // govuk-account-manager-prototype, so hard to change
8
+ var primaryGaProperty = window.GOVUK.analyticsVars.gaProperty || false
9
+
10
+ var crossDomainGaProperty = window.GOVUK.analyticsVars.gaPropertyCrossDomain || false
11
+ var crossDomainLinkedDomains = window.GOVUK.analyticsVars.linkedDomains || false
9
12
  }
10
13
 
11
14
  window.GOVUK.Analytics.checkDigitalIdentityConsent = function (location) {
@@ -39,7 +42,7 @@ var analyticsInit = function () {
39
42
 
40
43
  // Disable analytics by default
41
44
  // This will be reversed below, if the consent cookie says usage cookies are allowed
42
- var disabler = 'ga-disable-' + gaProperty
45
+ var disabler = 'ga-disable-' + primaryGaProperty
43
46
  window[disabler] = true
44
47
 
45
48
  if (consentCookie && consentCookie.usage) {
@@ -48,14 +51,14 @@ var analyticsInit = function () {
48
51
  // Load Google Analytics libraries
49
52
  window.GOVUK.StaticAnalytics.load()
50
53
 
51
- if (gaProperty) {
54
+ if (primaryGaProperty) {
52
55
  // Use document.domain in dev, preview and staging so that tracking works
53
56
  // Otherwise explicitly set the domain as www.gov.uk (and not gov.uk).
54
57
  var cookieDomain = (document.domain === 'www.gov.uk') ? '.www.gov.uk' : document.domain
55
58
 
56
59
  // Configure profiles, setup custom vars, track initial pageview
57
60
  var analytics = new window.GOVUK.StaticAnalytics({
58
- universalId: gaProperty,
61
+ universalId: primaryGaProperty,
59
62
  cookieDomain: cookieDomain,
60
63
  allowLinker: true
61
64
  })
@@ -63,8 +66,9 @@ var analyticsInit = function () {
63
66
  // Make interface public for virtual pageviews and events
64
67
  window.GOVUK.analytics = analytics
65
68
 
66
- if (linkedDomains && linkedDomains.length > 0) {
67
- window.GOVUK.analytics.addLinkedTrackerDomain(gaPropertyCrossDomain, 'govuk', linkedDomains)
69
+ // set up linking of domains for cross domain ga property
70
+ if (crossDomainLinkedDomains && crossDomainLinkedDomains.length > 0) {
71
+ window.GOVUK.analytics.addLinkedTrackerDomain(crossDomainGaProperty, 'govuk', crossDomainLinkedDomains)
68
72
  }
69
73
  }
70
74
  } else {
@@ -8,6 +8,7 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
8
8
 
9
9
  Intervention.prototype.init = function () {
10
10
  if (window.GOVUK.analytics && window.GOVUK.analytics.trackEvent) {
11
+ // Send a tracking event when this component is shown
11
12
  window.GOVUK.analytics.trackEvent('interventionBanner', 'interventionShown')
12
13
  }
13
14
  }
@@ -124,25 +124,11 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
124
124
 
125
125
  this.hiddenButtons = this.$module.querySelectorAll('button[hidden]')
126
126
 
127
- this.lastWindowSize = undefined
127
+ this.lastWindowSize = null
128
128
  }
129
129
 
130
130
  SuperNavigationMegaMenu.prototype.windowSize = windowSize
131
131
 
132
- // Resizes the space needed for the dropdown menu so that it doesn't overlap
133
- // with the page content. As this is an event that needs to be added and
134
- // removed it can't be be bound to `this` because that changes the fingerprint
135
- // of the function, and makes it unable to be removed with
136
- // `removeEventListener`.
137
- SuperNavigationMegaMenu.prototype.resizeHandler = function () {
138
- var $module = document.querySelector('[data-module="super-navigation-mega-menu"]')
139
- var $openButton = $module.querySelector('[aria-expanded="true"][data-toggle-desktop-group="top"]')
140
- var $openMenu = $openButton ? $module.querySelector('#' + $openButton.getAttribute('aria-controls')) : null
141
- var margin = $openMenu && windowSize() === 'desktop' ? $openMenu.offsetHeight : 0
142
-
143
- $module.style.marginBottom = margin + 'px'
144
- }
145
-
146
132
  SuperNavigationMegaMenu.prototype.updateStates = function () {
147
133
  if (this.windowSize() === 'mobile' && this.lastWindowSize !== 'mobile') {
148
134
  this.$navigationToggle.removeAttribute('hidden')
@@ -161,8 +147,21 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
161
147
  if (this.windowSize() === 'desktop' && this.lastWindowSize !== 'desktop') {
162
148
  this.$navigationToggle.setAttribute('hidden', 'hidden')
163
149
  this.$navigationMenu.removeAttribute('hidden')
150
+ }
164
151
 
165
- this.resizeHandler()
152
+ // The dropdown menu height is only needed when in desktop mode as this is
153
+ // when the dropdown menu is using `absolute` positioning. This requires
154
+ // JavaScript to work out the height and make space for the dropdown menu.
155
+ if (windowSize() === 'desktop') {
156
+ // Check whether any of the dropdown menus are open.
157
+ var $openButton = this.$module.querySelector('[aria-expanded="true"][data-toggle-desktop-group="top"]')
158
+ // Gets the open dropdown menu
159
+ var $openMenu = $openButton ? this.$module.querySelector('#' + $openButton.getAttribute('aria-controls')) : null
160
+ // If there is an open dropdown menu, get the height of the dropdown menu.
161
+ var margin = $openMenu ? $openMenu.offsetHeight : 0
162
+
163
+ // Make space for the dropdown menu.
164
+ this.$module.style.marginBottom = margin + 'px'
166
165
  }
167
166
 
168
167
  this.lastWindowSize = this.windowSize()
@@ -231,30 +230,11 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
231
230
 
232
231
  this.lastWindowSize = this.windowSize()
233
232
 
234
- // The menu needs to be updated when the window is resized - specifically,
235
- // the top level navigation toggle needs to be shown or hidden.
236
- // Using `matchMedia` to listen for both resize events means that this
237
- // will only fire when the media query is matched so is more efficient. The
238
- // fallback is the `window.resize` event with a check to make sure that it
239
- // only does things when moving from mobile to desktop view.
240
- var setupResizeListener = function () {
241
- window.addEventListener('resize', this.updateStates.bind(this), { passive: true })
242
- }.bind(this)
243
-
244
- if (typeof window.matchMedia === 'function') {
245
- // Internet Explorer 11 supports `matchMedia`, but doesn't support
246
- // the `change` event[1] - so we try it, and then fail back to using
247
- // `window.resize`.
248
- // [1]: https://developer.mozilla.org/en-US/docs/Web/API/MediaQueryList/onchange
249
- try {
250
- window.matchMedia('screen and (min-width:' + SETTINGS.breakpoint.desktop + 'px)')
251
- .addEventListener('change', this.updateStates.bind(this))
252
- } catch (error) {
253
- setupResizeListener()
254
- }
255
- } else {
256
- setupResizeListener()
257
- }
233
+ // The menu needs to be updated when the window is resized to make sure that
234
+ // the space needed for the dropdown menu is correct.
235
+ window.addEventListener('resize', this.updateStates.bind(this), { passive: true })
236
+
237
+ this.$module.classList.add('js-module-initialised')
258
238
  }
259
239
 
260
240
  Modules.SuperNavigationMegaMenu = SuperNavigationMegaMenu
@@ -1,18 +1,21 @@
1
1
  .gem-c-intervention {
2
2
  @include govuk-text-colour;
3
- @include govuk-responsive-padding(6, "left");
4
- @include govuk-responsive-padding(6, "right");
5
- @include govuk-responsive-padding(4, "top");
6
- @include govuk-responsive-padding(4, "bottom");
3
+ @include govuk-responsive-padding(3);
7
4
  @include govuk-responsive-margin(6, "bottom");
8
5
  background-color: govuk-colour("light-grey", $legacy: "grey-4");
9
-
10
- .gem-c-intervention__title {
11
- @include govuk-responsive-margin(0);
12
- @include govuk-responsive-padding(4, "bottom");
13
- }
6
+ border-left: 10px solid $govuk-success-colour;
14
7
 
15
8
  .govuk-body:last-of-type {
16
- @include govuk-responsive-margin(0, "bottom");
9
+ margin-bottom: 0;
17
10
  }
18
11
  }
12
+
13
+ .gem-c-intervention__textwrapper {
14
+ display: block;
15
+ }
16
+
17
+ .gem-c-intervention__dismiss-icon {
18
+ width: 1em;
19
+ height: 1em;
20
+ margin-bottom: -2px;
21
+ }
@@ -52,15 +52,3 @@ $current-indicator-width: 4px;
52
52
  color: $govuk-link-colour;
53
53
  }
54
54
  }
55
-
56
- .gem-c-layout-for-public-account-feedback-footer {
57
- margin-bottom: govuk-spacing(4);
58
- padding: govuk-spacing(3);
59
- background: govuk-colour("light-grey");
60
-
61
- @include govuk-media-query($from: tablet) {
62
- padding: govuk-spacing(6);
63
- margin-top: govuk-spacing(2);
64
- margin-bottom: govuk-spacing(8);
65
- }
66
- }