Postponed on #3606655: Make dark mode a first class citizen of Drupal core and #3517033: Add a style utility API
Problem/Motivation
#3606655: Make dark mode a first class citizen of Drupal core moves the dark mode setting from Default Admin to a central feature, but it's still Drupal-centric.
In #44, @pdureau gives real-world examples of the benefit to using a more agnostic approach:
I agree
$variables['html_attributes']['data-color-scheme']is too specific. This attributes will depend of the design (system) implementation in the theme.Examples:
data-bs-themeattribute, anywhere, in https://getbootstrap.com/docs/5.3/customize/color-modes/#dark-modedata-themeattribute in https://daisyui.com/docs/themes/data-fr-schemeattribute, only inhtmlelement, in DSFR- ...
Sometimes this attribute or class can be added only on specific elements, like HTML or BODY, HTML, sometimes anywhere.
That's why I believe ticket must be done and merged hand-to-hand with #3517033: Add a style utility API. Here, we manage:
- User specific value, extending User/Account/Session API and managing the related cache
- Specific settings for
admin_themeIn #3517033: Add a style utility API, we miss the User specific part, but we manage:
- declaration of modes in theme (with plugin definition): the values, the meta, the renderable alterations...
- in a more generic way (not only dark/light)
Choice of color mode is important for accessibility reasons, and making it easier for contrib / custom themes to use this setting helps accessibility.
Steps to reproduce
Proposed resolution
Coordinate with #3517033: Add a style utility API and adapt the new central dark mode setting to an API that suits various consumers better.
Remaining tasks
TBD
User interface changes
Introduced terminology
API changes
TBD
Data model changes
TBD
Comments
Comment #2
kentr commented