Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ui): product preview has been added #182

Merged
merged 1 commit into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions packages/ui/src/app/products/[name]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { Button } from '@openui-org/react/components'
import { Link } from 'next-view-transitions'
import Image from 'next/image'
import { ArrowLeft } from 'lucide-react'
import imagen from '../../../../public/product-test.webp'
import { ProductAccount } from '@/components/product-account'

export default function Page({ params }: { params: { name: string } }) {
return (
<>
<header className="pt-5 px-16">
<Button asChild>
<Link href="/">
<ArrowLeft />
</Link>
</Button>
</header>
<div>
<div className="flex justify-center p-10 gap-10 flex-wrap">
<Image src={imagen} alt="imagen" className="bg-muted/90 object-cover backdrop-brightness-90 object-center aspect-square" width="500" height="500" />
<article className="w-full md:w-[400px] flex flex-col gap-4">
<h2 className="text-5xl font-bold">{params.name}</h2>
<p>$10</p>
<ProductAccount />
<Button>Add to cart</Button>
<figure>
<h3 className="font-semibold pb-3">Description</h3>
<p className="text-sm font-extralight text-muted-foreground">Lorem ipsum, dolor sit amet consectetur adipisicing elit. In illo sint totam numquam, blanditiis consectetur cum magni corrupti assumenda ratione molestiae ducimus dolores, suscipit voluptatem quibusdam ad hic quia tempora.</p>
</figure>
</article>
</div>
</div>
</>
)
}
17 changes: 17 additions & 0 deletions packages/ui/src/components/product-account.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
'use client'
import { Button } from '@openui-org/react/components'
import { useState } from 'react'

export function ProductAccount() {
const [account, setAccount] = useState(1)
return (
<figure>
<h3 className="font-semibold pb-3">Quantity</h3>
<div className="flex gap-3 items-center">
<Button onClick={() => setAccount(account - 1)} className={`${account === 1 && 'pointer-events-none bg-primary/85'}`}>-</Button>
<span className="w-16 p-2 text-center rounded-sm bg-muted/90">{account}</span>
<Button onClick={() => setAccount(account + 1)}>+</Button>
</div>
</figure>
)
}
4 changes: 2 additions & 2 deletions packages/ui/src/components/product.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Link from 'next/link'
import { Link } from 'next-view-transitions'
import Image from 'next/image'
import clsx from 'clsx'
import { ShoppingBag } from 'lucide-react'
Expand All @@ -15,7 +15,7 @@ interface ProductProps {
export function Product(props: ProductProps) {
return (

<Link href="#" className="group">
<Link href={`/products/${props.product.name?.replace(/ /g, '-').toLowerCase()}`} className="group">
<div className="bg-muted/90 rounded overflow-hidden transition-all duration-500 relative aspect-square">
<Image
src={props.product.URL}
Expand Down
Loading
Loading