Fix dark mode flash by inlining critical script
- Move dark mode detection to inline script in HTML head - Prevents white flash in Firefox by applying theme before render - Clean up redundant code in dark-mode.js - Apply fix to all HTML pages for consistent behavior 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
ba5c3a9650
commit
7a4fa4b312
8 changed files with 42 additions and 8 deletions
|
@ -5,6 +5,12 @@
|
|||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Account Information</title>
|
||||
<link rel="stylesheet" href="styles.css">
|
||||
<script>
|
||||
// Apply dark mode immediately to prevent flash
|
||||
if (localStorage.getItem('theme') === 'dark') {
|
||||
document.documentElement.setAttribute('data-theme', 'dark');
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<button class="dark-mode-toggle" onclick="toggleDarkMode()">🌙</button>
|
||||
|
|
|
@ -5,6 +5,12 @@
|
|||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>AJAX Demo</title>
|
||||
<link rel="stylesheet" href="styles.css">
|
||||
<script>
|
||||
// Apply dark mode immediately to prevent flash
|
||||
if (localStorage.getItem('theme') === 'dark') {
|
||||
document.documentElement.setAttribute('data-theme', 'dark');
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<button class="dark-mode-toggle" onclick="toggleDarkMode()">🌙</button>
|
||||
|
|
|
@ -1,11 +1,3 @@
|
|||
// Apply saved theme immediately to prevent flash
|
||||
(function() {
|
||||
const savedTheme = localStorage.getItem('theme');
|
||||
if (savedTheme === 'dark') {
|
||||
document.documentElement.setAttribute('data-theme', 'dark');
|
||||
}
|
||||
})();
|
||||
|
||||
// Dark mode toggle functionality
|
||||
function toggleDarkMode() {
|
||||
const html = document.documentElement;
|
||||
|
|
|
@ -5,6 +5,12 @@
|
|||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Echo Test</title>
|
||||
<link rel="stylesheet" href="styles.css">
|
||||
<script>
|
||||
// Apply dark mode immediately to prevent flash
|
||||
if (localStorage.getItem('theme') === 'dark') {
|
||||
document.documentElement.setAttribute('data-theme', 'dark');
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<button class="dark-mode-toggle" onclick="toggleDarkMode()">🌙</button>
|
||||
|
|
|
@ -5,6 +5,12 @@
|
|||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Playground - Feature Showcase</title>
|
||||
<link rel="stylesheet" href="styles.css">
|
||||
<script>
|
||||
// Apply dark mode immediately to prevent flash
|
||||
if (localStorage.getItem('theme') === 'dark') {
|
||||
document.documentElement.setAttribute('data-theme', 'dark');
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<button class="dark-mode-toggle" onclick="toggleDarkMode()">🌙</button>
|
||||
|
|
|
@ -5,6 +5,12 @@
|
|||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Items Management - Test</title>
|
||||
<link rel="stylesheet" href="styles.css">
|
||||
<script>
|
||||
// Apply dark mode immediately to prevent flash
|
||||
if (localStorage.getItem('theme') === 'dark') {
|
||||
document.documentElement.setAttribute('data-theme', 'dark');
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<button class="dark-mode-toggle" onclick="toggleDarkMode()">🌙</button>
|
||||
|
|
|
@ -5,6 +5,12 @@
|
|||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Mining Resources - Playground</title>
|
||||
<link rel="stylesheet" href="styles.css">
|
||||
<script>
|
||||
// Apply dark mode immediately to prevent flash
|
||||
if (localStorage.getItem('theme') === 'dark') {
|
||||
document.documentElement.setAttribute('data-theme', 'dark');
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<button class="dark-mode-toggle" onclick="toggleDarkMode()">🌙</button>
|
||||
|
|
|
@ -5,6 +5,12 @@
|
|||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Random Number Generator</title>
|
||||
<link rel="stylesheet" href="styles.css">
|
||||
<script>
|
||||
// Apply dark mode immediately to prevent flash
|
||||
if (localStorage.getItem('theme') === 'dark') {
|
||||
document.documentElement.setAttribute('data-theme', 'dark');
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body class="text-center">
|
||||
<button class="dark-mode-toggle" onclick="toggleDarkMode()">🌙</button>
|
||||
|
|
Loading…
Add table
Reference in a new issue