added switch for light and dark mode
This commit is contained in:
parent
7083a55e03
commit
ba3c93ba19
@ -46,6 +46,9 @@ POST /tag/create=TagController->create
|
||||
; parsedown preview
|
||||
POST /parsedown/preview=ParsedownPreview->view
|
||||
|
||||
; toggle-theme
|
||||
POST /toggle-theme = ThemeController->toggle
|
||||
|
||||
; dashboard
|
||||
GET /dashboard=DashboardController->index
|
||||
|
||||
|
||||
13
app/controllers/ThemeController.php
Normal file
13
app/controllers/ThemeController.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
class ThemeController
|
||||
{
|
||||
function toggle($f3)
|
||||
{
|
||||
$current = $f3->get('SESSION.theme') ?: 'light';
|
||||
$new_theme = ($current === 'light') ? 'dark' : 'light';
|
||||
$f3->set('SESSION.theme', $new_theme);
|
||||
|
||||
$f3->reroute($f3->get('HEADERS.Referer') ?: '/');
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,5 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<html data-theme="{{ @SESSION.theme ?? 'light' }}" lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
@ -52,6 +52,13 @@
|
||||
<div class="navbar-end">
|
||||
<div class="navbar-item">
|
||||
<div class="buttons">
|
||||
<form id="theme-toggle-form" method="post" action="/toggle-theme" style="display:inline">
|
||||
<button type="submit" id="theme-toggle-button" class="button is-small" aria-label="Toggle Theme">
|
||||
<span class="icon">
|
||||
<i class="fas fa-circle-half-stroke" id="theme-icon"></i>
|
||||
</span>
|
||||
</button>
|
||||
</form>
|
||||
<check if="{{ isset(@SESSION.user) }}">
|
||||
<true>
|
||||
<a class="button is-primary" href="/logout">Log Out</a>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user