10 Commits
Author SHA1 Message Date
rickyandClaude Opus 5.5 e04cd336f8 2026.11.6
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-06 16:21:38 -05:00
rickyandClaude Opus 5.5 b241f75cc9 Keep checkboxes light on light pages
With Redmine set to Light and the device dark, the color-scheme meta let the browser draw checkboxes, radio buttons and scrollbars dark. Light pages now pin color-scheme: light.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-06 16:21:38 -05:00
ricky 3df55bc97f 2026.11.5 2026-11-04 15:04:19 -05:00
rickyandClaude Opus 5.5 2f58a1c7f7 Keep text readable on locked estimates and invoices
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 15:04:19 -05:00
ricky 9a2f1fe3b8 2026.11.4 2026-11-03 21:57:00 -05:00
rickyandClaude Opus 5.5 786bb499b2 Darken the box behind the tab scroll arrows
Redmine colours it white, which showed around the arrows when tabs don't fit,
e.g. Administration > Settings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-03 21:57:00 -05:00
rickyandClaude Opus 5.5 3e932e0612 2026.11.3
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-03 20:25:40 -05:00
rickyandClaude Opus 5.5 62be748419 Dark mode toggle in the phone slide-out menu, and let that menu scroll
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-03 20:25:40 -05:00
rickyandClaude Opus 5.5 ba953295ee 2026.11.2
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 22:22:50 -05:00
rickyandClaude Opus 5.5 885c4d2b3a Dark "Are you sure?" dialog on dark pages
rails-ujs confirmations (data-confirm) show a dark dialog in Gitea's colours while the page is dark,
instead of the browser's box drawn in the device's colours; OK carries on with the link, button or
form. Light pages keep the browser's box. RedmineDarkMode.confirm(message, onOk) does the same for
other scripts. The default mode is one setting (DEFAULT_MODE, Automatic).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 22:22:50 -05:00
7 changed files with 183 additions and 14 deletions

No files matched your search

+102 -7
View File
@@ -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,17 +42,109 @@
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); });
});
})();
// "Are you sure?" confirmations (data-confirm, through rails-ujs). The browser draws its own box in the device's
// colours, so on a dark page it can flash up bright; while the page is dark, a dark dialog asks instead, and OK
// carries on with the link, button or form. Light pages keep the browser's box.
(function () {
if (!window.RedmineDarkMode || !window.HTMLDialogElement) return;
var nativeConfirm = window.Rails && Rails.confirm;
var approved = null;
function ask(message, onOk) {
var labels = window.RedmineDarkMode.labels;
var dialog = document.createElement('dialog');
dialog.className = 'dark-mode-confirm';
var text = document.createElement('p');
text.textContent = message;
var buttons = document.createElement('div');
buttons.className = 'dark-mode-confirm-buttons';
var cancel = document.createElement('button');
cancel.type = 'button';
cancel.textContent = labels.cancel;
var ok = document.createElement('button');
ok.type = 'button';
ok.className = 'dark-mode-confirm-ok';
ok.textContent = labels.ok;
buttons.append(cancel, ok);
dialog.append(text, buttons);
document.body.appendChild(dialog);
var confirmed = false;
cancel.addEventListener('click', function () { dialog.close(); });
ok.addEventListener('click', function () { confirmed = true; dialog.close(); });
// Clicking the dimmed page outside the dialog cancels, like Escape
dialog.addEventListener('click', function (e) { if (e.target === dialog) dialog.close(); });
dialog.addEventListener('close', function () {
dialog.remove();
if (confirmed) onOk();
});
dialog.showModal();
ok.focus();
}
// For other scripts: asks in the dark dialog on dark pages, or the browser's box on light ones, then runs onOk
window.RedmineDarkMode.confirm = function (message, onOk) {
if (document.documentElement.classList.contains('dark-mode')) {
ask(message, onOk);
} else if (window.confirm(message)) {
onOk();
}
};
if (!window.Rails) return;
Rails.confirm = function (message, element) {
if (!document.documentElement.classList.contains('dark-mode')) {
return nativeConfirm ? nativeConfirm(message, element) : window.confirm(message);
}
// The second pass, after OK: let it through
if (approved === element) {
approved = null;
return true;
}
ask(message, function () {
approved = element;
if (element.tagName === 'FORM') {
element.requestSubmit ? element.requestSubmit() : element.submit();
} else {
element.click();
}
});
return false;
};
})();
+70
View File
@@ -8,6 +8,13 @@ html.dark-mode {
color-scheme: dark;
}
/* Light pages stay light even when the device is dark. The head's <meta name="color-scheme" content="light dark">
otherwise lets the browser draw its own controls (checkboxes, radio buttons, scrollbars) in the device's dark
style on a page the user set to Light. */
html:not(.dark-mode) {
color-scheme: light;
}
/* Dark palette: Gitea's dark theme colours (theme-gitea-dark.css) on Open Color's scales, where 0-2 are
backgrounds, 3-4 borders and 5-9 text. */
html.dark-mode,
@@ -196,6 +203,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 +255,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; }
@@ -304,6 +335,8 @@ html.dark-mode .qbo-field :is(label, .qbo-label),
html.dark-mode :is(.qbo-address, .qbo-estimate-amount-value, .qbo-estimate-totals th, .qbo-estimate-lines td.qbo-line-subtotal-label) { color: #c0c2c7; }
html.dark-mode .qbo-field :is(input[type=text], input[type=date], textarea) { background: #191a1c; color: #d2d4d8; }
html.dark-mode .qbo-field :is(input[readonly], input[disabled]) { background: #2c2e32; color: #c0c2c7; }
/* Locked estimates/invoices: their disabled boxes keep readable text */
html.dark-mode .qbo-estimate-sheet[disabled] :is(input, textarea, select) { color: #c0c2c7; -webkit-text-fill-color: #c0c2c7; }
html.dark-mode .qbo-estimate-lines th { border-bottom-color: #3f4248; }
html.dark-mode .qbo-estimate-lines td { border-bottom-color: #35373c; }
html.dark-mode .qbo-estimate-lines :is(input[type=text], textarea) { color: #d2d4d8; }
@@ -430,3 +463,40 @@ html.dark-mode .label-sub { color: #969aa1; }
html.dark-mode .box-white,
html.dark-mode div.issue_template { background-color: #1e1f20; }
html.dark-mode fieldset.issue { background-color: #191a1c; }
/* The dark "Are you sure?" dialog (dark_mode.js), in place of the browser's bright one */
dialog.dark-mode-confirm {
min-width: 320px;
max-width: min(90vw, 480px);
padding: 0;
border: 1px solid #3f4248;
border-radius: 8px;
background: #1e1f20;
color: #d2d4d8;
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
font-size: 1rem;
}
dialog.dark-mode-confirm::backdrop { background: rgba(0, 0, 0, 0.55); }
dialog.dark-mode-confirm p { margin: 0; padding: 20px 20px 16px; white-space: pre-line; }
.dark-mode-confirm-buttons {
display: flex;
justify-content: flex-end;
gap: 8px;
padding: 12px 16px;
border-top: 1px solid #3f4248;
background: #1b1c1e;
border-radius: 0 0 8px 8px;
}
.dark-mode-confirm-buttons button {
min-width: 80px;
padding: 6px 14px;
border: 1px solid #3f4248;
border-radius: 4px;
background: #2c2e32;
color: #d2d4d8;
font: inherit;
cursor: pointer;
}
.dark-mode-confirm-buttons button:hover { background: #35373c; }
.dark-mode-confirm-buttons button.dark-mode-confirm-ok { background: #4183c4; border-color: #4183c4; color: #fff; }
.dark-mode-confirm-buttons button.dark-mode-confirm-ok:hover { background: #548fca; border-color: #548fca; }
+1
View File
@@ -15,3 +15,4 @@ en:
label_dark_mode_dark: "On (dark)"
label_dark_mode_switch_dark: "Switch to dark mode"
label_dark_mode_switch_light: "Switch to light mode"
button_dark_mode_ok: "OK"
+1 -1
View File
@@ -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.1'
version '2026.11.6'
url 'https://github.com/rickbarrette/redmine_dark_mode'
author_url 'https://barrettefabrication.com'
requires_redmine version_or_higher: '7.0.0'
+6 -3
View File
@@ -9,9 +9,12 @@
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
module RedmineDarkMode
# A user's choice: follow the device (the default), or always light or dark
# A user's choice: follow the device, or always light or dark
MODES = %w[auto light dark].freeze
# Until someone chooses, Redmine follows their device
DEFAULT_MODE = 'auto'
def self.setup
UserPreference.prepend(RedmineDarkMode::UserPreferencePatch)
UserPreference.safe_attributes 'dark_mode'
@@ -20,9 +23,9 @@ module RedmineDarkMode
RedmineDarkMode::Hooks
end
# The mode for this user (anonymous users follow the device, or their browser's saved choice)
# The mode for this user: their choice, else the default (anonymous users: their browser's saved choice, else the default)
def self.mode_for(user)
mode = user&.logged? ? user.pref.dark_mode : nil
MODES.include?(mode) ? mode : 'auto'
MODES.include?(mode) ? mode : DEFAULT_MODE
end
end
+1 -1
View File
@@ -30,7 +30,7 @@ module RedmineDarkMode
get mode() { return mode; },
set: function (value) { mode = value; apply(); },
loggedIn: #{User.current.logged?.to_json},
labels: #{{ dark: l(:label_dark_mode_switch_dark), light: l(:label_dark_mode_switch_light) }.to_json}
labels: #{{ dark: l(:label_dark_mode_switch_dark), light: l(:label_dark_mode_switch_light), ok: l(:button_dark_mode_ok), cancel: l(:button_cancel) }.to_json}
};
apply();
if (media.addEventListener) media.addEventListener('change', apply);
@@ -12,11 +12,11 @@ module RedmineDarkMode
# Keeps the user's dark mode choice with their other preferences (My account)
module UserPreferencePatch
def dark_mode
self[:dark_mode].presence || 'auto'
self[:dark_mode].presence || RedmineDarkMode::DEFAULT_MODE
end
def dark_mode=(value)
self[:dark_mode] = RedmineDarkMode::MODES.include?(value.to_s) ? value.to_s : 'auto'
self[:dark_mode] = RedmineDarkMode::MODES.include?(value.to_s) ? value.to_s : RedmineDarkMode::DEFAULT_MODE
end
end
end