PluginProbe
Extendify / 1.6.1
Extendify v1.6.1
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 / Chat / components / dialog / Question.js

Question.js in Extendify 1.6.1, at src/Chat/components/dialog/Question.js

60 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { useEffect, useRef, useState } from '@wordpress/element'
2 import { __ } from '@wordpress/i18n'
3 import { Icon } from '@wordpress/icons'
4 import { send } from '@chat/svg'
5 import classnames from 'classnames'
6
7 export const Question = ({ setQuestion }) => {
8 const queryInput = useRef(null)
9 const [inputValue, setInputValue] = useState('')
10
11 const submit = (e) => {
12 e.preventDefault()
13
14 if (!inputValue) {
15 return
16 }
17
18 setQuestion(inputValue)
19 }
20
21 useEffect(() => {
22 // Focus the input when the component mounts
23 queryInput.current.focus()
24 }, [])
25
26 return (
27 <form onSubmit={submit} className="py-20">
28 <p className="text-lg font-medium m-0 mb-1 opacity-80">
29 {__('Hi there!', 'extendify')}
30 </p>
31 <p className="text-2xl font-medium m-0 mb-6">
32 {__('Ask me any questions about WordPress.', 'extendify')}
33 </p>
34 <div className="relative">
35 <input
36 type="text"
37 className="w-full py-4 pl-3 pr-10 placeholder-gray-600 rounded border shadow border-gray-300 bg-white outline-none disabled:border-gray-300 disabled:cursor-default"
38 placeholder={__(
39 'Ask your WordPress question…',
40 'extendify',
41 )}
42 value={inputValue}
43 maxLength={255}
44 onChange={(e) => setInputValue(e.target.value)}
45 ref={queryInput}
46 />
47 <button
48 type="submit"
49 className={classnames(
50 'absolute top-0 right-1.5 h-full bg-transparent border-none fill-current flex items-center cursor-pointer text-gray-700 hover:text-gray-900',
51 )}
52 disabled={!inputValue}>
53 <Icon icon={send} className="w-4 h-4" />
54 </button>
55 </div>
56 <input type="submit" className="hidden" />
57 </form>
58 )
59 }
60