-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: GameRoom 컴포넌트 생성 및 Pagination UI 구현
- Loading branch information
1 parent
55e2348
commit 34e5803
Showing
12 changed files
with
364 additions
and
40 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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,36 @@ | ||
import * as React from "react" | ||
import { cva, type VariantProps } from "class-variance-authority" | ||
|
||
import { cn } from "@/lib/utils" | ||
|
||
const badgeVariants = cva( | ||
"inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2", | ||
{ | ||
variants: { | ||
variant: { | ||
default: | ||
"border-transparent bg-primary text-primary-foreground hover:bg-primary/80", | ||
secondary: | ||
"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80", | ||
destructive: | ||
"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80", | ||
outline: "text-foreground", | ||
}, | ||
}, | ||
defaultVariants: { | ||
variant: "default", | ||
}, | ||
} | ||
) | ||
|
||
export interface BadgeProps | ||
extends React.HTMLAttributes<HTMLDivElement>, | ||
VariantProps<typeof badgeVariants> {} | ||
|
||
function Badge({ className, variant, ...props }: BadgeProps) { | ||
return ( | ||
<div className={cn(badgeVariants({ variant }), className)} {...props} /> | ||
) | ||
} | ||
|
||
export { Badge, badgeVariants } |
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,79 @@ | ||
import * as React from "react" | ||
|
||
import { cn } from "@/lib/utils" | ||
|
||
const Card = React.forwardRef< | ||
HTMLDivElement, | ||
React.HTMLAttributes<HTMLDivElement> | ||
>(({ className, ...props }, ref) => ( | ||
<div | ||
ref={ref} | ||
className={cn( | ||
"rounded-lg border bg-card text-card-foreground shadow-sm", | ||
className | ||
)} | ||
{...props} | ||
/> | ||
)) | ||
Card.displayName = "Card" | ||
|
||
const CardHeader = React.forwardRef< | ||
HTMLDivElement, | ||
React.HTMLAttributes<HTMLDivElement> | ||
>(({ className, ...props }, ref) => ( | ||
<div | ||
ref={ref} | ||
className={cn("flex flex-col space-y-1.5 p-6", className)} | ||
{...props} | ||
/> | ||
)) | ||
CardHeader.displayName = "CardHeader" | ||
|
||
const CardTitle = React.forwardRef< | ||
HTMLDivElement, | ||
React.HTMLAttributes<HTMLDivElement> | ||
>(({ className, ...props }, ref) => ( | ||
<div | ||
ref={ref} | ||
className={cn( | ||
"text-2xl font-semibold leading-none tracking-tight", | ||
className | ||
)} | ||
{...props} | ||
/> | ||
)) | ||
CardTitle.displayName = "CardTitle" | ||
|
||
const CardDescription = React.forwardRef< | ||
HTMLDivElement, | ||
React.HTMLAttributes<HTMLDivElement> | ||
>(({ className, ...props }, ref) => ( | ||
<div | ||
ref={ref} | ||
className={cn("text-sm text-muted-foreground", className)} | ||
{...props} | ||
/> | ||
)) | ||
CardDescription.displayName = "CardDescription" | ||
|
||
const CardContent = React.forwardRef< | ||
HTMLDivElement, | ||
React.HTMLAttributes<HTMLDivElement> | ||
>(({ className, ...props }, ref) => ( | ||
<div ref={ref} className={cn("p-6 pt-0", className)} {...props} /> | ||
)) | ||
CardContent.displayName = "CardContent" | ||
|
||
const CardFooter = React.forwardRef< | ||
HTMLDivElement, | ||
React.HTMLAttributes<HTMLDivElement> | ||
>(({ className, ...props }, ref) => ( | ||
<div | ||
ref={ref} | ||
className={cn("flex items-center p-6 pt-0", className)} | ||
{...props} | ||
/> | ||
)) | ||
CardFooter.displayName = "CardFooter" | ||
|
||
export { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent } |
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
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,42 @@ | ||
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; | ||
import { GameRoomProps } from '@/types/room'; | ||
import { FaCircle, FaCrown, FaUsers } from 'react-icons/fa6'; | ||
|
||
const GameRoom = ({ room }: GameRoomProps) => { | ||
return ( | ||
<Card className="flex w-full mt-2"> | ||
<CardHeader className="space-y-1"> | ||
<div className="flex items-center justify-between"> | ||
<CardTitle className="text-xl">{room.name}</CardTitle> | ||
</div> | ||
<div className="space-y-2 text-md text-muted-foreground px-1"> | ||
<div className="flex items-center gap-2"> | ||
<FaCrown className="text-yellow-500" /> | ||
<span>방장: {room.creator}</span> | ||
</div> | ||
<div className="flex items-center gap-2"> | ||
<FaCircle | ||
className={`text-sm ${room.isGameStarted ? 'text-red-500' : 'text-green-500'}`} | ||
/> | ||
<span> | ||
상태:{' '} | ||
<span | ||
className={ | ||
room.isGameStarted ? 'text-red-500' : 'text-green-500' | ||
} | ||
> | ||
{room.isGameStarted ? '게임 중' : '대기 중'} | ||
</span> | ||
</span> | ||
</div> | ||
<div className="flex items-center gap-2"> | ||
<FaUsers className="text-gray-500" /> | ||
<span>인원 수: {room.players.length} / 4</span> | ||
</div> | ||
</div> | ||
</CardHeader> | ||
</Card> | ||
); | ||
}; | ||
|
||
export default GameRoom; |
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,45 @@ | ||
import { Button } from '@/components/ui/button'; | ||
import { PaginationProps } from '@/types/room'; | ||
import { FaChevronLeft, FaChevronRight } from 'react-icons/fa6'; | ||
|
||
const Pagination = ({ | ||
currentPage, | ||
totalPages, | ||
onPageChange, | ||
}: PaginationProps) => { | ||
return ( | ||
<div className="flex items-center justify-center gap-4 mt-6"> | ||
<Button | ||
variant="outline" | ||
size="icon" | ||
onClick={() => onPageChange(currentPage - 1)} | ||
disabled={currentPage === 0} | ||
> | ||
<FaChevronLeft className="w-4 h-4" /> | ||
</Button> | ||
<div className="flex items-center gap-2"> | ||
{Array.from({ length: totalPages }, (_, i) => ( | ||
<Button | ||
key={i} | ||
variant={currentPage === i ? 'default' : 'outline'} | ||
size="sm" | ||
onClick={() => onPageChange(i)} | ||
className="w-8 h-8" | ||
> | ||
{i + 1} | ||
</Button> | ||
))} | ||
</div> | ||
<Button | ||
variant="outline" | ||
size="icon" | ||
onClick={() => onPageChange(currentPage + 1)} | ||
disabled={currentPage === totalPages - 1} | ||
> | ||
<FaChevronRight className="w-4 h-4" /> | ||
</Button> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Pagination; |
Oops, something went wrong.