Skip to content

Commit

Permalink
adding dark mode theme toggler
Browse files Browse the repository at this point in the history
  • Loading branch information
axon4 committed Oct 2, 2020
1 parent 9c0a03a commit d30826f
Show file tree
Hide file tree
Showing 9 changed files with 720 additions and 521 deletions.
11 changes: 11 additions & 0 deletions about.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
/>
<link rel="stylesheet" href="resources/style/style.css" />
<link rel="stylesheet" href="resources/style/about-page.css" />
<!-- Dark Mode -->
<link rel='stylesheet' type='text/css' href='resources/style/themeToggle.css'>
<script src='resources/scripts/themeToggle.js' defer></script>
<!-- /Dark Mode -->
</head>

<body>
Expand Down Expand Up @@ -73,6 +77,13 @@
</li>
</ul>
</div>
<div class='theme-toggle-container'>
<span class='theme-toggle-text'>Light Mode</span>
<label class='theme-toggle'>
<input id='theme-toggle-switch' type='checkbox'>
<span class='slider round'></span>
</label>
</div>
<a class="nav-link ml-md-auto" href="beyondztm.html"
>Beyond Zero to Mastery <i class="fas fa-arrow-right"></i></a
>
Expand Down
11 changes: 11 additions & 0 deletions beyondztm.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
<link href="https://fonts.googleapis.com/css?family=Lora|Montserrat&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.11.2/css/all.min.css">
<link rel="stylesheet" href="resources/style/style.css" />
<!-- Dark Mode -->
<link rel='stylesheet' type='text/css' href='resources/style/themeToggle.css'>
<script src='resources/scripts/themeToggle.js' defer></script>
<!-- /Dark Mode -->
</head>

<body>
Expand Down Expand Up @@ -42,6 +46,13 @@
</li>
</ul>
</div>
<div class='theme-toggle-container'>
<span class='theme-toggle-text'>Light Mode</span>
<label class='theme-toggle'>
<input id='theme-toggle-switch' type='checkbox'>
<span class='slider round'></span>
</label>
</div>
<a class="nav-link ml-md-auto" href="beyondztm.html">Beyond Zero to Mastery</a>
</nav>

Expand Down
11 changes: 11 additions & 0 deletions contributersProfile.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.11.2/css/all.min.css" />
<link rel="stylesheet" href="resources/style/style.css" />
<link rel="stylesheet" href="resources/style/about-page.css" />
<!-- Dark Mode -->
<link rel='stylesheet' type='text/css' href='resources/style/themeToggle.css'>
<script src='resources/scripts/themeToggle.js' defer></script>
<!-- /Dark Mode -->
</head>

<body>
Expand Down Expand Up @@ -46,6 +50,13 @@
</li>
</ul>
</div>
<div class='theme-toggle-container'>
<span class='theme-toggle-text'>Light Mode</span>
<label class='theme-toggle'>
<input id='theme-toggle-switch' type='checkbox'>
<span class='slider round'></span>
</label>
</div>
<a class="nav-link ml-md-auto" href="beyondztm.html">Beyond Zero to Mastery <i class="fas fa-arrow-right"></i></a>
</nav>
<div class="animated bounce">
Expand Down
13 changes: 12 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="en">
<html lang="en" theme='dar'>

<head>
<meta charset="UTF-8">
Expand All @@ -20,6 +20,10 @@
href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css"
integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
<!-- Dark Mode -->
<link rel='stylesheet' type='text/css' href='resources/style/themeToggle.css'>
<script src='resources/scripts/themeToggle.js' defer></script>
<!-- /Dark Mode -->
<script src="https://code.jquery.com/jquery-3.5.1.min.js"
integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script>
</head>
Expand Down Expand Up @@ -51,6 +55,13 @@
</li>
</ul>
</div>
<div class='theme-toggle-container'>
<span class='theme-toggle-text'>Light Mode</span>
<label class='theme-toggle'>
<input id='theme-toggle-switch' type='checkbox'>
<span class='slider round'></span>
</label>
</div>
<a id="headerText" class="nav-link ml-md-auto" href="beyondztm.html">Beyond Zero to Mastery <i class="fas fa-arrow-right"></i></a>
</nav>
<a class="gotopbtn" href="#"><i class="fas fa-chevron-circle-up"></i></a>
Expand Down
11 changes: 11 additions & 0 deletions instructor.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
/>
<link rel="stylesheet" href="resources/style/style.css" />
<link rel="stylesheet" href="resources/style/about-page.css" />
<!-- Dark Mode -->
<link rel='stylesheet' type='text/css' href='resources/style/themeToggle.css'>
<script src='resources/scripts/themeToggle.js' defer></script>
<!-- /Dark Mode -->
</head>

<body>
Expand Down Expand Up @@ -72,6 +76,13 @@
</li>
</ul>
</div>
<div class='theme-toggle-container'>
<span class='theme-toggle-text'>Light Mode</span>
<label class='theme-toggle'>
<input id='theme-toggle-switch' type='checkbox'>
<span class='slider round'></span>
</label>
</div>
<a class="nav-link ml-md-auto" href="beyondztm.html"
>Beyond Zero to Mastery <i class="fas fa-arrow-right"></i></a
>
Expand Down
11 changes: 11 additions & 0 deletions register.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
/>
<link rel="stylesheet" href="resources/style/style.css" />
<link rel="stylesheet" href="resources/style/register-page.css" />
<!-- Dark Mode -->
<link rel='stylesheet' type='text/css' href='resources/style/themeToggle.css'>
<script src='resources/scripts/themeToggle.js' defer></script>
<!-- /Dark Mode -->
</head>

<body>
Expand Down Expand Up @@ -63,6 +67,13 @@
</li>
</ul>
</div>
<div class='theme-toggle-container'>
<span class='theme-toggle-text'>Light Mode</span>
<label class='theme-toggle'>
<input id='theme-toggle-switch' type='checkbox'>
<span class='slider round'></span>
</label>
</div>
<a class="nav-link ml-md-auto" href="beyondztm.html">Beyond Zero to Mastery <i class="fas fa-arrow-right"></i></a>
</nav>

Expand Down
35 changes: 35 additions & 0 deletions resources/scripts/themeToggle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Dark Theme Global JS (by Yusuf)

const html = document.querySelector('html');
// const images = document.querySelectorAll('img');
// const pictures = document.querySelectorAll('pictures');
// const videos = document.querySelectorAll('video');

const themeToggle = document.querySelector('.theme-toggle');
const themeToggleText = document.querySelector('.theme-toggle-text');

let darkMode = false;

// function inverter(elements) {
// if (darkMode) {
// elements.forEach(element => element.classList.add('invert'));
// } else {
// elements.forEach(element => element.classList.remove('invert'));
// }
// };

function toggleTheme() {
darkMode = !darkMode;

if (darkMode) {
html.setAttribute('theme', 'dark');
themeToggleText.textContent = 'Dark Mode';
// themeToggleText.style.color = 'white';
} else {
html.setAttribute('theme', 'light');
themeToggleText.textContent = 'Light Mode';
// themeToggleText.style.color = 'black';
};
};

themeToggle.addEventListener('change', toggleTheme);
Loading

0 comments on commit d30826f

Please sign in to comment.