mediawiki-skins-Vector/includes/Components/VectorComponentDropdown.php
bwang 153c6f2668 Remove references to heading in dropdown PHP
Bug: T319358
Change-Id: I9830a4b4b55fdb205c479c09ef807de4f6d68713
2023-06-26 12:49:00 -05:00

57 lines
1.5 KiB
PHP

<?php
namespace MediaWiki\Skins\Vector\Components;
/**
* VectorComponentDropdown component
*/
class VectorComponentDropdown implements VectorComponent {
/** @var string */
private $id;
/** @var string */
private $label;
/** @var string */
private $class;
/** @var string */
private $tooltip;
/** @var string|null */
private $icon;
/**
* @param string $id
* @param string $label
* @param string $class
* @param string|null $icon
* @param string $tooltip
*/
public function __construct( string $id, string $label, string $class = '', $icon = null, string $tooltip = '' ) {
$this->id = $id;
$this->label = $label;
$this->class = $class;
$this->icon = $icon;
$this->tooltip = $tooltip;
}
/**
* @inheritDoc
*/
public function getTemplateData(): array {
// FIXME: Stop hardcoding button and icon styles, this assumes all dropdowns with icons are icon buttons
// Not the case for the language dropdown, page tools, etc
$icon = $this->icon;
$buttonClass = 'cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet';
$iconButtonClass = $icon ? ' cdx-button--icon-only ' : '';
return [
'id' => $this->id,
'label' => $this->label,
'label-class' => $buttonClass . $iconButtonClass,
'icon' => $this->icon,
'html-vector-menu-label-attributes' => '',
'html-vector-menu-checkbox-attributes' => '',
'class' => $this->class,
'html-tooltip' => $this->tooltip,
'checkbox-class' => '',
];
}
}