mirror of
https://github.com/StarCitizenTools/mediawiki-skins-Citizen.git
synced 2024-11-25 06:47:16 +00:00
feat: add support for different logo configurations and variants (#229)
* feat: add support for different logo configurations and variants * ci: lint code to MediaWiki standards Check commit and GitHub actions for more details Co-authored-by: github-actions <github-actions@users.noreply.github.com>
This commit is contained in:
parent
28cc5f272f
commit
2c93c68cb2
|
@ -150,7 +150,7 @@ class SkinCitizen extends SkinMustache {
|
|||
'href' => Skin::makeMainPageUrl(),
|
||||
]
|
||||
),
|
||||
'data-logos' => ResourceLoaderSkinModule::getAvailableLogos( $this->getConfig() ),
|
||||
'data-logos' => $this->getLogoData(),
|
||||
|
||||
'data-header' => [
|
||||
'data-drawer' => $this->buildDrawer(),
|
||||
|
@ -284,6 +284,30 @@ class SkinCitizen extends SkinMustache {
|
|||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get and pick the correct logo based on types and variants
|
||||
* Based on getLogoData() in MW 1.36
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function getLogoData() : array {
|
||||
$logoData = ResourceLoaderSkinModule::getAvailableLogos( $this->getConfig() );
|
||||
// check if the logo supports variants
|
||||
$variantsLogos = $logoData['variants'] ?? null;
|
||||
if ( $variantsLogos ) {
|
||||
$preferred = $this->getOutput()->getTitle()
|
||||
->getPageViewLanguage()->getCode();
|
||||
$variantOverrides = $variantsLogos[$preferred] ?? null;
|
||||
// Overrides the logo
|
||||
if ( $variantOverrides ) {
|
||||
foreach ( $variantOverrides as $key => $val ) {
|
||||
$logoData[$key] = $val;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $logoData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the navigation drawer
|
||||
* Based on buildSidebar()
|
||||
|
|
|
@ -5,18 +5,20 @@
|
|||
}}
|
||||
{{#data-logos}}
|
||||
<a {{{html-mainpage-attributes}}} class="mw-logo">
|
||||
{{#icon}}
|
||||
{{! alt is provided for valid HTML but given aria-hidden not needed. }}
|
||||
<img class="mw-logo-icon" src="{{.}}" alt=""
|
||||
aria-hidden="true" height="50" width="50">
|
||||
{{/icon}}
|
||||
<img class="mw-logo-icon" src="{{!
|
||||
Pick an icon based on this order: SVG > Icon > 1x
|
||||
Need a better way to indent the syntax below
|
||||
}}{{#svg}}{{.}}{{/svg}}{{!
|
||||
}}{{^svg}}{{!
|
||||
}}{{#icon}}{{.}}{{/icon}}{{!
|
||||
}}{{^icon}}{{!
|
||||
}}{{#1x}}{{.}}{{/1x}}{{!
|
||||
}}{{/icon}}{{!
|
||||
}}{{/svg}}"{{!
|
||||
}}alt="" aria-hidden="true" height="50" width="50">
|
||||
<span class="mw-logo-container">
|
||||
{{>Wordmark}}
|
||||
{{#tagline}}
|
||||
<img class="mw-logo-tagline"
|
||||
alt="{{msg-sitesubtitle}}"
|
||||
src="{{src}}" width="{{width}}" height="{{height}}">
|
||||
{{/tagline}}
|
||||
</span>
|
||||
</a>
|
||||
{{/data-logos}}
|
Loading…
Reference in a new issue