import { useEffect, useLayoutEffect, useState } from '@wordpress/element';
import { colord } from 'colord';
import { AnimatePresence, motion } from 'framer-motion';
export const PagesSkeleton = ({ pages }) => {
const [currentIndex, setCurrentIndex] = useState(0);
useEffect(() => {
const timer = setTimeout(() => {
setCurrentIndex((prevIndex) => (prevIndex + 1) % pages.length);
}, 10000);
return () => clearTimeout(timer);
}, [pages.length, currentIndex]);
return (
);
};
const PageSkeleton = ({ pageName }) => {
const [isLightBg, setIsLightBg] = useState(false);
const [show, setShow] = useState(false);
const [title, setTitle] = useState('');
useLayoutEffect(() => {
const documentStyles = window.getComputedStyle(document.body);
const bannerMain = documentStyles.getPropertyValue('--ext-banner-main');
setIsLightBg(colord(bannerMain).isLight());
}, []);
useEffect(() => {
setShow(false);
const timer = setTimeout(() => {
setShow(true);
setTitle(pageName);
}, 700);
return () => clearTimeout(timer);
}, [pageName]);
return (
{show ? (
{title}
{[0, 1, 2].map((item) => {
const delay = 3 * item;
return (
);
})}
) : null}
);
};
const Piece = ({ className, i }) => (
);