@ppg_pl/tinting 0.0.7 → 0.0.8
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/modal-header_9.cjs.entry.js +47 -22
- package/dist/cjs/modal-header_9.cjs.entry.js.map +1 -1
- package/dist/collection/components/colorbox/index.js +18 -1
- package/dist/collection/components/colorbox/index.js.map +1 -1
- package/dist/collection/components/colorinfo/index.js +2 -9
- package/dist/collection/components/colorinfo/index.js.map +1 -1
- package/dist/collection/utils/index.js +17 -0
- package/dist/collection/utils/index.js.map +1 -1
- package/dist/components/index10.js +4934 -3605
- package/dist/components/index10.js.map +1 -1
- package/dist/components/index11.js +3989 -0
- package/dist/components/index11.js.map +1 -0
- package/dist/components/index4.js +2 -13
- package/dist/components/index4.js.map +1 -1
- package/dist/components/index6.js +28 -27
- package/dist/components/index6.js.map +1 -1
- package/dist/components/index7.js +9 -53
- package/dist/components/index7.js.map +1 -1
- package/dist/components/index8.js +56 -129
- package/dist/components/index8.js.map +1 -1
- package/dist/components/index9.js +124 -5283
- package/dist/components/index9.js.map +1 -1
- package/dist/components/my-backdrop.js +1 -1
- package/dist/components/my-colorbox.js +1 -1
- package/dist/components/my-colorinfo.js +1 -1
- package/dist/components/my-component.js +5 -5
- package/dist/components/my-modal.js +1 -1
- package/dist/components/my-slider.js +1 -1
- package/dist/esm/modal-header_9.entry.js +47 -22
- package/dist/esm/modal-header_9.entry.js.map +1 -1
- package/dist/tinting/{p-4ec5261b.entry.js → p-2730a042.entry.js} +3 -3
- package/dist/tinting/p-2730a042.entry.js.map +1 -0
- package/dist/tinting/tinting.esm.js +1 -1
- package/dist/types/components/colorbox/index.d.ts +3 -0
- package/dist/types/utils/index.d.ts +6 -0
- package/package.json +1 -1
- package/www/build/{p-4ec5261b.entry.js → p-2730a042.entry.js} +3 -3
- package/www/build/p-2730a042.entry.js.map +1 -0
- package/www/build/tinting.esm.js +1 -1
- package/dist/tinting/p-4ec5261b.entry.js.map +0 -1
- package/www/build/p-4ec5261b.entry.js.map +0 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { h } from '@stencil/core';
|
|
2
2
|
import { setDataLayer } from '../../gtmUtils';
|
|
3
|
+
import { isVeryLightColor } from '../../utils';
|
|
3
4
|
import { APIURL, accessToken } from '../api';
|
|
4
5
|
export class MyColorBox {
|
|
5
6
|
constructor() {
|
|
@@ -24,6 +25,21 @@ export class MyColorBox {
|
|
|
24
25
|
const blue = parseInt(color[5] + color[6], 16) - 20;
|
|
25
26
|
return `rgb(${red},${green},${blue})`;
|
|
26
27
|
};
|
|
28
|
+
this.isLightSwatch = () => { var _a; return !((_a = this.isImageInsteadHex) === null || _a === void 0 ? void 0 : _a.isImageInsteadHex) && isVeryLightColor(this.color); };
|
|
29
|
+
// Active category keeps its 5px solid border (all active swatches share it, so
|
|
30
|
+
// alignment is consistent). In the normal grid we use an inset box-shadow
|
|
31
|
+
// instead of a border so light swatches gain a visible edge without changing
|
|
32
|
+
// their box size and skewing the grid.
|
|
33
|
+
this.getBorder = () => {
|
|
34
|
+
if (!this.isCategoryActive)
|
|
35
|
+
return '';
|
|
36
|
+
return `5px solid ${this.isLightSwatch() ? '#d9d9d9' : this.darkenColor(this.color)}`;
|
|
37
|
+
};
|
|
38
|
+
this.getBoxShadow = () => {
|
|
39
|
+
if (this.isCategoryActive)
|
|
40
|
+
return '';
|
|
41
|
+
return this.isLightSwatch() ? 'inset 0 0 0 1px #d9d9d9' : '';
|
|
42
|
+
};
|
|
27
43
|
this.color = undefined;
|
|
28
44
|
this.name = undefined;
|
|
29
45
|
this.shop = undefined;
|
|
@@ -38,7 +54,8 @@ export class MyColorBox {
|
|
|
38
54
|
backgroundSize: ((_a = this.isImageInsteadHex) === null || _a === void 0 ? void 0 : _a.isImageInsteadHex) ? 'cover' : '',
|
|
39
55
|
backgroundImage: ((_b = this.isImageInsteadHex) === null || _b === void 0 ? void 0 : _b.isImageInsteadHex) ? `url(${APIURL}/assets/${this.isImageInsteadHex.bigImage}?access_token=${accessToken})` : '',
|
|
40
56
|
background: ((_c = this.isImageInsteadHex) === null || _c === void 0 ? void 0 : _c.isImageInsteadHex) ? this.isImageInsteadHex.bigImage : this.color,
|
|
41
|
-
border: this.
|
|
57
|
+
border: this.getBorder(),
|
|
58
|
+
boxShadow: this.getBoxShadow(),
|
|
42
59
|
} }, h("div", { class: "color-name" }, this.name)));
|
|
43
60
|
}
|
|
44
61
|
static get is() { return "my-colorbox"; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/colorbox/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAM7C,MAAM,OAAO,UAAU;;IAWrB,eAAU,GAAG,GAAG,EAAE;MAChB,IAAI,CAAC,YAAY,GAAG,UAAU,CAAC,GAAG,EAAE;QAClC,YAAY,CAAC;UACX,KAAK,EAAE,YAAY;UACnB,IAAI,EAAE,IAAI,CAAC,IAAI;UACf,OAAO,EAAE,IAAI,CAAC,OAAO;UACrB,KAAK,EAAE,IAAI,CAAC,IAAI;SACjB,CAAC,CAAC;MACL,CAAC,EAAE,IAAI,CAAC,CAAC;IACX,CAAC,CAAC;IAEF,iBAAY,GAAG,GAAG,EAAE;MAClB,IAAI,IAAI,CAAC,YAAY;QAAE,YAAY,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;MACvD,IAAI,CAAC,YAAY,GAAG,SAAS,CAAC;IAChC,CAAC,CAAC;IAEF,gBAAW,GAAG,CAAC,KAAa,EAAE,EAAE;MAC9B,MAAM,GAAG,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,EAA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AAA,MAAA,IAAI,CAAC,iBAAiB,0CAAE,iBAAiB,EAAC,CAAC,CAAC,OAAO,MAAM,WAAW,IAAI,CAAC,iBAAiB,CAAC,QAAQ,iBAAiB,WAAW,GAAG,CAAC,CAAC,CAAC,EAAE;QACxJ,UAAU,EAAE,CAAA,MAAA,IAAI,CAAC,iBAAiB,0CAAE,iBAAiB,EAAC,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK;QACpG,MAAM,EAAE,IAAI,CAAC,SAAS,EAAE;QACxB,SAAS,EAAE,IAAI,CAAC,YAAY,EAAE;OAC/B;MAED,WAAK,KAAK,EAAC,YAAY,IAAE,IAAI,CAAC,IAAI,CAAO,CACrC,CACP,CAAC;EACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Prop, h } from '@stencil/core';\nimport { setDataLayer } from '../../gtmUtils';\nimport { ColorBoxyIsImageInsteadHex } from '../../types';\nimport { isVeryLightColor } from '../../utils';\nimport { APIURL, accessToken } from '../api';\n\n@Component({\n tag: 'my-colorbox',\n styleUrl: 'index.scss',\n})\nexport class MyColorBox {\n private checkTimeout: ReturnType<typeof setTimeout> | undefined;\n\n @Prop() color: string;\n @Prop() name: string;\n @Prop() shop: string;\n @Prop() product: string;\n @Prop() isActive?: boolean;\n @Prop() isCategoryActive?: boolean;\n @Prop() isImageInsteadHex?: ColorBoxyIsImageInsteadHex;\n\n colorCheck = () => {\n this.checkTimeout = setTimeout(() => {\n setDataLayer({\n event: 'ColorCheck',\n shop: this.shop,\n product: this.product,\n color: this.name,\n });\n }, 2000);\n };\n\n colorUnCheck = () => {\n if (this.checkTimeout) clearTimeout(this.checkTimeout);\n this.checkTimeout = undefined;\n };\n\n darkenColor = (color: string) => {\n const red = parseInt(color[1] + color[2], 16) - 20;\n const green = parseInt(color[3] + color[4], 16) - 20;\n const blue = parseInt(color[5] + color[6], 16) - 20;\n return `rgb(${red},${green},${blue})`;\n };\n\n private isLightSwatch = () => !this.isImageInsteadHex?.isImageInsteadHex && isVeryLightColor(this.color);\n\n // Active category keeps its 5px solid border (all active swatches share it, so\n // alignment is consistent). In the normal grid we use an inset box-shadow\n // instead of a border so light swatches gain a visible edge without changing\n // their box size and skewing the grid.\n private getBorder = () => {\n if (!this.isCategoryActive) return '';\n return `5px solid ${this.isLightSwatch() ? '#d9d9d9' : this.darkenColor(this.color)}`;\n };\n\n private getBoxShadow = () => {\n if (this.isCategoryActive) return '';\n return this.isLightSwatch() ? 'inset 0 0 0 1px #d9d9d9' : '';\n };\n\n render() {\n return (\n <div\n onMouseEnter={() => this.colorCheck()}\n onMouseLeave={() => this.colorUnCheck()}\n class={`my-color-box ${this.isActive ? 'active' : ''} ${this.isCategoryActive ? 'categoryactive' : ''}`}\n style={{\n backgroundSize: this.isImageInsteadHex?.isImageInsteadHex ? 'cover' : '',\n backgroundImage: this.isImageInsteadHex?.isImageInsteadHex ? `url(${APIURL}/assets/${this.isImageInsteadHex.bigImage}?access_token=${accessToken})` : '',\n background: this.isImageInsteadHex?.isImageInsteadHex ? this.isImageInsteadHex.bigImage : this.color,\n border: this.getBorder(),\n boxShadow: this.getBoxShadow(),\n }}\n >\n <div class=\"color-name\">{this.name}</div>\n </div>\n );\n }\n}\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { h, getAssetPath } from '@stencil/core';
|
|
2
2
|
import { setDataLayer } from '../../gtmUtils';
|
|
3
|
+
import { isVeryLightColor } from '../../utils';
|
|
3
4
|
import { APIURL, accessToken } from '../api';
|
|
4
5
|
export class MyColorInfo {
|
|
5
6
|
constructor() {
|
|
@@ -40,17 +41,9 @@ export class MyColorInfo {
|
|
|
40
41
|
return string.charAt(0).toUpperCase() + string.slice(1).toLocaleLowerCase();
|
|
41
42
|
};
|
|
42
43
|
this.isVeryLightBackground = () => {
|
|
43
|
-
var _a, _b;
|
|
44
44
|
if (this.currentColor.imageInsteadHex)
|
|
45
45
|
return true;
|
|
46
|
-
|
|
47
|
-
if (hex.length !== 6 && hex.length !== 3)
|
|
48
|
-
return false;
|
|
49
|
-
const r = parseInt(hex.length === 3 ? hex[0] + hex[0] : hex.slice(0, 2), 16) / 255;
|
|
50
|
-
const g = parseInt(hex.length === 3 ? hex[1] + hex[1] : hex.slice(2, 4), 16) / 255;
|
|
51
|
-
const b = parseInt(hex.length === 3 ? hex[2] + hex[2] : hex.slice(4, 6), 16) / 255;
|
|
52
|
-
const luminance = 0.299 * r + 0.587 * g + 0.114 * b;
|
|
53
|
-
return luminance > 0.96;
|
|
46
|
+
return isVeryLightColor(this.currentColor.hex);
|
|
54
47
|
};
|
|
55
48
|
this.getButtonClass = () => {
|
|
56
49
|
if (this.currentColor.imageInsteadHex)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/colorinfo/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,EAAE,YAAY,EAAE,KAAK,EAAgB,MAAM,eAAe,CAAC;AACpG,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAK7C,MAAM,OAAO,WAAW;;IAYd,mBAAc,GAAyC,IAAI,CAAC;IAC5D,mBAAc,GAAyC,IAAI,CAAC;IAiCpE,gBAAW,GAAG,GAAG,EAAE;;MACjB,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;MAC5C,IAAI,CAAC,YAAY;QACf,YAAY,CAAC;UACX,KAAK,EAAE,aAAa;UACpB,IAAI,EAAE,IA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Ac,kBAAc,KAAK,oBAAgB,OAAO,qBAAiB,OAAO,GAAG,CACnI,CACD;gBACP;kBACE,2BAAuB;gCAClB,CACH,CACP,CACG,CACF;UACN,WAAK,KAAK,EAAC,yCAAyC,IACjD,IAAI,CAAC,YAAY,KAAI,MAAA,IAAI,CAAC,YAAY,CAAC,KAAK,0CAAE,IAAI,CAAC,CAAC,IAAU,EAAE,EAAE,CAAC,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,IAAI,MAAK,IAAI,CAAC,IAAI,CAAC,CAAA,IAAI,CAC/F,SAAG,OAAO,EAAE,IAAI,CAAC,WAAW,EAAE,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,UAAU,IAAI,CAAC,cAAc,EAAE,EAAE,oBAExF,CACL,CACG,CACF,CACF;MACN,WAAK,KAAK,EAAC,4BAA4B,IAAE,IAAI,CAAC,mBAAmB,EAAE,CAAO,CACtE,CACP,CAAC;EACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Prop, State, Watch, h, getAssetPath, Event, EventEmitter } from '@stencil/core';\nimport { setDataLayer } from '../../gtmUtils';\nimport { AvailableTester, Color, Link, Product } from '../../types';\nimport { APIURL, accessToken } from '../api';\n\n@Component({\n tag: 'my-colorinfo',\n})\nexport class MyColorInfo {\n @Prop() currentColor: Color;\n @Prop() shop: string;\n @Prop() product: string;\n @Prop() baselink: string;\n @Prop() availableTesters: AvailableTester | null;\n @Prop() price: number | null;\n @Prop() data: Product | null = null;\n @Prop() isMobile: boolean = false;\n @Prop() infoBoxWidth: number | null;\n @Prop() closeImage = 'close.png';\n @State() basketStatus: 'idle' | 'loading' | 'success' = 'idle';\n private loadingTimeout: ReturnType<typeof setTimeout> | null = null;\n private successTimeout: ReturnType<typeof setTimeout> | null = null;\n @Event({ bubbles: true, composed: true }) onCurrentColor: EventEmitter<Color>;\n @Event({ bubbles: true, composed: true }) addToBasket: EventEmitter<{ id: number }>;\n\n @Event() closeInfoBox: EventEmitter;\n\n @Watch('currentColor')\n onColorChange(newColor: Color, oldColor: Color) {\n if (newColor?.name === oldColor?.name) return;\n this.resetBasketStatus();\n }\n\n disconnectedCallback() {\n this.clearBasketTimeouts();\n }\n\n private clearBasketTimeouts() {\n if (this.loadingTimeout) {\n clearTimeout(this.loadingTimeout);\n this.loadingTimeout = null;\n }\n\n if (this.successTimeout) {\n clearTimeout(this.successTimeout);\n this.successTimeout = null;\n }\n }\n\n private resetBasketStatus() {\n this.clearBasketTimeouts();\n this.basketStatus = 'idle';\n }\n\n goToProduct = () => {\n this.onCurrentColor.emit(this.currentColor);\n this.currentColor &&\n setDataLayer({\n event: 'GoToProduct',\n shop: this.shop,\n product: this.product,\n color: this.currentColor?.name,\n });\n\n this.closeInfoBox.emit();\n };\n\n onCloseButtonClick = () => {\n this.closeInfoBox.emit();\n };\n\n getHref = () => {\n if (this.baselink) {\n return `${this.baselink}/${this?.currentColor.links?.find((link: Link) => link?.shop === this.shop)?.path}`;\n }\n return this?.currentColor.links?.find((link: Link) => link?.shop === this.shop)?.path;\n };\n\n renderSliderOrImage = () => {\n if (this.currentColor.imageInsteadHex) {\n return <img class={'color-big-image'} src={`${APIURL}/assets/${this.currentColor.bigImage}?access_token=${accessToken}`} alt=\"color-image\" />;\n } else {\n return <my-slider color={this.currentColor.name} shop={this.shop} product={this.product} slides={this.data?.images}></my-slider>;\n }\n };\n\n capitalizeFirstLetter = (string: string) => {\n return string.charAt(0).toUpperCase() + string.slice(1).toLocaleLowerCase();\n };\n\n isVeryLightBackground = (): boolean => {\n if (this.currentColor.imageInsteadHex) return true;\n const hex = this.currentColor.hex?.replace('#', '') ?? '';\n if (hex.length !== 6 && hex.length !== 3) return false;\n const r = parseInt(hex.length === 3 ? hex[0] + hex[0] : hex.slice(0, 2), 16) / 255;\n const g = parseInt(hex.length === 3 ? hex[1] + hex[1] : hex.slice(2, 4), 16) / 255;\n const b = parseInt(hex.length === 3 ? hex[2] + hex[2] : hex.slice(4, 6), 16) / 255;\n const luminance = 0.299 * r + 0.587 * g + 0.114 * b;\n return luminance > 0.96;\n };\n\n getButtonClass = () => {\n if (this.currentColor.imageInsteadHex) return 'brown';\n return this.isVeryLightBackground() ? 'inverse' : '';\n };\n\n handleAddToBasket = () => {\n if (!this.availableTesters?.id_product_attribute) return;\n if (this.basketStatus !== 'idle') return;\n\n this.clearBasketTimeouts();\n this.basketStatus = 'loading';\n this.addToBasket.emit({\n id: this.availableTesters.id_product_attribute,\n });\n\n this.loadingTimeout = setTimeout(() => {\n this.basketStatus = 'success';\n this.successTimeout = setTimeout(() => {\n this.basketStatus = 'idle';\n }, 2500);\n }, 900);\n };\n\n render() {\n return (\n <div\n class={`boxes__box-content ${this.currentColor.textWhite ? 'boxes__box-content__white' : ''}`}\n style={{\n background: this.currentColor.imageInsteadHex ? 'white' : this.currentColor.hex,\n maxWidth: `${this.infoBoxWidth && this.infoBoxWidth - 4}px`,\n }}\n >\n {this.isMobile && <img class={'closebtn'} onClick={this.onCloseButtonClick} src={getAssetPath(`./assets/${this.closeImage}`)} alt=\"closebtn\" />}\n <div\n class=\"boxes__box-content__info\"\n style={{\n maxWidth: this.isMobile ? `${this.infoBoxWidth && this.infoBoxWidth - 35}px` : ``,\n }}\n >\n {!this.isMobile && <img class={'closebtn'} onClick={this.onCloseButtonClick} src={getAssetPath(`./assets/${this.closeImage}`)} alt=\"closebtn\" />}\n <h2>{this.currentColor.name}</h2>\n {!this.isMobile && <h4>{this.currentColor.number}</h4>}\n\n <div class=\"boxes__box-content__info__value\">\n <div class=\"divider\"></div>\n <div class=\"boxes__box-content__info__tester\">\n <div class=\"divider\"></div>\n <div class=\"tester-text\">\n <h2>Zamow tester</h2>\n <p>Sprawdz go na swojej scianie.</p>\n </div>\n <div class=\"tester-buy\">\n <div class=\"price\">{this.price ? `${this.price} zl` : ''}</div>\n {this.isMobile && <div class={'divider'}></div>}\n {this.basketStatus !== 'success' && (\n <button\n class={`button fit ${this.getButtonClass()} ${!this.availableTesters ? 'disabled' : ''} ${\n this.basketStatus === 'loading' ? 'is-loading' : ''\n }`}\n onClick={this.handleAddToBasket}\n disabled={!this.availableTesters || this.basketStatus === 'loading'}\n >\n <span class=\"button-content\">\n <span class=\"shape-icon\" aria-hidden=\"true\">\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"15\" height=\"16\" viewBox=\"0 0 15 16\">\n <path\n class=\"shape-icon__path\"\n transform=\"translate(0.0867462 0)\"\n d=\"M13.246571 12.763281L11.931726 4.961875C11.801879 4.1936703 11.13567 3.6319427 10.35657 3.63375L9.7429771 3.63375L9.7429771 3.1025C9.7429771 1.3890365 8.35394 0 6.6404767 0C4.9270134 0 3.537977 1.3890365 3.537977 3.1025L3.537977 3.63375L2.9217269 3.63375C2.1426277 3.6319427 1.4764187 4.1936703 1.3465706 4.961875L0.034383144 12.763281C-0.086738147 13.483807 0.11555123 14.221112 0.58740741 14.778946C1.0592636 15.336781 1.7528107 15.658594 2.4834456 15.658594L10.797508 15.658594C11.528143 15.658594 12.22169 15.336781 12.693546 14.778946C13.165402 14.221112 13.367692 13.483807 13.246571 12.763281L13.246571 12.763281ZM4.3348517 3.0892186C4.3348517 1.8158572 5.3671155 0.78359371 6.6404767 0.78359371C7.9138384 0.78359371 8.9461021 1.8158572 8.9461021 3.0892186L8.9461021 3.6204686L4.3348517 3.6204686L4.3348517 3.0892186ZM12.08579 14.264063C11.765244 14.643165 11.293964 14.86172 10.797508 14.86172L2.4834456 14.86172C1.9871488 14.862442 1.5158025 14.644215 1.195269 14.265309C0.87473541 13.886404 0.73765546 13.385406 0.82063317 12.896093L2.1248519 5.092031C2.1891608 4.703371 2.5278175 4.4200282 2.9217269 4.4252396L3.5353208 4.4252396L3.5353208 5.5834374C3.5353208 5.8034883 3.7137072 5.9818749 3.9337583 5.9818749C4.1538091 5.9818749 4.3321958 5.8034883 4.3321958 5.5834374L4.3321958 4.4252396L8.9461021 4.4252396L8.9461021 5.5834374C8.9461021 5.8034883 9.1244888 5.9818749 9.3445396 5.9818749C9.5645905 5.9818749 9.7429771 5.8034883 9.7429771 5.5834374L9.7429771 4.4252396L10.359227 4.4252396C10.753137 4.4200282 11.091793 4.703371 11.156102 5.092031L12.46032 12.896093C12.542204 13.384947 12.40527 13.885097 12.08579 14.264063L12.08579 14.264063Z\"\n />\n </svg>\n </span>\n {!this.availableTesters ? 'Tester obecnie niedostepny' : 'Dodaj do koszyka'}\n </span>\n {this.basketStatus === 'loading' && (\n <span class=\"spinner\" aria-hidden=\"true\">\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"18\" height=\"18\" viewBox=\"0 0 24 24\">\n <path d=\"M12 2 A10 10 0 1 1 2 12\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\" />\n </svg>\n </span>\n )}\n </button>\n )}\n {this.basketStatus === 'success' && (\n <div class={`basket-status basket-status--success ${this.getButtonClass()}`} role=\"status\" aria-live=\"polite\">\n <span class=\"check-icon\" aria-hidden=\"true\">\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\">\n <path d=\"M5 12.5l4.5 4.5L19 7.5\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\" />\n </svg>\n </span>\n <span>\n <strong>Dodano</strong> do koszyka\n </span>\n </div>\n )}\n </div>\n </div>\n <div class=\"boxes__box-content__info__value-product\">\n {this.currentColor && this.currentColor.links?.find((link: Link) => link?.shop === this.shop) && (\n <a onClick={this.goToProduct} href={this.getHref()} class={`button ${this.getButtonClass()}`}>\n wybierz kolor\n </a>\n )}\n </div>\n </div>\n </div>\n <div class=\"boxes__box-content__slider\">{this.renderSliderOrImage()}</div>\n </div>\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/colorinfo/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,EAAE,YAAY,EAAE,KAAK,EAAgB,MAAM,eAAe,CAAC;AACpG,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAK7C,MAAM,OAAO,WAAW;;IAYd,mBAAc,GAAyC,IAAI,CAAC;IAC5D,mBAAc,GAAyC,IAAI,CAAC;IAiCpE,gBAAW,GAAG,GAAG,EAAE;;MACjB,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;MAC5C,IAAI,CAAC,YAAY;QACf,YAAY,CAAC;UACX,KAAK,EAAE,aAAa;UACpB,IAAI,EAAE,IAAI,CAAC,IAAI;UACf,OAAO,EAAE,IAAI,CAAC,OAAO;UACrB,KAAK,EAAE,MAAA,IAAI,CAAC,YAAY,0CAAE,IAAI;SAC/B,CAAC,CAAC;MAEL,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC;IAC3B,CAAC,CAAC;IAEF,uBAAkB,GAAG,GAAG,EAAE;MACxB,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC;IAC3B,CAAC,CAAC;IAEF,YAAO,GAAG,GAAG,EAAE;;MACb,IAAI,IAAI,CAAC,QAAQ,EAAE;QACjB,OAAO,GAAG,IAAI,CAAC,QAAQ,IAAI,MAAA,MAAA,IAAI,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IAAI,CAAC,CAAC,IAAU,EAAE,EAAE,CAAC,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,IAAI,MAAK,IAAI,CAAC,IAAI,CAAC,CAAA,IAAI,CAC/F,SAAG,OAAO,EAAE,IAAI,CAAC,WAAW,EAAE,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,UAAU,IAAI,CAAC,cAAc,EAAE,EAAE,oBAExF,CACL,CACG,CACF,CACF;MACN,WAAK,KAAK,EAAC,4BAA4B,IAAE,IAAI,CAAC,mBAAmB,EAAE,CAAO,CACtE,CACP,CAAC;EACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Prop, State, Watch, h, getAssetPath, Event, EventEmitter } from '@stencil/core';\nimport { setDataLayer } from '../../gtmUtils';\nimport { AvailableTester, Color, Link, Product } from '../../types';\nimport { isVeryLightColor } from '../../utils';\nimport { APIURL, accessToken } from '../api';\n\n@Component({\n tag: 'my-colorinfo',\n})\nexport class MyColorInfo {\n @Prop() currentColor: Color;\n @Prop() shop: string;\n @Prop() product: string;\n @Prop() baselink: string;\n @Prop() availableTesters: AvailableTester | null;\n @Prop() price: number | null;\n @Prop() data: Product | null = null;\n @Prop() isMobile: boolean = false;\n @Prop() infoBoxWidth: number | null;\n @Prop() closeImage = 'close.png';\n @State() basketStatus: 'idle' | 'loading' | 'success' = 'idle';\n private loadingTimeout: ReturnType<typeof setTimeout> | null = null;\n private successTimeout: ReturnType<typeof setTimeout> | null = null;\n @Event({ bubbles: true, composed: true }) onCurrentColor: EventEmitter<Color>;\n @Event({ bubbles: true, composed: true }) addToBasket: EventEmitter<{ id: number }>;\n\n @Event() closeInfoBox: EventEmitter;\n\n @Watch('currentColor')\n onColorChange(newColor: Color, oldColor: Color) {\n if (newColor?.name === oldColor?.name) return;\n this.resetBasketStatus();\n }\n\n disconnectedCallback() {\n this.clearBasketTimeouts();\n }\n\n private clearBasketTimeouts() {\n if (this.loadingTimeout) {\n clearTimeout(this.loadingTimeout);\n this.loadingTimeout = null;\n }\n\n if (this.successTimeout) {\n clearTimeout(this.successTimeout);\n this.successTimeout = null;\n }\n }\n\n private resetBasketStatus() {\n this.clearBasketTimeouts();\n this.basketStatus = 'idle';\n }\n\n goToProduct = () => {\n this.onCurrentColor.emit(this.currentColor);\n this.currentColor &&\n setDataLayer({\n event: 'GoToProduct',\n shop: this.shop,\n product: this.product,\n color: this.currentColor?.name,\n });\n\n this.closeInfoBox.emit();\n };\n\n onCloseButtonClick = () => {\n this.closeInfoBox.emit();\n };\n\n getHref = () => {\n if (this.baselink) {\n return `${this.baselink}/${this?.currentColor.links?.find((link: Link) => link?.shop === this.shop)?.path}`;\n }\n return this?.currentColor.links?.find((link: Link) => link?.shop === this.shop)?.path;\n };\n\n renderSliderOrImage = () => {\n if (this.currentColor.imageInsteadHex) {\n return <img class={'color-big-image'} src={`${APIURL}/assets/${this.currentColor.bigImage}?access_token=${accessToken}`} alt=\"color-image\" />;\n } else {\n return <my-slider color={this.currentColor.name} shop={this.shop} product={this.product} slides={this.data?.images}></my-slider>;\n }\n };\n\n capitalizeFirstLetter = (string: string) => {\n return string.charAt(0).toUpperCase() + string.slice(1).toLocaleLowerCase();\n };\n\n isVeryLightBackground = (): boolean => {\n if (this.currentColor.imageInsteadHex) return true;\n return isVeryLightColor(this.currentColor.hex);\n };\n\n getButtonClass = () => {\n if (this.currentColor.imageInsteadHex) return 'brown';\n return this.isVeryLightBackground() ? 'inverse' : '';\n };\n\n handleAddToBasket = () => {\n if (!this.availableTesters?.id_product_attribute) return;\n if (this.basketStatus !== 'idle') return;\n\n this.clearBasketTimeouts();\n this.basketStatus = 'loading';\n this.addToBasket.emit({\n id: this.availableTesters.id_product_attribute,\n });\n\n this.loadingTimeout = setTimeout(() => {\n this.basketStatus = 'success';\n this.successTimeout = setTimeout(() => {\n this.basketStatus = 'idle';\n }, 2500);\n }, 900);\n };\n\n render() {\n return (\n <div\n class={`boxes__box-content ${this.currentColor.textWhite ? 'boxes__box-content__white' : ''}`}\n style={{\n background: this.currentColor.imageInsteadHex ? 'white' : this.currentColor.hex,\n maxWidth: `${this.infoBoxWidth && this.infoBoxWidth - 4}px`,\n }}\n >\n {this.isMobile && <img class={'closebtn'} onClick={this.onCloseButtonClick} src={getAssetPath(`./assets/${this.closeImage}`)} alt=\"closebtn\" />}\n <div\n class=\"boxes__box-content__info\"\n style={{\n maxWidth: this.isMobile ? `${this.infoBoxWidth && this.infoBoxWidth - 35}px` : ``,\n }}\n >\n {!this.isMobile && <img class={'closebtn'} onClick={this.onCloseButtonClick} src={getAssetPath(`./assets/${this.closeImage}`)} alt=\"closebtn\" />}\n <h2>{this.currentColor.name}</h2>\n {!this.isMobile && <h4>{this.currentColor.number}</h4>}\n\n <div class=\"boxes__box-content__info__value\">\n <div class=\"divider\"></div>\n <div class=\"boxes__box-content__info__tester\">\n <div class=\"divider\"></div>\n <div class=\"tester-text\">\n <h2>Zamow tester</h2>\n <p>Sprawdz go na swojej scianie.</p>\n </div>\n <div class=\"tester-buy\">\n <div class=\"price\">{this.price ? `${this.price} zl` : ''}</div>\n {this.isMobile && <div class={'divider'}></div>}\n {this.basketStatus !== 'success' && (\n <button\n class={`button fit ${this.getButtonClass()} ${!this.availableTesters ? 'disabled' : ''} ${\n this.basketStatus === 'loading' ? 'is-loading' : ''\n }`}\n onClick={this.handleAddToBasket}\n disabled={!this.availableTesters || this.basketStatus === 'loading'}\n >\n <span class=\"button-content\">\n <span class=\"shape-icon\" aria-hidden=\"true\">\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"15\" height=\"16\" viewBox=\"0 0 15 16\">\n <path\n class=\"shape-icon__path\"\n transform=\"translate(0.0867462 0)\"\n d=\"M13.246571 12.763281L11.931726 4.961875C11.801879 4.1936703 11.13567 3.6319427 10.35657 3.63375L9.7429771 3.63375L9.7429771 3.1025C9.7429771 1.3890365 8.35394 0 6.6404767 0C4.9270134 0 3.537977 1.3890365 3.537977 3.1025L3.537977 3.63375L2.9217269 3.63375C2.1426277 3.6319427 1.4764187 4.1936703 1.3465706 4.961875L0.034383144 12.763281C-0.086738147 13.483807 0.11555123 14.221112 0.58740741 14.778946C1.0592636 15.336781 1.7528107 15.658594 2.4834456 15.658594L10.797508 15.658594C11.528143 15.658594 12.22169 15.336781 12.693546 14.778946C13.165402 14.221112 13.367692 13.483807 13.246571 12.763281L13.246571 12.763281ZM4.3348517 3.0892186C4.3348517 1.8158572 5.3671155 0.78359371 6.6404767 0.78359371C7.9138384 0.78359371 8.9461021 1.8158572 8.9461021 3.0892186L8.9461021 3.6204686L4.3348517 3.6204686L4.3348517 3.0892186ZM12.08579 14.264063C11.765244 14.643165 11.293964 14.86172 10.797508 14.86172L2.4834456 14.86172C1.9871488 14.862442 1.5158025 14.644215 1.195269 14.265309C0.87473541 13.886404 0.73765546 13.385406 0.82063317 12.896093L2.1248519 5.092031C2.1891608 4.703371 2.5278175 4.4200282 2.9217269 4.4252396L3.5353208 4.4252396L3.5353208 5.5834374C3.5353208 5.8034883 3.7137072 5.9818749 3.9337583 5.9818749C4.1538091 5.9818749 4.3321958 5.8034883 4.3321958 5.5834374L4.3321958 4.4252396L8.9461021 4.4252396L8.9461021 5.5834374C8.9461021 5.8034883 9.1244888 5.9818749 9.3445396 5.9818749C9.5645905 5.9818749 9.7429771 5.8034883 9.7429771 5.5834374L9.7429771 4.4252396L10.359227 4.4252396C10.753137 4.4200282 11.091793 4.703371 11.156102 5.092031L12.46032 12.896093C12.542204 13.384947 12.40527 13.885097 12.08579 14.264063L12.08579 14.264063Z\"\n />\n </svg>\n </span>\n {!this.availableTesters ? 'Tester obecnie niedostepny' : 'Dodaj do koszyka'}\n </span>\n {this.basketStatus === 'loading' && (\n <span class=\"spinner\" aria-hidden=\"true\">\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"18\" height=\"18\" viewBox=\"0 0 24 24\">\n <path d=\"M12 2 A10 10 0 1 1 2 12\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\" />\n </svg>\n </span>\n )}\n </button>\n )}\n {this.basketStatus === 'success' && (\n <div class={`basket-status basket-status--success ${this.getButtonClass()}`} role=\"status\" aria-live=\"polite\">\n <span class=\"check-icon\" aria-hidden=\"true\">\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\">\n <path d=\"M5 12.5l4.5 4.5L19 7.5\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\" />\n </svg>\n </span>\n <span>\n <strong>Dodano</strong> do koszyka\n </span>\n </div>\n )}\n </div>\n </div>\n <div class=\"boxes__box-content__info__value-product\">\n {this.currentColor && this.currentColor.links?.find((link: Link) => link?.shop === this.shop) && (\n <a onClick={this.goToProduct} href={this.getHref()} class={`button ${this.getButtonClass()}`}>\n wybierz kolor\n </a>\n )}\n </div>\n </div>\n </div>\n <div class=\"boxes__box-content__slider\">{this.renderSliderOrImage()}</div>\n </div>\n );\n }\n}\n"]}
|
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns true when a hex color is so light it is hard to distinguish from a
|
|
3
|
+
* white background (e.g. NCS S 0300-N ≈ #fafaf8). Uses perceived luminance.
|
|
4
|
+
* Accepts values with or without a leading '#', in 3- or 6-digit form.
|
|
5
|
+
*/
|
|
6
|
+
export function isVeryLightColor(hex) {
|
|
7
|
+
var _a;
|
|
8
|
+
const cleaned = (_a = hex === null || hex === void 0 ? void 0 : hex.replace('#', '')) !== null && _a !== void 0 ? _a : '';
|
|
9
|
+
if (cleaned.length !== 6 && cleaned.length !== 3)
|
|
10
|
+
return false;
|
|
11
|
+
const short = cleaned.length === 3;
|
|
12
|
+
const r = parseInt(short ? cleaned[0] + cleaned[0] : cleaned.slice(0, 2), 16) / 255;
|
|
13
|
+
const g = parseInt(short ? cleaned[1] + cleaned[1] : cleaned.slice(2, 4), 16) / 255;
|
|
14
|
+
const b = parseInt(short ? cleaned[2] + cleaned[2] : cleaned.slice(4, 6), 16) / 255;
|
|
15
|
+
const luminance = 0.299 * r + 0.587 * g + 0.114 * b;
|
|
16
|
+
return luminance > 0.96;
|
|
17
|
+
}
|
|
1
18
|
export function debounce(func, wait) {
|
|
2
19
|
let timeout;
|
|
3
20
|
return function executedFunction(...args) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,QAAQ,CAAC,IAA8B,EAAE,IAAY;EACnE,IAAI,OAAsC,CAAC;EAE3C,OAAO,SAAS,gBAAgB,CAAC,GAAG,IAAW;IAC7C,MAAM,KAAK,GAAG,GAAG,EAAE;MACjB,YAAY,CAAC,OAAO,CAAC,CAAC;MACtB,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;IAChB,CAAC,CAAC;IAEF,YAAY,CAAC,OAAO,CAAC,CAAC;IACtB,OAAO,GAAG,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;EACpC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,GAA8B;;EAC7D,MAAM,OAAO,GAAG,MAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,mCAAI,EAAE,CA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,CAAC,OAAO,CAAC,CAAC;IACtB,OAAO,GAAG,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;EACpC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Returns true when a hex color is so light it is hard to distinguish from a\n * white background (e.g. NCS S 0300-N ≈ #fafaf8). Uses perceived luminance.\n * Accepts values with or without a leading '#', in 3- or 6-digit form.\n */\nexport function isVeryLightColor(hex: string | null | undefined): boolean {\n const cleaned = hex?.replace('#', '') ?? '';\n if (cleaned.length !== 6 && cleaned.length !== 3) return false;\n const short = cleaned.length === 3;\n const r = parseInt(short ? cleaned[0] + cleaned[0] : cleaned.slice(0, 2), 16) / 255;\n const g = parseInt(short ? cleaned[1] + cleaned[1] : cleaned.slice(2, 4), 16) / 255;\n const b = parseInt(short ? cleaned[2] + cleaned[2] : cleaned.slice(4, 6), 16) / 255;\n const luminance = 0.299 * r + 0.587 * g + 0.114 * b;\n return luminance > 0.96;\n}\n\nexport function debounce(func: (...args: any[]) => void, wait: number) {\n let timeout: ReturnType<typeof setTimeout>;\n\n return function executedFunction(...args: any[]) {\n const later = () => {\n clearTimeout(timeout);\n func(...args);\n };\n\n clearTimeout(timeout);\n timeout = setTimeout(later, wait);\n };\n}\n"]}
|