govuk_publishing_components 18.0.1 → 18.1.0

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: e7ac861a8149611a3195f191382f8847a3716d257a7641d6ca36c5416df83379
4
- data.tar.gz: b396032eb52b0846f2c4826e723212fa939ffbe03e8ddc0d3958b571fe55906d
3
+ metadata.gz: 0aea274f30d9c743a631169bf2e4793b3887a3479d0b48ef928ae9b6654483da
4
+ data.tar.gz: 994fe267ee6273b160defdc4f124c78773956147e3021f98b952b79db1483ecd
5
5
  SHA512:
6
- metadata.gz: 9ed1d1a8e80cee99f8bd3386422d0302f9615ee654c5ebcd3144b0d75ac7407b347dec573de192177b7205500d221b4952513c1b09dbe22f5629990943a72193
7
- data.tar.gz: 3c29336db5d8fbab1fbde5b06cea5f0e7b567de96f4e43a37b31cb405e16d182a606dcaa18489d916691f9f319de73cc09cf5885c853c60b29d73ea1e5305748
6
+ metadata.gz: 0e5512c8f700cfe2cdb3c8e69096012878d0cc0c4eb57153c8e9890a91082615b435121bb2937db094f9a7c4377acbe9c2315149c8dbf6617691d279128bb543
7
+ data.tar.gz: ad3f9632302f2e583029842fcdb105be963f475b280023f97e6c26c07926cc58d316a9fca07058583229bc87dfbb983dcf598484fdde2ffbb50ecdcf20699cad
@@ -42,10 +42,10 @@
42
42
  .gem-c-related-navigation__link {
43
43
  list-style-type: none;
44
44
  margin-top: govuk-spacing(3);
45
- @include govuk-font($size: 16, $weight: regular, $line-height: 1.5);
45
+ @include govuk-font($size: 16, $weight: regular, $line-height: 1.45);
46
46
 
47
47
  @include govuk-media-query($from: tablet) {
48
- margin-top: 5px;
48
+ line-height: 1.28;
49
49
  }
50
50
  }
51
51
 
@@ -13,6 +13,7 @@ $share-button-height: 32px;
13
13
  display: inline-block;
14
14
  min-height: $share-button-height;
15
15
  padding-left: ($share-button-width + govuk-spacing(2));
16
+ padding-right: govuk-spacing(1);
16
17
  margin-bottom: govuk-spacing(2);
17
18
  font-size: $share-button-height / 2;
18
19
  line-height: $share-button-height;
@@ -48,7 +49,7 @@ $share-button-height: 32px;
48
49
  }
49
50
 
50
51
  .gem-c-share-links__list-item {
51
- padding-left: 0;
52
+ padding-left: govuk-spacing(1);
52
53
  padding-right: ($share-button-width + govuk-spacing(2));
53
54
  }
54
55
 
@@ -58,6 +59,17 @@ $share-button-height: 32px;
58
59
  }
59
60
  }
60
61
 
62
+ .gem-c-share-links--columns {
63
+ .gem-c-share-links__list {
64
+ display: flex;
65
+ flex-wrap: wrap;
66
+ }
67
+
68
+ .gem-c-share-links__list-item {
69
+ flex: 0 0 200px;
70
+ }
71
+ }
72
+
61
73
  .gem-c-share-links--stacked {
62
74
  .gem-c-share-links__list-item {
63
75
  display: block;
@@ -7,7 +7,13 @@
7
7
  <% if local_assigns[:context] != :footer %>
8
8
  <h2 id="related-nav-related_items-<%= random %>"
9
9
  class="gem-c-related-navigation__main-heading"
10
- data-track-count="sidebarRelatedItemSection">
10
+ data-track-count="sidebarRelatedItemSection"
11
+ <%= related_nav_helper.t_lang(
12
+ "components.related_#{local_assigns[:context]}_navigation.related_content",
13
+ default: 'components.related_navigation.related_content'
14
+ )
15
+ %>
16
+ >
11
17
  <%= t("components.related_#{local_assigns[:context]}_navigation.related_content",
12
18
  default: t('components.related_navigation.related_content')) %>
13
19
  </h2>
@@ -3,12 +3,21 @@
3
3
  title ||= false
4
4
  track_as_sharing ||= false
5
5
  stacked ||= false
6
+ columns ||= false
6
7
 
7
8
  brand ||= false
8
9
  brand_helper = GovukPublishingComponents::AppHelpers::BrandHelper.new(brand)
10
+
11
+ classes = %w(gem-c-share-links)
12
+ classes << "gem-c-share-links--stacked" if stacked
13
+ classes << "gem-c-share-links--columns" if columns
14
+ classes << brand_helper.brand_class
15
+
16
+ data_attributes ||= {}
17
+ data_attributes[:module] = 'track-click'
9
18
  %>
10
19
  <% if links.any? %>
11
- <div class="gem-c-share-links <%= brand_helper.brand_class %> <%= 'gem-c-share-links--stacked' if stacked %>" data-module="track-click">
20
+ <%= tag.div(class: classes, data: data_attributes) do %>
12
21
  <% if title %>
13
22
  <h2 class="gem-c-share-links__title"><%= title %></h2>
14
23
  <% end %>
@@ -62,6 +71,9 @@
62
71
  <% elsif link[:icon] == 'youtube' %>
63
72
  <svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="9 9 32 32"><path fill="currentColor" d="M9 9h32v32H9V9z"/><path fill="#FFF" d="M19.88 33.32V16.68L33.32 25l-13.44 8.32z"/></svg>
64
73
 
74
+ <% elsif link[:icon] == 'whatsapp' %>
75
+ <svg xmlns="http://www.w3.org/2000/svg" width="32" height="32"><path d="M0 32V0h32v32H0zm20.839-13.894c-.263-.131-1.555-.766-1.796-.854-.24-.088-.416-.132-.59.131-.176.263-.68.855-.833 1.03-.153.176-.307.198-.57.066-.262-.131-1.109-.41-2.113-1.304-.78-.697-1.308-1.557-1.461-1.82-.153-.263-.016-.406.115-.536.118-.118.263-.308.394-.46.131-.154.175-.264.263-.44.088-.174.044-.328-.022-.46-.066-.131-.591-1.424-.81-1.95-.214-.513-.43-.443-.59-.452a10.506 10.506 0 0 0-.505-.009.964.964 0 0 0-.7.329c-.241.263-.92.899-.92 2.192 0 1.293.942 2.542 1.073 2.718.131.176 1.852 2.83 4.489 3.967.626.27 1.116.433 1.497.554.63.2 1.202.172 1.655.104.505-.075 1.555-.636 1.774-1.25.219-.613.219-1.14.153-1.25-.066-.108-.24-.174-.503-.306zm-4.795 6.547h-.003a8.73 8.73 0 0 1-4.449-1.219l-.319-.19-3.308.869.883-3.226-.208-.33a8.718 8.718 0 0 1-1.336-4.652c.001-4.819 3.922-8.74 8.744-8.74a8.68 8.68 0 0 1 6.179 2.564 8.686 8.686 0 0 1 2.557 6.183c-.002 4.82-3.922 8.74-8.74 8.74zm7.44-16.18a10.449 10.449 0 0 0-7.44-3.084c-5.796 0-10.513 4.717-10.516 10.516 0 1.853.484 3.662 1.404 5.256l-1.492 5.45 5.574-1.463a10.504 10.504 0 0 0 5.026 1.28h.004c5.796 0 10.514-4.717 10.516-10.515a10.455 10.455 0 0 0-3.077-7.44z" fill="currentColor"/></svg>
76
+
65
77
  <% else %>
66
78
  <svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="9 9 32 32"><path fill="currentColor" d="M9 9h32v32H9V9z"/><path fill="#FFF" d="M12.84 14.12v19.2h5.76l5.76 5.76v-5.76h12.8v-19.2H12.84zm3.2 8.32H28.2V25H16.04v-2.56zm16 7.68h-16v-2.56h16v2.56zm1.92-10.24H16.04v-2.56h17.92v2.56z"/></svg>
67
79
 
@@ -70,5 +82,5 @@
70
82
  </li>
71
83
  <% end %>
72
84
  </ul>
73
- </div>
85
+ <% end %>
74
86
  <% end %>
@@ -206,6 +206,52 @@ examples:
206
206
  - title: Pest Control
207
207
  base_path: /pest-control
208
208
  document_type: contact
209
+ with_different_languages:
210
+ description: |
211
+ Each link can have a `locale` parameter to set the correct `lang` attribute.
212
+
213
+ If the link locale is the same as the document locale, then the lang attribute won't be used. For example, `lang="en"` won't appear on a page written in English.
214
+ data:
215
+ content_item:
216
+ links:
217
+ ordered_related_items:
218
+ - title: Find an apprenticeship (French)
219
+ base_path: /apply-apprenticeship.fr
220
+ locale: fr
221
+ topics:
222
+ - title: Apprenticeships, 14 to 19 education and training for work (Korean)
223
+ base_path: /browse/education/find-course.ko
224
+ document_type: topic
225
+ locale: ko
226
+ topical_events:
227
+ - title: UK-China High-Level People to People Dialogue 2017 (Spanish)
228
+ base_path: /government/topical-events/uk-china-high-level-people-to-people-dialogue-2017.es
229
+ document_type: topical_event
230
+ locale: es
231
+ related:
232
+ - title: Jam producers (Spanish)
233
+ base_path: /jam-producers.es
234
+ document_type: contact
235
+ locale: es
236
+ related_statistical_data_sets:
237
+ - title: International road fuel prices (Italian)
238
+ base_path: /government/statistical-data-sets/comparisons-of-industrial-and-domestic-energy-prices-monthly-figures.it
239
+ document_type: statistical_data_set
240
+ locale: it
241
+ document_collections:
242
+ - title: Recruit an apprentice (formerly apprenticeship vacancies)
243
+ base_path: /government/collections/apprenticeship-vacancies
244
+ document_type: document_collection
245
+ locale: en
246
+ world_locations:
247
+ - title: South Sudan (Arabic)
248
+ base_path: /world/south-sudan/news.ar
249
+ locale: ar
250
+ details:
251
+ external_related_links:
252
+ - url: "http://media.slc.co.uk/sfe/1718/ft/sfe_terms_and_conditions_guide_1718_d.pdf"
253
+ title: "Student loans: terms and conditions 2017 to 2018 (PDF, 136KB)"
254
+ locale: en
209
255
  with_all_related-content:
210
256
  data:
211
257
  content_item:
@@ -91,6 +91,42 @@ examples:
91
91
  icon: 'twitter'
92
92
  },
93
93
  ]
94
+ arrange_in_columns:
95
+ description: Share links are arranged in even columns that adjust according to the available space. This option uses flexbox, which is not fully supported in IE <= 10, so in those browsers the columns are not even.
96
+ data:
97
+ columns: true
98
+ links: [
99
+ {
100
+ href: '/facebook-share-link',
101
+ text: 'Facebook',
102
+ icon: 'facebook'
103
+ },
104
+ {
105
+ href: '/twitter-share-link',
106
+ text: 'Twitter',
107
+ icon: 'twitter'
108
+ },
109
+ {
110
+ href: '/email-share-link',
111
+ text: 'Email',
112
+ icon: 'email'
113
+ },
114
+ {
115
+ href: '/flickr-share-link',
116
+ text: 'Flickr',
117
+ icon: 'flickr'
118
+ },
119
+ {
120
+ href: '/instagram-share-link',
121
+ text: 'Instagram',
122
+ icon: 'instagram'
123
+ },
124
+ {
125
+ href: '/linkedin-share-link',
126
+ text: 'Linkedin',
127
+ icon: 'linkedin'
128
+ },
129
+ ]
94
130
  with_all_icons:
95
131
  data:
96
132
  stacked: true
@@ -126,6 +162,11 @@ examples:
126
162
  text: 'Linkedin',
127
163
  icon: 'linkedin'
128
164
  },
165
+ {
166
+ href: '/whatsapp-share-link',
167
+ text: 'WhatsApp',
168
+ icon: 'whatsapp'
169
+ },
129
170
  {
130
171
  href: '/other-share-link',
131
172
  text: 'Anything else that might be included that could have quite a long name',
@@ -28,6 +28,7 @@
28
28
  link[:path],
29
29
  class: related_nav_helper.section_css_class("gem-c-related-navigation__section-link", section_title, link),
30
30
  rel: link[:rel],
31
+ lang: related_nav_helper.t_locale_check(link[:locale]),
31
32
  data: {
32
33
  track_category: 'relatedLinkClicked',
33
34
  track_action: "#{section_index}.#{index} #{related_nav_helper.construct_section_heading(section_title) || t('components.related_navigation.related_content')}",
@@ -90,8 +90,48 @@ module GovukPublishingComponents
90
90
  related_navigation.flat_map(&:last).any?
91
91
  end
92
92
 
93
+ def t_locale(content, options = {})
94
+ # Check if the content string has a translation
95
+ content_translation_available = translation_present?(content)
96
+
97
+ # True, return locale
98
+ this_locale = I18n.locale if content_translation_available
99
+ # If false, return default locale
100
+ this_locale = I18n.default_locale unless content_translation_available
101
+
102
+ # Check if default string passed in
103
+ if options[:default].present?
104
+ # Check if the default string has a translation
105
+ default_translation_available = translation_present?(options[:default])
106
+ # If true, return locale
107
+ this_locale = I18n.locale if default_translation_available
108
+ # If false, return default_locale
109
+ this_locale = I18n.default_locale unless default_translation_available
110
+ end
111
+
112
+ this_locale
113
+ end
114
+
115
+ def t_lang(content, options = {})
116
+ locale = t_locale(content, options)
117
+ "lang=#{locale}" unless locale.eql?(I18n.locale)
118
+ end
119
+
120
+ def t_locale_check(locale)
121
+ locale.presence unless locale.to_s.eql?(I18n.locale.to_s)
122
+ end
123
+
93
124
  private
94
125
 
126
+ def translation_present?(content)
127
+ default_string = 'This is a string to act as a default for the `I18n.translate` method. Comparing the result reveals if there is a translation in the i18n files.'
128
+ I18n.translate(
129
+ content,
130
+ default: default_string,
131
+ fallback: false
132
+ ) != default_string
133
+ end
134
+
95
135
  def related_items
96
136
  related_quick_links = content_item_details_for('quick_links')
97
137
 
@@ -184,7 +224,13 @@ module GovukPublishingComponents
184
224
  links = links.find_all { |link| link['document_type'] == only }
185
225
  end
186
226
 
187
- links.map { |link| { path: link['base_path'], text: link['title'] } }
227
+ links.map { |link|
228
+ {
229
+ path: link['base_path'],
230
+ text: link['title'],
231
+ locale: link['locale'],
232
+ }
233
+ }
188
234
  end
189
235
  end
190
236
  end
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = '18.0.1'.freeze
2
+ VERSION = '18.1.0'.freeze
3
3
  end
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: 18.0.1
4
+ version: 18.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: 2019-08-13 00:00:00.000000000 Z
11
+ date: 2019-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gds-api-adapters