mirror of
https://github.com/vercel/commerce.git
synced 2025-07-22 20:26:49 +00:00
Merge branch 'master' of github.com:okbel/e-comm-example into image-component
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
.root {
|
||||
@apply relative grid items-start gap-8 grid-cols-1;
|
||||
@apply relative grid items-start gap-8 grid-cols-1 overflow-x-hidden;
|
||||
|
||||
@screen lg {
|
||||
@apply grid-cols-12 pt-10;
|
||||
@apply grid-cols-12;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,24 +17,18 @@
|
||||
}
|
||||
|
||||
@screen lg {
|
||||
@apply mx-0 col-span-7;
|
||||
@apply mx-0 col-span-6;
|
||||
min-height: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.squareBg {
|
||||
@apply absolute inset-0 bg-violet z-0;
|
||||
max-height: 250px;
|
||||
|
||||
@screen md {
|
||||
@apply inset-20;
|
||||
max-height: 500px;
|
||||
}
|
||||
@apply absolute inset-0 bg-violet z-0 h-full;
|
||||
}
|
||||
|
||||
.nameBox {
|
||||
@apply absolute top-6 left-10 z-10;
|
||||
@apply absolute top-6 left-6 z-20;
|
||||
|
||||
& .name {
|
||||
@apply px-6 py-2 bg-primary text-primary font-bold;
|
||||
@@ -46,20 +40,19 @@
|
||||
@apply px-6 py-2 pb-4 bg-primary text-primary font-bold inline-block tracking-wide;
|
||||
}
|
||||
|
||||
@screen md {
|
||||
@screen lg {
|
||||
& .name,
|
||||
& .price {
|
||||
@apply bg-violet-light text-white;
|
||||
@apply bg-hover-1 text-white;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.sidebar {
|
||||
@apply flex flex-col col-span-1;
|
||||
@apply flex flex-col col-span-1 mx-auto max-w-8xl px-12 w-full;
|
||||
|
||||
@screen lg {
|
||||
@apply col-span-5;
|
||||
padding-top: 5rem;
|
||||
@apply col-span-5 pl-12 pt-20;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,20 +61,18 @@
|
||||
}
|
||||
|
||||
.img {
|
||||
@apply w-full h-full object-cover;
|
||||
|
||||
@screen md {
|
||||
height: 100%;
|
||||
margin-top: -2.75rem;
|
||||
}
|
||||
|
||||
@screen lg {
|
||||
height: 100%;
|
||||
margin-top: -8%;
|
||||
}
|
||||
@apply w-full h-auto max-h-full object-cover;
|
||||
}
|
||||
|
||||
.button {
|
||||
min-width: 300px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.wishlistButton {
|
||||
@apply absolute z-30 top-6 right-0 bg-primary text-base w-10 h-10 flex items-center justify-center font-semibold leading-6 cursor-pointer;
|
||||
|
||||
@screen lg {
|
||||
@apply right-12 text-white bg-violet;
|
||||
}
|
||||
}
|
||||
|
@@ -2,14 +2,16 @@ import { FC, useState, useEffect } from 'react'
|
||||
import cn from 'classnames'
|
||||
import Image from 'next/image'
|
||||
import { NextSeo } from 'next-seo'
|
||||
import type { ProductNode } from '@lib/bigcommerce/api/operations/get-product'
|
||||
import useAddItem from '@lib/bigcommerce/cart/use-add-item'
|
||||
import { isDesktop } from '@lib/browser'
|
||||
|
||||
import s from './ProductView.module.css'
|
||||
import { Heart } from '@components/icon'
|
||||
import { useUI } from '@components/ui/context'
|
||||
import { Button, Container } from '@components/ui'
|
||||
import { Swatch, ProductSlider } from '@components/product'
|
||||
|
||||
import useAddItem from '@lib/bigcommerce/cart/use-add-item'
|
||||
import type { ProductNode } from '@lib/bigcommerce/api/operations/get-product'
|
||||
import { getProductOptions } from '../helpers'
|
||||
import s from './ProductView.module.css'
|
||||
|
||||
interface Props {
|
||||
className?: string
|
||||
@@ -22,17 +24,12 @@ const ProductView: FC<Props> = ({ product, className }) => {
|
||||
const { openSidebar } = useUI()
|
||||
const options = getProductOptions(product)
|
||||
const [loading, setLoading] = useState(false)
|
||||
const [validMedia, setValidMedia] = useState(false)
|
||||
|
||||
const [choices, setChoices] = useState<Record<string, any>>({
|
||||
size: null,
|
||||
color: null,
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
setValidMedia(isDesktop())
|
||||
}, [])
|
||||
|
||||
const addToCart = async () => {
|
||||
setLoading(true)
|
||||
try {
|
||||
@@ -48,7 +45,7 @@ const ProductView: FC<Props> = ({ product, className }) => {
|
||||
}
|
||||
|
||||
return (
|
||||
<Container>
|
||||
<Container className="max-w-none w-full" clean>
|
||||
<NextSeo
|
||||
title={product.name}
|
||||
description={product.description}
|
||||
@@ -91,12 +88,6 @@ const ProductView: FC<Props> = ({ product, className }) => {
|
||||
))}
|
||||
</ProductSlider>
|
||||
</div>
|
||||
|
||||
{!validMedia && (
|
||||
<div className="absolute z-10 bottom-10 left-1/2 transform -translate-x-1/2 inline-block">
|
||||
<img src="/slider-arrows.png" />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className={s.sidebar}>
|
||||
@@ -146,6 +137,11 @@ const ProductView: FC<Props> = ({ product, className }) => {
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
{/* TODO make it work */}
|
||||
<div className={s.wishlistButton}>
|
||||
<Heart />
|
||||
</div>
|
||||
</div>
|
||||
</Container>
|
||||
)
|
||||
|
Reference in New Issue
Block a user