-
Notifications
You must be signed in to change notification settings - Fork 1
/
olivero_dark.theme
36 lines (32 loc) · 1007 Bytes
/
olivero_dark.theme
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
declare(strict_types=1);
/**
* Prepares variables for HTML document templates.
*
* This adds @code <meta name="color-scheme" content="dark light"> @endcode for
* browsers that support it, to indicate that we want to opt in to them using
* dark mode user agent styles (e.g. for the page background and form elements)
* when @code @media (prefers-color-scheme: dark) @endcode applies.
*
* Default template: html.html.twig.
*
* @param array $variables
* An associative array containing:
* - page: A render element representing the page.
*
* @see https://ambientimpact.com/web/snippets/the-color-scheme-meta-tag
*
* @see https://caniuse.com/mdn-html_elements_meta_name_color-scheme
*/
function olivero_dark_preprocess_html(array &$variables): void {
$variables['page']['#attached']['html_head'][] = [
[
'#tag' => 'meta',
'#attributes' => [
'name' => 'color-scheme',
'content' => 'dark light',
],
],
'color-scheme',
];
}