aboutsummaryrefslogtreecommitdiff
path: root/lib/Minz/View.php
diff options
context:
space:
mode:
authorGravatar maTh <math-home@web.de> 2023-03-04 15:05:58 +0100
committerGravatar GitHub <noreply@github.com> 2023-03-04 15:05:58 +0100
commit068d18b69bae8456669293a8b7dfe9afd827e03d (patch)
treed24e9d3804824c065a7d6d7a9e1b45d163fce476 /lib/Minz/View.php
parentd3966befafab3fe65e753d0ab2166a8bf5fb0d75 (diff)
Add: <meta name="theme-color"> (#5105)
* implemented * themes' metadata.json * fix * fix * retrigger tests * Update lib/Minz/View.php Co-authored-by: Luc SANCHEZ <4697568+ColonelMoutarde@users.noreply.github.com> * Update lib/Minz/View.php Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr> * Update lib/Minz/View.php Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr> * Update lib/Minz/View.php Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr> * fix --------- Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr> Co-authored-by: Luc SANCHEZ <4697568+ColonelMoutarde@users.noreply.github.com>
Diffstat (limited to 'lib/Minz/View.php')
-rw-r--r--lib/Minz/View.php30
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 () {