Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FR: Child Theming: Union's extra SCSS could already replicate Boost's extra SCSS rules if a theme with Boost Union as its ancestor is the current theme #718

Open
danowar2k opened this issue Sep 27, 2024 · 2 comments
Labels
child theme support Something which helps the creation and management of Boost Union child themes new issue to be labeled by Boost Union Team

Comments

@danowar2k
Copy link
Collaborator

danowar2k commented Sep 27, 2024

Is your feature request related to a problem? Please describe.
In our child theme we currently need to do this:

/**
 * Get SCSS to append.
 * @return string
 */
function theme_boost_union_feu_base_get_extra_scss():string {
    // Boost's extra SCSS function is called automatically before this,
    // but is only given the current theme's config.
    // Boost Union Feu Base doesn't replicate Boost's settings so that call leads to incomplete SCSS
    // Boost Union has Boost's extra SCSS relevant settings replicated,
    // so we load Boost Union's config and then get Boost's correct extra SCSS
    $unionConfig = theme_config::load('boost_union');
    $boostExtraScss = theme_boost_get_extra_scss($unionConfig);
    // Even though boost_union's config has already been called and produced the correct extra SCSS,
    // that is now "before" the currently produced Boost SCSS, so we need to again create the Union extra SCSS
    // to avoid that Union's SCSS is overwritten by Boost's SCSS rules
    $boostUnionExtraScss = theme_boost_union_get_extra_scss($unionConfig);
    return $boostExtraScss.$boostUnionExtraScss;
}

Basically, Moodle runs each theme's extra SCSS function in the ancestry with the $theme object of the current theme. When your theme doesn't replicate Boost's settings backgroundimage, loginbackgroundimage and scss, that extra SCSS generated by Boost's function is incomplete.
Boost Union replicates those settings, so we run Boost's extra SCSS function again with Union's config to get the correct SCSS.
But then we have to run Union's extra SCSS function again to have a correct order for the SCSS rules.

Describe the solution you'd like
Union could already run Boost's extra SCSS function at the start of its own extra SCSS function with the Union config as the parameter to generate the correct SCSS.
This way we wouldn't even need our own extra SCSS function anymore.

Of course, this should only be necessary if Union isn't the current theme.

Describe alternatives you've considered
Reproducing the settings still doesn't make sense to me...

@danowar2k danowar2k added the new issue to be labeled by Boost Union Team label Sep 27, 2024
@danowar2k
Copy link
Collaborator Author

danowar2k commented Sep 27, 2024

Proposed solution:

function theme_boost_union_get_extra_scss($theme) {
    global $CFG;

    // Require the necessary libraries.
    require_once($CFG->dirroot . '/course/lib.php');

    // Initialize extra SCSS.
    $content = '';
    
    // Fetch Boost's extra SCSS if the current theme is not Union itself (can only be a child theme then)
    if ($theme->name !== 'boost_union') {
        $union_config = theme_config::load('boost_union');
        $content .= theme_boost_get_extra_scss($union_config);
    }
    // You might think that this extra SCSS function is only called for the activated theme.

@danowar2k danowar2k added the child theme support Something which helps the creation and management of Boost Union child themes label Sep 27, 2024
@danowar2k
Copy link
Collaborator Author

Hmmm, maybe this issue will be resolved by my proposed change, too? moodle-an-hochschulen/moodle-theme_boost_union_child#5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
child theme support Something which helps the creation and management of Boost Union child themes new issue to be labeled by Boost Union Team
Projects
Status: No status
Development

No branches or pull requests

1 participant