2017-08-16 19:18:08 +00:00
|
|
|
<?php
|
|
|
|
/**
|
2018-04-15 23:21:12 +00:00
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
*
|
|
|
|
* @file
|
2017-08-16 19:18:08 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2018-04-15 23:21:12 +00:00
|
|
|
* FIXME: Use OOUI when available
|
|
|
|
*
|
2017-08-16 19:18:08 +00:00
|
|
|
* Helper methods for generating parts of the UI.
|
|
|
|
*/
|
|
|
|
class MinervaUI {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get CSS classes for icons
|
2019-12-30 16:26:31 +00:00
|
|
|
* @param string|null $iconName
|
2017-08-16 19:18:08 +00:00
|
|
|
* @param string $iconType element or before
|
|
|
|
* @param string $additionalClassNames additional class names you want to associate
|
|
|
|
* with the iconed element
|
2020-04-29 22:13:47 +00:00
|
|
|
* @param string $iconPrefix optional prefix for icons. Defaults to minerva.
|
2017-08-16 19:18:08 +00:00
|
|
|
* @return string class name for use with HTML element
|
|
|
|
*/
|
2018-01-05 18:52:17 +00:00
|
|
|
public static function iconClass( $iconName, $iconType = 'element', $additionalClassNames = '',
|
2020-04-29 22:13:47 +00:00
|
|
|
$iconPrefix = 'minerva'
|
2018-01-05 18:52:17 +00:00
|
|
|
) {
|
2017-08-16 19:18:08 +00:00
|
|
|
$base = 'mw-ui-icon';
|
|
|
|
$modifiers = 'mw-ui-icon-' . $iconType;
|
|
|
|
if ( $iconName ) {
|
2020-04-29 22:13:47 +00:00
|
|
|
$modifiers .= ' mw-ui-icon-' . $iconPrefix . '-' . $iconName;
|
2017-08-16 19:18:08 +00:00
|
|
|
}
|
|
|
|
return $base . ' ' . $modifiers . ' ' . $additionalClassNames;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get CSS classes for a mediawiki ui semantic element
|
|
|
|
* @param string $base The base class
|
|
|
|
* @param string $modifier Type of anchor (progressive, constructive, destructive)
|
|
|
|
* @param string $additionalClassNames additional class names you want to associate
|
|
|
|
* with the iconed element
|
|
|
|
* @return string class name for use with HTML element
|
|
|
|
*/
|
|
|
|
public static function semanticClass( $base, $modifier, $additionalClassNames = '' ) {
|
|
|
|
$modifier = empty( $modifier ) ? '' : 'mw-ui-' . $modifier;
|
|
|
|
return $base . ' ' . $modifier . ' ' . $additionalClassNames;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get CSS classes for buttons
|
|
|
|
* @param string $modifier Type of button (progressive, constructive, destructive)
|
|
|
|
* @param string $additionalClassNames additional class names you want to associate
|
|
|
|
* with the button element
|
|
|
|
* @return string class name for use with HTML element
|
|
|
|
*/
|
|
|
|
public static function buttonClass( $modifier = '', $additionalClassNames = '' ) {
|
|
|
|
return self::semanticClass( 'mw-ui-button', $modifier, $additionalClassNames );
|
|
|
|
}
|
|
|
|
}
|