11import React from 'react'
22import { CarouselContextType , useCarousel } from './Carousel' ;
33import { ComponentStylePrimitiveProps } from '../../primitives/types' ;
4+ import { twMerge } from 'tailwind-merge' ;
5+ import clsx from 'clsx' ;
46
57export interface CarouselContainerProps extends ComponentStylePrimitiveProps < HTMLDivElement > {
68 children : React . ReactNode
@@ -10,7 +12,7 @@ export const CarouselContainer: React.FC<CarouselContainerProps> = ({ children,
1012 const { className, ...rest } = props
1113 const { containerRef } = useCarousel ( ) ;
1214 return (
13- < div ref = { containerRef } className = { ` max-w-full h-full flex overflow-scroll gap-2 no-scrollbar ${ className } ` } { ...rest } >
15+ < div ref = { containerRef } className = { twMerge ( clsx ( ' max-w-full h-full flex overflow-scroll gap-2 no-scrollbar' , className ) ) } { ...rest } >
1416 { children }
1517 </ div >
1618 )
@@ -21,7 +23,7 @@ export interface CarouselItemProps extends CarouselContainerProps { }
2123export const CarouselItem : React . FC < CarouselItemProps > = ( { children, ...props } ) => {
2224 const { className, ...rest } = props
2325 return (
24- < div className = { ` flex-shrink-0 relative ${ className } ` } { ...rest } >
26+ < div className = { twMerge ( clsx ( ' flex-shrink-0 relative' , className ) ) } { ...rest } >
2527 { children }
2628 </ div >
2729 )
@@ -33,7 +35,7 @@ export interface CarouselControlProps extends ComponentStylePrimitiveProps<HTMLD
3335
3436export const CarouselControls : React . FC < CarouselControlProps > = ( { children, className, ...props } ) => {
3537 return (
36- < div className = { ` flex items-center gap-2 md:gap-4 w-fit mx-auto pt-4 ${ className } ` } { ...props } >
38+ < div className = { twMerge ( clsx ( ' flex items-center gap-2 md:gap-4 w-fit mx-auto pt-4' , className ) ) } { ...props } >
3739 { children }
3840 </ div >
3941 )
@@ -58,7 +60,7 @@ export const CarouselPreviousButton: React.FC<CarouselButtonProps> = ({ children
5860 const { icon, className, ...rest } = props
5961
6062 return (
61- < button onClick = { goToPreviousSlide } disabled = { ! possibleDirection . canGoToPreviousSlide } className = { ` w-10 h-10 flex items-center justify-center rounded-full border border-gray-600 dark:border-gray-300 p-2 text-gray-600 dark:text-gray-300 transition-colors hover:bg-gray-100 dark:hover:bg-gray-600 disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:bg-transparent disabled:dark:hover:bg-transparent ${ className } ` } { ...rest } >
63+ < button onClick = { goToPreviousSlide } disabled = { ! possibleDirection . canGoToPreviousSlide } className = { twMerge ( clsx ( ' w-10 h-10 flex items-center justify-center rounded-full border border-gray-600 dark:border-gray-300 p-2 text-gray-600 dark:text-gray-300 transition-colors hover:bg-gray-100 dark:hover:bg-gray-600 disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:bg-transparent disabled:dark:hover:bg-transparent' , className ) ) } { ...rest } >
6264 { icon }
6365 </ button >
6466 ) ;
@@ -79,7 +81,7 @@ export const CarouselNextButton: React.FC<CarouselButtonProps> = ({ children, ..
7981 const { icon, className, ...rest } = props
8082
8183 return (
82- < button onClick = { goToNextSlide } disabled = { ! possibleDirection . canGoToNextSlide } className = { ` w-10 h-10 flex items-center justify-center rounded-full border border-gray-600 dark:border-gray-300 p-2 text-gray-600 dark:text-gray-300 transition-colors hover:bg-gray-100 dark:hover:bg-gray-600 disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:bg-transparent disabled:dark:hover:bg-transparent ${ className } ` } { ...rest } >
84+ < button onClick = { goToNextSlide } disabled = { ! possibleDirection . canGoToNextSlide } className = { twMerge ( clsx ( ' w-10 h-10 flex items-center justify-center rounded-full border border-gray-600 dark:border-gray-300 p-2 text-gray-600 dark:text-gray-300 transition-colors hover:bg-gray-100 dark:hover:bg-gray-600 disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:bg-transparent disabled:dark:hover:bg-transparent' , className ) ) } { ...rest } >
8385 { icon }
8486 </ button >
8587 ) ;
0 commit comments