🐛 bug: carousel

:%s
This commit is contained in:
DatNguyen
2021-09-20 10:41:23 +07:00
13 changed files with 51 additions and 19 deletions

View File

@@ -0,0 +1,3 @@
.bannerWrap {
@apply w-full;
}

View File

@@ -3,6 +3,7 @@ import React, { memo } from 'react'
import { ResponsiveType } from 'react-multi-carousel' import { ResponsiveType } from 'react-multi-carousel'
import CarouselCommon from '../CarouselCommon/CarouselCommon' import CarouselCommon from '../CarouselCommon/CarouselCommon'
import BannerItem, { BannerItemProps } from './BannerItem/BannerItem' import BannerItem, { BannerItemProps } from './BannerItem/BannerItem'
import s from './Banner.module.scss'
interface Props { interface Props {
data: BannerItemProps[], data: BannerItemProps[],
@@ -29,13 +30,15 @@ const Banner = memo(({ data }: Props) => {
/> />
} }
return ( return (
<CarouselCommon<BannerItemProps> <div className={s.bannerWrap}>
data={data} <CarouselCommon<BannerItemProps>
itemKey="banner" data={data}
Component={BannerItem} itemKey="banner"
responsive={RESPONSIVE} Component={BannerItem}
showDots={true} responsive={RESPONSIVE}
/> showDots={true}
/>
</div>
) )
}) })

View File

@@ -1,8 +1,11 @@
@import "../../../../styles/utilities"; @import "../../../../styles/utilities";
.bannerItem { .bannerItem {
@apply bg-primary-light shape-common-lg overflow-hidden; @apply bg-primary-light shape-common-lg overflow-hidden w-full;
padding: 0; padding: 0;
@screen lg {
max-height: 42rem;
}
&.large { &.large {
margin-bottom: 2.8rem; margin-bottom: 2.8rem;
background-image: url("./pattern.svg"); background-image: url("./pattern.svg");

View File

@@ -72,13 +72,14 @@ const CarouselCommon = <T,>({
responsive={responsive} responsive={responsive}
arrows={false} arrows={false}
renderDotsOutside={true} renderDotsOutside={true}
ssr={true}
// customLeftArrow={<CustomCarouselArrow side="left" />} // customLeftArrow={<CustomCarouselArrow side="left" />}
// customRightArrow={<CustomCarouselArrow side="right" />} // customRightArrow={<CustomCarouselArrow side="right" />}
> >
{data?.map((props, index) => { {data.map((props, index) => {
const allProps = defaultComponentProps const allProps = defaultComponentProps
? { ...props, ...defaultComponentProps } ? { ...props, ...defaultComponentProps }
: props : props
return <Component {...allProps} key={`${itemKey}-${index}`} /> return <Component {...allProps} key={`${itemKey}-${index}`} />
})} })}
</Carousel> </Carousel>

View File

@@ -9,6 +9,7 @@
} }
} }
@screen lg { @screen lg {
max-width: 18.1rem;
@apply block; @apply block;
margin-right: 4rem; margin-right: 4rem;
padding: 0; padding: 0;

View File

@@ -20,13 +20,19 @@
} }
.productsWrap { .productsWrap {
@apply spacing-horizontal-left; @apply spacing-horizontal-left;
overflow: hidden;
@screen lg { @screen lg {
max-width: 75%; flex: 1;
// max-width: 75%;
padding: 0 0.8rem; padding: 0 0.8rem;
> div > div { > div > div {
@apply shape-common-lg bg-white; @apply shape-common-lg bg-white;
padding: 4rem 0; padding: 4rem 0;
} }
> div {
margin: 0 2.4;
overflow: visible
}
:global(.customArrow) { :global(.customArrow) {
@screen lg { @screen lg {
&:global(.leftArrow) { &:global(.leftArrow) {
@@ -40,7 +46,7 @@
} }
@screen xl { @screen xl {
padding: 0 2.4rem; padding: 0 2.4rem;
max-width: 80%; // max-width: 80%;
} }
} }
} }

View File

@@ -80,6 +80,7 @@ const ListProductWithInfo = ({ data, title, subtitle, hasBorderBottomMobile }: P
<CarouselCommon<ProductCardProps> <CarouselCommon<ProductCardProps>
data={data} data={data}
Component={ProductCard} Component={ProductCard}
// draggable={true} infinite={true}
itemKey={title} itemKey={title}
responsive={RESPONSIVE} responsive={RESPONSIVE}
/> />

View File

@@ -32,7 +32,6 @@ const ProductCard = ({
</div> </div>
} }
return ( return (
<div className={s.productCardWarpper}> <div className={s.productCardWarpper}>
<div className={s.cardTop}> <div className={s.cardTop}>

View File

@@ -1,15 +1,21 @@
@import "../../../../styles/utilities"; @import "../../../../styles/utilities";
.homeBanner { .homeBanner {
@apply spacing-horizontal; @apply spacing-horizontal overflow-hidden;
margin-bottom: 2.8rem; margin-bottom: 2.8rem;
.left { .left {
@apply hidden; @apply hidden;
margin-bottom: 3rem; margin-bottom: 3rem;
max-width: 50rem;
} }
@screen xl { @screen xl {
@apply grid; @apply grid;
grid-template-columns: 35.75% 64.25%; grid-template-columns: 35.75% 64.25%;
// grid-template-columns: 1fr 1.8fr;
> div {
@apply w-full overflow-hidden;
}
.left { .left {
@apply relative flex items-end justify-center shape-common-lg; @apply relative flex items-end justify-center shape-common-lg;
margin-right: 1.6rem; margin-right: 1.6rem;
@@ -29,7 +35,6 @@
@apply relative font-heading text-center; @apply relative font-heading text-center;
padding: 2.4rem 2.4rem 4.8rem; padding: 2.4rem 2.4rem 4.8rem;
width: min-content; width: min-content;
color: var(--white); color: var(--white);
font-size: 8.8rem; font-size: 8.8rem;
line-height: 8rem; line-height: 8rem;

View File

@@ -8,5 +8,9 @@
} }
> div { > div {
width: 100%; width: 100%;
// > div {
// height: 100%;
// }
} }
} }

View File

@@ -26,7 +26,7 @@ const DATA = [
const RESPONSIVE: ResponsiveType = { const RESPONSIVE: ResponsiveType = {
desktop: { desktop: {
breakpoint: { max: 999, min: 0 }, breakpoint: { max: 9999, min: 0 },
items: 1, items: 1,
slidesToSlide: 1, // optional, default to 1. slidesToSlide: 1, // optional, default to 1.
}, },

View File

@@ -16,6 +16,12 @@ const ProductListBanner = ({ }: Props) => {
subtitle: "Last call! Shop deep deals on 100+ bulk picks while you can.", subtitle: "Last call! Shop deep deals on 100+ bulk picks while you can.",
imgLink: BannerRight.src, imgLink: BannerRight.src,
size: "large", size: "large",
},
{
title: "Save 15% on your first order",
subtitle: "Last call! Shop deep deals on 100+ bulk picks while you can.",
imgLink: BannerRight.src,
size: "large",
} }
] ]
} }

View File

@@ -1,4 +1,4 @@
@import url("https://fonts.googleapis.com/css2?family=Nunito&family=Poppins:wght@500&family=Righteous&display=swap"); @import url("https://fonts.googleapis.com/css2?family=Nunito&family=Poppins:wght@500&display=swap");
@import '../../public/fonts/style.css'; @import '../../public/fonts/style.css';
:root { :root {
@@ -42,7 +42,7 @@
--line-height: 2.4rem; --line-height: 2.4rem;
--font-sans: "Nunito", -apple-system, system-ui, BlinkMacSystemFont, "Helvetica Neue", "Helvetica", sans-serif; --font-sans: "Nunito", -apple-system, system-ui, BlinkMacSystemFont, "Helvetica Neue", "Helvetica", sans-serif;
--font-heading: "Norquay-bold", "Righteous", -apple-system, system-ui, BlinkMacSystemFont, "Helvetica Neue", "Helvetica", sans-serif; --font-heading: "Norquay-bold", monospace, -apple-system, system-ui, BlinkMacSystemFont, "Helvetica Neue", "Helvetica", sans-serif;
--font-logo: "Poppins", -apple-system, system-ui, BlinkMacSystemFont, "Helvetica Neue", "Helvetica", sans-serif; --font-logo: "Poppins", -apple-system, system-ui, BlinkMacSystemFont, "Helvetica Neue", "Helvetica", sans-serif;
} }