|
|
|
|
@ -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 <html> attributes. |
|
|
|
|
$variables['html_attributes']['style'] = '--mobile_facets-color: ' . $color . ';'; |
|
|
|
|
|
|
|
|
|
// Optionally attach the library if not already. |
|
|
|
|
//$variables['#attached']['library'][] = 'mobile_facets/mobile_facets'; |
|
|
|
|
} |
|
|
|
|
|