From b1901210d9fd2f9a11219eb505a1fe2826208f19 Mon Sep 17 00:00:00 2001 From: Isarra Date: Sat, 17 Aug 2019 03:08:56 +0000 Subject: [PATCH] Migrate backdrop image style generation to set a variable we use in the LESS instead of adding the styles prebaked Bug: T223112 Change-Id: I773dbd9bd6d318144685d691e72627a00906472b --- includes/TimelessFileModule.php | 46 ------------------------- includes/TimelessVariablesModule.php | 50 ++++++++++++++++++++++++++++ resources/screen-common.less | 3 +- skin.json | 4 +-- 4 files changed, 54 insertions(+), 49 deletions(-) delete mode 100644 includes/TimelessFileModule.php create mode 100644 includes/TimelessVariablesModule.php diff --git a/includes/TimelessFileModule.php b/includes/TimelessFileModule.php deleted file mode 100644 index 9536fd2..0000000 --- a/includes/TimelessFileModule.php +++ /dev/null @@ -1,46 +0,0 @@ -getConfig(); - $background = $config->get( 'TimelessBackdropImage' ); - if ( $background === 'cat.svg' ) { - // expand default - $background = $config->get( 'StylePath' ) . '/Timeless/resources/images/cat.svg'; - } - - $background = OutputPage::transformResourcePath( $config, $background ); - $styles = parent::getStyles( $context ); - - $styles['all'][] = '#mw-content-container { background-image: ' . - CSSMin::buildUrlValue( $background ) . - '; }'; - - return $styles; - } - - /** - * Register the config var with the caching stuff so it properly updates the cache - * - * @param ResourceLoaderContext $context - * @return array - */ - public function getDefinitionSummary( ResourceLoaderContext $context ) { - $summary = parent::getDefinitionSummary( $context ); - $summary[] = [ - 'TimelessBackdropImage' => $this->getConfig()->get( 'TimelessBackdropImage' ) - ]; - return $summary; - } -} diff --git a/includes/TimelessVariablesModule.php b/includes/TimelessVariablesModule.php new file mode 100644 index 0000000..e516e20 --- /dev/null +++ b/includes/TimelessVariablesModule.php @@ -0,0 +1,50 @@ +getConfig(); + + // Backdrop image + $backdrop = $config->get( 'TimelessBackdropImage' ); + + if ( $backdrop === 'cat.svg' ) { + // expand default + $backdrop = 'images/cat.svg'; + } + + $vars = array_merge( + $vars, + [ + 'backdrop-image' => "url($backdrop)", + // 'logo-image' => '' + // 'wordmark-image' => '' + // +width cutoffs ... + ] + ); + + return $vars; + } + + /** + * Register the config var with the caching stuff so it properly updates the cache + * + * @param ResourceLoaderContext $context + * @return array + */ + public function getDefinitionSummary( ResourceLoaderContext $context ) { + $summary = parent::getDefinitionSummary( $context ); + $summary[] = [ + 'TimelessBackdropImage' => $this->getConfig()->get( 'TimelessBackdropImage' ) + ]; + return $summary; + } +} diff --git a/resources/screen-common.less b/resources/screen-common.less index 8b5d9c0..a17c6f6 100644 --- a/resources/screen-common.less +++ b/resources/screen-common.less @@ -196,7 +196,8 @@ body { background: @base80; border-bottom: solid 4px @green; - // Background image (default cat) set via TimelessFileModule + // Background image (default cat) + background-image: @backdrop-image; background-repeat: no-repeat; background-position: center 10em; } diff --git a/skin.json b/skin.json index d842460..e7df368 100644 --- a/skin.json +++ b/skin.json @@ -24,7 +24,7 @@ "ResourceModules": { "skins.timeless": { "targets": [ "desktop", "mobile" ], - "class": "TimelessFileModule", + "class": "TimelessVariablesModule", "styles": { "resources/libraries/normalise.css": { "media": "screen" @@ -95,7 +95,7 @@ "AutoloadClasses": { "SkinTimeless": "includes/SkinTimeless.php", "TimelessTemplate": "includes/TimelessTemplate.php", - "TimelessFileModule": "includes/TimelessFileModule.php" + "TimelessVariablesModule": "includes/TimelessVariablesModule.php" }, "manifest_version": 1 }