Skip to content

Commit

Permalink
Append class to body always (#525)
Browse files Browse the repository at this point in the history
* Append class always

The behavior was broken while f1c06ea

* Revert "Use logo skin feature (#524)"

This reverts commit 52336af.
  • Loading branch information
lens0021 authored Apr 20, 2022
1 parent 52336af commit d1a27b2
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 5 deletions.
30 changes: 30 additions & 0 deletions includes/FemiwikiResourceLoaderSkinModule.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace MediaWiki\Skins\Femiwiki;

use CSSMin;
use ResourceLoaderContext;
use ResourceLoaderSkinModule;

class FemiwikiResourceLoaderSkinModule extends ResourceLoaderSkinModule {
/**
* @param ResourceLoaderContext $context
* @return array
*/
protected function getLessVars( ResourceLoaderContext $context ) {
$lessVars = parent::getLessVars( $context );
$logos = $this->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;
}
}
3 changes: 2 additions & 1 deletion includes/SmallElementsHooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
}
}
7 changes: 6 additions & 1 deletion resources/skins.femiwiki/interface-gnb.less
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
5 changes: 2 additions & 3 deletions skin.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit d1a27b2

Please sign in to comment.