{% extends "node--teaser.html.twig" %}

{% block card_teaser_type %}
  <a href="{{ url }}" aria-hidden="true" title="{% trans %}Event: &nbsp;{% endtrans %}{{- label|render|striptags|trim -}}">
    <div class="teaser__teaser-type">
      <svg class="teaser__teaser-type-icon" aria-hidden="true">
        <title>{% trans %}Event: &nbsp;{% endtrans %}{{- label|render|striptags|trim -}}</title>
        {% if event_type_icon %}
          <use xlink:href="#{{- event_type_icon -}}"></use>
        {% else %}
          <use xlink:href="#icon-{{- node.bundle|clean_class -}}"></use>
        {% endif %}
      </svg>
    </div>
  </a>
{% endblock %}

{% block card_body %}

  {% embed "node--teaser__field.html.twig" %}
    {%- block field_icon -%} event {%- endblock -%}
    {%- block svg_title -%} <title>{% trans %}Event date{% endtrans %}</title> {%- endblock -%}
    {%- block field_value %}
      <span class="sr-only">{% trans %}Event date{% endtrans %} </span>
      {{ event_date }}
    {%- endblock -%}
  {% endembed %}

  {% if content.field_event_location|render is not empty %}
    {% embed "node--teaser__field.html.twig" %}
      {%- block field_icon -%} location {%- endblock -%}
      {%- block svg_title -%} <title>{% trans %}Located at: {% endtrans %}</title> {%- endblock -%}
      {%- block field_value -%}
        <span class="sr-only">{% trans %}The event will take place at the{% endtrans %} </span>
        {{ content.field_event_location }}
      {%- endblock -%}
    {% endembed %}
  {% endif %}

  {% if event_type %}
    {% embed "node--teaser__field.html.twig" %}
      {%- block field_icon -%} label {%- endblock -%}
      {%- block svg_title -%} <title>{% trans %}Event type {% endtrans %}</title> {%- endblock -%}
      {%- block field_value -%}
        <span class="sr-only">{% trans %}This event has type{% endtrans %} </span>
        {{ event_type }}
      {%- endblock -%}
    {% endembed %}
  {% endif %}

  {% if content.group_name %}
    {% embed "node--teaser__field.html.twig" %}
      {%- block field_icon -%} group {%- endblock -%}
      {%- block svg_title -%} <title>{% trans %}Group{% endtrans %}</title> {%- endblock -%}
      {%- block field_value -%}
        <span class="sr-only">{% trans %}This event is posted in{% endtrans %} </span>
        {{ content.group_name }}
      {%- endblock -%}
    {% endembed %}
  {% endif %}

{% endblock %}

{% block card_actionbar %}

  {% if visibility_icon and visibility_label %}
    <div class="badge teaser__badge">
      <span class="badge__container">
        <svg class="badge__icon">
           <title>{% trans %}Visibility{% endtrans %}</title>
          <use xlink:href="#icon-{{ visibility_icon }}"></use>
        </svg>
        <span class="badge__label text-gray">{{ visibility_label|capitalize }}</span>
      </span>
    </div>
  {% endif %}

  {% if content.enrollments_count is not empty %}
    <div class="badge teaser__badge">
      <span class="badge__container">
        <svg class="badge__icon">
          <title>{% trans %}Total amount of enrollments{% endtrans %}</title>
          <use xlink:href="#icon-person"></use>
        </svg>
        <span class="badge__label text-gray">
          {{ content.enrollments_count }}
        </span>
      </span>
    </div>
  {% endif %}

  {% if content.ongoing %}
    <span class="badge badge-primary teaser__badge">
          {{ content.ongoing }}
        </span>
  {% endif %}
  {% if content.enrolled %}
    <span class="badge badge-default teaser__badge">
      {{ content.enrolled }}
    </span>
  {% endif %}

  {{ content.links }}

{% endblock %}
