Skip to content

Commit

Permalink
Refactor Slider component to set direction based on language prop
Browse files Browse the repository at this point in the history
  • Loading branch information
jamalsoueidan committed Jun 14, 2024
1 parent fc8a8e6 commit 60df67b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions app/components/Slider.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import {Carousel, type CarouselProps} from '@mantine/carousel';
import useEmblaCarousel from 'embla-carousel-react';
import {useState} from 'react';
import classes from './Slider.module.css';

export function Slider({
children,
language,
...props
}: CarouselProps & {language: string}) {
const [options, setOptions] = useState({direction: 'rtl' as any});
const [emblaRef, emblaApi] = useEmblaCarousel(options);
const [emblaRef, emblaApi] = useEmblaCarousel({
direction: language === 'AR' ? 'rtl' : 'ltr',
});

return (
<Carousel
Expand All @@ -19,6 +19,7 @@ export function Slider({
withControls={false}
align="start"
containScroll="keepSnaps"
ref={emblaRef}
{...props}
>
{children}
Expand Down

0 comments on commit 60df67b

Please sign in to comment.