Merge pull request #1704 from mini-bomba/darkreader-proofing-the-dynamic-css

Darkreader-proofing the dynamic CSS variables
This commit is contained in:
Ajay Ramachandran
2023-03-22 00:11:22 -04:00
committed by GitHub

View File

@@ -2445,9 +2445,11 @@ function setCategoryColorCSSVariables() {
let css = ":root {" let css = ":root {"
for (const [category, config] of Object.entries(Config.config.barTypes)) { for (const [category, config] of Object.entries(Config.config.barTypes)) {
css += `--sb-category-${category}: ${config.color};`; css += `--sb-category-${category}: ${config.color};`;
css += `--darkreader-bg--sb-category-${category}: ${config.color};`;
const luminance = GenericUtils.getLuminance(config.color); const luminance = GenericUtils.getLuminance(config.color);
css += `--sb-category-text-${category}: ${luminance > 128 ? "black" : "white"};`; css += `--sb-category-text-${category}: ${luminance > 128 ? "black" : "white"};`;
css += `--darkreader-text--sb-category-text-${category}: ${luminance > 128 ? "black" : "white"};`;
} }
css += "}"; css += "}";