nodality
Version:
A lightweight library for declarative UI elements.
2 lines • 3.73 kB
JavaScript
/*! For license information please see sideBar.esm.js.LICENSE.txt */
var t={d:(e,n)=>{for(var i in n)t.o(n,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:n[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},e={};function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}function i(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,r(i.key),i)}}function r(t){var e=function(t){if("object"!=n(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,"string");if("object"!=n(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==n(e)?e:e+""}function o(){return o="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,n){var i=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=l(t)););return t}(t,e);if(i){var r=Object.getOwnPropertyDescriptor(i,e);return r.get?r.get.call(arguments.length<3?t:n):r.value}},o.apply(null,arguments)}function l(t){return l=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},l(t)}t.d(e,{z:()=>a});var a=function(){function t(e,n){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.ele=null,this.width="16em",this.height="100vh",this.els=e}return e=t,n=[{key:"setup",value:function(e){var n,i,r,a=this;e.tags&&(n=t,i=this,"function"==typeof(r=o(l(1&3?n.prototype:n),"setTags",i))?function(t){return r.apply(i,t)}:r)([e.tags]),e.width&&(this.width=e.width),e.height&&(this.height=e.height);var s=document.createElement("div");s.style.position="absolute";var c=document.createElement("button");c.style.position="absolute",c.style.background="white",c.style.opacity=.8,c.style.border="none",c.width="1.5em",c.height="1.5em",c.style.borderRadius="50%",c.style.zIndex=2;var u=document.createTextNode("☰");c.appendChild(u),c.style.fontSize="2em",window.matchMedia("(max-device-width: 400px)").matches&&(c.style.fontSize="6em"),window.matchMedia("(max-device-width: 400px)").matches&&e.fullMobile&&(this.width="100vw"),s.appendChild(c);var d=document.createElement("div");return d.style.position="absolute",d.style.backgroundColor="#fff",d.style.flexDirection="column",d.style.display="flex",d.style.alignItems="center",d.style.margin=0,d.style.padding=0,d.style.width=this.width,d.style.margin=0,d.style.marginTop="-10px",d.style.paddingTop="1em",d.style.paddingBottom="1em",d.style.height="".concat(this.height),d.style.transform="translateX(-".concat(this.width,")"),d.style.transition="all 0.80s",s.appendChild(d),this.hidden=!1,c.addEventListener("click",(function(){a.hidden=!a.hidden;for(var t=0;t<d.children.length;t++)"☰"!==d.textContent&&(a.hidden?d.style.transform="translateX(0em)":d.style.transform="translateX(-".concat(a.width,")"))})),this.ele=s,this.els&&this.items(this.els),this}},{key:"background",value:function(t){return this.ele.children[1].style.backgroundColor=t.color,this.ele.children[1].style.opacity=t.opacity,this}},{key:"items",value:function(t){this.itemCount=t.length;for(var e=0;e<t.length;e++)this.ele.children[1].appendChild(t[e].render());return this}},{key:"render",value:function(t){return t?(document.querySelector(t).style.padding=0,document.querySelector(t).style.margin=0,document.querySelector(t).appendChild(this.ele),this.ele):this.ele}}],n&&i(e.prototype,n),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,n}(),s=e.z;export{s as SideBar};