You are here

abstract class BootstrapBase in GridStack 8.2

Provides the base Bootstrap layout engine.

Hierarchy

Expanded class hierarchy of BootstrapBase

File

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

Namespace

Drupal\gridstack\Plugin\gridstack\engine
View source
abstract class BootstrapBase extends GridBase {

  /**
   * {@inheritdoc}
   */
  protected $containerClasses = [
    'row',
  ];

  /**
   * {@inheritdoc}
   */
  protected $nestedContainerClasses = [
    'row',
  ];

  /**
   * Sets the gridstack engine classes.
   *
   * @inheritdoc
   */
  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;
  }

  /**
   * Returns the base colors.
   */
  protected function baseColors() {
    return [
      'primary',
      'danger',
      'info',
      'warning',
      'success',
    ];
  }

  /**
   * Returns the colors.
   */
  protected function colors() {
    return $this
      ->baseColors();
  }

  /**
   * {@inheritdoc}
   */
  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];
      }
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
BootstrapBase::$containerClasses protected property The container classes, actually refers to row classes, not the outmost. Overrides GridStackEnginePluginBase::$containerClasses
BootstrapBase::$nestedContainerClasses protected property The nested container classes. Overrides GridStackEnginePluginBase::$nestedContainerClasses
BootstrapBase::baseColors protected function Returns the base colors. 1
BootstrapBase::colors protected function Returns the colors. 1
BootstrapBase::itemAttributes protected function Modifies the .box attributes. Overrides GridStackEnginePluginBase::itemAttributes
BootstrapBase::setClassOptions protected function Sets the gridstack engine classes. Overrides GridStackEnginePluginBase::setClassOptions
DependencySerializationTrait::$_entityStorages protected property An array of entity type IDs keyed by the property name of their storages.
DependencySerializationTrait::$_serviceIds protected property An array of service IDs keyed by property name used for serialization.
DependencySerializationTrait::__sleep public function 1
DependencySerializationTrait::__wakeup public function 2
GridBase::$colors protected property The colors.
GridBase::$setClassOptions protected property The class options.
GridBase::$setRowClassOptions protected property The row class options.
GridBase::containerAttributes public function Returns the .gridstack container attributes. Overrides GridStackEnginePluginBase::containerAttributes
GridBase::optimizeClasses protected function Optimize grid widths to remove similar widths.
GridBase::previewOptions public function Returns options which make sense for preview at Layout Builder page. Overrides GridStackEnginePluginBase::previewOptions
GridBase::unique protected function Returns attempted optimized column widths per chunck.
GridStackEnginePluginBase::$classOptions protected property The layout CSS classes for options.
GridStackEnginePluginBase::$colClass protected property The prefix class dependent on framework/ versions: col, cell, columns, etc. 1
GridStackEnginePluginBase::$colPrefix protected property The last prefix dependent on framework/ versions: col-, large, etc. 1
GridStackEnginePluginBase::$itemClasses protected property The item classes, .box.
GridStackEnginePluginBase::$itemContentClasses protected property The item content classes, .box__content.
GridStackEnginePluginBase::$regions protected property The admin regions.
GridStackEnginePluginBase::$rowClassOptions protected property The layout CSS row classes for options.
GridStackEnginePluginBase::$sizes protected property The layout sizes.
GridStackEnginePluginBase::$styles protected property The above-fold CSS inline styles as recommended by lighthouse.
GridStackEnginePluginBase::$stylizer protected property The stylizer service.
GridStackEnginePluginBase::attach public function Provides gridstack skins and libraries. 1
GridStackEnginePluginBase::attributes protected function Provides both CSS grid and js-driven attributes configurable via UI.
GridStackEnginePluginBase::build public function Alters GridStack build. Overrides GridStackEnginePluginInterface::build 1
GridStackEnginePluginBase::buildItem protected function Returns an individual item.
GridStackEnginePluginBase::buildItems public function Builds GridStack boxes to support nested grids for Bootstrap/ Foundation. Overrides GridStackEnginePluginInterface::buildItems
GridStackEnginePluginBase::buildNestedItems protected function Provides nested items if so configured.
GridStackEnginePluginBase::classOptions public function Returns the layout engine classes for select options. Overrides GridStackEnginePluginInterface::classOptions
GridStackEnginePluginBase::containerClasses public function 5
GridStackEnginePluginBase::contentAttributes protected function Provides the .gridstack__inner container attributes.
GridStackEnginePluginBase::create public static function Creates an instance of the plugin. Overrides GridStackPluginBase::create 2
GridStackEnginePluginBase::getIconBreakpoint public function Return the icon breakpoint to generate icon from.
GridStackEnginePluginBase::getSmallestBreakpoint public function Returns the smallest breakpoint, xs or sm.
GridStackEnginePluginBase::getVersionClasses protected function Returns the module feature CSS classes, not available at CSS frameworks. 2
GridStackEnginePluginBase::itemContentAttributes protected function Modifies the .box__content attributes. 1
GridStackEnginePluginBase::modifyItem protected function Modifies item content and attributes.
GridStackEnginePluginBase::modifyNestedItem protected function Modifies nested item contents and attributes.
GridStackEnginePluginBase::nestedContainerAttributes protected function Returns the .gridstack nested container attributes.
GridStackEnginePluginBase::prepare private function Prepares the settings, selector and active styles.
GridStackEnginePluginBase::rowClassOptions public function
GridStackEnginePluginBase::setContainerClasses protected function Sets the optional plugin engine container classes, configurable.
GridStackEnginePluginBase::setRowClassOptions protected function Sets the optional plugin engine classes for options, row, hard-coded. 1
GridStackEnginePluginBase::setSizes protected function Sets the sizes.
GridStackEnginePluginBase::setStyles protected function Sets the styles, might be string, or array.
GridStackEnginePluginBase::sizes public function
GridStackEnginePluginBase::styles public function
GridStackPluginBase::$breakpoints protected property The layout breakpoints.
GridStackPluginBase::$cellHeight protected property The optionset cell height.
GridStackPluginBase::$columns protected property The breakpoint columns.
GridStackPluginBase::$currentUser protected property The current user.
GridStackPluginBase::$manager protected property The gridstack manager service.
GridStackPluginBase::$minWidth protected property The optionset min-width.
GridStackPluginBase::$optionset protected property The gridstack optionset.
GridStackPluginBase::$verticalMargin protected property The optionset vertical margin.
GridStackPluginBase::config protected function Returns gridstack config shortcut.
GridStackPluginBase::defaultConfiguration public function Gets default configuration for this plugin. Overrides ConfigurableInterface::defaultConfiguration 1
GridStackPluginBase::get public function
GridStackPluginBase::getConfiguration public function Gets this plugin's configuration. Overrides ConfigurableInterface::getConfiguration
GridStackPluginBase::getOptionset public function
GridStackPluginBase::getSetting public function
GridStackPluginBase::label public function Returns the plugin label. Overrides GridStackPluginInterface::label
GridStackPluginBase::setConfiguration public function Sets the configuration for this plugin instance. Overrides ConfigurableInterface::setConfiguration
GridStackPluginBase::setOptionset public function Sets the optionset.
GridStackPluginBase::setSetting public function
MessengerTrait::$messenger protected property The messenger. 29
MessengerTrait::messenger public function Gets the messenger. 29
MessengerTrait::setMessenger public function Sets the messenger.
PluginBase::$configuration protected property Configuration information passed into the plugin. 1
PluginBase::$pluginDefinition protected property The plugin implementation definition. 1
PluginBase::$pluginId protected property The plugin_id.
PluginBase::DERIVATIVE_SEPARATOR constant A string which is used to separate base plugin IDs from the derivative ID.
PluginBase::getBaseId public function Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface::getBaseId
PluginBase::getDerivativeId public function Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface::getDerivativeId
PluginBase::getPluginDefinition public function Gets the definition of the plugin implementation. Overrides PluginInspectionInterface::getPluginDefinition 3
PluginBase::getPluginId public function Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface::getPluginId
PluginBase::isConfigurable public function Determines if the plugin is configurable.
PluginBase::__construct public function Constructs a \Drupal\Component\Plugin\PluginBase object. 92
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.