Skip to content

Commit d11c28a

Browse files
committed
Added Bulb JS project
1 parent ed3bd82 commit d11c28a

File tree

3 files changed

+95
-0
lines changed

3 files changed

+95
-0
lines changed

Bulb/sivangbagri/bulb.html

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="UTF-8" />
6+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
7+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
8+
<title>Image Carousel</title>
9+
<link rel="stylesheet" type="text/css" href="styles.css?ref=v1" />
10+
<link href="https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css" rel="stylesheet">
11+
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
12+
integrity="sha384-KK94CHFLLe+nY2dmCWGMq91rCGa5gtU4mk92HdvYe+M/SXH301p5ILy+dN9+nJOZ" crossorigin="anonymous">
13+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
14+
integrity="sha384-ENjdO4Dr2bkBIFxQpeoTz1HIcje39Wm4jDKdf19U8gI4ddQ3GYNS7NTKfAdVQSZe"
15+
crossorigin="anonymous"></script>
16+
</head>
17+
18+
<body class="bg-black">
19+
20+
21+
<div class="slide flex flex-col items-center">
22+
<div class="bulb mt-5">
23+
<img src="https://i.postimg.cc/KjK1wL3c/bulb-off.png" id="bulb" width="200">
24+
</div>
25+
<div class="bulbSwitch mt-20">
26+
<div class="form-check form-switch" onclick="lightSwitch()" id="bulbSwitch">
27+
<input class="form-check-input" type="checkbox" role="switch" id="flexSwitchCheckChecked"
28+
style="transform: scale(6);">
29+
</div>
30+
</div>
31+
</div>
32+
<script src="bulb.js"></script>
33+
</body>
34+
35+
</html>

Bulb/sivangbagri/bulb.js

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
const BULB_ON_URL = "https://i.postimg.cc/6QyTynzr/bulb-on.png";
2+
const BULB_OFF_URL = "https://i.postimg.cc/KjK1wL3c/bulb-off.png";
3+
4+
function lightSwitch() {
5+
const checkbox = document.getElementById("flexSwitchCheckChecked");
6+
if (checkbox.checked) {
7+
bulb_on();
8+
} else {
9+
bulb_off();
10+
}
11+
}
12+
13+
function bulb_on() {
14+
const bulb = document.getElementById("bulb");
15+
bulb.src = BULB_ON_URL;
16+
}
17+
18+
function bulb_off() {
19+
const bulb = document.getElementById("bulb");
20+
bulb.src = BULB_OFF_URL;
21+
}

Bulb/sivangbagri/readme.md

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Bulb Toggle Project
2+
3+
This is a simple project that demonstrates how to create a toggle button to switch a bulb on and off using HTML, CSS, JavaScript, and Bootstrap.
4+
5+
## Table of Contents
6+
7+
- [Project Overview](#project-overview)
8+
- [Tech Stack](#tech-stack)
9+
- [Getting Started](#getting-started)
10+
- [Usage](#usage)
11+
- [License](#license)
12+
13+
## Project Overview
14+
15+
This project provides a basic example of how to create a toggle button to turn a virtual bulb on and off. The toggle button changes the color of the bulb and updates its state accordingly.
16+
17+
## Tech Stack
18+
19+
- HTML
20+
- CSS
21+
- JavaScript
22+
- Bootstrap
23+
24+
## Getting Started
25+
26+
1. Clone the repository or download the source code.
27+
28+
2. Open `index.html` in a web browser to see the project in action.
29+
30+
## Usage
31+
32+
1. Open the `index.html` file in a web browser.
33+
34+
2. Click the toggle button to switch the bulb on and off. The bulb's color will change based on its state.
35+
36+
## License
37+
38+
This project is licensed under the [MIT License](LICENSE).
39+
Feel free to modify and distribute the code as needed.

0 commit comments

Comments
 (0)