mirror of
https://github.com/rickbarrette/redmine_dark_mode.git
synced 2026-11-18 04:50:36 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9a2f1fe3b8 | ||
|
|
786bb499b2 | ||
|
|
3e932e0612 | ||
|
|
62be748419 |
No files matched your search
@@ -24,12 +24,15 @@
|
||||
});
|
||||
}
|
||||
|
||||
function render(button) {
|
||||
// The top bar's icon button, and on phones a line in the slide-out menu (the top bar is hidden there)
|
||||
function render(button, link) {
|
||||
var dm = window.RedmineDarkMode;
|
||||
var label = isDark() ? dm.labels.light : dm.labels.dark;
|
||||
button.innerHTML = isDark() ? SUN : MOON;
|
||||
var icon = isDark() ? SUN : MOON;
|
||||
button.innerHTML = icon;
|
||||
button.title = label;
|
||||
button.setAttribute('aria-label', label);
|
||||
if (link) link.innerHTML = icon + '<span>' + label + '</span>';
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
@@ -39,18 +42,37 @@
|
||||
var button = document.createElement('button');
|
||||
button.type = 'button';
|
||||
button.className = 'dark-mode-toggle';
|
||||
render(button);
|
||||
button.addEventListener('click', function () {
|
||||
|
||||
var link = null;
|
||||
var flyout = document.querySelector('.js-flyout-menu');
|
||||
if (flyout) {
|
||||
var list = document.createElement('ul');
|
||||
list.className = 'dark-mode-flyout';
|
||||
var item = document.createElement('li');
|
||||
link = document.createElement('a');
|
||||
link.href = '#';
|
||||
link.className = 'dark-mode-flyout-toggle';
|
||||
item.appendChild(link);
|
||||
list.appendChild(item);
|
||||
flyout.appendChild(list);
|
||||
}
|
||||
|
||||
function toggle(e) {
|
||||
e.preventDefault();
|
||||
var mode = isDark() ? 'light' : 'dark';
|
||||
window.RedmineDarkMode.set(mode);
|
||||
render(button);
|
||||
render(button, link);
|
||||
save(mode);
|
||||
});
|
||||
}
|
||||
|
||||
render(button, link);
|
||||
button.addEventListener('click', toggle);
|
||||
if (link) link.addEventListener('click', toggle);
|
||||
menu.insertBefore(button, menu.firstChild);
|
||||
|
||||
// The device switching light/dark (Automatic) changes the icon too
|
||||
var media = window.matchMedia('(prefers-color-scheme: dark)');
|
||||
if (media.addEventListener) media.addEventListener('change', function () { render(button); });
|
||||
if (media.addEventListener) media.addEventListener('change', function () { render(button, link); });
|
||||
});
|
||||
})();
|
||||
|
||||
|
||||
@@ -196,6 +196,9 @@ html.dark-mode .tooltip:hover {
|
||||
/* Sticky issue title shown when scrolling down an issue (white in core) */
|
||||
html.dark-mode div#sticky-issue-header { background-color: var(--oc-white); color: var(--oc-gray-9); }
|
||||
|
||||
/* The box behind the tab scroll arrows, shown when tabs don't fit, e.g. Administration > Settings (white in core) */
|
||||
html.dark-mode div.tabs-buttons { background: var(--oc-white); }
|
||||
|
||||
/* Text formatting toolbar: its icons are dark drawings, so the buttons are inverted (interface icons only,
|
||||
never pictures); the background and border are set so they come out as the dark ones after inverting */
|
||||
html.dark-mode .jstElements button {
|
||||
@@ -245,6 +248,27 @@ html.dark-mode .item-description { color: #969aa1; }
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
/* The phone slide-out menu's dark mode line, after the profile links */
|
||||
.flyout-menu ul.dark-mode-flyout { margin-top: 12px; }
|
||||
.flyout-menu .dark-mode-flyout-toggle { display: flex; align-items: center; gap: 8px; }
|
||||
.flyout-menu .dark-mode-flyout-toggle svg { flex: none; }
|
||||
|
||||
/* Redmine's open slide-out menu is as tall as the page and the page can't scroll while it's open, so on a
|
||||
phone its last lines (Sign out, this toggle) sat out of reach. Pinned to the screen, it scrolls by itself. */
|
||||
@media screen and (max-width: 899px) {
|
||||
.flyout-is-active .flyout-menu {
|
||||
position: fixed;
|
||||
inset-block: 0;
|
||||
inset-inline-end: 0;
|
||||
block-size: 100vh;
|
||||
block-size: 100dvh;
|
||||
overflow-y: auto;
|
||||
overscroll-behavior: contain;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
z-index: 100;
|
||||
}
|
||||
}
|
||||
|
||||
/* Issue boxes and other cards: Gitea's card colour instead of Redmine's pale yellow */
|
||||
html.dark-mode div.issue { background: #191a1c; border-color: #3f4248; }
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ Redmine::Plugin.register :redmine_dark_mode do
|
||||
name 'Redmine Dark Mode plugin'
|
||||
author 'Rick Barrette'
|
||||
description 'A dark mode for Redmine: follows the device by default, with a per-user choice and a toggle in the top menu'
|
||||
version '2026.11.2'
|
||||
version '2026.11.4'
|
||||
url 'https://github.com/rickbarrette/redmine_dark_mode'
|
||||
author_url 'https://barrettefabrication.com'
|
||||
requires_redmine version_or_higher: '7.0.0'
|
||||
|
||||
Reference in new issue
Block a user