{% doc %}
  Intended for use in a block similar to the button block.

  @param {string} link - link to render, will override settings.link
  @param {object} [block] - The block

  @example
  {% render 'button', link: '/collections/all' %}
{% enddoc %}

{% stylesheet %}
  .link {
    text-decoration: none;
    text-decoration-color: currentcolor;

    &:hover {
      color: var(--color-primary-hover);
      text-decoration-color: transparent;
    }
  }
{% endstylesheet %}

{% assign link = link | default: block.settings.link %}

<a
  {% if link == blank %}
    role="link"
    aria-disabled="true"
  {% else %}
    href="{{ link }}"
  {% endif %}
  class="
    size-style
    {{ block.settings.style_class }}
    {{ block.settings.style_class }}--{{ block.id }}
  "
  style="{% render 'size-style', settings: block.settings %}"
  {%- if block.settings.open_in_new_tab -%}
    target="_blank"
    rel="noopener noreferrer"
  {%- endif -%}
  {{ block.shopify_attributes }}
>
  {{ block.settings.label }}
</a>
