mirror of
https://github.com/standardebooks/web.git
synced 2025-07-15 19:06:49 -04:00
Merge reset.css into core.css, and add settings page for specifying dark mode preferences
This commit is contained in:
parent
27d081b644
commit
11224136d1
9 changed files with 272 additions and 196 deletions
23
www/settings/index.php
Normal file
23
www/settings/index.php
Normal file
|
@ -0,0 +1,23 @@
|
|||
<?
|
||||
require_once('Core.php');
|
||||
|
||||
$colorScheme = $_COOKIE['color-scheme'] ?? 'auto';
|
||||
|
||||
?><?= Template::Header(['title' => 'Website Settings', 'description' => 'Adjust your settings for viewing the Standard Ebooks website.']) ?>
|
||||
<main>
|
||||
<h1>Website Settings</h1>
|
||||
<form action="/settings" method="post">
|
||||
<label class="select">
|
||||
<span>Color scheme</span>
|
||||
<span>
|
||||
<select name="color-scheme">
|
||||
<option value="auto"<? if($colorScheme == 'auto'){ ?> selected="selected"<? } ?>>Automatic</option>
|
||||
<option value="light"<? if($colorScheme == 'light'){ ?> selected="selected"<? } ?>>Light</option>
|
||||
<option value="dark"<? if($colorScheme == 'dark'){ ?> selected="selected"<? } ?>>Dark</option>
|
||||
</select>
|
||||
</span>
|
||||
</label>
|
||||
<button>Apply</button>
|
||||
</form>
|
||||
</main>
|
||||
<?= Template::Footer() ?>
|
21
www/settings/post.php
Normal file
21
www/settings/post.php
Normal file
|
@ -0,0 +1,21 @@
|
|||
<?
|
||||
require_once('Core.php');
|
||||
|
||||
$colorScheme = $_POST['color-scheme'] ?? 'auto';
|
||||
|
||||
if($colorScheme !== 'dark' && $colorScheme !== 'light' && $colorScheme !== 'auto'){
|
||||
$colorScheme = 'auto';
|
||||
}
|
||||
|
||||
if($colorScheme == 'auto'){
|
||||
// Delete the cookie; auto is the default
|
||||
setcookie('color-scheme', null, ['expires' => 0, 'path' => '/', 'secure' => true, 'httponly' => true]);
|
||||
}
|
||||
else{
|
||||
setcookie('color-scheme', $colorScheme, ['expires' => strtotime('+10 years'), 'path' => '/', 'secure' => true, 'httponly' => true]);
|
||||
}
|
||||
|
||||
// HTTP 303, See other
|
||||
http_response_code(303);
|
||||
header('Location: /settings');
|
||||
?>
|
Loading…
Add table
Add a link
Reference in a new issue