index uses product image

This commit is contained in:
Tororoi 2021-05-05 10:35:10 -04:00
parent 2bb79eb070
commit a4307e7356
6 changed files with 80 additions and 167 deletions

View File

@ -3,6 +3,8 @@
bg-no-repeat bg-center bg-cover transition-transform bg-no-repeat bg-center bg-cover transition-transform
ease-linear cursor-pointer; ease-linear cursor-pointer;
height: 100% !important; height: 100% !important;
display: flex;
flex-flow: row nowrap;
&:hover { &:hover {
& .squareBg:before { & .squareBg:before {
@ -18,47 +20,20 @@
& .wishlistButton { & .wishlistButton {
@apply bg-secondary text-secondary; @apply bg-secondary text-secondary;
} }
&:nth-child(6n + 1) .productTitle > span,
&:nth-child(6n + 1) .productPrice,
&:nth-child(6n + 1) .wishlistButton {
@apply bg-violet text-white;
}
&:nth-child(6n + 5) .productTitle > span,
&:nth-child(6n + 5) .productPrice,
&:nth-child(6n + 5) .wishlistButton {
@apply bg-blue text-white;
}
&:nth-child(6n + 3) .productTitle > span,
&:nth-child(6n + 3) .productPrice,
&:nth-child(6n + 3) .wishlistButton {
@apply bg-pink text-white;
}
&:nth-child(6n + 6) .productTitle > span,
&:nth-child(6n + 6) .productPrice,
&:nth-child(6n + 6) .wishlistButton {
@apply bg-cyan text-white;
} }
} }
&:nth-child(6n + 1) .squareBg { .button {
@apply bg-violet; @apply bg-gray-900 hover:bg-gray-500;
} padding: 10px 30px;
color: white;
&:nth-child(6n + 5) .squareBg { /* background: black; */
@apply bg-blue; font-weight: 600;
} width: fit-content;
height: auto;
&:nth-child(6n + 3) .squareBg { border-radius: 20px;
@apply bg-pink; text-align: center;
} transition: 0.3s;
&:nth-child(6n + 6) .squareBg {
@apply bg-cyan;
}
} }
.squareBg, .squareBg,
@ -84,50 +59,15 @@
@apply bg-accents-0 !important; @apply bg-accents-0 !important;
background-image: url('/bg-products.svg'); background-image: url('/bg-products.svg');
} }
& .productTitle {
@apply pt-2;
font-size: 1rem;
& span {
@apply leading-extra-loose;
}
} }
& .productPrice {
@apply text-sm;
}
}
.productTitle {
@apply pt-0 max-w-full w-full leading-extra-loose;
font-size: 2rem;
letter-spacing: 0.4px;
& span {
@apply py-4 px-6 bg-primary text-primary font-bold;
font-size: inherit;
letter-spacing: inherit;
box-decoration-break: clone;
-webkit-box-decoration-break: clone;
}
}
.productPrice {
@apply py-4 px-6 bg-primary text-primary font-semibold inline-block text-sm leading-6;
letter-spacing: 0.4px;
}
.wishlistButton {
@apply w-10 h-10 flex ml-auto items-center justify-center bg-primary text-primary font-semibold text-xs leading-6 cursor-pointer;
}
.imageContainer { .imageContainer {
@apply flex items-center justify-center; @apply flex items-center justify-center;
overflow: hidden; overflow: hidden;
& > div { & > div {
min-width: 100%; min-width: 50%;
} }
} }

View File

@ -21,42 +21,10 @@ const BagelCard: FC<Props> = ({
imgProps, imgProps,
...props ...props
}) => ( }) => (
<Link href={`/product/${product.slug}`} {...props}>
<a className={cn(s.root, { [s.simple]: variant === 'simple' }, className)}>
{variant === 'slim' ? (
<div className="relative overflow-hidden box-border">
<div className="absolute inset-0 flex items-center justify-end mr-8 z-20">
<span className="bg-black text-white inline-block p-3 font-bold text-xl break-words">
{product.name}
</span>
</div>
{product?.images && (
<Image
quality="85"
src={product.images[0].url || placeholderImg}
alt={product.name || 'Product Image'}
height={320}
width={320}
layout="fixed"
{...imgProps}
/>
)}
</div>
) : (
<> <>
<div className={s.squareBg} /> <div
<div className="flex flex-row justify-between box-border w-full z-20 absolute"> className={cn(s.root, { [s.simple]: variant === 'simple' }, className)}
<div className="absolute top-0 left-0 pr-16 max-w-full"> >
<h3 className={s.productTitle}>
<span>{product.name}</span>
</h3>
<span className={s.productPrice}>
{product.price.value}
&nbsp;
{product.price.currencyCode}
</span>
</div>
</div>
<div className={s.imageContainer}> <div className={s.imageContainer}>
{product?.images && ( {product?.images && (
<Image <Image
@ -71,10 +39,16 @@ const BagelCard: FC<Props> = ({
/> />
)} )}
</div> </div>
</> <div className={s.textContainer}>
)} <h1>
</a> Featuring <i>Grain</i>changing Technology
</h1>
<Link href={`/product/${product.slug}`} {...props}>
<a className={s.button}>Try The Better Bagel</a>
</Link> </Link>
</div>
</div>
</>
) )
export default BagelCard export default BagelCard

View File

@ -1,4 +1,5 @@
import '@assets/main.scss' import '@assets/main.scss'
import '../styles/globals.css'
import '@assets/chrome-bug.scss' import '@assets/chrome-bug.scss'
// import 'keen-slider/keen-slider.min.css' // import 'keen-slider/keen-slider.min.css'

View File

@ -1,6 +1,7 @@
import { Layout } from '@components/common' import { Layout } from '@components/common'
import { Grid, Marquee, Hero } from '@components/ui' import { Grid, Marquee, Hero } from '@components/ui'
import { BagelCard } from '@components/product' import { BagelCard } from '@components/product'
import { ProductCard } from '@components/product'
import type { GetStaticPropsContext, InferGetStaticPropsType } from 'next' import type { GetStaticPropsContext, InferGetStaticPropsType } from 'next'
import { getConfig } from '@framework/api' import { getConfig } from '@framework/api'
@ -8,6 +9,8 @@ import getAllProducts from '@framework/product/get-all-products'
import getSiteInfo from '@framework/common/get-site-info' import getSiteInfo from '@framework/common/get-site-info'
import getAllPages from '@framework/common/get-all-pages' import getAllPages from '@framework/common/get-all-pages'
import styles from '../styles/Home.module.scss'
export async function getStaticProps({ export async function getStaticProps({
preview, preview,
locale, locale,
@ -41,37 +44,23 @@ export default function Home({
}: InferGetStaticPropsType<typeof getStaticProps>) { }: InferGetStaticPropsType<typeof getStaticProps>) {
return ( return (
<> <>
<Grid> <div className={styles.container}>
{/* main product */} <div className={styles.main}>
{products.slice(0, 3).map((product, i) => ( <div className={styles.row}>
<BagelCard <div className={styles.square}>
key={product.id} <img src={products[0].images[0].url} alt="" />
product={product} </div>
imgProps={{ <div className={styles.info}>
width: i === 0 ? 1080 : 540, <h1>
height: i === 0 ? 1080 : 540, Featuring <i>Grain</i>changing Technology
}} </h1>
/> <button>
))} <h5>Try The Better Bagel</h5>
</Grid> </button>
{/* <FeaturedIn>Featured In</FeaturedIn> */} </div>
{/* <Banana>Banana Comparison</Banana> */} </div>
{/* <Nutrition></Nutrition> */} </div>
{/* <Mission></Mission> */} </div>
<Marquee variant="secondary">
{/* instagram */}
{products.slice(0, 3).map((product, i) => (
<BagelCard
key={product.id}
product={product}
variant="slim"
imgProps={{
width: 320,
height: 320,
}}
/>
))}
</Marquee>
</> </>
) )
} }

View File

@ -12,21 +12,22 @@
} }
.main { .main {
padding: 5rem 0;
margin: 2em; margin: 2em;
width: 100%;
flex: 1; flex: 1;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
justify-content: center; justify-content: flex-start;
align-items: center; align-items: center;
div { div {
display: flex; display: flex;
} }
} }
.grid { .row {
flex-flow: row nowrap; flex-flow: row nowrap;
margin: 2em; margin: 0 2em;
width: 100%;
div { div {
width: 50%; width: 50%;
margin: 2em; margin: 2em;

View File

@ -17,7 +17,9 @@ a {
h1 { h1 {
margin: 0; margin: 0;
font-size: 42px;
font-weight: 400; font-weight: 400;
line-height: 44px;
} }
h2 { h2 {
@ -32,18 +34,24 @@ h3 {
h4 { h4 {
margin: 0; margin: 0;
font-size: 20px;
font-weight: 700;
} }
h5 { h5 {
margin: 0; margin: 0;
font-size: 16px;
font-weight: 700;
} }
h6 { h6 {
margin: 0; margin: 0;
font-size: 12px;
font-weight: 700;
} }
btn { button {
padding: 10px 30px; padding: 10px 36px;
color: white; color: white;
background: black; background: black;
width: fit-content; width: fit-content;
@ -53,6 +61,6 @@ btn {
transition: 0.3s; transition: 0.3s;
} }
btn:hover { button:hover {
background: rgb(78, 78, 78); background: rgb(78, 78, 78);
} }