templates/front/partials/cards/news-event.html.twig line 1

Open in your IDE?
  1. {% set size = size ?? 'M' %}
  2. {% set picSizes = [[419, 236], [360, 203], [443, 250], [679, 366], [334,180]] %}
  3. {% if size == 'S' %}
  4.     {% set picSizes = [[316, 212], [360, 203], [443, 250], [679, 366], [334, 180]] %}
  5. {% elseif size == 'L' %}
  6.     {% set picSizes = [[656, 290], [560, 247], [443, 250], [679, 366], [334, 180]] %}
  7. {% endif %}
  8. {% if type == 'article' %}
  9.     {% set ctaLabel = 'Lire l\'actualité' %}
  10.     {% set tag = 'Actualité' %}
  11. {% elseif type == 'event' %}
  12.     {% set ctaLabel = 'Voir l\'événement' %}
  13.     {% set tag = 'événement' %}
  14. {% else %}
  15.     {% set ctaLabel = 'Voir l\'événement' %}
  16.     {% set tag = 'Agenda CGF' %}
  17. {% endif %}
  18. {% set isArticle = type == 'article' %}
  19. <div class="card-common card-common--{{ size }} card-news-event {{ not isArticle ? 'card-news-event--event' : '' }}">
  20.     <a href="{{ page_url(news, "front") }}" class="card-common__wrap">
  21.         <div class="card-common__tags">
  22.             <span class="tag">{{ tag }}</span>
  23.         </div>
  24.         <div class="relative {{ not isArticle ? 'mb-1 md:mb-3' : 'card-news-event__top--article' }} card-news-event__top card-news-event__top--{{ size }}">
  25.             <picture
  26.                     class="card-common__pic  {{ not isArticle ? 'card-common__pic--news card-common__pic--news-' ~ size  : '' }}">
  27.                 <source media="(max-width:420px)"
  28.                         data-srcset="{{ cloudinary_media(newsProperties.image.singleMedia, 'c_fill,f_auto,q_auto,w_' ~ picSizes[4][0] ~ ',h_' ~ picSizes[4][1]) }} 1x, {{ cloudinary_media(newsProperties.image.singleMedia, 'dpr_2,c_fill,f_auto,q_auto,w_' ~ picSizes[4][0] ~ ',h_' ~ picSizes[4][1]) }} 2x">
  29.                 <source media="(max-width:767px)"
  30.                         data-srcset="{{ cloudinary_media(newsProperties.image.singleMedia, 'c_fill,f_auto,q_auto,w_' ~ picSizes[3][0] ~ ',h_' ~ picSizes[3][1]) }} 1x, {{ cloudinary_media(newsProperties.image.singleMedia, 'dpr_2,c_fill,f_auto,q_auto,w_' ~ picSizes[3][0] ~ ',h_' ~ picSizes[3][1]) }} 2x">
  31.                 <source width="{{ picSizes[2][0] }}" height="{{ picSizes[2][1] }}" media="(max-width:1023px)"
  32.                         data-srcset="{{ cloudinary_media(newsProperties.image.singleMedia, 'c_fill,f_auto,q_auto,w_' ~ picSizes[2][0] ~ ',h_' ~ picSizes[2][1]) }} 1x, {{ cloudinary_media(newsProperties.image.singleMedia, 'dpr_2,c_fill,f_auto,q_auto,w_' ~ picSizes[2][0] ~ ',h_' ~ picSizes[2][1]) }} 2x">
  33.                 <source width="{{ picSizes[1][0] }}" height="{{ picSizes[1][1] }}" media="(max-width:1279px)"
  34.                         data-srcset="{{ cloudinary_media(newsProperties.image.singleMedia, 'c_fill,f_auto,q_auto,w_' ~ picSizes[1][0] ~ ',h_' ~ picSizes[1][1]) }} 1x, {{ cloudinary_media(newsProperties.image.singleMedia, 'dpr_2,c_fill,f_auto,q_auto,w_' ~ picSizes[1][0] ~ ',h_' ~ picSizes[1][1]) }} 2x">
  35.                 <source media="(min-width:1280px)"
  36.                         data-srcset="{{ cloudinary_media(newsProperties.image.singleMedia, 'c_fill,f_auto,q_auto,w_' ~ picSizes[0][0] ~ ',h_' ~ picSizes[0][1]) }} 1x, {{ cloudinary_media(newsProperties.image.singleMedia, 'dpr_2,c_fill,f_auto,q_auto,w_' ~ picSizes[0][0] ~ ',h_' ~ picSizes[0][1]) }} 2x">
  37.                 <img class="w-full lazyload" width="{{ picSizes[0][0] }}" height="{{ picSizes[0][1] }}"
  38.                      data-src="{{ cloudinary_media(newsProperties.image.singleMedia, 'c_fill,f_auto,q_auto,w_' ~ picSizes[0][0] ~ ',h_' ~ picSizes[0][1]) }}"
  39.                      alt="{{ newsProperties.image.singleMedia.alt }}"/>
  40.             </picture>
  41.             {% if not isArticle %}
  42.                 <div class="card-news-event__date card-news-event__date--{{ size }}">
  43.                     <span>{{ newsProperties.startEventDate.date|date("d.m") }}</span>
  44.                     {% if newsProperties.endEventDate is defined and newsProperties.endEventDate is not empty %}
  45.                         <span>{{ newsProperties.endEventDate.date|date("d.m") }}</span>
  46.                         <span class="year">{{ newsProperties.endEventDate.date|date("Y") }}</span>
  47.                     {% else %}
  48.                         <span class="year">{{ newsProperties.startEventDate.date|date("Y") }}</span>
  49.                     {% endif %}
  50.                 </div>
  51.             {% endif %}
  52.         </div>
  53.         <div class="card-common__inner {{ size == 'S' ? 'card-common__inner--S' : '' }} mt-5">
  54.             <div>
  55.                 {% if isArticle %}
  56.                     <p class="card-common__date text-grey-dark">
  57.                         <svg width="12" height="12" class="mr-2 icon--violet">
  58.                             <use href="#icon-hour" xlink:href="#icon-hour"></use>
  59.                         </svg>
  60.                         <span>Publié le <span
  61.                                     class="font-bold text-violet">{{ newsProperties.publicationDate.date|date("d.m.Y") }}</span></span>
  62.                     </p>
  63.                 {% endif %}
  64.                 <p class="title-card title-card--{{ size }} {{ isArticle ? 'text-violet' : 'text-white' }} mb-3">
  65.                     {{ news.title }}
  66.                 </p>
  67.                 {% if isArticle %}
  68.                     {% if news.description is defined and news.description is not null %}
  69.                     <div class="card-publi__chapo">
  70.                         {{ news.description|striptags|raw }}
  71.                     </div>
  72.                     {% endif %}
  73.                 {% else %}
  74.                     {% if newsProperties.place is defined and newsProperties.place is not null %}
  75.                     <div class="flex card-news-event__location">
  76.                         <svg width="14" height="20" class="mr-2 icon--orange flex-shrink-0">
  77.                             <use href="#icon-pin" xlink:href="#icon-pin"></use>
  78.                         </svg>
  79.                         {{ newsProperties.place }}
  80.                     </div>
  81.                     {% endif %}
  82.                 {% endif %}
  83.             </div>
  84.             <span class="cta-arrow {{ isArticle ? 'text-violet' : 'text-white' }} mt-5">
  85.                 {{ ctaLabel }}
  86.                 <span class="cta-arrow__circle">
  87.                     <svg width="8" height="8" class="icon--white">
  88.                         <use href="#icon-arrow" xlink:href="#icon-arrow"></use>
  89.                     </svg>
  90.                 </span>
  91.             </span>
  92.         </div>
  93.     </a>
  94.     {% if not isArticle %}
  95.         {% if newsProperties.registerLink is defined and newsProperties.registerLink is not null %}
  96.             <a href="{{ newsProperties.registerLink }}" target="_blank" rel="nofollow" class="card-common__action icon-center">
  97.                 <svg width="20" height="18" class="icon--white">
  98.                     <use href="#icon-calendar" xlink:href="#icon-calendar"></use>
  99.                 </svg>
  100.                 <span class="sr-only">S'inscrire à l'évènement</span>
  101.             </a>
  102.         {% endif %}
  103.     {% endif %}
  104. </div>