@@ -7,6 +7,7 @@ const Base64 = () => {
7
7
const [ string , setString ] = useState ( true ) ;
8
8
const [ output , setOutput ] = useState ( btoa ( 'Raw data' ) ) ;
9
9
const [ opening , setOpening ] = useState ( false ) ;
10
+ const [ copied , setCopied ] = useState ( false ) ;
10
11
11
12
const handleChangeInput = ( evt : { target : { value : string } } ) =>
12
13
setInput ( evt . target . value ) ;
@@ -27,7 +28,9 @@ const Base64 = () => {
27
28
} ;
28
29
29
30
const handleCopyOutput = ( ) => {
31
+ setCopied ( true ) ;
30
32
clipboard . write ( { text : output } ) ;
33
+ setTimeout ( ( ) => setCopied ( false ) , 500 ) ;
31
34
} ;
32
35
33
36
useEffect ( ( ) => {
@@ -57,8 +60,8 @@ const Base64 = () => {
57
60
>
58
61
Open...
59
62
</ button >
60
- < div className = "flex space-x-4 items-center" >
61
- < label htmlFor = "string" className = "flex items-center space-x-2 " >
63
+ < div className = "flex space-x-2 items-center" >
64
+ < label htmlFor = "string" className = "flex items-center space-x-1 " >
62
65
< input
63
66
type = "radio"
64
67
className = "btn"
@@ -69,7 +72,7 @@ const Base64 = () => {
69
72
/>
70
73
< p > Text</ p >
71
74
</ label >
72
- < label htmlFor = "raw" className = "flex items-center space-x-2 " >
75
+ < label htmlFor = "raw" className = "flex items-center space-x-1 " >
73
76
< input
74
77
type = "radio"
75
78
className = "btn"
@@ -84,7 +87,7 @@ const Base64 = () => {
84
87
</ span >
85
88
< span className = "flex space-x-4" >
86
89
< div className = "flex space-x-4 items-center" >
87
- < label htmlFor = "encoder" className = "flex items-center space-x-2 " >
90
+ < label htmlFor = "encoder" className = "flex items-center space-x-1 " >
88
91
< input
89
92
type = "radio"
90
93
className = "btn"
@@ -95,7 +98,7 @@ const Base64 = () => {
95
98
/>
96
99
< p > Encode</ p >
97
100
</ label >
98
- < label htmlFor = "decoder" className = "flex items-center space-x-2 " >
101
+ < label htmlFor = "decoder" className = "flex items-center space-x-1 " >
99
102
< input
100
103
type = "radio"
101
104
className = "btn"
@@ -107,8 +110,13 @@ const Base64 = () => {
107
110
< p > Decode</ p >
108
111
</ label >
109
112
</ div >
110
- < button type = "button" className = "btn" onClick = { handleCopyOutput } >
111
- Copy
113
+ < button
114
+ type = "button"
115
+ className = "btn"
116
+ onClick = { handleCopyOutput }
117
+ disabled = { copied }
118
+ >
119
+ { copied ? 'Copied' : 'Copy' }
112
120
</ button >
113
121
</ span >
114
122
</ div >
0 commit comments