From 798f3499fc201535783980cb5a9e868f9d590cdb Mon Sep 17 00:00:00 2001 From: gi8 Date: Wed, 20 Dec 2023 12:19:11 +0100 Subject: [PATCH] fix theme again because i didnt test it --- cmd/root.go | 2 +- web/static/js/vimbin.js | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index f7cc58a..8cdf343 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -30,7 +30,7 @@ import ( ) const ( - version = "v0.0.13" + version = "v0.0.14" ) var ( diff --git a/web/static/js/vimbin.js b/web/static/js/vimbin.js index f2c5f12..70de013 100644 --- a/web/static/js/vimbin.js +++ b/web/static/js/vimbin.js @@ -1,19 +1,25 @@ document.addEventListener("DOMContentLoaded", function () { // Function to get the preferred theme (dark, light, or system default) function getPreferredTheme() { - return window.matchMedia?.("(prefers-color-scheme: dark)")?.matches - ? "catppuccin" - : "default"; + const prefersDarkMode = window.matchMedia?.( + "(prefers-color-scheme: dark)", + )?.matches; + + // If theme is set to "dark" or "auto" and the user prefers dark mode, return "catppuccino" + if ((theme === "auto" || theme === "dark") && prefersDarkMode) { + return "catppuccin"; + } + + // For any other case, return "light" + return "light"; } // Function to set the theme based on the initial color scheme or the 'theme' variable function setThemeBasedOnColorScheme() { - const preferredTheme = theme || getPreferredTheme(); + const preferredTheme = getPreferredTheme(); console.log(`Setting theme to '${preferredTheme}'`); - editor.setOption("theme", preferredTheme); } - // Function to update Vim mode display function updateVimMode(vimEvent, vimModeElement) { const { mode, subMode } = vimEvent;