govuk_publishing_components 35.20.1 → 35.21.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '096ada32d1ecced73348563a12eaa51f1f722c75f11791baba32d24de329b4ad'
4
- data.tar.gz: 7c905c2babbe3a999a4a44d2441506b5b38b48edbb78593a9b9212b55549d8da
3
+ metadata.gz: 7d50686dad9cdda4ba4f752558bea505240bbf6114d87adb622f0c5979311fc6
4
+ data.tar.gz: d742933a7c501d815ffcde551a5b2fddad3c67cd7e6e24efae03bf6273df1408
5
5
  SHA512:
6
- metadata.gz: 7bca767187c1d88419a6c36c90a6cfb763773ef81cd1106bf24f2298142bf7f247ca293c05a4bc9c76fe567f326ff36a7cbb7986bc671995512c22b4f2f67461
7
- data.tar.gz: 715869ba54a39828637ded7125d39462716247acec55b3c71507975fbcbb567a01dfd2ab152a2fe19fac3044ca4c7c0e0b1ea56c9dca6b074ac440abdf4c3e28
6
+ metadata.gz: d0364bb2803a05e97bc0e52596dd6a952e2697dea2584d2a8e40b2d65abf132c190259dd7b1934f437c3ac70fed9eed2c2b72130f3a4f68b1ff0f3cfeeee21bc
7
+ data.tar.gz: 13829c743b74ddb4d384803b760dfc24d3d89fffe15427740d14c0b2e35352a985da5e43b63a98ca55930d253b655bfd33ba6a5fd336d0d1638dbec768aa5231
@@ -30,7 +30,16 @@ window.GOVUK.analyticsGa4 = window.GOVUK.analyticsGa4 || {};
30
30
  firstScript.parentNode.insertBefore(newScript, firstScript)
31
31
  },
32
32
 
33
+ getUserAgent: function () {
34
+ return navigator.userAgent
35
+ },
36
+
33
37
  sendData: function (data) {
38
+ // Prevent any GA4 data being sent during Smokey tests
39
+ if (this.getUserAgent() === 'Smokey Test / Ruby') {
40
+ return
41
+ }
42
+
34
43
  data.govuk_gem_version = this.getGemVersion()
35
44
  // set this in the console as a debugging aid
36
45
  if (window.GOVUK.analyticsGa4.showDebug) {
@@ -272,7 +281,7 @@ window.GOVUK.analyticsGa4 = window.GOVUK.analyticsGa4 || {};
272
281
  },
273
282
 
274
283
  getIndex: function (element, startPosition) {
275
- var index = element.getAttribute('data-ecommerce-index')
284
+ var index = element.getAttribute('data-ga4-ecommerce-index')
276
285
 
277
286
  if (!index) {
278
287
  return null
@@ -298,7 +307,7 @@ window.GOVUK.analyticsGa4 = window.GOVUK.analyticsGa4 || {};
298
307
  var element = data.element
299
308
  var resultsId = data.resultsId
300
309
  var isClickEvent = data.event !== undefined
301
- var isSearchResult = element.getAttribute('data-search-query')
310
+ var isSearchResult = element.getAttribute('data-ga4-search-query')
302
311
 
303
312
  var ecommerceSchema = new window.GOVUK.analyticsGa4.Schemas().ecommerceSchema()
304
313
  var PIIRemover = new window.GOVUK.analyticsGa4.PIIRemover()
@@ -306,14 +315,14 @@ window.GOVUK.analyticsGa4 = window.GOVUK.analyticsGa4 || {};
306
315
 
307
316
  if (isSearchResult) {
308
317
  // Limiting to 100 characters to avoid noise from extra long search queries and to stop the size of the payload going over 8k limit.
309
- var searchQuery = PIIRemover.stripPII(element.getAttribute('data-search-query')).substring(0, 100).toLowerCase()
310
- var variant = element.getAttribute('data-ecommerce-variant')
318
+ var searchQuery = PIIRemover.stripPII(element.getAttribute('data-ga4-search-query')).substring(0, 100).toLowerCase()
319
+ var variant = element.getAttribute('data-ga4-ecommerce-variant')
311
320
  DEFAULT_LIST_TITLE = 'Site search results'
312
321
  }
313
322
 
314
323
  var items = element.querySelectorAll('[data-ga4-ecommerce-path]')
315
- var listTitle = element.getAttribute('data-list-title') || DEFAULT_LIST_TITLE
316
- var startPosition = parseInt(element.getAttribute('data-ecommerce-start-index'), 10)
324
+ var listTitle = element.getAttribute('data-ga4-list-title') || DEFAULT_LIST_TITLE
325
+ var startPosition = parseInt(element.getAttribute('data-ga4-ecommerce-start-index'), 10)
317
326
 
318
327
  ecommerceSchema.event = 'search_results'
319
328
  ecommerceSchema.search_results.event_name = isClickEvent ? 'select_item' : 'view_item_list'
@@ -344,10 +353,10 @@ window.GOVUK.analyticsGa4 = window.GOVUK.analyticsGa4 || {};
344
353
  var item = items[i]
345
354
  var path = item.getAttribute('data-ga4-ecommerce-path')
346
355
 
347
- // If the element does not have a data-ecommerce-index attribute, we set one so that we can use it later when setting the index property
356
+ // If the element does not have a data-ga4-ecommerce-index attribute, we set one so that we can use it later when setting the index property
348
357
  // on the ecommerce object.
349
- if (!item.getAttribute('data-ecommerce-index')) {
350
- item.setAttribute('data-ecommerce-index', i + 1)
358
+ if (!item.getAttribute('data-ga4-ecommerce-index')) {
359
+ item.setAttribute('data-ga4-ecommerce-index', i + 1)
351
360
  }
352
361
 
353
362
  ecommerceSchema.search_results.ecommerce.items.push({
@@ -46,7 +46,7 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
46
46
  var formData = this.getInputValues(formInputs)
47
47
  data.text = data.text || this.combineGivenAnswers(formData) || this.useFallbackValue
48
48
 
49
- if (data.action === 'search') {
49
+ if (data.action === 'search' && data.text) {
50
50
  data.text = data.text.toLowerCase()
51
51
  data.text = window.GOVUK.analyticsGa4.core.trackFunctions.removeLinesAndExtraSpaces(data.text)
52
52
  }
@@ -880,6 +880,10 @@ $after-button-padding-left: govuk-spacing(4);
880
880
  width: 68px;
881
881
  }
882
882
 
883
+ .gem-c-layout-super-navigation-header__navigation-second-item-description {
884
+ margin-top: govuk-spacing(1);
885
+ }
886
+
883
887
  .gem-c-layout-super-navigation-header__navigation-dropdown-menu--large-navbar .gem-c-layout-super-navigation-header__navigation-second-item-description {
884
888
  font-size: 19px;
885
889
  font-size: govuk-px-to-rem(19px);
@@ -25,11 +25,14 @@
25
25
  .gem-c-metadata--inverse {
26
26
  background-color: govuk-colour("blue");
27
27
  color: govuk-colour("white");
28
- padding: govuk-spacing(2);
29
28
 
30
29
  a {
31
30
  @include govuk-link-style-inverse;
32
31
  }
32
+ }
33
+
34
+ .gem-c-metadata--inverse-padded {
35
+ padding: govuk-spacing(2);
33
36
 
34
37
  .gem-c-metadata__list {
35
38
  margin: govuk-spacing(2);
@@ -9,6 +9,7 @@
9
9
 
10
10
  other ||= nil
11
11
  inverse ||= false
12
+ inverse_compress ||= false
12
13
 
13
14
  direction_class = ""
14
15
  direction_class = " direction-#{direction}" if local_assigns.include?(:direction)
@@ -16,7 +17,13 @@
16
17
  shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)
17
18
  classes = %w(gem-c-metadata)
18
19
  classes << "direction-#{direction}" if local_assigns.include?(:direction)
19
- classes << "gem-c-metadata--inverse" if inverse
20
+
21
+ if inverse && inverse_compress
22
+ classes << "gem-c-metadata--inverse"
23
+ elsif inverse
24
+ classes << "gem-c-metadata--inverse gem-c-metadata--inverse-padded"
25
+ end
26
+
20
27
  classes << shared_helper.get_margin_bottom if local_assigns[:margin_bottom]
21
28
 
22
29
  ga4_tracking ||= false
@@ -355,6 +355,26 @@ examples:
355
355
  see_updates_link: true
356
356
  other:
357
357
  Applies to: England, Scotland, and Wales (see detailed guidance for <a href="http://www.dardni.gov.uk/news-dard-pa022-a-13-new-procedure-for" rel="external">Northern Ireland</a>)
358
+ on_a_dark_background_without_padding:
359
+ description: By default the inverse option includes extra spacing around the component. This option removes this padding. Note that both the `inverse` and `inverse_compress` options must be supplied.
360
+ data:
361
+ inverse: true
362
+ inverse_compress: true
363
+ from: [
364
+ "<a href='/government/organisations/ministry-of-defence'>Ministry of Defence</a>",
365
+ "<a href='/government/organisations/cabinet-office'>Cabinet Office</a>",
366
+ "<a href=\"/government/organisations/department-for-business-energy-and-industrial-strategy\">Department for Business, Energy &amp; Industrial Strategy</a>",
367
+ "<a href=\"/government/organisations/foreign-commonwealth-office\">Foreign &amp; Commonwealth Office</a>",
368
+ "<a href=\"/government/people/william-hague\">The Rt Hon William Hague</a>",
369
+ "<a href=\"/government/organisations/department-for-environment-food-rural-affairs\">Department for Environment, Food &amp; Rural Affairs</a>",
370
+ "<a href=\"/government/organisations/department-for-work-pensions\">Department for work and pensions</a>",
371
+ "<a href=\"/government/organisations/foreign-commonwealth-office\">Foreign and Commonwealth Office</a>"
372
+ ]
373
+ first_published: 14 June 2014
374
+ last_updated: 10 September 2015
375
+ see_updates_link: true
376
+ other:
377
+ Applies to: England, Scotland, and Wales (see detailed guidance for <a href="http://www.dardni.gov.uk/news-dard-pa022-a-13-new-procedure-for" rel="external">Northern Ireland</a>)
358
378
  with_custom_margin_bottom:
359
379
  description: |
360
380
  The component accepts a number for margin bottom from `0` to `9` (`0px` to `60px`) using the [GOV.UK Frontend spacing scale](https://design-system.service.gov.uk/styles/spacing/#the-responsive-spacing-scale). It defaults to the `margin-bottom` values defined in the [responsive-bottom-margin mixin](https://github.com/alphagov/govuk_publishing_components/blob/main/app/assets/stylesheets/govuk_publishing_components/components/mixins/_margins.scss#L1)
@@ -24,13 +24,13 @@ module GovukPublishingComponents
24
24
 
25
25
  def wrap_numbers_with_spans(content_item_link)
26
26
  content_item_text = strip_tags(content_item_link) # just the text of the link
27
-
27
+ content_item_text_stripped = content_item_text.strip # strip trailing spaces for the regex. Keep original content_item_text for the string replacement.
28
28
  # Must start with a number
29
29
  # Number must be between 1 and 999 (ie not 2014)
30
30
  # Must be followed by a space
31
31
  # May contain a period `1.`
32
32
  # May be a decimal `1.2`
33
- number = /^\d{1,3}(\.?|\.\d{1,2})(?=\s)/.match(content_item_text)
33
+ number = /^\d{1,3}(\.?|\.\d{1,2})(?=\s)/.match(content_item_text_stripped)
34
34
 
35
35
  if number
36
36
  words = content_item_text.sub(number.to_s, "").strip # remove the number from the text
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = "35.20.1".freeze
2
+ VERSION = "35.21.1".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk_publishing_components
3
3
  version: !ruby/object:Gem::Version
4
- version: 35.20.1
4
+ version: 35.21.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - GOV.UK Dev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-10-25 00:00:00.000000000 Z
11
+ date: 2023-10-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: govuk_app_config