blob: 43714aaf2a1a725022c22a9b8d0bbbb1e8447bbe (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
<?php
/**
* @var array<array{
* type: string,
* label: string,
* link?: string,
* name?: string,
* object?: MultiPersonSearch,
* icon: Icon,
* attributes: array
* }> $actions
* @var string $title
* @var string $aria_label
* @var string $action_menu_title
* @var array $attributes
* @var string $image
* @var array $image_attributes
*/
?>
<? // class "action-menu" will be set from API ?>
<div <?= arrayToHtmlAttributes($attributes) ?>>
<button class="action-menu-icon"
aria-expanded="false"
title="<?= htmlReady($action_menu_title) ?>"
aria-label="<?= htmlReady($action_menu_title) ?>"
<?= arrayToHtmlAttributes($image_attributes) ?>
>
<?= $image ?>
</button>
<div class="action-menu-content">
<div class="action-menu-title" aria-hidden="true">
<?= htmlReady($title) ?>
</div>
<ul class="action-menu-list" aria-label="<?= htmlReady($title) ?>">
<? foreach ($actions as $action): ?>
<li class="action-menu-item <? if ($action['disabled']) echo 'action-menu-item-disabled'; ?>">
<? if ($action['disabled']): ?>
<label class="undecorated" aria-disabled="true" <?= arrayToHtmlAttributes($action['attributes']) ?>>
<? if ($action['icon']): ?>
<?= $action['icon']->asSvg(false, ['class' => 'action-menu-item-icon']) ?>
<? else: ?>
<span class="action-menu-no-icon"></span>
<? endif ?>
<?= htmlReady($action['label']) ?>
</label>
<? elseif ($action['type'] === 'link'): ?>
<a href="<?= htmlReady($action['link']) ?>" <?= arrayToHtmlAttributes($action['attributes']) ?>>
<? if ($action['icon']): ?>
<?= $action['icon']->asSvg(false, ['class' => 'action-menu-item-icon']) ?>
<? else: ?>
<span class="action-menu-no-icon"></span>
<? endif ?>
<?= htmlReady($action['label']) ?>
</a>
<? elseif ($action['type'] === 'button'): ?>
<? if ($action['icon']): ?>
<label class="undecorated" tabindex="0">
<?= $action['icon']->asInput(false, $action['attributes'] + [
'class' => 'action-menu-item-icon',
'name' => $action['name'],
'title' => $action['label'],
]) ?>
<?= htmlReady($action['label']) ?>
</label>
<? else: ?>
<span class="action-menu-no-icon"></span>
<button name="<?= htmlReady($action['name']) ?>" <?= arrayToHtmlAttributes($action['attributes']) ?>>
<?= htmlReady($action['label']) ?>
</button>
<? endif ?>
<? elseif ($action['type'] === 'multi-person-search'): ?>
<?= $action['object']->render() ?>
<? elseif ($action['type'] === 'separator'): ?>
<hr>
<? endif ?>
</li>
<? endforeach ?>
</ul>
</div>
</div>
|