summaryrefslogtreecommitdiff
path: root/src/lib/home/components
diff options
context:
space:
mode:
authorRafi Zadanly <zadanlyr@gmail.com>2023-03-29 14:29:29 +0700
committerRafi Zadanly <zadanlyr@gmail.com>2023-03-29 14:29:29 +0700
commit1d606fe88f97f87e32a58b1b187a71f40c70169c (patch)
tree3045839e7e9362f1b851d182614f6ed3ae04af80 /src/lib/home/components
parentac230a35f325cc47e89fd5d635847536f2dd9b44 (diff)
blog detail
Diffstat (limited to 'src/lib/home/components')
-rw-r--r--src/lib/home/components/HeroBanner.jsx54
1 files changed, 33 insertions, 21 deletions
diff --git a/src/lib/home/components/HeroBanner.jsx b/src/lib/home/components/HeroBanner.jsx
index 95f590fc..e6136e03 100644
--- a/src/lib/home/components/HeroBanner.jsx
+++ b/src/lib/home/components/HeroBanner.jsx
@@ -8,14 +8,23 @@ import { Pagination, Autoplay } from 'swiper'
import 'swiper/css'
import 'swiper/css/pagination'
import 'swiper/css/autoplay'
-import useDevice from '@/core/hooks/useDevice'
+import MobileView from '@/core/components/views/MobileView'
+import DesktopView from '@/core/components/views/DesktopView'
const HeroBanner = () => {
- const { isMobile } = useDevice()
const { heroBanners } = useHeroBanner()
- const swiperBanner = {
- pagination: { dynamicBullets: isMobile ? true : false, clickable: true },
+ const swiperBannerMobile = {
+ pagination: { dynamicBullets: true, clickable: true },
+ autoplay: {
+ delay: 6000,
+ disableOnInteraction: false
+ },
+ modules: [Pagination, Autoplay]
+ }
+
+ const swiperBannerDesktop = {
+ pagination: { dynamicBullets: false, clickable: true },
autoplay: {
delay: 6000,
disableOnInteraction: false
@@ -27,23 +36,26 @@ const HeroBanner = () => {
<div className='min-h-[200px]'>
{heroBanners.isLoading && <ImageSkeleton />}
{!heroBanners.isLoading && (
- <Swiper
- slidesPerView={1}
- pagination={swiperBanner.pagination}
- modules={swiperBanner.modules}
- autoplay={swiperBanner.autoplay}
- className='border border-gray_r-6'
- >
- {heroBanners.data?.map((banner, index) => (
- <SwiperSlide key={index}>
- <Image
- src={banner.image}
- alt={banner.name}
- className='w-full h-auto'
- />
- </SwiperSlide>
- ))}
- </Swiper>
+ <>
+ <MobileView>
+ <Swiper slidesPerView={1} className='border border-gray_r-6' {...swiperBannerMobile}>
+ {heroBanners.data?.map((banner, index) => (
+ <SwiperSlide key={index}>
+ <Image src={banner.image} alt={banner.name} className='w-full h-auto' />
+ </SwiperSlide>
+ ))}
+ </Swiper>
+ </MobileView>
+ <DesktopView>
+ <Swiper slidesPerView={1} className='border border-gray_r-6' {...swiperBannerDesktop}>
+ {heroBanners.data?.map((banner, index) => (
+ <SwiperSlide key={index}>
+ <Image src={banner.image} alt={banner.name} className='w-full h-auto' />
+ </SwiperSlide>
+ ))}
+ </Swiper>
+ </DesktopView>
+ </>
)}
</div>
)