templates/includes/blocks/faqSection.html.twig line 1

Open in your IDE?
  1. <section class="faq-section bg-white text-blue lg:p-4" fade fade-trigger="scroll" section-shade="light">
  2.   <div class="big-container bg-light pt-12 px-[120px] pb-16">
  3.     <div class="w-full max-w-[1168px] mx-auto">
  4.       <nav batch-wrapp>
  5.         <ul class="projects-type-wrapp flex flex-wrap gap-x-2 md:gap-x-4 gap-y-4 md:gap-y-5">
  6.           <li fade fade-trigger="batch">
  7.             <button class="project-type-btn blue {{loop.first ? 'active'}}"
  8.               data-tab="{{ item.id|getFaqCategories|lower|replace({' ': "_"}) }}">
  9.               <svg>
  10.                 <use xlink:href="#icon-check" />
  11.               </svg>
  12.               {{ content.filterDefaultText }}
  13.             </button>
  14.           </li>
  15.           {% for item in content.categories %}
  16.           <li fade fade-trigger="batch">
  17.             <button class="project-type-btn blue"
  18.               data-tab="{{ item.id|getFaqCategories|lower|replace({' ': "_"}) }}">
  19.               <svg>
  20.                 <use xlink:href="#icon-check" />
  21.               </svg>
  22.               {{ item.id|getFaqCategories }}
  23.             </button>
  24.           </li>
  25.           {% endfor %}
  26.         </ul>
  27.       </nav>
  28.       {% set items = {} %}
  29.       {% set i = 0 %}
  30.       {% set sortedFaqs = content.faqs|sort((a, b) => a.descriptionSectionTitle <=> b.descriptionSectionTitle) %}
  31.       {% for item in sortedFaqs %}
  32.           {% set items = items|merge({
  33.               (i): {
  34.                   'descriptionSectionCategory': item.descriptionSectionCategory.id|getFaqCategories,
  35.                   'descriptionSectionTitle': item.descriptionSectionTitle,
  36.                   'descriptionSectionText': item.descriptionSectionText
  37.               }
  38.           }) %}
  39.           {% set i = i + 1 %}
  40.       {% endfor %}
  41.       <div class="tabs-wrapp flex flex-col gap-2 mt-10" fade fade-trigger="scroll">
  42.         {% for tab in content.categories %}
  43.           <div id='item_content' class="faq-tab flex flex-col gap-2" data-tab="{{tab.id|getFaqCategories|lower|replace({' ': "_"})}}">
  44.             {% for item in items %}
  45.              {% if tab.id|getFaqCategories == item.descriptionSectionCategory %}
  46.               <dl class="faq-item flex flex-col border border-transparent">
  47.                 <dt class="bg-white flex justify-between p-6 gap-3 cursor-default">
  48.                   <p id='item_title' class="text-lg md:text-2xl">
  49.                     {{item.descriptionSectionTitle}}
  50.                   </p>
  51.                   <button class="faq-item__button outline-none h-max rounded-md focus-visible:shadow-[0_0_0_5px_rgba(0,0,0,0.1)] duration-300 group">
  52.                     <svg class="faq-item__plus w-8 h-8 shrink-0 duration-300">
  53.                       <use xlink:href="#icon-plus" />
  54.                     </svg>
  55.                   </button>
  56.                 </dt>
  57.                 <dd class="faq-item__answer bg-gray h-0 overflow-hidden">
  58.                   <p class="text-sm m-6">{{item.descriptionSectionText|raw}}</p>
  59.                 </dd>
  60.               </dl>
  61.              {% endif %}
  62.             {% endfor %}
  63.            </div>
  64.         {% endfor %}
  65.       </div>
  66.     </div>
  67.   </div>
  68. </section>
  69. <script>
  70.   // JavaScript code to sort item_content divs by item_title
  71.   document.addEventListener('DOMContentLoaded', function () {
  72.     const faqTabs = document.querySelectorAll('.faq-tab');
  73.     const faqTabsWithTitles = [];
  74.     faqTabs.forEach((faqTab, index) => {
  75.       const itemTitle = faqTab.querySelector('#item_title').textContent;
  76.       faqTabsWithTitles.push({ element: faqTab, title: itemTitle, index });
  77.     });
  78.     faqTabsWithTitles.sort((a, b) => a.title.localeCompare(b.title));
  79.     const tabsWrapp = document.querySelector('.tabs-wrapp');
  80.     faqTabsWithTitles.forEach((faqTabWithTitle) => {
  81.       tabsWrapp.appendChild(faqTabWithTitle.element);
  82.     });
  83.   });
  84. </script>