Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

firefox pick page action icon for dark / light themes

I'm writing a web extension works on firefox. I want my icon works similar to the behavior of Firefox built in "Take a screenshot". The screenshot icon appeared in different colors when it shown in light theme / dark theme / in the menu.

I just added a page_action in manifest, and set an icon for it. The black icon looks ok on light theme, but become hard to use on dark theme. I want show light version of icon if browser is in dark theme (And also keep the icon in the menu black).

I had searched something about this, and find browser_action support theme_icons but page_action not.

What is the best practices to set different icons for different use case of page action icon?

enter image description here

What is the best prestic to config different icon color for different theme?

like image 435
tsh Avatar asked Jan 31 '18 10:01

tsh


People also ask

How do I change the light or dark theme in Firefox?

To change your settings within the browser, tap the three-dot menu in the bottom-right corner, select Settings, then Customize, and choose between Light, Dark, or Follow device theme.

Does Firefox have force dark mode?

You can do that by clicking “Themes” on the left side of the screen. You will see the “Dark” theme. Click on the “Enable” button to immediately activate the dark mode for the browser. Note: If you have Firefox Sync turned on, dark mode will be activated on all your Firefox installs.


2 Answers

After more google search, I found that this is implemented by screenshot add-on by adding fill="context-fill" fill-opacity="context-fill-opacity" on <svg> tag, and using svg for icon.

<?xml version="1.0" encoding="UTF-8"?>
<svg width="128px" height="128px" version="1.1" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="context-fill" fill-opacity="context-fill-opacity">
  <path d="m0 0 H 16 V 16 H 0 Z"/>
</svg>

But unfortunately, this feature only enabled by default on mozilla-signed extensions. So this won't work on user defined extension.

Checkout bugzilla for more detail:

  • Bug 1377302 - Support fill="context-fill" for mozilla-signed WebExtension icons
like image 68
tsh Avatar answered Oct 18 '22 23:10

tsh


According to Bug 1377302, context-fill doesn't work because svg.context-properties.content.enabled is not enabled by default. The same pages says it was fixed in Firefox 55, but I'm using 60 and it is still not fixed.

So, right now, I would still use context-fill hoping that, in the near future, users will see the icon with the same color as the rest of the icons.

like image 2
Nil Vila Avatar answered Oct 19 '22 00:10

Nil Vila