Update
This commit is contained in:
@@ -1,21 +1,22 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}" @class(['dark' => ($appearance ?? 'system') == 'dark'])>
|
||||
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
{{-- Inline script to detect system dark mode preference and apply it immediately --}}
|
||||
{{-- Inline script to detect theme preference and apply it immediately to prevent flash --}}
|
||||
<script>
|
||||
(function() {
|
||||
const appearance = '{{ $appearance ?? 'system' }}';
|
||||
const savedTheme = sessionStorage.getItem('theme') || 'system';
|
||||
|
||||
if (appearance === 'system') {
|
||||
if (savedTheme === 'system') {
|
||||
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
|
||||
|
||||
if (prefersDark) {
|
||||
document.documentElement.classList.add('dark');
|
||||
}
|
||||
} else if (savedTheme === 'dark') {
|
||||
document.documentElement.classList.add('dark');
|
||||
}
|
||||
})();
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user