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
ease-linear cursor-pointer;
height: 100% !important;
display: flex;
flex-flow: row nowrap;
&:hover {
& .squareBg:before {
@ -18,47 +20,20 @@
& .wishlistButton {
@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 {
@apply bg-violet;
}
&:nth-child(6n + 5) .squareBg {
@apply bg-blue;
}
&:nth-child(6n + 3) .squareBg {
@apply bg-pink;
}
&:nth-child(6n + 6) .squareBg {
@apply bg-cyan;
}
.button {
@apply bg-gray-900 hover:bg-gray-500;
padding: 10px 30px;
color: white;
/* background: black; */
font-weight: 600;
width: fit-content;
height: auto;
border-radius: 20px;
text-align: center;
transition: 0.3s;
}
.squareBg,
@ -84,50 +59,15 @@
@apply bg-accents-0 !important;
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 {
@apply flex items-center justify-center;
overflow: hidden;
& > div {
min-width: 100%;
min-width: 50%;
}
}

View File

@ -21,42 +21,10 @@ const BagelCard: FC<Props> = ({
imgProps,
...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 className="flex flex-row justify-between box-border w-full z-20 absolute">
<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={cn(s.root, { [s.simple]: variant === 'simple' }, className)}
>
<div className={s.imageContainer}>
{product?.images && (
<Image
@ -71,10 +39,16 @@ const BagelCard: FC<Props> = ({
/>
)}
</div>
</>
)}
</a>
<div className={s.textContainer}>
<h1>
Featuring <i>Grain</i>changing Technology
</h1>
<Link href={`/product/${product.slug}`} {...props}>
<a className={s.button}>Try The Better Bagel</a>
</Link>
</div>
</div>
</>
)
export default BagelCard

View File

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

View File

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

View File

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

View File

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