This module adds mobile behaviors to the search facets in the Island Archives olives* themes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

37 lines
1010 B

<?php
use Drupal\Core\Render\AttachmentsTrait;
/**
* Implements hook_page_attachments().
*/
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';
}