feat(projets): ajoute un bouton « Voir plus » qui affiche les projets 3 par 3
Au-delà de 3 projets publiés, les suivants sont masqués et un bouton « Voir plus de projets (N restants) » révèle les 3 suivants à chaque clic, puis disparaît quand tout est affiché. - tous les projets restent dans le HTML (indexables par Google) - sans JavaScript, tous les projets sont visibles et le bouton est masqué - le focus passe au premier projet révélé (clavier, lecteurs d'écran) - bouton sans contour, centré sous la grille Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
3d75cda7b1
commit
30f177c3d5
3 changed files with 83 additions and 3 deletions
|
|
@ -1253,6 +1253,40 @@ a:hover {
|
|||
}
|
||||
}
|
||||
|
||||
/* Pagination "Voir plus" : active uniquement avec JS, sinon tous les projets sont visibles */
|
||||
.js .project-card--extra:not(.is-revealed) {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.no-js .projects__more {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.project-card:focus {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.project-card:focus-visible {
|
||||
outline: 2px solid var(--accent);
|
||||
outline-offset: 4px;
|
||||
}
|
||||
|
||||
.projects__more {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
margin-top: var(--space-xl);
|
||||
}
|
||||
|
||||
.projects__more .btn,
|
||||
.projects__more .btn:hover {
|
||||
border-color: transparent;
|
||||
}
|
||||
|
||||
.projects__more-count {
|
||||
opacity: 0.7;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.project-card {
|
||||
background-color: var(--bg-card);
|
||||
border: 1px solid var(--border);
|
||||
|
|
|
|||
|
|
@ -149,6 +149,38 @@ var lerpCurrent = 0;
|
|||
navProjectsLink.parentElement.classList.add('nav-projects-hidden');
|
||||
}
|
||||
|
||||
/* ============================================
|
||||
PROJECTS: "VOIR PLUS" (3 PAR 3)
|
||||
============================================ */
|
||||
|
||||
const projectsMoreBtn = document.getElementById('projectsMore');
|
||||
|
||||
if (projectsMoreBtn) {
|
||||
const projectsStep = parseInt(projectsMoreBtn.dataset.step, 10) || 3;
|
||||
const projectsCount = projectsMoreBtn.querySelector('.projects__more-count');
|
||||
|
||||
projectsMoreBtn.addEventListener('click', function () {
|
||||
const hiddenCards = document.querySelectorAll('#projects-grid .project-card--extra:not(.is-revealed)');
|
||||
const nextCards = Array.prototype.slice.call(hiddenCards, 0, projectsStep);
|
||||
const remaining = hiddenCards.length - nextCards.length;
|
||||
|
||||
nextCards.forEach(function (card) {
|
||||
card.classList.add('is-revealed');
|
||||
});
|
||||
|
||||
// Focus sur le premier projet révélé (clavier / lecteurs d'écran)
|
||||
if (nextCards.length) {
|
||||
nextCards[0].focus({ preventScroll: true });
|
||||
}
|
||||
|
||||
if (remaining <= 0) {
|
||||
projectsMoreBtn.parentElement.remove();
|
||||
} else if (projectsCount) {
|
||||
projectsCount.textContent = '(' + remaining + ' restant' + (remaining > 1 ? 's' : '') + ')';
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* ============================================
|
||||
ACTIVE NAV LINK ON SCROLL
|
||||
============================================ */
|
||||
|
|
|
|||
20
index.php
20
index.php
|
|
@ -344,12 +344,16 @@ $captchaQuestion = "{$captchaA} + {$captchaB} = ?";
|
|||
<h2 id="projects-title" class="section__title">Ce que j'ai construit</h2>
|
||||
<p class="section__intro">Chaque projet présenté ici a été conçu et développé entièrement par mes soins — sans thème pré-acheté, sans constructeur de page. Du code écrit sur mesure, pour un résultat solide et durable.</p>
|
||||
|
||||
<div class="projects__grid">
|
||||
<?php foreach ($projects as $project):
|
||||
<?php
|
||||
$projectsPerStep = 3;
|
||||
$projectsTotal = count($projects);
|
||||
?>
|
||||
<div class="projects__grid" id="projects-grid">
|
||||
<?php foreach ($projects as $index => $project):
|
||||
$badge = formatBadge($project['badge']);
|
||||
$techs = parseTechnologies($project['technologies']);
|
||||
?>
|
||||
<article class="project-card reveal" aria-label="<?= htmlspecialchars($project['title'], ENT_QUOTES, 'UTF-8') ?>">
|
||||
<article class="project-card reveal<?= $index >= $projectsPerStep ? ' project-card--extra' : '' ?>" tabindex="-1" aria-label="<?= htmlspecialchars($project['title'], ENT_QUOTES, 'UTF-8') ?>">
|
||||
<?php if (!empty($project['image'])): ?>
|
||||
<div class="project-card__image">
|
||||
<img src="assets/img/projects/<?= htmlspecialchars($project['image'], ENT_QUOTES, 'UTF-8') ?>"
|
||||
|
|
@ -383,6 +387,16 @@ $captchaQuestion = "{$captchaA} + {$captchaB} = ?";
|
|||
</article>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
|
||||
<?php if ($projectsTotal > $projectsPerStep): ?>
|
||||
<div class="projects__more">
|
||||
<button type="button" class="btn btn--outline btn--lg" id="projectsMore"
|
||||
aria-controls="projects-grid" data-step="<?= $projectsPerStep ?>">
|
||||
Voir plus de projets
|
||||
<span class="projects__more-count">(<?= $projectsTotal - $projectsPerStep ?> restant<?= $projectsTotal - $projectsPerStep > 1 ? 's' : '' ?>)</span>
|
||||
</button>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</section>
|
||||
<?php endif; ?>
|
||||
|
|
|
|||
Loading…
Reference in a new issue