import PropTypes from 'prop-types' import React from 'react' import styles from './styles.module.css' interface CustomHTMLAttributes extends React.HTMLAttributes { '--active'?: number; '--offset'?: number; '--direction'?: number; '--abs-offset'?: number; } interface Carrusel3DProps { active: number children: any maxView?: number moveLeft: any moveRight: any } export const Carrusel3D: React.FC = (props) => { const { children, active, moveRight, moveLeft, maxView } = props const MAX_VISIBILITY = maxView ?? 3 const count = React.Children.count(children) return ( <>
{React.Children.map(children, (child, i) => {return (
= MAX_VISIBILITY ? '0' : '1', display: Math.abs(active - i) > MAX_VISIBILITY ? 'none' : 'block' } } as CustomHTMLAttributes} > {child}
)})}
) } Carrusel3D.propTypes = { active: PropTypes.number.isRequired, children: PropTypes.any, maxView: PropTypes.number, moveLeft: PropTypes.any, moveRight: PropTypes.any }