-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
722b614
commit 85d0866
Showing
5 changed files
with
83 additions
and
3 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,11 +1,23 @@ | ||
'use client'; | ||
import useProduct from '@hooks/useProduct'; | ||
import styles from './page.module.scss'; | ||
import ProductPage from '../_components/ProductPage/ProductPage'; | ||
|
||
interface Product { | ||
id: string; | ||
src: string; | ||
alt: string; | ||
name: string; | ||
price: number; | ||
} | ||
|
||
export default function Product({ params }: { params: { id: string } }) { | ||
const { product, loading } = useProduct(params.id); | ||
if (loading) { | ||
return 'loading...'; | ||
} | ||
return <div className={styles.container}>{JSON.stringify(product)}</div>; | ||
|
||
if (product === null) { | ||
return 'product does not exist'; | ||
} | ||
return <ProductPage {...(product as Product)} />; | ||
} |
25 changes: 25 additions & 0 deletions
25
app/(pages)/product/_components/ProductPage/ProductPage.module.scss
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,25 @@ | ||
$mid-gap: var(--spacer); | ||
|
||
.container { | ||
display: flex; | ||
flex-direction: row; | ||
padding: var(--medium-spacer); | ||
gap: $mid-gap; | ||
background-color: var(--light-foreground); | ||
} | ||
|
||
.main_img_container { | ||
width: calc(calc(100% - $mid-gap) / 2); | ||
aspect-ratio: calc(5/4); | ||
position: relative; | ||
|
||
.main_image { | ||
object-fit: cover; | ||
} | ||
} | ||
|
||
.prod_information { | ||
display: flex; | ||
flex-direction: column; | ||
gap: var(--spacer); | ||
} |
25 changes: 25 additions & 0 deletions
25
app/(pages)/product/_components/ProductPage/ProductPage.tsx
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,25 @@ | ||
import styles from './ProductPage.module.scss'; | ||
import Image from 'next/image'; | ||
|
||
interface Product { | ||
id: string; | ||
src: string; | ||
alt: string; | ||
name: string; | ||
price: number; | ||
} | ||
|
||
export default function ProductPage({ id: _, src, alt, name, price }: Product) { | ||
return ( | ||
<div className={styles.container}> | ||
<div className={styles.main_img_container}> | ||
<Image src={src} alt={alt} fill className={styles.main_image} /> | ||
</div> | ||
<div className={styles.prod_information}> | ||
<h2>{name}</h2> | ||
<p>${price}</p> | ||
<button className={styles.add_to_cart_button}>add to cart</button> | ||
</div> | ||
</div> | ||
); | ||
} |
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