From d1a27b287c92bc2cd4896fa58d0c384a05a40f3f Mon Sep 17 00:00:00 2001 From: Lens0021 Date: Thu, 21 Apr 2022 04:59:53 +0900 Subject: [PATCH] Append class to body always (#525) * Append class always The behavior was broken while https://github.com/femiwiki/FemiwikiSkin/pull/477/commits/f1c06ea9b16278f30a95054f26a1f85826f59196 * Revert "Use logo skin feature (#524)" This reverts commit 52336afb9304b2a16844b6a1c1d6c37e3c27dc07. --- includes/FemiwikiResourceLoaderSkinModule.php | 30 +++++++++++++++++++ includes/SmallElementsHooks.php | 3 +- resources/skins.femiwiki/interface-gnb.less | 7 ++++- skin.json | 5 ++-- 4 files changed, 40 insertions(+), 5 deletions(-) create mode 100644 includes/FemiwikiResourceLoaderSkinModule.php diff --git a/includes/FemiwikiResourceLoaderSkinModule.php b/includes/FemiwikiResourceLoaderSkinModule.php new file mode 100644 index 00000000..0469665a --- /dev/null +++ b/includes/FemiwikiResourceLoaderSkinModule.php @@ -0,0 +1,30 @@ +getConfig()->get( 'Logos' ); + + # icon has high priority for FemiwikiSkin's backward compatibility. + # This behavior will be removed in the next major version up(v2). + $symbol = $logos[ 'icon' ] ?? $logos[ 'svg' ] ?? null; + if ( $symbol !== null ) { + $lessVars[ 'symbol-enabled'] = true; + $lessVars[ 'symbol-url' ] = CSSMin::buildUrlValue( $symbol ); + } else { + $lessVars[ 'symbol-enabled'] = false; + } + + return $lessVars; + } +} diff --git a/includes/SmallElementsHooks.php b/includes/SmallElementsHooks.php index 2583b75a..4c47aac9 100644 --- a/includes/SmallElementsHooks.php +++ b/includes/SmallElementsHooks.php @@ -49,7 +49,8 @@ public function onOutputPageBodyAttributes( $out, $sk, &$bodyAttrs ): void { ( !$registered && $config->get( Constants::CONFIG_KEY_SMALL_ELEMENTS_FOR_ANONYMOUS_USER ) ) || ( $registered && !$userOptionsLookup->getBoolOption( $user, Constants::PREF_KEY_LARGER_ELEMENTS ) ) ) { - $bodyAttrs['class'] ??= ' fw-legacy-small-elements'; + $bodyAttrs['class'] ??= ''; + $bodyAttrs['class'] .= ' fw-legacy-small-elements'; } } } diff --git a/resources/skins.femiwiki/interface-gnb.less b/resources/skins.femiwiki/interface-gnb.less index b1cbec1e..9730c040 100644 --- a/resources/skins.femiwiki/interface-gnb.less +++ b/resources/skins.femiwiki/interface-gnb.less @@ -27,7 +27,12 @@ background-repeat: no-repeat; @width: @height; width: @width; - background-size: @height @height; + + & when( @symbol-enabled = 1 ) { + /* @embed */ + background-image: @symbol-url; + background-size: @height @height; + } & when( @logo-enabled = 1 ) { @media (min-width: @width-breakpoint-tablet) { diff --git a/skin.json b/skin.json index 06f31c4f..fe73ce7b 100644 --- a/skin.json +++ b/skin.json @@ -51,12 +51,11 @@ }, "ResourceModules": { "skins.femiwiki": { - "class": "ResourceLoaderSkinModule", + "class": "MediaWiki\\Skins\\Femiwiki\\FemiwikiResourceLoaderSkinModule", "features": { "content-media": true, "toc": false, - "normalize": true, - "logo": true + "normalize": true }, "targets": ["desktop", "mobile"], "position": "top",