Skip to content

Conversation

@godhaniripal
Copy link

Title: Add Dark Mode Toggle Feature
Description:
Hey team! This pull request brings a sleek dark mode toggle to the Rails Girls Guides project. Now, users can easily switch between light and dark themes to suit their preferences.

Key Changes:
Header Update: Added a handy toggle button with sun and moon icons to switch between themes.

JavaScript Integration: Included a script to manage dark mode toggling, with preferences saved in localStorage.

CSS Styles: Crafted styles for dark mode, tweaking text and background colors for optimal readability.

Footer Update: Ensured dark mode consistency throughout the site, including the footer.

User Experience:
Easy Toggle: Users can switch themes via a button in the header, making it super accessible.

Persistent Preferences: The chosen theme is saved, so users keep their preference across sessions.

body.classList.toggle("dark-mode");

// Save user preference
const isDarkMode = body.classList.contains("dark-mode");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).

const body = document.body;

// Check for saved user preference
const darkModeEnabled = localStorage.getItem("dark-mode") === "true";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).

document.addEventListener("DOMContentLoaded", function () {
const toggleButton = document.getElementById("toggle-button");
const toggleIcon = document.getElementById("toggle-icon");
const body = document.body;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).

@@ -0,0 +1,23 @@
document.addEventListener("DOMContentLoaded", function () {
const toggleButton = document.getElementById("toggle-button");
const toggleIcon = document.getElementById("toggle-icon");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).

@@ -0,0 +1,23 @@
document.addEventListener("DOMContentLoaded", function () {
const toggleButton = document.getElementById("toggle-button");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants