Skip to content

Commit 605b250

Browse files
committed
FIX: Update README.md and style.css for dark text color
1 parent 750123d commit 605b250

File tree

2 files changed

+24
-22
lines changed

2 files changed

+24
-22
lines changed

examples/video-popup/README.md

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ The `index.html` file defines the structure of the webpage. It includes:
4040
- `<p>` — A short movie description or tagline.
4141
- `<button id="openModalBtn">` — Button to trigger the modal popup.
4242
- `<div id="videoModal" class="modal">` — The modal container that holds the video player.
43-
- `<span class="close">&times;</span>` — The close icon (×) used to close the modal.
43+
- `<button class="close-btn" id="closeModalBtn">&times;</button>` — The close icon (×) used to close the modal.
4444
- `<video>` — The HTML5 video element that plays the trailer inside the modal.
4545

4646
These elements are organized in a clean hierarchy to ensure readability and easy maintenance.
@@ -91,41 +91,43 @@ The `script.js` file manages all interactions between the user and the modal.
9191
#### **Functions Explained**
9292
1. **Element References**
9393
```js
94-
const modal = document.getElementById("videoModal");
95-
const btn = document.getElementById("openModalBtn");
96-
const span = document.getElementById("closeModalBtn");
97-
const video = document.getElementById("trailer");
94+
const openBtn = document.getElementById("openModalBtn");
95+
const closeBtn = document.getElementById("closeModalBtn");
96+
const modal = document.getElementById("videoModal");
97+
const video = document.getElementById("trailer");
98+
9899
```
99100
These lines reference the key DOM elements for manipulation.
100101

101102
2. **Open Modal Functionality**
102103
```js
103-
btn.onclick = function() {
104-
modal.style.display = "flex";
105-
video.play();
106-
}
104+
openBtn.addEventListener("click", () => {
105+
modal.classList.add("active");
106+
video.play();
107+
});
108+
107109
```
108110
When the **Play Trailer** button is clicked, this function makes the modal visible and starts playing the video.
109111

110112
3. **Close Modal Functionality**
111113
```js
112-
span.onclick = function() {
113-
modal.style.display = "none";
114-
video.pause();
115-
video.currentTime = 0;
116-
}
114+
closeBtn.addEventListener("click", () => {
115+
modal.classList.remove("active");
116+
video.pause();
117+
video.currentTime = 0; // reset to beginning
118+
});
117119
```
118120
When the close icon (×) is clicked, the modal hides, the video pauses, and the playback resets.
119121

120122
4. **Outside Click Close**
121123
```js
122-
window.onclick = function(event) {
123-
if (event.target == modal) {
124-
modal.style.display = "none";
125-
video.pause();
126-
video.currentTime = 0;
127-
}
128-
}
124+
modal.addEventListener("click", (e) => {
125+
if (e.target === modal) {
126+
modal.classList.remove("active");
127+
video.pause();
128+
video.currentTime = 0;
129+
}
130+
});
129131
```
130132
This ensures that clicking **outside the modal content** also closes the popup and stops the video.
131133

examples/video-popup/style.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
body {
33
font-family: Arial, sans-serif;
44
background: #ffffff;
5-
color: #fff;
5+
color: #333;
66
display: flex;
77
justify-content: center;
88
align-items: center;

0 commit comments

Comments
 (0)