From c2088dadc63d385e9cb0cc95c7c6f3bde2e843eb Mon Sep 17 00:00:00 2001 From: Daniel Date: Wed, 23 Oct 2019 12:59:20 -0400 Subject: [PATCH] #24 floating side menu --- build/2.css | 2 +- build/2.js | 2 +- build/main.js | 2 +- src/components/collection/index.js | 62 ++++++++++++++++++------------ 4 files changed, 41 insertions(+), 27 deletions(-) diff --git a/build/2.css b/build/2.css index 1a9119f..0cb2e0f 100644 --- a/build/2.css +++ b/build/2.css @@ -1 +1 @@ -.icon14{height:14px;padding-bottom:2px}.icon16{height:16px}.icon20{height:20px}.icon24{height:24px}.bigger{font-size:14px}.name{-webkit-user-select:all;-moz-user-select:all;-ms-user-select:all;user-select:all}.name .subname:before{content:"\a ";white-space:pre}.name .subname{font-size:13px;padding-bottom:4px;display:inherit}@media only screen and (min-width:975px){.collection{margin-top:5px;margin-right:5px;margin-left:5px}}@media only screen and (min-width:975px){.collection>.left{font-family:Roboto,Arial,sans-serif;float:left;width:30%}.collection>.right{font-family:Roboto,Arial,sans-serif;float:right;width:70%}.collection #buttons{margin:0 0 2% 1%}.collection #buttons,.collection .button,.collection input[type=button],.collection input[type=text]{border-radius:5px;border-color:transparent;text-align:center;outline:none}.collection input[type=text]{margin-bottom:2px}.collection .centeredCheckBox,.collection input[type=text]{width:220px}.collection .text-entry{display:flex;justify-content:center;align-items:center}.collection .text-entry input:focus{outline:none}.collection .card{text-align:left;display:flex;border:1px solid #aeaeae}.collection .card .left,.collection .card .right,.collection .card .stats{padding-top:4px}.collection .card .bigger{text-align:center;font-weight:700}.collection .card .energy{display:flex;width:20px!important}.collection .card .left{vertical-align:text-top;float:left;width:210px;padding-left:4px}.collection .card .right{float:left;width:calc(100% - 322px);border-left:2px solid #aeaeae;padding-left:4px;padding-right:4px;padding-bottom:6px;white-space:pre-line}.collection .creature .right{width:calc(100% - 366px)}.collection .creature .stats{vertical-align:text-top;float:left;text-align:right;width:40px}.collection .SearchForm{padding-top:3px;font-family:Roboto,Arial,sans-serif}.collection .searchName{display:flex;justify-content:center;align-items:center;padding:2%;font-size:16pt}.collection .centeredCheckBox{margin:0 auto;text-align:left}.collection .centeredSpacing{display:flex;justify-content:space-between}.collection .setBox{width:80%;float:right}.collection #sets{width:80%}.collection .centeredButtons{display:flex;justify-content:center;align-items:center}.collection #search{width:25%;margin:2%;border-radius:5px;border-color:transparent;text-align:center}.collection .minMax{display:flex;justify-content:space-between;margin:0 auto;width:50%;text-align:right}.collection .brainwashed{border-radius:3px;background-color:#dcdddf;color:#000!important}.collection .chieftain,.collection .flavortext{font-style:italic}.collection .mull input{margin-left:0;margin-top:1px}.collection .Collapsible__contentInner input,.collection .mull input{vertical-align:middle}.collection .Collapsible__contentInner .centeredCheckBox{width:50%}.collection .tribes{width:96%;text-align:center}.collection .and,.collection .disciplines{text-align:center}.collection .and{vertical-align:text-bottom;width:15%;border-radius:5px;border-color:transparent;margin:2%}}.collection .disciplines input{width:30px;height:14px;text-align:center;margin-top:2px}.collection .mcbp input{width:24px;height:14px;padding:unset;text-align:center;margin-top:2px}.collection .card .icon14,.collection .card .icon16,.collection .card .icon20,.collection .card .icon24{vertical-align:middle}.collection .thumb{width:100px;height:98px}.collection .card .thumb{float:left}.collection .attack .bp{vertical-align:middle}.collection .Collapsible{margin-bottom:5px;margin-top:5px;width:96%}.collection .Collapsible__trigger{background-color:#333;display:block;position:relative;padding-top:5px;padding-bottom:5px;text-indent:5px;font-weight:700;white-space:pre}.collection .Collapsible__trigger:hover{background-color:red}.collection .Collapsible__trigger:after{content:"^";position:absolute;right:10px;top:10px;display:block;transition:transform .4s}.collection .Collapsible__trigger.is-open:after{transform:rotate(180deg);right:5px;top:5px}.collection .Collapsible__trigger.is-disabled{opacity:.5;background-color:grey}.collection .Collapsible__contentInner{margin-top:5px}.collection .left{position:relative}.collection .card_img{position:absolute;width:100%;z-index:2;left:-11px}.collection .card_img .hidden{display:none;max-height:0}.collection .card_img img{max-width:250px;max-height:350px}.collection .entries{text-align:left;width:100%}.collection .entries input[type=button]{margin:0 0 2% 1%}.collection .list-nav-top{display:flex}.collection .extended .fullcard{max-width:250px;max-height:350px}.collection hr{width:96%;margin-inline-start:0}.collection .none{display:inline}.collection .none>span{top:-3px;position:relative}.collection label{user-select:none;-webkit-user-select:none;-ms-user-select:none;-webkit-touch-callout:none;-o-user-select:none;-moz-user-select:none} \ No newline at end of file +.icon14{height:14px;padding-bottom:2px}.icon16{height:16px}.icon20{height:20px}.icon24{height:24px}.bigger{font-size:14px}.name{-webkit-user-select:all;-moz-user-select:all;-ms-user-select:all;user-select:all}.name .subname:before{content:"\a ";white-space:pre}.name .subname{font-size:13px;padding-bottom:4px;display:inherit}@media only screen and (min-width:975px){.collection{margin-top:5px;margin-right:5px;margin-left:5px}}@media only screen and (min-width:975px){.collection>.left{font-family:Roboto,Arial,sans-serif;float:left;width:30%}.collection>.right{font-family:Roboto,Arial,sans-serif;float:right;width:70%}.collection .left>.fixed{position:fixed;top:0;overflow-y:auto;height:100vh;width:calc(30% - 30px)}.collection #buttons{margin:0 0 2% 1%}.collection #buttons,.collection .button,.collection input[type=button],.collection input[type=text]{border-radius:5px;border-color:transparent;text-align:center;outline:none}.collection input[type=text]{margin-bottom:2px}.collection .centeredCheckBox,.collection input[type=text]{width:220px}.collection .text-entry{display:flex;justify-content:center;align-items:center}.collection .text-entry input:focus{outline:none}.collection .card{text-align:left;display:flex;border:1px solid #aeaeae}.collection .card .left,.collection .card .right,.collection .card .stats{padding-top:4px}.collection .card .bigger{text-align:center;font-weight:700}.collection .card .energy{display:flex;width:20px!important}.collection .card .left{vertical-align:text-top;float:left;width:210px;padding-left:4px}.collection .card .right{float:left;width:calc(100% - 322px);border-left:2px solid #aeaeae;padding-left:4px;padding-right:4px;padding-bottom:6px;white-space:pre-line}.collection .creature .right{width:calc(100% - 366px)}.collection .creature .stats{vertical-align:text-top;float:left;text-align:right;width:40px}.collection .SearchForm{padding-top:3px;font-family:Roboto,Arial,sans-serif}.collection .searchName{display:flex;justify-content:center;align-items:center;padding:2%;font-size:16pt}.collection .centeredCheckBox{margin:0 auto;text-align:left}.collection .centeredSpacing{display:flex;justify-content:space-between}.collection .setBox{width:80%;float:right}.collection #sets{width:80%}.collection .centeredButtons{display:flex;justify-content:center;align-items:center}.collection #search{width:25%;margin:2%;border-radius:5px;border-color:transparent;text-align:center}.collection .minMax{display:flex;justify-content:space-between;margin:0 auto;width:50%;text-align:right}.collection .brainwashed{border-radius:3px;background-color:#dcdddf;color:#000!important}.collection .chieftain,.collection .flavortext{font-style:italic}.collection .mull input{margin-left:0;margin-top:1px}.collection .Collapsible__contentInner input,.collection .mull input{vertical-align:middle}.collection .Collapsible__contentInner .centeredCheckBox{width:50%}.collection .tribes{width:96%;text-align:center}.collection .and,.collection .disciplines{text-align:center}.collection .and{vertical-align:text-bottom;width:15%;border-radius:5px;border-color:transparent;margin:2%}}.collection .disciplines input{width:30px;height:14px;text-align:center;margin-top:2px}.collection .mcbp input{width:24px;height:14px;padding:unset;text-align:center;margin-top:2px}.collection .card .icon14,.collection .card .icon16,.collection .card .icon20,.collection .card .icon24{vertical-align:middle}.collection .thumb{width:100px;height:98px}.collection .card .thumb{float:left}.collection .attack .bp{vertical-align:middle}.collection .Collapsible{margin-bottom:5px;margin-top:5px;width:96%}.collection .Collapsible__trigger{background-color:#333;display:block;position:relative;padding-top:5px;padding-bottom:5px;text-indent:5px;font-weight:700;white-space:pre}.collection .Collapsible__trigger:hover{background-color:red}.collection .Collapsible__trigger:after{content:"^";position:absolute;right:10px;top:10px;display:block;transition:transform .4s}.collection .Collapsible__trigger.is-open:after{transform:rotate(180deg);right:5px;top:5px}.collection .Collapsible__trigger.is-disabled{opacity:.5;background-color:grey}.collection .Collapsible__contentInner{margin-top:5px}.collection .card_img{position:absolute;width:100%;z-index:2;left:-11px}.collection .card_img .hidden{display:none;max-height:0}.collection .card_img img{max-width:250px;max-height:350px}.collection .entries{text-align:left;width:100%}.collection .entries input[type=button]{margin:0 0 2% 1%}.collection .list-nav-top{display:flex}.collection .extended .fullcard{max-width:250px;max-height:350px}.collection hr{width:96%;margin-inline-start:0}.collection .none{display:inline}.collection .none>span{top:-3px;position:relative}.collection label{user-select:none;-webkit-user-select:none;-ms-user-select:none;-webkit-touch-callout:none;-o-user-select:none;-moz-user-select:none} \ No newline at end of file diff --git a/build/2.js b/build/2.js index be1ba6f..579da78 100644 --- a/build/2.js +++ b/build/2.js @@ -1 +1 @@ -(window.webpackJsonp=window.webpackJsonp||[]).push([[2],{387:function(e,t,a){},390:function(e,t,a){"use strict";a.r(t);var n,r,i,l,s,c,m,u,o,g,p,d=a(122),x=a.n(d),h=a(64),b=a.n(h),f=a(62),y=a.n(f),$=a(52),E=a.n($),v=a(119),k=a.n(v),w=a(120),C=a.n(w),N=a(165),q=a.n(N),I=a(121),O=a.n(I),_=a(39),j=a.n(_),R=(a(164),a(0)),B=a.n(R),M=a(70),S=a(6),A=a(85),L=a(35),T=Object(A.a)(function(e,t,a){return t})(n=Object(A.b)(n=function(e){function t(){return y()(this,t),k()(this,C()(t).apply(this,arguments))}return O()(t,e),E()(t,[{key:"render",value:function(){var e=this,t=this.props.card;return 0==this.props.ext?B.a.createElement("div",{className:"card attack"},B.a.createElement("img",{className:"thumb",src:M.a.base_image+(t.gsx$thumb||M.a.thumb_missing),onClick:function(){return e.props.setImage(t.gsx$image)}}),B.a.createElement("div",{className:"left"},B.a.createElement(L.k,{name:t.gsx$name}),B.a.createElement("br",null),B.a.createElement(L.m,{set:t.gsx$set,rarity:t.gsx$rarity}),B.a.createElement("br",null),B.a.createElement("span",null,B.a.createElement(L.b,{bp:t.gsx$bp})," Attack - ",t.gsx$bp),B.a.createElement("br",null),B.a.createElement("div",null,B.a.createElement("span",{className:"bp bigger"},t.gsx$base)," | ",B.a.createElement(L.f,{element:"fire",value:t.gsx$fire}),t.gsx$fire," ",B.a.createElement(L.f,{element:"air",value:t.gsx$air}),t.gsx$air," ",B.a.createElement(L.f,{element:"earth",value:t.gsx$earth}),t.gsx$earth," ",B.a.createElement(L.f,{element:"water",value:t.gsx$water}),t.gsx$water)),B.a.createElement("br",null),B.a.createElement("div",{className:"right"},B.a.createElement(L.a,{ability:t.gsx$ability}),B.a.createElement(L.q,{data:{unique:t.gsx$unique,loyal:t.gsx$loyal,legendary:t.gsx$legendary}}),B.a.createElement("span",{className:"flavortext"},t.gsx$flavortext))):B.a.createElement("div",{className:"card attack"},B.a.createElement("img",{className:"fullcard",src:M.a.base_image+(t.gsx$image||M.a.card_back)}),B.a.createElement("div",{className:"right"},B.a.createElement(L.k,{name:t.gsx$name}),B.a.createElement("br",null),B.a.createElement(L.a,{ability:t.gsx$ability}),B.a.createElement(L.q,{data:{unique:t.gsx$unique,loyal:t.gsx$loyal,legendary:t.gsx$legendary}}),t.gsx$flavortext&&B.a.createElement(B.a.Fragment,null,B.a.createElement("span",{className:"flavortext"},t.gsx$flavortext),B.a.createElement("br",null)),B.a.createElement("span",null,"Art By: ",t.gsx$artist)))}}]),t}(B.a.Component))||n)||n,P=Object(A.a)(function(e,t,a){return t})(r=Object(A.b)(r=function(e){function t(){return y()(this,t),k()(this,C()(t).apply(this,arguments))}return O()(t,e),E()(t,[{key:"render",value:function(){var e=this,t=this.props.card;return 0==this.props.ext?B.a.createElement("div",{className:"card battlegear"},B.a.createElement("img",{className:"thumb",style:{float:"left"},src:M.a.base_image+(t.gsx$thumb||M.a.thumb_missing),onClick:function(){return e.props.setImage(t.gsx$image)}}),B.a.createElement("div",{className:"left"},B.a.createElement(L.k,{name:t.gsx$name}),B.a.createElement("br",null),B.a.createElement(L.m,{set:t.gsx$set,rarity:t.gsx$rarity}),B.a.createElement("br",null),B.a.createElement("span",null,B.a.createElement(L.c,null)," Battlegear",0=t.energy.min&&(l=l.find({gsx$energy:{$lte:t.energy.max}})),(0=t.mcbp.min&&(r=r.find({gsx$bp:{$lte:t.mcbp.max}}),l=l.find({gsx$mugicability:{$lte:t.mcbp.max}}),c=c.find({gsx$cost:{$lte:t.mcbp.max}})),(0=t.energy.min&&(l=l.find({gsx$energy:{$lte:t.energy.max}})),(0=t.mcbp.min&&(i=i.find({gsx$bp:{$lte:t.mcbp.max}}),l=l.find({gsx$mugicability:{$lte:t.mcbp.max}}),c=c.find({gsx$cost:{$lte:t.mcbp.max}})),(0=t[r]?de.setFixed(window.innerHeight):de.isFixed||de.setFixed(window.innerHeight)}else de.isFixed&&de.removeFixed()};var t=localStorage.getItem("extended");return null==t&&(e.ext=!1),e.ext=/true/i.test(t),e}return O()(a,e),E()(a,[{key:"componentDidMount",value:function(){window.addEventListener("scroll",this.handleScroll)}},{key:"componentWillUnmount",value:function(){window.removeEventListener("scroll",this.handleScroll)}},{key:"handleContent",value:function(e){this.content=e,this.p=1}},{key:"setImage",value:function(e){this.card_img=e||F.a.card_back,this.changeImage()}},{key:"setExt",value:function(){this.ext=!this.ext,localStorage.setItem("extended",this.ext)}},{key:"render",value:function(){var t=this;return B.a.createElement("div",{className:"collection "+(this.ext?"extended":"short")},B.a.createElement("div",{className:"left"},B.a.createElement("div",{id:"side-menu",style:de.fixed},B.a.createElement(fe,{url:F.a.base_image+this.card_img,ref:function(e){e&&(t.changeImage=e.getInstance().changeImage)}}),B.a.createElement(ge,x()({handleContent:this.handleContent.bind(this)},this.props)))),B.a.createElement("div",{className:"right"},B.a.createElement("div",{className:"list-nav-top"},this.navigation(),this.extended()),B.a.createElement("br",null),B.a.createElement(D,{ext:this.ext,cards:this.content.slice(this.n*(this.p-1),this.n*this.p),setImage:this.setImage.bind(this)}),B.a.createElement("br",null),this.navigation()))}},{key:"extended",value:function(){return B.a.createElement("div",{className:"ext-button"},B.a.createElement("button",{id:"buttons",onClick:this.setExt.bind(this)},this.ext?"Short Format":"Extended Format"))}},{key:"navigation",value:function(){var t=this,e=Math.ceil(this.content.length/this.n);return B.a.createElement("div",{className:"entries"},this.content.length," results - page ",this.p," of ",e," ",1new Date(t)&&(l[a].clear(),l[a].insert(e),k.set("".concat(l.format,"_").concat(a),e[0].updated,{path:"/"})):k.set("".concat(l.format,"_").concat(a),e[0].updated,{path:"/"})}),e.abrupt("return",t());e.next=5;break;case 5:if("building"==this.building[a].get())return r=Object(N.l)(this.building[a],function(e){r(),t()}),e.abrupt("return",r);e.next=8;break;case 8:if("setup"!=this.building[a].get()){e.next=16;break}if(this.building[a].set("building"),0==this[a].data.length)return e.abrupt("return",this.getSpreadsheetData(this.api.urls[n][this.format],n,function(e){return l[a].insert(e),l.building[a].set("built"),t()}));e.next=14;break;case 14:return this.building[a].set("built"),e.abrupt("return",t());case 16:e.next=21;break;case 18:return this.building[a]=N.k.box("wait"),i=Object(N.l)(this.building[a],function(){return i(),l.setupType(a,t)}),e.abrupt("return",i);case 21:case"end":return e.stop()}},e,this)})),function(e,t){return a.apply(this,arguments)})},{key:"setupDB",value:function(e){var n=new B.a("chaotic_".concat(e,".db"),{autosave:!0,autoload:!0,autoloadCallback:function(){var a=this;["attacks","battlegear","creatures","locations","mugic"].forEach(function(e){var t=n.getCollection(e);null===t||0===t.data.length?(a[e]=n.addCollection(e),a.building[e]?a.building[e].set("setup"):a.building[e]=N.k.box("setup")):(a[e]=t,a.building[e]?a.building[e].set("built"):a.building[e]=N.k.box("built"))})}.bind(this),autosaveInterval:4e3,persistenceMethod:"localStorage"});this.db=n}}]),n}(),l=A()(a.prototype,"building",[N.k],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return{}}}),A()(a.prototype,"setupType",[N.d],Object.getOwnPropertyDescriptor(a.prototype,"setupType"),a.prototype),A()(a.prototype,"setupDB",[N.d],Object.getOwnPropertyDescriptor(a.prototype,"setupDB"),a.prototype),a),C=(u=r=function(){function a(){b()(this,a),h()(this,"portal",c,this),h()(this,"cards",o,this),h()(this,"urls",s,this),this.instance=null,this.setupDB()}var t,n,r;return y()(a,[{key:"path",value:function(e){return a.path(e)}},{key:"base_image",get:function(){return"https://drive.google.com/uc?id="}},{key:"thumb_missing",get:function(){return"1JYjPzkv74IhzlHTyVh2niTDyui73HSfp"}},{key:"card_back",get:function(){return"1_MgWDPsPGf-gPBArn2v6ideJcqOPsSYC"}}],[{key:"getInstance",value:function(){return this.instance||(this.instance=new a),this.instance}},{key:"path",value:function(e){return a.base_url+e+a.data_format}}]),y()(a,[{key:"getSpreadsheet",value:(r=g()(p.a.mark(function e(t,a){return p.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:fetch(t).then(function(e){return e.json()}).then(function(e){return a(e.feed.entry)}).catch(function(e){return console.error("parsing failed",e),a(null)});case 1:case"end":return e.stop()}},e)})),function(e,t){return r.apply(this,arguments)})},{key:"setupDB",value:function(){try{var t={};i(360).forEach(function(e){t[e.gsx$type.$t]||(t[e.gsx$type.$t]={}),t[e.gsx$type.$t][e.gsx$subtype.$t]=a.path(e.gsx$url.$t)}),this.urls=t,this.portal=new M(this,"portal"),this.cards=new M(this,"cards")}catch(e){console.error("setting up database failed",e)}}},{key:"LoadDB",value:(n=g()(p.a.mark(function e(a){var n=this;return p.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise(function(e,t){null!==n.urls&&null!==n.portal&&null!==n.cards?n.buildCollection(a).then(function(){e()}):e()}));case 1:case"end":return e.stop()}},e)})),function(e){return n.apply(this,arguments)})},{key:"buildCollection",value:(t=g()(p.a.mark(function e(t){var n=this;return p.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Promise.all(t.map(function(a){return new Promise(function(e,t){return"cards"in a?n.cards.setupType(a.cards,e):"portal"in a?n.portal.setupType(a.portal,e):(console.error("cards or portal"),t())})}));case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}},e)})),function(e){return t.apply(this,arguments)})},{key:"purgeDB",value:function(){this.cards.purgeDB(),this.portal.purgeDB(),window.location.reload()}},{key:"tribes",get:function(){return["Danian","Generic","Mipedian","M'arrillian","OverWorld","UnderWorld"]}},{key:"sets",get:function(){return{DOP:"Dawn of Perim",ZOTH:"Zenith of the Hive",SS:"Silent Sands",MI:"Beyond the Doors",ROTO:"Rise of the Oligarch",TOTT:"Turn of the Tide",FUN:"Forged Unity",AU:"Alliance Unraveled",FAS:"Fire and Stone",SAS:"Storm and Sea",EE:"Elemental Emperors",BR:"Beyond Rare",LR:"League Rewards",OP1:"Organized Play 1",PROMO:"Promotional"}}}]),a}(),r.base_url="https://spreadsheets.google.com/feeds/list/",r.data_format="/od6/public/values?alt=json",n=u,c=A()(n.prototype,"portal",[N.k],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),o=A()(n.prototype,"cards",[N.k],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),s=A()(n.prototype,"urls",[N.k],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),n);t.a=C.getInstance()}}); \ No newline at end of file +!function(o){function e(e){for(var t,a,n=e[0],r=e[1],i=e[2],l=0,c=[];lnew Date(t)&&(l[a].clear(),l[a].insert(e),k.set("".concat(l.format,"_").concat(a),e[0].updated,{path:"/"})):k.set("".concat(l.format,"_").concat(a),e[0].updated,{path:"/"})}),e.abrupt("return",t());e.next=5;break;case 5:if("building"==this.building[a].get())return r=Object(N.l)(this.building[a],function(e){r(),t()}),e.abrupt("return",r);e.next=8;break;case 8:if("setup"!=this.building[a].get()){e.next=16;break}if(this.building[a].set("building"),0==this[a].data.length)return e.abrupt("return",this.getSpreadsheetData(this.api.urls[n][this.format],n,function(e){return l[a].insert(e),l.building[a].set("built"),t()}));e.next=14;break;case 14:return this.building[a].set("built"),e.abrupt("return",t());case 16:e.next=21;break;case 18:return this.building[a]=N.k.box("wait"),i=Object(N.l)(this.building[a],function(){return i(),l.setupType(a,t)}),e.abrupt("return",i);case 21:case"end":return e.stop()}},e,this)})),function(e,t){return a.apply(this,arguments)})},{key:"setupDB",value:function(e){var n=new B.a("chaotic_".concat(e,".db"),{autosave:!0,autoload:!0,autoloadCallback:function(){var a=this;["attacks","battlegear","creatures","locations","mugic"].forEach(function(e){var t=n.getCollection(e);null===t||0===t.data.length?(a[e]=n.addCollection(e),a.building[e]?a.building[e].set("setup"):a.building[e]=N.k.box("setup")):(a[e]=t,a.building[e]?a.building[e].set("built"):a.building[e]=N.k.box("built"))})}.bind(this),autosaveInterval:4e3,persistenceMethod:"localStorage"});this.db=n}}]),n}(),l=A()(a.prototype,"building",[N.k],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return{}}}),A()(a.prototype,"setupType",[N.d],Object.getOwnPropertyDescriptor(a.prototype,"setupType"),a.prototype),A()(a.prototype,"setupDB",[N.d],Object.getOwnPropertyDescriptor(a.prototype,"setupDB"),a.prototype),a),C=(u=r=function(){function a(){b()(this,a),h()(this,"portal",c,this),h()(this,"cards",o,this),h()(this,"urls",s,this),this.instance=null,this.setupDB()}var t,n,r;return y()(a,[{key:"path",value:function(e){return a.path(e)}},{key:"base_image",get:function(){return"https://drive.google.com/uc?id="}},{key:"thumb_missing",get:function(){return"1JYjPzkv74IhzlHTyVh2niTDyui73HSfp"}},{key:"card_back",get:function(){return"1_MgWDPsPGf-gPBArn2v6ideJcqOPsSYC"}}],[{key:"getInstance",value:function(){return this.instance||(this.instance=new a),this.instance}},{key:"path",value:function(e){return a.base_url+e+a.data_format}}]),y()(a,[{key:"getSpreadsheet",value:(r=g()(p.a.mark(function e(t,a){return p.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:fetch(t).then(function(e){return e.json()}).then(function(e){return a(e.feed.entry)}).catch(function(e){return console.error("parsing failed",e),a(null)});case 1:case"end":return e.stop()}},e)})),function(e,t){return r.apply(this,arguments)})},{key:"setupDB",value:function(){try{var t={};i(360).forEach(function(e){t[e.gsx$type.$t]||(t[e.gsx$type.$t]={}),t[e.gsx$type.$t][e.gsx$subtype.$t]=a.path(e.gsx$url.$t)}),this.urls=t,this.portal=new M(this,"portal"),this.cards=new M(this,"cards")}catch(e){console.error("setting up database failed",e)}}},{key:"LoadDB",value:(n=g()(p.a.mark(function e(a){var n=this;return p.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise(function(e,t){null!==n.urls&&null!==n.portal&&null!==n.cards?n.buildCollection(a).then(function(){e()}):e()}));case 1:case"end":return e.stop()}},e)})),function(e){return n.apply(this,arguments)})},{key:"buildCollection",value:(t=g()(p.a.mark(function e(t){var n=this;return p.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Promise.all(t.map(function(a){return new Promise(function(e,t){return"cards"in a?n.cards.setupType(a.cards,e):"portal"in a?n.portal.setupType(a.portal,e):(console.error("cards or portal"),t())})}));case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}},e)})),function(e){return t.apply(this,arguments)})},{key:"purgeDB",value:function(){this.cards.purgeDB(),this.portal.purgeDB(),window.location.reload()}},{key:"tribes",get:function(){return["Danian","Generic","Mipedian","M'arrillian","OverWorld","UnderWorld"]}},{key:"sets",get:function(){return{DOP:"Dawn of Perim",ZOTH:"Zenith of the Hive",SS:"Silent Sands",MI:"Beyond the Doors",ROTO:"Rise of the Oligarch",TOTT:"Turn of the Tide",FUN:"Forged Unity",AU:"Alliance Unraveled",FAS:"Fire and Stone",SAS:"Storm and Sea",EE:"Elemental Emperors",BR:"Beyond Rare",LR:"League Rewards",OP1:"Organized Play 1",PROMO:"Promotional",PROTO:"Prototype"}}}]),a}(),r.base_url="https://spreadsheets.google.com/feeds/list/",r.data_format="/od6/public/values?alt=json",n=u,c=A()(n.prototype,"portal",[N.k],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),o=A()(n.prototype,"cards",[N.k],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),s=A()(n.prototype,"urls",[N.k],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),n);t.a=C.getInstance()}}); \ No newline at end of file diff --git a/src/components/collection/index.js b/src/components/collection/index.js index 34432ef..46b3541 100644 --- a/src/components/collection/index.js +++ b/src/components/collection/index.js @@ -6,26 +6,28 @@ import CardList from './List'; import SearchForm from './search/index.js'; import './collection.scss' - // https://mobx.js.org/refguide/object.html -// TODO const fixedStyles = observable({ - fixed: {}, + style: {}, + get fixed() {return this.style}, + get isFixed() {return (Object.entries(this.style).length !== 0)}, setFixed(height) { - this.fixed = { + if (window.matchMedia("(min-width: 975px)").matches) + this.style = { position: "fixed", top: 0, + left: "31px", overflowY: "auto", - height: `${height}`, - width: "calc(30% - 30px)", + height: `${height}px`, + width: "calc(30% - 20px)", } }, - removeFixed() { - this.fixed = {} - } + removeFixed() {this.style = {}} }, { setFixed: action, removeFixed: action +}, { + deep: false }); @@ -37,7 +39,7 @@ export default class Home extends React.Component { @observable ext = false; @observable content = []; @observable card_img = API.card_back; - fixedStyles = autorun(() => fixedStyles.fixed); + @observable fixedStyles; constructor() { super(); @@ -72,22 +74,34 @@ export default class Home extends React.Component { handleScroll = (event) => { event.preventDefault(); - if (window.pageYOffset >= 220) { - // console.log(this.fixedStyles); - console.log(window.pageYOffset, window.innerHeight) //window.innerHeight- window.pageYOffset - if (window.pageYOffset > window.innerHeight) { - // this.fixedStyles.fixed = - // TODO variable to see if scroll has happend - // Fix with height of viewport - // When nearing the end of the screen (if page offset is higher then height) - // reduce height by difference so that it doesn't leak into footer + // Fix the side menu in place when scrolling down + if (window.pageYOffset >= 235) { + const + h = document.documentElement, + b = document.body, + st = 'scrollTop', + sh = 'scrollHeight', + ch = 'clientHeight'; + const percent = (h[st]||b[st]) / ((h[sh]||b[sh]) - h[ch]) * 100; + const sm = document.getElementById("side-menu"); + + // When nearing the end of the screen + // (if element height offset is higher then height of screen) + // reduce height by difference so that it doesn't leak into footer + if (percent >= 88) { + let exp = h[ch] - (h[ch] * (percent - 85) / 100); + fixedStyles.setFixed(exp); } - else { - // this.fixedStyles = fixedStyles(window.innerHeight + "px"); + // Fix with height of viewport when changed + else if (sm[sh] >= h[ch]){ + fixedStyles.setFixed(window.innerHeight); + } + else if (!fixedStyles.isFixed) { + fixedStyles.setFixed(window.innerHeight); } } - else { - // this.fixedStyles = {}; + else if (fixedStyles.isFixed) { + fixedStyles.removeFixed(); } }; @@ -95,7 +109,7 @@ export default class Home extends React.Component { return (
-
+
{if (n) this.changeImage = n.getInstance().changeImage}} />