forked from crowetic/commerce
Grid and Marquee Updated
This commit is contained in:
parent
77b011474d
commit
7d7d2deff6
@ -1,12 +1,12 @@
|
|||||||
import cn from 'classnames'
|
import cn from 'classnames'
|
||||||
import s from './ProductCard.module.css'
|
import s from './ProductCard.module.css'
|
||||||
import { FC } from 'react'
|
import { FC, ReactNode, Component } from 'react'
|
||||||
import { Heart } from '@components/icon'
|
import { Heart } from '@components/icon'
|
||||||
import Link from 'next/link'
|
import Link from 'next/link'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
className?: string
|
className?: string
|
||||||
children?: any
|
children?: ReactNode[] | Component[] | any[]
|
||||||
node: ProductData
|
node: ProductData
|
||||||
variant?: 'slim'
|
variant?: 'slim'
|
||||||
}
|
}
|
||||||
|
@ -4,20 +4,15 @@ import s from './Grid.module.css'
|
|||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
className?: string
|
className?: string
|
||||||
children?: any
|
children?: ReactNode[] | Component[] | any[]
|
||||||
items: [any] | any
|
|
||||||
layout?: 'A' | 'B' | 'C' | 'D' | 'normal'
|
layout?: 'A' | 'B' | 'C' | 'D' | 'normal'
|
||||||
wrapper?: ReactNode | Component | any
|
|
||||||
variant?: 'default' | 'filled'
|
variant?: 'default' | 'filled'
|
||||||
}
|
}
|
||||||
|
|
||||||
const DefaultWrapper: FC<Props> = ({ children }) => <div>{children}</div> // DEFAULT ITEMS WRAPPER
|
|
||||||
|
|
||||||
const Grid: FC<Props> = ({
|
const Grid: FC<Props> = ({
|
||||||
items = [],
|
|
||||||
className,
|
className,
|
||||||
layout = 'A',
|
layout = 'A',
|
||||||
wrapper: Component = DefaultWrapper,
|
children,
|
||||||
variant = 'default',
|
variant = 'default',
|
||||||
}) => {
|
}) => {
|
||||||
const rootClassName = cn(
|
const rootClassName = cn(
|
||||||
@ -33,13 +28,7 @@ const Grid: FC<Props> = ({
|
|||||||
},
|
},
|
||||||
className
|
className
|
||||||
)
|
)
|
||||||
return (
|
return <div className={rootClassName}>{children}</div>
|
||||||
<div className={rootClassName}>
|
|
||||||
{items.map((data: any, i: any) => (
|
|
||||||
<Component key={i} {...data} />
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Grid
|
export default Grid
|
||||||
|
@ -1,24 +1,15 @@
|
|||||||
import cn from 'classnames'
|
import cn from 'classnames'
|
||||||
import s from './Marquee.module.css'
|
import s from './Marquee.module.css'
|
||||||
import { FC } from 'react'
|
import { FC, ReactNode, Component } from 'react'
|
||||||
import Ticker from 'react-ticker'
|
import Ticker from 'react-ticker'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
className?: string
|
className?: string
|
||||||
children?: any
|
children?: ReactNode[] | Component[] | any[]
|
||||||
items: any[]
|
|
||||||
wrapper?: React.Component | any
|
|
||||||
variant?: 'primary' | 'secondary'
|
variant?: 'primary' | 'secondary'
|
||||||
}
|
}
|
||||||
|
|
||||||
const DefaultWrapper: FC<Props> = ({ children }) => <div>{children}</div> // DEFAULT PRODUCT WRAPPER
|
const M: FC<Props> = ({ className = '', children, variant = 'primary' }) => {
|
||||||
|
|
||||||
const M: FC<Props> = ({
|
|
||||||
className = '',
|
|
||||||
items,
|
|
||||||
wrapper: Component = DefaultWrapper,
|
|
||||||
variant = 'primary',
|
|
||||||
}) => {
|
|
||||||
const rootClassName = cn(
|
const rootClassName = cn(
|
||||||
s.root,
|
s.root,
|
||||||
{
|
{
|
||||||
@ -41,13 +32,7 @@ const M: FC<Props> = ({
|
|||||||
return (
|
return (
|
||||||
<div className={rootClassName}>
|
<div className={rootClassName}>
|
||||||
<Ticker offset={80}>
|
<Ticker offset={80}>
|
||||||
{({ index }) => (
|
{({ index }) => <div className={s.container}>{children}</div>}
|
||||||
<div className={s.container}>
|
|
||||||
{items.map((p: any, i: any) => (
|
|
||||||
<Component key={i} {...p} />
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</Ticker>
|
</Ticker>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
@ -23,11 +23,16 @@ export default function Home({
|
|||||||
}: InferGetStaticPropsType<typeof getStaticProps>) {
|
}: InferGetStaticPropsType<typeof getStaticProps>) {
|
||||||
return (
|
return (
|
||||||
<div className="mt-3">
|
<div className="mt-3">
|
||||||
<Grid items={products.slice(0, 3)} wrapper={ProductCard} />
|
<Grid>
|
||||||
<Marquee
|
{products.slice(0, 3).map((p: any) => (
|
||||||
items={products.slice(0, 3)}
|
<ProductCard key={p.id} {...p} />
|
||||||
wrapper={(p: any) => <ProductCard {...p} variant="slim" />}
|
))}
|
||||||
/>
|
</Grid>
|
||||||
|
<Marquee variant="secondary">
|
||||||
|
{products.slice(0, 3).map((p: any) => (
|
||||||
|
<ProductCard key={p.id} {...p} variant="slim" />
|
||||||
|
))}
|
||||||
|
</Marquee>
|
||||||
<Hero
|
<Hero
|
||||||
headline="Release Details: The Yeezy BOOST 350 V2 ‘Natural'"
|
headline="Release Details: The Yeezy BOOST 350 V2 ‘Natural'"
|
||||||
description="
|
description="
|
||||||
@ -38,12 +43,16 @@ export default function Home({
|
|||||||
Hebrew. It’s now undergone a name change, and will be referred to as
|
Hebrew. It’s now undergone a name change, and will be referred to as
|
||||||
‘Natural’."
|
‘Natural’."
|
||||||
/>
|
/>
|
||||||
<Grid items={products.slice(3, 6)} layout="B" wrapper={ProductCard} />
|
<Grid layout="B">
|
||||||
<Marquee
|
{products.slice(3, 6).map((p: any) => (
|
||||||
items={[...products.slice(3, 6)]}
|
<ProductCard key={p.id} {...p} />
|
||||||
variant="secondary"
|
))}
|
||||||
wrapper={(p: any) => <ProductCard {...p} variant="slim" />}
|
</Grid>
|
||||||
/>
|
<Marquee>
|
||||||
|
{products.slice(0, 3).map((p: any) => (
|
||||||
|
<ProductCard key={p.id} {...p} variant="slim" />
|
||||||
|
))}
|
||||||
|
</Marquee>
|
||||||
<div className="py-12 flex flex-row w-full px-12">
|
<div className="py-12 flex flex-row w-full px-12">
|
||||||
<div className="pr-3 w-48">
|
<div className="pr-3 w-48">
|
||||||
<ul className="mb-10">
|
<ul className="mb-10">
|
||||||
@ -68,15 +77,11 @@ export default function Home({
|
|||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex-1">
|
<div className="flex-1">
|
||||||
<Grid
|
<Grid layout="normal">
|
||||||
items={[
|
{products.map((p: any) => (
|
||||||
...products.slice(6),
|
<ProductCard key={p.id} {...p} />
|
||||||
...products.slice(6),
|
))}
|
||||||
...products.slice(6),
|
</Grid>
|
||||||
]}
|
|
||||||
layout="normal"
|
|
||||||
wrapper={ProductCard}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user