Ansprechpartner-Sektion: person-card/person-grid-Komponenten, Daten in ansprechpartner.json, Vereins-Platzhalter statt AdobeStock, tel:/mailto korrekt
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
41
app/components/person-card.php
Normal file
41
app/components/person-card.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Visitenkarte für eine Person. Props:
|
||||
* $person array{department, name, phone?, email?, image?}
|
||||
* Ohne image greift der Vereins-Platzhalter (Silhouette im TSV-Trikot).
|
||||
* Kontakt-Link: phone → tel:, sonst email → mailto:.
|
||||
*/
|
||||
$image = $person['image'] ?? null;
|
||||
$src = $image ?: 'img/persons/platzhalter.jpg';
|
||||
|
||||
if (!empty($person['phone'])) {
|
||||
$contactHref = 'tel:' . preg_replace('/[^+\d]/', '', $person['phone']);
|
||||
$contactLabel = $person['phone'];
|
||||
$contactIcon = 'telephone';
|
||||
} elseif (!empty($person['email'])) {
|
||||
$contactHref = 'mailto:' . $person['email'];
|
||||
$contactLabel = $person['email'];
|
||||
$contactIcon = 'envelope';
|
||||
} else {
|
||||
$contactHref = null;
|
||||
}
|
||||
?>
|
||||
<article class="person-card">
|
||||
<div class="person-card__media">
|
||||
<img src="<?= e(asset($src)) ?>"
|
||||
alt="<?= $image ? e($person['name']) : '' ?>"
|
||||
width="480" height="600" loading="lazy" decoding="async">
|
||||
</div>
|
||||
<div class="person-card__body">
|
||||
<h3 class="person-card__department"><?= e($person['department']) ?></h3>
|
||||
<p class="person-card__name"><?= e($person['name']) ?></p>
|
||||
<?php if ($contactHref !== null): ?>
|
||||
<a class="person-card__contact" href="<?= e($contactHref) ?>">
|
||||
<?= icon($contactIcon) ?><span><?= e($contactLabel) ?></span>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</article>
|
||||
26
app/components/person-grid.php
Normal file
26
app/components/person-grid.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Ansprechpartner-Grid aus data/ansprechpartner.json.
|
||||
* Optionaler Prop: $anchor (Sektions-ID, Default 'ansprechpartner').
|
||||
*/
|
||||
$data = json_load('ansprechpartner');
|
||||
$anchor = $anchor ?? 'ansprechpartner';
|
||||
?>
|
||||
<section class="section persons" id="<?= e($anchor) ?>">
|
||||
<div class="container">
|
||||
<h2><?= e($data['title']) ?></h2>
|
||||
<?php if (!empty($data['intro'])): ?>
|
||||
<p class="persons__intro"><?= e($data['intro']) ?></p>
|
||||
<?php endif; ?>
|
||||
<ul class="persons__grid">
|
||||
<?php foreach ($data['persons'] as $person): ?>
|
||||
<li>
|
||||
<?php component('person-card', ['person' => $person]); ?>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</div>
|
||||
</section>
|
||||
Reference in New Issue
Block a user