Provides common user interface elements and customizeable stylings.
This code is meant to be executed within the MediaWiki application context. No standalone usage is intended.
Add "mwstake/mediawiki-component-commonuserinterface": "~5.0"
to the require
section of your composer.json
file.
Since 3.0 explicit initialization is required. This can be achived by
- either adding
"callback": "mwsInitComponents"
to yourextension.json
/skin.json
- or calling
mwsInitComponents();
within you extensions/skins customcallback
method
See also mwstake/mediawiki-componentloader
.
Default renderer types:
*
bootstrap-5
A skin may define
$GLOBALS['mwsgCommonUIComponentRendererType'] = 'bootstrap-5';
if it provides "Twitter Bootstrap V5". The "CommonUserInterface" will fall back to *
of the requested renderer is not available to the chosen type.
$GLOBALS['mwsgCommonUIComponentRendererRegistry']['my-custom-renderer']['button'] = '...';
Default slots:
siteNoticeAfter
: Uses hookSiteNoticeAfter
to add components to any default skindataAfterContent
: Uses hookSkinAfterContent
to add components to any default skin
Examples:
$GLOBALS['mwsgCommonUISkinSlots']['siteNoticeAfter']['my-sitenoticeafter-toolbar'] = [
'factory' => function() {
return new MWStake\MediaWiki\Component\CommonUserInterface\Component\SimpleToolbar( [
'items' => [
new MWStake\MediaWiki\Component\CommonUserInterface\Component\SimpleDropDown( [
'label' => new RawMessage( 'Click me!' ),
'toggleRLModules' => [ 'my-dropdown-module' ]
] )
]
] );
}
];
$GLOBALS['mwsgCommonUISkinSlots']['skinAfterContent']['my-skinaftercontent-panel'] = [
'factory' => function() {
return new MWStake\MediaWiki\Component\CommonUserInterface\Component\SimplePanel( [
'title' => new RawMessage( 'My panel' ),
'collapsible' => true,
'collapsed' => true,
'expandRLModules' => [ 'my-panel-module' ]
] );
}
];
Example:
mws.commonui.renderPath( '<skinslot>/<parentComponentId>/<subComponentId>', $container );