import { motion } from 'framer-motion'
import { forwardRef } from 'react'

type AnimatedSectionProps = {
  children: React.ReactNode
  id?: string
  className?: string
}

export const AnimatedSection = forwardRef<HTMLElement, AnimatedSectionProps>(
  ({ children, id, className }, ref) => {
  return (
        <motion.section
      ref={ref}
      id={id}
      className={className}
      initial={{ opacity: 0, y: 40 }}
      whileInView={{ opacity: 1, y: 0 }}
      viewport={{ once: true, margin: '-25% 0px -20% 0px' }}
      transition={{ duration: 0.5, ease: 'easeOut' }}
    >
      {children}
    </motion.section>
  )
  },
)
