'use client' import React, { FC, useRef, useState } from 'react' import { AnimatePresence, motion, useInView } from 'framer-motion' import { Switch, cn } from 'ui' interface Props { className?: string } const CostControlAnimation: FC = ({ className }) => { const [hasSpendCap, setHasSpendCap] = useState(true) const ref = useRef(null) const isInView = useInView(ref, { margin: '-25%', once: true }) const toggleSpendCap = () => setHasSpendCap(!hasSpendCap) const bars = [{ y: 30 }, { y: 45 }, { y: 55 }, { y: 65 }, { y: 80 }] const variants = { hidden: { opacity: 0, transition: { when: 'beforeChildren', duration: 0.2, }, }, enabled: { opacity: 1, transition: { when: 'beforeChildren', duration: 0, }, }, } const barVariant = { hidden: { opacity: 0, height: 0, transition: { duration: 0, }, }, enabled: (i: number) => ({ height: '100%', opacity: 1, transition: { ease: [0.11, 0.04, 0, 1], duration: 0.17, delay: i * 0.075, }, }), } return (
Spend Cap {hasSpendCap ? 'On' : 'Off'}
{hasSpendCap && ( {bars.map((bar, index) => (
50 ? 50 : bar.y) + '%' }} >
))}
)} {!hasSpendCap && ( {bars.map((bar, index) => (
))}
{bars.map((bar, index) => (
{bar.y > 50 && ( $ )}
))}
)}
) } const Grid = () => (
) export default CostControlAnimation