PluginProbe
Extendify / 1.9.3
Extendify v1.9.3
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 0.7.0 All 126 releases
extendify / src / Chat / Chat.js

Chat.js in Extendify 1.9.3, at src/Chat/Chat.js

55 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { createSlotFill } from '@wordpress/components'
2 import { useEffect, useState } from '@wordpress/element'
3 import { registerPlugin, unregisterPlugin } from '@wordpress/plugins'
4 import { ChatSettings } from '@chat/ChatSettings'
5 import { ChatButton } from '@chat/components/ChatButton'
6 import { ChatDialog } from '@chat/components/ChatDialog'
7 import { motion, AnimatePresence } from 'framer-motion'
8
9 export const Chat = () => {
10 const [showChat, setShowChat] = useState(window.extChatData?.showChat)
11 const [showDialog, setShowDialog] = useState(false)
12
13 useEffect(() => {
14 const { Fill } = createSlotFill('Extendify/Assist/Settings')
15 registerPlugin('extendify-chat-settings', {
16 render: () => (
17 <Fill>
18 <ChatSettings
19 showChat={showChat}
20 setShowChat={setShowChat}
21 />
22 </Fill>
23 ),
24 })
25 return () => unregisterPlugin('extendify-chat-settings')
26 }, [showChat])
27
28 if (!showChat) return null
29
30 return (
31 <>
32 <ChatButton
33 showDialog={showDialog}
34 onClick={() => setShowDialog(!showDialog)}
35 />
36 <AnimatePresence>
37 {showDialog && (
38 <motion.div
39 key="chat-dialog"
40 className="fixed bottom-0 right-0 z-high"
41 initial={{ y: 15, opacity: 0 }}
42 exit={{ y: 15, opacity: 0 }}
43 transition={{
44 y: { duration: 0.25 },
45 opacity: { duration: 0.1 },
46 }}
47 animate={{ y: 0, opacity: 1 }}>
48 <ChatDialog setShowChat={setShowChat} />
49 </motion.div>
50 )}
51 </AnimatePresence>
52 </>
53 )
54 }
55