summaryrefslogtreecommitdiffstats
path: root/static/app.js
diff options
context:
space:
mode:
authorGab Virebent <gabriel1@virebent.art>2026-07-02 03:58:31 +0200
committerGab Virebent <gabriel1@virebent.art>2026-07-02 03:58:31 +0200
commit52eb46afad75d76c707ed11bbddddbcf5e121deb (patch)
tree728a5590c028e16a8a824274b7657b235439fea2 /static/app.js
parent4da18fe598f243c777d330ba9d50f1ecd4382b05 (diff)
downloadnymdrop-52eb46afad75d76c707ed11bbddddbcf5e121deb.tar.gz
nymdrop-52eb46afad75d76c707ed11bbddddbcf5e121deb.tar.xz
nymdrop-52eb46afad75d76c707ed11bbddddbcf5e121deb.zip
Add light/dark theme toggle, fix dark theme text contrast
Theme state persists via localStorage, applied pre-paint by theme-init.js to avoid flash. All JS moved to external files (app.js, theme-init.js) to keep script-src 'self' CSP intact, no inline scripts. Dark theme footer/notice/tagline colors were too close to the background (footer nearly matched the card border color) and hard to read; brightened to readable grays while leaving the light theme and submit button untouched.
Diffstat (limited to 'static/app.js')
-rw-r--r--static/app.js30
1 files changed, 30 insertions, 0 deletions
diff --git a/static/app.js b/static/app.js
new file mode 100644
index 0000000..1168281
--- /dev/null
+++ b/static/app.js
@@ -0,0 +1,30 @@
+document.getElementById('file').addEventListener('change', function() {
+ const name = this.files.length ? this.files[0].name : '';
+ document.getElementById('filename').textContent = name;
+});
+
+(function() {
+ var toggleBtn = document.getElementById('theme-toggle');
+
+ function isLight() {
+ return document.documentElement.getAttribute('data-theme') === 'light';
+ }
+
+ function updateIcon() {
+ // Shows the icon for the theme you'd switch TO.
+ toggleBtn.textContent = isLight() ? '\u{1F319}' : '☀️';
+ }
+
+ toggleBtn.addEventListener('click', function() {
+ if (isLight()) {
+ document.documentElement.removeAttribute('data-theme');
+ localStorage.setItem('nymdrop-theme', 'dark');
+ } else {
+ document.documentElement.setAttribute('data-theme', 'light');
+ localStorage.setItem('nymdrop-theme', 'light');
+ }
+ updateIcon();
+ });
+
+ updateIcon();
+})();