All files / src/tools theme.js

100% Statements 13/13
100% Branches 2/2
100% Functions 1/1
100% Lines 12/12
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23      5x     1x 1x 1x 1x 1x     1x 1x 1x 1x 1x   1x      
 
export default {
    loader: (clientDomain, theme, cb) => {
        if (!theme) return cb();
 
        // Javascript
        const themeJS = `${clientDomain}/static/js/krypton-client/V4.0/ext/${theme}.js`;
        let script = document.createElement('script');
        script.type = 'text/javascript';
        script.src = themeJS;
        document.getElementsByTagName('body')[0].appendChild(script);
 
        // CSS
        const themeCSS = `${clientDomain}/static/js/krypton-client/V4.0/ext/${theme}-reset.css`;
        let link = document.createElement('link');
        link.rel = 'stylesheet';
        link.href = themeCSS;
        document.getElementsByTagName('body')[0].appendChild(link);
 
        setTimeout(cb, 0);
    },
};