File tree Expand file tree Collapse file tree 2 files changed +27
-3
lines changed
src/plays/password-generator Expand file tree Collapse file tree 2 files changed +27
-3
lines changed Original file line number Diff line number Diff line change @@ -72,7 +72,11 @@ function PasswordGenerator(props) {
7272 const onCopyClick = ( e ) => {
7373 e . preventDefault ( ) ;
7474 navigator . clipboard . writeText ( password . password ) ;
75- setPassword ( { ...password , status : true } ) ;
75+ setPassword ( ( prev ) => ( { ...prev , status : true } ) ) ;
76+
77+ setTimeout ( ( ) => {
78+ setPassword ( ( prev ) => ( { ...prev , status : false } ) ) ;
79+ } , 1500 ) ;
7680 } ;
7781
7882 const ErrorBox = ( ) => {
@@ -109,8 +113,14 @@ function PasswordGenerator(props) {
109113 < h1 className = "title" > Password Generator</ h1 >
110114 { error && < ErrorBox /> }
111115 < div className = "inputfield" >
112- < input disabled readOnly className = "text" type = "text" value = { password . password } />
113- < button className = "copy copybtn" onClick = { onCopyClick } >
116+ < input
117+ disabled
118+ readOnly
119+ className = { `text ${ password . status ? 'copied' : '' } ` }
120+ type = "text"
121+ value = { password . password }
122+ />
123+ < button className = "copy copybtn" disabled = { password . status } onClick = { onCopyClick } >
114124 { password ?. status ? 'Copied' : 'Copy' }
115125 </ button >
116126 </ div >
Original file line number Diff line number Diff line change 4848 padding : 0.6em 1em ;
4949 border-radius : 0.7em ;
5050 text-transform : uppercase;
51+ min-width : 100px ;
52+ text-align : center;
53+ }
54+
55+ .password-generator .main .inputfield .text .copied {
56+ background-color : # b3daff ;
57+ border-radius : 0.4em ;
58+ transition : background-color 0.3s ease;
59+ }
60+
61+ .password-generator .main .inputfield .copybtn : disabled {
62+ opacity : 0.55 ;
63+ background-color : # 18c0f4 ;
64+ cursor : not-allowed;
5165}
5266
5367.password-generator .main .block {
You can’t perform that action at this time.
0 commit comments