6 * Element containing an icon.
8 * Icons are graphics, about the size of normal text. They can be used to aid the user in locating
9 * a control or convey information in a more space efficient way. Icons should rarely be used
10 * without labels; such as in a toolbar where space is at a premium or within a context where the
11 * meaning is very clear to the user.
21 protected $iconName = null;
29 * @param array $config Configuration options
30 * @param string $config['icon'] Symbolic icon name
32 public function initializeIconElement( array $config = [] ) {
34 // FIXME 'iconElement' is a very stupid way to call '$icon'
35 $this->icon = isset( $config['iconElement'] ) ? $config['iconElement'] : new Tag( 'span' );
38 $this->icon->addClasses( [ 'oo-ui-iconElement-icon' ] );
39 $this->setIcon( isset( $config['icon'] ) ? $config['icon'] : null );
41 $this->registerConfigCallback( function ( &$config ) {
42 if ( $this->iconName !== null ) {
43 $config['icon'] = $this->iconName;
51 * @param string|null $icon Symbolic icon name
54 public function setIcon( $icon = null ) {
55 if ( $this->iconName !== null ) {
56 $this->icon->removeClasses( [ 'oo-ui-icon-' . $this->iconName ] );
58 if ( $icon !== null ) {
59 $this->icon->addClasses( [ 'oo-ui-icon-' . $icon ] );
62 $this->iconName = $icon;
63 $this->toggleClasses( [ 'oo-ui-iconElement' ], (bool)$this->iconName );
71 * @return string Icon name
73 public function getIcon() {
74 return $this->iconName;
78 * Do not use outside of Theme::updateElementClasses
83 public function getIconElement() {