sokko-g/website/src/features/games/GamesPage.jsx

53 lines
2.5 KiB
JavaScript

// Rôle : liste les jeux déclarés et permet de reprendre le chargement de leur catalogue.
export function GamesPage({ siteContent, games, gamesError, gamesLoading, retryGames }) {
const content = siteContent.gamesPage;
return (
<>
<section className="page-hero nds-page-hero primary-list-hero">
<div>
<p className="eyebrow">{content.eyebrow}</p>
<h1>{content.title}</h1>
<p>{content.description}</p>
</div>
</section>
<section className="game-list">
{gamesError && games.length > 0 && <div className="nds-inline-notice" data-variant="warning" role="alert">
<span>{gamesError}</span>
<button className="nds-button" data-size="sm" type="button" onClick={retryGames}>{content.retryLabel}</button>
</div>}
{games.length ? games.map((game) => (
<article className="card nds-card game-card" data-variant="interactive" key={game.id}>
<a
className="card-cover nds-card-cover game-card-cover game-card-cover-link"
href={`#/games/${game.id}`}
aria-label={`Ouvrir ${game.title}`}
title={`Ouvrir ${game.title}`}
style={{ "--game-cover": game.cover || "var(--gradient-nebula)" }}
>
{game.images?.cardCover || game.image ? (
<img src={game.images?.cardCover || game.image} alt={game.title} loading="lazy" />
) : (
<span className="game-card-placeholder" aria-hidden="true">{game.title}</span>
)}
</a>
<div className="card-body nds-card-body">
<p className="eyebrow">{game.eyebrow || "Guide de jeu"}</p>
<h2>{game.title}</h2>
<p>{game.summary}</p>
<div className="card-actions nds-card-actions nds-toolbar">
<a className="nds-button" data-size="sm" data-variant="primary" href={`#/games/${game.id}`}>Ouvrir</a>
</div>
</div>
</article>
)) : (
<div className="empty nds-empty-state" aria-busy={gamesLoading}>
<h2>{gamesLoading ? content.loadingTitle : content.emptyTitle}</h2>
<p>{gamesLoading ? content.loadingText : gamesError || content.emptyText}</p>
{gamesError && <button className="nds-button" data-size="sm" data-variant="primary" type="button" onClick={retryGames}>{content.retryLabel}</button>}
</div>
)}
</section>
</>
);
}