templates/_snippets/blog.html.twig line 1

Open in your IDE?
  1. {# Paramètres de la section #}
  2. {% set blogId = 'blog-' ~ random() %}
  3. {% set backgroundCheckbox = blog.backgroundCheckbox == false ? 0 : 1 %} {# 0 = on veut une image ; 1 = une veut une couleur #}
  4. {% set noBackgroundCheckbox = blog.noBackgroundCheckbox == false ? 0 : 1 %} {# 0 = on ne veut pas de fond ; 1 = on veut un fond #}
  5. {% set backgroundGradientCheckbox = blog.backgroundGradientCheckbox == false ? 0 : 1 %} {# 0 = on ne veut pas de gradient ; 1 = on veut un gradient #}
  6. {% set backgroundGradientDirection = blog.backgroundGradientDirection|default('to right') %}
  7. {% set backgroundGradientColor1 = blog.backgroundGradientColor1|default('#000') %}
  8. {% set backgroundGradientColor2 = blog.backgroundGradientColor2|default('#fff') %}
  9. {% set backgroundGradientAngle = blog.backgroundGradientAngle|default(0) %}
  10. {% set backgroundGradientAngleUnit = blog.backgroundGradientAngleUnit|default('deg') %}
  11. {% set backgroundGradientColor1Position = blog.backgroundGradientColor1Position|default(0) %}
  12. {% set backgroundGradientColor2Position = blog.backgroundGradientColor2Position|default(100) %}
  13. {% set sectionMinHeight = blog.sectionMinHeight|default(0) %}
  14. {% set sectionMinHeightUnit = blog.sectionMinHeightUnit|default('px') %}
  15. {% set backgroundColor = blog.backgroundColor|default('transparent') %}
  16. {% set backgroundImage = blog.backgroundImage|default('') %}
  17. {% set backgroundFilter = blog.backgroundFilter|default('rgba(0,0,0)') %}
  18. {% set backgroundFilterOpacity = blog.backgroundFilterOpacity|default(0) %}
  19. {% set blogLogo = blog.blogLogo|default(null) %}
  20. {# Paramètres du bouton des articles #}
  21. {% set textButton = blog.textButton|default('DÉCOUVRIR') %}
  22. {% set inverseColorButton = blog.inverseColorButtonCheckbox == true ? 1 : 0 %}
  23. <section class="blog" id="{{ blogId }}">
  24. <div class="blog-head">
  25. {% if blogLogo is not null %}
  26. {% set logoUrl = sulu_media_url(blogLogo, '400x') %}
  27. <img src="{{ logoUrl }}" alt="Croisiland Le Blog" class="mb-5" loading="lazy">
  28. {% endif %}
  29. <a href="{{ blog.blogLink|default('') }}" class="blog-link" target="_blank">{{ blog.blogButtonText|default('DÉCOUVRIR') }}</a>
  30. </div>
  31. <div class="slider">
  32. <div class="cards">
  33. {% for article in blog.articles %}
  34. <div class="article animation1">
  35. <div class="image-container">
  36. {% if article.isInternalImage == true %}
  37. {% set articleImageUrl = sulu_media_url(article.internalImage, '800x') %}
  38. <img src="{{ articleImageUrl }}" alt="{{ (article.alt)|default('') }}" loading="lazy">
  39. {% else %}
  40. <img src="{{ (article.externalImage)|default('') }}" alt="{{ (article.alt)|default('') }}" loading="lazy">
  41. {% endif %}
  42. {% if article.tags is defined and article.tags is not empty %}
  43. <div class="tags-overlay">
  44. {% for tag in article.tags %}
  45. <span class="tag br2">{{ tag.tag }}</span>
  46. {% endfor %}
  47. </div>
  48. {% endif %}
  49. <!-- Date en bas à gauche -->
  50. {% if article.publicationDate is defined and article.publicationDate is not null and article.publicationDate is not empty %}
  51. <div class="date-overlay br2">
  52. {{ getLucidIcon('calendar', {width: '12', height: '12'}) }}
  53. <span class="date-text">{{ article.publicationDate ? article.publicationDate|date('d M Y') : '' }}</span>
  54. </div>
  55. {% endif %}
  56. <!-- Temps de lecture en bas à droite -->
  57. {% if article.readingTime is defined and article.readingTime is not null %}
  58. <div class="reading-time-overlay br2">
  59. {{ getLucidIcon('clock', {width: '12', height: '12'}) }}
  60. <span class="reading-time-text">{{ article.readingTime ~ ' min de lecture'|default('7min de lecture') }}</span>
  61. </div>
  62. {% endif %}
  63. </div>
  64. <div class="title">{{ article.title|default('') }}</div>
  65. <div class="content">{{ article.description|raw }}</div>
  66. <a href="{{ article.link|default('') }}" class="bouton" target="_blank">{{ textButton }}</a>
  67. </div>
  68. {% endfor %}
  69. </div>
  70. <div class="chevrons"></div>
  71. </div>
  72. </section>
  73. <style>
  74. /* ========================================
  75. SECTION BLOG - CONTENEUR PRINCIPAL
  76. ======================================== */
  77. #{{ blogId}} {
  78. /* Section */
  79. --section-padding: {{ blog.sectionPaddingTop|default(0) ~ blog.sectionPaddingUnit|default('px') ~ ' ' ~ blog.sectionPaddingRight|default(0) ~ blog.sectionPaddingUnit|default('px') ~ ' ' ~ blog.sectionPaddingBottom|default(0) ~ blog.sectionPaddingUnit|default('px') ~ ' ' ~ blog.sectionPaddingLeft|default(0) ~ blog.sectionPaddingUnit|default('px') }};
  80. --section-min-height : {{ blog.sectionMinHeight|default(0) ~ blog.sectionMinHeightUnit|default('px') }};
  81. --section-border-radius : {{ blog.sectionBorderRadius|default(0) ~ blog.sectionBorderRadiusUnit|default('px') }};
  82. /* Slider */
  83. --slider-padding-left : {{ blog.sectionPaddingLeft|default(0) ~ blog.sectionPaddingUnit|default('px') }};
  84. /* Articles */
  85. --articles-gap : {{ blog.articlesGap|default(2) ~ blog.articlesGapUnit|default('rem') }};
  86. /* Image Article */
  87. --articles-height-image : {{ blog.articleImageHeight|default(200) ~ blog.articleImageHeightUnit|default('px') }};
  88. --articles-margin-image : {{ blog.articlesMarginTopImage|default(0) ~ blog.articlesMarginUnitImage|default('px') ~ ' ' ~ blog.articlesMarginRightImage|default(0) ~ blog.articlesMarginUnitImage|default('px') ~ ' ' ~ blog.articlesMarginBottomImage|default(0) ~ blog.articlesMarginUnitImage|default('px') ~ ' ' ~ blog.articlesMarginLeftImage|default(0) ~ blog.articlesMarginUnitImage|default('px') }};
  89. /* Image Titres */
  90. --articles-color-title : {{ blog.titlesColor|default('inherit') }} ;
  91. --articles-size-title : {{ blog.titlesSize|default(20) ~ blog.titlesSizeUnit|default('px') }};
  92. --articles-line-height-title : {{ blog.titlesSize|default(20) * 1.2 ~ blog.titlesSizeUnit|default('') }};
  93. --articles-margin-title : {{ blog.articlesMarginTopTitle|default(0) ~ blog.articlesMarginUnitTitle|default('px') ~ ' ' ~ blog.articlesMarginRightTitle|default(0) ~ blog.articlesMarginUnitTitle|default('px') ~ ' ' ~ blog.articlesMarginBottomTitle|default(0) ~ blog.articlesMarginUnitTitle|default('px') ~ ' ' ~ blog.articlesMarginLeftTitle|default(0) ~ blog.articlesMarginUnitTitle|default('px') }};
  94. /* Bouton Article */
  95. --articles-color-button : {{ blog.colorButton|default('inherit') }} ;
  96. --articles-color-button-secondary : {{ blog.colorButtonSecondary|default('inherit') }} ;
  97. --articles-weight-button : {{ blog.weightButton|default(400) }} ;
  98. --articles-radius-button : {{ blog.radiusButton|default(0) ~ blog.radiusButtonUnit|default('px') }};
  99. --articles-padding-button : {{ blog.buttonPaddingTop|default(0) ~ blog.buttonPaddingUnit|default('px') ~ ' ' ~ blog.buttonPaddingRight|default(0) ~ blog.buttonPaddingUnit|default('px') ~ ' ' ~ blog.buttonPaddingBottom|default(0) ~ blog.buttonPaddingUnit|default('px') ~ ' ' ~ blog.buttonPaddingLeft|default(0) ~ blog.buttonPaddingUnit|default('px') }};
  100. --articles-margin-button : {{ blog.buttonMarginTop|default(0) ~ blog.buttonMarginUnit|default('px') ~ ' ' ~ blog.buttonMarginRight|default(0) ~ blog.buttonMarginUnit|default('px') ~ ' ' ~ blog.buttonMarginBottom|default(0) ~ blog.buttonMarginUnit|default('px') ~ ' ' ~ blog.buttonMarginLeft|default(0) ~ blog.buttonMarginUnit|default('px') }};
  101. /* Texte Article */
  102. --articles-color-text : {{ blog.textsColor|default('inherit') }} ;
  103. --articles-size-text : {{ blog.textsSize|default(14) ~ blog.textsSizeUnit|default('px') }};
  104. --articles-line-height-text : {{ blog.textsSize|default(14) * 1.2 ~ blog.textsSizeUnit|default('') }};
  105. --articles-margin-text : {{ blog.articlesMarginTopContent|default(0) ~ blog.articlesMarginUnitContent|default('px') ~ ' ' ~ blog.articlesMarginRightContent|default(0) ~ blog.articlesMarginUnitContent|default('px') ~ ' ' ~ blog.articlesMarginBottomContent|default(0) ~ blog.articlesMarginUnitContent|default('px') ~ ' ' ~ blog.articlesMarginLeftContent|default(0) ~ blog.articlesMarginUnitContent|default('px') }};
  106. }
  107. .blog {
  108. {% if noBackgroundCheckbox == 0 %}
  109. {% if backgroundCheckbox == 1 %}
  110. {% if backgroundGradientCheckbox == 1 %}
  111. background: linear-gradient({{ backgroundGradientDirection }}, {{ backgroundGradientColor1 ~ ' ' ~ backgroundGradientColor1Position ~ '%' }}, {{ backgroundGradientColor2 ~ ' ' ~ backgroundGradientColor2Position ~ '%' }});
  112. {% else %}
  113. background-color: {{ backgroundColor }};
  114. {% endif %}
  115. {% else %}
  116. background-image: url('{{ backgroundImage }}');
  117. background-size: cover;
  118. background-position: center;
  119. {% endif %}
  120. {% endif %}
  121. }
  122. /* ========================================
  123. ARTICLES - STRUCTURE ET LAYOUT
  124. ======================================== */
  125. .blog .blog-head .blog-link:hover {
  126. {% if backgroundCheckbox == 1 %}
  127. {% if backgroundGradientCheckbox == 1 %}
  128. background: linear-gradient({{ backgroundGradientDirection }}, {{ backgroundGradientColor1 ~ ' ' ~ backgroundGradientColor1Position ~ '%' }}, {{ backgroundGradientColor2 ~ ' ' ~ backgroundGradientColor2Position ~ '%' }});
  129. {% else %}
  130. background-color: {{ backgroundColor }};
  131. {% endif %}
  132. {% endif %}
  133. }
  134. </style>