77 lines
3.3 KiB
PHP
77 lines
3.3 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
declare(strict_types=1);
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Kombi-Sektion: FAQ (2/3) + einzelner Ansprechpartner (1/3) nebeneinander.
|
||
|
|
* Sinnvoll, wenn es pro Mannschaft nur einen Kontakt gibt. Props:
|
||
|
|
* $faq array [{q, a}]
|
||
|
|
* $persons array — ein oder mehrere Ansprechpartner (person-card). Leer → FAQ volle Breite.
|
||
|
|
* Bei mehreren: Mini-Slider (ohne JS alle Karten gestapelt sichtbar).
|
||
|
|
* $faqTitle string (optional, Default 'Häufige Fragen')
|
||
|
|
* $faqIntro string (optional) — gedämpfte Subline unter der Überschrift
|
||
|
|
* $contactTitle string (optional, Default 'Dein Ansprechpartner')
|
||
|
|
* $anchor string (optional, Default 'kontakt')
|
||
|
|
* Natives <details>/<summary> (ohne JS bedienbar); FAQPage-Schema liefert die Seite.
|
||
|
|
*/
|
||
|
|
$faqTitle = $faqTitle ?? 'Häufige Fragen';
|
||
|
|
$faqIntro = $faqIntro ?? '';
|
||
|
|
$contactTitle = $contactTitle ?? 'Dein Ansprechpartner';
|
||
|
|
$anchor = $anchor ?? 'kontakt';
|
||
|
|
$faq = array_values(array_filter(
|
||
|
|
$faq ?? [],
|
||
|
|
static fn (array $i): bool => !empty($i['q']) && !empty($i['a'])
|
||
|
|
));
|
||
|
|
$persons = array_values(array_filter($persons ?? [], static fn ($p): bool => !empty($p)));
|
||
|
|
$hasPerson = $persons !== [];
|
||
|
|
$isSlider = count($persons) > 1;
|
||
|
|
if ($faq === [] && !$hasPerson) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
?>
|
||
|
|
<section class="section faq-contact<?= $hasPerson ? '' : ' faq-contact--solo' ?>" id="<?= e($anchor) ?>">
|
||
|
|
<div class="container">
|
||
|
|
<h2 class="faq-contact__title"><?= e($faqTitle) ?></h2>
|
||
|
|
<?php if ($faqIntro !== ''): ?>
|
||
|
|
<p class="faq-contact__intro text-muted"><?= e($faqIntro) ?></p>
|
||
|
|
<?php endif; ?>
|
||
|
|
<div class="faq-contact__inner">
|
||
|
|
<div class="faq-contact__main">
|
||
|
|
<div class="faq__list">
|
||
|
|
<?php foreach ($faq as $item): ?>
|
||
|
|
<details class="faq__item">
|
||
|
|
<summary class="faq__q"><span><?= e($item['q']) ?></span><?= icon('chevron-down', 'faq__chevron') ?></summary>
|
||
|
|
<div class="faq__a"><p><?= e($item['a']) ?></p></div>
|
||
|
|
</details>
|
||
|
|
<?php endforeach; ?>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
<?php if ($hasPerson): ?>
|
||
|
|
<aside class="faq-contact__aside">
|
||
|
|
<?php if ($contactTitle !== ''): ?>
|
||
|
|
<h2><?= e($contactTitle) ?></h2>
|
||
|
|
<?php endif; ?>
|
||
|
|
<?php if ($isSlider): ?>
|
||
|
|
<div class="contact-slider" data-contact-slider>
|
||
|
|
<ul class="contact-slider__track">
|
||
|
|
<?php foreach ($persons as $p): ?>
|
||
|
|
<li class="contact-slider__slide" data-contact-slide>
|
||
|
|
<?php component('person-card', ['person' => $p]); ?>
|
||
|
|
</li>
|
||
|
|
<?php endforeach; ?>
|
||
|
|
</ul>
|
||
|
|
<div class="contact-slider__dots">
|
||
|
|
<?php foreach ($persons as $i => $p): ?>
|
||
|
|
<button type="button" class="contact-slider__dot" data-contact-dot<?= $i === 0 ? ' aria-current="true"' : '' ?> aria-label="Ansprechpartner <?= $i + 1 ?>: <?= e($p['name']) ?>"></button>
|
||
|
|
<?php endforeach; ?>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
<?php else: ?>
|
||
|
|
<?php component('person-card', ['person' => $persons[0]]); ?>
|
||
|
|
<?php endif; ?>
|
||
|
|
</aside>
|
||
|
|
<?php endif; ?>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
</section>
|