{% set withContact = showContact | default('true') == 'true' %}
{% set container = containerSize | default('container') %}
{# Defined as EditableDialogBoxInterface field #}
{% set faqObjects = faqObjects ?? pimcore_relations('frequently-asked-questions').getElements() %}
{% embed 'app/area-brick-layout.html.twig' %}
{% block content %}
{% if editmode and faqObjects is empty %}
<div class="container text-center text-red">
<h2>Nog geen vragen gekoppeld, dit brick is momenteel niet zichtbaar.</h2>
</div>
{% elseif faqObjects is not empty %}
<section class="delay-200">
<div class="{{ container }} {{ containerClass | default() }} flex flex-wrap py-10 md:py-20">
<div class="w-full {% if withContact %} md:w-1/2 {% endif %}">
{% if showAutoNotice ?? true %}
{% include 'areas/faq-brick/partials/editmode/_no-objects-found.html.twig' %}
{% endif %}
{% if faqObjects is not empty %}
<h2 class="mb-4 text-2xl md:mb-10 mb:text-3xl">{{ "Veelgestelde vragen"|trans }}</h2>
{% for faq in faqObjects %}
<div class="px-4 mb-2 bg-white rounded-md shadow md:px-6 md:mb-3" x-data="{ open: false }">
<div
class="flex items-center justify-between py-6 cursor-pointer"
@click="open = !open"
>
<h3 class="mb-0 text-lg leading-tight">{{ faq.question }}</h3>
<span
class="flex items-center justify-center w-8 h-8 transition-all duration-500 bg-blue-200 rounded-full shrink-0"
:class="{ 'rotate-180' : !open }"
>
<svg class="w-4 h-3" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 17 10">
<path fill="#0072BB" fill-rule="evenodd" d="M.39 7.64 7.12.676c.24-.248.575-.388.926-.388.35 0 .685.14.925.388l6.732 6.964a1.206 1.206 0 0 1-.068 1.748l-.114.09a1.297 1.297 0 0 1-1.669-.154L8.045 3.316 2.239 9.323a1.295 1.295 0 0 1-1.783.065A1.205 1.205 0 0 1 .389 7.64H.39Z"/>
</svg>
</span>
</div>
<div class="block overflow-hidden transition-all duration-700 max-h-0"
:style="open ? `max-height: ${ $el.scrollHeight + 24 }px` : ``"
:class="{ 'pb-6' : open }"
>
<p>{{ faq.answer|raw }}</p>
</div>
</div>
{% endfor %}
{% endif %}
</div>
{% if withContact == 'true' %}
<div class="flex flex-col w-full mt-8 md:flex-row md:mt-0 md:w-1/2 lg:pl-36">
{% include 'includes/partials/_contact-snippet.html.twig' %}
</div>
{% endif %}
</div>
</section>
{% endif %}
{% endblock %}
{% endembed %}
{% if faqObjects is not empty %}
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "FAQPage",
"mainEntity": [
{% for faq in faqObjects %}
{
"@type": "Question",
"name": "{{ faq.question }}",
"acceptedAnswer": {
"@type": "Answer",
"text": "{{ faq.answer | raw | escape }}"
}
}{% if not loop.last %},{% endif %}
{% endfor %}
]
}
</script>
{% endif %}