@salla.sa/twilight-components
Version:
Salla Web Component
5 lines • 4.18 kB
JavaScript
/*!
* Crafted with ❤ by Salla
*/
import{r as registerInstance,h}from"./index-DWStDVKB.js";import{a as arrowLeft}from"./arrow-left-BedNk7k1.js";import{H as Helper}from"./Helper-CzEjEM5j.js";import"./anime.es-CgtvEd63.js";var IconQuoteOpen='\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>quote-open</title>\n<path d="M8 12v-5.333c0-0.737-0.596-1.333-1.333-1.333-3.676 0-6.667 2.991-6.667 6.667v8c0 3.676 2.991 6.667 6.667 6.667h1.333c3.676 0 6.667-2.991 6.667-6.667v-1.333c0-3.676-2.991-6.667-6.667-6.667zM12 20c0 2.205-1.795 4-4 4h-1.333c-2.205 0-4-1.795-4-4v-8c0-1.739 1.115-3.221 2.667-3.772v5.105c0 0.737 0.596 1.333 1.333 1.333h1.333c2.205 0 4 1.795 4 4zM25.333 12v-5.333c0-0.737-0.596-1.333-1.333-1.333-3.676 0-6.667 2.991-6.667 6.667v8c0 3.676 2.991 6.667 6.667 6.667h1.333c3.676 0 6.667-2.991 6.667-6.667v-1.333c0-3.676-2.991-6.667-6.667-6.667zM29.333 20c0 2.205-1.795 4-4 4h-1.333c-2.205 0-4-1.795-4-4v-8c0-1.739 1.115-3.221 2.667-3.772v5.105c0 0.737 0.596 1.333 1.333 1.333h1.333c2.205 0 4 1.795 4 4z"></path>\n</svg>\n';var sallaReviewsCss="";var SallaReviews=function(){function s(s){var e=this;registerInstance(this,s);this.limit=5;this.type="store";this.sort="latest";this.hideCustomerInfo=false;this.reviews=[];this.showReviews=false;this.testimonialText=salla.lang.get("blocks.home.testimonials");this.displayAllLinkText=salla.lang.get("blocks.home.display_all");this.displayAllURL=null;this.source=this.source;salla.onReady((function(){e.displayAllURL=salla.url.get("testimonials");e.isRTL=salla.config.get("theme.is_rtl",true)}));salla.lang.onLoaded((function(){e.testimonialText=salla.lang.get("blocks.home.testimonials");e.displayAllLinkText=salla.lang.get("blocks.home.display_all")}))}s.prototype.fetchReviews=function(){if(this.source==="json"){return Promise.resolve(JSON.parse(this.sourceValue))}var s=["products","categories"].includes(this.source);var e={limit:this.limit,source:this.source,items:s?JSON.parse(this.sourceValue):this.sourceValue,sort:this.sort,type:this.type,hide_customer_info:this.hideCustomerInfo?1:0};return salla.api.request("reviews",{params:e},"get")};s.prototype.componentWillLoad=function(){var s=this;return new Promise((function(s){return salla.onReady(s)})).then((function(){return s.fetchReviews()})).then((function(s){return s.data||[]})).then((function(e){if(e.length){s.reviews=e;s.showReviews=true;Helper.generateReviewSchema(s.reviews)}}))};s.prototype.render=function(){return h("div",{key:"5d4370acb6b9e75e443abf7a477e5c4e928db40f",class:"s-reviews-container"},h("div",{key:"ee332858f498fbde2dcbc0afb60a172e988bf649",class:"s-reviews-header-wrapper"},h("h1",{key:"a8a89784646cdd3ab1aae6094ecd8968b85aa638",class:"s-reviews-header"},this.testimonialText),!!this.displayAllLink?h("a",{href:this.displayAllURL,class:"s-reviews-display-all"},this.displayAllLinkText,h("span",{class:"s-reviews-display-all-icon",innerHTML:arrowLeft})):null),h("salla-slider",{key:"26092cc63d5ce3d29feda2b91edf8b58ac50a251",centered:true,"slides-per-view":1,type:"testimonials",class:"s-reviews-testimonials-slider","controls-outer":true,"auto-play":true,id:"testimonials-".concat(this.source,"-slider")},h("div",{key:"6b68348a443afe0c9649fa29252bd0ea642bb355",slot:"items"},this.reviews.map((function(s,e){return h("div",{key:e,class:"s-reviews-swiper-slide"},h("div",{class:"s-reviews-testimonial"},h("div",{class:"s-reviews-testimonial__inner"},h("div",{class:"s-reviews-testimonial__avatar"},h("img",{src:"images/s-empty.png","data-src":s.avatar,alt:s.name?s.name:"testimonial-"+e,class:"lazy"})),h("div",{class:"s-reviews-testimonial__text"},h("p",{innerHTML:s.content}),h("div",{class:"s-reviews-testimonial__name_wrapper"},h("div",{class:"s-reviews-testimonial__info"},s.name&&h("h2",null,"".concat(s.name))),h("div",{class:"s-reviews-testimonial__rating"},h("salla-rating-stars",{size:"small",value:s.stars})))),h("span",{class:"s-reviews-testimonial__icon",innerHTML:IconQuoteOpen}))))})))))};return s}();SallaReviews.style=sallaReviewsCss;export{SallaReviews as salla_reviews};
//# sourceMappingURL=salla-reviews.entry.js.map