Chris@18
|
1 <?php
|
Chris@18
|
2
|
Chris@18
|
3 namespace Drupal\layout_builder;
|
Chris@18
|
4
|
Chris@18
|
5 /**
|
Chris@18
|
6 * A trait for generating IDs used to highlight active UI elements.
|
Chris@18
|
7 */
|
Chris@18
|
8 trait LayoutBuilderHighlightTrait {
|
Chris@18
|
9
|
Chris@18
|
10 /**
|
Chris@18
|
11 * Provides the ID used to highlight the active Layout Builder UI element.
|
Chris@18
|
12 *
|
Chris@18
|
13 * @param string $delta
|
Chris@18
|
14 * The section the block is in.
|
Chris@18
|
15 * @param string $region
|
Chris@18
|
16 * The section region in which the block is placed.
|
Chris@18
|
17 *
|
Chris@18
|
18 * @return string
|
Chris@18
|
19 * The highlight ID of the block.
|
Chris@18
|
20 */
|
Chris@18
|
21 protected function blockAddHighlightId($delta, $region) {
|
Chris@18
|
22 return "block-$delta-$region";
|
Chris@18
|
23 }
|
Chris@18
|
24
|
Chris@18
|
25 /**
|
Chris@18
|
26 * Provides the ID used to highlight the active Layout Builder UI element.
|
Chris@18
|
27 *
|
Chris@18
|
28 * @param string $uuid
|
Chris@18
|
29 * The uuid of the block.
|
Chris@18
|
30 *
|
Chris@18
|
31 * @return string
|
Chris@18
|
32 * The highlight ID of the block.
|
Chris@18
|
33 */
|
Chris@18
|
34 protected function blockUpdateHighlightId($uuid) {
|
Chris@18
|
35 return $uuid;
|
Chris@18
|
36 }
|
Chris@18
|
37
|
Chris@18
|
38 /**
|
Chris@18
|
39 * Provides the ID used to highlight the active Layout Builder UI element.
|
Chris@18
|
40 *
|
Chris@18
|
41 * @param string $delta
|
Chris@18
|
42 * The location of the section.
|
Chris@18
|
43 *
|
Chris@18
|
44 * @return string
|
Chris@18
|
45 * The highlight ID of the section.
|
Chris@18
|
46 */
|
Chris@18
|
47 protected function sectionAddHighlightId($delta) {
|
Chris@18
|
48 return "section-$delta";
|
Chris@18
|
49 }
|
Chris@18
|
50
|
Chris@18
|
51 /**
|
Chris@18
|
52 * Provides the ID used to highlight the active Layout Builder UI element.
|
Chris@18
|
53 *
|
Chris@18
|
54 * @param string $delta
|
Chris@18
|
55 * The location of the section.
|
Chris@18
|
56 *
|
Chris@18
|
57 * @return string
|
Chris@18
|
58 * The highlight ID of the section.
|
Chris@18
|
59 */
|
Chris@18
|
60 protected function sectionUpdateHighlightId($delta) {
|
Chris@18
|
61 return "section-update-$delta";
|
Chris@18
|
62 }
|
Chris@18
|
63
|
Chris@18
|
64 }
|