collective-webcomponents
Version:
Stencil Component Starter
2 lines • 6.1 kB
JavaScript
/*! Built with http://stenciljs.com */
var __generator=this&&this.__generator||function(e,t){var r,o,n,i,c={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return i={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(i){return function(l){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;c;)try{if(r=1,o&&(n=2&i[0]?o.return:i[0]?o.throw||((n=o.return)&&n.call(o),0):o.next)&&!(n=n.call(o,i[1])).done)return n;switch(o=0,n&&(i=[2&i[0],n.value]),i[0]){case 0:case 1:n=i;break;case 4:return c.label++,{value:i[1],done:!1};case 5:c.label++,o=i[1],i=[0];continue;case 7:i=c.ops.pop(),c.trys.pop();continue;default:if(!(n=(n=c.trys).length>0&&n[n.length-1])&&(6===i[0]||2===i[0])){c=0;continue}if(3===i[0]&&(!n||i[1]>n[0]&&i[1]<n[3])){c.label=i[1];break}if(6===i[0]&&c.label<n[1]){c.label=n[1],n=i;break}if(n&&c.label<n[2]){c.label=n[2],c.ops.push(i);break}n[2]&&c.ops.pop(),c.trys.pop();continue}i=t.call(e,c)}catch(e){i=[6,e],o=0}finally{r=n=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,l])}}};CollectiveWebcomponents.loadBundle("hf5wg0q6",["exports"],function(e){var t=window.CollectiveWebcomponents.h,r=function(){function e(){this.products=[]}return e.prototype.render=function(){var e=this;return t("div",{style:{display:"flex",overflowX:"auto",overflowY:"hidden",WebkitOverflowScrolling:"touch"}},this.products.map(function(r){return t("collective-widget-product-cell",{style:{flexShrink:"0"},showSalePrice:e.showSalePrice,showBrand:e.showBrand,imageSize:e.imageSize,showPrice:e.showPrice,showInfoOnHover:e.showInfoOnHover,productId:r})}))},Object.defineProperty(e,"is",{get:function(){return"collective-products"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"properties",{get:function(){return{columns:{type:Number,attr:"columns"},element:{elementRef:!0},imageSize:{type:Number,attr:"image-size"},pid:{type:String,attr:"pid"},products:{type:"Any",attr:"products"},showBrand:{type:Boolean,attr:"show-brand"},showInfoOnHover:{type:Boolean,attr:"show-info-on-hover"},showPrice:{type:Boolean,attr:"show-price"},showRetailer:{type:Boolean,attr:"show-retailer"},showSalePrice:{type:Boolean,attr:"show-sale-price"}}},enumerable:!0,configurable:!0}),Object.defineProperty(e,"style",{get:function(){return".shopsense-widget .placeholder-box{background:linear-gradient(233deg,#fff,#d7d7d7);background-size:400% 400%;-webkit-animation:2s infinite AnimationName;-moz-animation:2s infinite AnimationName;animation:2s infinite AnimationName}\@-webkit-keyframes AnimationName{0%,100%{background-position:0 53%}50%{background-position:100% 48%}}\@-moz-keyframes AnimationName{0%,100%{background-position:0 53%}50%{background-position:100% 48%}}\@keyframes AnimationName{0%,100%{background-position:0 53%}50%{background-position:100% 48%}}"},enumerable:!0,configurable:!0}),e}(),o=function(e,t,r,o){return new(r||(r=Promise))(function(n,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function l(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){e.done?n(e.value):new r(function(t){t(e.value)}).then(c,l)}a((o=o.apply(e,t||[])).next())})},n=function(){function e(){this.showSalePrice=!0,this.imageSize=200,this.showBrand=!0,this.showInfoOnHover=!1}return e.prototype.productChanged=function(){this.productObject=this.product},e.prototype.fetchProductById=function(){return o(this,void 0,void 0,function(){var e;return __generator(this,function(t){switch(t.label){case 0:return this.productId?[4,fetch("https://api.shopstyle.com/api/v2/products/"+this.productId+"?pid=shopstyle")]:[3,3];case 1:return[4,t.sent().json()];case 2:e=t.sent(),this.productObject=e,t.label=3;case 3:return[2]}})})},e.prototype.componentWillLoad=function(){return o(this,void 0,void 0,function(){return __generator(this,function(e){switch(e.label){case 0:return[4,this.fetchProductById()];case 1:return e.sent(),[2]}})})},e.prototype.render=function(){var e=this.productObject;return t("div",{style:{backgroundColor:"white",width:this.imageSize+"px",height:this.imageSize+100+"px",marginRight:"10px",marginBottom:"10px",display:"flex",flexDirection:"column",alignItems:"stretch",padding:"10px",cursor:"pointer"}},e&&t("div",{style:{display:"flex",flexDirection:"column",alignItems:"stretch",flexGrow:"1"}},t("div",{style:{flexGrow:"1",backgroundImage:"url("+e.image.sizes.XLarge.url+")",backgroundPosition:"center",backgroundSize:"contain",backgroundRepeat:"no-repeat",marginBottom:"10px"}}),!this.showInfoOnHover&&t("div",{class:"info"},t("div",{class:"name",style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",fontSize:"14px"}},this.showBrand&&e.brandedName),this.showPrice&&t("div",{class:"price",style:{display:"flex",marginBottom:"10px",fontWeight:"bold",fontSize:"15px"}},e.salePriceLabel&&t("div",{class:"sale-price",style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",marginRight:"5px"}},e.salePriceLabel),t("div",{class:"full-price",style:Object.assign({whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},e.salePriceLabel?{opacity:"0.5",textDecoration:"line-through"}:{})},e.priceLabel)))))},Object.defineProperty(e,"is",{get:function(){return"collective-widget-product-cell"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"properties",{get:function(){return{imageSize:{type:Number,attr:"image-size"},product:{type:"Any",attr:"product",watchCallbacks:["productChanged"]},productId:{type:"Any",attr:"product-id",watchCallbacks:["fetchProductById"]},productObject:{state:!0},showBrand:{type:Boolean,attr:"show-brand"},showInfoOnHover:{type:Boolean,attr:"show-info-on-hover"},showPrice:{type:Boolean,attr:"show-price"},showSalePrice:{type:Boolean,attr:"show-sale-price"}}},enumerable:!0,configurable:!0}),Object.defineProperty(e,"style",{get:function(){return"collective-widget-product-cell{font-family:Averta,\"Avenir Next\",\"Helvetica Neue\",Helvetica,Arial,sans-serif}"},enumerable:!0,configurable:!0}),e}();e.CollectiveProducts=r,e.CollectiveWidgetProductCell=n,Object.defineProperty(e,"__esModule",{value:!0})});