Skip to content

Conversation

@RKBoss6
Copy link
Contributor

@RKBoss6 RKBoss6 commented Dec 22, 2025

In conjunction with #4103, this helps add dark mode to the app loader. Adding dark mode helps significantly with eye strain, and blending into the device's UI. Check it out on my personal app loader! and let me know of any suggestions/comments.

Specifically, this PR handles ensuring the right theme is displayed, and theming of app html customizer iframes.

Screenshots:

Screenshot 2025-12-22 at 1 54 05 PM
Screenshot 2025-12-22 at 1 54 14 PM Screenshot 2025-12-22 at 1 54 22 PM

Added theme setting functionality and updated iframe styles.
Copilot AI review requested due to automatic review settings December 22, 2025 19:13
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds dark mode support to the app loader with three theme options: light, dark, and device (follows system preference). The implementation handles theme persistence in settings, dynamic theme application, and extends dark mode styling to app customizer iframes.

Key Changes:

  • Added theme setting with three modes: light, dark, and device
  • Implemented theme application logic that respects user preferences and system settings
  • Applied dark mode styling to app customizer iframes

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1446 to +1447
const theme = prefersDark ? 'dark' : 'light';
document.documentElement.style.colorScheme = theme;
Copy link

Copilot AI Dec 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The local variable 'theme' shadows the function parameter with the same name. Consider renaming this variable to something like 'computedTheme' or 'resolvedTheme' to avoid confusion.

Suggested change
const theme = prefersDark ? 'dark' : 'light';
document.documentElement.style.colorScheme = theme;
const computedTheme = prefersDark ? 'dark' : 'light';
document.documentElement.style.colorScheme = computedTheme;

Copilot uses AI. Check for mistakes.
Comment on lines +1450 to +1456
function repaintSite(){
//tricks browser into repainting the site to apply theme changes
const body = document.body;
body.style.display = 'none';
body.offsetHeight;
body.style.display = '';
}
Copy link

Copilot AI Dec 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The repaintSite function is defined but never called anywhere in the code. This function should either be removed or integrated into the theme application logic if it's needed.

Suggested change
function repaintSite(){
//tricks browser into repainting the site to apply theme changes
const body = document.body;
body.style.display = 'none';
body.offsetHeight;
body.style.display = '';
}

Copilot uses AI. Check for mistakes.
settingsCheckbox("settings-nopacket", "noPackets");
loadSettings();

selectTheme = document.getElementById("settings-theme");
Copy link

Copilot AI Dec 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable 'selectTheme' is not declared with 'let', 'const', or 'var', making it an implicit global variable. Add 'const' or 'let' before 'selectTheme' to properly declare it.

Suggested change
selectTheme = document.getElementById("settings-theme");
const selectTheme = document.getElementById("settings-theme");

Copilot uses AI. Check for mistakes.
Comment on lines +29 to +31



Copy link

Copilot AI Dec 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These blank lines appear to be unnecessary and should be removed to maintain code consistency.

Suggested change

Copilot uses AI. Check for mistakes.
Comment on lines +320 to +324
// Style custom apps for dark mode
const iframeDoc = iframe.contentDocument || iframe.contentWindow.document;
if (iframeDoc && iframeDoc.body) {
const bgColor = window.matchMedia('(prefers-color-scheme: dark)').matches ? '#2c2c2c' : '#ffffff';
const textColor = window.matchMedia('(prefers-color-scheme: dark)').matches ? '#FFFFFF' : '#000000';
Copy link

Copilot AI Dec 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The iframe styling always checks the system's color scheme preference using matchMedia, but it should respect the user's theme setting (SETTINGS.theme) instead. When the user selects "light" or "dark" explicitly, the iframe should use that theme rather than always following the system preference. Consider using the applyTheme logic or a similar approach to determine which theme to apply based on SETTINGS.theme.

Suggested change
// Style custom apps for dark mode
const iframeDoc = iframe.contentDocument || iframe.contentWindow.document;
if (iframeDoc && iframeDoc.body) {
const bgColor = window.matchMedia('(prefers-color-scheme: dark)').matches ? '#2c2c2c' : '#ffffff';
const textColor = window.matchMedia('(prefers-color-scheme: dark)').matches ? '#FFFFFF' : '#000000';
// Style custom apps according to theme (light/dark/device)
const iframeDoc = iframe.contentDocument || iframe.contentWindow.document;
if (iframeDoc && iframeDoc.body) {
// Determine effective theme: use SETTINGS.theme if available, otherwise default
const currentSettings = (typeof SETTINGS !== "undefined" && SETTINGS) ? SETTINGS : DEFAULTSETTINGS;
const theme = currentSettings && currentSettings.theme ? currentSettings.theme : DEFAULTSETTINGS.theme;
const prefersDark = window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches;
const isDark = theme === "dark" || (theme === "device" && prefersDark);
const bgColor = isDark ? "#2c2c2c" : "#ffffff";
const textColor = isDark ? "#FFFFFF" : "#000000";

Copilot uses AI. Check for mistakes.
else{

const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
console.log(prefersDark)
Copy link

Copilot AI Dec 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This console.log statement appears to be a leftover debug statement and should be removed.

Suggested change
console.log(prefersDark)

Copilot uses AI. Check for mistakes.
Comment on lines +323 to +324
const bgColor = window.matchMedia('(prefers-color-scheme: dark)').matches ? '#2c2c2c' : '#ffffff';
const textColor = window.matchMedia('(prefers-color-scheme: dark)').matches ? '#FFFFFF' : '#000000';
Copy link

Copilot AI Dec 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The matchMedia check is duplicated for both bgColor and textColor. Consider storing the result in a variable to avoid checking twice.

Suggested change
const bgColor = window.matchMedia('(prefers-color-scheme: dark)').matches ? '#2c2c2c' : '#ffffff';
const textColor = window.matchMedia('(prefers-color-scheme: dark)').matches ? '#FFFFFF' : '#000000';
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
const bgColor = prefersDark ? '#2c2c2c' : '#ffffff';
const textColor = prefersDark ? '#FFFFFF' : '#000000';

Copilot uses AI. Check for mistakes.
<div class="modal-body" style="height:100%">
<div class="content" style="height:100%">
<iframe src="apps/${appTemplate.id}/${appTemplate.custom}" style="width:100%;height:100%;border:0px;">
<iframe class="modal-iframe" src="apps/${appTemplate.id}/${appTemplate.custom}" style="width:100%;height:100%;border:0px;">
Copy link

Copilot AI Dec 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 'modal-iframe' class is added to the iframe element but is not used anywhere in the codebase (no CSS rules or JavaScript selectors reference it). Consider removing this class if it's not needed, or ensure the corresponding styles are added if it's intended for styling.

Suggested change
<iframe class="modal-iframe" src="apps/${appTemplate.id}/${appTemplate.custom}" style="width:100%;height:100%;border:0px;">
<iframe src="apps/${appTemplate.id}/${appTemplate.custom}" style="width:100%;height:100%;border:0px;">

Copilot uses AI. Check for mistakes.
RKBoss6 and others added 2 commits December 22, 2025 14:19
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant