mirror of
https://github.com/mosh-hamedani/game-hub.git
synced 2026-05-21 12:14:32 +02:00
Refactor: remove duplicated styles
This commit is contained in:
parent
efcd3c596e
commit
83e825fe9c
|
|
@ -11,7 +11,7 @@ interface Props {
|
||||||
|
|
||||||
const GameCard = ({ game }: Props) => {
|
const GameCard = ({ game }: Props) => {
|
||||||
return (
|
return (
|
||||||
<Card width='300px' borderRadius={10} overflow='hidden'>
|
<Card>
|
||||||
<Image src={getCroppedImageUrl(game.background_image)} />
|
<Image src={getCroppedImageUrl(game.background_image)} />
|
||||||
<CardBody>
|
<CardBody>
|
||||||
<Heading fontSize='2xl'>{game.name}</Heading>
|
<Heading fontSize='2xl'>{game.name}</Heading>
|
||||||
|
|
|
||||||
16
src/components/GameCardContainer.tsx
Normal file
16
src/components/GameCardContainer.tsx
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
import { Box } from "@chakra-ui/react";
|
||||||
|
import { ReactNode } from "react";
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
children: ReactNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
const GameCardContainer = ({ children }: Props) => {
|
||||||
|
return (
|
||||||
|
<Box width="300px" borderRadius={10} overflow="hidden">
|
||||||
|
{children}
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default GameCardContainer;
|
||||||
|
|
@ -2,7 +2,7 @@ import { Card, CardBody, Skeleton, SkeletonText } from '@chakra-ui/react'
|
||||||
|
|
||||||
const GameCardSkeleton = () => {
|
const GameCardSkeleton = () => {
|
||||||
return (
|
return (
|
||||||
<Card width='300px' borderRadius={10} overflow='hidden'>
|
<Card>
|
||||||
<Skeleton height="200px" />
|
<Skeleton height="200px" />
|
||||||
<CardBody>
|
<CardBody>
|
||||||
<SkeletonText />
|
<SkeletonText />
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import { SimpleGrid, Text } from "@chakra-ui/react";
|
import { SimpleGrid, Text } from "@chakra-ui/react";
|
||||||
import useGames from "../hooks/useGames";
|
import useGames from "../hooks/useGames";
|
||||||
import GameCard from "./GameCard";
|
import GameCard from "./GameCard";
|
||||||
|
import GameCardContainer from "./GameCardContainer";
|
||||||
import GameCardSkeleton from "./GameCardSkeleton";
|
import GameCardSkeleton from "./GameCardSkeleton";
|
||||||
|
|
||||||
const GameGrid = () => {
|
const GameGrid = () => {
|
||||||
|
|
@ -16,9 +17,15 @@ const GameGrid = () => {
|
||||||
spacing={10}
|
spacing={10}
|
||||||
>
|
>
|
||||||
{isLoading &&
|
{isLoading &&
|
||||||
skeletons.map((skeleton) => <GameCardSkeleton key={skeleton} />)}
|
skeletons.map((skeleton) => (
|
||||||
|
<GameCardContainer>
|
||||||
|
<GameCardSkeleton key={skeleton} />
|
||||||
|
</GameCardContainer>
|
||||||
|
))}
|
||||||
{games.map((game) => (
|
{games.map((game) => (
|
||||||
|
<GameCardContainer>
|
||||||
<GameCard key={game.id} game={game} />
|
<GameCard key={game.id} game={game} />
|
||||||
|
</GameCardContainer>
|
||||||
))}
|
))}
|
||||||
</SimpleGrid>
|
</SimpleGrid>
|
||||||
</>
|
</>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue