{#
/**
 * Event card
 *
 * An event card represents a small piece of event-related content.
 *
 * @var string $heading Main heading title for the card.
 * @var string|\DateTime $event_date The date of the event.
 * @var bool $datetime_format (optional) Display the time of the event. Defaults to `D, M j` e.g. Mon, Nov 12.
 * @var string $media (optional) media (img, video, or any other CSS replaced element).
 * @var string $content (optional) Additional content for the card.
 * @var string $heading_element The HTML element for the heading. Defaults to `h2`.
 * @var string $eyebrow_heading_element The HTML element for the eyebrow_heading. Defaults to `h3`.
 * @var string $link_url (optional) A URL for link over the entire card.
 * @var string $link_alt Alt text for the card link.
 * @var Drupal\Core\Template\Attribute|array $wrapper_attributes Attributes (class, data, etc.) for the card wrapper.
 * @var Drupal\Core\Template\Attribute|array $attributes Attributes (class, data, etc.) for the entire card.
 * @var Drupal\Core\Template\Attribute|array $content_attributes Attributes for the card content region.
 * @var Drupal\Core\Template\Attribute|array $link_attributes Attributes for the card link.
 *
 * @union-variation cu-event-card--mini A small version of the card with image and date icon on the left.
 *
 * @see https://www.figma.com/file/pfhQCvR2YmyHyKjEXS9gnK/23_ILR-WIP?type=design&node-id=945-13551&t=iMguE6zBDTf8L53V-4 WIP in Figma
 */
#}
{% set wrapper_attributes = union_attributes(wrapper_attributes|default([])) %}
{% set attributes = union_attributes(attributes|default([])) %}
{% set content_attributes = union_attributes(content_attributes|default([])) %}
{% set link_attributes = union_attributes(link_attributes|default([])) %}

{% set event_date_time_element %}
<time datetime="{{ event_date|date("c", false) }}" itemprop="startDate">{{ event_date|date(datetime_format|default('D, M j'), false) }}</time>
{% endset %}
<div{{ wrapper_attributes.addClass(['cu-event-card-wrapper']) }}>
<div{{ attributes.addClass([
    'cu-event-card',
    media ? 'cu-event-card--with-media'
  ]) }} itemscope itemtype="http://schema.org/Event">
  <div{{ content_attributes.addClass(['cu-event-card__content']) }}>
    {% if heading or event_date %}
    {% include '@union/_composite-heading.twig' with {
      eyebrow_heading: event_date_time_element,
      heading: heading,
      eyebrow_heading_element: eyebrow_heading_element,
      heading_element: heading_element,
      heading_attributes: {
        itemprop: 'name'
      },
      attributes: {
        class: [
          'cu-event-card__meta',
          'cu-composite-heading--minimal',
          'cu-composite-heading--left'
        ]
      }
    } only %}
    {% endif %}
    {{ content }}
    <time class="cu-event-card__icon" datetime="{{ event_date|date("c") }}"><span class="cu-event-card__icon_month">{{ event_date|date("M", false) }}</span><span class="cu-event-card__icon_day">{{ event_date|date("j", false) }}</span></time>
  </div>
{% if media %}
  <div class="cu-event-card__media">
    {{ media }}
  </div>
{% endif %}
{% if link_url %}
  <a{{ link_attributes.addClass(['cu-event-card__link']) }} href="{{ link_url }}" title="{{ heading }}">{{ link_alt }}</a>
{% endif %}
</div>
</div>
