| 1 |
<?php |
| 2 |
namespace MediaWiki\Skins\Vector\Components; |
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
class VectorComponentDropdown implements VectorComponent { |
| 8 |
|
| 9 |
private $id; |
| 10 |
|
| 11 |
private $label; |
| 12 |
|
| 13 |
private $class; |
| 14 |
|
| 15 |
private $tooltip; |
| 16 |
|
| 17 |
private $icon; |
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 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 |
|
| 36 |
|
| 37 |
public function getTemplateData(): array { |
| 38 |
|
| 39 |
|
| 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 |
} |