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 / HelpCenter / components / ai-chat / Question.jsx

Question.jsx in Extendify 3.0.4, at src/HelpCenter/components/ai-chat/Question.jsx

48 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { DynamicTextarea } from '@help-center/components/ai-chat/DynamicTextarea';
2 import { send } from '@help-center/components/ai-chat/icons';
3 import { useRef, useState } from '@wordpress/element';
4 import { __ } from '@wordpress/i18n';
5 import { Icon } from '@wordpress/icons';
6
7 export const Question = ({ onSubmit }) => {
8 const [inputValue, setInputValue] = useState('');
9 const formRef = useRef(null);
10
11 const handleInputChange = (e) => {
12 setInputValue(e.target.value);
13 };
14
15 const handleKeyDown = (e) => {
16 if (e.key === 'Enter' && !e.shiftKey) {
17 formRef?.current?.requestSubmit();
18 }
19 };
20
21 return (
22 <form onSubmit={onSubmit} ref={formRef} className="rtl:w-full">
23 <p className="m-0 mb-1 text-lg font-medium opacity-80">
24 {__('Hi there!', 'extendify-local')}
25 </p>
26 <p className="m-0 mb-6 text-2xl font-medium">
27 {__('Ask me any questions about WordPress.', 'extendify-local')}
28 </p>
29 <div className="relative rounded-sm border border-gray-300 bg-white shadow">
30 <DynamicTextarea
31 value={inputValue}
32 className="rtl:pl-auto h-full w-full flex-1 resize-none py-4 pl-3 pr-10 placeholder-gray-600 rtl:py-2.5 rtl:pr-2"
33 placeholder={__('Ask your WordPress question…', 'extendify-local')}
34 onChange={handleInputChange}
35 onKeyDown={handleKeyDown}
36 />
37 <button
38 type="submit"
39 className="absolute bottom-3.5 right-2.5 flex h-6 items-center border-none bg-transparent fill-current text-gray-700 hover:text-gray-900 rtl:bottom-2 rtl:left-2.5 rtl:right-auto"
40 disabled={!inputValue}
41 >
42 <Icon icon={send} className="h-4 w-4" />
43 </button>
44 </div>
45 </form>
46 );
47 };
48