degmods.com/src/components/GameCard.tsx

32 lines
733 B
TypeScript
Raw Normal View History

2024-09-18 21:43:36 +05:00
import { useNavigate } from 'react-router-dom'
2024-07-11 17:15:03 +05:00
import '../styles/cardGames.css'
import { handleGameImageError } from '../utils'
2024-09-18 21:43:36 +05:00
import { getGamePageRoute } from 'routes'
2024-07-11 17:15:03 +05:00
type GameCardProps = {
title: string
imageUrl: string
2024-07-11 17:15:03 +05:00
}
export const GameCard = ({ title, imageUrl }: GameCardProps) => {
2024-09-18 21:43:36 +05:00
const navigate = useNavigate()
2024-07-11 17:15:03 +05:00
return (
2024-09-18 21:43:36 +05:00
<div
className='cardGameMainWrapperLink'
onClick={() => navigate(getGamePageRoute(title))}
>
2024-09-02 09:49:53 +00:00
<div className='cardGameMainWrapper'>
2024-09-02 09:48:51 +00:00
<img
src={imageUrl}
onError={handleGameImageError}
className='cardGameMain'
/>
</div>
2024-07-11 17:15:03 +05:00
<div className='cardGameMainTitle'>
<p>{title}</p>
2024-07-11 17:15:03 +05:00
</div>
2024-09-18 21:43:36 +05:00
</div>
2024-07-11 17:15:03 +05:00
)
}