Skip to content

Commit

Permalink
chore: common ad slides in mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
thechefpenguin committed Nov 4, 2024
1 parent db25147 commit 9de617f
Showing 1 changed file with 23 additions and 18 deletions.
41 changes: 23 additions & 18 deletions apps/web/src/components/AdPanel/CardLayouts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import styled from 'styled-components'
import { Autoplay, EffectFade, Pagination } from 'swiper/modules'
import { SwiperSlide } from 'swiper/react'
import { StyledSwiper } from './CarrouselWithSlider'
import { TitleContentAd } from './Variations/TitleContentAd'
import { AdList } from './config'

const FloatingContainer = styled(Box)`
Expand All @@ -21,6 +20,27 @@ const MobileContainer = styled(Box)`
align-items: center;
`

const AdSlides = () => {
return (
<StyledSwiper
modules={[Autoplay, Pagination, EffectFade]}
spaceBetween={50}
observer
slidesPerView={1}
effect="fade"
fadeEffect={{ crossFade: true }}
speed={500}
autoplay={{ delay: 5000, pauseOnMouseEnter: true, disableOnInteraction: false }}
loop
pagination={{ clickable: true }}
>
{AdList.map((ad) => (
<SwiperSlide key={ad.id}>{ad.component}</SwiperSlide>
))}
</StyledSwiper>
)
}

/**
* Renders floating Ad banners on desktop
*/
Expand All @@ -31,22 +51,7 @@ export const DesktopCard = () => {
return portalRoot && isDesktop
? createPortal(
<FloatingContainer>
<StyledSwiper
modules={[Autoplay, Pagination, EffectFade]}
spaceBetween={50}
observer
slidesPerView={1}
effect="fade"
fadeEffect={{ crossFade: true }}
speed={500}
autoplay={{ delay: 5000, pauseOnMouseEnter: true, disableOnInteraction: false }}
loop
pagination={{ clickable: true }}
>
{AdList.map((ad) => (
<SwiperSlide key={ad.id}>{ad.component}</SwiperSlide>
))}
</StyledSwiper>
<AdSlides />
</FloatingContainer>,
portalRoot,
)
Expand All @@ -60,7 +65,7 @@ export const MobileCard = () => {
const { isDesktop } = useMatchBreakpoints()
return !isDesktop ? (
<MobileContainer>
<TitleContentAd />
<AdSlides />
</MobileContainer>
) : null
}

0 comments on commit 9de617f

Please sign in to comment.