Skip to content
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-mode: Add a proposal for dark mode extension icons #585

Merged
merged 56 commits into from
May 9, 2024
Merged
Changes from 2 commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
2a58213
dark-mode: Add a proposal for dark mode extension icons
solomonkinard Apr 5, 2024
9d65c2f
dark-mode: Add a proposal for dark mode extension icons
solomonkinard Apr 5, 2024
67b5762
dark-mode: Add a proposal for dark mode extension icons
solomonkinard Apr 5, 2024
447c704
dark-mode: Add a proposal for dark mode extension icons
solomonkinard Apr 5, 2024
7773648
dark-mode: Add a proposal for dark mode extension icons
solomonkinard Apr 5, 2024
3aa4866
Update proposals/dark_mode_extension_icons.md
solomonkinard Apr 9, 2024
b0ce301
dark-mode: Add a proposal for dark mode extension icons
solomonkinard Apr 9, 2024
5826697
dark-mode: Add a proposal for dark mode extension icons
solomonkinard Apr 9, 2024
dc86a8a
main: Format FAQ
solomonkinard Apr 9, 2024
b4504c1
Use TypeScript where possible in the schema and reinvented ImageData
solomonkinard Apr 10, 2024
c398b05
main: Add an option in the case that neither icon nor light mode exist
solomonkinard Apr 10, 2024
fc9a84e
main: Incorporate ideas from the meeting and the review comments
solomonkinard Apr 12, 2024
45c4448
Addressed comments in the thread and removed options with no attention
solomonkinard Apr 18, 2024
cc24421
Include any in manifest.json and use the same style
solomonkinard Apr 18, 2024
0bc8701
Include array of {"color_scheme": ["dark", "light"]} to cover all cases
solomonkinard Apr 19, 2024
29be8c9
Removed TODO
solomonkinard Apr 19, 2024
5fe0b84
Update proposals/dark_mode_extension_icons.md
solomonkinard Apr 19, 2024
dae3dec
Update proposals/dark_mode_extension_icons.md
solomonkinard Apr 19, 2024
e577b20
Update proposals/dark_mode_extension_icons.md
solomonkinard Apr 19, 2024
f3ab3cf
Update proposals/dark_mode_extension_icons.md
solomonkinard Apr 19, 2024
bf6d0ea
Update proposals/dark_mode_extension_icons.md
solomonkinard Apr 19, 2024
c76a737
Update proposals/dark_mode_extension_icons.md
solomonkinard Apr 19, 2024
27e1fc5
Address comments
solomonkinard Apr 19, 2024
96ffdef
Update proposals/dark_mode_extension_icons.md
solomonkinard Apr 23, 2024
6773528
Update proposals/dark_mode_extension_icons.md
solomonkinard Apr 23, 2024
5b1c668
Update proposals/dark_mode_extension_icons.md
solomonkinard Apr 23, 2024
bfc0f75
main: Line wrap and nest bullets
solomonkinard Apr 23, 2024
e3f3c28
main: Addressed remaining comments
solomonkinard Apr 23, 2024
6e6af62
main: Flesh out more defined behavior for a myriad of cases
solomonkinard Apr 24, 2024
9f15f4c
Update proposals/dark_mode_extension_icons.md
solomonkinard Apr 24, 2024
4a514e6
Update proposals/dark_mode_extension_icons.md
solomonkinard Apr 24, 2024
47c80c2
Update proposals/dark_mode_extension_icons.md
solomonkinard Apr 24, 2024
f78f34b
Update proposals/dark_mode_extension_icons.md
solomonkinard Apr 24, 2024
96613e3
Apply suggestions from code review
solomonkinard Apr 24, 2024
58017e1
Apply suggestions from code review
solomonkinard Apr 24, 2024
8345783
Apply suggestions from code review
solomonkinard Apr 25, 2024
da8166f
Apply suggestions from code review
solomonkinard Apr 25, 2024
3f70cb4
Addressed comment
solomonkinard Apr 25, 2024
da5db34
Update proposals/dark_mode_extension_icons.md
solomonkinard Apr 26, 2024
f6567e0
Update proposals/dark_mode_extension_icons.md
solomonkinard Apr 29, 2024
d2d9daa
Update proposals/dark_mode_extension_icons.md
solomonkinard Apr 29, 2024
ee129e8
Update proposals/dark_mode_extension_icons.md
solomonkinard Apr 29, 2024
c7583cc
Apply an unclickable outdated commit, line wrap, and organize rules
solomonkinard Apr 29, 2024
35f1c96
Include API in the heading
solomonkinard Apr 29, 2024
bc73bef
Pull in wording from the doc
solomonkinard Apr 29, 2024
bdbefd6
Added a summary and organized sections
solomonkinard Apr 29, 2024
25c570b
Labeled the summary
solomonkinard Apr 29, 2024
932ddf4
Update proposals/dark_mode_extension_icons.md
solomonkinard Apr 29, 2024
6f2fc51
Update proposals/dark_mode_extension_icons.md
solomonkinard Apr 29, 2024
2bf510f
Update proposals/dark_mode_extension_icons.md
solomonkinard Apr 29, 2024
c37fc62
Update proposals/dark_mode_extension_icons.md
solomonkinard May 1, 2024
c815458
Moved schema to examples, added a generic schema, and a comma
solomonkinard May 1, 2024
26a3ff2
Update proposals/dark_mode_extension_icons.md
solomonkinard May 9, 2024
7f82152
Removed the TypeScript section recommended by Simeon, for faster merge
solomonkinard May 9, 2024
e1b23de
Only one mime-type per icon group as per the conversation
solomonkinard May 9, 2024
86e7051
Clarify what happens if more than one type is present in an icon group
solomonkinard May 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
205 changes: 205 additions & 0 deletions proposals/dark_mode_extension_icons.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
# Dark Mode Extension Icons

**Summary**

Feature to enable developers to enhance extension icon visibility in dark mode.

**Document Metadata**

**Author:** <solomonkinard>

**Sponsoring Browser:** Chromium.

**Contributors:** <oliverdunk>

**Created:** 2024-04-05

**Related Issues:**
* https://crbug.com/893175
* https://github.com/w3c/webextensions/issues/229

## Motivation

### Objective

Extension developers will be able to supply and define a set of icons to be used
in the event that browser system settings are set to dark mode. The set of dark
solomonkinard marked this conversation as resolved.
Show resolved Hide resolved
mode icons can and will be made automatically visible once the system setting is
in dark mode, thereby enhancing the overall browser experience.

#### Use Cases

1. Improved icon visibility in the extension toolbar.
1. Improved icon visibility on management the management and shortcuts pages.
solomonkinard marked this conversation as resolved.
Show resolved Hide resolved
1. Dark mode icon declarations made possible through the extension manifest.
1. setIcon() will allow setting of dark and/or light mode specific icons.
solomonkinard marked this conversation as resolved.
Show resolved Hide resolved
1. Improved icon visibility on context menu (Chrome and Safari reply on default icons, only Firefox can specify icons).
1. Improved icon visibility on side panel (Chrome replies on default icons, Firefox can specify icons).

### Known Consumers

The associated and linked bug has 48 stars and 31 comments.
solomonkinard marked this conversation as resolved.
Show resolved Hide resolved

## Specification

### Schema

Some browsers don't currently have plans to support svg. Therefore, a drop-in
replacement of an already supported image type will be allowed.

numberToPathDictionary
```
{
"<number>": "<path>"
}
```

manifest.json
```
{
"icon_variants": {
"<dark|light>": <numberToPathDictionary>
solomonkinard marked this conversation as resolved.
Show resolved Hide resolved
},
"action": {
"default_icon": <numberToPathDictionary>|<svgPathString|pathString>,
"icon_variants": {
"<dark|light>": <numberToPathDictionary>
}
}
}
```

solomonkinard marked this conversation as resolved.
Show resolved Hide resolved
Action
```
action.setIcon({
imageData?: ImageData | object:<numberToPathDictionary>,
path?: string | object:<numberToPathDictionary>,
tabId?: number,
variants?: {
"<dark|light>": <numberToPathDictionary>
},
});
solomonkinard marked this conversation as resolved.
Show resolved Hide resolved
```

### Examples

manifest.json
```
{
"icon_variants": {
"dark": {
"128": "128_dark.png"
},
"light": {
"128": "128_light.png"
}
},
"action": {
"default_icon": {
"128": "128_action.png"
},
"icon_variants": {
"dark": {
"128": "128_action_dark.png"
},
"light": {
"128": "128_action_light.png"
}
}
}
}
```

Action
```
action.setIcon({
variants?: {
"dark": {
"128": "128_action_dark.png"
},
"light": {
"128": "128_action_light.png"
}
},
});
```

### Behavior

Existing manifest key. The behavior of the icons manifest key will remain unchanged.
```
{
"icons": {
"64": "icon_64.png"
},
"action": {
"default_icon": {
"64": "action_64.png"
}
}
}
```

Order of precedence. The new `icon_variants` keys and subkeys will take
precedent, followed by the incumbent `icons` key.

solomonkinard marked this conversation as resolved.
Show resolved Hide resolved
### New Permissions

N/A.

### Manifest File Changes

#### Optional or required?
`icon_variants` is an optional key of the top level manifest dictionary.
`icon_variants` is also an optional sub-key in the action key dictionary.

#### Fallback
`icon_variants` will be used if they're supplied. Otherwise `default_icon` will
be used if it's supplied. If neither are supplied, then `icons` will be used.
solomonkinard marked this conversation as resolved.
Show resolved Hide resolved

#### Warning or error?
The new `icon_variants` key (or sub-key) will only emit a non-blocking warning
solomonkinard marked this conversation as resolved.
Show resolved Hide resolved
rather than a hard error in the event of unexpected values or missing icons.
solomonkinard marked this conversation as resolved.
Show resolved Hide resolved
This will allow this optional key to be more flexible in the event of ideas for
future changes. The `icons` key cannot be used for dark mode support because it
errors in cases when a warning would have otherwise sufficed. The warning is
ok for `icon_variants` based on the safety net outlined in the fallback section.

solomonkinard marked this conversation as resolved.
Show resolved Hide resolved
solomonkinard marked this conversation as resolved.
Show resolved Hide resolved
solomonkinard marked this conversation as resolved.
Show resolved Hide resolved
## Security and Privacy

### Exposed Sensitive Data

N/A.

### Abuse Mitigations

N/A.

### Additional Security Considerations

N/A.

## Alternatives

### Existing Workarounds

1. A developer could ask the user to specify what mode they're in and then
dynamically set the icon to a dark mode icon using action.setIcon(). That
solomonkinard marked this conversation as resolved.
Show resolved Hide resolved
wouldn't change the management page icon.
2. A developer could change icons dynamically to dark mode icons if this is
true: `window.matchMedia('(prefers-color-scheme: dark)')`.
solomonkinard marked this conversation as resolved.
Show resolved Hide resolved

### Open Web API

As stated in the workarounds section, the following is already an option to consider: `window.matchMedia('(prefers-color-scheme: dark)')`. However, that
wouldn't automatically set icons dynamically, as it would require subsequent
calls to action.setIcon(). It also wouldn't update the icon on the management
solomonkinard marked this conversation as resolved.
Show resolved Hide resolved
pages.

## Implementation Notes

N/A.

## Future Work

Svg support may be considered at some point for some browsers.
solomonkinard marked this conversation as resolved.
Show resolved Hide resolved