diff --git a/src/components/CriticScore.tsx b/src/components/CriticScore.tsx new file mode 100644 index 0000000..8a97734 --- /dev/null +++ b/src/components/CriticScore.tsx @@ -0,0 +1,15 @@ +import { Badge } from '@chakra-ui/react'; + +interface Props { + score: number; +} + +const CriticScore = ({ score }: Props) => { + let color = score > 75 ? 'green' : score > 60 ? 'yellow' : ''; + + return ( + {score} + ) +} + +export default CriticScore \ No newline at end of file diff --git a/src/components/GameCard.tsx b/src/components/GameCard.tsx index d9502cc..d5c8a49 100644 --- a/src/components/GameCard.tsx +++ b/src/components/GameCard.tsx @@ -1,6 +1,7 @@ -import { Card, CardBody, Heading, Image, Text } from '@chakra-ui/react' +import { Card, CardBody, Heading, HStack, Image, Text } from '@chakra-ui/react' import React from 'react' import { Game } from '../hooks/useGames' +import CriticScore from './CriticScore' import PlatformIconList from './PlatformIconList' interface Props { @@ -13,7 +14,10 @@ const GameCard = ({ game }: Props) => { {game.name} - p.platform)} /> + + p.platform)} /> + + ) diff --git a/src/hooks/useGames.ts b/src/hooks/useGames.ts index cca68b5..708b9df 100644 --- a/src/hooks/useGames.ts +++ b/src/hooks/useGames.ts @@ -12,7 +12,8 @@ export interface Game { id: number; name: string; background_image: string; - parent_platforms: { platform: Platform }[] + parent_platforms: { platform: Platform }[]; + metacritic: number; } interface FetchGamesResponse {