diff options
Diffstat (limited to 'lib/Minz/View.php')
| -rw-r--r-- | lib/Minz/View.php | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/Minz/View.php b/lib/Minz/View.php index 459ef1e23..3b5052c36 100644 --- a/lib/Minz/View.php +++ b/lib/Minz/View.php @@ -19,6 +19,7 @@ class Minz_View { private static $title = ''; private static $styles = array (); private static $scripts = array (); + private static $themeColors; private static $params = array (); @@ -238,6 +239,35 @@ class Minz_View { } /** + * @param array|string $themeColors + */ + public static function appendThemeColors($themeColors): void { + self::$themeColors = $themeColors; + } + + /** + * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta/name/theme-color + */ + public static function metaThemeColor(): string { + $meta = ''; + + if (!empty(self::$themeColors['light'])) { + $meta .= '<meta name="theme-color" media="(prefers-color-scheme: light)" content="' . htmlspecialchars(self::$themeColors['light']) . '" />'; + } + if (!empty(self::$themeColors['dark'])) { + $meta .= '<meta name="theme-color" media="(prefers-color-scheme: dark)" content="' . htmlspecialchars(self::$themeColors['dark']) . '" />'; + } + if (!empty(self::$themeColors['default'])) { + $meta .= '<meta name="theme-color" content="' . htmlspecialchars(self::$themeColors['default']) . '" />'; + } + if (empty(self::$themeColors['default']) && !empty(self::$themeColors) && empty(self::$themeColors['light']) && empty(self::$themeColors['dark'])) { + $meta .= '<meta name="theme-color" content="' . htmlspecialchars(self::$themeColors) . '" />'; + } + + return $meta; + } + + /** * Gestion des scripts JS */ public static function headScript () { |
