You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you save this icon into a file and load it as a custom icon (file) for a panel, it will be black in light mode and white in dark mode. Whenever you switch the device light mode the icon color changes.
However for most of the other SVG icon files I tried, this does not work: it will appear with the correct color (based on the device light mode) upon load but will keep this color when device light mode is switched.
Here is an example of an icon file that stays to the same color:
Since I tried various icons I realized that the only icons that "worked" were small icons, that is in size (kB). Whenever the path is big, it will not work.
After digging into the code I realized the problems comes from an optimization that Sideberry does when loading a custom icon, this happens in the function resizeFavicon
This functions makes a copy of the icon loaded, and saves it as PNG. Therefore any CSS styles are lost.
This optimization is skipped for small SVG files because of this check:
Steps to reproduce
Actual behavior
The color of the icon does not change (except for very small SVG icons, more on that in the description)
Expected behavior
The color of the icon should update based on the device light mode
System
Arch Linux
Firefox version
133
Sidebery version
5.2.0
Logs
no logs
Why I am using CSS media queries in icons
I am using CSS media query to update icon colors based on device light setting (dark or light), here is an example:
If you save this icon into a file and load it as a custom icon (file) for a panel, it will be black in light mode and white in dark mode. Whenever you switch the device light mode the icon color changes.
However for most of the other SVG icon files I tried, this does not work: it will appear with the correct color (based on the device light mode) upon load but will keep this color when device light mode is switched.
Here is an example of an icon file that stays to the same color:
Explanation
Since I tried various icons I realized that the only icons that "worked" were small icons, that is in size (kB). Whenever the path is big, it will not work.
After digging into the code I realized the problems comes from an optimization that Sideberry does when loading a custom icon, this happens in the function resizeFavicon
This functions makes a copy of the icon loaded, and saves it as PNG. Therefore any CSS styles are lost.
This optimization is skipped for small SVG files because of this check:
where:
So if resulting icon is larger by 300 bytes (in my case
window.devicePixelRatio
= 2 according to FF) than original icon, the operation is skipped.Proposal to allow media queries to work
May be this optimization could be disabled for SVG icons?
The text was updated successfully, but these errors were encountered: