govuk_publishing_components 62.3.0 → 63.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/assets/stylesheets/govuk_publishing_components/_all_components.scss +1 -1
- data/app/assets/stylesheets/govuk_publishing_components/components/_image-card.scss +0 -47
- data/app/views/govuk_publishing_components/components/_image_card.html.erb +0 -1
- data/app/views/govuk_publishing_components/components/_layout_for_public.html.erb +15 -9
- data/app/views/govuk_publishing_components/components/_pagination.html.erb +40 -0
- data/app/views/govuk_publishing_components/components/docs/image_card.yml +0 -23
- data/app/views/govuk_publishing_components/components/docs/{previous_and_next_navigation.yml → pagination.yml} +68 -13
- data/config/locales/ar.yml +1 -1
- data/config/locales/az.yml +1 -1
- data/config/locales/be.yml +1 -1
- data/config/locales/bg.yml +1 -1
- data/config/locales/bn.yml +1 -1
- data/config/locales/cs.yml +1 -1
- data/config/locales/cy.yml +2 -2
- data/config/locales/da.yml +1 -1
- data/config/locales/de.yml +1 -1
- data/config/locales/dr.yml +1 -1
- data/config/locales/el.yml +1 -1
- data/config/locales/en.yml +1 -1
- data/config/locales/es-419.yml +1 -1
- data/config/locales/es.yml +1 -1
- data/config/locales/et.yml +1 -1
- data/config/locales/fa.yml +1 -1
- data/config/locales/fi.yml +1 -1
- data/config/locales/fr.yml +1 -1
- data/config/locales/gd.yml +1 -1
- data/config/locales/gu.yml +1 -1
- data/config/locales/he.yml +1 -1
- data/config/locales/hi.yml +1 -1
- data/config/locales/hr.yml +1 -1
- data/config/locales/hu.yml +1 -1
- data/config/locales/hy.yml +1 -1
- data/config/locales/id.yml +1 -1
- data/config/locales/is.yml +1 -1
- data/config/locales/it.yml +1 -1
- data/config/locales/ja.yml +1 -1
- data/config/locales/ka.yml +1 -1
- data/config/locales/kk.yml +1 -1
- data/config/locales/ko.yml +1 -1
- data/config/locales/ku.yml +1 -1
- data/config/locales/ky.yml +1 -1
- data/config/locales/lt.yml +1 -1
- data/config/locales/lv.yml +1 -1
- data/config/locales/ms.yml +1 -1
- data/config/locales/mt.yml +1 -1
- data/config/locales/ne.yml +1 -1
- data/config/locales/nl.yml +1 -1
- data/config/locales/no.yml +1 -1
- data/config/locales/pa-pk.yml +1 -1
- data/config/locales/pa.yml +1 -1
- data/config/locales/pl.yml +1 -1
- data/config/locales/ps.yml +1 -1
- data/config/locales/pt.yml +1 -1
- data/config/locales/ro.yml +1 -1
- data/config/locales/ru.yml +1 -1
- data/config/locales/si.yml +1 -1
- data/config/locales/sk.yml +1 -1
- data/config/locales/sl.yml +1 -1
- data/config/locales/so.yml +1 -1
- data/config/locales/sq.yml +1 -1
- data/config/locales/sr.yml +1 -1
- data/config/locales/sv.yml +1 -1
- data/config/locales/sw.yml +1 -1
- data/config/locales/ta.yml +1 -1
- data/config/locales/th.yml +1 -1
- data/config/locales/ti.yml +1 -1
- data/config/locales/tk.yml +1 -1
- data/config/locales/tr.yml +1 -1
- data/config/locales/uk.yml +1 -1
- data/config/locales/ur.yml +1 -1
- data/config/locales/uz.yml +1 -1
- data/config/locales/vi.yml +1 -1
- data/config/locales/zh-hk.yml +1 -1
- data/config/locales/zh-tw.yml +1 -1
- data/config/locales/zh.yml +1 -1
- data/lib/govuk_publishing_components/presenters/component_wrapper_helper.rb +3 -0
- data/lib/govuk_publishing_components/presenters/image_card_helper.rb +1 -56
- data/lib/govuk_publishing_components/presenters/pagination_helper.rb +106 -0
- data/lib/govuk_publishing_components/version.rb +1 -1
- data/lib/govuk_publishing_components.rb +1 -0
- metadata +5 -7
- data/app/assets/images/govuk_publishing_components/youtube-play-icon.png +0 -0
- data/app/assets/images/govuk_publishing_components/youtube-play-icon.svg +0 -4
- data/app/assets/javascripts/govuk_publishing_components/components/image-card.js +0 -19
- data/app/views/govuk_publishing_components/components/_previous_and_next_navigation.html.erb +0 -73
- /data/app/assets/stylesheets/govuk_publishing_components/components/{_previous-and-next-navigation.scss → _pagination.scss} +0 -0
data/config/locales/kk.yml
CHANGED
data/config/locales/ko.yml
CHANGED
data/config/locales/ku.yml
CHANGED
|
@@ -162,7 +162,7 @@ ku:
|
|
|
162
162
|
label: ووشەی نهێنی
|
|
163
163
|
password_hidden_announcement: وشەی نهێنی تۆ شاراوەتەوە
|
|
164
164
|
password_shown_announcement: وشەی نهێنی تۆ دیارە
|
|
165
|
-
|
|
165
|
+
pagination:
|
|
166
166
|
next: داهاتوو
|
|
167
167
|
pagination: لاپەڕەسازی
|
|
168
168
|
previous: پێشووتر
|
data/config/locales/ky.yml
CHANGED
data/config/locales/lt.yml
CHANGED
data/config/locales/lv.yml
CHANGED
data/config/locales/ms.yml
CHANGED
data/config/locales/mt.yml
CHANGED
data/config/locales/ne.yml
CHANGED
data/config/locales/nl.yml
CHANGED
data/config/locales/no.yml
CHANGED
data/config/locales/pa-pk.yml
CHANGED
data/config/locales/pa.yml
CHANGED
data/config/locales/pl.yml
CHANGED
data/config/locales/ps.yml
CHANGED
data/config/locales/pt.yml
CHANGED
data/config/locales/ro.yml
CHANGED
data/config/locales/ru.yml
CHANGED
data/config/locales/si.yml
CHANGED
data/config/locales/sk.yml
CHANGED
data/config/locales/sl.yml
CHANGED
data/config/locales/so.yml
CHANGED
data/config/locales/sq.yml
CHANGED
data/config/locales/sr.yml
CHANGED
data/config/locales/sv.yml
CHANGED
data/config/locales/sw.yml
CHANGED
data/config/locales/ta.yml
CHANGED
data/config/locales/th.yml
CHANGED
data/config/locales/ti.yml
CHANGED
data/config/locales/tk.yml
CHANGED
data/config/locales/tr.yml
CHANGED
data/config/locales/uk.yml
CHANGED
data/config/locales/ur.yml
CHANGED
data/config/locales/uz.yml
CHANGED
data/config/locales/vi.yml
CHANGED
data/config/locales/zh-hk.yml
CHANGED
data/config/locales/zh-tw.yml
CHANGED
data/config/locales/zh.yml
CHANGED
|
@@ -184,6 +184,9 @@ module GovukPublishingComponents
|
|
|
184
184
|
return if lang.blank?
|
|
185
185
|
|
|
186
186
|
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 zh-hk zh-tw cv kw co cr hr cs da dv nl dz dr 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 pa-pk qu rm ro ru se sm sg sa sr sh st tn sn ii sd si ss sk sl so nr es es-419 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]
|
|
187
|
+
|
|
188
|
+
lang = lang.to_s
|
|
189
|
+
|
|
187
190
|
unless langs.include? lang
|
|
188
191
|
raise(ArgumentError, "lang attribute (#{lang}) is not recognised")
|
|
189
192
|
end
|
|
@@ -4,14 +4,13 @@ module GovukPublishingComponents
|
|
|
4
4
|
include ActionView::Helpers
|
|
5
5
|
include ActionView::Context
|
|
6
6
|
|
|
7
|
-
attr_reader :extra_details, :extra_details_no_indent, :heading_text, :metadata, :lang, :image_loading, :
|
|
7
|
+
attr_reader :href, :large, :extra_details, :extra_details_no_indent, :heading_text, :metadata, :lang, :image_loading, :image_src, :two_thirds, :large_font_size_mobile
|
|
8
8
|
|
|
9
9
|
def initialize(local_assigns, brand_helper)
|
|
10
10
|
@href = local_assigns[:href]
|
|
11
11
|
@extra_details = local_assigns[:extra_details] || []
|
|
12
12
|
@image_src = local_assigns[:image_src]
|
|
13
13
|
@image_alt = local_assigns[:image_alt] || ""
|
|
14
|
-
@youtube_video_alt = local_assigns[:youtube_video_alt]
|
|
15
14
|
@image_loading = local_assigns[:image_loading] || "auto"
|
|
16
15
|
@srcset = local_assigns[:srcset] || nil
|
|
17
16
|
@sizes = local_assigns[:sizes] || nil
|
|
@@ -25,24 +24,10 @@ module GovukPublishingComponents
|
|
|
25
24
|
@extra_details_no_indent = local_assigns[:extra_details_no_indent]
|
|
26
25
|
@metadata = local_assigns[:metadata]
|
|
27
26
|
@lang = local_assigns[:lang]
|
|
28
|
-
@youtube_video_id = local_assigns[:youtube_video_id] || nil
|
|
29
27
|
|
|
30
28
|
@brand_helper = brand_helper
|
|
31
29
|
end
|
|
32
30
|
|
|
33
|
-
def href
|
|
34
|
-
return youtube_href if @youtube_video_id
|
|
35
|
-
|
|
36
|
-
@href
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
def large
|
|
40
|
-
# if youtube video, we don't want to use
|
|
41
|
-
# the small variant, large will be always
|
|
42
|
-
# true if a youtube_video_id is supplied
|
|
43
|
-
@youtube_video_id || @large
|
|
44
|
-
end
|
|
45
|
-
|
|
46
31
|
def large_mobile_font_size?
|
|
47
32
|
# allow the font-size to be 19px on mobile
|
|
48
33
|
# for the two-thirds varation of the
|
|
@@ -51,8 +36,6 @@ module GovukPublishingComponents
|
|
|
51
36
|
end
|
|
52
37
|
|
|
53
38
|
def media
|
|
54
|
-
return youtube_link if @youtube_video_id
|
|
55
|
-
|
|
56
39
|
image
|
|
57
40
|
end
|
|
58
41
|
|
|
@@ -103,44 +86,6 @@ module GovukPublishingComponents
|
|
|
103
86
|
|
|
104
87
|
content_tag(:div, @description, class: "gem-c-image-card__description") if @description
|
|
105
88
|
end
|
|
106
|
-
|
|
107
|
-
def youtube_href
|
|
108
|
-
"https://www.youtube.com/watch?v=#{@youtube_video_id}"
|
|
109
|
-
end
|
|
110
|
-
|
|
111
|
-
def youtube_thumbnail_url
|
|
112
|
-
"https://img.youtube.com/vi/#{@youtube_video_id}/maxresdefault.jpg"
|
|
113
|
-
end
|
|
114
|
-
|
|
115
|
-
def youtube_thumbnail
|
|
116
|
-
thumbnail = content_tag(:div, class: "gem-c-image-card__youtube-thumbnail-image-container") do
|
|
117
|
-
image_tag(
|
|
118
|
-
youtube_thumbnail_url,
|
|
119
|
-
class: "gem-c-image-card__image gem-c-image-card__youtube-thumbnail-image",
|
|
120
|
-
alt: "",
|
|
121
|
-
loading: @image_loading,
|
|
122
|
-
)
|
|
123
|
-
end
|
|
124
|
-
thumbnail + content_tag(:figcaption, @youtube_video_alt, class: "gem-c-image-card__youtube-thumbnail-container-text govuk-link #{@brand_helper.color_class}")
|
|
125
|
-
end
|
|
126
|
-
|
|
127
|
-
def youtube_link
|
|
128
|
-
content_tag(
|
|
129
|
-
:figure,
|
|
130
|
-
class: "gem-c-image-card__image-wrapper gem-c-image-card__image-wrapper--youtube-embed",
|
|
131
|
-
) do
|
|
132
|
-
content_tag(:div) do
|
|
133
|
-
link_to(
|
|
134
|
-
href,
|
|
135
|
-
{
|
|
136
|
-
class: "govuk-body govuk-link gem-c-image-card__youtube-thumbnail-container js-youtube-card-embed",
|
|
137
|
-
},
|
|
138
|
-
) do
|
|
139
|
-
youtube_thumbnail
|
|
140
|
-
end
|
|
141
|
-
end
|
|
142
|
-
end
|
|
143
|
-
end
|
|
144
89
|
end
|
|
145
90
|
end
|
|
146
91
|
end
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
module GovukPublishingComponents
|
|
2
|
+
module Presenters
|
|
3
|
+
class PaginationHelper
|
|
4
|
+
include ActionView::Helpers
|
|
5
|
+
include ActionView::Context
|
|
6
|
+
|
|
7
|
+
attr_reader :prev_link, :next_link, :page_links, :ga4_type
|
|
8
|
+
|
|
9
|
+
def initialize(local_assigns)
|
|
10
|
+
@arrow_links = {
|
|
11
|
+
next: local_assigns[:next_page] || nil,
|
|
12
|
+
prev: local_assigns[:previous_page] || nil,
|
|
13
|
+
}
|
|
14
|
+
@items = local_assigns[:items] || nil
|
|
15
|
+
|
|
16
|
+
@disable_ga4 = local_assigns[:disable_ga4] || nil
|
|
17
|
+
@ga4_type = has_pages? ? "pagination" : "previous and next"
|
|
18
|
+
@prev_link = arrow_link_helper(direction: "prev")
|
|
19
|
+
@next_link = arrow_link_helper(direction: "next")
|
|
20
|
+
@page_links = pages_link_helper
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def ga4_link_event(text:, section:)
|
|
24
|
+
unless @disable_ga4
|
|
25
|
+
{
|
|
26
|
+
event_name: "navigation",
|
|
27
|
+
type: @ga4_type,
|
|
28
|
+
text:,
|
|
29
|
+
section:,
|
|
30
|
+
}.to_json
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def has_links?
|
|
35
|
+
has_pages? || @prev_link || @next_link
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def has_pages?
|
|
39
|
+
@items.present?
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def pages_link_helper
|
|
43
|
+
return unless has_pages?
|
|
44
|
+
|
|
45
|
+
page_links = @items.each_with_index.map do |item, index|
|
|
46
|
+
{ href: nil, ellipsis: nil, current: nil, number: nil, visually_hidden_text: nil, **item.symbolize_keys } => { href:, ellipsis:, current:, number:, visually_hidden_text: }
|
|
47
|
+
|
|
48
|
+
raise ArgumentError, "Number or ellipsis value required for item #{index}" if ellipsis.blank? && number.blank?
|
|
49
|
+
|
|
50
|
+
list_item_classes = %w[govuk-pagination__item]
|
|
51
|
+
list_item_classes << "govuk-pagination__item--ellipsis" if ellipsis
|
|
52
|
+
list_item_classes << "govuk-pagination__item--current" if current
|
|
53
|
+
|
|
54
|
+
item_aria_label = visually_hidden_text || "Page #{number}"
|
|
55
|
+
|
|
56
|
+
ga4_link = ga4_link_event(text: number, section: "Pagination list")
|
|
57
|
+
|
|
58
|
+
content_tag(:li, class: list_item_classes) do
|
|
59
|
+
if ellipsis
|
|
60
|
+
"⋯".html_safe
|
|
61
|
+
else
|
|
62
|
+
content_tag(:a, number, class: "govuk-link govuk-pagination__link", href:, aria: { label: item_aria_label, current: current ? "page" : nil }, data: { ga4_link: })
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
content_tag(:ul, class: "govuk-pagination__list") do
|
|
68
|
+
page_links.collect { |page_link| concat(page_link) }
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def arrow_link_helper(direction:)
|
|
73
|
+
arrow_link_options = @arrow_links[direction.to_sym]
|
|
74
|
+
|
|
75
|
+
return if arrow_link_options.blank?
|
|
76
|
+
|
|
77
|
+
{ href: nil, label: nil, title: nil, icon: nil, **arrow_link_options.symbolize_keys } => { href:, label:, title:, icon: }
|
|
78
|
+
|
|
79
|
+
title ||= {
|
|
80
|
+
"prev": t("components.pagination.previous"),
|
|
81
|
+
"next": t("components.pagination.next"),
|
|
82
|
+
}[direction.to_sym]
|
|
83
|
+
|
|
84
|
+
section = {
|
|
85
|
+
prev: "Previous",
|
|
86
|
+
next: "Next",
|
|
87
|
+
}[direction.to_sym]
|
|
88
|
+
|
|
89
|
+
ga4_link = ga4_link_event(text: label || title, section:)
|
|
90
|
+
|
|
91
|
+
link_text_classes = %w[govuk-pagination__link-title]
|
|
92
|
+
link_text_classes << "govuk-pagination__link-title--decorated" if label.blank?
|
|
93
|
+
|
|
94
|
+
content_tag(:div, class: "govuk-pagination__#{direction}") do
|
|
95
|
+
content_tag(:a, href:, class: "govuk-link govuk-pagination__link", data: { ga4_link: }) do
|
|
96
|
+
concat icon if direction == "prev" || !has_pages? && direction == "next"
|
|
97
|
+
concat content_tag(:span, title, class: link_text_classes)
|
|
98
|
+
concat icon if has_pages? && direction == "next"
|
|
99
|
+
concat content_tag(:span, ":", class: "govuk-visually-hidden") if label.present?
|
|
100
|
+
concat content_tag(:span, label, class: "govuk-pagination__link-label") if label.present?
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
end
|
|
@@ -39,6 +39,7 @@ require "govuk_publishing_components/presenters/image_card_helper"
|
|
|
39
39
|
require "govuk_publishing_components/presenters/intervention_helper"
|
|
40
40
|
require "govuk_publishing_components/presenters/organisation_logo_helper"
|
|
41
41
|
require "govuk_publishing_components/presenters/single_page_notification_button_helper"
|
|
42
|
+
require "govuk_publishing_components/presenters/pagination_helper"
|
|
42
43
|
|
|
43
44
|
require "govuk_publishing_components/app_helpers/taxon_breadcrumbs"
|
|
44
45
|
require "govuk_publishing_components/app_helpers/table_helper"
|