FileMaster
Search
Toggle Dark Mode
Home
/
.
/
wp-content
/
plugins
/
surecart
/
dist
/
components
/
collection
/
components
/
ui
/
sc-cart-icon
Edit File: sc-cart-icon.js
import{h}from"@stencil/core";import{state as checkoutState}from"../../../store/checkout/index";import uiStore from"../../../store/ui";import{__,sprintf}from"@wordpress/i18n";export class ScCartIcon{constructor(){this.icon="shopping-bag"}getItemsCount(){var t,e;const o=null===(e=null===(t=null==checkoutState?void 0:checkoutState.checkout)||void 0===t?void 0:t.line_items)||void 0===e?void 0:e.data;let r=0;return(o||[]).forEach((t=>{r+=null==t?void 0:t.quantity})),r}toggleCart(){return uiStore.set("cart",{...uiStore.state.cart,open:!uiStore.state.cart.open})}render(){var t,e,o;return(null==checkoutState?void 0:checkoutState.checkout)&&0!==(null===(o=null===(e=null===(t=null==checkoutState?void 0:checkoutState.checkout)||void 0===t?void 0:t.line_items)||void 0===e?void 0:e.data)||void 0===o?void 0:o.length)?h("div",{class:{cart:!0},part:"base",onClick:()=>this.toggleCart(),onKeyDown:t=>{"Enter"!==(null==t?void 0:t.code)&&"Space"!==(null==t?void 0:t.code)||(this.toggleCart(),t.preventDefault())},tabIndex:0,role:"button","aria-label":uiStore.state.cart.open?__("Close Cart Floating Icon","surecart"):sprintf(__("Open Cart Floating Icon with %d items","surecart"),this.getItemsCount())},h("div",{class:"cart__container",part:"container"},h("div",{class:{cart__counter:!0}},this.getItemsCount()),h("slot",null,h("sc-icon",{exportparts:"base:icon__base",name:this.icon})))):null}static get is(){return"sc-cart-icon"}static get encapsulation(){return"shadow"}static get originalStyleUrls(){return{$:["sc-cart-icon.scss"]}}static get styleUrls(){return{$:["sc-cart-icon.css"]}}static get properties(){return{icon:{type:"string",mutable:!1,complexType:{original:"string",resolved:"string",references:{}},required:!1,optional:!1,docs:{tags:[],text:"The icon to show."},attribute:"icon",reflect:!1,defaultValue:"'shopping-bag'"}}}}
Save
Back