From 033014a554dbbcc6e9dd44b428f4a91de508e281 Mon Sep 17 00:00:00 2001 From: "Peter Droogmans (attiks)" Date: Wed, 18 Dec 2024 12:12:11 +0100 Subject: [PATCH 1/2] feat: Use light/dark favicons Refs: #OPS-11179 --- common_design.theme | 55 +++++++++++++++++++++++++++++++++ img/favicons/blue/favicon.ico | Bin 0 -> 15406 bytes img/favicons/white/favicon.ico | Bin 0 -> 15406 bytes 3 files changed, 55 insertions(+) create mode 100755 img/favicons/blue/favicon.ico create mode 100755 img/favicons/white/favicon.ico diff --git a/common_design.theme b/common_design.theme index 73c2fc65..f987f8cc 100644 --- a/common_design.theme +++ b/common_design.theme @@ -32,6 +32,13 @@ function common_design_form_system_theme_settings_alter(&$form, FormStateInterfa ]; } + // Add a setting to use light/dark favicons. + $form['common_design']['use_light_dark_favicon'] = [ + '#type' => 'checkbox', + '#title' => t('Use light/dark favicon'), + '#default_value' => theme_get_setting('use_light_dark_favicon') ?? FALSE, + ]; + // Load the node view modes. $storage = \Drupal::entityTypeManager()->getStorage('entity_view_mode'); $view_modes = $storage->loadByProperties([ @@ -1001,3 +1008,51 @@ function common_design_preprocess_datetime_wrapper(&$variables) { $variables['title_attributes']['class'][] = 'visually-hidden'; } } + +/** + * Implements hook_page_attachments_alter(). + */ +function common_design_page_attachments_alter(array &$page) { + $active_theme = \Drupal::theme()->getActiveTheme(); + + if (!theme_get_setting('use_light_dark_favicon')) { + return; + } + + // Attach favicon from active theme. + if (file_exists($active_theme->getPath() . '/img/favicons/blue/favicon.ico')) { + $page['#attached']['html_head_link'][][] = [ + 'rel' => 'icon', + 'href' => '/' . $active_theme->getPath() . '/img/favicons/blue/favicon.ico', + 'type' => 'image/x-icon', + 'media' => '(prefers-color-scheme: light)', + ]; + $page['#attached']['html_head_link'][][] = [ + 'rel' => 'icon', + 'href' => '/' . $active_theme->getPath() . '/img/favicons/white/favicon.ico', + 'type' => 'image/x-icon', + 'media' => '(prefers-color-scheme: dark)', + ]; + } + else { + // Attach favicon from parent theme. + foreach ($active_theme->getBaseThemeExtensions() as $base_theme) { + if (file_exists($base_theme->getPath() . '/img/favicons/blue/favicon.ico')) { + $page['#attached']['html_head_link'][][] = [ + 'rel' => 'icon', + 'href' => '/' . $base_theme->getPath() . '/img/favicons/blue/favicon.ico', + 'type' => 'image/x-icon', + 'media' => '(prefers-color-scheme: light)', + ]; + $page['#attached']['html_head_link'][][] = [ + 'rel' => 'icon', + 'href' => '/' . $base_theme->getPath() . '/img/favicons/white/favicon.ico', + 'type' => 'image/x-icon', + 'media' => '(prefers-color-scheme: dark)', + ]; + + return; + } + } + } +} diff --git a/img/favicons/blue/favicon.ico b/img/favicons/blue/favicon.ico new file mode 100755 index 0000000000000000000000000000000000000000..38aa081e2f4aaddae235c1c4d1518de674715803 GIT binary patch literal 15406 zcmeI33%J%(y1-Y=)yz1IlVi*v8fh3LB9~DSJKfdZ-Bn7u=pMRZb}EIMQqpx_x|zzz zphCAzOc>2El6L#rWhW^O<2uRs&hPjCzJETEqdCWOJkM!A&)d4axAm@fz3W};{}n=| zaAY{{#TG4zOy+m zR4G{$DwpJjj6@<-5=!#J)umIz@#V9^DFp=qZNK=JpuZ$93**nHsyq$l;(!}pqU2F!>`Q>Kix7X{HkPjI4^?yaMt?y;aGS)#P~FM zOB3^ewmV~w!+U;NerQ`ZJ5-Yg=7htuFc z5*u`29z)RgVfbBNlpn4H|I96OLrr+!&syD2*@eEjK!?Kn!*S(v!@0<5T{<`XvIw2% zuLF6-|TrSgyTa2=tQhH^AI%tYp;tk31hy%5~fTz`S_y3o8znMHXCpe|s1I{f!Px4?!);d|_4@atmy7CF5Vi#U8zf5<)p-|c~J&5Ndk!(Nf5Y)-hKY*F~P z81L(r`n&Sn|M2-Md&}5mtoRVw#+5$QZ!osdt_z+qvKM<|NgD1);QR%c%s#tJ`+Qyb zo&oUdf}E+8Gk~$c5Of*@Opf|?mz6(=9?I0OmWA)fv|HzeGwDAwZX@dl##QLL7=zKz zvwJXnp98M|*aqLWF@Ab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Q<!|R{nEsR24 zn1e<^-Wiz>PCEn5!i-RuuXRq5Be%dc|6Vw*gpCM>SGJp1W z4Bm5X@j4u{4K5Diw{O?5RPee0W#h{U*ZMN7Ku!2s_NA;iA04p{=By;lt@mUP7_0Yy zafRQF%wE=WQ@6vSX$ zj%vZ#ygR2caQzCwy0-Ja9gPN_Q@v;D4W+xXad)C3wEL<9M|{n zfdAXqSlqWhN8Hc$@g$7tl(E~!gZFd7eNhMF@Ckfoh0jdq;QE@Q^u8$PMc@GStyUi$G8E;G8E~53vwdbQ~#HG=G1=G4x177?cVS{ z7>yKM5Zeo{9XmIikMYh%Z`daN-}tuSwR7kN^X2>DePoUvgnPj{_IFa-*fGykrmg#- z2x9Z?nzw*CPK58rA+}CyUU!1~rZeovI)%{)-jmG{+s1x Date: Thu, 19 Dec 2024 12:07:36 +0100 Subject: [PATCH 2/2] feat: Use light/dark favicons Refs: #OPS-11179 --- common_design.theme | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/common_design.theme b/common_design.theme index f987f8cc..1c8f884a 100644 --- a/common_design.theme +++ b/common_design.theme @@ -1019,7 +1019,7 @@ function common_design_page_attachments_alter(array &$page) { return; } - // Attach favicon from active theme. + // Attach blue favicon from active theme. if (file_exists($active_theme->getPath() . '/img/favicons/blue/favicon.ico')) { $page['#attached']['html_head_link'][][] = [ 'rel' => 'icon', @@ -1027,12 +1027,6 @@ function common_design_page_attachments_alter(array &$page) { 'type' => 'image/x-icon', 'media' => '(prefers-color-scheme: light)', ]; - $page['#attached']['html_head_link'][][] = [ - 'rel' => 'icon', - 'href' => '/' . $active_theme->getPath() . '/img/favicons/white/favicon.ico', - 'type' => 'image/x-icon', - 'media' => '(prefers-color-scheme: dark)', - ]; } else { // Attach favicon from parent theme. @@ -1044,6 +1038,24 @@ function common_design_page_attachments_alter(array &$page) { 'type' => 'image/x-icon', 'media' => '(prefers-color-scheme: light)', ]; + break; + } + } + } + + // Attach white favicon from active theme. + if (file_exists($active_theme->getPath() . '/img/favicons/white/favicon.ico')) { + $page['#attached']['html_head_link'][][] = [ + 'rel' => 'icon', + 'href' => '/' . $active_theme->getPath() . '/img/favicons/white/favicon.ico', + 'type' => 'image/x-icon', + 'media' => '(prefers-color-scheme: dark)', + ]; + } + else { + // Attach favicon from parent theme. + foreach ($active_theme->getBaseThemeExtensions() as $base_theme) { + if (file_exists($base_theme->getPath() . '/img/favicons/white/favicon.ico')) { $page['#attached']['html_head_link'][][] = [ 'rel' => 'icon', 'href' => '/' . $base_theme->getPath() . '/img/favicons/white/favicon.ico', @@ -1051,7 +1063,7 @@ function common_design_page_attachments_alter(array &$page) { 'media' => '(prefers-color-scheme: dark)', ]; - return; + break; } } }