File tree 3 files changed +21
-2
lines changed
3 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,14 @@ const randomFunctions = {
31
31
symbol : getRandomSymbol ,
32
32
} ;
33
33
34
+ const createNotification = ( message ) => {
35
+ const notif = document . createElement ( "div" ) ;
36
+ notif . classList . add ( "toast" ) ;
37
+ notif . innerText = message ;
38
+ document . body . appendChild ( notif ) ;
39
+ setTimeout ( ( ) => notif . remove ( ) , 3000 ) ;
40
+ } ;
41
+
34
42
clipboardElement . addEventListener ( "click" , ( ) => {
35
43
const password = resultElement . innerText ;
36
44
if ( ! password ) return ;
@@ -40,7 +48,7 @@ clipboardElement.addEventListener("click", () => {
40
48
textarea . select ( ) ;
41
49
document . execCommand ( "copy" ) ;
42
50
textarea . remove ( ) ;
43
- alert ( "Password copied to clipboard!" ) ;
51
+ createNotification ( "Password copied to clipboard!" ) ;
44
52
} ) ;
45
53
46
54
generateElement . addEventListener ( "click" , ( ) => {
Original file line number Diff line number Diff line change 78
78
align-items : center;
79
79
margin : 15px 0 ;
80
80
}
81
+
82
+ .toast {
83
+ position : fixed;
84
+ bottom : 10px ;
85
+ right : 10px ;
86
+ background-color : # fff ;
87
+ color : # 3b3b98 ;
88
+ border-radius : 5px ;
89
+ padding : 1rem 2rem ;
90
+ margin : 0.5rem ;
91
+ }
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ function searchMeal(e) {
34
34
} ) ;
35
35
search . value = "" ;
36
36
} else {
37
- alert ( "Please enter a search term" ) ;
37
+ getRandomMeal ( ) ;
38
38
}
39
39
}
40
40
You can’t perform that action at this time.
0 commit comments