mediawiki-skins-Vector/includes/Components/VectorComponentDropdown.php
Jon Robson c10ef66e6e Refactor: PageTools composes several different components
* Introduce Dropdownmenu, PinnableElement and PinnedContainer components

Additional changes:
* Drops unused has-multiple-menus
* Update TableOfContents to use PinnedContainer and PinnableElement

Bug: T317900
Change-Id: I0a740f8543831e266f2b1b874b40e44c8241d4cb
2022-12-12 22:17:24 +00:00

56 lines
1.3 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 {
$icon = $this->icon;
$headingClass = $icon ?
'mw-checkbox-hack-button mw-ui-icon mw-ui-button mw-ui-quiet ' .
'mw-ui-icon-element mw-ui-icon-wikimedia-' . $icon : '';
return [
'id' => $this->id,
'label' => $this->label,
'heading-class' => $headingClass,
'html-vector-menu-heading-attributes' => '',
'html-vector-menu-checkbox-attributes' => '',
'html-vector-heading-icon' => '',
'class' => $this->class,
'html-tooltip' => $this->tooltip,
'checkbox-class' => '',
];
}
}