Bug 1858711 - Refactor lwtheme attributes to account for missing colors. r=dao,desktop-theme-reviewers

When a theme doesn't specify popup colors, it makes sense to follow the
system-preferred color scheme. Refactor theming attributes so that we
can distinguish this. Instead of a single [lwt-popup-brighttext], we get
lwt-popup="dark"/"light", and handle it appropriately.

Same for the other relevant attributes.

Refactor sidebar theming (which already did this tri-state thing via
lwt-sidebar and lwt-sidebar-brighttext) to do the same using a single
lwt-sidebar attribute, and update the docs.

Differential Revision: https://phabricator.services.mozilla.com/D190919
This commit is contained in:
Emilio Cobos Álvarez
2023-10-13 13:24:14 +00:00
parent ac0ad14937
commit 04e2ae3af3
17 changed files with 161 additions and 149 deletions

View File

@@ -503,14 +503,17 @@ Writing theme-friendly CSS
- Never write CSS specially for the built-in light/dark theme in
``compacttheme.css`` unless that CSS isn't supposed to affect
WebExtension themes.
- These selectors can be used to target dark areas:
- These selectors can be used to target themed areas, though in general it's
recommended to try to avoid them and use ``light-dark()`` to get the right
colors automatically:
- ``:-moz-lwtheme-brighttext``: dark window frame.
- ``:root[lwt-toolbar-field-brighttext]``: dark address bar and
searchbar.
- ``:root[lwt-popup-brighttext]``: dark arrow panels and
autocomplete panels.
- ``:root[lwt-sidebar-brighttext]``: dark sidebars.
- ``:root[lwt-toolbar-field="light/dark"]``: explicitly light or dark address bar and
searchbar.
- ``:root[lwt-toolbar-field-focus="light/dark"]``: explicitly light or dark address bar and
searchbar in the focused state.
- ``:root[lwt-popup="light/dark"]``: explicitly light or dark arrow panels
and autocomplete panels.
- ``:root[lwt-sidebar="light/dark"]``: explicitly light or dark sidebars.
- If you'd like a different shade of a themed area and no CSS variable
is adequate, using colors with alpha transparency is usually a good