Skip to content

Commit

Permalink
Merge pull request #43 from group14-aaa/anjal/styling
Browse files Browse the repository at this point in the history
Anjal/styling
  • Loading branch information
anjalsali committed Feb 15, 2024
2 parents 018a232 + ffac8c2 commit a1227f0
Showing 1 changed file with 45 additions and 33 deletions.
78 changes: 45 additions & 33 deletions src/components/RawgTopRatedGames.jsx
Original file line number Diff line number Diff line change
@@ -1,40 +1,52 @@
import { Link } from 'react-router-dom';


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">
Most Popular 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="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">

{/* Game image */}
<Link to={`/games/${game.id}`}>
<img className="w-full h-40 object-cover" src={game.short_screenshots[0].image} alt={game.name} />
</Link>

{/* Game name and rating */}
<div className="px-6 py-4">
<div className="font-bold text-base mb-2">
{`${index + 1}. ${game.name}`}
</div>
<p className="text-gray-400 text-sm">
Rating: {game.rating}
</p>
</div>
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 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>
</div>
</div>
);
);
};

export default RawgTopRatedGames;

0 comments on commit a1227f0

Please sign in to comment.