Add accordion + active-filter chip bar for mobile repertoire

- repertoire-index.php: wrap each filter column in rep-accordion with toggle
  button, chevron, badge (active filter count); add rep-chip-bar with
  removable active-filter chips above the columns
- repertoire.css: mobile (≤640px) accordion mode — columns collapse to
  single-open accordion sections with 48px touch targets; chip bar becomes
  sticky; desktop/tablet layout unchanged via display:none on toggle elements
- repertoire.php: JS for single-accordion-open behavior on mobile, HTMX
  re-init after swap, resize-breakpoint cleanup
- docs/repertoire-mobile-propositions.md: analysis + 4 architecture proposals
This commit is contained in:
Pontoporeia
2026-06-22 15:45:58 +02:00
parent cca3d08f05
commit ecb90ba5dd
5 changed files with 529 additions and 45 deletions

View File

@@ -106,9 +106,50 @@ foreach ($filterColumns as $col) {
fn($i) => $i['matched']
));
}
// ── Active filter chips ─────────────────────────────────────────────────────
// Build a flat list of {dim, label, value, url} for every active filter entry.
$activeChips = [];
$dimLabels = [
'years' => 'Année',
'ap' => 'AP',
'or' => 'Orientation',
'fi' => 'Finalité',
'kw' => 'Mot-clé',
];
foreach (['years', 'ap', 'or', 'fi', 'kw'] as $dim) {
foreach ($activeSets[$dim] as $val) {
$activeChips[] = [
'dim' => $dim,
'label' => $dimLabels[$dim],
'value' => $val,
'url' => repToggleUrl($activeSets, $dim, $val),
];
}
}
?>
<div id="repertoire-index" class="repertoire-index">
<?php if ($anyActive): ?>
<!-- Active filter chips bar -->
<div class="rep-chip-bar" role="status" aria-label="Filtres actifs">
<span class="rep-chip-bar__label">Filtres&nbsp;:</span>
<?php foreach ($activeChips as $chip): ?>
<button type="button" class="rep-chip"
hx-get="<?= htmlspecialchars($chip['url']) ?>"
hx-target="#repertoire-index"
hx-swap="outerHTML"
hx-push-url="true"
hx-indicator="#rep-indicator"
aria-label="Retirer le filtre <?= htmlspecialchars($chip['label']) ?> : <?= htmlspecialchars($chip['value']) ?>">
<span class="rep-chip__dim"><?= htmlspecialchars($chip['label']) ?></span>
<span class="rep-chip__value"><?= htmlspecialchars($chip['value']) ?></span>
<span class="rep-chip__remove" aria-hidden="true">×</span>
</button>
<?php endforeach; ?>
</div>
<?php endif; ?>
<?php
// Render filter columns in the correct left-to-right order.
// Students column (non-filter) is inserted between keywords and AP/or/fi/years.
@@ -117,8 +158,15 @@ $renderOrder = ['years', 'ap', 'or', 'fi', 'students', 'kw'];
foreach ($renderOrder as $colKey):
if ($colKey === 'students'): ?>
<!-- ÉTUDIANTES -->
<section class="repertoire-col" data-col="students">
<h2>Étudiant·es</h2>
<section class="repertoire-col rep-accordion" data-col="students">
<h2>
<span class="rep-accordion__heading-text">Étudiant·es</span>
<button type="button" class="rep-accordion__toggle" aria-expanded="false">
Étudiant·es
<span class="rep-accordion__chevron" aria-hidden="true"></span>
</button>
</h2>
<div class="rep-accordion__panel">
<ul>
<?php if (empty($studentWorks)): ?>
<li class="rep-empty">—</li>
@@ -143,16 +191,32 @@ foreach ($renderOrder as $colKey):
<?php endforeach; ?>
<?php endif; ?>
</ul>
</div>
</section>
<?php else:
$col = array_values(array_filter($filterColumns, fn($c) => $c['dim'] === $colKey))[0]; ?>
<section class="repertoire-col" data-col="<?= $col['dim'] ?>">
<h2><?= $col['heading'] ?></h2>
$col = array_values(array_filter($filterColumns, fn($c) => $c['dim'] === $colKey))[0];
// Count active filters in this column for the badge
$activeCount = count($activeSets[$col['dim']]);
?>
<section class="repertoire-col rep-accordion" data-col="<?= $col['dim'] ?>">
<h2>
<span class="rep-accordion__heading-text"><?= $col['heading'] ?></span>
<button type="button" class="rep-accordion__toggle" aria-expanded="false">
<?= $col['heading'] ?>
<?php if ($activeCount > 0): ?>
<span class="rep-accordion__badge"><?= $activeCount ?></span>
<?php endif; ?>
<span class="rep-accordion__chevron" aria-hidden="true"></span>
</button>
</h2>
<div class="rep-accordion__panel">
<ul>
<?php foreach ($repData[$col['dataKey']] as $item):
repFilterEntry($item, $col['dim'], $activeSets, $anyActive, $colHasMatches[$col['dim']], $hx);
endforeach; ?>
</ul>
</div>
</section>
<?php endif;
endforeach; ?>