From cf9495e6c27c3e2c94d3450bb84b8600fca7b045 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Sun, 4 Oct 2020 13:25:16 -0300 Subject: [PATCH] 4 types of layout grids --- .../ProductCard/ProductCard.module.css | 2 +- .../product/ProductCard/ProductCard.tsx | 8 +-- .../ProductGrid/ProductGrid.module.css | 66 +++++++++++++++++-- .../product/ProductGrid/ProductGrid.tsx | 14 +++- pages/index.tsx | 15 ++--- 5 files changed, 81 insertions(+), 24 deletions(-) diff --git a/components/product/ProductCard/ProductCard.module.css b/components/product/ProductCard/ProductCard.module.css index 94c5457eb..4dbb8f041 100644 --- a/components/product/ProductCard/ProductCard.module.css +++ b/components/product/ProductCard/ProductCard.module.css @@ -1,5 +1,5 @@ .root { - @apply relative w-full h-full p-6 box-border overflow-hidden; + @apply relative w-full p-6 box-border overflow-hidden; } .productTitle { diff --git a/components/product/ProductCard/ProductCard.tsx b/components/product/ProductCard/ProductCard.tsx index 1c98d71b3..f47630dc1 100644 --- a/components/product/ProductCard/ProductCard.tsx +++ b/components/product/ProductCard/ProductCard.tsx @@ -16,6 +16,7 @@ interface ProductData { const ProductCard: FC = ({ className, productData }) => { const rootClassName = cn(s.root, className) + return (
{/* Overlay */} @@ -30,18 +31,17 @@ const ProductCard: FC = ({ className, productData }) => {
-
-
- {/* */} + {/* */} -
+ {/* */} ) } diff --git a/components/product/ProductGrid/ProductGrid.module.css b/components/product/ProductGrid/ProductGrid.module.css index 10afffada..ddf614ff2 100644 --- a/components/product/ProductGrid/ProductGrid.module.css +++ b/components/product/ProductGrid/ProductGrid.module.css @@ -1,23 +1,23 @@ .root { --row-height: calc(100vh - 80px - 56px); - @apply grid grid-cols-1 lg:grid-cols-3 lg:grid-rows-4 w-full; + @apply grid grid-cols-1 lg:grid-cols-3 lg:grid-rows-2 gap-0; & > * { - @apply row-span-1 lg:col-span-1 h-full bg-black box-border; + @apply row-span-1 lg:col-span-1 bg-black border border-yellow-300 box-border overflow-hidden; height: 500px; + max-height: 800px; @screen lg { - height: auto; + height: inherit; } } +} +.layoutA { & > div:nth-child(6n + 1), & > div:nth-child(6n + 5) { @apply row-span-2 lg:col-span-2 bg-violet; - - @screen lg { - min-height: var(--row-height); - } + height: var(--row-height); } & > div:nth-child(6n + 5) { @@ -32,3 +32,55 @@ @apply bg-cyan; } } + +.layoutB { + & > div:nth-child(6n + 2) { + @apply row-span-2 lg:col-span-2 bg-violet; + height: var(--row-height); + } + + & > div:nth-child(6n + 4) { + @apply row-span-2 lg:col-span-2 bg-blue; + height: var(--row-height); + } + + & > div:nth-child(6n + 3) { + @apply bg-pink; + } + + & > div:nth-child(6n + 6) { + @apply bg-cyan; + } +} + +.layoutC { + & > div:nth-child(12n + 1) { + @apply row-span-2 lg:col-span-2 bg-violet; + height: var(--row-height); + } + + & > div:nth-child(12n + 8) { + @apply row-span-2 lg:col-span-2 bg-cyan; + height: var(--row-height); + } + + & > div:nth-child(6n + 3) { + @apply bg-pink; + } +} + +.layoutD { + & > div:nth-child(12n + 2) { + @apply row-span-2 lg:col-span-2 bg-violet; + height: var(--row-height); + } + + & > div:nth-child(12n + 7) { + @apply row-span-2 lg:col-span-2 bg-cyan; + height: var(--row-height); + } + + & > div:nth-child(6n + 3) { + @apply bg-pink; + } +} diff --git a/components/product/ProductGrid/ProductGrid.tsx b/components/product/ProductGrid/ProductGrid.tsx index 48f410a79..04f29cc53 100644 --- a/components/product/ProductGrid/ProductGrid.tsx +++ b/components/product/ProductGrid/ProductGrid.tsx @@ -6,10 +6,20 @@ interface Props { className?: string children?: any products: [any] | any + layout?: 'A' | 'B' | 'C' | 'D' } -const ProductView: FC = ({ products, className }) => { - const rootClassName = cn(s.root, className) +const ProductView: FC = ({ products, className, layout = 'A' }) => { + const rootClassName = cn( + s.root, + { + [s.layoutA]: layout === 'A', + [s.layoutB]: layout === 'B', + [s.layoutC]: layout === 'C', + [s.layoutD]: layout === 'D', + }, + className + ) return (
{products.map((data: any) => ( diff --git a/pages/index.tsx b/pages/index.tsx index 2878aacf1..c015aeefe 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -16,17 +16,12 @@ export default function Home({ return ( <> -
asdsasad
- + {/* */} + {/*
*/} + {/* */} ) }