import React, { useState, useEffect } from 'react';const BoxBreathing = () => { const [phase, setPhase] = useState(0); const [progress, setProgress] = useState(0); const phases = ['Inhale', 'Hold', 'Exhale', 'Hold']; const duration = 4000; // 4 seconds per phase useEffect(() => { const timer = setInterval(() => { setProgress((oldProgress) => { if (oldProgress === 100) { setPhase((oldPhase) => (oldPhase + 1) % 4); return 0; } return oldProgress + 1; }); }, duration / 100); return () => clearInterval(timer); }, []); const getBoxStyle = (index) => ({ position: 'absolute', width: `${100 - index * 25}%`, height: `${100 - index * 25}%`, border: '2px solid #3498db', boxSizing: 'border-box', transition: 'all 0.3s ease', opacity: phase === index ? 1 : 0.3, transform: `rotate(${progress * 0.9}deg)`, }); return (

Box Breathing

{[0, 1, 2, 3].map((index) => (
))}
{phases[phase]}
{phases[phase]}
);};export default BoxBreathing;