You are here

private function Builder::lbux in GridStack 8.2

Returns a clone of LB UX links.

1 call to Builder::lbux()
Builder::lb in src/Plugin/gridstack/stylizer/Builder.php
Provides Layout Builder attributes.

File

src/Plugin/gridstack/stylizer/Builder.php, line 199

Class

Builder
Provides Layout Builder integration for editor previews.

Namespace

Drupal\gridstack\Plugin\gridstack\stylizer

Code

private function lbux(array $params, $fallback) {
  $links = [
    '#type' => 'container',
    '#attributes' => [
      'class' => [
        'layout-builder__actions',
        'layout-builder__actions__block',
        // In case changed to match the rest BEM, we are prepared.
        'layout-builder__actions--block',
      ],
      'tabindex' => 0,
    ],
    'label' => [
      '#type' => 'html_tag',
      '#tag' => 'span',
      '#attributes' => [
        'class' => [
          'layout-builder__block-label',
        ],
      ],
      'content' => [
        '#markup' => $fallback,
      ],
    ],
    'move' => [
      '#url' => Url::fromRoute('layout_builder.move_block_form', $params),
    ],
    'configure' => [
      '#url' => Url::fromRoute('layout_builder.update_block', $params),
    ],
    'remove' => [
      '#url' => Url::fromRoute('layout_builder.remove_block', $params),
    ],
  ];
  foreach ([
    'move',
    'configure',
    'remove',
  ] as $key) {
    $title = $this
      ->t('@title @block', [
      '@title' => ucwords($key),
      '@block' => $fallback,
    ]);
    $links[$key]['#type'] = 'link';
    $links[$key]['#title'] = [
      '#markup' => '<span class="visually-hidden">' . $title . '</span>',
      '#allowed_tags' => [
        'span',
      ],
    ];
    $links[$key]['#attributes'] = [
      'class' => [
        'use-ajax',
        'layout-builder__link',
        'layout-builder__link--' . $key,
      ],
      'data-dialog-type' => 'dialog',
      'data-dialog-renderer' => 'off_canvas',
    ];
  }
  return $links;
}