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

Rename purpose: badge to purpose: monochrome and expand on it #830

Closed
NotWoods opened this issue Dec 5, 2019 · 4 comments · Fixed by #833
Closed

Rename purpose: badge to purpose: monochrome and expand on it #830

NotWoods opened this issue Dec 5, 2019 · 4 comments · Fixed by #833

Comments

@NotWoods
Copy link
Member

NotWoods commented Dec 5, 2019

I'd like to experiment with letting PWAs specify the icon that appears in the "Site controls" notification (the silent notification where you can copy the URL). Since Android expects a grayscale icon for notifications, I'd like to have a purpose defined for this case.

Site controls notifications in Chrome and Firefox

We currently have the "badge" purpose. In the spec its defined as:

A user agent can present this icon where space constraints and/or color requirements differ from those of the application icon.

I don't feel like this is clear enough for browsers or developers, and no browser currently supports this purpose type.


There's been some discussion on this in multiple issues that I'll try to summarize here.


I'd like to propose that we specify monochrome icons as images where all the r,g,b color information is removed and only the alpha is kept. Browsers can then apply whatever color is needed by the OS, or let the OS handle the tinting. This has the added benefit of letting developers potentially reuse their transparent PWA icons by specifying purpose: "monochrome any" if the silhouette is distinct.

If no monochrome icon is available, the browser may choose to create a fallback. For Safari's pinned tabs, icons are converted automatically. In this example, Facebook has not specified any special icon.

Safari pinned tabs

In the case of Site controls, it also makes sense for the browser to show a default icon like its logo or the PWA logo, as Chrome and Firefox currently do.

To best handle different use cases, the browser may also add padding to the icon depending on where it is used. In the notification, no padding is needed. If the icon is used in a shortcut on Android, the browser may add padding so that it lines up with platform conventions.

@NotWoods
Copy link
Member Author

NotWoods commented Dec 5, 2019

@mgiuca I'd like to hear your thoughts on this 😄 I've opened a new issue since this is a separate use case from shortcuts.

@mgiuca mgiuca changed the title Rename purpose: badge to purpose: maskable and expand on it Rename purpose: badge to purpose: monochrome and expand on it Dec 6, 2019
@mgiuca
Copy link
Collaborator

mgiuca commented Dec 6, 2019

Hi Tiger,

Thanks for opening this discussion. I am pretty sure you meant rename to "monochrome", not "maskable" (???), so I've gone ahead and renamed the issue. :) This is a bit of a dupe of #795 but since that discussion is very long and shortcut-focused, happy to start a fresh one here. However, readers should be aware that this was litigated a fair bit on #795.

I completely agree with the proposal here. Happy to work on spec language for it (you can do it and I can review it, or I can do it with your review if you're happy for me to take it). We need to specify exactly the format of a monochrome icon so that UAs can adapt it for their various purposes, e.g. Safari wants to make a grey gradient, Windows might want to change the icon's foreground color to the app's theme_color, etc, etc. But in order to do that, we need to establish a contract between the developer and the UA, so that for example it's well defined what the foreground pixels and the background pixels are.

I'm happier to go with your suggestion of ignoring RGB pixel colour and just looking at the alpha channel (over my previous suggestion on #795 to ignore alpha and ask for icons to be greyscale). It does make the icons a little harder to author, but it's much less ambiguous (for example, we don't need to worry about what happens if we find a non-grey pixel; we just totally ignore RGB channels and only look at alpha).

So the specifics would be that the UA MUST NOT look at the RGB channels of the pixel data (developers are recommended to set all pixels to black, but it doesn't matter). It SHOULD treat the alpha channel with opaque = foreground colour, and transparent = background colour. UAs are free to manipulate the image however they see fit, for example, converting the transparency into a solid colour, or setting all of the RGB pixel data to white, or to the app's theme colour.

@NotWoods
Copy link
Member Author

NotWoods commented Dec 6, 2019

I would like to take on writing the spec here 😃 I'll let you know when it's ready for review.

@mgiuca
Copy link
Collaborator

mgiuca commented Dec 6, 2019

Cool, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants