[w3c/manifest] Add a way to explicitly colour the standalone window's title bar (#695)

I'm filing a bug here to raise a concern as more browsers move towards PWAs on more host platforms, including Desktop. However, after extensive internal discussions at Google, I'm happy to leave this and wait and see if it's an issue before acting.

The issue is this: should user agents theme standalone windows' title bars with a) the app's `theme_color` (from the web app manifest), or b) the user's OS preferred title bar colour? Obviously, the answer is "this is up to the user agent, not the spec". But, consider the likely answer for each OS (according to observed platform conventions):

- Windows: *Probably* (b) (but there are exceptions).
- Mac: *Probably* (b) (but there are exceptions; seemingly more so than Windows).
- Linux: (b) (apps cannot modify window title bars, unless they fully take over the window, and this behaviour interferes or plays poorly with the vast collection of different window managers including TWMs with no title bars at all).
- Android: (a) (no strong OS theme colour; top-bar is app branded).
- Chrome OS: (a) (no strong OS theme colour; top-bar is app branded).
- As future platforms come along, they may have either convention.

So the likely answer is that the user agent makes the decision, per-OS, as to whether to go with (a) or (b).

However, consider that many developers will want to override the choice of (b) wherever possible, and force their theme colour into the title bar. We see this with a lot of Electron apps on Windows and Mac (e.g., Spotify, Discord, WhatsApp). If the user agent chooses (b), those apps won't be happy. So, in order to satisfy those customers that want a "fancy" experience, the user agent is incentivized to choose (a) on all platforms. (This is the current direction we're heading with Chrome.)

So now we're in a place where user agents typically choose (a) on all platforms, but where does that leave developers who *want* the "normal" experience of (b) on Windows, Mac, Linux? They have two options:

1. Delete their `theme_color`, thus using the system default, or
2. Server-side user agent detection, and serve a different manifest on each platform.

Option 1 is bad because we want apps to have a `theme_color`; it's used for more than just the title bar (e.g., the splash screen background) and not having one makes them look "boring" on (a)-type platforms like Android and Chrome OS --- note that there is no user preference for title bar colour on these platforms, it's just grey. Option 2 is much worse, because then developers are forced to consider each platform, and won't be future-proofing their sites.

This leads me to the conclusion that we should give developers a way of making one of two different statements:

- "this is my theme colour; please use it wherever appropriate based on the host system conventions" (i.e., (a) on Android and Chrome OS, (b) on Windows, Mac and Linux).
- "please use this colour in the title bar wherever possible" (i.e., (a) everywhere possible; perhaps even draw a custom title bar on Linux instead of deferring to the system).

There is currently no way for developers to specify which of the above two statements they want to make. The proposal to allow this would be to introduce a new hex-colour member, `title_bar_color`, which expresses an explicit desire to theme the standalone window's title bar, as opposed to specifying a generic theme colour.

Thus, the following manifest:

```json
{
  "theme_color": "#a5a"
}
```

Provides a general statement about theme colour, but has no strong opinion about the title bar, whereas:

```json
{
  "theme_color": "#a5a",
  "title_bar_color": "#a5a"
}
```

Explicitly asks the title bar to be branded with the app's theme colour.

A few notes:

- On (a)-type platforms (which naturally theme the title bar), the UA would take the `title_bar_color`, with a fallback to `theme_color`.
- This also allows an app to show a different colour in the title bar than its generic theme colour. Which could be useful for having different shades of the same hue, for example.
- This wouldn't actually enshrine the concept of "title bar" into the web (of course, many platforms won't have a "title bar" as such). It would be specified as a hint to the user agent to use `title_bar_color` prominently in the border of the stand-alone window. The name is just suggestive of its most common meaning. Perhaps `border_color` is a better name.

Anyway, Chrome is going to proceed without this, choosing (a) on all platforms. The above proposal isn't strictly necessary, but we'll see if there is demand from developers.

@boyofgreen who may be interested in this (since Edge PWAs are currently taking the (b) approach on Windows 10).

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/manifest/issues/695

Received on Thursday, 14 June 2018 08:37:21 UTC