2021-10-23 12:17:04 +07:00
|
|
|
"use strict";function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}!function(){var e,t,n={minWidth:"992px",targets:{nav:"aside nav",details:"aside details"},init:function(){var e,t;window.matchMedia("(min-width: "+this.minWidth+")").matches&&(e=document.querySelector(this.targets.nav),t=document.querySelectorAll(this.targets.details),e.clientHeight<e.scrollHeight&&t.forEach(function(e){e.removeAttribute("open")}))}},i={_scheme:"auto",change:{light:"<i>Turn on dark mode</i>",dark:"<i>Turn off dark mode</i>"},buttonsTarget:".theme-switcher",init:function(){this.scheme=this._scheme,this.initSwitchers()},get preferedColorScheme(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"},initSwitchers:function(){document.querySelectorAll(this.buttonsTarget).forEach(function(e){e.addEventListener("click",function(e){"dark"==this.scheme?this.scheme="light":this.scheme="dark"}.bind(this),!1)}.bind(this))},addButton:function(e){var t=document.createElement(e.tag);t.className=e.class,document.querySelector(e.target).appendChild(t)},set scheme(e){"auto"==e?"dark"==this.preferedColorScheme?this._scheme="dark":this._scheme="light":"dark"!=e&&"light"!=e||(this._scheme=e),this.applyScheme()},get scheme(){return this._scheme},applyScheme:function(){var t;document.querySelector("html").setAttribute("data-theme",this.scheme),document.querySelectorAll(this.buttonsTarget).forEach(function(e){t="dark"==this.scheme?this.change.dark:this.change.light,e.innerHTML=t,e.setAttribute("aria-label",t.replace(/<[^>]*>?/gm,""))}.bind(this))}},a={colors:null,buttonsTarget:'#customization article[data-theme="generated"]',selectorButton:"#customization button[data-color]",selectorSection:"#customization",buttons:null,generatedStyles:null,init:function(){this.generateButtons(),this.setActiveButton("pink"),this.generateTheme("pink")},generateButtons:function(){var e,t="",n="";for(e in this.colors)t+='<button data-color="'+e+'" aria-label="Activate '+e+' theme"></button>',n+='\n button[data-color="'.concat(e,'"] {\n background-color: ').concat(this.colors[e][600],';\n }\n [data-theme="light"] button[data-color="').concat(e,'"]:hover,\n [data-theme="light"] button[data-color="').concat(e,'"]:active,\n [data-theme="light"] button[data-color="').concat(e,'"]:focus {\n background-color: ').concat(this.colors[e][700],'; \'\n }\n [data-theme="dark"] button[data-color="').concat(e,'"]:hover,\n [data-theme="dark"] button[data-color="').concat(e,'"]:active,\n [data-theme="dark"] button[data-color="').concat(e,'"]:focus {\n background-color: ').concat(this.colors[e][500],";\n }");var i=document.createElement("FIGURE");i.innerHTML=t,document.querySelector(this.buttonsTarget).before(i),this.buttons=document.querySelectorAll(this.selectorButton),this.buttons.forEach(function(e){e.addEventListener("click",function(e){e=e.target.getAttribute("data-color");this.setActiveButton(e),this.generateTheme(e)}.bind(this),!1)}.bind(this));i=document.createElement("STYLE");i.setAttribute("title","color-picker"),this.generatedStyles=this.minifyCSS(n),i.innerHTML=this.generatedStyles,document.querySelector("head").appendChild(i)},setActiveButton:function(e){this.buttons.forEach(function(e){e.removeAttribute("class")}.bind(this)),document.querySelector(this.selectorButton+'[data-color="'+e+'"]').setAttribute("class","picked")},generateTheme:function(e){var t=e,e=this.colors[e],n={".name":t.charAt(0).toUpperCase()+t.substring(1)+" ",".c500":e[500],".c600":e[600],".c700":e[700],".c600-outline-light":this.hexToRgbA(e[600],.125),".c600-outline-dark":this.hexToRgbA(e[600],.25),".inverse":e.inverse};Object.keys(n).forEach(function(t){document.querySelectorAll(this.selectorSection+" "+t).forEach(function(e){e.innerHTML=n[t]}.bind(this))}.bind(this));e='\n [data-theme="generated"] {\n
|