From 0b46b9d21f407adbd076521e4247bb484c73dbaa Mon Sep 17 00:00:00 2001 From: wnhlee <2wheeh@gmail.com> Date: Thu, 2 May 2024 18:23:21 +0900 Subject: [PATCH] feat: implement Swiper --- ui/src/components/common/client/swiper.tsx | 52 ++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 ui/src/components/common/client/swiper.tsx diff --git a/ui/src/components/common/client/swiper.tsx b/ui/src/components/common/client/swiper.tsx new file mode 100644 index 00000000..1b687240 --- /dev/null +++ b/ui/src/components/common/client/swiper.tsx @@ -0,0 +1,52 @@ +'use client'; + +import clsx from 'clsx'; + +import { useSwiper } from '@/hooks/common/use-swiper'; + +import { getValidChildrenOfType } from '@/lib/utils/common/get-valid-children-of-type'; + +function Swiper({ children }: { children: React.ReactNode }) { + const { offsetX, onTouchStart, currentIdx, onIndicatorClick, isSwiping, containerRef } = + useSwiper(); + + const slides = getValidChildrenOfType(children, SwiperSlide); + + return ( +
+ + + +
+ ); +} + +function SwiperSlide({ children }: { children: React.ReactNode }) { + return
  • {children}
  • ; +} + +export default Object.assign(Swiper, { Slide: SwiperSlide });