-
Notifications
You must be signed in to change notification settings - Fork 21
Add dark mode support #84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Added theme setting functionality and updated iframe styles.
There was a problem hiding this 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.
| const theme = prefersDark ? 'dark' : 'light'; | ||
| document.documentElement.style.colorScheme = theme; |
Copilot
AI
Dec 22, 2025
There was a problem hiding this comment.
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.
| const theme = prefersDark ? 'dark' : 'light'; | |
| document.documentElement.style.colorScheme = theme; | |
| const computedTheme = prefersDark ? 'dark' : 'light'; | |
| document.documentElement.style.colorScheme = computedTheme; |
| 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
AI
Dec 22, 2025
There was a problem hiding this comment.
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.
| 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 = ''; | |
| } |
| settingsCheckbox("settings-nopacket", "noPackets"); | ||
| loadSettings(); | ||
|
|
||
| selectTheme = document.getElementById("settings-theme"); |
Copilot
AI
Dec 22, 2025
There was a problem hiding this comment.
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.
| selectTheme = document.getElementById("settings-theme"); | |
| const selectTheme = document.getElementById("settings-theme"); |
|
|
||
|
|
||
|
|
Copilot
AI
Dec 22, 2025
There was a problem hiding this comment.
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.
| // 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'; |
Copilot
AI
Dec 22, 2025
There was a problem hiding this comment.
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.
| // 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"; |
| else{ | ||
|
|
||
| const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches; | ||
| console.log(prefersDark) |
Copilot
AI
Dec 22, 2025
There was a problem hiding this comment.
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.
| console.log(prefersDark) |
| const bgColor = window.matchMedia('(prefers-color-scheme: dark)').matches ? '#2c2c2c' : '#ffffff'; | ||
| const textColor = window.matchMedia('(prefers-color-scheme: dark)').matches ? '#FFFFFF' : '#000000'; |
Copilot
AI
Dec 22, 2025
There was a problem hiding this comment.
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.
| 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'; |
| <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;"> |
Copilot
AI
Dec 22, 2025
There was a problem hiding this comment.
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.
| <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;"> |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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: