Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/components/GameCard.astro
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,27 @@ const { game } = Astro.props;

<p class="text-slate-400 mb-4 text-sm line-clamp-2" data-testid="game-description">{game.description}</p>

<div class="mb-4 flex items-center gap-1" data-testid="game-rating">
{game.starRating !== null ? (
<>
<div class="flex gap-0.5">
{Array.from({ length: 5 }).map((_, i) => {
const fillPercentage = Math.max(0, Math.min(1, game.starRating! - i));
return (
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="relative" data-star={i} aria-hidden="true">
<path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z" fill="currentColor" class="text-slate-400" />
<path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z" fill="currentColor" class="text-yellow-500" style={{ clipPath: `inset(0 ${(1 - fillPercentage) * 100}% 0 0)` }} />
</svg>
);
})}
</div>
<span class="text-sm text-slate-400 ml-1">{game.starRating.toFixed(1)}</span>
</>
) : (
<span class="text-sm text-slate-400">No rating yet</span>
)}
</div>

<div class="mt-4 text-sm text-blue-400 font-medium flex items-center">
<span>View details</span>
<ArrowRight class="h-4 w-4 ml-1 transform transition-transform duration-300 group-hover:translate-x-2" aria-hidden="true" />
Expand Down