You are here

protected function BootstrapBase::itemAttributes in GridStack 8.2

Modifies the .box attributes.

Overrides GridStackEnginePluginBase::itemAttributes

File

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

Class

BootstrapBase
Provides the base Bootstrap layout engine.

Namespace

Drupal\gridstack\Plugin\gridstack\engine

Code

protected function itemAttributes(array &$attributes, array &$settings) {
  parent::itemAttributes($attributes, $settings);
  $classes = $this
    ->optimizeClasses($settings);
  $column = $classes['column'];
  $region = $classes['region'];
  if (!empty($region[0])) {
    $attributes['class'][] = 'box--' . Html::cleanCssIdentifier($region[0]);
  }

  // Allows custom overrides such as for parallax layouts.
  if (!empty($settings['_ungrid'])) {
    return;
  }

  // Bootstrap 4 uses flexbox with `col` class, and has `xl` breakpoint.
  $attributes['class'][] = $this->colClass;
  foreach ($this->sizes as $point => $label) {
    if (!isset($column[$point])) {
      continue;
    }

    // Specific to XS: Bootstrap 3: col-xs-*, Bootstrap 4: col-*.
    $col_class = $this->colClass . '-' . $point . '-';
    if ($this
      ->getSetting('framework') != 'bootstrap3' && $point == 'xs') {
      $col_class = $this->colClass . '-';
    }
    if ($column[$point]) {
      $attributes['class'][] = $col_class . $column[$point];
    }
  }
}