48 lines
1.4 KiB
TypeScript
48 lines
1.4 KiB
TypeScript
import { ArrowRight } from "lucide-react";
|
|
import React, { useState } from "react";
|
|
|
|
interface SearchBarProps {
|
|
placeholder?: string;
|
|
onSearch: (value: string) => void;
|
|
width?: string;
|
|
className?: string;
|
|
}
|
|
|
|
export default function SearchBar({
|
|
placeholder = "Rechercher",
|
|
onSearch,
|
|
width = "w-full md:w-[600px]",
|
|
className = "",
|
|
}: Readonly<SearchBarProps>) {
|
|
const [value, setValue] = useState("");
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
const handleSubmit: React.FormEventHandler<HTMLFormElement> = (e) => {
|
|
e.preventDefault();
|
|
onSearch(value);
|
|
};
|
|
|
|
return (
|
|
<form
|
|
onSubmit={handleSubmit}
|
|
className={`flex h-14 items-center justify-between gap-4 rounded-full border-4 border-bleu bg-white pl-8 pr-8 ${width} ${className}`}
|
|
>
|
|
<input
|
|
type="text"
|
|
value={value}
|
|
onChange={(e) => {
|
|
setValue(e.target.value);
|
|
}}
|
|
placeholder={placeholder}
|
|
className="w-full border-none bg-transparent font-poppins-bold text-cta text-bleu outline-none placeholder:text-bleu/40 focus:ring-0"
|
|
/>
|
|
<button
|
|
type="submit"
|
|
aria-label="Lancer la recherche"
|
|
className="flex shrink-0 items-center justify-center text-bleu transition-opacity hover:opacity-70 cursor-pointer"
|
|
>
|
|
<ArrowRight size={27} strokeWidth={2.5} />
|
|
</button>
|
|
</form>
|
|
);
|
|
}
|