Merge pull request 'Add dark theme toggle' (#35) from dark-mode into master
Reviewed-on: #35
This commit is contained in:
commit
5c5e4fbdd7
@ -4,18 +4,20 @@
|
|||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
.polaroid a.edit {
|
.polaroid a.edit {
|
||||||
background: #fff;
|
background: var(--bs-body-bg);
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
box-shadow: 1px 1px 2px rgba(0,0,0,0.3);
|
box-shadow: 1px 1px 2px rgba(0,0,0,0.3);
|
||||||
display: none !important;
|
color: var(--bs-body-color);
|
||||||
|
opacity: 0;
|
||||||
left: 20px;
|
left: 20px;
|
||||||
line-height: 1.5;
|
line-height: 1.5;
|
||||||
padding: 5px 10px;
|
padding: 5px 10px;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
transition: 0.25s;
|
||||||
top: 20px;
|
top: 20px;
|
||||||
}
|
}
|
||||||
.polaroid:hover > a.edit {
|
.polaroid:hover > a.edit {
|
||||||
display: block !important;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -18,6 +18,11 @@ body {
|
|||||||
font-family: "Open Sans", sans-serif;
|
font-family: "Open Sans", sans-serif;
|
||||||
background: #aaa 0 -50% fixed;
|
background: #aaa 0 -50% fixed;
|
||||||
padding: 0 0 3rem;
|
padding: 0 0 3rem;
|
||||||
|
transition: 0.5s;
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-bs-theme=dark] body {
|
||||||
|
background-color: #444;
|
||||||
}
|
}
|
||||||
|
|
||||||
#wrapper, header .container {
|
#wrapper, header .container {
|
||||||
@ -34,7 +39,19 @@ a:hover {
|
|||||||
color: #262626;
|
color: #262626;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[data-bs-theme=dark] .content-box a:not(.btn) {
|
||||||
|
color: #b94b4b;
|
||||||
|
}
|
||||||
|
[data-bs-theme=dark] .content-box a:not(.btn):hover {
|
||||||
|
color: #963626;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
.page-link {
|
.page-link {
|
||||||
|
--bs-pagination-disabled-bg: var(--bs-body-bg);
|
||||||
|
--bs-pagination-disabled-color: var(--bs-body-color);
|
||||||
|
}
|
||||||
|
.page-link, .page-padding {
|
||||||
color: #b50707;
|
color: #b50707;
|
||||||
font-family: 'Coda', sans-serif;
|
font-family: 'Coda', sans-serif;
|
||||||
}
|
}
|
||||||
@ -45,6 +62,15 @@ a:hover {
|
|||||||
background-color: #990b0b;
|
background-color: #990b0b;
|
||||||
border-color: #a40d0d;
|
border-color: #a40d0d;
|
||||||
}
|
}
|
||||||
|
[data-bs-theme=dark] .page-link,
|
||||||
|
[data-bs-theme=dark] .page-padding{
|
||||||
|
color: #ae473c;
|
||||||
|
}
|
||||||
|
[data-bs-theme=dark] .active > .page-link, .page-link.active {
|
||||||
|
background-color: #4a0e0e;
|
||||||
|
border-color: #5b5a5a;
|
||||||
|
color: #ddd;
|
||||||
|
}
|
||||||
|
|
||||||
@media (max-width: 767px) {
|
@media (max-width: 767px) {
|
||||||
.pagination {
|
.pagination {
|
||||||
@ -182,7 +208,7 @@ i.nyan-cat {
|
|||||||
/* Content boxes
|
/* Content boxes
|
||||||
------------------*/
|
------------------*/
|
||||||
.content-box {
|
.content-box {
|
||||||
background-color: #fff;
|
background-color: var(--bs-body-bg);
|
||||||
margin: 0 auto 2rem;
|
margin: 0 auto 2rem;
|
||||||
padding: 2rem;
|
padding: 2rem;
|
||||||
border-radius: 0.5rem;
|
border-radius: 0.5rem;
|
||||||
@ -203,10 +229,10 @@ i.nyan-cat {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.tiled-header > a {
|
.tiled-header > a {
|
||||||
background: #fff;
|
background: var(--bs-body-bg);
|
||||||
box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
|
box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
|
||||||
border-radius: 0.5rem;
|
border-radius: 0.5rem;
|
||||||
color: #000;
|
color: var(--bs-body-color);
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
font: 400 18px/2.2 'Coda', sans-serif;
|
font: 400 18px/2.2 'Coda', sans-serif;
|
||||||
margin: 0 0 1.5% 0;
|
margin: 0 0 1.5% 0;
|
||||||
@ -217,7 +243,7 @@ i.nyan-cat {
|
|||||||
}
|
}
|
||||||
|
|
||||||
div.polaroid {
|
div.polaroid {
|
||||||
background: #fff;
|
background: var(--bs-body-bg);
|
||||||
box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.3);
|
box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.3);
|
||||||
line-height: 0;
|
line-height: 0;
|
||||||
position: relative;
|
position: relative;
|
||||||
@ -227,7 +253,7 @@ div.polaroid:hover {
|
|||||||
box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.5);
|
box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.5);
|
||||||
}
|
}
|
||||||
div.polaroid img.normal-photo {
|
div.polaroid img.normal-photo {
|
||||||
background: #fff url('../images/nothumb.svg') center no-repeat;
|
background: var(--bs-body-bg) url('../images/nothumb.svg') center no-repeat;
|
||||||
border: none;
|
border: none;
|
||||||
left: 0;
|
left: 0;
|
||||||
object-fit: cover;
|
object-fit: cover;
|
||||||
@ -246,13 +272,13 @@ div.polaroid img.blur-photo {
|
|||||||
z-index: 0;
|
z-index: 0;
|
||||||
}
|
}
|
||||||
div.polaroid img.placeholder-image {
|
div.polaroid img.placeholder-image {
|
||||||
background: #fff;
|
background: var(--bs-body-bg);
|
||||||
z-index: 20;
|
z-index: 20;
|
||||||
}
|
}
|
||||||
div.polaroid h4 {
|
div.polaroid h4 {
|
||||||
background: #fff;
|
background: var(--bs-body-bg);
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
color: #000;
|
color: var(--bs-body-color);
|
||||||
margin: 0;
|
margin: 0;
|
||||||
font: 400 18px 'Coda', sans-serif;
|
font: 400 18px 'Coda', sans-serif;
|
||||||
padding: 15px 5px;
|
padding: 15px 5px;
|
||||||
@ -278,7 +304,7 @@ div.polaroid a {
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
.album_title_box > a {
|
.album_title_box > a {
|
||||||
background: #fff;
|
background: var(--bs-body-bg);
|
||||||
box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
|
box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
|
||||||
border-top-left-radius: 0.5rem;
|
border-top-left-radius: 0.5rem;
|
||||||
border-bottom-left-radius: 0.5rem;
|
border-bottom-left-radius: 0.5rem;
|
||||||
@ -289,7 +315,7 @@ div.polaroid a {
|
|||||||
padding: 8px 10px;
|
padding: 8px 10px;
|
||||||
}
|
}
|
||||||
.album_title_box > div {
|
.album_title_box > div {
|
||||||
background: #fff;
|
background: var(--bs-body-bg);
|
||||||
box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
|
box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
|
||||||
border-top-right-radius: 0.5rem;
|
border-top-right-radius: 0.5rem;
|
||||||
border-bottom-right-radius: 0.5rem;
|
border-bottom-right-radius: 0.5rem;
|
||||||
@ -300,7 +326,7 @@ div.polaroid a {
|
|||||||
margin: 0 0 1.5% 0;
|
margin: 0 0 1.5% 0;
|
||||||
}
|
}
|
||||||
.album_title_box h2 {
|
.album_title_box h2 {
|
||||||
color: #262626;
|
color: var(--bs-body-color);
|
||||||
font: 400 18px/2 'Coda', sans-serif !important;
|
font: 400 18px/2 'Coda', sans-serif !important;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
@ -316,10 +342,18 @@ div.polaroid a {
|
|||||||
margin-bottom: 3rem;
|
margin-bottom: 3rem;
|
||||||
}
|
}
|
||||||
.album_button_box > a {
|
.album_button_box > a {
|
||||||
|
background: var(--bs-body-bg);
|
||||||
box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
|
box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
|
||||||
|
border-color: var( --bs-secondary-bg);
|
||||||
|
color: var(--bs-body-color);
|
||||||
padding: 8px 10px;
|
padding: 8px 10px;
|
||||||
margin-left: 12px;
|
margin-left: 12px;
|
||||||
}
|
}
|
||||||
|
.album_button_box > a:hover {
|
||||||
|
background: var(--bs-secondary-bg);
|
||||||
|
border-color: var(--bs-tertiary-bg);
|
||||||
|
color: var(--bs-secondary-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* (Tag) autosuggest
|
/* (Tag) autosuggest
|
||||||
@ -329,8 +363,9 @@ div.polaroid a {
|
|||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
.autosuggest {
|
.autosuggest {
|
||||||
background: #fff;
|
background: var(--bs-body-bg);
|
||||||
border: 1px solid #ccc;
|
border: 1px solid #ccc;
|
||||||
|
color: var(--bs-body-color);
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 2px;
|
left: 2px;
|
||||||
top: 37px;
|
top: 37px;
|
||||||
@ -459,9 +494,9 @@ figure#photo-figure img.blur-photo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#previous_photo, #next_photo {
|
#previous_photo, #next_photo {
|
||||||
background: #fff;
|
background: var(--bs-body-bg);
|
||||||
box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
|
box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
|
||||||
color: #262626;
|
color: var(--bs-body-color);
|
||||||
font-size: 3rem;
|
font-size: 3rem;
|
||||||
line-height: 0.5;
|
line-height: 0.5;
|
||||||
padding: 2rem 0.5rem;
|
padding: 2rem 0.5rem;
|
||||||
@ -473,8 +508,8 @@ span#previous_photo, span#next_photo {
|
|||||||
opacity: 0.25;
|
opacity: 0.25;
|
||||||
}
|
}
|
||||||
a#previous_photo:hover, a#next_photo:hover {
|
a#previous_photo:hover, a#next_photo:hover {
|
||||||
background: #eee;
|
background: var(--bs-secondary-bg);
|
||||||
color: #000;
|
color: var(--bs-secondary-color);
|
||||||
}
|
}
|
||||||
#previous_photo {
|
#previous_photo {
|
||||||
border-top-right-radius: 0.5rem;
|
border-top-right-radius: 0.5rem;
|
||||||
|
77
public/js/color-modes.js
Normal file
77
public/js/color-modes.js
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
/*!
|
||||||
|
* Color mode toggler for Bootstrap's docs (https://getbootstrap.com/)
|
||||||
|
* Copyright 2011-2023 The Bootstrap Authors
|
||||||
|
* Licensed under the Creative Commons Attribution 3.0 Unported License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
(() => {
|
||||||
|
'use strict'
|
||||||
|
|
||||||
|
const getStoredTheme = () => localStorage.getItem('theme');
|
||||||
|
const setStoredTheme = theme => localStorage.setItem('theme', theme);
|
||||||
|
|
||||||
|
const getPreferredTheme = () => {
|
||||||
|
const storedTheme = getStoredTheme();
|
||||||
|
if (storedTheme) {
|
||||||
|
return storedTheme;
|
||||||
|
}
|
||||||
|
|
||||||
|
return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
|
||||||
|
}
|
||||||
|
|
||||||
|
const setTheme = theme => {
|
||||||
|
if (theme === 'auto' && window.matchMedia('(prefers-color-scheme: dark)').matches) {
|
||||||
|
document.documentElement.setAttribute('data-bs-theme', 'dark');
|
||||||
|
} else {
|
||||||
|
document.documentElement.setAttribute('data-bs-theme', theme);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setTheme(getPreferredTheme());
|
||||||
|
|
||||||
|
const showActiveTheme = (theme, focus = false) => {
|
||||||
|
const themeSwitcher = document.querySelector('#bd-theme');
|
||||||
|
|
||||||
|
if (!themeSwitcher) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const themeSwitcherText = document.querySelector('#bd-theme-text');
|
||||||
|
const activeThemeIcon = document.querySelector('#theme-icon-active');
|
||||||
|
const btnToActive = document.querySelector(`[data-bs-theme-value="${theme}"]`);
|
||||||
|
const activeButtonIcon = btnToActive.querySelector('i.bi').className;
|
||||||
|
|
||||||
|
document.querySelectorAll('[data-bs-theme-value]').forEach(element => {
|
||||||
|
element.classList.remove('active');
|
||||||
|
});
|
||||||
|
|
||||||
|
btnToActive.classList.add('active');
|
||||||
|
activeThemeIcon.className = activeButtonIcon;
|
||||||
|
const themeSwitcherLabel = `${themeSwitcherText.textContent} (${btnToActive.dataset.bsThemeValue})`
|
||||||
|
|
||||||
|
if (focus) {
|
||||||
|
themeSwitcher.focus()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', () => {
|
||||||
|
const storedTheme = getStoredTheme()
|
||||||
|
if (storedTheme !== 'light' && storedTheme !== 'dark') {
|
||||||
|
setTheme(getPreferredTheme())
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
window.addEventListener('DOMContentLoaded', () => {
|
||||||
|
showActiveTheme(getPreferredTheme())
|
||||||
|
|
||||||
|
document.querySelectorAll('[data-bs-theme-value]')
|
||||||
|
.forEach(toggle => {
|
||||||
|
toggle.addEventListener('click', () => {
|
||||||
|
const theme = toggle.getAttribute('data-bs-theme-value')
|
||||||
|
setStoredTheme(theme)
|
||||||
|
setTheme(theme)
|
||||||
|
showActiveTheme(theme, true)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})()
|
@ -51,6 +51,8 @@ class MainNavBar extends NavBar
|
|||||||
$userMenu = new UserMenu();
|
$userMenu = new UserMenu();
|
||||||
$this->renderMenuItems($userMenu->getItems());
|
$this->renderMenuItems($userMenu->getItems());
|
||||||
|
|
||||||
|
$this->darkModeToggle();
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
</ul>
|
</ul>
|
||||||
</div>';
|
</div>';
|
||||||
@ -60,4 +62,36 @@ class MainNavBar extends NavBar
|
|||||||
</div>
|
</div>
|
||||||
</nav>';
|
</nav>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function darkModeToggle()
|
||||||
|
{
|
||||||
|
echo '
|
||||||
|
<li class="nav-item dropdown">
|
||||||
|
<button class="btn btn-link nav-link py-2 px-0 px-lg-2 dropdown-toggle d-flex align-items-center"
|
||||||
|
id="bd-theme" type="button" data-bs-toggle="dropdown" data-bs-display="static">
|
||||||
|
<i id="theme-icon-active" class="bi bi-light"></i>
|
||||||
|
<span class="d-lg-none ms-2" id="bd-theme-text">Toggle theme</span>
|
||||||
|
</button>
|
||||||
|
<ul class="dropdown-menu dropdown-menu-end">
|
||||||
|
<li>
|
||||||
|
<button type="button" class="dropdown-item d-flex align-items-center" data-bs-theme-value="light">
|
||||||
|
<i class="bi bi-sun-fill"></i>
|
||||||
|
Light
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<button type="button" class="dropdown-item d-flex align-items-center" data-bs-theme-value="dark">
|
||||||
|
<i class="bi bi-moon-stars-fill"></i>
|
||||||
|
Dark
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<button type="button" class="dropdown-item d-flex align-items-center active" data-bs-theme-value="auto">
|
||||||
|
<i class="bi bi-circle-half"></i>
|
||||||
|
Auto
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</li>';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,8 @@ class MainTemplate extends Template
|
|||||||
<link rel="stylesheet" href="', BASEURL, '/vendor/twbs/bootstrap/dist/css/bootstrap.min.css">
|
<link rel="stylesheet" href="', BASEURL, '/vendor/twbs/bootstrap/dist/css/bootstrap.min.css">
|
||||||
<link rel="stylesheet" href="', BASEURL, '/vendor/twbs/bootstrap-icons/font/bootstrap-icons.css">
|
<link rel="stylesheet" href="', BASEURL, '/vendor/twbs/bootstrap-icons/font/bootstrap-icons.css">
|
||||||
<link type="text/css" rel="stylesheet" href="', BASEURL, '/css/default.css">
|
<link type="text/css" rel="stylesheet" href="', BASEURL, '/css/default.css">
|
||||||
<script type="text/javascript" src="', BASEURL, '/js/main.js"></script>'
|
<script type="text/javascript" src="', BASEURL, '/js/main.js"></script>
|
||||||
|
<script type="text/javascript" src="', BASEURL, '/js/color-modes.js"></script>'
|
||||||
, $this->header_html, '
|
, $this->header_html, '
|
||||||
</head>
|
</head>
|
||||||
<body', !empty($this->classes) ? ' class="' . implode(' ', $this->classes) . '"' : '', '>
|
<body', !empty($this->classes) ? ' class="' . implode(' ', $this->classes) . '"' : '', '>
|
||||||
|
Loading…
Reference in New Issue
Block a user