Skip to content

Commit b9cf104

Browse files
committed
Add content to display message on-click
1 parent a72f1ce commit b9cf104

File tree

3 files changed

+56
-1
lines changed

3 files changed

+56
-1
lines changed

BulbOnOffButton/LakshyaMalik/index.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff 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>

BulbOnOffButton/LakshyaMalik/script.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff 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
}

BulbOnOffButton/LakshyaMalik/style.css

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
}
55

66
.bg{
7-
background-color: #070707;
7+
background-color: #8c8686;
88
}
99

1010
.container {
@@ -52,6 +52,37 @@
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%;

0 commit comments

Comments
 (0)