You are here

protected function BootstrapBase::setClassOptions in GridStack 8.2

Sets the gridstack engine classes.

@inheritdoc

Overrides GridStackEnginePluginBase::setClassOptions

File

src/Plugin/gridstack/engine/BootstrapBase.php, line 28

Class

BootstrapBase
Provides the base Bootstrap layout engine.

Namespace

Drupal\gridstack\Plugin\gridstack\engine

Code

protected function setClassOptions() {
  if (!isset($this->setClassOptions)) {
    $bg = $utility = $text_color = $text_align = $text_transform = [];

    // Utility.
    $utility[] = 'clearfix';

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

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

    // Background/ text color classes.
    foreach ($this
      ->colors() as $type) {
      $bg[] = "bg-{$type}";
      $text_color[] = "text-{$type}";
    }
    $text_color[] = 'text-muted';
    $font_size = [
      'h1',
      'h2',
      'h3',
      'h4',
      'h5',
      'h6',
      'lead',
      'display-1',
      'display-2',
      'display-3',
      'display-4',
      'small',
    ];
    $height = [
      'min-vh-100',
      'vh-100',
    ];
    foreach ([
      25,
      50,
      75,
      100,
      'auto',
    ] as $key) {
      $height[] = 'h-' . $key;
    }
    $padding = [];
    $prefixes = [
      'p',
      'py',
      'px',
    ];
    foreach ($prefixes as $prefix) {
      foreach (range(0, 5) as $key) {
        $padding[] = $prefix . '-' . $key;
      }
    }
    $margin = [];
    $prefixes = [
      'm',
      'my',
      'mx',
    ];
    foreach ($prefixes as $prefix) {
      foreach (range(0, 5) as $key) {
        $margin[] = $prefix . '-' . $key;
      }
    }

    // Classes, keyed by group.
    $this->setClassOptions = NestedArray::mergeDeep([
      'background' => $bg,
      'font_size' => $font_size,
      'height' => $height,
      'margin' => $margin,
      'padding' => $padding,
      'text_align' => $text_align,
      'text_color' => $text_color,
      'text_transform' => $text_transform,
      'utility' => $utility,
    ], $this
      ->getVersionClasses());
  }
  return $this->setClassOptions;
}