{#
/**
 * @file
 * Template for a Card component.
 */
#}

{% set hover_shadow = hover_shadow|default(false) %}
{% set classes = [
  'card',
  hover_shadow ? 'has-hover-shadow' : ''
]|merge(classes|default([])) %}

{% if print_attributes and attributes %}
  {# This is a workaround for QuickEdit that allows the extending template to
  print the attributes in this component template, as opposed to the paragraph
  wrapper. When displaying a card in a cark deck, the card needs to be a direct
  descendant, and cannot have an "extra" element in between. Just removing the
  Paragraph wrapper is an option, but doing so also omits attributes needed by
  QuickEdit, and that cause a JavaScript error. This code allows both attributes
  to be printed, and the card deck component to work as designed. #}
  <div{{ attributes.addClass(classes) }}>
{% else %}
  <div class="{{ classes|join(' ')|trim }}">
{% endif %}

  {% if url %}
    <a href="{{ url }}">
  {% endif %}

    {% if image %}
      <div class="card-img-top">
        {{ image }}
      </div>
    {% endif %}

    {% if title or body %}
      <div class="card-body">
        {% if title %}
          <h4 class="card-title">{{ title }}</h4>
        {% endif %}
        {% block body %}
          {{ body }}
        {% endblock %}
      </div>
    {% endif %}

    {% if footer %}
      <div class="card-footer">
        {{ footer }}
      </div>
    {% endif %}

  {% if url %}
    </a>
  {% endif %}
</div>
