Skip to content

Commit

Permalink
update product page
Browse files Browse the repository at this point in the history
  • Loading branch information
sadmann7 committed Dec 7, 2023
1 parent e08d334 commit 60ca66c
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 32 deletions.
11 changes: 11 additions & 0 deletions src/app/(lobby)/@modal/(.)product-preview/[productId]/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { AlertDialog, AlertDialogContent } from "@/components/ui/alert-dialog"

export default function ProductModalLayout({
children,
}: React.PropsWithChildren) {
return (
<AlertDialog defaultOpen>
<AlertDialogContent>{children}</AlertDialogContent>
</AlertDialog>
)
}
15 changes: 15 additions & 0 deletions src/app/(lobby)/@modal/(.)product-preview/[productId]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
interface ProductModalPageProps {
params: {
productId: string
}
}

export default function ProductModalPage({ params }: ProductModalPageProps) {
const productId = Number(params.productId)

return (
<div>
<div>Product: {productId}</div>
</div>
)
}
3 changes: 3 additions & 0 deletions src/app/(lobby)/@modal/default.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function Default() {
return null
}
13 changes: 11 additions & 2 deletions src/app/(lobby)/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,24 @@ import { currentUser } from "@clerk/nextjs"
import { SiteFooter } from "@/components/layouts/site-footer"
import { SiteHeader } from "@/components/layouts/site-header"

interface LobbyLayoutProps
extends React.PropsWithChildren<{
modal: React.ReactNode
}> {}

export default async function LobbyLayout({
children,
}: React.PropsWithChildren) {
modal,
}: LobbyLayoutProps) {
const user = await currentUser()

return (
<div className="relative flex min-h-screen flex-col">
<SiteHeader user={user} />
<main className="flex-1">{children}</main>
<main className="flex-1">
{children}
{modal}
</main>
<SiteFooter />
</div>
)
Expand Down
35 changes: 7 additions & 28 deletions src/app/(lobby)/product/[productId]/loading.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { cn } from "@/lib/utils"
import { AspectRatio } from "@/components/ui/aspect-ratio"
import { Card, CardContent, CardFooter, CardHeader } from "@/components/ui/card"
import { ScrollArea } from "@/components/ui/scroll-area"
import { Separator } from "@/components/ui/separator"
import { Skeleton } from "@/components/ui/skeleton"
import { Icons } from "@/components/icons"
import { Shell } from "@/components/shells/shell"
import { ProductCardSkeleton } from "@/components/skeletons/product-card-skeleton"

export default function ProductLoading() {
return (
Expand Down Expand Up @@ -75,36 +75,15 @@ export default function ProductLoading() {
<Separator className="md:hidden" />
</div>
</div>
<div className="overflow-hidden md:pt-6">
<Skeleton className="h-9 w-14" />
<div className="overflow-x-auto pb-2 pt-6">
<div className="space-y-6 overflow-hidden">
<Skeleton className="h-7 w-1/4" />
<ScrollArea orientation="horizontal" className="pb-3.5">
<div className="flex gap-4">
{Array.from({ length: 4 }).map((_, i) => (
<Card key={i} className="min-w-[260px] rounded-sm">
<CardHeader className="border-b p-0">
<AspectRatio ratio={4 / 3}>
<div className="flex h-full items-center justify-center bg-secondary">
<Icons.placeholder
className="h-9 w-9 text-muted-foreground"
aria-hidden="true"
/>
</div>
</AspectRatio>
</CardHeader>
<CardContent className="grid gap-2.5 p-4">
<Skeleton className="h-4 w-1/2" />
<Skeleton className="h-4 w-1/4" />
</CardContent>
<CardFooter className="p-4">
<div className="flex w-full flex-col items-center gap-2 sm:flex-row sm:justify-between">
<Skeleton className="h-8 w-full rounded-sm" />
<Skeleton className="h-8 w-full rounded-sm" />
</div>
</CardFooter>
</Card>
<ProductCardSkeleton key={i} className="min-w-[260px]" />
))}
</div>
</div>
</ScrollArea>
</div>
</Shell>
)
Expand Down
14 changes: 12 additions & 2 deletions src/components/skeletons/product-card-skeleton.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
import { cn } from "@/lib/utils"
import { AspectRatio } from "@/components/ui/aspect-ratio"
import { Card, CardContent, CardFooter, CardHeader } from "@/components/ui/card"
import { Skeleton } from "@/components/ui/skeleton"
import { PlaceholderImage } from "@/components/placeholder-image"

export function ProductCardSkeleton() {
interface ProductCardSkeletonProps
extends React.ComponentPropsWithoutRef<typeof Card> {}

export function ProductCardSkeleton({
className,
...props
}: ProductCardSkeletonProps) {
return (
<Card className="h-full overflow-hidden rounded-sm">
<Card
className={cn("h-full overflow-hidden rounded-sm", className)}
{...props}
>
<CardHeader className="border-b p-0">
<AspectRatio ratio={4 / 3}>
<PlaceholderImage asChild className="rounded-none" />
Expand Down

1 comment on commit 60ca66c

@vercel
Copy link

@vercel vercel bot commented on 60ca66c Dec 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.