PluginProbe
Extendify / 3.2.1
Extendify v3.2.1
3.2.1 3.2.0 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.6 3.0.5 3.0.4 trunk 0.1.0 0.10.0 0.10.1 0.10.2 0.11.0 0.11.1 0.2.0 0.3.0 0.3.1 0.4.0 0.5.0 0.6.0 All 127 releases
extendify / src / Launch / components / CreatingSite / PageSkeleton.jsx

PageSkeleton.jsx in Extendify 3.2.1, at src/Launch/components/CreatingSite/PageSkeleton.jsx

100 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { useEffect, useLayoutEffect, useState } from '@wordpress/element';
2 import { colord } from 'colord';
3 import { AnimatePresence, motion } from 'framer-motion';
4
5 export const PagesSkeleton = ({ pages }) => {
6 const [currentIndex, setCurrentIndex] = useState(0);
7
8 useEffect(() => {
9 const timer = setTimeout(() => {
10 setCurrentIndex((prevIndex) => (prevIndex + 1) % pages.length);
11 }, 10000);
12 return () => clearTimeout(timer);
13 }, [pages.length, currentIndex]);
14
15 return (
16 <div className="mt-3">
17 <PageSkeleton pageName={pages[currentIndex]} />
18 </div>
19 );
20 };
21
22 const PageSkeleton = ({ pageName }) => {
23 const [isLightBg, setIsLightBg] = useState(false);
24 const [show, setShow] = useState(false);
25 const [title, setTitle] = useState('');
26
27 useLayoutEffect(() => {
28 const documentStyles = window.getComputedStyle(document.body);
29 const bannerMain = documentStyles.getPropertyValue('--ext-banner-main');
30 setIsLightBg(colord(bannerMain).isLight());
31 }, []);
32
33 useEffect(() => {
34 setShow(false);
35 const timer = setTimeout(() => {
36 setShow(true);
37 setTitle(pageName);
38 }, 700);
39 return () => clearTimeout(timer);
40 }, [pageName]);
41
42 return (
43 <AnimatePresence>
44 {show ? (
45 <motion.div
46 initial={{ opacity: 0, x: 50 }}
47 animate={{ opacity: 1, x: 0, transition: { duration: 0.6 } }}
48 exit={{ opacity: 0, x: -50 }}
49 transition={{ ease: 'easeInOut' }}
50 className="mt-12 w-96 rounded-sm border-8 border-[rgba(204,204,204,0.45)] p-4"
51 >
52 <h1 className="mb-8 text-banner-text opacity-50">{title}</h1>
53 <div
54 className="space-y-6"
55 style={{
56 mixBlendMode: isLightBg ? 'difference' : 'plus-lighter',
57 }}
58 >
59 {[0, 1, 2].map((item) => {
60 const delay = 3 * item;
61 return (
62 <motion.div
63 aria-hidden="true"
64 key={item}
65 initial={{ opacity: 0 }}
66 animate={{ opacity: 1 }}
67 transition={item ? { duration: delay / 2, delay } : {}}
68 role="status"
69 className="max-w-sm space-y-2"
70 >
71 <Piece i={item * delay} className="mb-3 h-3 w-48" />
72 <Piece i={item * delay} className="h-2 w-full" />
73 <Piece i={item * delay} className="h-2 w-full max-w-[90%]" />
74 <Piece i={item * delay} className="h-2 w-full" />
75 <Piece i={item * delay} className="h-2 w-full" />
76 </motion.div>
77 );
78 })}
79 </div>
80 </motion.div>
81 ) : null}
82 </AnimatePresence>
83 );
84 };
85
86 const Piece = ({ className, i }) => (
87 <div
88 className={`rounded-full ${className}`}
89 style={{
90 backgroundColor: 'rgba(204, 204, 204, 0.25)',
91 backgroundImage:
92 'linear-gradient(90deg, rgba(255,255,255,0) 0%, rgba(255,255,255,0.5) 50%, rgba(255,255,255,0) 100%)',
93 backgroundSize: '600% 600%',
94 animation: 'extendify-loading-skeleton 10s ease-in-out infinite',
95 animationDelay: `${i}s`,
96 mixBlendMode: 'plus-lighter',
97 }}
98 />
99 );
100