PluginProbe
Extendify / 3.0.4
Extendify v3.0.4
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 / Agent / components / buttons / PostEditor.jsx

PostEditor.jsx in Extendify 3.0.4, at src/Agent/components/buttons/PostEditor.jsx

59 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { magic, magicAnimated } from '@agent/icons';
2 import { useGlobalStore } from '@agent/state/global';
3 import { Button } from '@wordpress/components';
4 import { useEffect, useRef, useState } from '@wordpress/element';
5 import { __ } from '@wordpress/i18n';
6 import classNames from 'classnames';
7
8 export const PostEditor = () => {
9 const { toggleOpen, open, isMobile } = useGlobalStore();
10 const [animate, setAnimate] = useState(false);
11 const [animateIcon, setAnimateIcon] = useState(false);
12 const pageLoaded = useRef(false);
13
14 useEffect(() => {
15 // Don't run this on the first page load
16 if (!pageLoaded.current) {
17 pageLoaded.current = true;
18 return;
19 }
20 if (open || isMobile) return;
21 setAnimate(true);
22 setAnimateIcon(true);
23 const id = setTimeout(() => {
24 setAnimate(false);
25 }, 1500);
26 const iconId = setTimeout(() => {
27 setAnimateIcon(false);
28 }, 5000);
29 return () => {
30 clearTimeout(id);
31 clearTimeout(iconId);
32 };
33 }, [open, isMobile]);
34
35 if (isMobile) return null;
36
37 return (
38 <Button
39 variant="primary"
40 icon={animateIcon ? magicAnimated : magic}
41 iconPosition="left"
42 className="is-compact has-text relative z-10"
43 onClick={() => {
44 if (open) setAnimate(true);
45 toggleOpen();
46 }}
47 aria-label={__('Open Agent', 'extendify-local')}
48 >
49 <span
50 className={classNames('px-1 leading-none', {
51 'extendify-gradient-animation': animate,
52 })}
53 >
54 {__('AI Agent', 'extendify-local')}
55 </span>
56 </Button>
57 );
58 };
59