gridstack-8.x-2.5/src/Plugin/Layout/GridStackBootstrap.php

src/Plugin/Layout/GridStackBootstrap.php
<?php

namespace Drupal\gridstack\Plugin\Layout;

/**
 * Provides Bootstrap integration.
 */
class GridStackBootstrap {

  /**
   * The classes.
   *
   * @var array
   */
  private static $classes;

  /**
   * Returns the supported classes.
   *
   * @return array
   *   An associative array of grouped classes.
   */
  public static function classes() {
    if (!isset(static::$classes)) {
      $version = \gridstack()->configLoad('framework', 'gridstack.settings');
      $version_classes = $utility = $hidden = $visible = $visibility = $bg = [];
      $text_color = $text_align = $text_transform = [];

      foreach (['left', 'right', 'center', 'justify', 'nowrap'] as $key) {
        $text_align[] = 'text-' . $key;
      }

      foreach (['lowercase', 'uppercase', 'capitalize'] as $key) {
        $text_transform[] = 'text-' . $key;
      }

      // Utility.
      $utility[] = 'clearfix';
      $sizes = ['xs', 'sm', 'md', 'lg', 'xl'];

      // Background/text color classes.
      $colors = ['primary', 'danger', 'info', 'warning', 'success'];
      if ($version == 'bootstrap') {
        $colors4 = ['secondary', 'light', 'dark', 'white', 'transparent'];
        $colors = array_merge($colors, $colors4);
      }

      foreach ($colors as $type) {
        $bg[] = "bg-$type";
        $text_color[] = "text-$type";
      }
      $text_color[] = 'text-muted';

      if ($version == 'bootstrap') {
        $text_color[] = 'text-black-50';
        $text_color[] = 'text-white-50';
      }

      // Visibility for Bootstrap4+.
      if ($version == 'bootstrap') {
        $visibility[] = 'visible';
        $visibility[] = 'invisible';
        $version_classes['visibility'] = $visibility;

        $utility[] = 'text-monospace';
      }
      // Visibility for Bootstrap3.
      elseif ($version == 'bootstrap3') {
        foreach ($sizes as $size) {
          $hidden[] = "hidden-$size";
          $visible[] = "visible-$size";
        }

        $version_classes['hidden'] = $hidden;
        $version_classes['visible'] = $visible;
      }

      // Classes, keyed by group.
      static::$classes = $version_classes + [
        'background' => $bg,
        'text_align' => $text_align,
        'text_color' => $text_color,
        'text_transform' => $text_transform,
        'utility' => $utility,
      ];
    }

    return static::$classes;
  }

}

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

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