govuk_publishing_components 30.0.0 → 30.1.0

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: a9d5601a07939b79ec5f1d7f4251d9b7ad00628225282405c6e17bb95b3f7552
4
- data.tar.gz: 866b2f17bc9cc6bab9e7a29bec0fbc9f5f72e96f99742556bed1d5ff8811e3b2
3
+ metadata.gz: 98ffd65de2a6ab2a76338534b51c8a25a9c45bbf7c15ea2eb59363067929846f
4
+ data.tar.gz: 7b0e8e36604bd2666bfe8171b1e06334af902135028115afdbc59838d36ebb94
5
5
  SHA512:
6
- metadata.gz: a4cac8f96d558bf72da3a0f016d40341ea211a9e3895401b7980a260c125f4ccd898b720968e7c207c227128400440237ad0f1d4f6739834aac1923200b4e4a0
7
- data.tar.gz: e97320af9673d84fd8324c66d88dc6d64b0fb9708a41fe9e42573a33cfca2deea1b6e34400e546c762485141b38c6a088a15be4e5425283206bdfef37141178a
6
+ metadata.gz: cbd879810fbb5845aeb9ad610b1afe41dd4324ed9148895bfe5da773599e87f593c606ffd364fb54623cde60f6e340689eab3168aebf229e210e8fc4612c0b49
7
+ data.tar.gz: 4c179f7d646a332d7ea36c6383bd8d808a001590280ba40c747e248a62ed29ece82580331ab6b0f509c99835ef3fcfd72d31ccb1cccf91fc1d39fa688b328172
@@ -33,7 +33,7 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
33
33
  // get attributes from the data attribute to send to GA
34
34
  // only allow it if it already exists in the schema
35
35
  for (var property in data) {
36
- if (schema.event_data[property]) {
36
+ if (property in schema.event_data) {
37
37
  schema.event_data[property] = data[property]
38
38
  }
39
39
  }
@@ -5,6 +5,7 @@
5
5
 
6
6
  GOVUK.Gtm = {
7
7
  PIIRemover: new GOVUK.analyticsGA4.PIIRemover(), // imported in analytics-ga4.js
8
+ nullValue: null,
8
9
 
9
10
  sendPageView: function () {
10
11
  if (window.dataLayer) {
@@ -32,9 +33,9 @@
32
33
  language: this.getLanguage(),
33
34
  history: this.getHistory(),
34
35
  withdrawn: this.getWithDrawn(),
35
- first_published_at: this.getMetaContent('first-published-at'),
36
- updated_at: this.getMetaContent('updated-at'),
37
- public_updated_at: this.getMetaContent('public-updated-at'),
36
+ first_published_at: this.stripTimeFrom(this.getMetaContent('first-published-at')),
37
+ updated_at: this.stripTimeFrom(this.getMetaContent('updated-at')),
38
+ public_updated_at: this.stripTimeFrom(this.getMetaContent('public-updated-at')),
38
39
  publishing_government: this.getMetaContent('publishing-government'),
39
40
  political_status: this.getMetaContent('political-status'),
40
41
  primary_publishing_organisation: this.getMetaContent('primary-publishing-organisation'),
@@ -73,13 +74,17 @@
73
74
  if (tag) {
74
75
  return tag.getAttribute('content')
75
76
  } else {
76
- return 'n/a'
77
+ return this.nullValue
77
78
  }
78
79
  },
79
80
 
80
81
  getLanguage: function () {
81
- var html = document.querySelector('html')
82
- return html.getAttribute('lang') || 'n/a'
82
+ var content = document.getElementById('content')
83
+ if (content) {
84
+ return content.getAttribute('lang') || this.nullValue
85
+ } else {
86
+ return this.nullValue
87
+ }
83
88
  },
84
89
 
85
90
  getHistory: function () {
@@ -90,6 +95,16 @@
90
95
  getWithDrawn: function () {
91
96
  var withdrawn = this.getMetaContent('withdrawn')
92
97
  return (withdrawn === 'withdrawn') ? 'true' : 'false'
98
+ },
99
+
100
+ // return only the date from given timestamps of the form
101
+ // 2022-03-28T19:11:00.000+00:00
102
+ stripTimeFrom: function (value) {
103
+ if (value !== null) {
104
+ return value.split('T')[0]
105
+ } else {
106
+ return this.nullValue
107
+ }
93
108
  }
94
109
  }
95
110
 
@@ -4,7 +4,7 @@
4
4
  var GOVUK = global.GOVUK || {}
5
5
 
6
6
  var Schemas = function () {
7
- this.null = 'n/a'
7
+ this.null = null
8
8
  }
9
9
 
10
10
  Schemas.prototype.eventSchema = function () {
@@ -31,6 +31,7 @@ $govuk-new-link-styles: true;
31
31
  @import "components/details";
32
32
  @import "components/devolved-nations";
33
33
  @import "components/document-list";
34
+ @import "components/emergency-banner";
34
35
  @import "components/error-alert";
35
36
  @import "components/error-message";
36
37
  @import "components/error-summary";
@@ -7,6 +7,7 @@
7
7
  @import "components/print/button";
8
8
  @import "components/print/cards";
9
9
  @import "components/print/contents-list";
10
+ @import "components/print/emergency-banner";
10
11
  @import "components/print/govspeak-html-publication";
11
12
  @import "components/print/govspeak";
12
13
  @import "components/print/layout-super-navigation-header";
@@ -0,0 +1,76 @@
1
+ .gem-c-emergency-banner {
2
+ @include govuk-font(19);
3
+ background-color: govuk-colour("mid-grey");
4
+ color: govuk-colour("white");
5
+ margin-top: 2px;
6
+ padding: govuk-spacing(3) 0;
7
+
8
+ @include govuk-media-query($from: tablet) {
9
+ padding: govuk-spacing(6) 0;
10
+ }
11
+ }
12
+
13
+ .gem-c-emergency-banner--homepage {
14
+ border-bottom: govuk-spacing(1) solid govuk-colour("white");
15
+ border-top: govuk-spacing(1) solid govuk-colour("white");
16
+ margin-bottom: govuk-spacing(-2);
17
+ margin-top: 0;
18
+ position: relative;
19
+ z-index: 10;
20
+ }
21
+
22
+ .gem-c-emergency-banner__heading {
23
+ @include govuk-font(24, $weight: bold);
24
+ margin: 0;
25
+ }
26
+
27
+ .gem-c-emergency-banner__heading--homepage {
28
+ @include govuk-font(48, $weight: bold);
29
+
30
+ @include govuk-media-query($from: tablet) {
31
+ margin-bottom: govuk-spacing(4);
32
+ }
33
+ }
34
+
35
+ .gem-c-emergency-banner__description {
36
+ @include govuk-font(19);
37
+ color: govuk-colour("white");
38
+ margin-top: 0;
39
+ margin-bottom: govuk-spacing(4);
40
+
41
+ &:last-child {
42
+ margin-bottom: 0;
43
+ }
44
+ }
45
+
46
+ .gem-c-emergency-banner__description--homepage {
47
+ margin: govuk-spacing(4) 0;
48
+ }
49
+
50
+ .gem-c-emergency-banner__link {
51
+ @include govuk-font(19);
52
+ }
53
+
54
+ .gem-c-emergency-banner__link:link,
55
+ .gem-c-emergency-banner__link:visited {
56
+ color: govuk-colour("white");
57
+ }
58
+
59
+ .gem-c-emergency-banner__link:focus {
60
+ @include govuk-focused-text;
61
+ }
62
+
63
+ .gem-c-emergency-banner--notable-death {
64
+ background-color: govuk-colour("black");
65
+ }
66
+
67
+ .gem-c-emergency-banner--national-emergency {
68
+ // Not using govuk-colour("red") aka #d4351c as that's a slightly different red.
69
+ background-color: #b10e1e;
70
+ }
71
+
72
+ .gem-c-emergency-banner--local-emergency {
73
+ // Not using govuk-colour("turquoise") for background colour as
74
+ // the contrast was too low with white text
75
+ background-color: #00847d;
76
+ }
@@ -0,0 +1,3 @@
1
+ .gem-c-emergency-banner {
2
+ display: none;
3
+ }
@@ -0,0 +1,51 @@
1
+ <%
2
+ heading ||= ""
3
+ short_description ||= nil
4
+ link ||= nil
5
+ link_text ||= "More information"
6
+ campaign_class ||= nil
7
+ homepage ||= false
8
+
9
+ emergency_banner_helper = GovukPublishingComponents::Presenters::EmergencyBannerHelper.new()
10
+
11
+ if !campaign_class
12
+ raise ArgumentError, "Need to specify an emergency_type"
13
+ end
14
+
15
+ if !emergency_banner_helper.is_a_valid_emergency_type?(campaign_class)
16
+ raise ArgumentError, "Emergency type #{campaign_class} is not in list of valid emergency types (#{emergency_banner_helper.emergency_types.join(', ')})"
17
+ end
18
+
19
+ banner_classes = %w[gem-c-emergency-banner]
20
+ banner_classes << "gem-c-emergency-banner--#{campaign_class}"
21
+ banner_classes << "gem-c-emergency-banner--homepage" if homepage
22
+
23
+ heading_classes = %w[gem-c-emergency-banner__heading]
24
+ heading_classes << "gem-c-emergency-banner__heading--homepage" if homepage
25
+
26
+ description_classes = %w[gem-c-emergency-banner__description]
27
+ description_classes << "gem-c-emergency-banner__description--homepage" if homepage
28
+
29
+ %>
30
+
31
+ <%= content_tag('div', class: banner_classes, "aria-label": "emergency banner", "role": "region", "data-nosnippet": true ) do %>
32
+ <div class="govuk-width-container">
33
+ <div class="govuk-grid-row">
34
+ <div class="govuk-grid-column-two-thirds">
35
+ <%= content_tag('h2', class: heading_classes) do %>
36
+ <%= heading %>
37
+ <% end %>
38
+ <% if short_description %>
39
+ <%= content_tag('p', class: description_classes) do %>
40
+ <%= short_description %>
41
+ <% end %>
42
+ <% end %>
43
+ <% if link %>
44
+ <a href="<%= link %>" class="gem-c-emergency-banner__link">
45
+ <%= link_text %>
46
+ </a>
47
+ <% end %>
48
+ </div>
49
+ </div>
50
+ </div>
51
+ <% end %>
@@ -185,15 +185,15 @@ examples:
185
185
  description: |
186
186
  Adds custom data attributes to each section of the accordion. Accepts a hash, so multiple attributes can be added.
187
187
 
188
- The `data_attributes` hash is for the outermost element in the accordion.
188
+ The `data_attributes` option applies attributes to the outermost element in the accordion. Each item can also have a `data_attributes` hash, which are placed on the `button` that triggers the opening and closing - useful for differentiating between each section of the accordion.
189
189
 
190
- Each item can also have a `data_attributes` hash. These `data_attributes` are placed on the `button` that triggers the opening and closing - useful for differentiating between each section of the accordion.
190
+ Data attributes can be added to the 'Show/hide all' link using the `data_attributes_show_all` option, primarily where custom tracking is required. These attributes are read from the accordion markup and then added to the link by JavaScript (which is how the link is created). More details on how this can be used with the GA4 click tracking can be found in the 'Advanced' section of the [click tracking documentation](https://github.com/alphagov/govuk_publishing_components/blob/main/docs/analytics-gtm/gtm-click-tracking.md).
191
191
 
192
- Data attributes can also be added to the 'Show/hide all' link using the `data_attributes_show_all` option, primarily where custom tracking is required. These attributes are read from the accordion markup and then added to the link by JavaScript (which is how the link is created). If `track_options` within `data_attributes_show_all` is set, then it is possible to pass a custom dimension when 'Show/Hide all' is clicked.
192
+ If `track_options` within `data_attributes_show_all` is set, then it is possible to pass a custom dimension when 'Show/Hide all' is clicked.
193
193
  data:
194
194
  data_attributes:
195
- gtm: gtm-accordion
196
- ga: ga-accordion
195
+ gtm: gtm-accordion
196
+ ga: ga-accordion
197
197
  data_attributes_show_all:
198
198
  gtm-event-name: example
199
199
  gtm-attributes: "{ 'ui': { 'type': 'type value', 'section': 'section value' } }"
@@ -0,0 +1,45 @@
1
+ name: Emergency banner
2
+ description: A site-wide banner used in the event of an emergency
3
+ body: |
4
+ There are three types of events that would lead GOV.UK to add an emergency banner to the top of each page on the web site; a notable death, a national emergency or a local emergency.
5
+
6
+ See the [opsmanual](https://docs.publishing.service.gov.uk/manual/emergency-publishing.html#adding-emergency-publishing-banners) for information about what the Emergency Banner is and when it should be deployed.
7
+
8
+ shared_accessibility_criteria:
9
+ - link
10
+
11
+ examples:
12
+ default:
13
+ description: |
14
+ Death of a notable person
15
+ data:
16
+ campaign_class: "notable-death"
17
+ heading: "His Royal Highness Henry VIII"
18
+ short_description: "1491 to 1547"
19
+ link_text: "Override Link Text"
20
+ link: "https://www.gov.uk/"
21
+ national_emergency:
22
+ description: |
23
+ National emergency (level 1 or category 2)
24
+ data:
25
+ campaign_class: "national-emergency"
26
+ heading: "National emergency"
27
+ short_description: "This is a level 1 incident"
28
+ link: "https://www.gov.uk/"
29
+ local_emergency:
30
+ description: |
31
+ Localised large-scale emergency (level 2 or category 1)
32
+ data:
33
+ campaign_class: "local-emergency"
34
+ heading: "Local emergency"
35
+ short_description: "This is a level 2 incident"
36
+ link: "https://www.gov.uk/"
37
+ notable_death_homepage:
38
+ description: |
39
+ When presenting any type of emergency banner on homepage the styling is slightly different.
40
+ data:
41
+ campaign_class: "notable-death"
42
+ heading: "His Royal Highness Henry VIII"
43
+ short_description: "1491 to 1547"
44
+ link: "https://www.gov.uk/"
45
+ homepage: true
@@ -0,0 +1,17 @@
1
+ module GovukPublishingComponents
2
+ module Presenters
3
+ class EmergencyBannerHelper
4
+ EMERGENCY_TYPES = %w[notable-death national-emergency local-emergency].freeze
5
+
6
+ def initialize; end
7
+
8
+ def emergency_types
9
+ EMERGENCY_TYPES
10
+ end
11
+
12
+ def is_a_valid_emergency_type?(type)
13
+ EMERGENCY_TYPES.include?(type)
14
+ end
15
+ end
16
+ end
17
+ end
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = "30.0.0".freeze
2
+ VERSION = "30.1.0".freeze
3
3
  end
@@ -12,6 +12,7 @@ require "govuk_publishing_components/presenters/breadcrumb_selector"
12
12
  require "govuk_publishing_components/presenters/button_helper"
13
13
  require "govuk_publishing_components/presenters/contextual_navigation"
14
14
  require "govuk_publishing_components/presenters/devolved_nations_helper"
15
+ require "govuk_publishing_components/presenters/emergency_banner_helper"
15
16
  require "govuk_publishing_components/presenters/related_navigation_helper"
16
17
  require "govuk_publishing_components/presenters/step_by_step_nav_helper"
17
18
  require "govuk_publishing_components/presenters/page_with_step_by_step_navigation"
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: 30.0.0
4
+ version: 30.1.0
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: 2022-07-28 00:00:00.000000000 Z
11
+ date: 2022-08-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: govuk_app_config
@@ -534,6 +534,7 @@ files:
534
534
  - app/assets/stylesheets/govuk_publishing_components/components/_details.scss
535
535
  - app/assets/stylesheets/govuk_publishing_components/components/_devolved-nations.scss
536
536
  - app/assets/stylesheets/govuk_publishing_components/components/_document-list.scss
537
+ - app/assets/stylesheets/govuk_publishing_components/components/_emergency-banner.scss
537
538
  - app/assets/stylesheets/govuk_publishing_components/components/_error-alert.scss
538
539
  - app/assets/stylesheets/govuk_publishing_components/components/_error-message.scss
539
540
  - app/assets/stylesheets/govuk_publishing_components/components/_error-summary.scss
@@ -622,6 +623,7 @@ files:
622
623
  - app/assets/stylesheets/govuk_publishing_components/components/print/_button.scss
623
624
  - app/assets/stylesheets/govuk_publishing_components/components/print/_cards.scss
624
625
  - app/assets/stylesheets/govuk_publishing_components/components/print/_contents-list.scss
626
+ - app/assets/stylesheets/govuk_publishing_components/components/print/_emergency-banner.scss
625
627
  - app/assets/stylesheets/govuk_publishing_components/components/print/_govspeak-html-publication.scss
626
628
  - app/assets/stylesheets/govuk_publishing_components/components/print/_govspeak.scss
627
629
  - app/assets/stylesheets/govuk_publishing_components/components/print/_layout-super-navigation-header.scss
@@ -678,6 +680,7 @@ files:
678
680
  - app/views/govuk_publishing_components/components/_details.html.erb
679
681
  - app/views/govuk_publishing_components/components/_devolved_nations.html.erb
680
682
  - app/views/govuk_publishing_components/components/_document_list.html.erb
683
+ - app/views/govuk_publishing_components/components/_emergency_banner.html.erb
681
684
  - app/views/govuk_publishing_components/components/_error_alert.html.erb
682
685
  - app/views/govuk_publishing_components/components/_error_message.html.erb
683
686
  - app/views/govuk_publishing_components/components/_error_summary.html.erb
@@ -760,6 +763,7 @@ files:
760
763
  - app/views/govuk_publishing_components/components/docs/details.yml
761
764
  - app/views/govuk_publishing_components/components/docs/devolved_nations.yml
762
765
  - app/views/govuk_publishing_components/components/docs/document_list.yml
766
+ - app/views/govuk_publishing_components/components/docs/emergency_banner.yml
763
767
  - app/views/govuk_publishing_components/components/docs/error_alert.yml
764
768
  - app/views/govuk_publishing_components/components/docs/error_message.yml
765
769
  - app/views/govuk_publishing_components/components/docs/error_summary.yml
@@ -922,6 +926,7 @@ files:
922
926
  - lib/govuk_publishing_components/presenters/contextual_navigation.rb
923
927
  - lib/govuk_publishing_components/presenters/curated_taxonomy_sidebar_links.rb
924
928
  - lib/govuk_publishing_components/presenters/devolved_nations_helper.rb
929
+ - lib/govuk_publishing_components/presenters/emergency_banner_helper.rb
925
930
  - lib/govuk_publishing_components/presenters/heading_helper.rb
926
931
  - lib/govuk_publishing_components/presenters/image_card_helper.rb
927
932
  - lib/govuk_publishing_components/presenters/intervention_helper.rb