mirror of
https://github.com/minio/docs.git
synced 2025-08-06 14:42:56 +03:00
Light/dark mode: avoid flickering on page reload (#995)
**Current behaviour:** https://github.com/minio/docs/assets/13393018/1c8b5762-9ee5-45ec-9e44-88f99c1750dd **Fix:** https://github.com/minio/docs/assets/13393018/658f7858-d793-40ca-87de-8f519a12dffa
This commit is contained in:
@@ -74,17 +74,6 @@ window.addEventListener("DOMContentLoaded", (event) => {
|
||||
// --------------------------------------------------
|
||||
(function () {
|
||||
const readModeEl = document.getElementById("read-mode-toggle");
|
||||
const headerEl = document.querySelector(".header");
|
||||
|
||||
// Check if the read mode in enabled in user's local storage
|
||||
if (readModeLs === "true") {
|
||||
document.documentElement.classList.add("read-mode");
|
||||
readModeEl.classList.add("active");
|
||||
}
|
||||
|
||||
// Make header visible after the page is loaded and read-mode is decided.
|
||||
// This is to prevent the flickering of the header on page load.
|
||||
headerEl.classList.remove("inactive");
|
||||
|
||||
// Toggle read mode on icon click
|
||||
readModeEl.addEventListener("click", (event) => {
|
||||
@@ -136,13 +125,6 @@ window.addEventListener("DOMContentLoaded", (event) => {
|
||||
// --------------------------------------------------
|
||||
(function () {
|
||||
const darkModeEl = document.getElementById("dark-mode-toggle");
|
||||
var darkModeLs = localStorage.getItem("dark-mode");
|
||||
|
||||
// Check if the dark mode in enabled in user's local storage
|
||||
if (darkModeLs === "true") {
|
||||
document.documentElement.classList.add("dark-mode");
|
||||
darkModeEl.classList.add("active");
|
||||
}
|
||||
|
||||
darkModeEl.addEventListener("click", (event) => {
|
||||
document.documentElement.classList.toggle("dark-mode");
|
||||
|
Reference in New Issue
Block a user