Closed Bug 2044712 Opened 1 month ago Closed 1 month ago

Expose colors and icons to extensions

Categories

(WebExtensions :: General, enhancement)

enhancement

Tracking

(firefox153 fixed)

RESOLVED FIXED
153 Branch
Tracking Status
firefox153 --- fixed

People

(Reporter: baku, Assigned: baku)

References

Details

(Keywords: dev-doc-complete)

Attachments

(1 file)

Currently, there is no exposed way to discover which colors and icons are available for add-ons to use with containers (there is just an MDN page).

This issue proposes exposing the complete list of available container colors and icons through a public API, so that add-ons can reliably use supported options.

Assignee: nobody → amarchesini
Status: NEW → ASSIGNED

Depending on the shape of the API, this could also potentially fix bug 1405780.

Although this is a Container feature, I'd like to move this to WebExtensions::General because it is about an external facing extension API, and putting it there would make it easier to follow up with documentation needs. Does that sound good to you?

See Also: → 1405780

Adding dev-doc-needed so that this API can be documented.

The API does not introduce a new image format, it just returns a list of objects describing the supported color names and icons.
This bug will therefore not fix bug 1405780.

The note below is merely informative, it should NOT be documented on MDN as part of the public API because its behavior may be subject to change.

The way that the multi-account container extension colorizes their icons right now is through a SVG filter, introduced in https://github.com/mozilla/multi-account-containers/commit/53363865cb722e124f40da9f1d01a499f9fd4732

A fully-self contained example based on that technique is the following, showing a red briefcase (instead of black):

data:text/html,<div style='
width: 32px;
height: 32px;
background-image: url("resource://usercontext-content/briefcase.svg");
fill: red;
filter: url(&apos;data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg"><filter id="fill"><feComposite in="FillPaint" in2="SourceGraphic" operator="in"/></filter></svg>&num;fill&apos;);
'></div>

or even just an <img> instead of a background image:

data:text/html,<img src="resource://usercontext-content/briefcase.svg"
style='fill: red;
filter: url(&apos;data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg"><filter id="fill"><feComposite in="FillPaint" in2="SourceGraphic" operator="in"/></filter></svg>&num;fill&apos;);
'>

I hardcoded resource://usercontext-content/briefcase.svg in the above examples, but with the new API one could just fill in iconUrl and color.
This depends on the ability to specify an additional SVG filter to apply to the existing SVG. In HTML of extension pages that works because we can use HTML, but in browser UI that does not work, hence bug 1405780 remains open.

Component: Containers → General
Keywords: dev-doc-needed
Product: Firefox → WebExtensions
Status: ASSIGNED → RESOLVED
Closed: 1 month ago
Resolution: --- → FIXED
Target Milestone: --- → 153 Branch
See Also: → 2044354
See Also: → 2045986
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: