govuk_publishing_components 27.8.1 → 27.8.2

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: 2f2aa4a5338ce625693a82792f054575ba77e17f7b59dec7a43375cd69bdc0a0
4
- data.tar.gz: b972a36c99f444e03f1190b54dc38c48a4e755779df9b3596331765785a0ea28
3
+ metadata.gz: 3763a55d9466b65e17b6d352fcbc6a646aebe57cb22dfca0918a8732244af04b
4
+ data.tar.gz: 1cd543455e2a9881bb70efff661206cb6869ff7608f782429d767c8cf6287893
5
5
  SHA512:
6
- metadata.gz: 7ef57a9ae12333724ca55b5826eb2f962e02c51877e2944b10d7d214258e38aa517317692cc1ee2aab58f38ed7051ebf9fe3ddc864e6982330baf286fe314f9d
7
- data.tar.gz: 8548a40fad2185b2a63fd7c7748f1bcee2511dfc0c610fbeb8f50caf7ad0daf6739e04fe0c06bcf9e52536d71e8a35203f22847a83ece3b3517c826eda87a8ae
6
+ metadata.gz: 0e50da185727b17d9440a957019e0231de4947251bfe3a06273f19e4a0d4fa60bc1b67c9a937877c6dd09f3ac494bc80fb287c767d6541bb4399b1ef194828e7
7
+ data.tar.gz: 59f7ef7156937d87460beebe6c798c9307ef7472a84fa44eaaa9795e7d41adfb6510833ee16af03b54911c13a834b2514a0b026ad2a3fa2e62aa08dd0ef9be2e
@@ -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
  }
@@ -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
+ }
@@ -85,6 +85,19 @@ $large-input-size: 50px;
85
85
  }
86
86
  }
87
87
 
88
+ @mixin icon-positioning($container-size) {
89
+ $icon-dimension: 20px;
90
+ $icon-position: ($container-size - $icon-dimension) / 2;
91
+
92
+ display: block;
93
+ pointer-events: none;
94
+ position: absolute;
95
+ height: $icon-dimension;
96
+ width: $icon-dimension;
97
+ top: $icon-position;
98
+ left: $icon-position;
99
+ }
100
+
88
101
  .gem-c-search__submit {
89
102
  border: 0;
90
103
  cursor: pointer;
@@ -93,15 +106,11 @@ $large-input-size: 50px;
93
106
  padding: 0;
94
107
  width: $input-size;
95
108
  height: $input-size;
96
- background-image: image-url("govuk_publishing_components/search-button.png");
97
- background-repeat: no-repeat;
98
- background-position: 2px 50%;
99
109
  text-indent: -5000px;
100
110
  overflow: hidden;
101
111
 
102
- @include govuk-device-pixel-ratio {
103
- background-size: 52.5px auto;
104
- background-position: 115% 50%;
112
+ .gem-c-search__icon {
113
+ @include icon-positioning($input-size);
105
114
  }
106
115
 
107
116
  &:focus {
@@ -222,11 +231,9 @@ $large-input-size: 50px;
222
231
  .gem-c-search__submit {
223
232
  width: $large-input-size;
224
233
  height: $large-input-size;
225
- background-position: 8px 50%;
226
234
 
227
- @include govuk-device-pixel-ratio {
228
- background-size: 60px auto;
229
- background-position: 160% 50%;
235
+ .gem-c-search__icon {
236
+ @include icon-positioning($large-input-size);
230
237
  }
231
238
  }
232
239
  }
@@ -1,33 +1,46 @@
1
1
  <%
2
+ dismiss_text ||= false
3
+ suggestion_link_text ||= false
4
+ suggestion_link_url ||= false
5
+ suggestion_text ||= nil
6
+
2
7
  data_attributes ||= {}
3
8
  data_attributes[:module] = 'intervention'
4
- %>
9
+ suggestion_data_attributes ||= {}
10
+ dismiss_data_attributes ||= {}
11
+
12
+ aria_attributes ||= {}
13
+ aria_attributes[:label] = 'Intervention'
5
14
 
6
- <%= tag.section class: "gem-c-intervention", role: "region", data: data_attributes do %>
7
- <h2 class="gem-c-intervention__title govuk-heading-s">
8
- <a class="govuk-link" href="/next-steps-for-your-business"
9
- data-module="gem-track-click"
10
- data-track-category="interventionBanner"
11
- data-track-action="interventionClicked"
12
- data-track-dimension="<%= t("components.intervention.title") %>"
13
- data-track-dimension-index="29"
14
- data-track-label="/next-steps-for-your-business">
15
- <%= t("components.intervention.title") %></a>
16
- </h2>
15
+ local_assigns[:query_string] ||= request.query_string
16
+
17
+ intervention_helper = GovukPublishingComponents::Presenters::InterventionHelper.new(local_assigns)
18
+ dismiss_href = intervention_helper.dismiss_link
19
+ %>
20
+ <% if suggestion_text or (suggestion_link_text and suggestion_link_text) %>
21
+ <%= tag.section class: "gem-c-intervention", role: "region", aria: aria_attributes, data: data_attributes do %>
22
+ <p class="govuk-body">
23
+ <%= tag.span suggestion_text, class: "gem-c-intervention__textwrapper" if suggestion_text %>
24
+ <% if suggestion_link_text and suggestion_link_url %>
25
+ <%= tag.a suggestion_link_text, class: "govuk-link gem-c-intervention__suggestion-link", href: suggestion_link_url, data: suggestion_data_attributes %>
17
26
 
18
- <p class="govuk-body">
19
- <%= t("components.intervention.description") %>
20
- </p>
27
+ <% end %>
28
+ </p>
21
29
 
22
- <p class="govuk-body">
23
- <a class="govuk-link" href="?hide-intervention=true"
24
- data-module="gem-track-click"
25
- data-track-category="interventionBanner"
26
- data-track-action="interventionDismissed"
27
- data-track-label="?hide-intervention=true"
28
- data-track-dimension="<%= t("components.intervention.dismiss_link_text") %>"
29
- data-track-dimension-index="29">
30
- <%= t("components.intervention.dismiss_link_text") %></a>
31
- <%= t("components.intervention.dismiss_post_link") %>
32
- </p>
30
+ <% if dismiss_text %>
31
+ <p class="govuk-body">
32
+ <%= tag.a class: "govuk-link gem-c-intervention__dismiss", href: dismiss_href, data: dismiss_data_attributes do %>
33
+ <svg class="gem-c-intervention__dismiss-icon"
34
+ width="19" height="19" viewBox="0 0 19 19"
35
+ aria-hidden="true"
36
+ fill="none" stroke="currentColor">
37
+ <path d="M0.499997 9.5C0.499997 4.52944 4.52944 0.499999 9.5 0.499999C14.4706 0.5 18.5 4.52944 18.5 9.5C18.5 14.4706 14.4706 18.5 9.5 18.5C4.52943 18.5 0.499997 14.4706 0.499997 9.5Z"/>
38
+ <path d="M13.3477 5.4209L9.67383 9.09473L6 5.4209"/>
39
+ <path d="M6 13.4209L9.67383 9.74707L13.3477 13.4209"/>
40
+ </svg>
41
+ <%= dismiss_text %>
42
+ <% end %>
43
+ </p>
44
+ <% end %>
45
+ <% end %>
33
46
  <% end %>
@@ -213,30 +213,10 @@
213
213
  <span class="govuk-visually-hidden">
214
214
  <%= search_text %>
215
215
  </span>
216
- <svg
217
- class="gem-c-layout-super-navigation-header__search-toggle-button-link-icon"
218
- width="27"
219
- height="27"
220
- viewBox="0 0 27 27"
221
- fill="none"
222
- xmlns="http://www.w3.org/2000/svg"
223
- aria-hidden="true"
224
- focusable="false"
225
- >
226
- <circle
227
- cx="10.0161"
228
- cy="10.0161"
229
- r="8.51613"
230
- stroke="currentColor"
231
- stroke-width="3" />
232
- <line
233
- x1="15.8668"
234
- y1="16.3587"
235
- x2="25.4475"
236
- y2="25.9393"
237
- stroke="currentColor"
238
- stroke-width="3" />
239
- </svg>
216
+ <%=
217
+ render "govuk_publishing_components/components/search/search_icon",
218
+ classes: %W[gem-c-layout-super-navigation-header__search-toggle-button-link-icon]
219
+ %>
240
220
  </button>
241
221
 
242
222
  <div id="super-search-menu" class="gem-c-layout-super-navigation-header__search-items">
@@ -53,6 +53,7 @@
53
53
  <div class="gem-c-search__item gem-c-search__submit-wrapper">
54
54
  <%= tag.button class: "gem-c-search__submit", type: "submit", data: data_attributes do %>
55
55
  <%= button_text %>
56
+ <%= render "govuk_publishing_components/components/search/search_icon" %>
56
57
  <% end %>
57
58
  </div>
58
59
  </div>
@@ -6,19 +6,58 @@ body: |
6
6
  that would be useful to them. This component would be used to add this personalised content and would
7
7
  indicate to the user that this is not normally part of the page, but has been added for them specifically.
8
8
 
9
- Right now the contents of the component are static, as the MVP of personalised content is only for Start a Business.
10
- Since many pages will use this component with the same text, we hard-code it here for now.
9
+ The dismiss link points to the current URL with the "hide-intervention" query string parameter set to "true". The backend should check for this string in order to render the same page without the intervention.
11
10
 
12
- The dismiss link will reload the page but the `hide-intervention` query string parameter will cause the
13
- backed not to show the intervention again. Some progressive enhancement will be added in later to avoid
14
- reloading the page if JavaScript is available.
15
11
  accessibility_criteria: |
16
12
  The intervention component must:
17
13
 
18
14
  - have a border colour contrast ratio of more than 4.5:1 with its background to be visually distinct
15
+ - prevent screen readers from announcing the dismiss link icon
16
+
19
17
 
20
- - always render headings with associated description content, so there are no isolated heading elements inside the component
21
18
  shared_accessibility_criteria:
22
19
  - link
23
20
  examples:
24
21
  default:
22
+ data:
23
+ suggestion_text: "You should renew your permit every 6 months."
24
+
25
+ with_suggestion_link:
26
+ data:
27
+ suggestion_text: "Based on your browsing you might be interested in"
28
+ suggestion_link_text: "Travel abroad: step by step"
29
+ suggestion_link_url: "/travel-abroad"
30
+
31
+ with_dismiss_link:
32
+ data:
33
+ suggestion_text: "You should renew your permit every 6 months."
34
+ dismiss_text: "Hide this suggestion"
35
+
36
+ with_suggestion_link_only:
37
+ data:
38
+ suggestion_link_text: "You can now apply for a permit online."
39
+ suggestion_link_url: "/permit"
40
+
41
+ with_data_attributes:
42
+ description: |
43
+ This example shows the use of `suggestion_data_attributes` and
44
+ `dismiss_data_attributes` for click tracking.
45
+ data:
46
+ suggestion_text: "Based on your browsing you might be interested in"
47
+ suggestion_link_text: "Travel abroad: step by step"
48
+ suggestion_link_url: "/travel-abroad"
49
+ suggestion_data_attributes:
50
+ module: "gem-track-click"
51
+ track-category: "interventionBanner"
52
+ track-action: "interventionClicked"
53
+ track-dimension: "Travel abroad: step by step"
54
+ track-dimension-index: "29"
55
+ track-label: "clicked suggestion"
56
+ dismiss_text: "Hide this suggestion"
57
+ dismiss_data_attributes:
58
+ module: "gem-track-click"
59
+ track-category: "interventionBanner"
60
+ track-action: "interventionDismissed"
61
+ track-dimension: "Hide this suggestion"
62
+ track-dimension-index: "29"
63
+ track-label: "hid the intervention"
@@ -62,17 +62,6 @@ examples:
62
62
  margin_bottom: 0
63
63
  context:
64
64
  dark_background: true
65
- in_html_publication_with_context_link:
66
- description: Page titles are used in HTML Publications ([see example](https://www.gov.uk/government/publications/fees-for-civil-and-family-courts/court-fees-for-the-high-court-county-court-and-family-court))
67
- data:
68
- context:
69
- text: Publication
70
- href: '/link'
71
- title: HTML publication page title
72
- inverse: true
73
- margin_bottom: 0
74
- context:
75
- dark_background: true
76
65
  using_design_system_template:
77
66
  description: |
78
67
  This option allows the removal of top margin from the component so that it works within a [Design System page template](https://design-system.service.gov.uk/styles/page-template/default/index.html), where spacing above the title is already provided by padding on the wrapping div.
@@ -0,0 +1,28 @@
1
+ <%
2
+ classes ||= %w[gem-c-search__icon]
3
+ %>
4
+
5
+ <svg
6
+ class="<%= classes.join(" ") %>"
7
+ width="27"
8
+ height="27"
9
+ viewBox="0 0 27 27"
10
+ fill="none"
11
+ xmlns="http://www.w3.org/2000/svg"
12
+ aria-hidden="true"
13
+ focusable="false"
14
+ >
15
+ <circle
16
+ cx="10.0161"
17
+ cy="10.0161"
18
+ r="8.51613"
19
+ stroke="currentColor"
20
+ stroke-width="3" />
21
+ <line
22
+ x1="15.8668"
23
+ y1="16.3587"
24
+ x2="25.4475"
25
+ y2="25.9393"
26
+ stroke="currentColor"
27
+ stroke-width="3" />
28
+ </svg>
@@ -86,11 +86,6 @@ en:
86
86
  news_and_communications: News and communications
87
87
  statistics: Statistics
88
88
  worldwide: Worldwide
89
- intervention:
90
- title: Check the next steps for your limited company
91
- description: You might be interested in this because you’ve been browsing guidance relevant to starting a limited company.
92
- dismiss_link_text: Hide this suggestion
93
- dismiss_post_link: if it’s not relevant to you
94
89
  layout_footer:
95
90
  copyright_html: <a class="govuk-footer__link govuk-footer__copyright-logo" href="http://www.nationalarchives.gov.uk/information-management/re-using-public-sector-information/copyright-and-re-use/crown-copyright/">© Crown copyright</a>
96
91
  licence_html: All content is available under the <a class="govuk-footer__link" href="https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/" rel="license">Open Government Licence v3.0</a>, except where otherwise stated
@@ -0,0 +1,19 @@
1
+ module GovukPublishingComponents
2
+ module Presenters
3
+ class InterventionHelper
4
+ attr_reader :query_string
5
+
6
+ def initialize(local_assigns)
7
+ @query_string = local_assigns[:query_string]
8
+ end
9
+
10
+ def dismiss_link
11
+ if @query_string.present?
12
+ "#{@query_string}&hide-intervention=true"
13
+ else
14
+ "?hide-intervention=true"
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = "27.8.1".freeze
2
+ VERSION = "27.8.2".freeze
3
3
  end
@@ -30,6 +30,7 @@ require "govuk_publishing_components/presenters/schema_org"
30
30
  require "govuk_publishing_components/presenters/heading_helper"
31
31
  require "govuk_publishing_components/presenters/contents_list_helper"
32
32
  require "govuk_publishing_components/presenters/image_card_helper"
33
+ require "govuk_publishing_components/presenters/intervention_helper"
33
34
  require "govuk_publishing_components/presenters/organisation_logo_helper"
34
35
  require "govuk_publishing_components/presenters/highlight_boxes_helper"
35
36
  require "govuk_publishing_components/presenters/taxonomy_list_helper"
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: 27.8.1
4
+ version: 27.8.2
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: 2021-10-22 00:00:00.000000000 Z
11
+ date: 2021-10-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: govuk_app_config
@@ -844,6 +844,7 @@ files:
844
844
  - app/views/govuk_publishing_components/components/layout_header/_search.html.erb
845
845
  - app/views/govuk_publishing_components/components/metadata/_sentence.html.erb
846
846
  - app/views/govuk_publishing_components/components/related_navigation/_section.html.erb
847
+ - app/views/govuk_publishing_components/components/search/_search_icon.html.erb
847
848
  - app/views/layouts/govuk_publishing_components/application.html.erb
848
849
  - config/i18n-tasks.yml
849
850
  - config/initializers/assets.rb
@@ -943,6 +944,7 @@ files:
943
944
  - lib/govuk_publishing_components/presenters/heading_helper.rb
944
945
  - lib/govuk_publishing_components/presenters/highlight_boxes_helper.rb
945
946
  - lib/govuk_publishing_components/presenters/image_card_helper.rb
947
+ - lib/govuk_publishing_components/presenters/intervention_helper.rb
946
948
  - lib/govuk_publishing_components/presenters/machine_readable/article_schema.rb
947
949
  - lib/govuk_publishing_components/presenters/machine_readable/creative_work_schema.rb
948
950
  - lib/govuk_publishing_components/presenters/machine_readable/dataset_schema.rb