Merge "Message box styles for Minerva come from core"

This commit is contained in:
jenkins-bot 2021-04-12 22:12:51 +00:00 committed by Gerrit Code Review
commit 5fd4a83482
4 changed files with 53 additions and 12 deletions

View file

@ -336,6 +336,51 @@ class MinervaHooks {
}
}
/**
* The Minerva skin loads message box styles differently from core, to
* reduce the amount of styles on the critical path.
* This adds message box styles to pages that need it, to avoid loading them
* on pages where they are not.
*
* @param OutputPage $out
* @param Skin $skin
*/
public static function onBeforePageDisplay( OutputPage $out, Skin $skin ) {
if ( $skin->getSkinName() === 'minerva' ) {
self::addMessageBoxStylesToPage( $out );
}
}
/**
* The Minerva skin loads message box styles differently from core, to
* reduce the amount of styles on the critical path.
* This adds message box styles to pages that need it, to avoid loading them
* on pages where they are not.
* The pages where they are needed are:
* - special pages
* - edit workflow (action=edit and action=submit)
* - when viewing old revisions
*
* @param OutputPage $out
*/
private static function addMessageBoxStylesToPage( OutputPage $out ) {
$request = $out->getRequest();
// Warning box styles are needed when reviewing old revisions
// and inside the fallback editor styles to action=edit page.
$requestAction = $request->getVal( 'action' );
$viewAction = $requestAction === null || $requestAction === 'view';
if (
$out->getTitle()->isSpecialPage() ||
$request->getText( 'oldid' ) ||
!$viewAction
) {
$out->addModuleStyles( [
'skins.minerva.messageBox.styles'
] );
}
}
/**
* Modifies the `<body>` element's attributes.
*

View file

@ -251,10 +251,6 @@ input.search {
.topic-title-list li,
.site-link-list li,
.drawer,
.messagebox,
.errorbox,
.successbox,
.warningbox,
.list-header,
.mw-revision {
padding-left: @contentPadding;

View file

@ -121,6 +121,9 @@
"minerva": "GlobalVarConfig::newInstance"
},
"Hooks": {
"BeforePageDisplay": [
"MinervaHooks::onBeforePageDisplay"
],
"ResourceLoaderRegisterModules": [
"MinervaHooks::onResourceLoaderRegisterModules"
],
@ -579,6 +582,10 @@
"resources/skins.minerva.scripts/watchstar.js"
]
},
"skins.minerva.messageBox.styles": {
"class": "ResourceLoaderSkinModule",
"features": [ "interface-message-box" ]
},
"skins.minerva.options": {
"targets": [
"mobile",
@ -599,6 +606,7 @@
"localBasePath": "",
"remoteSkinPath": "MinervaNeue",
"dependencies": [
"skins.minerva.messageBox.styles",
"mobile.startup",
"mediawiki.user",
"mediawiki.experiments"

View file

@ -11,14 +11,6 @@
display: none;
}
// `.messagebox` not needed here, as it's not used currently.
.errorbox,
.successbox,
.warningbox {
padding: 0.5em 1em;
margin: 1em 0;
}
.mw-ui-container {
.mw-ui-vform {
margin: auto;