UNPKG

nodality

Version:

A lightweight library for declarative UI elements.

2 lines 3.92 kB
/*! For license information please see sideBar.cjs.js.LICENSE.txt */ (()=>{"use strict";var e={d:(t,n)=>{for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};function n(e){return n="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},n(e)}function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,i(r.key),r)}}function i(e){var t=function(e){if("object"!=n(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=n(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==n(t)?t:t+""}function o(){return o="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,n){var r=function(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=l(e)););return e}(e,t);if(r){var i=Object.getOwnPropertyDescriptor(r,t);return i.get?i.get.call(arguments.length<3?e:n):i.value}},o.apply(null,arguments)}function l(e){return l=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},l(e)}e.r(t),e.d(t,{SideBar:()=>a});var a=function(){function e(t,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.ele=null,this.width="16em",this.height="100vh",this.els=t}return t=e,n=[{key:"setup",value:function(t){var n,r,i,a=this;t.tags&&(n=e,r=this,"function"==typeof(i=o(l(1&3?n.prototype:n),"setTags",r))?function(e){return i.apply(r,e)}:i)([t.tags]),t.width&&(this.width=t.width),t.height&&(this.height=t.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&&t.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 e=0;e<d.children.length;e++)"☰"!==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(e){return this.ele.children[1].style.backgroundColor=e.color,this.ele.children[1].style.opacity=e.opacity,this}},{key:"items",value:function(e){this.itemCount=e.length;for(var t=0;t<e.length;t++)this.ele.children[1].appendChild(e[t].render());return this}},{key:"render",value:function(e){return e?(document.querySelector(e).style.padding=0,document.querySelector(e).style.margin=0,document.querySelector(e).appendChild(this.ele),this.ele):this.ele}}],n&&r(t.prototype,n),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,n}();module.exports=t})();