PluginProbe
Extendify / 3.1.0
Extendify v3.1.0
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 / Mobile.jsx

Mobile.jsx in Extendify 3.1.0, at src/Agent/components/buttons/Mobile.jsx

57 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { magic } from '@agent/icons';
2 import { useGlobalStore } from '@agent/state/global';
3 import { useEffect, useRef } from '@wordpress/element';
4 import { __ } from '@wordpress/i18n';
5 import { chevronUp, Icon } from '@wordpress/icons';
6
7 export const Mobile = () => {
8 const { isMobile, minimized, setMinimized } = useGlobalStore();
9 const ref = useRef(null);
10
11 const minimize = () => setMinimized(false);
12
13 useEffect(() => {
14 if (!isMobile || minimized) return;
15 // Set button height as root var
16 document.body.style.setProperty(
17 '--extendify-agent-mobile-btn-height',
18 `${ref.current?.offsetHeight}px`,
19 );
20 }, [isMobile, minimized]);
21
22 useEffect(() => {
23 if (!isMobile) return;
24 document.body.classList.add('extendify-agent-mobile-btn-open');
25 return () => {
26 document.body.classList.remove('extendify-agent-mobile-btn-open');
27 };
28 }, [isMobile]);
29
30 if (!isMobile || !minimized) return null;
31
32 return (
33 <button
34 ref={ref}
35 type="button"
36 className="m-0 flex w-full items-center justify-between gap-2 bg-gray-900 px-4 py-3 font-sans text-white shadow-[0_-1px_0_0_rgba(255,255,255,0.05)]"
37 onClick={minimize}
38 aria-label={__('Open Agent', 'extendify-local')}
39 >
40 <div className="flex gap-3">
41 <div className="flex h-10 w-10 items-center justify-center rounded-full bg-[#3858e9]">
42 <Icon icon={magic} size={24} />
43 </div>
44 <div className="text-left text-sm rtl:text-right">
45 <div className="font-semibold">
46 {__('AI Agent', 'extendify-local')}
47 </div>
48 <div className="text-gray-600">
49 {__('How can we help you today?', 'extendify-local')}
50 </div>
51 </div>
52 </div>
53 <Icon className="fill-white" icon={chevronUp} size={24} />
54 </button>
55 );
56 };
57