aboutsummaryrefslogtreecommitdiffstats
path: root/theme/admin/html
diff options
context:
space:
mode:
authorThomas Lange <code@nerdmind.de>2021-07-05 21:42:20 +0200
committerThomas Lange <code@nerdmind.de>2021-07-05 22:00:36 +0200
commiteb6c2659c877b927d5461d9de309dd16e8ae8155 (patch)
treefdde59b56169998cfd67187861a6c34fca928039 /theme/admin/html
parentcb6e45b130bde70458ee544069834a951214037d (diff)
downloadblog-eb6c2659c877b927d5461d9de309dd16e8ae8155.tar.gz
blog-eb6c2659c877b927d5461d9de309dd16e8ae8155.tar.xz
blog-eb6c2659c877b927d5461d9de309dd16e8ae8155.zip
Add dark color mode for admin theme
This commit adds a dark color mode for the admin theme. The dark color mode can be enabled/disabled by clicking the hyperlink in the footer. It is not perfect yet (it uses cookies and needs a full page reload), but it works just fine for the moment. Hope your eyes can enjoy it!
Diffstat (limited to 'theme/admin/html')
-rw-r--r--theme/admin/html/main.php25
-rw-r--r--theme/admin/html/migration.php3
2 files changed, 26 insertions, 2 deletions
diff --git a/theme/admin/html/main.php b/theme/admin/html/main.php
index 45cdc41..a0a1412 100644
--- a/theme/admin/html/main.php
+++ b/theme/admin/html/main.php
@@ -1,10 +1,25 @@
+<?php
+if($toogle = HTTP::GET('colors')) {
+ $options = ['path' => '/', 'samesite' => 'Lax'];
+
+ if($toogle === 'dark') {
+ $_COOKIE['dark_mode'] = TRUE;
+ setcookie('dark_mode', TRUE, $options);
+ } else {
+ unset($_COOKIE['dark_mode']);
+ setcookie('dark_mode', NULL, array_merge($options, ['expires' => -1]));
+ }
+}
+
+$theme = isset($_COOKIE['dark_mode']) ? 'dark' : 'main';
+?>
<!DOCTYPE html>
<html lang="<?=$BLOGMETA['LANG']?>">
<head>
<meta charset="UTF-8" />
<meta name="referrer" content="origin-when-crossorigin" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
- <link rel="stylesheet" href="<?=Application::getTemplateURL('rsrc/css/main.css')?>" />
+ <link rel="stylesheet" href="<?=Application::getTemplateURL("rsrc/css/$theme.css")?>" />
<script defer src="<?=Application::getTemplateURL('rsrc/main.js')?>"></script>
<title><?=escapeHTML($NAME)?> | Administration</title>
</head>
@@ -47,6 +62,14 @@
<li><i class="fa fa-github-square"></i><a href="https://github.com/Nerdmind/Blog/releases" target="_blank">Releases</a></li>
<li><i class="fa fa-book"></i><a href="https://github.com/Nerdmind/Blog/wiki" target="_blank">Documentation</a></li>
<li><i class="fa fa-bug"></i><a href="https://github.com/Nerdmind/Blog/issues">Bugreport</a></li>
+ <li>
+ <span id="theme-toogle-dark">
+ <i class="fa fa-moon"></i><a href="?<?=http_build_query(array_merge($_GET, ['colors' => 'dark']))?>"><?=$Language->text('dark_colors')?></a>
+ </span>
+ <span id="theme-toogle-bright">
+ <i class="fa fa-sun"></i><a href="?<?=http_build_query(array_merge($_GET, ['colors' => 'bright']))?>"><?=$Language->text('bright_colors')?></a>
+ </span>
+ </li>
</ul>
</footer>
</body>
diff --git a/theme/admin/html/migration.php b/theme/admin/html/migration.php
index 14405c4..1b5be2c 100644
--- a/theme/admin/html/migration.php
+++ b/theme/admin/html/migration.php
@@ -1,10 +1,11 @@
+<?php $theme = isset($_COOKIE['dark_mode']) ? 'dark' : 'main'; ?>
<!DOCTYPE html>
<html lang="<?=$BLOGMETA['LANG']?>">
<head>
<meta charset="UTF-8" />
<meta name="referrer" content="origin-when-crossorigin" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
- <link rel="stylesheet" href="<?=Application::getTemplateURL('rsrc/css/main.css')?>" />
+ <link rel="stylesheet" href="<?=Application::getTemplateURL("rsrc/css/$theme.css")?>" />
<title><?=$Language->text('maintenance_mode')?></title>
</head>
<body>