-
Notifications
You must be signed in to change notification settings - Fork 7
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
Dark theme font issue #42
Comments
Do you mean the icon? The popup? The popup should work well in a dark theme (#30). For the icon, you can customize the colors in the add-on preferences. Sure, it would be nice to make it work automatically, but the wbextensions APIs don't let me specify different icons for light and dark themes (bug 1484840). |
Wait, seems I can use |
It will be kind of annoying having to decide whether to use light or dark text by myself, since technically this may depend on various factors I don't have control over, but I guess I can try to replicate what Firefox does in the toolbar/tabbar: https://searchfox.org/mozilla-central/rev/8f4c180b87e52f3345ef8a3432d6e54bd1eb18dc/browser/base/content/browser.js#9008-9035// The getComputedStyle calls and setting the brighttext are separated in
// two loops to avoid flushing layout and making it dirty repeatedly.
let cachedLuminances = this._toolbarLuminanceCache;
let luminances = new Map();
for (let toolbar of document.querySelectorAll(toolbarSelector)) {
// toolbars *should* all have ids, but guard anyway to avoid blowing up
let cacheKey =
toolbar.id && toolbar.id + JSON.stringify(this._windowState);
// lookup cached luminance value for this toolbar in this window state
let luminance = cacheKey && cachedLuminances.get(cacheKey);
if (isNaN(luminance)) {
let [r, g, b] = parseRGB(getComputedStyle(toolbar).color);
luminance = 0.2125 * r + 0.7154 * g + 0.0721 * b;
if (cacheKey) {
cachedLuminances.set(cacheKey, luminance);
}
}
luminances.set(toolbar, luminance);
}
const luminanceThreshold = 127; // In between 0 and 255
for (let [toolbar, luminance] of luminances) {
if (luminance <= luminanceThreshold) {
toolbar.removeAttribute("brighttext");
} else {
toolbar.setAttribute("brighttext", "true");
}
} Where For the overflow menu, Firefox uses https://searchfox.org/mozilla-central/rev/8f4c180b87e52f3345ef8a3432d6e54bd1eb18dc/toolkit/modules/LightweightThemeConsumer.jsm#85-91,508-510let { r, g, b, a } = rgbaChannels;
if (_isColorDark(r, g, b)) {
element.removeAttribute("lwt-popup-brighttext");
} else {
element.setAttribute("lwt-popup-brighttext", "true");
} function _isColorDark(r, g, b) {
return 0.2125 * r + 0.7154 * g + 0.0721 * b <= 127;
} |
Just FYI, it looks good to me with a dark theme. I do manually set the foreground color, but you've made it so easy. :) |
This is what Firefox uses (1st available color):
I can't actually know where the action is, but by default it appears in the navigation toolbar.
Just for SVG icons, I don't think this makes much sense for badges. Catch: different windows may have different themes. By default I'm already tracking windows and using a different icon per window, so not a big deal. But when counting tabs globally, I will need to be careful. |
If Firefox use dark theme the number of the extension is not visible,because its dark too.
So maybe if its possible it must to match with the UI color theme
The text was updated successfully, but these errors were encountered: