mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-06-25 16:19:19 +02:00
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:
@@ -16,7 +16,7 @@
|
||||
display: grid;
|
||||
grid-template-columns:
|
||||
minmax(3rem, 0.45fr)
|
||||
minmax(12rem, 1fr)
|
||||
minmax(16rem, 1.2fr)
|
||||
minmax(9rem, 1fr)
|
||||
minmax(7rem, 1fr)
|
||||
minmax(8rem, 1fr)
|
||||
@@ -29,45 +29,92 @@
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
@media (max-width: 1024px) {
|
||||
.repertoire-index {
|
||||
grid-template-columns: 1fr 1fr 1fr;
|
||||
padding: 0;
|
||||
grid-template-rows: auto auto 1fr;
|
||||
min-height: auto;
|
||||
/* ---- Active filter chip bar ---- */
|
||||
.rep-chip-bar {
|
||||
display: none;
|
||||
}
|
||||
|
||||
@media (max-width: 1025px) {
|
||||
.rep-chip-bar {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: var(--space-2xs);
|
||||
padding: var(--space-2xs) var(--space-s);
|
||||
border-bottom: 1px solid var(--border-secondary);
|
||||
margin: 0;
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 10;
|
||||
background: var(--bg-primary);
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 600px) {
|
||||
.repertoire-index {
|
||||
grid-template-columns: 1fr;
|
||||
padding: 0;
|
||||
grid-template-rows: none;
|
||||
min-height: auto;
|
||||
}
|
||||
.rep-chip-bar__label {
|
||||
font-family: var(--font-display);
|
||||
font-size: var(--step--2);
|
||||
letter-spacing: 0.08em;
|
||||
text-transform: uppercase;
|
||||
color: var(--text-secondary);
|
||||
margin-right: var(--space-3xs);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
/* On single column, each section is a self-contained block again */
|
||||
.repertoire-col {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
min-height: 12rem;
|
||||
border-bottom: 1px solid var(--border-primary);
|
||||
}
|
||||
.rep-chip {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: var(--space-3xs);
|
||||
padding: var(--space-3xs) var(--space-2xs);
|
||||
background: var(--accent-muted);
|
||||
border: 1px solid var(--accent-primary);
|
||||
border-radius: 99px;
|
||||
font-family: var(--font-body);
|
||||
font-size: var(--step--2);
|
||||
color: var(--accent-primary);
|
||||
cursor: pointer;
|
||||
white-space: nowrap;
|
||||
transition: background 0.15s, color 0.15s;
|
||||
}
|
||||
|
||||
.repertoire-col:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
.rep-chip:hover {
|
||||
background: var(--accent-primary);
|
||||
color: var(--accent-foreground);
|
||||
}
|
||||
|
||||
.repertoire-col > h2 {
|
||||
grid-row: unset;
|
||||
align-self: unset;
|
||||
}
|
||||
.rep-chip__dim {
|
||||
font-weight: 500;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.05em;
|
||||
font-size: 0.75em;
|
||||
color: var(--accent-secondary);
|
||||
}
|
||||
|
||||
.repertoire-col > ul {
|
||||
grid-row: unset;
|
||||
flex: 1;
|
||||
}
|
||||
.rep-chip:hover .rep-chip__dim {
|
||||
color: inherit;
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
.rep-chip__remove {
|
||||
font-size: 1.1em;
|
||||
line-height: 1;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
/* ---- Accordion: visible only on mobile (≤ 640px) ---- */
|
||||
|
||||
/* Desktop: heading-text visible, toggle hidden */
|
||||
.rep-accordion__heading-text {
|
||||
/* visible — inherits the h2 styling above */
|
||||
}
|
||||
|
||||
.rep-accordion__toggle,
|
||||
.rep-accordion__chevron,
|
||||
.rep-accordion__badge {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.rep-accordion__panel {
|
||||
display: contents;
|
||||
}
|
||||
|
||||
/* Each section becomes transparent to the grid so h2+ul sit in the 2-row layout */
|
||||
@@ -79,33 +126,215 @@
|
||||
grid-row: 1;
|
||||
font-family: var(--font-display);
|
||||
font-size: var(--step--1);
|
||||
letter-spacing: 0.12em;
|
||||
letter-spacing: 0.08em;
|
||||
text-transform: uppercase;
|
||||
color: var(--text-primary);
|
||||
font-weight: 398;
|
||||
line-height: 23px;
|
||||
line-height: 1.3;
|
||||
margin: 0;
|
||||
padding: var(--space-xs) 0 var(--space-3xs) 0;
|
||||
border-bottom: 1px solid var(--text-primary);
|
||||
align-self: end;
|
||||
hyphens: manual;
|
||||
hyphens: auto;
|
||||
word-break: normal;
|
||||
overflow-wrap: normal;
|
||||
overflow-wrap: break-word;
|
||||
}
|
||||
|
||||
.repertoire-col > ul {
|
||||
grid-row: 2;
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
padding: var(--space-2xs) 0 var(--space-l) 0;
|
||||
padding-top: var(--space-2xs);
|
||||
padding-bottom: var(--space-l);
|
||||
padding-left: 0;
|
||||
padding-right: 0;
|
||||
}
|
||||
|
||||
/* Strip list chrome inside repertoire columns */
|
||||
.repertoire-col ul {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
/* ---- Responsive (≤ 1025px): accordion mode, chip bar, students as results ---- */
|
||||
@media (max-width: 1025px) {
|
||||
.repertoire-index {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 0;
|
||||
height: 100%;
|
||||
overflow-y: hidden;
|
||||
gap: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
/* Each column becomes a block-level accordion section */
|
||||
.repertoire-col {
|
||||
display: block;
|
||||
border-bottom: 1px solid var(--text-primary);
|
||||
}
|
||||
|
||||
.repertoire-col[data-col="students"] {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
/* Flex order: years/ap/or/fi first, then keywords, students last */
|
||||
.repertoire-col[data-col="years"] { order: 0; }
|
||||
.repertoire-col[data-col="ap"] { order: 1; }
|
||||
.repertoire-col[data-col="or"] { order: 2; }
|
||||
.repertoire-col[data-col="fi"] { order: 3; }
|
||||
.repertoire-col[data-col="kw"] { order: 4; }
|
||||
.repertoire-col[data-col="students"] { order: 5; }
|
||||
|
||||
/* Students column: not an accordion — open results list below filters */
|
||||
.repertoire-col[data-col="students"] {
|
||||
border-bottom: none;
|
||||
border-top: none;
|
||||
margin-top: 0;
|
||||
padding-top: 0;
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.repertoire-col[data-col="students"] .rep-accordion__toggle {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.repertoire-col[data-col="students"] .rep-accordion__heading-text {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.repertoire-col[data-col="students"] .rep-accordion__panel {
|
||||
display: block;
|
||||
max-height: none;
|
||||
overflow-y: auto;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
/* Hide the plain h2 — the toggle button replaces it */
|
||||
.repertoire-col > h2 {
|
||||
display: block;
|
||||
grid-row: unset;
|
||||
align-self: unset;
|
||||
border-bottom: none;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
font-size: inherit;
|
||||
line-height: inherit;
|
||||
}
|
||||
|
||||
/* Hide heading text on mobile (toggle button replaces it) */
|
||||
.rep-accordion__heading-text {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* Accordion toggle: full-width touch target */
|
||||
.rep-accordion__toggle {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
width: 100%;
|
||||
min-height: 48px;
|
||||
padding: var(--space-xs) var(--space-s);
|
||||
background: none;
|
||||
border: none;
|
||||
font-family: var(--font-display);
|
||||
font-size: var(--step--2);
|
||||
letter-spacing: 0.08em;
|
||||
text-transform: uppercase;
|
||||
color: var(--text-primary);
|
||||
font-weight: 398;
|
||||
text-align: left;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.rep-accordion__toggle:active {
|
||||
background: var(--bg-secondary);
|
||||
}
|
||||
|
||||
/* Badge: active filter count */
|
||||
.rep-accordion__badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-width: 1.4em;
|
||||
height: 1.4em;
|
||||
padding: 0 0.35em;
|
||||
margin-left: var(--space-2xs);
|
||||
background: var(--accent-primary);
|
||||
color: var(--accent-foreground);
|
||||
border-radius: 99px;
|
||||
font-family: var(--font-body);
|
||||
font-size: var(--step--2);
|
||||
font-weight: 500;
|
||||
letter-spacing: 0;
|
||||
text-transform: none;
|
||||
}
|
||||
|
||||
/* Chevron: CSS triangle */
|
||||
.rep-accordion__chevron {
|
||||
display: inline-block;
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
flex-shrink: 0;
|
||||
margin-left: var(--space-2xs);
|
||||
border-right: 2px solid var(--text-secondary);
|
||||
border-bottom: 2px solid var(--text-secondary);
|
||||
transform: rotate(45deg);
|
||||
transition: transform 0.2s;
|
||||
}
|
||||
|
||||
.rep-accordion__toggle[aria-expanded="true"] .rep-accordion__chevron {
|
||||
transform: rotate(-135deg);
|
||||
}
|
||||
|
||||
/* Panel: collapsed by default */
|
||||
.rep-accordion__panel {
|
||||
display: block;
|
||||
max-height: 0;
|
||||
overflow: hidden;
|
||||
transition: max-height 0.3s ease;
|
||||
}
|
||||
|
||||
.rep-accordion__panel.is-open {
|
||||
max-height: 60vh;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
/* Reposition the <ul> inside the panel */
|
||||
.repertoire-col ul {
|
||||
grid-row: unset;
|
||||
overflow-y: visible;
|
||||
padding: 0;
|
||||
padding-left: 1ch;
|
||||
}
|
||||
|
||||
/* Larger touch targets for filter entries */
|
||||
.rep-entry {
|
||||
padding: var(--space-2xs) 0;
|
||||
min-height: 44px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
/* Years column: keep big numbers but smaller on mobile */
|
||||
.repertoire-col[data-col="years"] .rep-entry {
|
||||
font-size: var(--step-2);
|
||||
min-height: 48px;
|
||||
}
|
||||
|
||||
/* Column heading font-size is handled by the toggle button */
|
||||
.repertoire-col > h2 {
|
||||
font-size: inherit;
|
||||
line-height: inherit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* ---- rep-entry: shared base (button + link variants) ---- */
|
||||
.rep-entry {
|
||||
display: block;
|
||||
|
||||
@@ -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 :</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; ?>
|
||||
|
||||
@@ -44,3 +44,81 @@
|
||||
}, true);
|
||||
}());
|
||||
</script>
|
||||
|
||||
<script>
|
||||
// Mobile accordion: single-open behavior + HTMX re-init
|
||||
(function () {
|
||||
var INDEX_SEL = '#repertoire-index';
|
||||
var ACCORDION_SEL = '.rep-accordion';
|
||||
var TOGGLE_SEL = '.rep-accordion__toggle';
|
||||
var PANEL_SEL = '.rep-accordion__panel';
|
||||
|
||||
function isMobile() {
|
||||
return window.matchMedia('(max-width: 1025px)').matches;
|
||||
}
|
||||
|
||||
function initAccordions(root) {
|
||||
if (!isMobile()) return;
|
||||
var toggles = root.querySelectorAll(TOGGLE_SEL);
|
||||
toggles.forEach(function (btn) {
|
||||
// Skip students column — always visible, not an accordion
|
||||
if (btn.closest('[data-col="students"]')) return;
|
||||
if (btn._accordionBound) return;
|
||||
btn._accordionBound = true;
|
||||
btn.addEventListener('click', function () {
|
||||
var section = btn.closest(ACCORDION_SEL);
|
||||
var panel = section.querySelector(PANEL_SEL);
|
||||
var isOpen = btn.getAttribute('aria-expanded') === 'true';
|
||||
|
||||
// Close all others (except students)
|
||||
root.querySelectorAll(ACCORDION_SEL).forEach(function (s) {
|
||||
if (s.dataset.col === 'students') return;
|
||||
var p = s.querySelector(PANEL_SEL);
|
||||
var t = s.querySelector(TOGGLE_SEL);
|
||||
if (s !== section) {
|
||||
t.setAttribute('aria-expanded', 'false');
|
||||
p.classList.remove('is-open');
|
||||
}
|
||||
});
|
||||
|
||||
// Toggle this one
|
||||
var nowOpen = !isOpen;
|
||||
btn.setAttribute('aria-expanded', nowOpen ? 'true' : 'false');
|
||||
if (nowOpen) {
|
||||
panel.classList.add('is-open');
|
||||
} else {
|
||||
panel.classList.remove('is-open');
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Initial bind
|
||||
initAccordions(document);
|
||||
|
||||
// Re-bind after HTMX swaps
|
||||
document.body.addEventListener('htmx:afterSwap', function (e) {
|
||||
if (e.detail.target && e.detail.target.matches && e.detail.target.matches(INDEX_SEL)) {
|
||||
initAccordions(e.detail.target);
|
||||
}
|
||||
});
|
||||
|
||||
// Re-bind on resize crossing the breakpoint
|
||||
var wasMobile = isMobile();
|
||||
window.addEventListener('resize', function () {
|
||||
var nowMobile = isMobile();
|
||||
if (nowMobile !== wasMobile) {
|
||||
wasMobile = nowMobile;
|
||||
// When switching to desktop, close all panels
|
||||
if (!nowMobile) {
|
||||
document.querySelectorAll(INDEX_SEL + ' ' + TOGGLE_SEL).forEach(function (btn) {
|
||||
btn.setAttribute('aria-expanded', 'false');
|
||||
});
|
||||
document.querySelectorAll(INDEX_SEL + ' ' + PANEL_SEL).forEach(function (p) {
|
||||
p.classList.remove('is-open');
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}());
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user