mirror of
https://github.com/mosh-hamedani/game-hub.git
synced 2026-05-21 12:14:32 +02:00
Displaying critic score
This commit is contained in:
parent
a5edf66ee0
commit
9a9eb5d2a6
15
src/components/CriticScore.tsx
Normal file
15
src/components/CriticScore.tsx
Normal file
|
|
@ -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 (
|
||||||
|
<Badge colorScheme={color} fontSize='14px' paddingX={2} borderRadius='4px'>{score}</Badge>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default CriticScore
|
||||||
|
|
@ -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 React from 'react'
|
||||||
import { Game } from '../hooks/useGames'
|
import { Game } from '../hooks/useGames'
|
||||||
|
import CriticScore from './CriticScore'
|
||||||
import PlatformIconList from './PlatformIconList'
|
import PlatformIconList from './PlatformIconList'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
|
|
@ -13,7 +14,10 @@ const GameCard = ({ game }: Props) => {
|
||||||
<Image src={game.background_image} />
|
<Image src={game.background_image} />
|
||||||
<CardBody>
|
<CardBody>
|
||||||
<Heading fontSize='2xl'>{game.name}</Heading>
|
<Heading fontSize='2xl'>{game.name}</Heading>
|
||||||
<PlatformIconList platforms={game.parent_platforms.map(p => p.platform)} />
|
<HStack justifyContent='space-between'>
|
||||||
|
<PlatformIconList platforms={game.parent_platforms.map(p => p.platform)} />
|
||||||
|
<CriticScore score={game.metacritic} />
|
||||||
|
</HStack>
|
||||||
</CardBody>
|
</CardBody>
|
||||||
</Card>
|
</Card>
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,8 @@ export interface Game {
|
||||||
id: number;
|
id: number;
|
||||||
name: string;
|
name: string;
|
||||||
background_image: string;
|
background_image: string;
|
||||||
parent_platforms: { platform: Platform }[]
|
parent_platforms: { platform: Platform }[];
|
||||||
|
metacritic: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface FetchGamesResponse {
|
interface FetchGamesResponse {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue