Feat: Add creating decks

This commit is contained in:
globuzma 2024-12-27 16:41:39 +01:00
parent 7145906862
commit aaa0bee853
26 changed files with 1279 additions and 180 deletions

View file

@ -0,0 +1,26 @@
"use client"
import * as React from "react"
import * as LabelPrimitive from "@radix-ui/react-label"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "@/lib/utils"
const labelVariants = cva(
"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
)
const Label = React.forwardRef<
React.ElementRef<typeof LabelPrimitive.Root>,
React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> &
VariantProps<typeof labelVariants>
>(({ className, ...props }, ref) => (
<LabelPrimitive.Root
ref={ref}
className={cn(labelVariants(), className)}
{...props}
/>
))
Label.displayName = LabelPrimitive.Root.displayName
export { Label }

View file

@ -6,10 +6,15 @@ interface MTGCardProps {
className?: string,
imageURI: string,
cardname: string,
url: string
url: string,
nbrDecks?: number,
totalDecks?: number,
percentDecks?: number,
price?: string,
cardmarketURI?: string
}
const MTGCard = ({ className, imageURI, cardname, url }: MTGCardProps) => {
const MTGCard = ({ className, imageURI, cardname, url, nbrDecks, totalDecks, percentDecks, price, cardmarketURI }: MTGCardProps) => {
const [loaded, setLoaded] = React.useState(false)
return (
@ -24,7 +29,17 @@ const MTGCard = ({ className, imageURI, cardname, url }: MTGCardProps) => {
<span className="h-64 shadow">Loading...</span>
}
<img src={imageURI} className="rounded" height={loaded ? 'auto' : '0'} onLoad={() => {setLoaded(true)}} loading="lazy" />
<span className="text-center">{cardname}</span>
<div className="flex flex-col items-center gap-0">
{ price != undefined && (
<a href={cardmarketURI != undefined ? cardmarketURI : "#"} target={cardmarketURI != undefined ? "_blank" : "_self"}>{price}</a>
)}
<span className="text-center">{cardname}</span>
{ nbrDecks != undefined && (
<>
<span className="text-xs">{nbrDecks} de {totalDecks} Decks ({percentDecks}%)</span>
</>
)}
</div>
</a>
)}
MTGCard.displayName = "MTGCard"

View file

@ -66,7 +66,7 @@ export function NavigationBar ({ isLoggedIn, username}: NavigationProps) {
</a>
</DropdownMenuItem>
<DropdownMenuItem>
<a className="flex flex-row gap-2" href="/top/blue">
<a className="flex flex-row gap-2" href="/top/black">
<Black className="h-4 w-4"/>
<span>Noir</span>
</a>
@ -394,10 +394,13 @@ export function NavigationBar ({ isLoggedIn, username}: NavigationProps) {
}
{
isLoggedIn &&
<a href="/account/profile" className="flex flex-row items-center gap-2">
<IconUserFilled color="gray" />
<span className="text-gray-400">{username}</span>
</a>
<>
<a href="/account/profile/decks" className="flex flex-row items-center gap-2"><span className="text-gray-400">Decks</span></a>
<a href="/account/profile" className="flex flex-row items-center gap-2">
<IconUserFilled color="gray" />
<span className="text-gray-400">{username}</span>
</a>
</>
}
</div>
</div>

View file

@ -0,0 +1,33 @@
"use client"
import * as React from "react"
import * as PopoverPrimitive from "@radix-ui/react-popover"
import { cn } from "@/lib/utils"
const Popover = PopoverPrimitive.Root
const PopoverTrigger = PopoverPrimitive.Trigger
const PopoverAnchor = PopoverPrimitive.Anchor
const PopoverContent = React.forwardRef<
React.ElementRef<typeof PopoverPrimitive.Content>,
React.ComponentPropsWithoutRef<typeof PopoverPrimitive.Content>
>(({ className, align = "center", sideOffset = 4, ...props }, ref) => (
<PopoverPrimitive.Portal>
<PopoverPrimitive.Content
ref={ref}
align={align}
sideOffset={sideOffset}
className={cn(
"z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
className
)}
{...props}
/>
</PopoverPrimitive.Portal>
))
PopoverContent.displayName = PopoverPrimitive.Content.displayName
export { Popover, PopoverTrigger, PopoverContent, PopoverAnchor }

View file

@ -0,0 +1,22 @@
import * as React from "react"
import { cn } from "@/lib/utils"
const Textarea = React.forwardRef<
HTMLTextAreaElement,
React.ComponentProps<"textarea">
>(({ className, ...props }, ref) => {
return (
<textarea
className={cn(
"flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
className
)}
ref={ref}
{...props}
/>
)
})
Textarea.displayName = "Textarea"
export { Textarea }