File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change
1
+ import { useState } from "react" ;
1
2
import { Form } from "remix" ;
2
3
3
4
export type UrlFormProps = {
4
5
className ?: string ;
5
6
} ;
6
7
7
8
export function UrlForm ( { className } : UrlFormProps ) {
9
+ const [ inputValue , setInputValue ] = useState ( "" ) ;
10
+
11
+ const isButtonDisabled = ! inputValue . length ;
12
+
8
13
return (
9
14
< Form
10
15
method = "post"
@@ -18,11 +23,16 @@ export function UrlForm({ className }: UrlFormProps) {
18
23
id = "jsonUrl"
19
24
className = "block flex-grow text-base text-slate-200 placeholder:text-slate-300 bg-slate-900/40 border border-slate-600 rounded-l-sm py-2 px-3 transition duration-300 focus:ring-indigo-500 focus:border-indigo-500"
20
25
placeholder = "Enter a JSON URL or paste in JSON here..."
26
+ value = { inputValue }
27
+ onChange = { ( event ) => setInputValue ( event . target . value ) }
21
28
/>
22
29
< button
23
30
type = "submit"
24
31
value = "Go"
25
- className = "inline-flex items-center justify-center px-4 py-2 border border-transparent font-medium rounded-r-sm text-white bg-lime-500 transition hover:bg-lime-600 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-lime-500"
32
+ className = { `inline-flex items-center justify-center px-4 py-2 border border-transparent font-medium rounded-r-sm text-white bg-lime-500 transition hover:bg-lime-600 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-lime-500 ${
33
+ isButtonDisabled && "disabled:opacity-50 disabled:hover:bg-lime-500"
34
+ } `}
35
+ disabled = { isButtonDisabled }
26
36
>
27
37
Go
28
38
</ button >
You can’t perform that action at this time.
0 commit comments