mirror of
https://github.com/mosh-hamedani/game-hub.git
synced 2026-05-21 12:14:32 +02:00
Add emojis
This commit is contained in:
parent
0dbda793db
commit
f128906aee
BIN
src/assets/bulls-eye.webp
Normal file
BIN
src/assets/bulls-eye.webp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4 KiB |
BIN
src/assets/meh.webp
Normal file
BIN
src/assets/meh.webp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.7 KiB |
BIN
src/assets/thumbs-up.webp
Normal file
BIN
src/assets/thumbs-up.webp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3 KiB |
24
src/components/Emoji.tsx
Normal file
24
src/components/Emoji.tsx
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
import bullsEye from '../assets/bulls-eye.webp';
|
||||||
|
import thumbsUp from '../assets/thumbs-up.webp';
|
||||||
|
import meh from '../assets/meh.webp';
|
||||||
|
import { Image, ImageProps } from '@chakra-ui/react';
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
rating: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Emoji = ({ rating }: Props) => {
|
||||||
|
if (rating < 3) return null;
|
||||||
|
|
||||||
|
const emojiMap: { [key: number]: ImageProps } = {
|
||||||
|
3: { src: meh, alt: 'meh', boxSize: '25px' },
|
||||||
|
4: { src: thumbsUp, alt: 'recommended', boxSize: '25px' },
|
||||||
|
5: { src: bullsEye, alt: 'exceptional', boxSize: '35px' },
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Image {...emojiMap[rating]} marginTop={1} />
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Emoji
|
||||||
|
|
@ -3,6 +3,7 @@ import React from 'react'
|
||||||
import { Game } from '../hooks/useGames'
|
import { Game } from '../hooks/useGames'
|
||||||
import getCroppedImageUrl from '../services/image-url'
|
import getCroppedImageUrl from '../services/image-url'
|
||||||
import CriticScore from './CriticScore'
|
import CriticScore from './CriticScore'
|
||||||
|
import Emoji from './Emoji'
|
||||||
import PlatformIconList from './PlatformIconList'
|
import PlatformIconList from './PlatformIconList'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
|
|
@ -18,7 +19,7 @@ const GameCard = ({ game }: Props) => {
|
||||||
<PlatformIconList platforms={game.parent_platforms.map(p => p.platform)} />
|
<PlatformIconList platforms={game.parent_platforms.map(p => p.platform)} />
|
||||||
<CriticScore score={game.metacritic} />
|
<CriticScore score={game.metacritic} />
|
||||||
</HStack>
|
</HStack>
|
||||||
<Heading fontSize='2xl'>{game.name}</Heading>
|
<Heading fontSize='2xl'>{game.name}<Emoji rating={game.rating_top}/></Heading>
|
||||||
</CardBody>
|
</CardBody>
|
||||||
</Card>
|
</Card>
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ export interface Game {
|
||||||
background_image: string;
|
background_image: string;
|
||||||
parent_platforms: { platform: Platform }[];
|
parent_platforms: { platform: Platform }[];
|
||||||
metacritic: number;
|
metacritic: number;
|
||||||
|
rating_top: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
const useGames = (gameQuery: GameQuery) =>
|
const useGames = (gameQuery: GameQuery) =>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue