File tree Expand file tree Collapse file tree 3 files changed +56
-1
lines changed
BulbOnOffButton/LakshyaMalik Expand file tree Collapse file tree 3 files changed +56
-1
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,14 @@ <h1>Toggle the given Button to turn the bulb On or Off</h1>
1414 < div class ="container ">
1515 < img src ="./assets/Bulb-off2.png " alt ="Bulb is turned On " id ="bulbimg ">
1616 < button title ="press to toggle " onclick ="ToggleBulb() " class ="btn "> < img src ="./assets/switch-button.svg " alt ="On/off "> </ button >
17+
1718 </ div >
19+ < div id ="dialogueBox " class ="dialogue-box " style ="display:none; ">
20+ < p > Don't forget to turn it off before leaving</ p >
21+ < button class ="ok-button " onclick ="closeDialogue() "> Ok</ button >
22+ </ div >
23+
24+
1825
1926 < script src ="./script.js "> </ script >
2027</ body >
Original file line number Diff line number Diff line change @@ -6,9 +6,26 @@ const ToggleBulb = () =>{
66 if ( Bulb . src . match ( './assets/Bulb-on2.png' ) ) {
77 Bulb . setAttribute ( 'src' , './assets/Bulb-off2.png' ) ;
88 console . log ( 'dfghjkl' ) ;
9+ closeDialogue ( ) ;
910 }
1011
1112 else {
1213 Bulb . setAttribute ( 'src' , './assets/Bulb-on2.png' ) ;
14+ openDialogue ( ) ;
1315 }
16+ }
17+ const openDialogue = ( ) => {
18+ document . getElementById ( "dialogueBox" ) ;
19+ dialogueBox . style . display = "inline-grid" ;
20+ dialogueBox . style . position = "fixed" ; // Use absolute if you want it relative to a positioned ancestor
21+ dialogueBox . style . top = "60%" ;
22+ dialogueBox . style . left = "56%" ;
23+
24+
25+ }
26+
27+
28+
29+ const closeDialogue = ( ) => {
30+ document . getElementById ( "dialogueBox" ) . style . display = "none" ;
1431}
Original file line number Diff line number Diff line change 44}
55
66.bg {
7- background-color : # 070707 ;
7+ background-color : # 8c8686 ;
88}
99
1010.container {
5252 justify-self : auto;
5353 margin : 0 ;
5454 }
55+ .dialogue-box {
56+
57+ margin-left : 600px ;
58+ background-color : white;
59+ padding : 20px ;
60+ border-radius : 10px ;
61+ box-shadow : 0 0 10px rgba (0 , 0 , 0 , 0.3 );
62+ z-index : 1000 ;
63+
64+
65+ }
66+
67+ .dialogue-box p {
68+
69+ margin-bottom : 10px ;
70+ }
71+
72+
73+ .ok-button {
74+ width : 200px ;
75+ padding : 5px 10px ;
76+ background-color : # 4CAF50 ;
77+ color : white;
78+ border : # 8c8686 ;
79+ border-radius : 3px ;
80+ cursor : pointer;
81+ margin-top : 10px ; /* Add some space between the paragraph and the button */
82+ margin-left : 600px ;
83+ }
84+
85+
5586
5687 # bulbimg {
5788 width : 100% ;
You can’t perform that action at this time.
0 commit comments