Code Coverage
 
Lines
Branches
Paths
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 94
0.00% covered (danger)
0.00%
0 / 40
0.00% covered (danger)
0.00%
0 / 49
0.00% covered (danger)
0.00%
0 / 6
CRAP
0.00% covered (danger)
0.00%
0 / 1
ControlsButtons
0.00% covered (danger)
0.00%
0 / 88
0.00% covered (danger)
0.00%
0 / 40
0.00% covered (danger)
0.00%
0 / 49
0.00% covered (danger)
0.00%
0 / 6
380
0.00% covered (danger)
0.00%
0 / 1
 build
0.00% covered (danger)
0.00%
0 / 24
0.00% covered (danger)
0.00%
0 / 11
0.00% covered (danger)
0.00%
0 / 32
0.00% covered (danger)
0.00%
0 / 1
42
 hasButtons
0.00% covered (danger)
0.00%
0 / 21
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 buildHighlightButton
0.00% covered (danger)
0.00%
0 / 9
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
12
 buildFullscreenButton
0.00% covered (danger)
0.00%
0 / 9
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
12
 buildThemeMenu
0.00% covered (danger)
0.00%
0 / 19
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
12
 buildKeyboardButton
0.00% covered (danger)
0.00%
0 / 6
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
12
1<?php
2
3declare(strict_types=1);
4
5namespace Drupal\display_builder\Plugin\display_builder\Island;
6
7use Drupal\Core\StringTranslation\TranslatableMarkup;
8use Drupal\display_builder\Attribute\Island;
9use Drupal\display_builder\InstanceInterface;
10use Drupal\display_builder\IslandPluginToolbarButtonConfigurationBase;
11use Drupal\display_builder\IslandType;
12
13/**
14 * Controls button island plugin implementation.
15 */
16#[Island(
17  id: 'controls',
18  enabled_by_default: TRUE,
19  label: new TranslatableMarkup('Controls'),
20  description: new TranslatableMarkup('Control the building experience.'),
21  type: IslandType::Button,
22)]
23class ControlsButtons extends IslandPluginToolbarButtonConfigurationBase {
24
25  /**
26   * {@inheritdoc}
27   */
28  public function build(InstanceInterface $builder, array $data = [], array $options = []): array {
29    $buttons = [];
30    $library = [];
31
32    if ($this->isButtonEnabled('highlight')) {
33      $buttons[] = $this->buildHighlightButton();
34      $library[] = 'display_builder/highlight';
35    }
36
37    if ($this->isButtonEnabled('fullscreen')) {
38      $buttons[] = $this->buildFullscreenButton();
39      $library[] = 'display_builder/fullscreen';
40    }
41
42    if ($this->isButtonEnabled('theme')) {
43      $buttons[] = $this->buildThemeMenu();
44    }
45
46    if ($this->isButtonEnabled('help')) {
47      $buttons[] = $this->buildKeyboardButton();
48    }
49
50    if (empty($buttons)) {
51      return [];
52    }
53
54    return [
55      '#type' => 'component',
56      '#component' => 'display_builder:button_group',
57      '#slots' => [
58        'buttons' => $buttons,
59      ],
60      '#attached' => [
61        'library' => $library,
62      ],
63    ];
64  }
65
66  /**
67   * {@inheritdoc}
68   */
69  protected function hasButtons(): array {
70    return [
71      'highlight' => [
72        'title' => $this->t('Highlight'),
73        'description' => $this->t('Highlight builder zones to ease drag and move around.'),
74        'default' => 'icon',
75      ],
76      'fullscreen' => [
77        'title' => $this->t('Fullscreen'),
78        'default' => 'icon',
79      ],
80      'theme' => [
81        'title' => $this->t('Theme'),
82        'description' => $this->t('Pick a theme mode as light/dark/system for the display builder.'),
83        'default' => 'icon',
84      ],
85      'help' => [
86        'title' => $this->t('Help'),
87        'description' => $this->t('Information about the available keyboard shortcuts.'),
88        'default' => 'icon',
89      ],
90    ];
91  }
92
93  /**
94   * Builds the highlight button.
95   *
96   * @return array
97   *   The highlight button render array.
98   */
99  private function buildHighlightButton(): array {
100    $highlight = $this->buildButton(
101      $this->showLabel('highlight') ? $this->t('Highlight') : '',
102      'highlight',
103      $this->showIcon('highlight') ? 'border' : '',
104      $this->t('Highlight components. (shortcut: H)'),
105      ['H' => $this->t('Toggle highlight (shift+H)')]
106    );
107    // Required for the library to work.
108    $highlight['#attributes']['data-set-highlight'] = TRUE;
109
110    return $highlight;
111  }
112
113  /**
114   * Builds the fullscreen button.
115   *
116   * @return array
117   *   The fullscreen button render array.
118   */
119  private function buildFullscreenButton(): array {
120    $fullscreen = $this->buildButton(
121      $this->showLabel('fullscreen') ? $this->t('Fullscreen') : '',
122      'fullscreen',
123      $this->showIcon('fullscreen') ? 'fullscreen' : '',
124      $this->t('Toggle fullscreen. (shortcut: F)'),
125      ['F' => $this->t('Toggle fullscreen (shift+F)')]
126    );
127    // Required for the library to work.
128    $fullscreen['#attributes']['data-set-fullscreen'] = TRUE;
129
130    return $fullscreen;
131  }
132
133  /**
134   * Builds the theme menu component.
135   *
136   * @return array
137   *   The theme menu component render array.
138   */
139  private function buildThemeMenu(): array {
140    return [
141      '#type' => 'component',
142      '#component' => 'display_builder:theme_menu',
143      '#attributes' => [
144        'placement' => 'bottom-end',
145        'data-theme-switch' => TRUE,
146      ],
147      '#slots' => [
148        'button' => $this->buildButton(
149          $this->showLabel('theme') ? $this->t('Theme') : '',
150          'theme',
151          $this->showIcon('theme') ? 'sun' : '',
152        ),
153      ],
154      '#props' => [
155        'tooltip' => $this->t('Switch the display builder interface theme.'),
156        'icon' => 'sun',
157      ],
158    ];
159  }
160
161  /**
162   * Builds the keyboard button.
163   *
164   * @return array
165   *   The keyboard button render array.
166   */
167  private function buildKeyboardButton(): array {
168    return $this->buildButton(
169      $this->showLabel('help') ? $this->t('Help') : '',
170      'help',
171      $this->showIcon('help') ? 'question-circle' : '',
172      '...'
173    );
174  }
175
176}

Paths

Below are the source code lines that represent each code path as identified by Xdebug. Please note a path is not necessarily coterminous with a line, a line may contain multiple paths and therefore show up more than once. Please also be aware that some paths may include implicit rather than explicit branches, e.g. an if statement always has an else as part of its logical flow even if you didn't write one.

ControlsButtons->build
28  public function build(InstanceInterface $builder, array $data = [], array $options = []): array {
29    $buttons = [];
30    $library = [];
31
32    if ($this->isButtonEnabled('highlight')) {
 
33      $buttons[] = $this->buildHighlightButton();
34      $library[] = 'display_builder/highlight';
35    }
36
37    if ($this->isButtonEnabled('fullscreen')) {
 
37    if ($this->isButtonEnabled('fullscreen')) {
 
38      $buttons[] = $this->buildFullscreenButton();
39      $library[] = 'display_builder/fullscreen';
40    }
41
42    if ($this->isButtonEnabled('theme')) {
 
42    if ($this->isButtonEnabled('theme')) {
 
43      $buttons[] = $this->buildThemeMenu();
44    }
45
46    if ($this->isButtonEnabled('help')) {
 
46    if ($this->isButtonEnabled('help')) {
 
47      $buttons[] = $this->buildKeyboardButton();
48    }
49
50    if (empty($buttons)) {
 
50    if (empty($buttons)) {
 
51      return [];
28  public function build(InstanceInterface $builder, array $data = [], array $options = []): array {
29    $buttons = [];
30    $library = [];
31
32    if ($this->isButtonEnabled('highlight')) {
 
33      $buttons[] = $this->buildHighlightButton();
34      $library[] = 'display_builder/highlight';
35    }
36
37    if ($this->isButtonEnabled('fullscreen')) {
 
37    if ($this->isButtonEnabled('fullscreen')) {
 
38      $buttons[] = $this->buildFullscreenButton();
39      $library[] = 'display_builder/fullscreen';
40    }
41
42    if ($this->isButtonEnabled('theme')) {
 
42    if ($this->isButtonEnabled('theme')) {
 
43      $buttons[] = $this->buildThemeMenu();
44    }
45
46    if ($this->isButtonEnabled('help')) {
 
46    if ($this->isButtonEnabled('help')) {
 
47      $buttons[] = $this->buildKeyboardButton();
48    }
49
50    if (empty($buttons)) {
 
50    if (empty($buttons)) {
 
55      '#type' => 'component',
56      '#component' => 'display_builder:button_group',
57      '#slots' => [
58        'buttons' => $buttons,
59      ],
60      '#attached' => [
61        'library' => $library,
28  public function build(InstanceInterface $builder, array $data = [], array $options = []): array {
29    $buttons = [];
30    $library = [];
31
32    if ($this->isButtonEnabled('highlight')) {
 
33      $buttons[] = $this->buildHighlightButton();
34      $library[] = 'display_builder/highlight';
35    }
36
37    if ($this->isButtonEnabled('fullscreen')) {
 
37    if ($this->isButtonEnabled('fullscreen')) {
 
38      $buttons[] = $this->buildFullscreenButton();
39      $library[] = 'display_builder/fullscreen';
40    }
41
42    if ($this->isButtonEnabled('theme')) {
 
42    if ($this->isButtonEnabled('theme')) {
 
43      $buttons[] = $this->buildThemeMenu();
44    }
45
46    if ($this->isButtonEnabled('help')) {
 
46    if ($this->isButtonEnabled('help')) {
 
50    if (empty($buttons)) {
 
51      return [];
28  public function build(InstanceInterface $builder, array $data = [], array $options = []): array {
29    $buttons = [];
30    $library = [];
31
32    if ($this->isButtonEnabled('highlight')) {
 
33      $buttons[] = $this->buildHighlightButton();
34      $library[] = 'display_builder/highlight';
35    }
36
37    if ($this->isButtonEnabled('fullscreen')) {
 
37    if ($this->isButtonEnabled('fullscreen')) {
 
38      $buttons[] = $this->buildFullscreenButton();
39      $library[] = 'display_builder/fullscreen';
40    }
41
42    if ($this->isButtonEnabled('theme')) {
 
42    if ($this->isButtonEnabled('theme')) {
 
43      $buttons[] = $this->buildThemeMenu();
44    }
45
46    if ($this->isButtonEnabled('help')) {
 
46    if ($this->isButtonEnabled('help')) {
 
50    if (empty($buttons)) {
 
55      '#type' => 'component',
56      '#component' => 'display_builder:button_group',
57      '#slots' => [
58        'buttons' => $buttons,
59      ],
60      '#attached' => [
61        'library' => $library,
28  public function build(InstanceInterface $builder, array $data = [], array $options = []): array {
29    $buttons = [];
30    $library = [];
31
32    if ($this->isButtonEnabled('highlight')) {
 
33      $buttons[] = $this->buildHighlightButton();
34      $library[] = 'display_builder/highlight';
35    }
36
37    if ($this->isButtonEnabled('fullscreen')) {
 
37    if ($this->isButtonEnabled('fullscreen')) {
 
38      $buttons[] = $this->buildFullscreenButton();
39      $library[] = 'display_builder/fullscreen';
40    }
41
42    if ($this->isButtonEnabled('theme')) {
 
42    if ($this->isButtonEnabled('theme')) {
 
46    if ($this->isButtonEnabled('help')) {
 
47      $buttons[] = $this->buildKeyboardButton();
48    }
49
50    if (empty($buttons)) {
 
50    if (empty($buttons)) {
 
51      return [];
28  public function build(InstanceInterface $builder, array $data = [], array $options = []): array {
29    $buttons = [];
30    $library = [];
31
32    if ($this->isButtonEnabled('highlight')) {
 
33      $buttons[] = $this->buildHighlightButton();
34      $library[] = 'display_builder/highlight';
35    }
36
37    if ($this->isButtonEnabled('fullscreen')) {
 
37    if ($this->isButtonEnabled('fullscreen')) {
 
38      $buttons[] = $this->buildFullscreenButton();
39      $library[] = 'display_builder/fullscreen';
40    }
41
42    if ($this->isButtonEnabled('theme')) {
 
42    if ($this->isButtonEnabled('theme')) {
 
46    if ($this->isButtonEnabled('help')) {
 
47      $buttons[] = $this->buildKeyboardButton();
48    }
49
50    if (empty($buttons)) {
 
50    if (empty($buttons)) {
 
55      '#type' => 'component',
56      '#component' => 'display_builder:button_group',
57      '#slots' => [
58        'buttons' => $buttons,
59      ],
60      '#attached' => [
61        'library' => $library,
28  public function build(InstanceInterface $builder, array $data = [], array $options = []): array {
29    $buttons = [];
30    $library = [];
31
32    if ($this->isButtonEnabled('highlight')) {
 
33      $buttons[] = $this->buildHighlightButton();
34      $library[] = 'display_builder/highlight';
35    }
36
37    if ($this->isButtonEnabled('fullscreen')) {
 
37    if ($this->isButtonEnabled('fullscreen')) {
 
38      $buttons[] = $this->buildFullscreenButton();
39      $library[] = 'display_builder/fullscreen';
40    }
41
42    if ($this->isButtonEnabled('theme')) {
 
42    if ($this->isButtonEnabled('theme')) {
 
46    if ($this->isButtonEnabled('help')) {
 
50    if (empty($buttons)) {
 
51      return [];
28  public function build(InstanceInterface $builder, array $data = [], array $options = []): array {
29    $buttons = [];
30    $library = [];
31
32    if ($this->isButtonEnabled('highlight')) {
 
33      $buttons[] = $this->buildHighlightButton();
34      $library[] = 'display_builder/highlight';
35    }
36
37    if ($this->isButtonEnabled('fullscreen')) {
 
37    if ($this->isButtonEnabled('fullscreen')) {
 
38      $buttons[] = $this->buildFullscreenButton();
39      $library[] = 'display_builder/fullscreen';
40    }
41
42    if ($this->isButtonEnabled('theme')) {
 
42    if ($this->isButtonEnabled('theme')) {
 
46    if ($this->isButtonEnabled('help')) {
 
50    if (empty($buttons)) {
 
55      '#type' => 'component',
56      '#component' => 'display_builder:button_group',
57      '#slots' => [
58        'buttons' => $buttons,
59      ],
60      '#attached' => [
61        'library' => $library,
28  public function build(InstanceInterface $builder, array $data = [], array $options = []): array {
29    $buttons = [];
30    $library = [];
31
32    if ($this->isButtonEnabled('highlight')) {
 
33      $buttons[] = $this->buildHighlightButton();
34      $library[] = 'display_builder/highlight';
35    }
36
37    if ($this->isButtonEnabled('fullscreen')) {
 
37    if ($this->isButtonEnabled('fullscreen')) {
 
42    if ($this->isButtonEnabled('theme')) {
 
43      $buttons[] = $this->buildThemeMenu();
44    }
45
46    if ($this->isButtonEnabled('help')) {
 
46    if ($this->isButtonEnabled('help')) {
 
47      $buttons[] = $this->buildKeyboardButton();
48    }
49
50    if (empty($buttons)) {
 
50    if (empty($buttons)) {
 
51      return [];
28  public function build(InstanceInterface $builder, array $data = [], array $options = []): array {
29    $buttons = [];
30    $library = [];
31
32    if ($this->isButtonEnabled('highlight')) {
 
33      $buttons[] = $this->buildHighlightButton();
34      $library[] = 'display_builder/highlight';
35    }
36
37    if ($this->isButtonEnabled('fullscreen')) {
 
37    if ($this->isButtonEnabled('fullscreen')) {
 
42    if ($this->isButtonEnabled('theme')) {
 
43      $buttons[] = $this->buildThemeMenu();
44    }
45
46    if ($this->isButtonEnabled('help')) {
 
46    if ($this->isButtonEnabled('help')) {
 
47      $buttons[] = $this->buildKeyboardButton();
48    }
49
50    if (empty($buttons)) {
 
50    if (empty($buttons)) {
 
55      '#type' => 'component',
56      '#component' => 'display_builder:button_group',
57      '#slots' => [
58        'buttons' => $buttons,
59      ],
60      '#attached' => [
61        'library' => $library,
28  public function build(InstanceInterface $builder, array $data = [], array $options = []): array {
29    $buttons = [];
30    $library = [];
31
32    if ($this->isButtonEnabled('highlight')) {
 
33      $buttons[] = $this->buildHighlightButton();
34      $library[] = 'display_builder/highlight';
35    }
36
37    if ($this->isButtonEnabled('fullscreen')) {
 
37    if ($this->isButtonEnabled('fullscreen')) {
 
42    if ($this->isButtonEnabled('theme')) {
 
43      $buttons[] = $this->buildThemeMenu();
44    }
45
46    if ($this->isButtonEnabled('help')) {
 
46    if ($this->isButtonEnabled('help')) {
 
50    if (empty($buttons)) {
 
51      return [];
28  public function build(InstanceInterface $builder, array $data = [], array $options = []): array {
29    $buttons = [];
30    $library = [];
31
32    if ($this->isButtonEnabled('highlight')) {
 
33      $buttons[] = $this->buildHighlightButton();
34      $library[] = 'display_builder/highlight';
35    }
36
37    if ($this->isButtonEnabled('fullscreen')) {
 
37    if ($this->isButtonEnabled('fullscreen')) {
 
42    if ($this->isButtonEnabled('theme')) {
 
43      $buttons[] = $this->buildThemeMenu();
44    }
45
46    if ($this->isButtonEnabled('help')) {
 
46    if ($this->isButtonEnabled('help')) {
 
50    if (empty($buttons)) {
 
55      '#type' => 'component',
56      '#component' => 'display_builder:button_group',
57      '#slots' => [
58        'buttons' => $buttons,
59      ],
60      '#attached' => [
61        'library' => $library,
28  public function build(InstanceInterface $builder, array $data = [], array $options = []): array {
29    $buttons = [];
30    $library = [];
31
32    if ($this->isButtonEnabled('highlight')) {
 
33      $buttons[] = $this->buildHighlightButton();
34      $library[] = 'display_builder/highlight';
35    }
36
37    if ($this->isButtonEnabled('fullscreen')) {
 
37    if ($this->isButtonEnabled('fullscreen')) {
 
42    if ($this->isButtonEnabled('theme')) {
 
46    if ($this->isButtonEnabled('help')) {
 
47      $buttons[] = $this->buildKeyboardButton();
48    }
49
50    if (empty($buttons)) {
 
50    if (empty($buttons)) {
 
51      return [];
28  public function build(InstanceInterface $builder, array $data = [], array $options = []): array {
29    $buttons = [];
30    $library = [];
31
32    if ($this->isButtonEnabled('highlight')) {
 
33      $buttons[] = $this->buildHighlightButton();
34      $library[] = 'display_builder/highlight';
35    }
36
37    if ($this->isButtonEnabled('fullscreen')) {
 
37    if ($this->isButtonEnabled('fullscreen')) {
 
42    if ($this->isButtonEnabled('theme')) {
 
46    if ($this->isButtonEnabled('help')) {
 
47      $buttons[] = $this->buildKeyboardButton();
48    }
49
50    if (empty($buttons)) {
 
50    if (empty($buttons)) {
 
55      '#type' => 'component',
56      '#component' => 'display_builder:button_group',
57      '#slots' => [
58        'buttons' => $buttons,
59      ],
60      '#attached' => [
61        'library' => $library,
28  public function build(InstanceInterface $builder, array $data = [], array $options = []): array {
29    $buttons = [];
30    $library = [];
31
32    if ($this->isButtonEnabled('highlight')) {
 
33      $buttons[] = $this->buildHighlightButton();
34      $library[] = 'display_builder/highlight';
35    }
36
37    if ($this->isButtonEnabled('fullscreen')) {
 
37    if ($this->isButtonEnabled('fullscreen')) {
 
42    if ($this->isButtonEnabled('theme')) {
 
46    if ($this->isButtonEnabled('help')) {
 
50    if (empty($buttons)) {
 
51      return [];
28  public function build(InstanceInterface $builder, array $data = [], array $options = []): array {
29    $buttons = [];
30    $library = [];
31
32    if ($this->isButtonEnabled('highlight')) {
 
33      $buttons[] = $this->buildHighlightButton();
34      $library[] = 'display_builder/highlight';
35    }
36
37    if ($this->isButtonEnabled('fullscreen')) {
 
37    if ($this->isButtonEnabled('fullscreen')) {
 
42    if ($this->isButtonEnabled('theme')) {
 
46    if ($this->isButtonEnabled('help')) {
 
50    if (empty($buttons)) {
 
55      '#type' => 'component',
56      '#component' => 'display_builder:button_group',
57      '#slots' => [
58        'buttons' => $buttons,
59      ],
60      '#attached' => [
61        'library' => $library,
28  public function build(InstanceInterface $builder, array $data = [], array $options = []): array {
29    $buttons = [];
30    $library = [];
31
32    if ($this->isButtonEnabled('highlight')) {
 
37    if ($this->isButtonEnabled('fullscreen')) {
 
38      $buttons[] = $this->buildFullscreenButton();
39      $library[] = 'display_builder/fullscreen';
40    }
41
42    if ($this->isButtonEnabled('theme')) {
 
42    if ($this->isButtonEnabled('theme')) {
 
43      $buttons[] = $this->buildThemeMenu();
44    }
45
46    if ($this->isButtonEnabled('help')) {
 
46    if ($this->isButtonEnabled('help')) {
 
47      $buttons[] = $this->buildKeyboardButton();
48    }
49
50    if (empty($buttons)) {
 
50    if (empty($buttons)) {
 
51      return [];
28  public function build(InstanceInterface $builder, array $data = [], array $options = []): array {
29    $buttons = [];
30    $library = [];
31
32    if ($this->isButtonEnabled('highlight')) {
 
37    if ($this->isButtonEnabled('fullscreen')) {
 
38      $buttons[] = $this->buildFullscreenButton();
39      $library[] = 'display_builder/fullscreen';
40    }
41
42    if ($this->isButtonEnabled('theme')) {
 
42    if ($this->isButtonEnabled('theme')) {
 
43      $buttons[] = $this->buildThemeMenu();
44    }
45
46    if ($this->isButtonEnabled('help')) {
 
46    if ($this->isButtonEnabled('help')) {
 
47      $buttons[] = $this->buildKeyboardButton();
48    }
49
50    if (empty($buttons)) {
 
50    if (empty($buttons)) {
 
55      '#type' => 'component',
56      '#component' => 'display_builder:button_group',
57      '#slots' => [
58        'buttons' => $buttons,
59      ],
60      '#attached' => [
61        'library' => $library,
28  public function build(InstanceInterface $builder, array $data = [], array $options = []): array {
29    $buttons = [];
30    $library = [];
31
32    if ($this->isButtonEnabled('highlight')) {
 
37    if ($this->isButtonEnabled('fullscreen')) {
 
38      $buttons[] = $this->buildFullscreenButton();
39      $library[] = 'display_builder/fullscreen';
40    }
41
42    if ($this->isButtonEnabled('theme')) {
 
42    if ($this->isButtonEnabled('theme')) {
 
43      $buttons[] = $this->buildThemeMenu();
44    }
45
46    if ($this->isButtonEnabled('help')) {
 
46    if ($this->isButtonEnabled('help')) {
 
50    if (empty($buttons)) {
 
51      return [];
28  public function build(InstanceInterface $builder, array $data = [], array $options = []): array {
29    $buttons = [];
30    $library = [];
31
32    if ($this->isButtonEnabled('highlight')) {
 
37    if ($this->isButtonEnabled('fullscreen')) {
 
38      $buttons[] = $this->buildFullscreenButton();
39      $library[] = 'display_builder/fullscreen';
40    }
41
42    if ($this->isButtonEnabled('theme')) {
 
42    if ($this->isButtonEnabled('theme')) {
 
43      $buttons[] = $this->buildThemeMenu();
44    }
45
46    if ($this->isButtonEnabled('help')) {
 
46    if ($this->isButtonEnabled('help')) {
 
50    if (empty($buttons)) {
 
55      '#type' => 'component',
56      '#component' => 'display_builder:button_group',
57      '#slots' => [
58        'buttons' => $buttons,
59      ],
60      '#attached' => [
61        'library' => $library,
28  public function build(InstanceInterface $builder, array $data = [], array $options = []): array {
29    $buttons = [];
30    $library = [];
31
32    if ($this->isButtonEnabled('highlight')) {
 
37    if ($this->isButtonEnabled('fullscreen')) {
 
38      $buttons[] = $this->buildFullscreenButton();
39      $library[] = 'display_builder/fullscreen';
40    }
41
42    if ($this->isButtonEnabled('theme')) {
 
42    if ($this->isButtonEnabled('theme')) {
 
46    if ($this->isButtonEnabled('help')) {
 
47      $buttons[] = $this->buildKeyboardButton();
48    }
49
50    if (empty($buttons)) {
 
50    if (empty($buttons)) {
 
51      return [];
28  public function build(InstanceInterface $builder, array $data = [], array $options = []): array {
29    $buttons = [];
30    $library = [];
31
32    if ($this->isButtonEnabled('highlight')) {
 
37    if ($this->isButtonEnabled('fullscreen')) {
 
38      $buttons[] = $this->buildFullscreenButton();
39      $library[] = 'display_builder/fullscreen';
40    }
41
42    if ($this->isButtonEnabled('theme')) {
 
42    if ($this->isButtonEnabled('theme')) {
 
46    if ($this->isButtonEnabled('help')) {
 
47      $buttons[] = $this->buildKeyboardButton();
48    }
49
50    if (empty($buttons)) {
 
50    if (empty($buttons)) {
 
55      '#type' => 'component',
56      '#component' => 'display_builder:button_group',
57      '#slots' => [
58        'buttons' => $buttons,
59      ],
60      '#attached' => [
61        'library' => $library,
28  public function build(InstanceInterface $builder, array $data = [], array $options = []): array {
29    $buttons = [];
30    $library = [];
31
32    if ($this->isButtonEnabled('highlight')) {
 
37    if ($this->isButtonEnabled('fullscreen')) {
 
38      $buttons[] = $this->buildFullscreenButton();
39      $library[] = 'display_builder/fullscreen';
40    }
41
42    if ($this->isButtonEnabled('theme')) {
 
42    if ($this->isButtonEnabled('theme')) {
 
46    if ($this->isButtonEnabled('help')) {
 
50    if (empty($buttons)) {
 
51      return [];
28  public function build(InstanceInterface $builder, array $data = [], array $options = []): array {
29    $buttons = [];
30    $library = [];
31
32    if ($this->isButtonEnabled('highlight')) {
 
37    if ($this->isButtonEnabled('fullscreen')) {
 
38      $buttons[] = $this->buildFullscreenButton();
39      $library[] = 'display_builder/fullscreen';
40    }
41
42    if ($this->isButtonEnabled('theme')) {
 
42    if ($this->isButtonEnabled('theme')) {
 
46    if ($this->isButtonEnabled('help')) {
 
50    if (empty($buttons)) {
 
55      '#type' => 'component',
56      '#component' => 'display_builder:button_group',
57      '#slots' => [
58        'buttons' => $buttons,
59      ],
60      '#attached' => [
61        'library' => $library,
28  public function build(InstanceInterface $builder, array $data = [], array $options = []): array {
29    $buttons = [];
30    $library = [];
31
32    if ($this->isButtonEnabled('highlight')) {
 
37    if ($this->isButtonEnabled('fullscreen')) {
 
42    if ($this->isButtonEnabled('theme')) {
 
43      $buttons[] = $this->buildThemeMenu();
44    }
45
46    if ($this->isButtonEnabled('help')) {
 
46    if ($this->isButtonEnabled('help')) {
 
47      $buttons[] = $this->buildKeyboardButton();
48    }
49
50    if (empty($buttons)) {
 
50    if (empty($buttons)) {
 
51      return [];
28  public function build(InstanceInterface $builder, array $data = [], array $options = []): array {
29    $buttons = [];
30    $library = [];
31
32    if ($this->isButtonEnabled('highlight')) {
 
37    if ($this->isButtonEnabled('fullscreen')) {
 
42    if ($this->isButtonEnabled('theme')) {
 
43      $buttons[] = $this->buildThemeMenu();
44    }
45
46    if ($this->isButtonEnabled('help')) {
 
46    if ($this->isButtonEnabled('help')) {
 
47      $buttons[] = $this->buildKeyboardButton();
48    }
49
50    if (empty($buttons)) {
 
50    if (empty($buttons)) {
 
55      '#type' => 'component',
56      '#component' => 'display_builder:button_group',
57      '#slots' => [
58        'buttons' => $buttons,
59      ],
60      '#attached' => [
61        'library' => $library,
28  public function build(InstanceInterface $builder, array $data = [], array $options = []): array {
29    $buttons = [];
30    $library = [];
31
32    if ($this->isButtonEnabled('highlight')) {
 
37    if ($this->isButtonEnabled('fullscreen')) {
 
42    if ($this->isButtonEnabled('theme')) {
 
43      $buttons[] = $this->buildThemeMenu();
44    }
45
46    if ($this->isButtonEnabled('help')) {
 
46    if ($this->isButtonEnabled('help')) {
 
50    if (empty($buttons)) {
 
51      return [];
28  public function build(InstanceInterface $builder, array $data = [], array $options = []): array {
29    $buttons = [];
30    $library = [];
31
32    if ($this->isButtonEnabled('highlight')) {
 
37    if ($this->isButtonEnabled('fullscreen')) {
 
42    if ($this->isButtonEnabled('theme')) {
 
43      $buttons[] = $this->buildThemeMenu();
44    }
45
46    if ($this->isButtonEnabled('help')) {
 
46    if ($this->isButtonEnabled('help')) {
 
50    if (empty($buttons)) {
 
55      '#type' => 'component',
56      '#component' => 'display_builder:button_group',
57      '#slots' => [
58        'buttons' => $buttons,
59      ],
60      '#attached' => [
61        'library' => $library,
28  public function build(InstanceInterface $builder, array $data = [], array $options = []): array {
29    $buttons = [];
30    $library = [];
31
32    if ($this->isButtonEnabled('highlight')) {
 
37    if ($this->isButtonEnabled('fullscreen')) {
 
42    if ($this->isButtonEnabled('theme')) {
 
46    if ($this->isButtonEnabled('help')) {
 
47      $buttons[] = $this->buildKeyboardButton();
48    }
49
50    if (empty($buttons)) {
 
50    if (empty($buttons)) {
 
51      return [];
28  public function build(InstanceInterface $builder, array $data = [], array $options = []): array {
29    $buttons = [];
30    $library = [];
31
32    if ($this->isButtonEnabled('highlight')) {
 
37    if ($this->isButtonEnabled('fullscreen')) {
 
42    if ($this->isButtonEnabled('theme')) {
 
46    if ($this->isButtonEnabled('help')) {
 
47      $buttons[] = $this->buildKeyboardButton();
48    }
49
50    if (empty($buttons)) {
 
50    if (empty($buttons)) {
 
55      '#type' => 'component',
56      '#component' => 'display_builder:button_group',
57      '#slots' => [
58        'buttons' => $buttons,
59      ],
60      '#attached' => [
61        'library' => $library,
28  public function build(InstanceInterface $builder, array $data = [], array $options = []): array {
29    $buttons = [];
30    $library = [];
31
32    if ($this->isButtonEnabled('highlight')) {
 
37    if ($this->isButtonEnabled('fullscreen')) {
 
42    if ($this->isButtonEnabled('theme')) {
 
46    if ($this->isButtonEnabled('help')) {
 
50    if (empty($buttons)) {
 
51      return [];
28  public function build(InstanceInterface $builder, array $data = [], array $options = []): array {
29    $buttons = [];
30    $library = [];
31
32    if ($this->isButtonEnabled('highlight')) {
 
37    if ($this->isButtonEnabled('fullscreen')) {
 
42    if ($this->isButtonEnabled('theme')) {
 
46    if ($this->isButtonEnabled('help')) {
 
50    if (empty($buttons)) {
 
55      '#type' => 'component',
56      '#component' => 'display_builder:button_group',
57      '#slots' => [
58        'buttons' => $buttons,
59      ],
60      '#attached' => [
61        'library' => $library,
ControlsButtons->buildFullscreenButton
120    $fullscreen = $this->buildButton(
121      $this->showLabel('fullscreen') ? $this->t('Fullscreen') : '',
 
121      $this->showLabel('fullscreen') ? $this->t('Fullscreen') : '',
 
121      $this->showLabel('fullscreen') ? $this->t('Fullscreen') : '',
122      'fullscreen',
123      $this->showIcon('fullscreen') ? 'fullscreen' : '',
 
123      $this->showIcon('fullscreen') ? 'fullscreen' : '',
 
123      $this->showIcon('fullscreen') ? 'fullscreen' : '',
124      $this->t('Toggle fullscreen. (shortcut: F)'),
125      ['F' => $this->t('Toggle fullscreen (shift+F)')]
126    );
127    // Required for the library to work.
128    $fullscreen['#attributes']['data-set-fullscreen'] = TRUE;
129
130    return $fullscreen;
120    $fullscreen = $this->buildButton(
121      $this->showLabel('fullscreen') ? $this->t('Fullscreen') : '',
 
121      $this->showLabel('fullscreen') ? $this->t('Fullscreen') : '',
 
121      $this->showLabel('fullscreen') ? $this->t('Fullscreen') : '',
122      'fullscreen',
123      $this->showIcon('fullscreen') ? 'fullscreen' : '',
 
123      $this->showIcon('fullscreen') ? 'fullscreen' : '',
 
123      $this->showIcon('fullscreen') ? 'fullscreen' : '',
124      $this->t('Toggle fullscreen. (shortcut: F)'),
125      ['F' => $this->t('Toggle fullscreen (shift+F)')]
126    );
127    // Required for the library to work.
128    $fullscreen['#attributes']['data-set-fullscreen'] = TRUE;
129
130    return $fullscreen;
120    $fullscreen = $this->buildButton(
121      $this->showLabel('fullscreen') ? $this->t('Fullscreen') : '',
 
121      $this->showLabel('fullscreen') ? $this->t('Fullscreen') : '',
 
121      $this->showLabel('fullscreen') ? $this->t('Fullscreen') : '',
122      'fullscreen',
123      $this->showIcon('fullscreen') ? 'fullscreen' : '',
 
123      $this->showIcon('fullscreen') ? 'fullscreen' : '',
 
123      $this->showIcon('fullscreen') ? 'fullscreen' : '',
124      $this->t('Toggle fullscreen. (shortcut: F)'),
125      ['F' => $this->t('Toggle fullscreen (shift+F)')]
126    );
127    // Required for the library to work.
128    $fullscreen['#attributes']['data-set-fullscreen'] = TRUE;
129
130    return $fullscreen;
120    $fullscreen = $this->buildButton(
121      $this->showLabel('fullscreen') ? $this->t('Fullscreen') : '',
 
121      $this->showLabel('fullscreen') ? $this->t('Fullscreen') : '',
 
121      $this->showLabel('fullscreen') ? $this->t('Fullscreen') : '',
122      'fullscreen',
123      $this->showIcon('fullscreen') ? 'fullscreen' : '',
 
123      $this->showIcon('fullscreen') ? 'fullscreen' : '',
 
123      $this->showIcon('fullscreen') ? 'fullscreen' : '',
124      $this->t('Toggle fullscreen. (shortcut: F)'),
125      ['F' => $this->t('Toggle fullscreen (shift+F)')]
126    );
127    // Required for the library to work.
128    $fullscreen['#attributes']['data-set-fullscreen'] = TRUE;
129
130    return $fullscreen;
ControlsButtons->buildHighlightButton
100    $highlight = $this->buildButton(
101      $this->showLabel('highlight') ? $this->t('Highlight') : '',
 
101      $this->showLabel('highlight') ? $this->t('Highlight') : '',
 
101      $this->showLabel('highlight') ? $this->t('Highlight') : '',
102      'highlight',
103      $this->showIcon('highlight') ? 'border' : '',
 
103      $this->showIcon('highlight') ? 'border' : '',
 
103      $this->showIcon('highlight') ? 'border' : '',
104      $this->t('Highlight components. (shortcut: H)'),
105      ['H' => $this->t('Toggle highlight (shift+H)')]
106    );
107    // Required for the library to work.
108    $highlight['#attributes']['data-set-highlight'] = TRUE;
109
110    return $highlight;
100    $highlight = $this->buildButton(
101      $this->showLabel('highlight') ? $this->t('Highlight') : '',
 
101      $this->showLabel('highlight') ? $this->t('Highlight') : '',
 
101      $this->showLabel('highlight') ? $this->t('Highlight') : '',
102      'highlight',
103      $this->showIcon('highlight') ? 'border' : '',
 
103      $this->showIcon('highlight') ? 'border' : '',
 
103      $this->showIcon('highlight') ? 'border' : '',
104      $this->t('Highlight components. (shortcut: H)'),
105      ['H' => $this->t('Toggle highlight (shift+H)')]
106    );
107    // Required for the library to work.
108    $highlight['#attributes']['data-set-highlight'] = TRUE;
109
110    return $highlight;
100    $highlight = $this->buildButton(
101      $this->showLabel('highlight') ? $this->t('Highlight') : '',
 
101      $this->showLabel('highlight') ? $this->t('Highlight') : '',
 
101      $this->showLabel('highlight') ? $this->t('Highlight') : '',
102      'highlight',
103      $this->showIcon('highlight') ? 'border' : '',
 
103      $this->showIcon('highlight') ? 'border' : '',
 
103      $this->showIcon('highlight') ? 'border' : '',
104      $this->t('Highlight components. (shortcut: H)'),
105      ['H' => $this->t('Toggle highlight (shift+H)')]
106    );
107    // Required for the library to work.
108    $highlight['#attributes']['data-set-highlight'] = TRUE;
109
110    return $highlight;
100    $highlight = $this->buildButton(
101      $this->showLabel('highlight') ? $this->t('Highlight') : '',
 
101      $this->showLabel('highlight') ? $this->t('Highlight') : '',
 
101      $this->showLabel('highlight') ? $this->t('Highlight') : '',
102      'highlight',
103      $this->showIcon('highlight') ? 'border' : '',
 
103      $this->showIcon('highlight') ? 'border' : '',
 
103      $this->showIcon('highlight') ? 'border' : '',
104      $this->t('Highlight components. (shortcut: H)'),
105      ['H' => $this->t('Toggle highlight (shift+H)')]
106    );
107    // Required for the library to work.
108    $highlight['#attributes']['data-set-highlight'] = TRUE;
109
110    return $highlight;
ControlsButtons->buildKeyboardButton
168    return $this->buildButton(
169      $this->showLabel('help') ? $this->t('Help') : '',
 
169      $this->showLabel('help') ? $this->t('Help') : '',
 
169      $this->showLabel('help') ? $this->t('Help') : '',
170      'help',
171      $this->showIcon('help') ? 'question-circle' : '',
 
171      $this->showIcon('help') ? 'question-circle' : '',
 
171      $this->showIcon('help') ? 'question-circle' : '',
172      '...'
168    return $this->buildButton(
169      $this->showLabel('help') ? $this->t('Help') : '',
 
169      $this->showLabel('help') ? $this->t('Help') : '',
 
169      $this->showLabel('help') ? $this->t('Help') : '',
170      'help',
171      $this->showIcon('help') ? 'question-circle' : '',
 
171      $this->showIcon('help') ? 'question-circle' : '',
 
171      $this->showIcon('help') ? 'question-circle' : '',
172      '...'
168    return $this->buildButton(
169      $this->showLabel('help') ? $this->t('Help') : '',
 
169      $this->showLabel('help') ? $this->t('Help') : '',
 
169      $this->showLabel('help') ? $this->t('Help') : '',
170      'help',
171      $this->showIcon('help') ? 'question-circle' : '',
 
171      $this->showIcon('help') ? 'question-circle' : '',
 
171      $this->showIcon('help') ? 'question-circle' : '',
172      '...'
168    return $this->buildButton(
169      $this->showLabel('help') ? $this->t('Help') : '',
 
169      $this->showLabel('help') ? $this->t('Help') : '',
 
169      $this->showLabel('help') ? $this->t('Help') : '',
170      'help',
171      $this->showIcon('help') ? 'question-circle' : '',
 
171      $this->showIcon('help') ? 'question-circle' : '',
 
171      $this->showIcon('help') ? 'question-circle' : '',
172      '...'
ControlsButtons->buildThemeMenu
141      '#type' => 'component',
142      '#component' => 'display_builder:theme_menu',
143      '#attributes' => [
144        'placement' => 'bottom-end',
145        'data-theme-switch' => TRUE,
146      ],
147      '#slots' => [
148        'button' => $this->buildButton(
149          $this->showLabel('theme') ? $this->t('Theme') : '',
 
149          $this->showLabel('theme') ? $this->t('Theme') : '',
 
149          $this->showLabel('theme') ? $this->t('Theme') : '',
150          'theme',
151          $this->showIcon('theme') ? 'sun' : '',
 
151          $this->showIcon('theme') ? 'sun' : '',
 
151          $this->showIcon('theme') ? 'sun' : '',
152        ),
153      ],
154      '#props' => [
155        'tooltip' => $this->t('Switch the display builder interface theme.'),
156        'icon' => 'sun',
141      '#type' => 'component',
142      '#component' => 'display_builder:theme_menu',
143      '#attributes' => [
144        'placement' => 'bottom-end',
145        'data-theme-switch' => TRUE,
146      ],
147      '#slots' => [
148        'button' => $this->buildButton(
149          $this->showLabel('theme') ? $this->t('Theme') : '',
 
149          $this->showLabel('theme') ? $this->t('Theme') : '',
 
149          $this->showLabel('theme') ? $this->t('Theme') : '',
150          'theme',
151          $this->showIcon('theme') ? 'sun' : '',
 
151          $this->showIcon('theme') ? 'sun' : '',
 
151          $this->showIcon('theme') ? 'sun' : '',
152        ),
153      ],
154      '#props' => [
155        'tooltip' => $this->t('Switch the display builder interface theme.'),
156        'icon' => 'sun',
141      '#type' => 'component',
142      '#component' => 'display_builder:theme_menu',
143      '#attributes' => [
144        'placement' => 'bottom-end',
145        'data-theme-switch' => TRUE,
146      ],
147      '#slots' => [
148        'button' => $this->buildButton(
149          $this->showLabel('theme') ? $this->t('Theme') : '',
 
149          $this->showLabel('theme') ? $this->t('Theme') : '',
 
149          $this->showLabel('theme') ? $this->t('Theme') : '',
150          'theme',
151          $this->showIcon('theme') ? 'sun' : '',
 
151          $this->showIcon('theme') ? 'sun' : '',
 
151          $this->showIcon('theme') ? 'sun' : '',
152        ),
153      ],
154      '#props' => [
155        'tooltip' => $this->t('Switch the display builder interface theme.'),
156        'icon' => 'sun',
141      '#type' => 'component',
142      '#component' => 'display_builder:theme_menu',
143      '#attributes' => [
144        'placement' => 'bottom-end',
145        'data-theme-switch' => TRUE,
146      ],
147      '#slots' => [
148        'button' => $this->buildButton(
149          $this->showLabel('theme') ? $this->t('Theme') : '',
 
149          $this->showLabel('theme') ? $this->t('Theme') : '',
 
149          $this->showLabel('theme') ? $this->t('Theme') : '',
150          'theme',
151          $this->showIcon('theme') ? 'sun' : '',
 
151          $this->showIcon('theme') ? 'sun' : '',
 
151          $this->showIcon('theme') ? 'sun' : '',
152        ),
153      ],
154      '#props' => [
155        'tooltip' => $this->t('Switch the display builder interface theme.'),
156        'icon' => 'sun',
ControlsButtons->hasButtons
72        'title' => $this->t('Highlight'),
73        'description' => $this->t('Highlight builder zones to ease drag and move around.'),
74        'default' => 'icon',
75      ],
76      'fullscreen' => [
77        'title' => $this->t('Fullscreen'),
78        'default' => 'icon',
79      ],
80      'theme' => [
81        'title' => $this->t('Theme'),
82        'description' => $this->t('Pick a theme mode as light/dark/system for the display builder.'),
83        'default' => 'icon',
84      ],
85      'help' => [
86        'title' => $this->t('Help'),
87        'description' => $this->t('Information about the available keyboard shortcuts.'),
88        'default' => 'icon',