govuk_publishing_components 39.1.0 → 39.2.1
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/components/cookie-banner.js +0 -3
- data/app/assets/javascripts/govuk_publishing_components/load-analytics.js +0 -4
- data/app/assets/javascripts/govuk_publishing_components/vendor/lux/lux-reporter.js +637 -328
- data/app/views/govuk_publishing_components/components/_contents_list.html.erb +1 -1
- data/app/views/govuk_publishing_components/components/docs/contents_list.yml +1 -1
- data/lib/govuk_publishing_components/presenters/contents_list_helper.rb +14 -7
- data/lib/govuk_publishing_components/version.rb +1 -1
- metadata +2 -2
@@ -42,7 +42,7 @@
|
|
42
42
|
<% contents.each.with_index(1) do |contents_item, position| %>
|
43
43
|
<li class="<%= cl_helper.list_item_classes(contents_item, false) %>" <%= "aria-current=true" if contents_item[:active] %>>
|
44
44
|
<span aria-hidden="true"></span>
|
45
|
-
<% link_text = format_numbers ? cl_helper.wrap_numbers_with_spans(contents_item[:text]) : contents_item[:text]
|
45
|
+
<% link_text = format_numbers ? cl_helper.wrap_numbers_with_spans(contents_item[:text]) : cl_helper.clean_string(contents_item[:text])
|
46
46
|
unless disable_ga4
|
47
47
|
ga4_data[:event_name] = cl_helper.get_ga4_event_name(contents_item[:href]) if contents_item[:href]
|
48
48
|
ga4_data[:index_link] = index_link
|
@@ -22,24 +22,31 @@ module GovukPublishingComponents
|
|
22
22
|
list_item_classes
|
23
23
|
end
|
24
24
|
|
25
|
-
def wrap_numbers_with_spans(
|
26
|
-
|
27
|
-
content_item_text_stripped = content_item_text.strip # strip trailing spaces for the regex. Keep original content_item_text for the string replacement.
|
25
|
+
def wrap_numbers_with_spans(link_text)
|
26
|
+
output = clean_string(link_text)
|
28
27
|
# Must start with a number
|
29
28
|
# Number must be between 1 and 999 (ie not 2014)
|
30
29
|
# Must be followed by a space
|
31
30
|
# May contain a period `1.`
|
32
31
|
# May be a decimal `1.2`
|
33
|
-
number = /^\d{1,3}(\.?|\.\d{1,2})(?=\s)/.match(
|
32
|
+
number = /^\d{1,3}(\.?|\.\d{1,2})(?=\s)/.match(output)
|
34
33
|
|
35
34
|
if number
|
36
|
-
words =
|
37
|
-
|
35
|
+
words = output.sub(number.to_s, "").strip # remove the number from the text
|
36
|
+
# the space in the first span is needed for screen readers
|
37
|
+
"<span class=\"gem-c-contents-list__number\">#{number} </span><span class=\"gem-c-contents-list__numbered-text\">#{words}</span>".squish.html_safe
|
38
38
|
else
|
39
|
-
|
39
|
+
output
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
+
def clean_string(text)
|
44
|
+
text = text.gsub(/ /, " ")
|
45
|
+
text = text.gsub("/\u00a0/", " ")
|
46
|
+
text = text.gsub(160.chr("UTF-8"), " ")
|
47
|
+
strip_tags(text.tr("\n", "")).strip
|
48
|
+
end
|
49
|
+
|
43
50
|
def get_index_total
|
44
51
|
total = @contents.length
|
45
52
|
@contents.each do |parent|
|
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: 39.1
|
4
|
+
version: 39.2.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: 2024-
|
11
|
+
date: 2024-07-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: govuk_app_config
|