govuk_publishing_components 35.11.0 → 35.13.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/javascripts/govuk_publishing_components/analytics-ga4/ga4-core.js +2 -48
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-form-tracker.js +5 -0
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-link-tracker.js +2 -2
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-schemas.js +51 -5
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-scroll-tracker.js +225 -0
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/init-ga4.js +0 -5
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4.js +1 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_document-list.scss +3 -1
- data/app/assets/stylesheets/govuk_publishing_components/components/_search.scss +8 -2
- data/app/controllers/govuk_publishing_components/audit_controller.rb +3 -2
- data/app/models/govuk_publishing_components/audit_applications.rb +3 -1
- data/app/models/govuk_publishing_components/audit_comparer.rb +1 -1
- data/app/models/govuk_publishing_components/audit_components.rb +3 -2
- data/app/models/govuk_publishing_components/component_wrapper_helper_options.rb +1 -0
- data/app/views/govuk_publishing_components/audit/_applications.html.erb +1 -1
- data/app/views/govuk_publishing_components/components/_attachment.html.erb +3 -1
- data/app/views/govuk_publishing_components/components/_document_list.html.erb +29 -27
- data/app/views/govuk_publishing_components/components/_heading.html.erb +8 -5
- data/app/views/govuk_publishing_components/components/_tabs.html.erb +30 -14
- data/app/views/govuk_publishing_components/components/docs/heading.yml +1 -4
- data/app/views/govuk_publishing_components/components/docs/single_page_notification_button.yml +1 -6
- data/app/views/govuk_publishing_components/components/docs/tabs.yml +26 -3
- data/lib/govuk_publishing_components/config.rb +3 -0
- data/lib/govuk_publishing_components/presenters/component_wrapper_helper.rb +17 -1
- data/lib/govuk_publishing_components/version.rb +1 -1
- data/node_modules/govuk-frontend/govuk/all.js +406 -1
- data/node_modules/govuk-frontend/govuk/all.js.map +1 -1
- data/node_modules/govuk-frontend/govuk/common/govuk-frontend-version.js +1 -1
- data/node_modules/govuk-frontend/govuk/components/_all.scss +2 -1
- data/node_modules/govuk-frontend/govuk/components/back-link/_index.scss +8 -0
- data/node_modules/govuk-frontend/govuk/components/back-link/fixtures.json +9 -0
- data/node_modules/govuk-frontend/govuk/components/breadcrumbs/_index.scss +12 -0
- data/node_modules/govuk-frontend/govuk/components/breadcrumbs/fixtures.json +21 -0
- data/node_modules/govuk-frontend/govuk/components/button/_index.scss +41 -3
- data/node_modules/govuk-frontend/govuk/components/button/fixtures.json +44 -0
- data/node_modules/govuk-frontend/govuk/components/checkboxes/macro-options.json +9 -8
- data/node_modules/govuk-frontend/govuk/components/exit-this-page/README.md +15 -0
- data/node_modules/govuk-frontend/govuk/components/exit-this-page/_exit-this-page.scss +2 -0
- data/node_modules/govuk-frontend/govuk/components/exit-this-page/_index.scss +97 -0
- data/node_modules/govuk-frontend/govuk/components/exit-this-page/exit-this-page.js +2120 -0
- data/node_modules/govuk-frontend/govuk/components/exit-this-page/exit-this-page.js.map +1 -0
- data/node_modules/govuk-frontend/govuk/components/exit-this-page/fixtures.json +50 -0
- data/node_modules/govuk-frontend/govuk/components/exit-this-page/macro-options.json +62 -0
- data/node_modules/govuk-frontend/govuk/components/exit-this-page/macro.njk +3 -0
- data/node_modules/govuk-frontend/govuk/components/exit-this-page/template.njk +16 -0
- data/node_modules/govuk-frontend/govuk/components/radios/macro-options.json +9 -8
- data/node_modules/govuk-frontend/govuk/core/_govuk-frontend-version.scss +1 -1
- data/node_modules/govuk-frontend/govuk/helpers/_visually-hidden.scss +12 -0
- data/node_modules/govuk-frontend/govuk/objects/_template.scss +20 -0
- data/node_modules/govuk-frontend/govuk-esm/all.mjs +8 -0
- data/node_modules/govuk-frontend/govuk-esm/all.mjs.map +1 -1
- data/node_modules/govuk-frontend/govuk-esm/common/govuk-frontend-version.mjs +1 -1
- data/node_modules/govuk-frontend/govuk-esm/components/exit-this-page/exit-this-page.mjs +406 -0
- data/node_modules/govuk-frontend/govuk-esm/components/exit-this-page/exit-this-page.mjs.map +1 -0
- data/node_modules/govuk-frontend/govuk-prototype-kit.config.json +4 -0
- data/node_modules/govuk-frontend/package.json +4 -2
- metadata +14 -2
@@ -29,35 +29,37 @@
|
|
29
29
|
<p class='gem-c-document-list__highlight-text'><%= item[:highlight_text] %></p>
|
30
30
|
<% end %>
|
31
31
|
|
32
|
-
<%=
|
33
|
-
|
32
|
+
<%= content_tag :div, class: "gem-c-document-list__item-title" do -%>
|
33
|
+
<%=
|
34
|
+
item_classes = "#{brand_helper.color_class} #{title_with_context_class if item[:link][:context]}"
|
34
35
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
36
|
+
if item[:link][:path]
|
37
|
+
rel = [
|
38
|
+
"external",
|
39
|
+
"nofollow",
|
40
|
+
"noopener",
|
41
|
+
"noreferrer",
|
42
|
+
"opener",
|
43
|
+
].include?(item[:link][:rel]) ? item[:link][:rel] : nil
|
43
44
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
45
|
+
link_to(
|
46
|
+
item[:link][:text],
|
47
|
+
item[:link][:path],
|
48
|
+
data: item[:link][:data_attributes],
|
49
|
+
class: "#{item_classes} govuk-link",
|
50
|
+
lang: item[:link][:locale].presence,
|
51
|
+
rel: rel,
|
52
|
+
)
|
53
|
+
else
|
54
|
+
content_tag(
|
55
|
+
"span",
|
56
|
+
item[:link][:text],
|
57
|
+
data: item[:link][:data_attributes],
|
58
|
+
class: item_classes,
|
59
|
+
)
|
60
|
+
end
|
61
|
+
%>
|
62
|
+
<% end %>
|
61
63
|
|
62
64
|
<% if item[:link][:context] %>
|
63
65
|
<span class="gem-c-document-list__item-context"><%= item[:link][:context] %></span>
|
@@ -7,15 +7,18 @@
|
|
7
7
|
brand_helper = GovukPublishingComponents::AppHelpers::BrandHelper.new(brand)
|
8
8
|
heading_helper = GovukPublishingComponents::Presenters::HeadingHelper.new(local_assigns)
|
9
9
|
shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)
|
10
|
+
component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
|
10
11
|
|
11
12
|
classes = %w(gem-c-heading)
|
12
13
|
classes << heading_helper.classes
|
13
14
|
classes << brand_helper.brand_class
|
14
15
|
classes << brand_helper.border_color_class
|
15
16
|
classes << shared_helper.get_margin_bottom if [*0..9].include?(local_assigns[:margin_bottom])
|
17
|
+
|
18
|
+
component_helper.add_class(classes.join(" "))
|
19
|
+
component_helper.set_id(heading_helper.id)
|
20
|
+
element = shared_helper.get_heading_level
|
16
21
|
%>
|
17
|
-
<%= content_tag(
|
18
|
-
|
19
|
-
|
20
|
-
lang: lang
|
21
|
-
) %>
|
22
|
+
<%= content_tag(element, component_helper.all_attributes) do %>
|
23
|
+
<%= text %>
|
24
|
+
<% end %>
|
@@ -7,22 +7,30 @@
|
|
7
7
|
panel_css_classes << "gem-c-tabs__panel--no-border" if panel_border == false
|
8
8
|
panel_css_classes = panel_css_classes.join(" ")
|
9
9
|
|
10
|
+
as_links ||= false
|
10
11
|
ga4_tracking ||= false
|
11
|
-
|
12
|
-
|
12
|
+
|
13
|
+
component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
|
14
|
+
component_helper.add_class("govuk-tabs gem-c-tabs")
|
15
|
+
component_helper.add_data_attribute({ module: "govuk-tabs" }) unless as_links
|
16
|
+
|
17
|
+
if ga4_tracking
|
18
|
+
component_helper.add_data_attribute({ module: "ga4-event-tracker" }) unless as_links
|
19
|
+
component_helper.add_data_attribute({ module: "ga4-link-tracker" }) if as_links
|
20
|
+
end
|
13
21
|
%>
|
14
22
|
<% if tabs.count > 1 %>
|
15
|
-
|
23
|
+
<%= tag.div(**component_helper.all_attributes) do %>
|
16
24
|
<h2 class="govuk-tabs__title">
|
17
25
|
<%= t("components.tabs.contents") %>
|
18
26
|
</h2>
|
19
27
|
<ul class="govuk-tabs__list">
|
20
28
|
<% tabs.each_with_index do |tab, index| %>
|
21
|
-
<li class="govuk-tabs__list-item">
|
29
|
+
<li class="govuk-tabs__list-item <%= "govuk-tabs__list-item--selected" if tab[:active] %>">
|
22
30
|
<%
|
23
31
|
tab[:tab_data_attributes] ||= {}
|
24
32
|
if ga4_tracking
|
25
|
-
|
33
|
+
ga4_attributes = {
|
26
34
|
event_name: "select_content",
|
27
35
|
type: "tabs",
|
28
36
|
text: tab[:label],
|
@@ -31,24 +39,32 @@
|
|
31
39
|
index_section_count: tabs.length,
|
32
40
|
},
|
33
41
|
}
|
42
|
+
ga4_attributes[:event_name] = "navigation" if as_links
|
43
|
+
tab[:tab_data_attributes][:ga4_link] = ga4_attributes if as_links
|
44
|
+
tab[:tab_data_attributes][:ga4_event] = ga4_attributes unless as_links
|
34
45
|
end
|
46
|
+
|
47
|
+
tab_link = "##{tab[:id]}"
|
48
|
+
tab_link = tab[:href] if as_links
|
35
49
|
%>
|
36
50
|
<%= link_to(tab[:label],
|
37
|
-
|
51
|
+
tab_link,
|
38
52
|
class: "govuk-tabs__tab",
|
39
53
|
data: tab[:tab_data_attributes]) %>
|
40
54
|
</li>
|
41
55
|
<% end %>
|
42
56
|
</ul>
|
43
|
-
<%
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
57
|
+
<% unless as_links %>
|
58
|
+
<% tabs.each do |tab| %>
|
59
|
+
<section class="<%= panel_css_classes %>" id="<%= tab[:id] %>">
|
60
|
+
<% if tab[:title] %>
|
61
|
+
<h2 class="govuk-heading-l"><%= tab[:title] %></h2>
|
62
|
+
<% end %>
|
63
|
+
<%= tab[:content] %>
|
64
|
+
</section>
|
65
|
+
<% end %>
|
50
66
|
<% end %>
|
51
|
-
|
67
|
+
<% end %>
|
52
68
|
<% end %>
|
53
69
|
<% if tabs.count == 1 %>
|
54
70
|
<section id="<%= tabs[0][:id] %>">
|
@@ -15,6 +15,7 @@ accessibility_criteria: |
|
|
15
15
|
- be part of a correct heading structure for a page
|
16
16
|
- be semantically represented as a heading
|
17
17
|
- convey the heading level
|
18
|
+
uses_component_wrapper_helper: true
|
18
19
|
examples:
|
19
20
|
default:
|
20
21
|
data:
|
@@ -31,10 +32,6 @@ examples:
|
|
31
32
|
data:
|
32
33
|
text: 'One big heading'
|
33
34
|
font_size: "xl"
|
34
|
-
with_id_attribute:
|
35
|
-
data:
|
36
|
-
text: 'Detail of outcome'
|
37
|
-
id: 'detail_of_outcome'
|
38
35
|
right_to_left:
|
39
36
|
data:
|
40
37
|
text: 'مستندات'
|
data/app/views/govuk_publishing_components/components/docs/single_page_notification_button.yml
CHANGED
@@ -9,6 +9,7 @@ body: |
|
|
9
9
|
When the button is clicked, the `base_path` is submitted to an endpoint which proceeds to check the user's authentication status and whether they are already subscribed to the page or not. Depending on these factors, they will be routed accordingly.
|
10
10
|
accessibility_criteria: |
|
11
11
|
- The bell icon must be presentational and ignored by screen readers.
|
12
|
+
uses_component_wrapper_helper: true
|
12
13
|
examples:
|
13
14
|
default:
|
14
15
|
description: By default this component prompts the user to subscribe to email notifications to this page.
|
@@ -19,12 +20,6 @@ examples:
|
|
19
20
|
data:
|
20
21
|
base_path: '/current-page-path'
|
21
22
|
already_subscribed: true
|
22
|
-
with_data_attributes:
|
23
|
-
description: The component accepts data attributes (for example, for analytics)
|
24
|
-
data:
|
25
|
-
base_path: '/current-page-path'
|
26
|
-
data_attributes:
|
27
|
-
test_attribute: "testing"
|
28
23
|
with_ga4_tracking:
|
29
24
|
description: To add GA4 tracking, pass a `ga4_data_attributes` object with the necessary properties to the component. For example:-
|
30
25
|
data:
|
@@ -17,7 +17,7 @@ accessibility_criteria: |
|
|
17
17
|
* be usable with touch
|
18
18
|
* be usable with voice commands
|
19
19
|
* have visible text
|
20
|
-
|
20
|
+
uses_component_wrapper_helper: true
|
21
21
|
examples:
|
22
22
|
default:
|
23
23
|
data:
|
@@ -30,6 +30,17 @@ examples:
|
|
30
30
|
label: "Second section"
|
31
31
|
content: |
|
32
32
|
<p class="govuk-body-m">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam congue elementum commodo. Vestibulum elit turpis, efficitur quis posuere vitae, commodo vitae augue. Donec ut pharetra ligula. Phasellus ac mauris eu felis bibendum dapibus rutrum sed quam. Pellentesque posuere ante id consequat pretium.</p>
|
33
|
+
as_links:
|
34
|
+
description: With this option the tabs operate as links, rather than switching between elements within a single page.
|
35
|
+
data:
|
36
|
+
as_links: true
|
37
|
+
tabs:
|
38
|
+
- href: "link1"
|
39
|
+
label: "Page one"
|
40
|
+
active: true
|
41
|
+
- href: "link2"
|
42
|
+
label: "Page two"
|
43
|
+
active: false
|
33
44
|
without_panel_border:
|
34
45
|
data:
|
35
46
|
panel_border: false
|
@@ -84,8 +95,8 @@ examples:
|
|
84
95
|
tracking: GTM-123AB
|
85
96
|
content: |
|
86
97
|
<p class="govuk-body-m">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam congue elementum commodo. Vestibulum elit turpis, efficitur quis posuere vitae, commodo vitae augue. Donec ut pharetra ligula. Phasellus ac mauris eu felis bibendum dapibus rutrum sed quam. Pellentesque posuere ante id consequat pretium.</p>
|
87
|
-
|
88
|
-
description: Enables GA4 tracking
|
98
|
+
with_ga4_tracking_on_tabs:
|
99
|
+
description: Enables GA4 tracking by adding the event tracker and required data attributes to the tabs. See the [ga4-event-tracker documentation](https://github.com/alphagov/govuk_publishing_components/blob/main/docs/analytics-ga4/ga4-event-tracker.md) for more information.
|
89
100
|
data:
|
90
101
|
ga4_tracking: true
|
91
102
|
tabs:
|
@@ -99,3 +110,15 @@ examples:
|
|
99
110
|
title: "Second section"
|
100
111
|
content: |
|
101
112
|
<p class="govuk-body-m">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam congue elementum commodo. Vestibulum elit turpis, efficitur quis posuere vitae, commodo vitae augue. Donec ut pharetra ligula. Phasellus ac mauris eu felis bibendum dapibus rutrum sed quam. Pellentesque posuere ante id consequat pretium.</p>
|
113
|
+
with_ga4_tracking_on_tabs_as_links:
|
114
|
+
description: Enables GA4 tracking by adding the link tracker and required data attributes to the tabs. See the [ga4-link-tracker documentation](https://github.com/alphagov/govuk_publishing_components/blob/main/docs/analytics-ga4/ga4-link-tracker.md) for more information.
|
115
|
+
data:
|
116
|
+
as_links: true
|
117
|
+
ga4_tracking: true
|
118
|
+
tabs:
|
119
|
+
- href: "/page1"
|
120
|
+
label: "Link 1"
|
121
|
+
active: true
|
122
|
+
- href: "/page2"
|
123
|
+
label: "Link 2"
|
124
|
+
active: false
|
@@ -9,6 +9,9 @@ module GovukPublishingComponents
|
|
9
9
|
mattr_accessor :component_guide_title
|
10
10
|
self.component_guide_title = "Component Guide"
|
11
11
|
|
12
|
+
mattr_accessor :application_dir
|
13
|
+
self.application_dir = ""
|
14
|
+
|
12
15
|
mattr_accessor :application_stylesheet
|
13
16
|
self.application_stylesheet = "application"
|
14
17
|
|
@@ -9,6 +9,7 @@ module GovukPublishingComponents
|
|
9
9
|
check_classes_are_valid(@options[:classes]) if @options.include?(:classes)
|
10
10
|
check_aria_is_valid(@options[:aria]) if @options.include?(:aria)
|
11
11
|
check_role_is_valid(@options[:role]) if @options.include?(:role)
|
12
|
+
check_lang_is_valid(@options[:lang]) if @options.include?(:lang)
|
12
13
|
end
|
13
14
|
|
14
15
|
def all_attributes
|
@@ -19,6 +20,7 @@ module GovukPublishingComponents
|
|
19
20
|
attributes[:aria] = @options[:aria] unless @options[:aria].blank?
|
20
21
|
attributes[:class] = @options[:classes] unless @options[:classes].blank?
|
21
22
|
attributes[:role] = @options[:role] unless @options[:role].blank?
|
23
|
+
attributes[:lang] = @options[:lang] unless @options[:lang].blank?
|
22
24
|
|
23
25
|
attributes
|
24
26
|
end
|
@@ -48,6 +50,11 @@ module GovukPublishingComponents
|
|
48
50
|
extend_string(:role, role)
|
49
51
|
end
|
50
52
|
|
53
|
+
def set_lang(lang)
|
54
|
+
check_lang_is_valid(lang)
|
55
|
+
@options[:lang] = lang
|
56
|
+
end
|
57
|
+
|
51
58
|
private
|
52
59
|
|
53
60
|
def check_id_is_valid(id)
|
@@ -69,7 +76,7 @@ module GovukPublishingComponents
|
|
69
76
|
return if classes.blank?
|
70
77
|
|
71
78
|
class_array = classes.split(" ")
|
72
|
-
unless class_array.all? { |c| c.start_with?("js-", "gem-c-", "govuk-", "brand--") }
|
79
|
+
unless class_array.all? { |c| c.start_with?("js-", "gem-c-", "govuk-", "brand--", "brand__") }
|
73
80
|
raise(ArgumentError, "Classes (#{classes}) must be prefixed with `js-`")
|
74
81
|
end
|
75
82
|
end
|
@@ -98,6 +105,15 @@ module GovukPublishingComponents
|
|
98
105
|
end
|
99
106
|
end
|
100
107
|
|
108
|
+
def check_lang_is_valid(lang)
|
109
|
+
return if lang.blank?
|
110
|
+
|
111
|
+
langs = %w[ab aa af ak sq am ar an hy as av ae ay az bm ba eu be bn bh bi bs br bg my ca ch ce ny zh zh-Hans zh-Hant cv kw co cr hr cs da dv nl dz en eo et ee fo fj fi fr ff gl gd gv ka de el kl gn gu ht ha he hz hi ho hu is io ig id in ia ie iu ik ga it ja jv kl kn kr ks kk km ki rw rn ky kv kg ko ku kj lo la lv li ln lt lu lg lb gv mk mg ms ml mt mi mr mh mo mn na nv ng nd ne no nb nn ii oc oj cu or om os pi ps fa pl pt pa qu rm ro ru se sm sg sa sr sh st tn sn ii sd si ss sk sl so nr es su sw ss sv tl ty tg ta tt te th bo ti to ts tr tk tw ug uk ur uz ve vi vo wa cy wo fy xh yi ji yo za zu]
|
112
|
+
unless langs.include? lang
|
113
|
+
raise(ArgumentError, "lang attribute (#{lang}) is not recognised")
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
101
117
|
def extend_string(option, string)
|
102
118
|
((@options[option] ||= "") << " #{string}").strip!
|
103
119
|
end
|