aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/SearchForm
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/SearchForm')
-rw-r--r--src/components/SearchForm/SearchForm.tsx37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/components/SearchForm/SearchForm.tsx b/src/components/SearchForm/SearchForm.tsx
new file mode 100644
index 0000000..c02c224
--- /dev/null
+++ b/src/components/SearchForm/SearchForm.tsx
@@ -0,0 +1,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;