- Also fixed some remaining areas which needed dark mode support.
return $this->changeListSort($id, $request, $type);
}
+ /**
+ * Toggle dark mode for the current user.
+ */
+ public function toggleDarkMode()
+ {
+ $enabled = setting()->getForCurrentUser('dark-mode-enabled', false);
+ setting()->putUser(user(), 'dark-mode-enabled', $enabled ? 'false' : 'true');
+ return redirect()->back();
+ }
+
/**
* Update the stored section expansion preference for the given user.
*/
--- /dev/null
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M10 2c-1.82 0-3.53.5-5 1.35C7.99 5.08 10 8.3 10 12s-2.01 6.92-5 8.65C6.47 21.5 8.18 22 10 22c5.52 0 10-4.48 10-10S15.52 2 10 2z"/></svg>
\ No newline at end of file
--- /dev/null
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20 15.31L23.31 12 20 8.69V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69zM12 18c-3.31 0-6-2.69-6-6s2.69-6 6-6 6 2.69 6 6-2.69 6-6 6z"/></svg>
\ No newline at end of file
li.border-bottom {
border-bottom: 1px solid #DDD;
}
+ li hr {
+ margin: $-xs 0;
+ }
}
// Books grid view
<!DOCTYPE html>
-<html lang="{{ config('app.lang') }}" dir="{{ config('app.rtl') ? 'rtl' : 'ltr' }}" class="@yield('body-class')">
+<html lang="{{ config('app.lang') }}"
+ dir="{{ config('app.rtl') ? 'rtl' : 'ltr' }}"
+ class="{{ setting()->getForCurrentUser('dark-mode-enabled') ? 'dark-mode ' : '' }}@yield('body-class')">
<head>
<title>{{ isset($pageTitle) ? $pageTitle . ' | ' : '' }}{{ setting('app-name') }}</title>
<!-- Translations for JS -->
@stack('translations')
-
- <script>
- if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
- document.documentElement.classList.add('dark-mode');
- }
- </script>
</head>
<body class="@yield('body-class')">
<a href="{{ url('/logout') }}">@icon('logout'){{ trans('auth.logout') }}</a>
@endif
</li>
+ <li><hr></li>
+ <li>
+ <form action="{{ url('/settings/users/toggle-dark-mode') }}" method="post">
+ {{ csrf_field() }}
+ {{ method_field('patch') }}
+ @if(setting()->getForCurrentUser('dark-mode-enabled'))
+ <button>@icon('light-mode')Light Mode</button>
+ @else
+ <button>@icon('dark-mode')Dark Mode</button>
+ @endif
+ </form>
+ </li>
</ul>
</div>
@endif
Route::patch('/users/{id}/switch-shelf-view', 'UserController@switchShelfView');
Route::patch('/users/{id}/change-sort/{type}', 'UserController@changeSort');
Route::patch('/users/{id}/update-expansion-preference/{key}', 'UserController@updateExpansionPreference');
+ Route::patch('/users/toggle-dark-mode', 'UserController@toggleDarkMode');
Route::post('/users/create', 'UserController@store');
Route::get('/users/{id}', 'UserController@edit');
Route::put('/users/{id}', 'UserController@update');