-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42 from pepero-1/feature/#7
Feature/#7 게임방 리스트 불러오기 , 게임방 데이터 적용하기
- Loading branch information
Showing
2 changed files
with
143 additions
and
200 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import { | ||
Box, | ||
Button, | ||
Card, | ||
CardBody, | ||
CardFooter, | ||
Heading, | ||
Stack, | ||
Tag, | ||
Text, | ||
} from "@chakra-ui/react"; | ||
import { DocumentData } from "firebase/firestore"; | ||
|
||
interface Game { | ||
name: string; | ||
users: string[]; | ||
isPrivate?: boolean; | ||
num?: number; | ||
bg?: string; | ||
status?: string; | ||
id: string; | ||
} | ||
|
||
interface Props { | ||
game: Game | DocumentData; | ||
} | ||
|
||
const GameCard = ({ game: { id, bg, name, num, status, users } }: Props) => { | ||
console.log(id); | ||
|
||
return ( | ||
<Card | ||
direction={{ base: "column", sm: "row" }} | ||
overflow="hidden" | ||
variant="outline" | ||
display="flex" | ||
alignItems="center" | ||
> | ||
<Box fontSize="4rem" pl="5"> | ||
{bg} | ||
</Box> | ||
<Stack w="100%" marginLeft="2"> | ||
<CardBody> | ||
<Box display="flex" justifyContent="space-between"> | ||
<Heading size="md"> | ||
{name.length >= 8 ? name.substr(0, 6) + "..." : name} | ||
</Heading> | ||
<Tag | ||
color={status === "게임중" ? "white" : ""} | ||
bgColor={status === "게임중" ? "green" : ""} | ||
> | ||
{status} | ||
</Tag> | ||
</Box> | ||
</CardBody> | ||
|
||
<CardFooter display="flex" justifyContent="space-between"> | ||
<Text> | ||
{users.length}/{num} | ||
</Text> | ||
<Button | ||
size="sm" | ||
bg="blackAlpha.800" | ||
color="white" | ||
_hover={{ bg: "blackAlpha.900" }} | ||
> | ||
입장하기 | ||
</Button> | ||
</CardFooter> | ||
</Stack> | ||
</Card> | ||
); | ||
}; | ||
|
||
export default GameCard; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters