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:
+38
-26
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user