import { ChevronLeft, ChevronRight, Images, Plus } from 'lucide-react' import { useRef } from 'react' import { useLocale } from '@meshkee/dashboard-ui' import { useT } from '../i18n/useT' import type { WebsiteSliderSlide } from '../types/websiteSlider' import { EmptyState } from './EmptyState' import { Tooltip } from './Tooltip' import { WebsiteSliderSlideCard } from './WebsiteSliderSlideCard' import styles from './WebsiteSliderGallery.module.css' interface WebsiteSliderGalleryProps { slides: WebsiteSliderSlide[] onAddSlide: () => void onRemoveSlide: (slide: WebsiteSliderSlide) => void showAdd?: boolean addLabel?: string aspectRatio?: string | null removeLabel?: string } export function WebsiteSliderGallery({ slides, onAddSlide, onRemoveSlide, showAdd = true, addLabel, aspectRatio, removeLabel, }: WebsiteSliderGalleryProps) { const t = useT() const { locale } = useLocale() const isFa = locale === 'fa' const trackRef = useRef(null) const showNav = slides.length > 0 const addText = addLabel ?? t('website.sliders.addSlide') if (slides.length === 0) { return ( ) } function scrollBy(direction: -1 | 1) { const track = trackRef.current if (!track) return const amount = Math.max(track.clientWidth * 0.75, 280) track.scrollBy({ left: direction * amount, behavior: 'smooth' }) } const addCard = showAdd ? (
) : null const slideCards = slides.map((slide) => (
onRemoveSlide(slide)} aspectRatio={aspectRatio} removeLabel={removeLabel} />
)) return (
{showNav && (
)}
{slideCards} {addCard}
) }