Skip to content

Commit 2c84534

Browse files
massahoudoumassahoudou
authored andcommitted
remove console.log && formated the code with prettier
1 parent ab77bfd commit 2c84534

File tree

1 file changed

+33
-27
lines changed

1 file changed

+33
-27
lines changed

components/Hero.tsx

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,17 @@ function Hero() {
1515
const formRef = useRef<HTMLFormElement | null>(null);
1616
const router = useRouter();
1717
const handleClear: MouseEventHandler<HTMLButtonElement> = () => {
18-
if (formRef.current && !isSearchEmpty ) {
19-
18+
if (formRef.current && !isSearchEmpty) {
2019
formRef.current.reset();
2120
setErrorMessage(null);
2221
}
23-
24-
}
22+
};
2523
const handleSubmit: FormEventHandler = e => {
2624
e.preventDefault();
2725
const formData = new FormData(e.target as HTMLFormElement);
2826
const search = (formData.get('search') as string).trim();
2927
// Check if the input is empty or contains only spaces
3028
if (search === '') {
31-
3229
setErrorMessage('Empty search terms invalid!');
3330
return;
3431
}
@@ -44,37 +41,37 @@ function Hero() {
4441
<h1 className="mb-5 text-2023-manga-3 text-5xl font-bold uppercase">
4542
Search your language
4643
</h1>
47-
<form ref={formRef}
44+
<form
45+
ref={formRef}
4846
className="form-control w-full max-w-xs mx-auto items-center mt-10 mb-12"
4947
onSubmit={handleSubmit}
5048
>
5149
<div className="flex w-full">
52-
<div className='flex relative'>
50+
<div className="flex relative">
5351
<input
5452
type="text"
5553
placeholder="Search for your language"
5654
className="input input-bordered w-full text-neutral-100 border-2023-bavarian-gold-2 focus:outline-2023-bavarian-gold-2 max-w-xs rounded-tr-none rounded-br-none bg-transparent"
5755
name="search"
58-
onChange={
59-
(e) => {
60-
setIsSearchEmpty(e.target.value.trim() === '') ;
61-
console.log(e.target.value.trim(),e.target.value.trim() === '' );
62-
}
63-
}
56+
onChange={e => {
57+
setIsSearchEmpty(e.target.value.trim() === '');
58+
}}
6459
/>
6560

66-
{!isSearchEmpty &&
67-
<button onClick={handleClear} className='absolute right-0 top-0 bottom-0 p-2'>
68-
<ClearIcon />
69-
</button>}
70-
61+
{!isSearchEmpty && (
62+
<button
63+
onClick={handleClear}
64+
className="absolute right-0 top-0 bottom-0 p-2"
65+
>
66+
<ClearIcon />
67+
</button>
68+
)}
7169
</div>
7270
<button
7371
type="submit"
7472
className="group btn btn-square rounded-tl-none rounded-bl-none bg-transparent border-2023-manga-3 hover:bg-2023-manga-2 hover:text-2023-void-2 hover:border-2023-manga-2"
7573
>
7674
<SearchIcon />
77-
7875
</button>
7976
</div>
8077
</form>
@@ -133,13 +130,22 @@ const SearchIcon = () => (
133130
</svg>
134131
);
135132
const ClearIcon = () => {
136-
return <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" strokeWidth={1.5} stroke="currentColor" className="w-4 h-4 text-white ">
137-
<path strokeLinecap="round" strokeLinejoin="round" d="M6 18L18 6M6 6l12 12" />
138-
</svg>
139-
140-
141-
}
133+
return (
134+
<svg
135+
xmlns="http://www.w3.org/2000/svg"
136+
fill="none"
137+
viewBox="0 0 24 24"
138+
strokeWidth={1.5}
139+
stroke="currentColor"
140+
className="w-4 h-4 text-white "
141+
>
142+
<path
143+
strokeLinecap="round"
144+
strokeLinejoin="round"
145+
d="M6 18L18 6M6 6l12 12"
146+
/>
147+
</svg>
148+
);
149+
};
142150

143151
export default Hero;
144-
145-

0 commit comments

Comments
 (0)