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 / AdminBar.jsx

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

50 lines 1.6 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 { Icon } from '@wordpress/components';
4 import { __ } from '@wordpress/i18n';
5 import classNames from 'classnames';
6 import { motion } from 'framer-motion';
7
8 // TODO: this isnt great if we allow the user to "pop out" the sidebar
9 const isSidebarDocked = window.extAgentData.agentPosition !== 'floating';
10
11 export const AdminBar = () => {
12 const { toggleOpen, open, isMobile } = useGlobalStore();
13
14 if (isMobile) return null;
15
16 return (
17 <motion.button
18 type="button"
19 initial={false}
20 animate={{
21 width: isSidebarDocked ? (open ? 0 : 'auto') : 'auto',
22 opacity: isSidebarDocked ? (open ? 0 : 100) : 100,
23 }}
24 transition={{
25 width: { duration: 0.3, ease: 'easeInOut' },
26 opacity: { duration: 0.1, ease: 'easeInOut' },
27 }}
28 className={classNames(
29 'items-center justify-center gap-0.5 h-full border-0 leading-extra-tight text-white md:inline-flex whitespace-nowrap hover:opacity-80',
30 { 'opacity-60': open && !isSidebarDocked },
31 // Open, docked sidebar (keeps the spacing)
32 { 'mr-1 rtl:ml-1 rtl:mr-0': open && isSidebarDocked },
33 {
34 // Styles for when docked sidebar is open
35 // Useful to put things here you don't want to animate out
36 'py-0.5 px-1.5 bg-design-main text-design-text':
37 !isSidebarDocked || (isSidebarDocked && !open),
38 },
39 )}
40 onClick={() => toggleOpen()}
41 aria-label={__('Open Agent', 'extendify-local')}
42 >
43 <Icon className="shrink-0" icon={magic} width={20} height={20} />
44 <span className="px-1 leading-none">
45 {__('AI Agent', 'extendify-local')}
46 </span>
47 </motion.button>
48 );
49 };
50