Debian Codegraph @

skins/Vector/includes/Components/VectorComponentDropdown.php

raw symbols SCIP
1 <?php
2 namespace MediaWiki\Skins\Vector\Components;
3
4 /**
5 * VectorComponentDropdown component
6 */
7 class VectorComponentDropdown implements VectorComponent {
8 /** @var string */
9 private $id;
10 /** @var string */
11 private $label;
12 /** @var string */
13 private $class;
14 /** @var string */
15 private $tooltip;
16 /** @var string|null */
17 private $icon;
18
19 /**
20 * @param string $id
21 * @param string $label
22 * @param string $class
23 * @param string|null $icon
24 * @param string $tooltip
25 */
26 public function __construct( string $id, string $label, string $class = '', $icon = null, string $tooltip = '' ) {
27 $this->id = $id;
28 $this->label = $label;
29 $this->class = $class;
30 $this->icon = $icon;
31 $this->tooltip = $tooltip;
32 }
33
34 /**
35 * @inheritDoc
36 */
37 public function getTemplateData(): array {
38 // FIXME: Stop hardcoding button and icon styles, this assumes all dropdowns with icons are icon buttons
39 // Not the case for the language dropdown, page tools, etc
40 $icon = $this->icon;
41 $buttonClass = 'cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet';
42 $iconButtonClass = $icon ? ' cdx-button--icon-only ' : '';
43
44 return [
45 'id' => $this->id,
46 'label' => $this->label,
47 'label-class' => $buttonClass . $iconButtonClass,
48 'icon' => $this->icon,
49 'html-vector-menu-label-attributes' => '',
50 'html-vector-menu-checkbox-attributes' => '',
51 'class' => $this->class,
52 'html-tooltip' => $this->tooltip,
53 'checkbox-class' => '',
54 ];
55 }
56 }