2022-12-07 01:05:22 +00:00
|
|
|
<?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 {
|
2023-02-16 19:41:35 +00:00
|
|
|
// 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
|
2022-12-07 01:05:22 +00:00
|
|
|
$icon = $this->icon;
|
2023-04-27 20:39:40 +00:00
|
|
|
$buttonClass = 'cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet';
|
|
|
|
$iconButtonClass = $icon ? ' cdx-button--icon-only ' : '';
|
2022-12-07 01:05:22 +00:00
|
|
|
|
|
|
|
return [
|
|
|
|
'id' => $this->id,
|
|
|
|
'label' => $this->label,
|
2023-06-22 19:22:07 +00:00
|
|
|
'label-class' => $buttonClass . $iconButtonClass,
|
2023-02-16 19:41:35 +00:00
|
|
|
'icon' => $this->icon,
|
2023-06-22 19:22:07 +00:00
|
|
|
'html-vector-menu-label-attributes' => '',
|
2022-12-07 01:05:22 +00:00
|
|
|
'html-vector-menu-checkbox-attributes' => '',
|
|
|
|
'class' => $this->class,
|
|
|
|
'html-tooltip' => $this->tooltip,
|
|
|
|
'checkbox-class' => '',
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|