Skip to content

Commit

Permalink
Riverlea - dynamic CSS set color-scheme: so system elements respect d…
Browse files Browse the repository at this point in the history
…ark mode setting
  • Loading branch information
ufundo committed Dec 18, 2024
1 parent b5e0cd2 commit edaa8b5
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions ext/riverlea/Civi/riverlea/DynamicCss.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,22 @@ public static function buildAssetCss($e) {

switch ($params['dark'] ?? NULL) {
case 'light':
// nothing more to do
// tell OS we want light for system elements
$content[] = ":root { color-scheme: light; }";
break;

case 'dark':
// add dark vars unconditionally
// tell OS we want dark for system elements
$content[] = ":root { color-scheme: dark; }";
// add stream dark vars unconditionally
$content[] = self::getCSSFromFile('_dark.css', $stream);
break;

case 'inherit':
default:
// add dark vars wrapped inside a media query
// tell OS we are happy with light or dark for system elements
$content[] = ":root { color-scheme: light dark; }";
// add stream dark vars wrapped inside a media query
$content[] = '@media (prefers-color-scheme: dark) {';
$content[] = self::getCSSFromFile('_dark.css', $stream);
$content[] = '}';
Expand Down

0 comments on commit edaa8b5

Please sign in to comment.