Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…hub-profiles into minimal_items
  • Loading branch information
nishant0708 committed Aug 1, 2024
2 parents 3c43155 + f3bc32d commit 7996548
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 28 deletions.
29 changes: 29 additions & 0 deletions dark-mode.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
document.addEventListener("DOMContentLoaded", function () {
const themeToggleCheckbox = document.querySelector("#theme-toggle");
const themeLabel = document.querySelector(".toggle-label");

// Function to set the theme
function setTheme(theme) {
if (theme === "dark") {
document.body.classList.add("dark-mode");
themeLabel.textContent = "Dark Mode";
themeToggleCheckbox.checked = true;
} else {
document.body.classList.remove("dark-mode");
themeLabel.textContent = "Light Mode";
themeToggleCheckbox.checked = false;
}
localStorage.setItem("theme", theme);
}

// Load the theme from localStorage
const savedTheme = localStorage.getItem("theme") || "light";
setTheme(savedTheme);

// Add event listener to toggle checkbox
themeToggleCheckbox.addEventListener("change", () => {
const newTheme = themeToggleCheckbox.checked ? "dark" : "light";
setTheme(newTheme);
});
});

1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,6 @@ <h1 class="main-heading">Awesome GitHub Profile READMEs</h1>
</div>
</div>
<script src="retriveprofile.js"></script>
<script src="dark-mode.js"></script>
</body>
</html>
29 changes: 1 addition & 28 deletions retriveprofile.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,6 @@
document.addEventListener("DOMContentLoaded", function () {
const themeToggleCheckbox = document.querySelector("#theme-toggle");
const themeLabel = document.querySelector(".toggle-label");

// Function to set the theme
function setTheme(theme) {
if (theme === "dark") {
document.body.classList.add("dark-mode");
themeLabel.textContent = "Dark Mode";
themeToggleCheckbox.checked = true;
} else {
document.body.classList.remove("dark-mode");
themeLabel.textContent = "Light Mode";
themeToggleCheckbox.checked = false;
}
localStorage.setItem("theme", theme);
}

// Load the theme from localStorage
const savedTheme = localStorage.getItem("theme") || "light";
setTheme(savedTheme);

// Add event listener to toggle checkbox
themeToggleCheckbox.addEventListener("change", () => {
const newTheme = themeToggleCheckbox.checked ? "dark" : "light";
setTheme(newTheme);
});

// Fetch and render profiles
let contributors = [];

function renderProfiles(filter = "") {
const container = document.querySelector(".profiles");
container.innerHTML = "";
Expand Down

0 comments on commit 7996548

Please sign in to comment.