-
Notifications
You must be signed in to change notification settings - Fork 1
/
RawgTopRatedGames.jsx
50 lines (48 loc) · 2.54 KB
/
RawgTopRatedGames.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import { Link } from "react-router-dom";
import { FcRating } from "react-icons/fc";
import { MdRateReview } from "react-icons/md";
import { FaGripfire } from "react-icons/fa6";
import { FaStarHalfAlt } from "react-icons/fa";
const RawgTopRatedGames = ({ gamesList }) => {
return (
<div className="p-5">
<h2 className="text-3xl font-bold text-gray-400 mb-4 mt-6 text-center">Top Rated Games</h2>
<div className="flex flex-wrap justify-center">
{/* Container for the top games */}
<div className="flex flex-wrap w-full justify-center">
{gamesList
.sort((a, b) => b.rating - a.rating)
.map((game, index) => index < 24 && (
<div
key={game.id}
className="relative w-full sm:w-1/2 md:w-1/3 lg:w-1/4 xl:w-1/5 bg-secondary rounded overflow-hidden shadow-lg m-4 group hover:scale-110 transition-all duration-300 ease cursor-pointer"
>
<Link to={`/games/${game.id}`}>
<img loading="lazy" width={100} height={40} className="w-full h-40 object-cover" src={game.short_screenshots[0].image} alt={game.name} />
</Link>
<div className="absolute top-0 right-0 p-2 bg-gray-800 text-white rounded-bl">
<FcRating alt="MetaCritic Rating" /> {game.metacritic}
</div>
<div className="px-6 py-4">
<div className="font-bold text-base mb-2">{`${game.name}`}</div>
<div className="flex items-center gap-3 justify-center">
<p className="text-gray-400 text-sm flex items-center">
<FaStarHalfAlt alt="The number of ratings" /> {game.rating}{" "}
</p>
<p className="text-gray-400 text-sm flex items-center">
<MdRateReview alt="The number of reviews" /> {game.reviews_count}{" "}
</p>
<p className="text-gray-400 text-sm flex items-center">
<FaGripfire alt="Suggestions" /> {game.suggestions_count}
</p>
</div>
</div>
</div>
)
)}
</div>
</div>
</div>
);
};
export default RawgTopRatedGames;