mediawiki-skins-Vector/includes/Components/VectorComponentDropdown.php
Jan Drewniak 6e8a98ca8b Remove custom checkbox-hack implementations
Removes several styles that were used for
expanding/collapsing the table of contents at narrow
widths for non-js users as well as the main menu
for no-js users.

Existing `.vector-menu-checkbox` styles address this
use-case with the addition of a display:none rule for the
two affected checkboxes.

Related to the Page Tools clean-up since these styles
were once scoped to the .vector-page-tools-disabled
class.

Bug: T332090
Change-Id: I13efd4a87bacecb0e9f5a5e44d5e15861d632c62
2023-04-04 10:01:09 -04:00

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