Sha256: a0ffd10f9407ff1753ec9bf4046d708edc6a45d0b2c7bc508f805de563f4fca2

Contents?: true

Size: 1.12 KB

Versions: 4

Compression:

Stored size: 1.12 KB

Contents

<%
  add_gem_component_stylesheet("print-link")

  text ||= t('components.print_link.text')
  href ||= nil
  child_data_attributes ||= {}
  require_js ||= href.nil?
  local_assigns[:margin_bottom] ||= 3

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

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

  component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
  component_helper.add_class("gem-c-print-link govuk-!-display-none-print")
  component_helper.add_class("gem-c-print-link--show-without-js") unless require_js
%>
<%= tag.div(**component_helper.all_attributes) do %>
  <% if require_js %>
    <%= content_tag(:button, text, {
        class: child_classes,
        data: child_data_attributes
    }) %>
  <% else %>
    <%= link_to(
      text,
      href,
      class: child_classes,
      rel: "alternate",
      data: child_data_attributes,
      role: "button"
    ) %>
  <% end %>
<% end %>

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
govuk_publishing_components-51.1.0 app/views/govuk_publishing_components/components/_print_link.html.erb
govuk_publishing_components-51.0.0 app/views/govuk_publishing_components/components/_print_link.html.erb
govuk_publishing_components-50.0.1 app/views/govuk_publishing_components/components/_print_link.html.erb
govuk_publishing_components-50.0.0 app/views/govuk_publishing_components/components/_print_link.html.erb