blob: c02c2246b049427757842092eba80a37d9b37f86 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
import { ButtonSubmit } from '@components/Buttons';
import { Form, Input } from '@components/Form';
import { t } from '@lingui/macro';
import { FormEvent, useEffect, useRef, useState } from 'react';
const SearchForm = ({ isOpened }: { isOpened: boolean }) => {
const [query, setQuery] = useState('');
const inputRef = useRef<HTMLInputElement>(null);
useEffect(() => {
setTimeout(() => {
if (inputRef.current) {
inputRef.current.focus();
}
}, 800);
}, [isOpened]);
const launchSearch = (e: FormEvent) => {
e.preventDefault();
};
return (
<Form submitHandler={launchSearch} modifier="search">
<Input
ref={inputRef}
id="search-query"
name="search-query"
type="search"
value={query}
setValue={setQuery}
/>
<ButtonSubmit>{t`Search`}</ButtonSubmit>
</Form>
);
};
export default SearchForm;
|