fixed dark/light mode
This commit is contained in:
+2
-14
@@ -1,16 +1,6 @@
|
|||||||
@import "tailwindcss";
|
@import "tailwindcss";
|
||||||
|
|
||||||
/* Dark mode configuration */
|
|
||||||
@media (prefers-color-scheme: dark) {
|
|
||||||
:root {
|
|
||||||
color-scheme: dark;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Custom Styles */
|
|
||||||
@theme {
|
@theme {
|
||||||
/* Enable class-based dark mode */
|
|
||||||
--color-scheme: class;
|
|
||||||
--color-primary-50: #f0f9ff;
|
--color-primary-50: #f0f9ff;
|
||||||
--color-primary-100: #e0f2fe;
|
--color-primary-100: #e0f2fe;
|
||||||
--color-primary-200: #bae6fd;
|
--color-primary-200: #bae6fd;
|
||||||
@@ -36,6 +26,8 @@
|
|||||||
--color-accent-950: #4a044e;
|
--color-accent-950: #4a044e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@variant dark (&:where(.dark, .dark *));
|
||||||
|
|
||||||
/* Utility Classes */
|
/* Utility Classes */
|
||||||
.line-clamp-1 {
|
.line-clamp-1 {
|
||||||
display: -webkit-box;
|
display: -webkit-box;
|
||||||
@@ -50,7 +42,3 @@
|
|||||||
-webkit-box-orient: vertical;
|
-webkit-box-orient: vertical;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-primary {
|
|
||||||
@apply inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md text-white bg-primary-600 hover:bg-primary-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -14,14 +14,27 @@
|
|||||||
</button>
|
</button>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
if (
|
||||||
|
localStorage.theme === 'dark' ||
|
||||||
|
(!('theme' in localStorage) &&
|
||||||
|
window.matchMedia('(prefers-color-scheme: dark)').matches)
|
||||||
|
) {
|
||||||
|
document.documentElement.classList.add('dark');
|
||||||
|
} else {
|
||||||
|
document.documentElement.classList.remove('dark');
|
||||||
|
document.documentElement.classList.add('light');
|
||||||
|
}
|
||||||
|
|
||||||
function toggleTheme() {
|
function toggleTheme() {
|
||||||
const html = document.documentElement;
|
const html = document.documentElement;
|
||||||
const isDark = html.classList.contains('dark');
|
const isDark = html.classList.contains('dark');
|
||||||
|
|
||||||
if (isDark) {
|
if (isDark) {
|
||||||
html.classList.remove('dark');
|
html.classList.remove('dark');
|
||||||
|
html.classList.add('light');
|
||||||
localStorage.setItem('theme', 'light');
|
localStorage.setItem('theme', 'light');
|
||||||
} else {
|
} else {
|
||||||
|
html.classList.remove('light');
|
||||||
html.classList.add('dark');
|
html.classList.add('dark');
|
||||||
localStorage.setItem('theme', 'dark');
|
localStorage.setItem('theme', 'dark');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,30 +9,6 @@
|
|||||||
|
|
||||||
<title>{{ $title ?? config('app.name', 'BestTech') }}</title>
|
<title>{{ $title ?? config('app.name', 'BestTech') }}</title>
|
||||||
|
|
||||||
<!-- Dark Mode Script (Must be in head to prevent flash) -->
|
|
||||||
<script>
|
|
||||||
// Check for saved theme preference or default to light mode
|
|
||||||
if (localStorage.theme === 'dark' || (!('theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
|
|
||||||
document.documentElement.classList.add('dark');
|
|
||||||
} else {
|
|
||||||
document.documentElement.classList.remove('dark');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Toggle theme function
|
|
||||||
window.toggleTheme = function() {
|
|
||||||
const html = document.documentElement;
|
|
||||||
const isDark = html.classList.contains('dark');
|
|
||||||
|
|
||||||
if (isDark) {
|
|
||||||
html.classList.remove('dark');
|
|
||||||
localStorage.setItem('theme', 'light');
|
|
||||||
} else {
|
|
||||||
html.classList.add('dark');
|
|
||||||
localStorage.setItem('theme', 'dark');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<!-- Fonts -->
|
<!-- Fonts -->
|
||||||
<link rel="preconnect" href="https://fonts.bunny.net">
|
<link rel="preconnect" href="https://fonts.bunny.net">
|
||||||
<link href="https://fonts.bunny.net/css?family=inter:300,400,500,600,700,800" rel="stylesheet">
|
<link href="https://fonts.bunny.net/css?family=inter:300,400,500,600,700,800" rel="stylesheet">
|
||||||
|
|||||||
Reference in New Issue
Block a user