PluginProbe
Extendify / 3.0.5
Extendify v3.0.5
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 / AutoLaunch / components / ViewportPulse.jsx

ViewportPulse.jsx in Extendify 3.0.5, at src/AutoLaunch/components/ViewportPulse.jsx

52 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { useMemo } from '@wordpress/element';
2 import { colord } from 'colord';
3 import { motion, useReducedMotion } from 'framer-motion';
4
5 export const ViewportPulse = () => {
6 const shouldReduceMotion = useReducedMotion();
7 const bannerMain = useMemo(() => {
8 return getComputedStyle(document.documentElement)
9 .getPropertyValue('--ext-banner-main')
10 .trim();
11 }, []);
12
13 const bannerMainWashed = useMemo(() => {
14 return colord(bannerMain)
15 .desaturate(0.3)
16 .lighten(0.4)
17 .alpha(0.2)
18 .toRgbString();
19 }, [bannerMain]);
20
21 const isLight = useMemo(() => colord(bannerMain).isLight(), [bannerMain]);
22
23 const designMain = useMemo(() => {
24 return getComputedStyle(document.documentElement)
25 .getPropertyValue('--ext-design-main')
26 .trim();
27 }, []);
28
29 const mainColorLike = useMemo(() => {
30 return colord(designMain).desaturate(0.3).alpha(0.2).toRgbString();
31 }, [designMain]);
32
33 if (shouldReduceMotion) return null;
34
35 const colorToUse = isLight ? mainColorLike : bannerMainWashed;
36 return (
37 <motion.div
38 className="absolute inset-0"
39 style={{
40 background: `radial-gradient(ellipse at center, transparent 70%, ${colorToUse} 100%)`,
41 }}
42 animate={{ opacity: [0, 1, 0] }}
43 transition={{
44 duration: 2.5,
45 repeatDelay: 4,
46 repeat: Infinity,
47 ease: 'linear',
48 }}
49 />
50 );
51 };
52