blob: fa0962a0cb6de7946feedbe4d1ad5f67a2d2445b (
plain) (
blame)
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
|
"use client";
import { FaSearch } from "react-icons/fa";
import styles from "./manga.module.css";
import { useState } from "react";
import { useRouter } from "next/navigation";
export default function SearchBar() {
const router = useRouter();
const [title, setMangaTitle] = useState("");
return (
<div className={styles.SearchBar}>
<FaSearch color="white" style={{ marginLeft: 5 }} />
<input
type="text"
name="manga"
placeholder="Enter manga title"
autoComplete="off"
onChange={(e) => setMangaTitle(e.target.value)}
onKeyDown={(event) => {
if (
(event.key === "Enter" ||
event.code === 13 ||
event.code === "Enter") &&
title !== ""
) {
router.push(`/manga/${title}`);
}
}}
></input>
</div>
);
}
|