You are here

public function StyleBase::attributes in GridStack 8.2

Provides both CSS grid and js-driven attributes configurable via UI.

Can be applied to either $attributes or $content_attributes depending on whether using CSS framework, or original js-driven or native Grid layouts. Must be applied to $content_attributes for UI draggable to work. Do not unset anything here so that nested grids (.row) can still access it.

The CSS BG rule is good at .box or .box__content for native grid, yet .box__content for js-driven and CSS framework due to absolute and overlapping containers respectively. The CSS framework was done at self::modifyNestedItem. For logic consistency, js-driven native grid uses .box__content too.

File

src/Plugin/gridstack/stylizer/StyleBase.php, line 30

Class

StyleBase
Provides the base styles.

Namespace

Drupal\gridstack\Plugin\gridstack\stylizer

Code

public function attributes(array &$attributes, array $settings) {
  if (!empty($settings['attributes']) && is_string($settings['attributes'])) {
    $this
      ->parseAttributes($attributes, $settings['attributes']);
  }
  foreach ([
    'row',
    'wrapper',
  ] as $key) {
    if (!empty($settings[$key . '_classes']) && is_string($settings[$key . '_classes'])) {
      $this
        ->parseClasses($attributes, $settings[$key . '_classes']);
    }
  }

  // These options affect layouts, provides the contexts.
  $this
    ->extraAttributes($attributes, $settings);
}