# Generates a set of social share buttons based on the specified options.
def social_share_buttons(title:, url:)
tag.div(
- :class => "social-share-button d-flex gap-1 align-items-end flex-wrap mb-3"
+ :class => "social-share-buttons d-flex gap-1 align-items-end flex-wrap mb-3"
) do
- safe_join(SOCIAL_SHARE_CONFIG.map do |site, icon|
+ buttons = [
+ tag.button(:type => "button",
+ :class => "btn btn-secondary p-1 border-1 rounded-circle",
+ :title => I18n.t("application.share.share.title"),
+ :hidden => true,
+ :data => { :share_type => "native",
+ :share_text => title,
+ :share_url => url }) do
+ image_tag("social_icons/share.svg", :alt => I18n.t("application.share.share.alt"), :size => 18, :class => "d-block")
+ end
+ ]
+
+ buttons << SOCIAL_SHARE_CONFIG.map do |site, icon|
link_options = {
:rel => "nofollow",
- :class => "ssb-icon rounded-circle",
+ :class => "rounded-circle focus-ring",
:title => I18n.t("application.share.#{site}.title"),
- :target => "_blank"
+ :target => "_blank",
+ :data => { :share_type => site == :email ? "email" : "site" }
}
link_to generate_share_url(site, title, url), link_options do
image_tag(icon, :alt => I18n.t("application.share.#{site}.alt"), :size => 28)
end
- end, "\n")
+ end
+
+ safe_join(buttons, "\n")
end
end
def generate_share_url(site, title, url)
site = site.to_sym
- title = URI.encode_www_form_component(title)
- url = URI.encode_www_form_component(url)
+ title = URI.encode_uri_component(title)
+ url = URI.encode_uri_component(url)
case site
when :email