import React from 'react'; import { useTranslation } from 'react-i18next'; import { ArrowLeftOutlined, ArrowRightOutlined } from '@ant-design/icons'; import { Link } from 'gatsby'; import Slider from 'react-slick'; import classNames from 'classnames'; import 'slick-carousel/slick/slick.css'; import 'slick-carousel/slick/slick-theme.css'; import styles from './Cases.module.less'; interface Case { logo?: string; isAppLogo?: boolean; title: string; description: string; link?: string; image: string; } interface CasesProps { cases: Case[]; style?: React.CSSProperties; className?: string; } const Cases: React.FC = ({ cases = [], style = {}, className }) => { const { t } = useTranslation(); let slider: any; const clickPrevious = () => { slider.slickPrev(); }; const clickNext = () => { slider.slickNext(); }; const getCases = () => { let buttons: any; if (cases.length > 1) { buttons = (
); } const children = cases.map((app) => { const linkDiv = (
{app.link && app.link.startsWith('http') ? ( {t('查看详情')} ) : ( {t('查看详情')} )}
); return (
{app.title}
logo

{app.title}

{app.description}

{linkDiv}
{buttons}
); }); return children; }; const sliderSettings = { dots: cases.length > 1, infinite: true, slidesToShow: 1, adaptiveHeight: true, speed: 500, cssEase: 'linear', arrows: false, autoplay: true, autoplaySpeed: 3000, fade: true, }; return (
{ slider = c; }} > {getCases()}
); }; export default Cases;