%
links ||= []
title ||= false
track_as_sharing ||= false
stacked ||= false
columns ||= false
brand ||= false
brand_helper = GovukPublishingComponents::AppHelpers::BrandHelper.new(brand)
classes = %w(gem-c-share-links)
classes << "gem-c-share-links--stacked" if stacked
classes << "gem-c-share-links--columns" if columns
classes << brand_helper.brand_class
data_attributes ||= {}
data_attributes[:module] = 'gem-track-click'
%>
<% if links.any? %>
<%= tag.div(class: classes, data: data_attributes) do %>
<% if title %>
<%= title %>
<% end %>
<% links.each do |link| %>
<% link_text = capture do %>
<% if link[:hidden_text] %>
<%= link[:hidden_text] %>
<% else %>
Share on
<% end %>
<%= link[:text] %>
<% end %>
-
<%
if track_as_sharing
track_options = {
'socialAction': 'share',
'socialNetwork': link[:icon],
'socialTarget': link[:href]
}
end
%>
<%= link_to link[:href],
target: "_blank",
rel: "noopener noreferrer external",
data: {
'track-category': 'social media',
'track-action': link[:icon],
'track-options': track_options
},
class: "gem-c-share-links__link #{brand_helper.color_class}" do %>
<% if link[:icon] == 'facebook' %>
<% elsif link[:icon] == 'twitter' %>
<% elsif link[:icon] == 'email' %>
<% elsif link[:icon] == 'flickr' %>
<% elsif link[:icon] == 'instagram' %>
<% elsif link[:icon] == 'linkedin' %>
<% elsif link[:icon] == 'youtube' %>
<% elsif link[:icon] == 'whatsapp' %>
<% else %>
<% end %>
<%= link_text %><% end %>
<% end %>
<% end %>
<% end %>