From 9d6740b8ed634ec8d3e12aa07eec5b424dc8acc9 Mon Sep 17 00:00:00 2001 From: rdrew Date: Wed, 12 Nov 2025 14:40:47 -0400 Subject: [PATCH] added hex code form --- mobile_facets.module | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/mobile_facets.module b/mobile_facets.module index 067dc86..a77d2f5 100755 --- a/mobile_facets.module +++ b/mobile_facets.module @@ -8,3 +8,30 @@ use Drupal\Core\Render\AttachmentsTrait; function mobile_facets_page_attachments(array &$attachments) { $attachments['#attached']['library'][] = 'mobile_facets/mobile_facets'; } + +/** + * @file + * Contains mobile_facets.module. + */ + +/** + * Implements hook_preprocess_html(). + */ +function mobile_facets_preprocess_html(&$variables) { + $config = \Drupal::config('mobile_facets.settings'); + $color = $config->get('color') ?? '#000000'; + + $variables['#attached']['html_head_link'][] = [ + [ + 'rel' => 'preload', + 'as' => 'style', + 'href' => \Drupal::service('extension.list.theme')->getPath('your_theme_name') . '/css/mobile_facets.css', // Adjust if needed. + ], + ]; + + // Add the CSS variable to attributes. + $variables['html_attributes']['style'] = '--mobile_facets-color: ' . $color . ';'; + + // Optionally attach the library if not already. + //$variables['#attached']['library'][] = 'mobile_facets/mobile_facets'; +}