Module: Decidim::SocialShareButtonHelper
- Included in:
- Design::IconographyHelper, ShareTextWidgetCell, ShareWidgetCell
- Defined in:
- decidim-core/app/helpers/decidim/social_share_button_helper.rb
Overview
A Helper that reimplements the SocialShareButton gem helpers, so that we do not depend on it anymore.
Instance Method Summary collapse
- #render_social_share_button(service, title, args) ⇒ Object
- #render_social_share_buttons(services, title, args) ⇒ Object
- #render_social_share_icon(service, options = {}) ⇒ Object
- #social_share_button_tag(title, args) ⇒ Object
Instance Method Details
#render_social_share_button(service, title, args) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'decidim-core/app/helpers/decidim/social_share_button_helper.rb', line 18 def (service, title, args) uri = service.formatted_share_uri(title, args) return unless uri data = service.optional_args.reverse_merge( "site" => service.name.downcase, "external-link" => "text-only", "external-domain-link" => false ) link_to( uri, rel: "nofollow noopener noreferrer", target: "_blank", data:, title: t("decidim.shared.share_modal.share_to", service: service.name) ) do content_tag(:span, (service), class: "icon") + content_tag(:span, service.name, class: "text") end end |
#render_social_share_buttons(services, title, args) ⇒ Object
12 13 14 15 16 |
# File 'decidim-core/app/helpers/decidim/social_share_button_helper.rb', line 12 def (services, title, args) services.map do |service| (service, title, args) end.join.html_safe end |
#render_social_share_icon(service, options = {}) ⇒ Object
40 41 42 43 44 45 46 |
# File 'decidim-core/app/helpers/decidim/social_share_button_helper.rb', line 40 def (service, = {}) if service.icon.include? ".svg" image_tag service.icon_path, .merge(alt: t("decidim.shared.share_modal.share_to", service: service.name)) else icon(service.icon, .merge(ignore_missing: true)) end end |
#social_share_button_tag(title, args) ⇒ Object
6 7 8 9 10 |
# File 'decidim-core/app/helpers/decidim/social_share_button_helper.rb', line 6 def (title, args) return unless enabled_services.length.positive? (enabled_services, title, args) end |