/* * Theme Pack 1.0.0 (https://github.com/abdullahseba/theme-pack) * Copyright 2018 Abdullah Seba * Licensed under MIT */ import ThemeManager from "./ThemeManager"; import LayoutManager from "./LayoutManager"; import SkinManager from "./SkinManager"; import Sidebar from "./Sidebar"; /** * Options interface for {@link ThemePack.setTheme}. * * @type {interface} */ export interface options { name: string; skin?: string; layout?: string[]; default?: string; callback?: object; } class ThemePack { //Add these classes globally. themeManager = ThemeManager; skinManager = SkinManager; layoutManager = LayoutManager; sidebar = Sidebar; /** * Set theme. * * @param {options} * { * 'name':'', * 'skin', * 'layout': [] * } */ setTheme(options: options) { //Throw error if options is not an object. if (typeof options != "object") { throw "Invalid object provided"; } /** * Name of theme provided in options. * @const {string} */ const themeName = options.name; /** * Name of skin provided in options. * @const {string} */ const skinName = options.skin; /** * Name of layout provided in options. * @const {string[]} */ const layoutNames: string[] = options.layout; //Load theme if (options.callback) { ThemeManager.loadTheme({ themeName: themeName, callback: options.callback }); } else { ThemeManager.loadTheme({ themeName: themeName }); } //Load skin. if (skinName) { SkinManager.setSkin(skinName); } else { SkinManager.applyDefaultSkin(); } //Load layout. if (layoutNames) { LayoutManager.addLayout(layoutNames); } else { LayoutManager.applyDefaultLayout(); } } } export default ThemePack; // (window).addEventListener( // "DOMContentLoaded", // () => { // (window).ThemePack = new ThemePack(); // (window).ThemePack.setTheme({ // name: "material", // // "layout": ["tpl-main-sidebar-collapsed"], // skin: "light" // }); // // //Get styles. // // const styles = getComputedStyle(document.documentElement); // // //Get mobile layout. // // const mobileLayout = styles.getPropertyValue("--mobile-layout"); // // //Minimize sidebar if on mobile. // // if (mobileLayout == " true") { // // (window).ThemePack.mainSidebar.minimize(); // // } // }, // false // );