Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
MobileUI
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 1
 icon
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
 contentElement
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3use MediaWiki\Html\Html;
4use MediaWiki\Html\TemplateParser;
5
6/**
7 * Helper methods for generating parts of the UI.
8 *
9 * @internal not for use outside MobileFrontend.
10 */
11class MobileUI {
12    /**
13     * Renders a icon using Codex markup styled with Codex mixins
14     *
15     * @param string $iconName
16     * @param string $className
17     * @return string
18     */
19    public static function icon( $iconName, $className = '' ) {
20        $iconClass = 'mf-icon-' . $iconName;
21        return Html::element( 'span', [
22            'class' => trim( 'mw-mf-icon ' . $iconClass . ' ' . $className ),
23        ] );
24    }
25
26    /**
27     * Mark some html as being content
28     * @param string $html HTML content
29     * @param string $className additional class names
30     * @return string of html
31     */
32    public static function contentElement( $html, $className = '' ) {
33        $templateParser = new TemplateParser( __DIR__ . '/templates' );
34        return $templateParser->processTemplate( 'ContentBox', [
35            'className' => $className,
36            'html' => $html,
37        ] );
38    }
39}