import { AnimatePresence, motion } from 'framer-motion'; import { useEffect, useState } from 'react'; import style from './LowerLines.module.css'; import NavLogo from "../../../../common/components/nav/NavLogo"; export default function LowerLines(props) { const { lower, title, options } = props; const defaults = { size: 1, transitionIn: 3, textColour: '#fffffa', bgColour: '#00000033', }; const [showLower, setShowLower] = useState(true); // Unmount if fadeOut useEffect(() => { if (!options.fadeOut) return; // Calculate time const fadeOutTime = (parseInt(options.fadeOut) + (options.transitionIn || defaults.transitionIn)) * 1000; if (isNaN(fadeOutTime)) return; const timeout = setTimeout(() => { setShowLower(false); }, fadeOutTime); return () => clearTimeout(timeout); }, [options.fadeOut, options.transitionIn, defaults.transitionIn]); useEffect(() => { setShowLower(title.showNow); }, [title.showNow]); // Format messages const showLowerMessage = lower.text !== '' && lower.visible; // motion // transition segments const t = options.transitionIn || defaults.transitionIn; const eight = t / 8; const quarter = t / 4; const third = t / 3; const half = t / 2; const lowerThirdVariants = { hidden: { opacity: 0, }, visible: { opacity: 1, transition: { duration: third, }, }, exit: { opacity: 0, x: -1000, transition: { duration: third, }, }, }; const titleContainerVariants = { hidden: { left: -1000, }, visible: { left: 0, transition: { duration: third, }, }, }; const titleVariants = { hidden: { opacity: 0, }, visible: { opacity: 1, transition: { delay: quarter, duration: half, }, }, }; const subtitleContainerVariants = { hidden: { left: -1000, }, visible: { left: 0, transition: { delay: eight, duration: third, }, }, }; const subtitleVariants = { hidden: { opacity: 0, }, visible: { opacity: 1, transition: { delay: third, duration: third * 2, }, }, }; const sizeMultiplier = (options.size || 1) * 4; return (