@@ -15,20 +15,17 @@ function Hero() {
15
15
const formRef = useRef < HTMLFormElement | null > ( null ) ;
16
16
const router = useRouter ( ) ;
17
17
const handleClear : MouseEventHandler < HTMLButtonElement > = ( ) => {
18
- if ( formRef . current && ! isSearchEmpty ) {
19
-
18
+ if ( formRef . current && ! isSearchEmpty ) {
20
19
formRef . current . reset ( ) ;
21
20
setErrorMessage ( null ) ;
22
21
}
23
-
24
- }
22
+ } ;
25
23
const handleSubmit : FormEventHandler = e => {
26
24
e . preventDefault ( ) ;
27
25
const formData = new FormData ( e . target as HTMLFormElement ) ;
28
26
const search = ( formData . get ( 'search' ) as string ) . trim ( ) ;
29
27
// Check if the input is empty or contains only spaces
30
28
if ( search === '' ) {
31
-
32
29
setErrorMessage ( 'Empty search terms invalid!' ) ;
33
30
return ;
34
31
}
@@ -44,37 +41,37 @@ function Hero() {
44
41
< h1 className = "mb-5 text-2023-manga-3 text-5xl font-bold uppercase" >
45
42
Search your language
46
43
</ h1 >
47
- < form ref = { formRef }
44
+ < form
45
+ ref = { formRef }
48
46
className = "form-control w-full max-w-xs mx-auto items-center mt-10 mb-12"
49
47
onSubmit = { handleSubmit }
50
48
>
51
49
< div className = "flex w-full" >
52
- < div className = ' flex relative' >
50
+ < div className = " flex relative" >
53
51
< input
54
52
type = "text"
55
53
placeholder = "Search for your language"
56
54
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"
57
55
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
+ } }
64
59
/>
65
60
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
+ ) }
71
69
</ div >
72
70
< button
73
71
type = "submit"
74
72
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"
75
73
>
76
74
< SearchIcon />
77
-
78
75
</ button >
79
76
</ div >
80
77
</ form >
@@ -133,13 +130,22 @@ const SearchIcon = () => (
133
130
</ svg >
134
131
) ;
135
132
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
+ } ;
142
150
143
151
export default Hero ;
144
-
145
-
0 commit comments