hemfixarna-web-components 1.7.0 → 1.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/hemfixarna-address_15.cjs.entry.js +1 -1
- package/dist/cjs/hemfixarna-address_15.cjs.entry.js.map +1 -1
- package/dist/collection/components/hemfixarna-component/hemfixarna-component.js +1 -1
- package/dist/collection/components/hemfixarna-component/hemfixarna-component.js.map +1 -1
- package/dist/esm/hemfixarna-address_15.entry.js +1 -1
- package/dist/esm/hemfixarna-address_15.entry.js.map +1 -1
- package/dist/hemfixarna-components/hemfixarna-components.esm.js +1 -1
- package/dist/hemfixarna-components/p-9df46508.entry.js +2 -0
- package/dist/hemfixarna-components/p-9df46508.entry.js.map +1 -0
- package/package.json +3 -2
- package/readme.md +1 -0
- package/dist/hemfixarna-components/p-a9845efc.entry.js +0 -2
- package/dist/hemfixarna-components/p-a9845efc.entry.js.map +0 -1
@@ -128,7 +128,7 @@ export class HemfixarnaComponent {
|
|
128
128
|
const logo = getAssetPath(`./assets/hemfixarna.svg`);
|
129
129
|
const pensel = getAssetPath(`./assets/pensel.svg`);
|
130
130
|
const monteringLogo = getAssetPath(`./assets/montering.svg`);
|
131
|
-
return (h("div", { class:
|
131
|
+
return (h("div", { class: `hemfixarna hemfixarna-${this.business}` }, h("div", { class: `hemfixarna_box hemfixarna_box--${this.widgetStyle}` }, [WidgetStyle.alternative_2, WidgetStyle.alternative_3].includes(this.widgetStyle) ? (h("img", { src: this.id === 'maleri' ? pensel : monteringLogo, alt: "montering logo", width: 32, height: 32 })) : null, h("div", null, h("div", null, h("p", { onClick: () => this.openModal(), class: `pointer ${[WidgetStyle.alternative_2, WidgetStyle.alternative_3].includes(this.widgetStyle) && state.selectedProduct ? 'underline' : ''}` }, this.id === 'maleri' ? (h("span", null, "Ber\u00E4kna fast pris p\u00E5 m\u00E5leri & tapetsering h\u00E4r")) : (h(Fragment, null, !state.selectedCustomerCategory && !this.product && !this.proppedProduct ? (h(Fragment, null, ((_a = state.customer) === null || _a === void 0 ? void 0 : _a.widget_title) ? (h("span", null, state.customer.widget_title)) : (h("span", null, "Montering/Installation - ", h("strong", { class: "underline" }, "se priser h\u00E4r"))))) : (h(Fragment, null, ((_b = this.product) === null || _b === void 0 ? void 0 : _b.title) || ((_c = this.proppedProduct) === null || _c === void 0 ? void 0 : _c.title) || ((_d = state.selectedCustomerCategory) === null || _d === void 0 ? void 0 : _d.widget_title) || (h("span", null, "Montering", h("wbr", null), "/Installation ", (_f = (_e = state.selectedCustomerCategory) === null || _e === void 0 ? void 0 : _e.name) !== null && _f !== void 0 ? _f : 'på plats', " - ", h("strong", { class: "underline" }, "se priser h\u00E4r"))), this.proppedProduct && !((_g = this.product) === null || _g === void 0 ? void 0 : _g.invoice) && !((_h = this.proppedProduct) === null || _h === void 0 ? void 0 : _h.invoice) ? (h("span", null, ' från', " ", h("strong", null, getProductPriceWithRotAndRut(this.proppedProduct || this.product), "kr"))) : null)))))), this.widgetStyle === WidgetStyle.standard ? h("img", { src: logo, width: 104 }) : null, this.widgetStyle === WidgetStyle.alternative ? (h("span", { class: "p-s" }, "Utf\u00F6rs av ", h("strong", null, "Hemfixarna"))) : null), [WidgetStyle.standard, WidgetStyle.alternative].includes(this.widgetStyle) ? (h("button", { onClick: () => this.openModal(), class: "hemfixarna_btn", style: {
|
132
132
|
color: ((_j = this.buttonColor) === null || _j === void 0 ? void 0 : _j.startsWith('#')) || !((_k = this.buttonColor) === null || _k === void 0 ? void 0 : _k.length) ? this.buttonColor : `#${this.buttonColor}`,
|
133
133
|
backgroundColor: ((_l = this.buttonBg) === null || _l === void 0 ? void 0 : _l.startsWith('#')) || !((_m = this.buttonBg) === null || _m === void 0 ? void 0 : _m.length) ? this.buttonBg : `#${this.buttonBg}`,
|
134
134
|
} }, "Best\u00E4ll h\u00E4r", this.getCartLength() > 0 && h("span", null, this.getCartLength()))) : null, WidgetStyle.alternative_2 === this.widgetStyle ? (h("div", { class: "hemfixarna_altbtn" }, h("strong", { class: "p-s" }, "Utf\u00F6rs av"), h("img", { src: logo, alt: "hemfixarna logo", width: 98 }))) : null), this.modal && (h("div", null, h("div", { class: `hemfixarna_modal ${this.showModal ? 'hemfixarna_modal--open' : ''}` }, state.modal && (h("div", { class: "hemfixarna_infomodal" }, state.modal.title && h("h2", null, state.modal.title), state.modal.text.map((t) => (h("p", { innerHTML: t }))), h("div", null, h("button", { onClick: () => (state.modal = null) }, "St\u00E4ng")))), state.customer && h("hemfixarna-breadcrumbs", { closeModal: () => this.closeModal() }), h("div", { class: `hemfixarna_content hemfixarna_content--${state.step} ${state.step === 4 && state.maleri ? 'hemfixarna_content--painting' : ''}` }, state.step < 4 && h("hemfixarna-start", null), state.step === 4 && h("hemfixarna-product", null), state.step === 5 && h("hemfixarna-cart", null), state.step === 6 && h("hemfixarna-order", null))), h("div", { class: `hemfixarna_backdrop ${this.showModal ? 'hemfixarna_backdrop--open' : ''}` })))));
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"hemfixarna-component.js","sourceRoot":"","sources":["../../../src/components/hemfixarna-component/hemfixarna-component.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAC1G,OAAO,KAAK,MAAM,aAAa,CAAC;AAChC,OAAO,EAAqB,WAAW,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAC5F,OAAO,EAAE,4BAA4B,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAQjD,MAAM,OAAO,mBAAmB;;IA0F9B,uBAAkB,GAAG,GAAG,EAAE;MACxB,MAAM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IAAI,8BAAwB,UAAU,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,UAAU,EAAE,GAAI;UAClF,WAAK,KAAK,EAAE,0CAA0C,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,8BAA8B,CAAC,CAAC,CAAC,EAAE,EAAE;YACzI,KAAK,CAAC,IAAI,GAAG,CAAC,IAAI,2BAAoB;YAEtC,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,6BAAsB;YAE1C,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,0BAAmB;YAEvC,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,2BAAoB,CACrC,CACF;QACN,WAAK,KAAK,EAAE,uBAAuB,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,2BAA2B,CAAC,CAAC,CAAC,EAAE,EAAE,GAAQ,CAC1F,CACP,CACG,CACP,CAAC;EACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Element, Fragment, Listen, Prop, State, Watch, getAssetPath, h } from '@stencil/core';\nimport state from '../../store';\nimport { Business, Product, WidgetStyle } from '../../types';\nimport { getCustomer, getGreenDiscount, getOptions, getRot, getRut } from '../../utils/api';\nimport { getProductPriceWithRotAndRut } from '../../utils/calc';\nimport { scrollToTop } from '../../utils/scroll';\n\n@Component({\n tag: 'hemfixarna-component',\n styleUrl: 'hemfixarna.scss',\n shadow: true,\n assetsDirs: ['assets'],\n})\nexport class HemfixarnaComponent {\n @State() modal: boolean = false;\n @State() showModal: boolean = false;\n @State() product: Product | null = null;\n @Prop() id?: string;\n @Prop() business: Business;\n @Prop() widgetStyle: WidgetStyle = WidgetStyle.standard;\n @Prop() buttonColor?: string;\n @Prop() buttonBg?: string;\n @State() proppedProduct: Product | null = null;\n\n @Element() private el: HTMLElement;\n\n loadCategoryOrProduct(id: string) {\n this.proppedProduct = null;\n if (id.startsWith('c-')) {\n const categories = [...state.customer.categories, ...state.customer.categories.map(c => c.sub_categories ?? [])].flat();\n const category = categories.find(c => c && c.id === id.replace('c-', ''));\n if (category) {\n state.selectedCustomerCategory = category;\n state.step = 2;\n }\n } else {\n const products = state.customer.categories\n .map(c => (c.show_products ? c.products : c.sub_categories ? c.sub_categories.map(c => c.products) : []))\n .flat()\n .flat();\n const product = products.find(p => p && p.fields.ID === parseInt(id));\n if (product) {\n state.selectedProduct = product.fields;\n state.step = 4;\n this.proppedProduct = product.fields;\n }\n }\n }\n\n @Watch('id')\n async watchIdChange(id: string) {\n if (id && state.customer) {\n if (id === 'maleri') {\n state.maleri = true;\n state.step = 4;\n } else {\n this.loadCategoryOrProduct(id);\n }\n }\n }\n\n async componentWillLoad() {\n state.business = this.business;\n const cart = window.sessionStorage.getItem(`hemfixarna-${this.business}-cart`);\n if (cart) {\n state.cart = JSON.parse(cart);\n }\n const user = window.sessionStorage.getItem(`hemfixarna-${this.business}-user`);\n if (user) {\n state.user = JSON.parse(user);\n }\n const creditSafeUser = window.sessionStorage.getItem(`hemfixarna-${this.business}-creditSafeUser`);\n if (creditSafeUser) {\n state.creditSafeUser = JSON.parse(creditSafeUser);\n }\n\n const [options, rut, rot, greenDiscount] = await Promise.all([getOptions(), getRut(), getRot(), getGreenDiscount()]);\n\n try {\n const customer = await getCustomer(this.business);\n if (customer?.code === 'not_found') {\n console.warn('customer not found');\n } else if (customer) {\n state.customer = customer;\n if (this.id) {\n if (this.id === 'maleri') {\n state.maleri = true;\n state.step = 4;\n } else {\n this.loadCategoryOrProduct(this.id);\n }\n }\n }\n } catch (error) {\n console.warn('customer not found');\n }\n\n state.rotOptions = rot;\n state.rutOptions = rut;\n state.greenOptions = greenDiscount;\n state.options = options;\n }\n\n triggerScrollTotop = () => {\n const el = this.el.shadowRoot.querySelector('.hemfixarna_content');\n scrollToTop(el);\n };\n\n // Open close modal && click outside event\n openModal() {\n this.modal = true;\n setTimeout(() => {\n this.showModal = true;\n }, 50);\n }\n closeModal() {\n this.showModal = false;\n setTimeout(() => {\n this.modal = false;\n }, 200);\n }\n @Listen('click')\n handleClick(e: Event) {\n if ((e?.composedPath()[0] as HTMLElement).classList.contains('hemfixarna_backdrop')) {\n this.closeModal();\n }\n const infomodal = this.el.shadowRoot.querySelector('.hemfixarna_infomodal');\n if (infomodal) {\n const isClickInside = infomodal.contains(e.composedPath()[0] as HTMLInputElement);\n if (!isClickInside) {\n state.modal = null;\n }\n }\n }\n\n getCartLength() {\n return state.cart.reduce((acc, curr) => acc + curr.amount, 0);\n }\n\n render() {\n const logo = getAssetPath(`./assets/hemfixarna.svg`);\n const pensel = getAssetPath(`./assets/pensel.svg`);\n const monteringLogo = getAssetPath(`./assets/montering.svg`);\n\n return (\n <div class=\"hemfixarna\">\n <div class={`hemfixarna_box hemfixarna_box--${this.widgetStyle}`}>\n {[WidgetStyle.alternative_2, WidgetStyle.alternative_3].includes(this.widgetStyle) ? (\n <img src={this.id === 'maleri' ? pensel : monteringLogo} alt=\"montering logo\" width={32} height={32} />\n ) : null}\n <div>\n <div>\n <p\n onClick={() => this.openModal()}\n class={`pointer ${[WidgetStyle.alternative_2, WidgetStyle.alternative_3].includes(this.widgetStyle) && state.selectedProduct ? 'underline' : ''}`}\n >\n {this.id === 'maleri' ? (\n <span>Beräkna fast pris på måleri & tapetsering här</span>\n ) : (\n <Fragment>\n {!state.selectedCustomerCategory && !this.product && !this.proppedProduct ? (\n <Fragment>\n {state.customer?.widget_title ? (\n <span>{state.customer.widget_title}</span>\n ) : (\n <span>\n Montering/Installation - <strong class=\"underline\">se priser här</strong>\n </span>\n )}\n </Fragment>\n ) : (\n <Fragment>\n {this.product?.title || this.proppedProduct?.title || state.selectedCustomerCategory?.widget_title || (\n <span>\n Montering\n <wbr />\n /Installation {state.selectedCustomerCategory?.name ?? 'på plats'} - <strong class=\"underline\">se priser här</strong>\n </span>\n )}\n {this.proppedProduct && !this.product?.invoice && !this.proppedProduct?.invoice ? (\n <span>\n {' från'} <strong>{getProductPriceWithRotAndRut(this.proppedProduct || this.product)}kr</strong>\n </span>\n ) : null}\n </Fragment>\n )}\n </Fragment>\n )}\n </p>\n </div>\n {this.widgetStyle === WidgetStyle.standard ? <img src={logo} width={104} /> : null}\n {this.widgetStyle === WidgetStyle.alternative ? (\n <span class=\"p-s\">\n Utförs av <strong>Hemfixarna</strong>\n </span>\n ) : null}\n </div>\n {[WidgetStyle.standard, WidgetStyle.alternative].includes(this.widgetStyle) ? (\n <button\n onClick={() => this.openModal()}\n class=\"hemfixarna_btn\"\n style={{\n color: this.buttonColor?.startsWith('#') || !this.buttonColor?.length ? this.buttonColor : `#${this.buttonColor}`,\n backgroundColor: this.buttonBg?.startsWith('#') || !this.buttonBg?.length ? this.buttonBg : `#${this.buttonBg}`,\n }}\n >\n Beställ här\n {this.getCartLength() > 0 && <span>{this.getCartLength()}</span>}\n </button>\n ) : null}\n {WidgetStyle.alternative_2 === this.widgetStyle ? (\n <div class=\"hemfixarna_altbtn\">\n <strong class=\"p-s\">Utförs av</strong>\n <img src={logo} alt=\"hemfixarna logo\" width={98} />\n </div>\n ) : null}\n </div>\n {this.modal && (\n <div>\n <div class={`hemfixarna_modal ${this.showModal ? 'hemfixarna_modal--open' : ''}`}>\n {state.modal && (\n <div class=\"hemfixarna_infomodal\">\n {state.modal.title && <h2>{state.modal.title}</h2>}\n {state.modal.text.map((t: string) => (\n <p innerHTML={t}></p>\n ))}\n <div>\n <button onClick={() => (state.modal = null)}>Stäng</button>\n </div>\n </div>\n )}\n {state.customer && <hemfixarna-breadcrumbs closeModal={() => this.closeModal()} />}\n <div class={`hemfixarna_content hemfixarna_content--${state.step} ${state.step === 4 && state.maleri ? 'hemfixarna_content--painting' : ''}`}>\n {state.step < 4 && <hemfixarna-start />}\n {/* // IF SELECTED PRODUCT (step 4) */}\n {state.step === 4 && <hemfixarna-product />}\n {/* // IF CHECKOUT (step 5) */}\n {state.step === 5 && <hemfixarna-cart />}\n {/* // IF ORDER CONFIRM (step 6) */}\n {state.step === 6 && <hemfixarna-order />}\n </div>\n </div>\n <div class={`hemfixarna_backdrop ${this.showModal ? 'hemfixarna_backdrop--open' : ''}`}></div>\n </div>\n )}\n </div>\n );\n }\n}\n"]}
|
1
|
+
{"version":3,"file":"hemfixarna-component.js","sourceRoot":"","sources":["../../../src/components/hemfixarna-component/hemfixarna-component.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAC1G,OAAO,KAAK,MAAM,aAAa,CAAC;AAChC,OAAO,EAAqB,WAAW,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAC5F,OAAO,EAAE,4BAA4B,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAQjD,MAAM,OAAO,mBAAmB;;IA0F9B,uBAAkB,GAAG,GAAG,EAAE;MACxB,MAAM,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,qBAAqB,CAAC,CAAC;MACnE,WAAW,CAAC,EAAE,CAAC,CAAC;IAClB,CAAC,CAAC;iBA5FwB,KAAK;qBACD,KAAK;mBACA,IAAI;;;uBAGJ,WAAW,CAAC,QAAQ;;;0BAGb,IAAI;;EAI9C,qBAAqB,CAAC,EAAU;IAC9B,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;IAC3B,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;MACvB,MAAM,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I,6BAAsB;YAE1C,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,0BAAmB;YAEvC,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,2BAAoB,CACrC,CACF;QACN,WAAK,KAAK,EAAE,uBAAuB,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,2BAA2B,CAAC,CAAC,CAAC,EAAE,EAAE,GAAQ,CAC1F,CACP,CACG,CACP,CAAC;EACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Element, Fragment, Listen, Prop, State, Watch, getAssetPath, h } from '@stencil/core';\nimport state from '../../store';\nimport { Business, Product, WidgetStyle } from '../../types';\nimport { getCustomer, getGreenDiscount, getOptions, getRot, getRut } from '../../utils/api';\nimport { getProductPriceWithRotAndRut } from '../../utils/calc';\nimport { scrollToTop } from '../../utils/scroll';\n\n@Component({\n tag: 'hemfixarna-component',\n styleUrl: 'hemfixarna.scss',\n shadow: true,\n assetsDirs: ['assets'],\n})\nexport class HemfixarnaComponent {\n @State() modal: boolean = false;\n @State() showModal: boolean = false;\n @State() product: Product | null = null;\n @Prop() id?: string;\n @Prop() business: Business;\n @Prop() widgetStyle: WidgetStyle = WidgetStyle.standard;\n @Prop() buttonColor?: string;\n @Prop() buttonBg?: string;\n @State() proppedProduct: Product | null = null;\n\n @Element() private el: HTMLElement;\n\n loadCategoryOrProduct(id: string) {\n this.proppedProduct = null;\n if (id.startsWith('c-')) {\n const categories = [...state.customer.categories, ...state.customer.categories.map(c => c.sub_categories ?? [])].flat();\n const category = categories.find(c => c && c.id === id.replace('c-', ''));\n if (category) {\n state.selectedCustomerCategory = category;\n state.step = 2;\n }\n } else {\n const products = state.customer.categories\n .map(c => (c.show_products ? c.products : c.sub_categories ? c.sub_categories.map(c => c.products) : []))\n .flat()\n .flat();\n const product = products.find(p => p && p.fields.ID === parseInt(id));\n if (product) {\n state.selectedProduct = product.fields;\n state.step = 4;\n this.proppedProduct = product.fields;\n }\n }\n }\n\n @Watch('id')\n async watchIdChange(id: string) {\n if (id && state.customer) {\n if (id === 'maleri') {\n state.maleri = true;\n state.step = 4;\n } else {\n this.loadCategoryOrProduct(id);\n }\n }\n }\n\n async componentWillLoad() {\n state.business = this.business;\n const cart = window.sessionStorage.getItem(`hemfixarna-${this.business}-cart`);\n if (cart) {\n state.cart = JSON.parse(cart);\n }\n const user = window.sessionStorage.getItem(`hemfixarna-${this.business}-user`);\n if (user) {\n state.user = JSON.parse(user);\n }\n const creditSafeUser = window.sessionStorage.getItem(`hemfixarna-${this.business}-creditSafeUser`);\n if (creditSafeUser) {\n state.creditSafeUser = JSON.parse(creditSafeUser);\n }\n\n const [options, rut, rot, greenDiscount] = await Promise.all([getOptions(), getRut(), getRot(), getGreenDiscount()]);\n\n try {\n const customer = await getCustomer(this.business);\n if (customer?.code === 'not_found') {\n console.warn('customer not found');\n } else if (customer) {\n state.customer = customer;\n if (this.id) {\n if (this.id === 'maleri') {\n state.maleri = true;\n state.step = 4;\n } else {\n this.loadCategoryOrProduct(this.id);\n }\n }\n }\n } catch (error) {\n console.warn('customer not found');\n }\n\n state.rotOptions = rot;\n state.rutOptions = rut;\n state.greenOptions = greenDiscount;\n state.options = options;\n }\n\n triggerScrollTotop = () => {\n const el = this.el.shadowRoot.querySelector('.hemfixarna_content');\n scrollToTop(el);\n };\n\n // Open close modal && click outside event\n openModal() {\n this.modal = true;\n setTimeout(() => {\n this.showModal = true;\n }, 50);\n }\n closeModal() {\n this.showModal = false;\n setTimeout(() => {\n this.modal = false;\n }, 200);\n }\n @Listen('click')\n handleClick(e: Event) {\n if ((e?.composedPath()[0] as HTMLElement).classList.contains('hemfixarna_backdrop')) {\n this.closeModal();\n }\n const infomodal = this.el.shadowRoot.querySelector('.hemfixarna_infomodal');\n if (infomodal) {\n const isClickInside = infomodal.contains(e.composedPath()[0] as HTMLInputElement);\n if (!isClickInside) {\n state.modal = null;\n }\n }\n }\n\n getCartLength() {\n return state.cart.reduce((acc, curr) => acc + curr.amount, 0);\n }\n\n render() {\n const logo = getAssetPath(`./assets/hemfixarna.svg`);\n const pensel = getAssetPath(`./assets/pensel.svg`);\n const monteringLogo = getAssetPath(`./assets/montering.svg`);\n\n return (\n <div class={`hemfixarna hemfixarna-${this.business}`}>\n <div class={`hemfixarna_box hemfixarna_box--${this.widgetStyle}`}>\n {[WidgetStyle.alternative_2, WidgetStyle.alternative_3].includes(this.widgetStyle) ? (\n <img src={this.id === 'maleri' ? pensel : monteringLogo} alt=\"montering logo\" width={32} height={32} />\n ) : null}\n <div>\n <div>\n <p\n onClick={() => this.openModal()}\n class={`pointer ${[WidgetStyle.alternative_2, WidgetStyle.alternative_3].includes(this.widgetStyle) && state.selectedProduct ? 'underline' : ''}`}\n >\n {this.id === 'maleri' ? (\n <span>Beräkna fast pris på måleri & tapetsering här</span>\n ) : (\n <Fragment>\n {!state.selectedCustomerCategory && !this.product && !this.proppedProduct ? (\n <Fragment>\n {state.customer?.widget_title ? (\n <span>{state.customer.widget_title}</span>\n ) : (\n <span>\n Montering/Installation - <strong class=\"underline\">se priser här</strong>\n </span>\n )}\n </Fragment>\n ) : (\n <Fragment>\n {this.product?.title || this.proppedProduct?.title || state.selectedCustomerCategory?.widget_title || (\n <span>\n Montering\n <wbr />\n /Installation {state.selectedCustomerCategory?.name ?? 'på plats'} - <strong class=\"underline\">se priser här</strong>\n </span>\n )}\n {this.proppedProduct && !this.product?.invoice && !this.proppedProduct?.invoice ? (\n <span>\n {' från'} <strong>{getProductPriceWithRotAndRut(this.proppedProduct || this.product)}kr</strong>\n </span>\n ) : null}\n </Fragment>\n )}\n </Fragment>\n )}\n </p>\n </div>\n {this.widgetStyle === WidgetStyle.standard ? <img src={logo} width={104} /> : null}\n {this.widgetStyle === WidgetStyle.alternative ? (\n <span class=\"p-s\">\n Utförs av <strong>Hemfixarna</strong>\n </span>\n ) : null}\n </div>\n {[WidgetStyle.standard, WidgetStyle.alternative].includes(this.widgetStyle) ? (\n <button\n onClick={() => this.openModal()}\n class=\"hemfixarna_btn\"\n style={{\n color: this.buttonColor?.startsWith('#') || !this.buttonColor?.length ? this.buttonColor : `#${this.buttonColor}`,\n backgroundColor: this.buttonBg?.startsWith('#') || !this.buttonBg?.length ? this.buttonBg : `#${this.buttonBg}`,\n }}\n >\n Beställ här\n {this.getCartLength() > 0 && <span>{this.getCartLength()}</span>}\n </button>\n ) : null}\n {WidgetStyle.alternative_2 === this.widgetStyle ? (\n <div class=\"hemfixarna_altbtn\">\n <strong class=\"p-s\">Utförs av</strong>\n <img src={logo} alt=\"hemfixarna logo\" width={98} />\n </div>\n ) : null}\n </div>\n {this.modal && (\n <div>\n <div class={`hemfixarna_modal ${this.showModal ? 'hemfixarna_modal--open' : ''}`}>\n {state.modal && (\n <div class=\"hemfixarna_infomodal\">\n {state.modal.title && <h2>{state.modal.title}</h2>}\n {state.modal.text.map((t: string) => (\n <p innerHTML={t}></p>\n ))}\n <div>\n <button onClick={() => (state.modal = null)}>Stäng</button>\n </div>\n </div>\n )}\n {state.customer && <hemfixarna-breadcrumbs closeModal={() => this.closeModal()} />}\n <div class={`hemfixarna_content hemfixarna_content--${state.step} ${state.step === 4 && state.maleri ? 'hemfixarna_content--painting' : ''}`}>\n {state.step < 4 && <hemfixarna-start />}\n {/* // IF SELECTED PRODUCT (step 4) */}\n {state.step === 4 && <hemfixarna-product />}\n {/* // IF CHECKOUT (step 5) */}\n {state.step === 5 && <hemfixarna-cart />}\n {/* // IF ORDER CONFIRM (step 6) */}\n {state.step === 6 && <hemfixarna-order />}\n </div>\n </div>\n <div class={`hemfixarna_backdrop ${this.showModal ? 'hemfixarna_backdrop--open' : ''}`}></div>\n </div>\n )}\n </div>\n );\n }\n}\n"]}
|
@@ -725,7 +725,7 @@ const HemfixarnaComponent = class {
|
|
725
725
|
const logo = getAssetPath(`./assets/hemfixarna.svg`);
|
726
726
|
const pensel = getAssetPath(`./assets/pensel.svg`);
|
727
727
|
const monteringLogo = getAssetPath(`./assets/montering.svg`);
|
728
|
-
return (h("div", { class:
|
728
|
+
return (h("div", { class: `hemfixarna hemfixarna-${this.business}` }, h("div", { class: `hemfixarna_box hemfixarna_box--${this.widgetStyle}` }, [WidgetStyle.alternative_2, WidgetStyle.alternative_3].includes(this.widgetStyle) ? (h("img", { src: this.id === 'maleri' ? pensel : monteringLogo, alt: "montering logo", width: 32, height: 32 })) : null, h("div", null, h("div", null, h("p", { onClick: () => this.openModal(), class: `pointer ${[WidgetStyle.alternative_2, WidgetStyle.alternative_3].includes(this.widgetStyle) && state.selectedProduct ? 'underline' : ''}` }, this.id === 'maleri' ? (h("span", null, "Ber\u00E4kna fast pris p\u00E5 m\u00E5leri & tapetsering h\u00E4r")) : (h(Fragment, null, !state.selectedCustomerCategory && !this.product && !this.proppedProduct ? (h(Fragment, null, ((_a = state.customer) === null || _a === void 0 ? void 0 : _a.widget_title) ? (h("span", null, state.customer.widget_title)) : (h("span", null, "Montering/Installation - ", h("strong", { class: "underline" }, "se priser h\u00E4r"))))) : (h(Fragment, null, ((_b = this.product) === null || _b === void 0 ? void 0 : _b.title) || ((_c = this.proppedProduct) === null || _c === void 0 ? void 0 : _c.title) || ((_d = state.selectedCustomerCategory) === null || _d === void 0 ? void 0 : _d.widget_title) || (h("span", null, "Montering", h("wbr", null), "/Installation ", (_f = (_e = state.selectedCustomerCategory) === null || _e === void 0 ? void 0 : _e.name) !== null && _f !== void 0 ? _f : 'på plats', " - ", h("strong", { class: "underline" }, "se priser h\u00E4r"))), this.proppedProduct && !((_g = this.product) === null || _g === void 0 ? void 0 : _g.invoice) && !((_h = this.proppedProduct) === null || _h === void 0 ? void 0 : _h.invoice) ? (h("span", null, ' från', " ", h("strong", null, getProductPriceWithRotAndRut(this.proppedProduct || this.product), "kr"))) : null)))))), this.widgetStyle === WidgetStyle.standard ? h("img", { src: logo, width: 104 }) : null, this.widgetStyle === WidgetStyle.alternative ? (h("span", { class: "p-s" }, "Utf\u00F6rs av ", h("strong", null, "Hemfixarna"))) : null), [WidgetStyle.standard, WidgetStyle.alternative].includes(this.widgetStyle) ? (h("button", { onClick: () => this.openModal(), class: "hemfixarna_btn", style: {
|
729
729
|
color: ((_j = this.buttonColor) === null || _j === void 0 ? void 0 : _j.startsWith('#')) || !((_k = this.buttonColor) === null || _k === void 0 ? void 0 : _k.length) ? this.buttonColor : `#${this.buttonColor}`,
|
730
730
|
backgroundColor: ((_l = this.buttonBg) === null || _l === void 0 ? void 0 : _l.startsWith('#')) || !((_m = this.buttonBg) === null || _m === void 0 ? void 0 : _m.length) ? this.buttonBg : `#${this.buttonBg}`,
|
731
731
|
} }, "Best\u00E4ll h\u00E4r", this.getCartLength() > 0 && h("span", null, this.getCartLength()))) : null, WidgetStyle.alternative_2 === this.widgetStyle ? (h("div", { class: "hemfixarna_altbtn" }, h("strong", { class: "p-s" }, "Utf\u00F6rs av"), h("img", { src: logo, alt: "hemfixarna logo", width: 98 }))) : null), this.modal && (h("div", null, h("div", { class: `hemfixarna_modal ${this.showModal ? 'hemfixarna_modal--open' : ''}` }, state.modal && (h("div", { class: "hemfixarna_infomodal" }, state.modal.title && h("h2", null, state.modal.title), state.modal.text.map((t) => (h("p", { innerHTML: t }))), h("div", null, h("button", { onClick: () => (state.modal = null) }, "St\u00E4ng")))), state.customer && h("hemfixarna-breadcrumbs", { closeModal: () => this.closeModal() }), h("div", { class: `hemfixarna_content hemfixarna_content--${state.step} ${state.step === 4 && state.maleri ? 'hemfixarna_content--painting' : ''}` }, state.step < 4 && h("hemfixarna-start", null), state.step === 4 && h("hemfixarna-product", null), state.step === 5 && h("hemfixarna-cart", null), state.step === 6 && h("hemfixarna-order", null))), h("div", { class: `hemfixarna_backdrop ${this.showModal ? 'hemfixarna_backdrop--open' : ''}` })))));
|