import { clsx } from 'clsx' import { For, Show, onMount } from 'solid-js' import SwiperCore from 'swiper' import { Manipulation, Navigation, Pagination } from 'swiper/modules' import { Shout } from '../../../graphql/schema/core.gen' import { ArticleCard } from '../../Feed/ArticleCard' import { Icon } from '../Icon' import { ShowOnlyOnClient } from '../ShowOnlyOnClient' import { SwiperRef } from './swiper' import styles from './Swiper.module.scss' type Props = { slides: Shout[] title?: string } export const ArticleCardSwiper = (props: Props) => { const mainSwipeRef: { current: SwiperRef } = { current: null } onMount(async () => { if (props.slides.length > 1) { const { register } = await import('swiper/element/bundle') register() SwiperCore.use([Pagination, Navigation, Manipulation]) } }) return (
1, [styles.articleMode]: true, [styles.ArticleCardSwiper]: props.slides.length > 1, [styles.unswiped]: props.slides.length === 1, })} >

{props.title}

1} fallback={ } >
(mainSwipeRef.current = el)} centered-slides={true} observer={true} space-between={10} breakpoints={{ 576: { spaceBetween: 20, slidesPerView: 1.5 }, 992: { spaceBetween: 52, slidesPerView: 1.5 }, }} round-lengths={true} loop={true} speed={800} autoplay={{ disableOnInteraction: false, delay: 6000, pauseOnMouseEnter: true, }} > {(slide, index) => ( // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore )}
mainSwipeRef.current.swiper.slidePrev()} >
mainSwipeRef.current.swiper.slideNext()} >
) }