1
1
import React from 'react'
2
2
import { CarouselContextType , useCarousel } from './Carousel' ;
3
3
import { ComponentStylePrimitiveProps } from '../../primitives/types' ;
4
+ import { twMerge } from 'tailwind-merge' ;
5
+ import clsx from 'clsx' ;
4
6
5
7
export interface CarouselContainerProps extends ComponentStylePrimitiveProps < HTMLDivElement > {
6
8
children : React . ReactNode
@@ -10,7 +12,7 @@ export const CarouselContainer: React.FC<CarouselContainerProps> = ({ children,
10
12
const { className, ...rest } = props
11
13
const { containerRef } = useCarousel ( ) ;
12
14
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 } >
14
16
{ children }
15
17
</ div >
16
18
)
@@ -21,7 +23,7 @@ export interface CarouselItemProps extends CarouselContainerProps { }
21
23
export const CarouselItem : React . FC < CarouselItemProps > = ( { children, ...props } ) => {
22
24
const { className, ...rest } = props
23
25
return (
24
- < div className = { ` flex-shrink-0 relative ${ className } ` } { ...rest } >
26
+ < div className = { twMerge ( clsx ( ' flex-shrink-0 relative' , className ) ) } { ...rest } >
25
27
{ children }
26
28
</ div >
27
29
)
@@ -33,7 +35,7 @@ export interface CarouselControlProps extends ComponentStylePrimitiveProps<HTMLD
33
35
34
36
export const CarouselControls : React . FC < CarouselControlProps > = ( { children, className, ...props } ) => {
35
37
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 } >
37
39
{ children }
38
40
</ div >
39
41
)
@@ -58,7 +60,7 @@ export const CarouselPreviousButton: React.FC<CarouselButtonProps> = ({ children
58
60
const { icon, className, ...rest } = props
59
61
60
62
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 } >
62
64
{ icon }
63
65
</ button >
64
66
) ;
@@ -79,7 +81,7 @@ export const CarouselNextButton: React.FC<CarouselButtonProps> = ({ children, ..
79
81
const { icon, className, ...rest } = props
80
82
81
83
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 } >
83
85
{ icon }
84
86
</ button >
85
87
) ;
0 commit comments