UNPKG

nodality

Version:

A lightweight library for declarative UI elements.

2 lines 2.87 kB
/*! For license information please see gridSwitcher.esm.js.LICENSE.txt */ var t={d:(e,r)=>{for(var n in r)t.o(r,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},e={};function r(t){return r="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},r(t)}function n(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,i(n.key),n)}}function i(t){var e=function(t){if("object"!=r(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=r(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==r(e)?e:e+""}t.d(e,{t:()=>o});var o=function(){return t=function t(){(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")})(this,t),this.gridContainer=document.createElement("div"),this.gridContainer.classList.add("grid-container"),this.gridContainer.style.display="grid"},e=[{key:"set",value:function(t){return t.gap&&(this.gridContainer.style.gap=t.gap),t.height&&(this.gridContainer.style.height=t.height),t.width&&(this.gridContainer.style.width=t.width),this}},{key:"react",value:function(t){var e=this,r=function(){console.log(t.length);for(var r=0;r<t.length-1;r++){console.warn(window.innerWidth);var n=parseInt(t[r].at),i=parseInt(t[r+1].at);if(window.innerWidth>n&&window.innerWidth<i){console.log("FROM "+n+" TO "+i);var o=t[r].template.map((function(t){return t.split("").join(" ")})).map((function(t){return'"'.concat(t,'"')})).join(" ");e.gridContainer.style.gridTemplateAreas=o}else if(window.innerWidth>i){console.log("BIGGER THAN "+i);var a=t[t.length-1].template.map((function(t){return t.split("").join(" ")})).map((function(t){return'"'.concat(t,'"')})).join(" ");e.gridContainer.style.gridTemplateAreas=a}}};return r(),window.addEventListener("resize",r),this}},{key:"add",value:function(t){console.log(t);for(var e=function(t){for(var e=[],r=0;r<t;r++){var n="",i=r;do{n=String.fromCharCode(65+i%26)+n,i=Math.floor(i/26)-1}while(i>=0);e.push(n)}return e}(t.length),r=0;r<t.length;r++){var n=t[r].render();n.style.gridArea=e[r].toLowerCase();var i=document.createElement("div");i.textContent=t[r].text,i.style.gridArea=e[r].toLowerCase(),this.gridContainer.appendChild(n)}return this}},{key:"render",value:function(t){return t&&document.querySelector(t).appendChild(this.gridContainer),this.gridContainer}},{key:"toCode",value:function(){return"new Simple().set({}).react([])"}}],e&&n(t.prototype,e),r&&n(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r}(),a=e.t;export{a as AreaSwitcher};