You are here

public function GridStackEnginePluginBase::containerAttributes in GridStack 8.2

Returns the .gridstack container attributes.

3 calls to GridStackEnginePluginBase::containerAttributes()
GridBase::containerAttributes in src/Plugin/gridstack/engine/GridBase.php
Returns the .gridstack container attributes.
GridStackBase::containerAttributes in src/Plugin/gridstack/engine/GridStackBase.php
Returns the .gridstack container attributes.
GridStackEnginePluginBase::prepare in src/GridStackEnginePluginBase.php
Prepares the settings, selector and active styles.
2 methods override GridStackEnginePluginBase::containerAttributes()
GridBase::containerAttributes in src/Plugin/gridstack/engine/GridBase.php
Returns the .gridstack container attributes.
GridStackBase::containerAttributes in src/Plugin/gridstack/engine/GridStackBase.php
Returns the .gridstack container attributes.

File

src/GridStackEnginePluginBase.php, line 447

Class

GridStackEnginePluginBase
Provides base class for all gridstack layout engines.

Namespace

Drupal\gridstack

Code

public function containerAttributes(array &$attributes, array &$settings) {
  $attributes['class'] = empty($settings['_ungrid']) ? $this
    ->containerClasses() : [];

  // Provides configurable attributes via Layout Builder.
  $this
    ->attributes($attributes, $settings);

  // Add debug class for admin usages.
  if ($this
    ->getSetting('debug') || $this
    ->getSetting('_ipe')) {
    $attributes['class'][] = 'is-gs-debug';
    if ($this
      ->getSetting('_ipe')) {
      $attributes['class'][] = 'is-gs-lb';
      $attributes['data-region'] = GridStackDefault::ROOT;

      // Prevents parallax from messing around the admin page.
      // We'll toggle as needed via JS if doable instead.
      if (in_array('is-gs-parallax', $attributes['class'])) {
        $removed = [
          'is-gs-parallax',
          'is-gs-parallax-fs',
        ];
        $attributes['class'] = array_diff($attributes['class'], $removed);
      }
    }
    if ($this
      ->getSetting('_lbux')) {
      $attributes['class'][] = 'is-gs-lbux';
    }
  }

  // Empty it after being processed to not leak to children due to similarity.
  unset($settings['attributes'], $settings['wrapper_classes'], $settings['fw_classes']);

  // Unique class per layout which can be many similar on a page.
  if ($gid = $this
    ->getSetting('gid')) {
    $attributes['class'][] = 'is-gs-' . str_replace([
      '_',
      ':',
    ], '-', $gid);
  }

  // Unique class per layout variant which can be many similar on a page.
  if ($variant = $this
    ->getSetting('_variant')) {
    $attributes['class'][] = $this->stylizer
      ->style()
      ->getVariantClass($variant);
  }

  // Adds .blazy container to manage lazy load, or lightboxes per layout.
  Blazy::containerAttributes($attributes, $settings);

  // Provides configurable item attributes.
  if ($this->stylizer
    ->getStyle('parallax-fs', $settings)) {
    $attributes['class'][] = 'is-b-scroll';

    // @todo remove post blazy:2.1+.
    // Old bLazy, not IO, needs scrolling container to lazyload correctly.
    // With fullscreen parallax, the body overflow is hidden for parallax
    // container own scrollbar, hence we need to provide the option.
    $blazy = empty($attributes['data-blazy']) ? [] : Json::decode($attributes['data-blazy']);
    $blazy['container'] = '.is-b-scroll';
    $attributes['data-blazy'] = Json::encode($blazy);
  }
}