Sha256: 3a33098d9dd84f6a6c6597971b0a959ae7301923b1a55d78cb049eba0fd5e732

Contents?: true

Size: 1.14 KB

Versions: 46

Compression:

Stored size: 1.14 KB

Contents

<%
  text ||= t('components.print_link.text')
  href ||= nil
  data_attributes ||= {}
  require_js ||= href.nil?
  margin_top ||= 3
  margin_bottom ||= 3

  ((data_attributes[:module] ||= "") << " " << (require_js ? "print-link" : "button")).strip!

  shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new({
    margin_top: margin_top,
    margin_bottom: margin_bottom
  })

  wrapper_classes = %w(gem-c-print-link govuk-!-display-none-print)
  wrapper_classes << "gem-c-print-link--show-without-js" unless require_js
  wrapper_classes << shared_helper.get_margin_top
  wrapper_classes << shared_helper.get_margin_bottom

  classes = %w[govuk-link]
  classes << "govuk-body-s gem-c-print-link__button" if href.nil?
  classes << "gem-c-print-link__link govuk-link--no-visited-state" if href.present?
%>

<%= tag.div class: wrapper_classes do %>
  <% if require_js %>
    <%= content_tag(:button, text, {
        class: classes,
        data: data_attributes
    }) %>
  <% else %>
    <%= link_to(
      text,
      href,
      class: classes,
      rel: "alternate",
      data: data_attributes,
      role: "button"
    ) %>
  <% end %>
<% end %>

Version data entries

46 entries across 46 versions & 1 rubygems

Version Path
govuk_publishing_components-30.5.0 app/views/govuk_publishing_components/components/_print_link.html.erb
govuk_publishing_components-30.4.1 app/views/govuk_publishing_components/components/_print_link.html.erb
govuk_publishing_components-30.4.0 app/views/govuk_publishing_components/components/_print_link.html.erb
govuk_publishing_components-30.3.0 app/views/govuk_publishing_components/components/_print_link.html.erb
govuk_publishing_components-30.2.1 app/views/govuk_publishing_components/components/_print_link.html.erb
govuk_publishing_components-30.2.0 app/views/govuk_publishing_components/components/_print_link.html.erb