MDL-56959 theme: SCSS file is inherited from parent

Also added support for the SCSS property to be a Closure
and return content rather than simply being the name of a file.
This commit is contained in:
Frederic Massart
2016-11-17 15:18:29 +08:00
parent b4d6669dd0
commit 41b973bcbb
4 changed files with 117 additions and 53 deletions
+38 -26
View File
@@ -46,38 +46,16 @@ function theme_boost_get_extra_scss($theme) {
}
/**
* Get SCSS to prepend.
* Returns the main SCSS content.
*
* @param theme_config $theme The theme config object.
* @return array
* @return string
*/
function theme_boost_get_pre_scss($theme) {
function theme_boost_get_main_scss_content($theme) {
global $CFG;
$scss = '';
$configurable = [
// Config key => [variableName, ...].
'brandcolor' => ['brand-primary'],
];
// Prepend variables first.
foreach ($configurable as $configkey => $targets) {
$value = $theme->settings->{$configkey};
if (empty($value)) {
continue;
}
array_map(function($target) use (&$scss, $value) {
$scss .= '$' . $target . ': ' . $value . ";\n";
}, (array) $targets);
}
// Prepend pre-scss.
if (!empty($theme->settings->scsspre)) {
$scss .= $theme->settings->scsspre;
}
// Now append the preset.
$filename = $theme->settings->preset;
$filename = !empty($theme->settings->preset) ? $theme->settings->preset : null;
$fs = get_file_storage();
$context = context_system::instance();
@@ -94,3 +72,37 @@ function theme_boost_get_pre_scss($theme) {
return $scss;
}
/**
* Get SCSS to prepend.
*
* @param theme_config $theme The theme config object.
* @return array
*/
function theme_boost_get_pre_scss($theme) {
global $CFG;
$scss = '';
$configurable = [
// Config key => [variableName, ...].
'brandcolor' => ['brand-primary'],
];
// Prepend variables first.
foreach ($configurable as $configkey => $targets) {
$value = isset($theme->settings->{$configkey}) ? $theme->settings->{$configkey} : null;
if (empty($value)) {
continue;
}
array_map(function($target) use (&$scss, $value) {
$scss .= '$' . $target . ': ' . $value . ";\n";
}, (array) $targets);
}
// Prepend pre-scss.
if (!empty($theme->settings->scsspre)) {
$scss .= $theme->settings->scsspre;
}
return $scss;
}