"use client"; import Box from "@/components/Box"; import { FC, PropsWithChildren, useRef } from "react"; import { Swiper, SwiperClass, SwiperSlide } from "swiper/react"; import { GroupType } from "@/api/home"; import { CardProps } from "@/components/Card/Card"; import GroupCard, { GroupProps } from "@/components/Card/GroupCard"; import styles from "./style.module.scss"; interface SwiperGroupProps extends GroupProps, CardProps { group: GroupType; page?: number; // todos visibleTodos?: boolean; // icon offsetX?: number; offsetY?: number; } const HomeSwiper: FC> = (props) => { const { group, page = 6, visibleTodos = true, ...other } = props; const swiperRef = useRef(null); const swiperData = Array(Math.ceil(group.to_tal! / page)) .fill(0) .map((_, index) => { return { key: index, data: group.game_list!.slice(index * page, index * page + page), }; }); const prev = () => { swiperRef.current!.slidePrev(); }; const next = () => { swiperRef.current!.slideNext(); }; return ( <>
{group.category_name}
{group.tag}
{visibleTodos && (
Todos {group.to_tal}
)}
{ swiperRef.current = swiper; }} loop > {swiperData?.map((data, index) => ( ))} ); }; export default HomeSwiper;