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