Skip to content

Commit

Permalink
Moved schema to examples, added a generic schema, and a comma
Browse files Browse the repository at this point in the history
This incorporates the kernel of what Simeon discussed in WECG and
recommended in
#585 (comment).
It's not meant to replace that comment, but only to introduce it here
for clarity, while allowing Simeon to update it as needed once this PR
is merged.

Added a fuzzy matching section again even though someone suggested it
be removed earlier. It was introduced in 6e6af62, but removed in a
subsequent "Commit suggestion" from somoene on GitHub. It's worth
calling out here at some point, so it might as well be in this PR,
which is already approved but still awaiting someone with the ability
to go ahead and merge it.

Some of these changes may foster discussion, which is completely
understandable.
  • Loading branch information
solomonkinard committed May 1, 2024
1 parent c37fc62 commit c815458
Showing 1 changed file with 48 additions and 5 deletions.
53 changes: 48 additions & 5 deletions proposals/dark_mode_extension_icons.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Feature to enable developers to enhance extension icon visibility in dark mode.

**Sponsoring Browser:** Chromium

**Contributors:** oliverdunk, xeenon, carlosjeurissen, hanguokai
**Contributors:** oliverdunk, xeenon, carlosjeurissen, hanguokai, dotproto

**Created:** 2024-04-05

Expand Down Expand Up @@ -45,6 +45,44 @@ The Chromium bug has a significant amount of developer interest.

### Schema

manifest.json
```
type ImagePath = string;
type ColorScheme = "light" | "dark";
interface IconVariantsBase {
color_scheme?: ColorScheme | ColorScheme[];
}
interface IconVariantsManifest extends IconVariantsBase {
any?: ImagePath;
[index: number]: ImagePath;
}
interface ManifestAction {
[icon_variants: string]: IconVariantsManifest;
}
interface ExtensionManifest {
icon_variants: IconVariantsManifest[];
action: Action;
}
```

action.setIcon
```
interface SetIconVariantsApiDetails extends IconVariantsBase {
any?: ImagePath | ImageData;
[index: number]: ImagePath | ImageData;
}
interface SetIconVariantsApi {
[variants: string]: ActionIconVariants;
}
```

### Examples

manifest.json
```
"icon_variants": [
Expand All @@ -65,7 +103,10 @@ manifest.json
"32": "light32.png",
"color_scheme": ["dark", "light"]
}
]
],
"action": {
"icon_variants": [...]
}
```
`icon_variants` requires an array with a set of icon groups objects. Each icon
group consists of a set of icon paths and icon group matching criteria.
Expand Down Expand Up @@ -185,7 +226,9 @@ warning. For example, `color_scheme: ["unknown"]` will be treated as an empty
array. An empty array means the browser should mark the icon group as invalid
and ignore it.
1. If only one icon object is defined with a specific color scheme, that icon
object will be applied to all color schemes. It will be the icon used.
object will be applied to all color schemes.
1. **Fuzzy matching** Inexact size matches will return the icon closest in size,
starting with smaller sizes if available, retreating to the nearest larger size.

**Size**
1. The `"16"` is a size in `{"16": "icon.png"}` and any number can be used as a
Expand All @@ -199,7 +242,7 @@ the next largest pixel size or `"any"` will be used.
1. **Vector images**: Sizes are in points, ensuring device independence. If the
exact point size is unavailable, an integer multiple (e.g. 32, 48, etc.) or
`"any"` will be used.
* If none of the specified icon groups have matching criteria, browsers should
1. If none of the specified icon groups have matching criteria, browsers should
drop matching criteria in a specified order until it finds a group which results
in a match. It will start by dropping any matching criteria which are
unsupported/unknown. If still no match could be made, it will drop known
Expand All @@ -213,7 +256,7 @@ action. If not specified, it falls back to default_icon, then to the top-level
`icon_variants` or icons.
1. `action.setIcon({variants})` will not throw when giving it icon groups with
properties it does not understand. Those icon groups will simply be ignored for
making matches. If however none of the icon groups are supported, an exception
making matches. If however, none of the icon groups are supported, an exception
will be thrown allowing both feature detection and specifying fallbacks without
requiring feature detection.

Expand Down

0 comments on commit c815458

Please sign in to comment.