bootstrap_components_toolkit-1.0.0/bootstrap_components_toolkit.module

bootstrap_components_toolkit.module
<?php

/**
 * @file
 * Primary module hooks for Bootstrap Components Toolkit Theme Components module.
 */

use Drupal\Component\Utility\Html;
use Drupal\bootstrap_components_toolkit\BootstrapComponentsToolkitColor;

/**
 * Implements hook_theme().
 */
function bootstrap_components_toolkit_theme($existing, $type, $theme, $path) {
  return [
    'bootstrap_button' => [
      'variables' => [
        'url' => '',
        'type' => FALSE,
        'size' => '',
        'color' => '',
        'button_content' => '',
        'attributes' => '',
      ],
    ],
    'bootstrap_alert' => [
      'variables' => [
        'alert_content' => '',
        'type' => BootstrapComponentsToolkitColor::PRIMARY,
        'dismissible' => TRUE,
        'attributes' => '',
      ],
    ],
    'bootstrap_badge' => [
      'variables' => [
        'badge_content' => '',
        'type' => BootstrapComponentsToolkitColor::PRIMARY,
        'dismissible' => TRUE,
        'is_dark' => FALSE,
        'rounded' => FALSE,
        'attributes' => '',
        'url' => FALSE,
      ],
    ],
    'bootstrap_dropdown' => [
      'variables' => [
        'url' => '',
        'title' => '',
        'type' => '',
        'size' => '',
        'color' => BootstrapComponentsToolkitColor::PRIMARY,
        'items' => '',
        'attributes' => '',
        'id' => '',
        'direction' => '',
        'offset' => [],
        'auto_close' => 'true',
      ],
    ],
    'bootstrap_card' => [
      'variables' => [
        'card_img_top' => '',
        'card_content' => '',
        'card_img_bottom' => '',
      ],
    ],
    'bootstrap_nav' => [
      'variables' => [
        'attributes' => '',
        'items' => [],
        'alignmet' => '',
        'style' => '',
        'fill' => ''
      ],
    ],
    'bootstrap_tabs' => [
      'variables' => [
        'nav_items' => [],
        'nav_classes' => [],
        'nav_alignment' => '',
        'tabs' => []
      ],
    ],
    'bootstrap_accordion' => [
      'variables' => [
        'id' => '',
        'items' => [],
        'style' => '',
        'classes' => [],
      ],
    ],
    'bootstrap_accordion__item' => [
      'variables' => [
        'parent_id' => '',
        'item_id' => '',
        'is_open' => FALSE,
        'always_open' => FALSE,
        'header_text' => '',
        'header_tag' => '',
        'body_content' => [],
      ],
    ],
    'bootstrap_figure' => [
      'variables' => [
        'image_url' => '',
        'caption' => '',
        'rounded' => FALSE,
        'caption_alignment' => FALSE,
      ]
    ]
  ];
}

/**
 * Implements hook_preprocess_bootstrap_dropdown().
 */
function template_preprocess_bootstrap_dropdown(&$variables) {

  // Set an auto-generated ID if no value has been explicitly passed.
  if (empty($variables['id'])) {
    $variables['id'] = Html::getUniqueId('bootstrap_dropdown');
  }

  if (!empty($variables['items'])) {
    foreach ($variables['items'] as &$item) {
      $item['#attributes']['class'][] = 'dropdown-item';
    }
  };
}

/**
 * Implements hook_preprocess_bootstrap_badge().
 */
function template_preprocess_bootstrap_badge(&$variables) {

  $type = $variables['type'];

  // Support setting the contrast colors at a theme level.
  $contrast_color = theme_get_setting("contrast-$type");

  // Only set the is_dark variable if there is a theme setting and no value
  // has been passed explicitly.
  if (!empty($contrast_color) && empty($variables['is_dark'])) {
    $variables['is_dark'] = $contrast_color === 'dark';
  }

}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc