Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added dark_mode_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 27 additions & 7 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,15 @@
<button class="btn btn-primary" onclick="playAudio(this)" type="button">
Play Music
</button>

<input title="range" type="range" id="volume-slider" />
<a class="navbar-brand" href="about.html">About</a>
<a class="navbar-brand" href="#">Play Game</a>
<a class="navbar-brand" href="contributors.html">Contributors</a>
<button class="btn btn-info" onclick="myFunction()">Dark Mode</button>
<!-- dark mode toggle: show an icon if available; text may be present on other variants -->
<button class="btn btn-info" onclick="myFunction()" aria-label="Toggle theme">
<img class="mode_icon" src="dark_mode_icon.png" height="20" width="20" alt="theme icon" />
</button>
</nav>
<br />

Expand All @@ -72,7 +76,7 @@
}
</script>
<!-- instructions phase starts here -->
<div class="popup-container">
<div class="popup-container">
<div class="instructions">
<p>
You probably already know how to play Tic-Tac-Toe. It's a really
Expand Down Expand Up @@ -199,28 +203,44 @@ <h2 id="move">PLAYER MOVE!</h2>
<div id="block_8" class="block"></div>
</div>
<!-- <button onclick="myFunction()">Toggle dark mode</button> -->
<<<<<<< HEAD

=======

>>>>>>> tictactoe1/master
<script>
function myFunction() {
var main = document.body;
var hero = document.getElementsByClassName("navbar")[0];
var container = document.getElementById("play");
var darkToggle = document.getElementsByClassName("btn");
var instructions = document.getElementsByClassName("instructions")[0] || null;
var toggleTheme = document.querySelector(".mode_icon");
var darkBtn = document.querySelector('button[onclick="myFunction()"]');
var heroText = document.getElementsByClassName("navbar-brand");
var arr = Array.prototype.slice.call(heroText);

arr.forEach((element) => {
element.classList.toggle("dark-text");
});

if (darkToggle[1].textContent === "Dark Mode") {
darkToggle[1].textContent = "Light Mode";
} else {
darkToggle[1].textContent = "Dark Mode";
// Toggle icon appearance if present
if (toggleTheme) {
toggleTheme.classList.toggle("dark-mode-icon");
}

// Toggle button text when present (keeps compatibility with variants that use text)
if (darkBtn) {
var t = darkBtn.textContent.trim();
if (t === "Dark Mode") {
darkBtn.textContent = "Light Mode";
} else if (t === "Light Mode") {
darkBtn.textContent = "Dark Mode";
}
}

hero.classList.toggle("dark-hero");
main.classList.toggle("dark-main");
if (instructions) instructions.classList.toggle("dark-instructions");
container.classList.toggle("dark-play");
}
</script>
Expand Down
Binary file added light_mode_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 14 additions & 1 deletion style.css
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ nav {
border-style: groove;
border-width: 7px;
background: whitesmoke;
/* Use centered nav for responsive layout */
margin: auto;
padding: 3px;
text-align: center;
Expand Down Expand Up @@ -412,6 +413,10 @@ pre {
}
}

.mode_icon{
filter: invert(0%);
content: url("dark_mode_icon.png");
}
/* light and dark more style */
body {
padding: 25px;
Expand All @@ -424,6 +429,10 @@ thead{
background-color: lightblue
}

.dark-mode-icon{
filter: invert(100%);
content: url("light_mode_icon.png");
}
.dark-main {
background-color: #121212;
color: white;
Expand All @@ -443,7 +452,11 @@ thead{
.dark-text {
color: white !important;
}

.dark-instructions{
background-color: #000000;
color: #ffffff;
padding: 4%;
}
.table{
width: 100px;
visibility: initial;
Expand Down