You are here

function seeds_toolbar_preprocess_html in Seeds Toolbar 8

Implements hook_preprocess_HOOK().

File

./seeds_toolbar.module, line 250
Contains seeds_toolbar.module.

Code

function seeds_toolbar_preprocess_html(&$variables) {

  // Default width to fix the jumping issue.
  if (\Drupal::currentUser()
    ->hasPermission('access toolbar')) {
    $config = \Drupal::config('seeds_toolbar.settings');
    $settings = $config
      ->get();
    $variables['attributes'] = new Attribute($variables['attributes']);
    $variables['attributes']
      ->addClass('seeds-toolbar', $config
      ->get('style'));
    $variables["attributes"]
      ->removeClass("toolbar-horizontal", "toolbar-tray-open");
    $dir = \Drupal::service('seeds_toolbar.manager')
      ->getDirection();
    if (!$settings['compact']) {
      $variables['attributes']
        ->setAttribute('style', "margin-{$dir}:245px");
    }
    else {
      $variables['attributes']
        ->setAttribute('style', "margin-{$dir}:55px");
    }
    if (!$config
      ->get('compact')) {
      $variables['attributes']
        ->addClass('seeds-toolbar-open');
    }
  }
}