You are here

public function Extras::afterBuildExtras in GridStack 8.2

Provides preview classes.

File

src/Plugin/gridstack/stylizer/Extras.php, line 110

Class

Extras
Provides the extras styles.

Namespace

Drupal\gridstack\Plugin\gridstack\stylizer

Code

public function afterBuildExtras(array $element) {
  $settings = $element['#settings'];
  $use_background = $this
    ->getStyle('background', $settings);
  $removed = [
    'form-wrapper--extras',
    'is-collapsible',
    'is-collapsed',
    'is-gs-fieldset',
  ];
  foreach (Element::children($element) as $key) {
    $element[$key]['#attributes']['data-gs-extras-region'] = $element['#region'];
    $element[$key]['#attributes']['data-gs-extras-region-class'] = 'is-gs-' . str_replace('_', '-', $key);
    $element[$key]['#attributes']['data-gs-bg-selector'] = $use_background ? '.b-gs .media__element' : '.b-gs';
    if ($key == 'parallax') {
      $element[$key]['#description'] = $this
        ->t('Recipes: BG, Min height, EtE at odd rows, non-EtE even, or vice versa, for simple parallax. Use non-BG for regular transitions. Plus few more adjustments.');
    }

    // Unfortunately container classes are also inherited by each item.
    if (isset($element[$key]['#attributes']['class'])) {
      $classes = $element[$key]['#attributes']['class'];
      $classes = array_diff($classes, $removed);
      $element[$key]['#attributes']['class'] = $classes;
    }
  }
  return $element;
}