From e88e236f6bb69171b24459aedb72e6d7e9ffa892 Mon Sep 17 00:00:00 2001 From: ItsLemmy Date: Sun, 5 Oct 2025 19:10:29 -0400 Subject: [PATCH] Vesktop: better light theme support for predefined colorscheme --- Helpers/ColorVariants.js | 34 ++++++++++++++++++++++++---------- Services/MatugenService.qml | 12 ++++++------ 2 files changed, 30 insertions(+), 16 deletions(-) diff --git a/Helpers/ColorVariants.js b/Helpers/ColorVariants.js index 32405961b..8441c7c40 100644 --- a/Helpers/ColorVariants.js +++ b/Helpers/ColorVariants.js @@ -97,13 +97,21 @@ function hslToHex(h, s, l) { * Generate fixed_dim variant (darker, muted version) * Material 3 fixed_dim is typically 20-30% darker */ -function generateFixedDim(hexColor) { +function generateFixedDim(hexColor, isDarkTheme = false) { const hsl = hexToHSL(hexColor); if (!hsl) return hexColor; - // Reduce lightness by 25-30% and slightly reduce saturation - const newL = Math.max(hsl.l * 0.7, 10); - const newS = Math.max(hsl.s * 0.85, 5); + let newL, newS; + + if (isDarkTheme) { + // Dark theme: make it dimmer but not too dark (aim for 15-25 lightness) + newL = Math.max(hsl.l * 0.6, 15); + newS = Math.max(hsl.s * 0.7, 15); + } else { + // Light theme: reduce lightness by 25-30% and slightly reduce saturation + newL = Math.max(hsl.l * 0.7, 10); + newS = Math.max(hsl.s * 0.85, 5); + } return hslToHex(hsl.h, newS, newL); } @@ -112,13 +120,20 @@ function generateFixedDim(hexColor) { * Generate bright variant (lighter, more vibrant version) * Material 3 bright is typically 15-25% lighter with boosted saturation */ -function generateBright(hexColor) { +function generateBright(hexColor, isDarkTheme = false) { const hsl = hexToHSL(hexColor); if (!hsl) return hexColor; - - // Increase lightness by 20-25% and boost saturation - const newL = Math.min(hsl.l * 1.25, 90); - const newS = Math.min(hsl.s * 1.1, 100); + + let newL, newS; + if (isDarkTheme) { + // Dark theme: brighten significantly but cap to avoid washing out (aim for 40-60 lightness) + newL = Math.min(hsl.l * 1.5, 60); + newS = Math.min(hsl.s * 1.15, 100); + } else { + // Light theme: increase lightness by 20-25% and boost saturation + newL = Math.min(hsl.l * 1.25, 90); + newS = Math.min(hsl.s * 1.1, 100); + } return hslToHex(hsl.h, newS, newL); } @@ -132,7 +147,6 @@ function generateContainer(hexColor, isDarkTheme = false) { if (!hsl) return hexColor; let newL, newS; - if (isDarkTheme) { // Dark theme: darken the color (aim for 10-20 lightness) newL = Math.max(hsl.l - (hsl.l - 15) * 0.85, 10); diff --git a/Services/MatugenService.qml b/Services/MatugenService.qml index ed7a91b35..0910f7ec3 100644 --- a/Services/MatugenService.qml +++ b/Services/MatugenService.qml @@ -335,24 +335,24 @@ Singleton { }, "surface_container_high": { "light": { - "color": ColorVariants.generateBright(ColorVariants.generateContainer(variant.mSurface, false)) + "color": ColorVariants.generateBright(ColorVariants.generateContainer(variant.mSurface, false), false) }, "default": { - "color": ColorVariants.generateBright(ColorVariants.generateContainer(variant.mSurface, true)) + "color": ColorVariants.generateBright(ColorVariants.generateContainer(variant.mSurface, true), true) }, "dark": { - "color": ColorVariants.generateBright(ColorVariants.generateContainer(variant.mSurface, true)) + "color": ColorVariants.generateBright(ColorVariants.generateContainer(variant.mSurface, true), true) } }, "surface_container_highest": { "light": { - "color": ColorVariants.generateBright(ColorVariants.generateBright(ColorVariants.generateContainer(variant.mSurface, false))) + "color": ColorVariants.generateBright(ColorVariants.generateBright(ColorVariants.generateContainer(variant.mSurface, false), false), false) }, "default": { - "color": ColorVariants.generateBright(ColorVariants.generateBright(ColorVariants.generateContainer(variant.mSurface, true))) + "color": ColorVariants.generateBright(ColorVariants.generateBright(ColorVariants.generateContainer(variant.mSurface, true), true), true) }, "dark": { - "color": ColorVariants.generateBright(ColorVariants.generateBright(ColorVariants.generateContainer(variant.mSurface, true))) + "color": ColorVariants.generateBright(ColorVariants.generateBright(ColorVariants.generateContainer(variant.mSurface, true), true), true) } } }