govuk_publishing_components 35.0.0 → 35.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/stylesheets/govuk_publishing_components/components/_layout-super-navigation-header.scss +1 -1
- data/app/assets/stylesheets/govuk_publishing_components/components/helpers/_markdown-typography.scss +1 -1
- data/app/views/govuk_publishing_components/components/_error_summary.html.erb +7 -5
- data/app/views/govuk_publishing_components/components/_layout_footer.html.erb +48 -11
- data/app/views/govuk_publishing_components/components/docs/error_summary.yml +1 -12
- data/config/locales/en.yml +0 -4
- data/lib/govuk_publishing_components/presenters/layout_footer_helper.rb +47 -0
- data/lib/govuk_publishing_components/version.rb +1 -1
- data/lib/govuk_publishing_components.rb +5 -2
- metadata +4 -4
- data/lib/govuk_publishing_components/railtie.rb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd345b52485fb5fefdb529d929af976ca97fe31f8c9d73d5d8aa42868dbc55b0
|
4
|
+
data.tar.gz: 3a41640de2f4784004f724604bdc7dc1a9a9202f963e1304c2c4ae4d2db2dfa9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0cfddee718886b034fcef934d97479726c0cf74257c268a8671f8ce2d88de9715416021dff81cc948d0791b70a115ba9545e6bde329ccf0fccaac1530687c915
|
7
|
+
data.tar.gz: 561a511659dd0a07ca6d6b8432bdddff207770cc6a782d54ddd769dfbfd17c30583b9e2585688ad1decb645bd4390ae17d61e5e52b97fc33859ef801e9c73c4d
|
@@ -705,7 +705,7 @@ $after-button-padding-left: govuk-spacing(4);
|
|
705
705
|
}
|
706
706
|
|
707
707
|
@include govuk-media-query($from: "desktop") {
|
708
|
-
@include columns($items:
|
708
|
+
@include columns($items: 16, $columns: 2, $selector: "li", $flow: column);
|
709
709
|
}
|
710
710
|
}
|
711
711
|
|
@@ -9,12 +9,14 @@
|
|
9
9
|
if items.empty? && !title
|
10
10
|
raise ArgumentError, "The error_summary component needs at least one item or a title in order to render."
|
11
11
|
end
|
12
|
+
|
13
|
+
component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
|
14
|
+
component_helper.set_id(id)
|
15
|
+
component_helper.add_class("gem-c-error-summary govuk-error-summary")
|
16
|
+
component_helper.add_data_attribute({ module: "govuk-error-summary" })
|
12
17
|
%>
|
13
|
-
|
14
|
-
|
15
|
-
data: { module: "govuk-error-summary" }.merge(data_attributes),
|
16
|
-
id: id,
|
17
|
-
) do %>
|
18
|
+
|
19
|
+
<%= tag.div(**component_helper.all_attributes) do %>
|
18
20
|
<%= tag.div(
|
19
21
|
role: "alert",
|
20
22
|
) do %>
|
@@ -6,15 +6,16 @@
|
|
6
6
|
with_border ||= false
|
7
7
|
classes = %w(gem-c-layout-footer govuk-footer)
|
8
8
|
classes << "gem-c-layout-footer--border" if with_border
|
9
|
+
layout_footer_helper = GovukPublishingComponents::Presenters::LayoutFooterHelper.new(navigation, meta)
|
9
10
|
%>
|
10
|
-
<%= tag.footer class: classes, role: "contentinfo" do %>
|
11
|
+
<%= tag.footer class: classes, role: "contentinfo", 'data-module': "ga4-link-tracker" do %>
|
11
12
|
<div class="govuk-width-container">
|
12
13
|
<% if navigation.any? %>
|
13
14
|
<div class="govuk-footer__navigation" data-module="gem-track-click" data-track-links-only>
|
14
|
-
<% navigation.
|
15
|
-
<% if
|
15
|
+
<% navigation.each_with_index do |section, ga4_section_index| %>
|
16
|
+
<% if section[:items] %>
|
16
17
|
<%
|
17
|
-
case
|
18
|
+
case section[:columns]
|
18
19
|
when 2
|
19
20
|
width_class = "govuk-grid-column-two-thirds"
|
20
21
|
when 3
|
@@ -26,25 +27,29 @@
|
|
26
27
|
# If the list has multiple columns and there is only one link.
|
27
28
|
# This is to prevent a long link wrapping in a column, which
|
28
29
|
# leaves an obvious blank space to the right.
|
29
|
-
single_item_list = ((
|
30
|
+
single_item_list = (( section[:columns] == 2 || section[:columns] == 3 ) && section[:items].length == 1 )
|
30
31
|
|
31
32
|
list_classes = %w[govuk-footer__list]
|
32
|
-
list_classes << "govuk-footer__list--columns-#{
|
33
|
+
list_classes << "govuk-footer__list--columns-#{section[:columns]}" if section[:columns] unless single_item_list
|
33
34
|
%>
|
34
35
|
<div class="<%= width_class %> govuk-!-display-none-print">
|
35
|
-
<h2 class="govuk-footer__heading govuk-heading-m"><%=
|
36
|
+
<h2 class="govuk-footer__heading govuk-heading-m"><%= section[:title] %></h2>
|
36
37
|
<ul class="<%= list_classes.join(' ') %>">
|
37
|
-
<%
|
38
|
+
<% section[:items].each_with_index do |item, index| %>
|
38
39
|
<% if item[:href] && item[:text] %>
|
39
40
|
<li class="govuk-footer__list-item">
|
40
41
|
<%
|
41
42
|
attributes = {
|
42
43
|
class: "govuk-footer__link",
|
43
44
|
data: {
|
44
|
-
"track-category": "footerClicked"
|
45
|
+
"track-category": "footerClicked",
|
45
46
|
}
|
46
47
|
}.merge(item.fetch(:attributes, {}))
|
47
48
|
attributes[:rel] = "noopener" if attributes[:target] == "_blank" && !attributes[:rel]
|
49
|
+
|
50
|
+
unless attributes[:data][:ga4_link]
|
51
|
+
attributes[:data][:ga4_link] = layout_footer_helper.generate_ga4_link_attribute(index, ga4_section_index, section[:title])
|
52
|
+
end
|
48
53
|
%>
|
49
54
|
<%= link_to item[:text], item[:href], attributes %>
|
50
55
|
</li>
|
@@ -63,11 +68,18 @@
|
|
63
68
|
<% if meta.any? %>
|
64
69
|
<h2 class="govuk-visually-hidden"><%= t("components.layout_footer.support_links") %></h2>
|
65
70
|
<ul class="govuk-footer__inline-list govuk-!-display-none-print" data-module="gem-track-click" data-track-links-only>
|
66
|
-
<% meta[:items].
|
71
|
+
<% meta[:items].each_with_index do |item, index| %>
|
67
72
|
<li class="govuk-footer__inline-list-item">
|
68
73
|
<%
|
69
|
-
attributes = {
|
74
|
+
attributes = {
|
75
|
+
class: "govuk-footer__link",
|
76
|
+
}.merge(item.fetch(:attributes, {}))
|
77
|
+
attributes[:data] ||= {}
|
70
78
|
attributes[:rel] = "noopener" if attributes[:target] == "_blank" && !attributes[:rel]
|
79
|
+
|
80
|
+
unless attributes[:data][:ga4_link]
|
81
|
+
attributes[:data][:ga4_link] = layout_footer_helper.generate_ga4_link_attribute(index, navigation.length, "Support links")
|
82
|
+
end
|
71
83
|
%>
|
72
84
|
<%= link_to item[:text], item[:href], attributes %>
|
73
85
|
</li>
|
@@ -89,6 +101,19 @@
|
|
89
101
|
data-track-label="https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/"
|
90
102
|
data-track-options='{"dimension29": "Open Government Licence v3.0"}'
|
91
103
|
data-track-links-only
|
104
|
+
data-ga4-track-links-only
|
105
|
+
data-ga4-link="<%= {
|
106
|
+
"event_name": "navigation",
|
107
|
+
"section": "Licence",
|
108
|
+
"index": {
|
109
|
+
"index_section": layout_footer_helper.ga4_ogl_link_index_section.to_s,
|
110
|
+
"index_link": "1",
|
111
|
+
"index_section_count": layout_footer_helper.ga4_index_section_count.to_s,
|
112
|
+
},
|
113
|
+
"text": "Open Government Licence v3.0",
|
114
|
+
"index_total": layout_footer_helper.ga4_index_total.to_s,
|
115
|
+
"type": "footer",
|
116
|
+
}.to_json %>"
|
92
117
|
>
|
93
118
|
<%= t("components.layout_footer.licence_html") %>
|
94
119
|
</span>
|
@@ -102,6 +127,18 @@
|
|
102
127
|
data-track-label="https://www.nationalarchives.gov.uk/information-management/re-using-public-sector-information/uk-government-licensing-framework/crown-copyright/"
|
103
128
|
data-track-options='{"dimension29": "© Crown copyright"}'
|
104
129
|
data-track-links-only
|
130
|
+
data-ga4-link="<%= {
|
131
|
+
"event_name": "navigation",
|
132
|
+
"section": "Copyright",
|
133
|
+
"index": {
|
134
|
+
"index_section": layout_footer_helper.ga4_copyright_link_index_section.to_s,
|
135
|
+
"index_link": "1",
|
136
|
+
"index_section_count": layout_footer_helper.ga4_index_section_count.to_s,
|
137
|
+
},
|
138
|
+
"text": "© Crown copyright",
|
139
|
+
"index_total": layout_footer_helper.ga4_index_total.to_s,
|
140
|
+
"type": "footer",
|
141
|
+
}.to_json %>"
|
105
142
|
>
|
106
143
|
<%= t("components.layout_footer.copyright_html") %>
|
107
144
|
</div>
|
@@ -7,6 +7,7 @@ shared_accessibility_criteria:
|
|
7
7
|
- link
|
8
8
|
accessibility_excluded_rules:
|
9
9
|
- skip-link # This component is creating references to to sections on the page that do not exist in examples
|
10
|
+
uses_component_wrapper_helper: true
|
10
11
|
examples:
|
11
12
|
default:
|
12
13
|
data:
|
@@ -26,18 +27,6 @@ examples:
|
|
26
27
|
- text: Descriptive link to the question with an error 2
|
27
28
|
href: '#example-error-2'
|
28
29
|
- text: Description of error without link
|
29
|
-
with_data_attributes:
|
30
|
-
description: |
|
31
|
-
The example shown applies a tracking attribute specifically for use by Google Tag Manager in [Content Publisher](https://github.com/alphagov/content-publisher).
|
32
|
-
|
33
|
-
Other data attributes can also be applied as required. Note that the component does not include built in tracking. If this is required consider using the [track click script](https://github.com/alphagov/govuk_publishing_components/blob/main/docs/analytics/track-click.md).
|
34
|
-
data:
|
35
|
-
title: Message to alert the user to a problem goes here
|
36
|
-
description: Optional description of the errors and how to correct them
|
37
|
-
data_attributes:
|
38
|
-
tracking: GTM-123AB
|
39
|
-
items:
|
40
|
-
- text: Descriptive link to the question with an error 1
|
41
30
|
with_custom_target_on_links:
|
42
31
|
data:
|
43
32
|
title: Message to alert the user to a problem goes here
|
data/config/locales/en.yml
CHANGED
@@ -102,8 +102,6 @@ en:
|
|
102
102
|
href: "/browse/childcare-parenting"
|
103
103
|
- text: Citizenship and living in the UK
|
104
104
|
href: "/browse/citizenship"
|
105
|
-
- text: Cost of living support
|
106
|
-
href: "/cost-of-living"
|
107
105
|
- text: Crime, justice and the law
|
108
106
|
href: "/browse/justice"
|
109
107
|
- text: Disabled people
|
@@ -185,8 +183,6 @@ en:
|
|
185
183
|
href: "/browse/childcare-parenting"
|
186
184
|
- label: Citizenship and living in the UK
|
187
185
|
href: "/browse/citizenship"
|
188
|
-
- label: Cost of living support
|
189
|
-
href: "/cost-of-living"
|
190
186
|
- label: Crime, justice and the law
|
191
187
|
href: "/browse/justice"
|
192
188
|
- label: Disabled people
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module GovukPublishingComponents
|
2
|
+
module Presenters
|
3
|
+
class LayoutFooterHelper
|
4
|
+
attr_reader :ga4_index_total, :ga4_index_section_count, :ga4_ogl_link_index_section, :ga4_copyright_link_index_section
|
5
|
+
|
6
|
+
def initialize(footer_navigation_section, footer_meta_section)
|
7
|
+
@ga4_index_total = 0
|
8
|
+
@ga4_index_section_count = 0
|
9
|
+
@amount_of_meta_sections = 0
|
10
|
+
|
11
|
+
footer_navigation_section.each do |section|
|
12
|
+
@ga4_index_section_count += 1
|
13
|
+
if section[:items]
|
14
|
+
@ga4_index_total += section[:items].length
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
if footer_meta_section.any?
|
19
|
+
@amount_of_meta_sections = 1
|
20
|
+
@ga4_index_section_count += 1
|
21
|
+
@ga4_index_total += footer_meta_section[:items].length
|
22
|
+
end
|
23
|
+
|
24
|
+
# For our GOVUK footer links, we need to add 2 to the index_total and index_section_count. This is due to the "Open Government License" and "Crown Copyright" links being defined separately to the rest of our footer links.
|
25
|
+
@ga4_index_total += 2
|
26
|
+
@ga4_index_section_count += 2
|
27
|
+
|
28
|
+
@ga4_ogl_link_index_section = footer_navigation_section.length + @amount_of_meta_sections + 1
|
29
|
+
@ga4_copyright_link_index_section = footer_navigation_section.length + @amount_of_meta_sections + 2
|
30
|
+
end
|
31
|
+
|
32
|
+
def generate_ga4_link_attribute(index_link, index_section, section)
|
33
|
+
{
|
34
|
+
"event_name": "navigation",
|
35
|
+
"type": "footer",
|
36
|
+
"index": {
|
37
|
+
"index_link": (index_link + 1).to_s,
|
38
|
+
"index_section": (index_section + 1).to_s,
|
39
|
+
"index_section_count": @ga4_index_section_count.to_s,
|
40
|
+
},
|
41
|
+
"index-total": @ga4_index_total.to_s,
|
42
|
+
"section": section,
|
43
|
+
}
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -16,6 +16,7 @@ require "govuk_publishing_components/presenters/button_helper"
|
|
16
16
|
require "govuk_publishing_components/presenters/contextual_navigation"
|
17
17
|
require "govuk_publishing_components/presenters/devolved_nations_helper"
|
18
18
|
require "govuk_publishing_components/presenters/emergency_banner_helper"
|
19
|
+
require "govuk_publishing_components/presenters/layout_footer_helper"
|
19
20
|
require "govuk_publishing_components/presenters/related_navigation_helper"
|
20
21
|
require "govuk_publishing_components/presenters/step_by_step_nav_helper"
|
21
22
|
require "govuk_publishing_components/presenters/page_with_step_by_step_navigation"
|
@@ -43,8 +44,6 @@ require "govuk_publishing_components/app_helpers/brand_helper"
|
|
43
44
|
require "govuk_publishing_components/app_helpers/environment"
|
44
45
|
require "govuk_publishing_components/app_helpers/asset_helper"
|
45
46
|
|
46
|
-
require "govuk_publishing_components/railtie" if defined?(Rails::Railtie)
|
47
|
-
|
48
47
|
# Add i18n paths and views for usage outside of a Rails app
|
49
48
|
I18n.load_path.unshift(
|
50
49
|
*Dir.glob(File.expand_path("config/locales/*.yml", GovukPublishingComponents::Config.gem_directory)),
|
@@ -56,6 +55,10 @@ ActiveSupport.on_load(:action_controller) do
|
|
56
55
|
)
|
57
56
|
end
|
58
57
|
|
58
|
+
ActiveSupport.on_load(:action_view) do
|
59
|
+
include GovukPublishingComponents::AppHelpers::AssetHelper
|
60
|
+
end
|
61
|
+
|
59
62
|
module GovukPublishingComponents
|
60
63
|
def self.render(component, options = {})
|
61
64
|
I18n.with_locale(options.fetch(:locale, "en")) do
|
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.
|
4
|
+
version: 35.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: 2023-03-
|
11
|
+
date: 2023-03-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: govuk_app_config
|
@@ -934,6 +934,7 @@ files:
|
|
934
934
|
- lib/govuk_publishing_components/presenters/heading_helper.rb
|
935
935
|
- lib/govuk_publishing_components/presenters/image_card_helper.rb
|
936
936
|
- lib/govuk_publishing_components/presenters/intervention_helper.rb
|
937
|
+
- lib/govuk_publishing_components/presenters/layout_footer_helper.rb
|
937
938
|
- lib/govuk_publishing_components/presenters/machine_readable/article_schema.rb
|
938
939
|
- lib/govuk_publishing_components/presenters/machine_readable/creative_work_schema.rb
|
939
940
|
- lib/govuk_publishing_components/presenters/machine_readable/dataset_schema.rb
|
@@ -960,7 +961,6 @@ files:
|
|
960
961
|
- lib/govuk_publishing_components/presenters/step_by_step_nav_helper.rb
|
961
962
|
- lib/govuk_publishing_components/presenters/subscription_links_helper.rb
|
962
963
|
- lib/govuk_publishing_components/presenters/translation_nav_helper.rb
|
963
|
-
- lib/govuk_publishing_components/railtie.rb
|
964
964
|
- lib/govuk_publishing_components/version.rb
|
965
965
|
- node_modules/axe-core/LICENSE
|
966
966
|
- node_modules/axe-core/README.md
|
@@ -1415,7 +1415,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
1415
1415
|
- !ruby/object:Gem::Version
|
1416
1416
|
version: '0'
|
1417
1417
|
requirements: []
|
1418
|
-
rubygems_version: 3.4.
|
1418
|
+
rubygems_version: 3.4.9
|
1419
1419
|
signing_key:
|
1420
1420
|
specification_version: 4
|
1421
1421
|
summary: A gem to document components in GOV.UK frontend applications
|