UNPKG

@startpage/theming

Version:

Create and use themes for your startpage

21 lines (20 loc) 675 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.injectThemeIntoCss = void 0; const root = document.documentElement; const injectObject = (object, path) => { Object.keys(object).forEach(key => { const newPath = `${path}-${key}`; if (typeof object[key] === "object") injectObject(object[key], newPath); else root.style.setProperty(newPath, object[key]); }); }; const injectThemeIntoCss = (theme, prefix) => { if (prefix) injectObject(theme, "--" + prefix); else injectObject(theme, "-"); }; exports.injectThemeIntoCss = injectThemeIntoCss;