Add CSS injection code

This commit is contained in:
Evan Pratten 2020-04-17 17:20:51 -04:00
parent d4dbed85e9
commit e9a5521dfc
No known key found for this signature in database
GPG Key ID: 93AC7B3D071356D3

View File

@ -1,4 +1,6 @@
// Document root theme
let _rootCSS = document.body.style;
/**
* Inject all KVPs from a dictionary into the document
@ -9,6 +11,17 @@
*/
function injectMultiCSS(prefix, source_dict) {
console.log(`[CSSInjector] Injecting css for: ${prefix}`);
// Iter through every variable, and add it to the site CSS
Object.keys(source_dict).forEach((k) => {
let varname = `--${prefix}-${k}`;
_rootCSS += `${varname}:${source_dict[k]};`
});
}
/* Mappings from constants file to CSS */