refactor(core): ♻️ use core sidebar data

This commit is contained in:
alistair3149 2022-10-04 22:20:29 -04:00
parent 9325a4e2be
commit a93f373269
No known key found for this signature in database
5 changed files with 10 additions and 12 deletions

View file

@ -80,10 +80,6 @@ final class Drawer extends Partial {
} }
} }
$sidebarData += [
'data-drawer-sitestats' => $this->getSiteStatsData()
];
return $sidebarData; return $sidebarData;
} }
@ -128,7 +124,7 @@ final class Drawer extends Partial {
* *
* @return array for use in Mustache template. * @return array for use in Mustache template.
*/ */
private function getSiteStatsData(): array { public function getSiteStatsData(): array {
$props = []; $props = [];
if ( $this->getConfigValue( 'CitizenEnableDrawerSiteStats' ) ) { if ( $this->getConfigValue( 'CitizenEnableDrawerSiteStats' ) ) {

View file

@ -95,11 +95,10 @@ class SkinCitizen extends SkinMustache {
'toc-enabled' => $out->isTOCEnabled(), 'toc-enabled' => $out->isTOCEnabled(),
// Data objects // Data objects
'data-header' => [ 'data-header' => [
'data-drawer' => $drawer->decorateSidebarData( $parentData['data-portlets-sidebar'] ),
'data-personal-menu' => $header->buildPersonalMenu(), 'data-personal-menu' => $header->buildPersonalMenu(),
'data-search-box' => $header->buildSearchProps(), 'data-search-box' => $header->buildSearchProps(),
], ],
'data-footer' => $footer->decorateFooterData( $parentData['data-footer'] ), 'data-sitestats' => $drawer->getSiteStatsData(),
// HTML strings // HTML strings
'html-title-heading--formatted' => $pageTitle->buildTitle( $parentData, $title ), 'html-title-heading--formatted' => $pageTitle->buildTitle( $parentData, $title ),
'html-citizen-jumptotop' => $this->msg( 'citizen-jumptotop' )->text() . ' [home]', 'html-citizen-jumptotop' => $this->msg( 'citizen-jumptotop' )->text() . ' [home]',
@ -109,6 +108,9 @@ class SkinCitizen extends SkinMustache {
// Needed to be parsed here as it should be wikitext // Needed to be parsed here as it should be wikitext
'msg-citizen-footer-desc' => $this->msg( "citizen-footer-desc" )->inContentLanguage()->parse(), 'msg-citizen-footer-desc' => $this->msg( "citizen-footer-desc" )->inContentLanguage()->parse(),
'msg-citizen-footer-tagline' => $this->msg( "citizen-footer-tagline" )->inContentLanguage()->parse(), 'msg-citizen-footer-tagline' => $this->msg( "citizen-footer-tagline" )->inContentLanguage()->parse(),
// Decorate data provided by core
'data-portlets-sidebar' => $drawer->decorateSidebarData( $parentData['data-portlets-sidebar'] ),
'data-footer' => $footer->decorateFooterData( $parentData['data-footer'] ),
]; ];
$data += $tools->getPageToolsData( $parentData ); $data += $tools->getPageToolsData( $parentData );

View file

@ -15,14 +15,16 @@
<header class="citizen-drawer__header"> <header class="citizen-drawer__header">
{{>Drawer__logo}} {{>Drawer__logo}}
<div class="citizen-drawer__siteinfo"> <div class="citizen-drawer__siteinfo">
{{>Drawer__siteStats}} {{#data-sitestats}}{{>Drawer__siteStats}}{{/data-sitestats}}
<div class="mw-logo-wordmark">{{msg-sitetitle}}</div> <div class="mw-logo-wordmark">{{msg-sitetitle}}</div>
</div> </div>
</header> </header>
{{#data-portlets-sidebar}}
<section class="citizen-drawer__menu"> <section class="citizen-drawer__menu">
{{#data-portlets-first}}{{>Menu}}{{/data-portlets-first}} {{#data-portlets-first}}{{>Menu}}{{/data-portlets-first}}
{{#array-portlets-rest}}{{>Menu}}{{/array-portlets-rest}} {{#array-portlets-rest}}{{>Menu}}{{/array-portlets-rest}}
</section> </section>
{{/data-portlets-sidebar}}
</aside> </aside>
{{>Drawer__button}} {{>Drawer__button}}
</div> </div>

View file

@ -1,7 +1,5 @@
{{#data-drawer-sitestats}}
<div class="citizen-siteStats"> <div class="citizen-siteStats">
{{#array-drawer-sitestats-item}} {{#array-drawer-sitestats-item}}
<div class="citizen-siteStats__item" id="citizen-siteStats__item--{{id}}" title="{{label}}">{{value}}</div> <div class="citizen-siteStats__item" id="citizen-siteStats__item--{{id}}" title="{{label}}">{{value}}</div>
{{/array-drawer-sitestats-item}} {{/array-drawer-sitestats-item}}
</div> </div>
{{/data-drawer-sitestats}}

View file

@ -4,7 +4,7 @@
}} }}
<header class="mw-header citizen-header"> <header class="mw-header citizen-header">
{{#data-search-box}}{{>Search}}{{/data-search-box}} {{#data-search-box}}{{>Search}}{{/data-search-box}}
{{#data-drawer}}{{>Drawer}}{{/data-drawer}} {{>Drawer}}
<div class="citizen-header__inner"> <div class="citizen-header__inner">
<div class="citizen-header__start"></div> <div class="citizen-header__start"></div>
<div class="citizen-header__end"> <div class="citizen-header__end">