Skip to content

Commit

Permalink
start to add basic create game form
Browse files Browse the repository at this point in the history
  • Loading branch information
troypoulter committed Apr 9, 2024
1 parent 7716e77 commit 499f7dd
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/app/_components/CreateGameForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

import { createGameRoom } from "@/actions/createGameRoom";
import { Button } from "@/components/ui/button";
import {
Card,
CardContent,
CardFooter,
CardHeader,
CardTitle,
} from "@/components/ui/card";
import { cn } from "@/lib/utils";
import { Loader2, Play } from "lucide-react";
import { useFormStatus } from "react-dom";
Expand All @@ -14,7 +21,7 @@ function CreateGameButton() {
type="submit"
aria-disabled={pending}
className={cn(
"bg-green-500 hover:bg-green-500/90",
"w-full bg-green-500 hover:bg-green-500/90",
pending && "opacity-50"
)}
>
Expand All @@ -34,8 +41,15 @@ function CreateGameButton() {

export function CreateGameForm() {
return (
<form action={createGameRoom}>
<CreateGameButton />
</form>
<Card className="w-[560px]">
<CardHeader className="items-center">
<CardTitle>Create Game</CardTitle>
</CardHeader>
<CardContent>
<form action={createGameRoom}>
<CreateGameButton />
</form>
</CardContent>
</Card>
);
}
79 changes: 79 additions & 0 deletions src/components/ui/card.tsx
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<
HTMLParagraphElement,
React.HTMLAttributes<HTMLHeadingElement>
>(({ className, ...props }, ref) => (
<h3
ref={ref}
className={cn(
"text-2xl font-semibold leading-none tracking-tight",
className
)}
{...props}
/>
))
CardTitle.displayName = "CardTitle"

const CardDescription = React.forwardRef<
HTMLParagraphElement,
React.HTMLAttributes<HTMLParagraphElement>
>(({ className, ...props }, ref) => (
<p
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 }

0 comments on commit 499f7dd

Please sign in to comment.