@ppg_pl/tinting 0.0.5 → 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/{index-0a139db0.js → index-b6962659.js} +51 -4
- package/dist/cjs/index-b6962659.js.map +1 -0
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/modal-header_9.cjs.entry.js +165 -41
- package/dist/cjs/modal-header_9.cjs.entry.js.map +1 -1
- package/dist/cjs/tinting.cjs.js +2 -2
- 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 +128 -1
- package/dist/collection/components/colorinfo/index.js.map +1 -1
- package/dist/collection/components/component/index.js +64 -1
- package/dist/collection/components/component/index.js.map +1 -1
- package/dist/collection/components/modal/index.css +176 -1
- package/dist/collection/components/modal/index.js +50 -2
- package/dist/collection/components/modal/index.js.map +1 -1
- package/dist/collection/components/slider/index.css +24 -6
- package/dist/collection/components/slider/index.js +32 -21
- package/dist/collection/components/slider/index.js.map +1 -1
- package/dist/collection/types.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 -3598
- 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 +57 -52
- package/dist/components/index8.js.map +1 -1
- package/dist/components/index9.js +124 -5272
- 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 +18 -7
- package/dist/components/my-component.js.map +1 -1
- package/dist/components/my-modal.js +1 -1
- package/dist/components/my-slider.js +1 -1
- package/dist/esm/{index-f3be6531.js → index-cb79645d.js} +51 -4
- package/dist/esm/index-cb79645d.js.map +1 -0
- package/dist/esm/loader.js +3 -3
- package/dist/esm/modal-header_9.entry.js +165 -41
- package/dist/esm/modal-header_9.entry.js.map +1 -1
- package/dist/esm/tinting.js +3 -3
- package/dist/tinting/p-2730a042.entry.js +15 -0
- package/dist/tinting/p-2730a042.entry.js.map +1 -0
- package/dist/tinting/p-5b9dc044.js +3 -0
- package/dist/tinting/p-5b9dc044.js.map +1 -0
- package/dist/tinting/tinting.esm.js +1 -1
- package/dist/tinting/tinting.esm.js.map +1 -1
- package/dist/types/components/colorbox/index.d.ts +3 -0
- package/dist/types/components/colorinfo/index.d.ts +17 -1
- package/dist/types/components/component/index.d.ts +8 -0
- package/dist/types/components/modal/index.d.ts +6 -1
- package/dist/types/components.d.ts +16 -2
- package/dist/types/types.d.ts +4 -0
- package/dist/types/utils/index.d.ts +6 -0
- package/package.json +3 -2
- package/www/build/p-2730a042.entry.js +15 -0
- package/www/build/p-2730a042.entry.js.map +1 -0
- package/www/build/p-5b9dc044.js +3 -0
- package/www/build/p-5b9dc044.js.map +1 -0
- package/www/build/tinting.esm.js +1 -1
- package/www/build/tinting.esm.js.map +1 -1
- package/www/index.html +76 -12
- package/dist/cjs/index-0a139db0.js.map +0 -1
- package/dist/esm/index-f3be6531.js.map +0 -1
- package/dist/tinting/p-398633de.entry.js +0 -15
- package/dist/tinting/p-398633de.entry.js.map +0 -1
- package/dist/tinting/p-b135c76f.js +0 -3
- package/dist/tinting/p-b135c76f.js.map +0 -1
- package/www/build/p-398633de.entry.js +0 -15
- package/www/build/p-398633de.entry.js.map +0 -1
- package/www/build/p-b135c76f.js +0 -3
- package/www/build/p-b135c76f.js.map +0 -1
|
@@ -1,16 +1,5 @@
|
|
|
1
1
|
import { proxyCustomElement, HTMLElement, createEvent, h, getAssetPath } from '@stencil/core/internal/client';
|
|
2
|
-
|
|
3
|
-
function debounce(func, wait) {
|
|
4
|
-
let timeout;
|
|
5
|
-
return function executedFunction(...args) {
|
|
6
|
-
const later = () => {
|
|
7
|
-
clearTimeout(timeout);
|
|
8
|
-
func(...args);
|
|
9
|
-
};
|
|
10
|
-
clearTimeout(timeout);
|
|
11
|
-
timeout = setTimeout(later, wait);
|
|
12
|
-
};
|
|
13
|
-
}
|
|
2
|
+
import { d as debounce } from './index6.js';
|
|
14
3
|
|
|
15
4
|
const indexCss = "@import url(\"https://fonts.googleapis.com/css2?family=Figtree:ital,wght@0,300..900;1.sc-my-select,300..900&family=Poppins.sc-my-select:ital,wght@0.sc-my-select,100.sc-my-select;0.sc-my-select,200.sc-my-select;0.sc-my-select,300.sc-my-select;0.sc-my-select,400.sc-my-select;0.sc-my-select,500.sc-my-select;0.sc-my-select,600.sc-my-select;0.sc-my-select,700.sc-my-select;0.sc-my-select,800.sc-my-select;0.sc-my-select,900.sc-my-select;1.sc-my-select,100.sc-my-select;1.sc-my-select,200.sc-my-select;1.sc-my-select,300.sc-my-select;1.sc-my-select,400.sc-my-select;1.sc-my-select,500.sc-my-select;1.sc-my-select,600.sc-my-select;1.sc-my-select,700.sc-my-select;1.sc-my-select,800.sc-my-select;1.sc-my-select,900&display=swap\").sc-my-select; .tinting-wrapper.sc-my-select *.sc-my-select{font-family:\"Poppins\", sans-serif}.select.sc-my-select{position:relative;width:300px}@media (max-width: 768px){.select.sc-my-select{width:100%}}.select.sc-my-select .input-wrapper.sc-my-select{position:relative;display:flex;align-items:flex-start}.select.sc-my-select input.sc-my-select{font-size:16px;padding:16px;border-radius:27.35px;border:1px solid #dfdfdf;width:100%;color:#4c4c4c;box-sizing:border-box;padding-right:50px}.select.sc-my-select button.sc-my-select{position:absolute;right:10px;background:transparent;border:none;cursor:pointer;width:40px;height:100%;display:flex;align-items:center;justify-content:center}.select.sc-my-select button.sc-my-select img.sc-my-select{transition:transform 0.3s ease}.select.sc-my-select button.sc-my-select img.rotated.sc-my-select{transform:rotate(180deg)}.select.sc-my-select .dropdown.sc-my-select{position:absolute;top:100%;left:0;width:100%;background:white;border:1px solid #dfdfdf;border-radius:5px;max-height:200px;overflow-y:auto;z-index:1000;padding:0;margin:0}.select.sc-my-select .dropdown.sc-my-select li.sc-my-select{padding:0;margin:0;padding:10px;cursor:pointer;list-style:none;text-align:left}.select.sc-my-select .dropdown.sc-my-select li.sc-my-select:hover{background:#f5f5f5}.select.sc-my-select .dropdown.sc-my-select .no-results.sc-my-select{padding:10px;text-align:center;color:#999}@media (max-width: 768px){.select.sc-my-select .dropdown.sc-my-select{position:relative}}";
|
|
16
5
|
|
|
@@ -116,6 +105,6 @@ function defineCustomElement() {
|
|
|
116
105
|
} });
|
|
117
106
|
}
|
|
118
107
|
|
|
119
|
-
export { MySelect as M,
|
|
108
|
+
export { MySelect as M, defineCustomElement as d };
|
|
120
109
|
|
|
121
110
|
//# sourceMappingURL=index4.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"index4.js","mappings":"
|
|
1
|
+
{"file":"index4.js","mappings":";;;AAAA,MAAM,QAAQ,GAAG,wrEAAwrE;;MCU5rE,QAAQ;;;;;;;IAgBX,kBAAa,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC,WAAW,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC;IAErD,oBAAe,GAAG,QAAQ,CAAC,CAAC,KAAa;MAC/C,MAAM,kBAAkB,GAAG,CAAC,IAAI,CAAC,aAAa,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC;MACjE,IAAI,CAAC,eAAe,GAAG,kBAAkB,CAAC,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;MACpH,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;KACnC,EAAE,GAAG,CAAC,CAAC;IAkBA,uBAAkB,GAAG,CAAC,KAAiB;MAC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AAM,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC,IAC5H,MAAM,CAAC,IAAI,CACT,CACN,CAAC,KAEF,UAAI,KAAK,EAAC,YAAY,uBAAsB,CAC7C,CACE,CACN,CACG,EACN;GACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":[],"sources":["./src/components/select/index.scss?tag=my-select&encapsulation=scoped","./src/components/select/index.tsx"],"sourcesContent":["@import '../../global/app.scss';\n\n.select {\n position: relative;\n width: 300px;\n\n @media (max-width: $small) {\n width: 100%;\n }\n\n .input-wrapper {\n position: relative;\n display: flex;\n align-items: flex-start;\n }\n\n input {\n font-size: 16px;\n padding: 16px;\n border-radius: 27.35px;\n border: 1px solid #dfdfdf;\n width: 100%;\n color: #4c4c4c;\n box-sizing: border-box;\n padding-right: 50px;\n }\n\n button {\n position: absolute;\n right: 10px;\n background: transparent;\n border: none;\n cursor: pointer;\n width: 40px;\n height: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n\n img {\n transition: transform 0.3s ease;\n\n &.rotated {\n transform: rotate(180deg);\n }\n }\n }\n\n .dropdown {\n position: absolute;\n top: 100%;\n left: 0;\n width: 100%;\n background: white;\n border: 1px solid #dfdfdf;\n border-radius: 5px;\n max-height: 200px;\n overflow-y: auto;\n z-index: 1000;\n padding: 0;\n margin: 0;\n\n li {\n padding: 0;\n margin: 0;\n padding: 10px;\n cursor: pointer;\n list-style: none;\n text-align: left;\n &:hover {\n background: #f5f5f5;\n }\n }\n\n .no-results {\n padding: 10px;\n text-align: center;\n color: #999;\n }\n @media (max-width: $small) {\n position: relative;\n }\n }\n}\n","import { Component, Prop, h, State, Event, EventEmitter, Listen, Watch, Element } from '@stencil/core';\nimport { getAssetPath } from '@stencil/core';\nimport { debounce } from '../../utils';\n\n@Component({\n tag: 'my-select',\n styleUrl: 'index.scss',\n assetsDirs: ['assets'],\n scoped: true,\n})\nexport class MySelect {\n @Element() el: HTMLElement;\n\n @Prop() options: any[] = []; // List of selectable options\n @Prop() placeholder: string = 'Select an option'; // Placeholder text\n @Prop() isMobile: boolean = false;\n @Prop() searchIcon: string = 'chevron.png'; // Search icon asset\n\n @State() searchText: string = '';\n @State() filteredOptions: any[] = [];\n @State() showDropdown: boolean = false;\n @State() selectedValue: string | null = null;\n @Event() onReset: EventEmitter<void>;\n @Event() selectValue: EventEmitter<{ key: string; value: number | null }>; // Emits selected value\n @Event() inputValueChange: EventEmitter<string>; // Emits input changes for filtering\n\n private defaultOption = { name: this.placeholder, id: null };\n\n private debouncedSearch = debounce((value: string) => {\n const optionsWithDefault = [this.defaultOption, ...this.options];\n this.filteredOptions = optionsWithDefault.filter(option => option.name.toLowerCase().includes(value.toLowerCase()));\n this.inputValueChange.emit(value);\n }, 300);\n\n private reset() {\n this.onReset.emit();\n }\n\n componentWillLoad() {\n this.filteredOptions = [this.defaultOption, ...this.options];\n }\n\n componentDidLoad() {\n document.addEventListener('click', this.handleClickOutside);\n }\n\n disconnectedCallback() {\n document.removeEventListener('click', this.handleClickOutside);\n }\n\n private handleClickOutside = (event: MouseEvent) => {\n if (!this.el.contains(event.target as Node)) {\n this.showDropdown = false;\n }\n };\n\n private handleInput(event: Event) {\n const value = (event.target as HTMLInputElement).value;\n this.searchText = value;\n this.showDropdown = true;\n this.debouncedSearch(value);\n }\n\n private selectOption(option: { key: string; value: number | null }) {\n if (option.value === null) {\n this.selectedValue = null;\n this.searchText = '';\n this.reset();\n } else {\n this.selectedValue = option.key;\n this.searchText = option.key;\n this.selectValue.emit(option);\n }\n this.showDropdown = false;\n }\n\n private toggleDropdown() {\n this.showDropdown = !this.showDropdown;\n }\n\n @Watch('options')\n updateOptions(newOptions: any[]) {\n this.filteredOptions = [this.defaultOption, ...newOptions];\n }\n\n @Listen('clearSearchText', { target: 'document' })\n clearSearchTextHandler() {\n this.searchText = '';\n this.selectedValue = null;\n this.reset();\n }\n\n render() {\n return (\n <div class=\"select\">\n <div class=\"input-wrapper\">\n <input type=\"text\" placeholder={this.placeholder} value={this.searchText} onInput={this.handleInput.bind(this)} onFocus={() => (this.showDropdown = true)} />\n <button onClick={() => this.toggleDropdown()}>\n <img src={getAssetPath(`./assets/${this.searchIcon}`)} alt=\"dropdown icon\" class={this.showDropdown ? 'rotated' : ''} />\n </button>\n </div>\n\n {this.showDropdown && (\n <ul class=\"dropdown\">\n {this.filteredOptions.length > 0 ? (\n this.filteredOptions.map(option => (\n <li class={option.id === null ? 'default-option' : ''} onClick={() => this.selectOption({ key: option.name, value: option.id })}>\n {option.name}\n </li>\n ))\n ) : (\n <li class=\"no-results\">No results found</li>\n )}\n </ul>\n )}\n </div>\n );\n }\n}\n"],"version":3}
|
|
@@ -1,31 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
+
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
|
+
}
|
|
18
|
+
function debounce(func, wait) {
|
|
19
|
+
let timeout;
|
|
20
|
+
return function executedFunction(...args) {
|
|
21
|
+
const later = () => {
|
|
22
|
+
clearTimeout(timeout);
|
|
23
|
+
func(...args);
|
|
24
|
+
};
|
|
25
|
+
clearTimeout(timeout);
|
|
26
|
+
timeout = setTimeout(later, wait);
|
|
27
|
+
};
|
|
27
28
|
}
|
|
28
29
|
|
|
29
|
-
export {
|
|
30
|
+
export { debounce as d, isVeryLightColor as i };
|
|
30
31
|
|
|
31
32
|
//# sourceMappingURL=index6.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"index6.js","mappings":"
|
|
1
|
+
{"file":"index6.js","mappings":"AAAA;;;;;SAKgB,gBAAgB,CAAC,GAA8B;;EAC7D,MAAM,OAAO,GAAG,MAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,mCAAI,EAAE,CAAC;EAC5C,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;IAAE,OAAO,KAAK,CAAC;EAC/D,MAAM,KAAK,GAAG,OAAO,CAAC,MAAM,KAAK,CAAC,CAAC;EACnC,MAAM,CAAC,GAAG,QAAQ,CAAC,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC;EACpF,MAAM,CAAC,GAAG,QAAQ,CAAC,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC;EACpF,MAAM,CAAC,GAAG,QAAQ,CAAC,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC;EACpF,MAAM,SAAS,GAAG,KAAK,GAAG,CAAC,GAAG,KAAK,GAAG,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC;EACpD,OAAO,SAAS,GAAG,IAAI,CAAC;AAC1B,CAAC;SAEe,QAAQ,CAAC,IAA8B,EAAE,IAAY;EACnE,IAAI,OAAsC,CAAC;EAE3C,OAAO,SAAS,gBAAgB,CAAC,GAAG,IAAW;IAC7C,MAAM,KAAK,GAAG;MACZ,YAAY,CAAC,OAAO,CAAC,CAAC;MACtB,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;KACf,CAAC;IAEF,YAAY,CAAC,OAAO,CAAC,CAAC;IACtB,OAAO,GAAG,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;GACnC,CAAC;AACJ;;;;","names":[],"sources":["./src/utils/index.ts"],"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"],"version":3}
|
|
@@ -1,75 +1,31 @@
|
|
|
1
|
-
import { proxyCustomElement, HTMLElement
|
|
2
|
-
import { s as setDataLayer } from './gtmUtils.js';
|
|
3
|
-
import { a as APIURL, b as accessToken } from './index5.js';
|
|
1
|
+
import { proxyCustomElement, HTMLElement } from '@stencil/core/internal/client';
|
|
4
2
|
|
|
5
|
-
const indexCss = "@import url(\"https://fonts.googleapis.com/css2?family=Figtree:ital,wght@0,300..900;1,300..900&family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap\"); .tinting-wrapper *{font-family:\"Poppins\", sans-serif}
|
|
3
|
+
const indexCss = "@import url(\"https://fonts.googleapis.com/css2?family=Figtree:ital,wght@0,300..900;1,300..900&family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap\"); .tinting-wrapper *{font-family:\"Poppins\", sans-serif}my-backdrop{width:100%;height:100%;background-color:rgba(0, 0, 0, 0.7);position:fixed;z-index:100;left:0;top:0}";
|
|
6
4
|
|
|
7
|
-
const
|
|
5
|
+
const MyBackdrop = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
8
6
|
constructor() {
|
|
9
7
|
super();
|
|
10
8
|
this.__registerHost();
|
|
11
|
-
this.colorCheck = () => {
|
|
12
|
-
this.checkTimeout = setTimeout(() => {
|
|
13
|
-
setDataLayer({
|
|
14
|
-
event: 'ColorCheck',
|
|
15
|
-
shop: this.shop,
|
|
16
|
-
product: this.product,
|
|
17
|
-
color: this.name,
|
|
18
|
-
});
|
|
19
|
-
}, 2000);
|
|
20
|
-
};
|
|
21
|
-
this.colorUnCheck = () => {
|
|
22
|
-
if (this.checkTimeout)
|
|
23
|
-
clearTimeout(this.checkTimeout);
|
|
24
|
-
this.checkTimeout = undefined;
|
|
25
|
-
};
|
|
26
|
-
this.darkenColor = (color) => {
|
|
27
|
-
const red = parseInt(color[1] + color[2], 16) - 20;
|
|
28
|
-
const green = parseInt(color[3] + color[4], 16) - 20;
|
|
29
|
-
const blue = parseInt(color[5] + color[6], 16) - 20;
|
|
30
|
-
return `rgb(${red},${green},${blue})`;
|
|
31
|
-
};
|
|
32
|
-
this.color = undefined;
|
|
33
|
-
this.name = undefined;
|
|
34
|
-
this.shop = undefined;
|
|
35
|
-
this.product = undefined;
|
|
36
|
-
this.isActive = undefined;
|
|
37
|
-
this.isCategoryActive = undefined;
|
|
38
|
-
this.isImageInsteadHex = undefined;
|
|
39
9
|
}
|
|
40
10
|
render() {
|
|
41
|
-
|
|
42
|
-
return (h("div", { onMouseEnter: () => this.colorCheck(), onMouseLeave: () => this.colorUnCheck(), class: `my-color-box ${this.isActive ? 'active' : ''} ${this.isCategoryActive ? 'categoryactive' : ''}`, style: {
|
|
43
|
-
backgroundSize: ((_a = this.isImageInsteadHex) === null || _a === void 0 ? void 0 : _a.isImageInsteadHex) ? 'cover' : '',
|
|
44
|
-
backgroundImage: ((_b = this.isImageInsteadHex) === null || _b === void 0 ? void 0 : _b.isImageInsteadHex) ? `url(${APIURL}/assets/${this.isImageInsteadHex.bigImage}?access_token=${accessToken})` : '',
|
|
45
|
-
background: ((_c = this.isImageInsteadHex) === null || _c === void 0 ? void 0 : _c.isImageInsteadHex) ? this.isImageInsteadHex.bigImage : this.color,
|
|
46
|
-
border: this.isCategoryActive ? `5px solid ${this.darkenColor(this.color)}` : '',
|
|
47
|
-
} }, h("div", { class: "color-name" }, this.name)));
|
|
11
|
+
return null;
|
|
48
12
|
}
|
|
49
13
|
static get style() { return indexCss; }
|
|
50
|
-
}, [0, "my-
|
|
51
|
-
"color": [1],
|
|
52
|
-
"name": [1],
|
|
53
|
-
"shop": [1],
|
|
54
|
-
"product": [1],
|
|
55
|
-
"isActive": [4, "is-active"],
|
|
56
|
-
"isCategoryActive": [4, "is-category-active"],
|
|
57
|
-
"isImageInsteadHex": [16]
|
|
58
|
-
}]);
|
|
14
|
+
}, [0, "my-backdrop"]);
|
|
59
15
|
function defineCustomElement() {
|
|
60
16
|
if (typeof customElements === "undefined") {
|
|
61
17
|
return;
|
|
62
18
|
}
|
|
63
|
-
const components = ["my-
|
|
19
|
+
const components = ["my-backdrop"];
|
|
64
20
|
components.forEach(tagName => { switch (tagName) {
|
|
65
|
-
case "my-
|
|
21
|
+
case "my-backdrop":
|
|
66
22
|
if (!customElements.get(tagName)) {
|
|
67
|
-
customElements.define(tagName,
|
|
23
|
+
customElements.define(tagName, MyBackdrop);
|
|
68
24
|
}
|
|
69
25
|
break;
|
|
70
26
|
} });
|
|
71
27
|
}
|
|
72
28
|
|
|
73
|
-
export {
|
|
29
|
+
export { MyBackdrop as M, defineCustomElement as d };
|
|
74
30
|
|
|
75
31
|
//# sourceMappingURL=index7.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"index7.js","mappings":"
|
|
1
|
+
{"file":"index7.js","mappings":";;AAAA,MAAM,QAAQ,GAAG,6ZAA6Z;;MCMja,UAAU;;;;;EACrB,MAAM;IACJ,OAAO,IAAI,CAAC;GACb;;;;;;;;;;;;;;;;;;;","names":[],"sources":["./src/components/backdrop/index.scss?tag=my-backdrop","./src/components/backdrop/index.tsx"],"sourcesContent":["@import '../../global/app.scss';\n\nmy-backdrop {\n width: 100%;\n height: 100%;\n background-color: $backdrop_black;\n position: fixed;\n z-index: 100;\n left: 0;\n top: 0;\n}\n","import { Component } from '@stencil/core';\n\n@Component({\n tag: 'my-backdrop',\n styleUrl: 'index.scss',\n})\nexport class MyBackdrop {\n render() {\n return null;\n }\n}\n"],"version":3}
|
|
@@ -1,87 +1,92 @@
|
|
|
1
|
-
import { proxyCustomElement, HTMLElement,
|
|
1
|
+
import { proxyCustomElement, HTMLElement, h } from '@stencil/core/internal/client';
|
|
2
2
|
import { s as setDataLayer } from './gtmUtils.js';
|
|
3
|
+
import { i as isVeryLightColor } from './index6.js';
|
|
3
4
|
import { a as APIURL, b as accessToken } from './index5.js';
|
|
4
|
-
import { d as defineCustomElement$1 } from './index9.js';
|
|
5
5
|
|
|
6
|
-
const
|
|
6
|
+
const indexCss = "@import url(\"https://fonts.googleapis.com/css2?family=Figtree:ital,wght@0,300..900;1,300..900&family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap\"); .tinting-wrapper *{font-family:\"Poppins\", sans-serif}.my-color-box{width:125px;height:125px;display:block;margin-bottom:5px;cursor:pointer;display:flex;flex-direction:column;justify-content:flex-end;position:relative}@media (max-width: 1024px){.my-color-box{width:65px;height:65px}}.my-color-box .color-name{width:100%;background-color:#fff;padding:15px 0px 10px;border-top-left-radius:15px;border-top-right-radius:15px;opacity:0;transition:0.3s opacity ease-in-out;font-size:10px;color:#232323;text-transform:lowercase}.my-color-box.active .color-name{opacity:1}.my-color-box.categoryactive{width:120px;height:115px}.my-color-box.categoryactive .color-name{opacity:1}@media (max-width: 1024px){.my-color-box.categoryactive{width:72px;height:72px}}.my-color-box:hover .color-name{opacity:1}";
|
|
7
|
+
|
|
8
|
+
const MyColorBox = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
7
9
|
constructor() {
|
|
8
10
|
super();
|
|
9
11
|
this.__registerHost();
|
|
10
|
-
this.
|
|
11
|
-
|
|
12
|
-
this.goToProduct = () => {
|
|
13
|
-
var _a;
|
|
14
|
-
this.onCurrentColor.emit(this.currentColor);
|
|
15
|
-
this.currentColor &&
|
|
12
|
+
this.colorCheck = () => {
|
|
13
|
+
this.checkTimeout = setTimeout(() => {
|
|
16
14
|
setDataLayer({
|
|
17
|
-
event: '
|
|
15
|
+
event: 'ColorCheck',
|
|
18
16
|
shop: this.shop,
|
|
19
17
|
product: this.product,
|
|
20
|
-
color:
|
|
18
|
+
color: this.name,
|
|
21
19
|
});
|
|
22
|
-
|
|
20
|
+
}, 2000);
|
|
23
21
|
};
|
|
24
|
-
this.
|
|
25
|
-
this.
|
|
22
|
+
this.colorUnCheck = () => {
|
|
23
|
+
if (this.checkTimeout)
|
|
24
|
+
clearTimeout(this.checkTimeout);
|
|
25
|
+
this.checkTimeout = undefined;
|
|
26
26
|
};
|
|
27
|
-
this.
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
27
|
+
this.darkenColor = (color) => {
|
|
28
|
+
const red = parseInt(color[1] + color[2], 16) - 20;
|
|
29
|
+
const green = parseInt(color[3] + color[4], 16) - 20;
|
|
30
|
+
const blue = parseInt(color[5] + color[6], 16) - 20;
|
|
31
|
+
return `rgb(${red},${green},${blue})`;
|
|
32
|
+
};
|
|
33
|
+
this.isLightSwatch = () => { var _a; return !((_a = this.isImageInsteadHex) === null || _a === void 0 ? void 0 : _a.isImageInsteadHex) && isVeryLightColor(this.color); };
|
|
34
|
+
// Active category keeps its 5px solid border (all active swatches share it, so
|
|
35
|
+
// alignment is consistent). In the normal grid we use an inset box-shadow
|
|
36
|
+
// instead of a border so light swatches gain a visible edge without changing
|
|
37
|
+
// their box size and skewing the grid.
|
|
38
|
+
this.getBorder = () => {
|
|
39
|
+
if (!this.isCategoryActive)
|
|
40
|
+
return '';
|
|
41
|
+
return `5px solid ${this.isLightSwatch() ? '#d9d9d9' : this.darkenColor(this.color)}`;
|
|
35
42
|
};
|
|
36
|
-
this.
|
|
37
|
-
|
|
43
|
+
this.getBoxShadow = () => {
|
|
44
|
+
if (this.isCategoryActive)
|
|
45
|
+
return '';
|
|
46
|
+
return this.isLightSwatch() ? 'inset 0 0 0 1px #d9d9d9' : '';
|
|
38
47
|
};
|
|
39
|
-
this.
|
|
48
|
+
this.color = undefined;
|
|
49
|
+
this.name = undefined;
|
|
40
50
|
this.shop = undefined;
|
|
41
51
|
this.product = undefined;
|
|
42
|
-
this.
|
|
43
|
-
this.
|
|
44
|
-
this.
|
|
45
|
-
this.infoBoxWidth = undefined;
|
|
46
|
-
this.closeImage = 'close.png';
|
|
52
|
+
this.isActive = undefined;
|
|
53
|
+
this.isCategoryActive = undefined;
|
|
54
|
+
this.isImageInsteadHex = undefined;
|
|
47
55
|
}
|
|
48
56
|
render() {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
57
|
+
var _a, _b, _c;
|
|
58
|
+
return (h("div", { onMouseEnter: () => this.colorCheck(), onMouseLeave: () => this.colorUnCheck(), class: `my-color-box ${this.isActive ? 'active' : ''} ${this.isCategoryActive ? 'categoryactive' : ''}`, style: {
|
|
59
|
+
backgroundSize: ((_a = this.isImageInsteadHex) === null || _a === void 0 ? void 0 : _a.isImageInsteadHex) ? 'cover' : '',
|
|
60
|
+
backgroundImage: ((_b = this.isImageInsteadHex) === null || _b === void 0 ? void 0 : _b.isImageInsteadHex) ? `url(${APIURL}/assets/${this.isImageInsteadHex.bigImage}?access_token=${accessToken})` : '',
|
|
61
|
+
background: ((_c = this.isImageInsteadHex) === null || _c === void 0 ? void 0 : _c.isImageInsteadHex) ? this.isImageInsteadHex.bigImage : this.color,
|
|
62
|
+
border: this.getBorder(),
|
|
63
|
+
boxShadow: this.getBoxShadow(),
|
|
64
|
+
} }, h("div", { class: "color-name" }, this.name)));
|
|
55
65
|
}
|
|
56
|
-
|
|
57
|
-
|
|
66
|
+
static get style() { return indexCss; }
|
|
67
|
+
}, [0, "my-colorbox", {
|
|
68
|
+
"color": [1],
|
|
69
|
+
"name": [1],
|
|
58
70
|
"shop": [1],
|
|
59
71
|
"product": [1],
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"infoBoxWidth": [2, "info-box-width"],
|
|
64
|
-
"closeImage": [1, "close-image"]
|
|
72
|
+
"isActive": [4, "is-active"],
|
|
73
|
+
"isCategoryActive": [4, "is-category-active"],
|
|
74
|
+
"isImageInsteadHex": [16]
|
|
65
75
|
}]);
|
|
66
76
|
function defineCustomElement() {
|
|
67
77
|
if (typeof customElements === "undefined") {
|
|
68
78
|
return;
|
|
69
79
|
}
|
|
70
|
-
const components = ["my-
|
|
80
|
+
const components = ["my-colorbox"];
|
|
71
81
|
components.forEach(tagName => { switch (tagName) {
|
|
72
|
-
case "my-
|
|
73
|
-
if (!customElements.get(tagName)) {
|
|
74
|
-
customElements.define(tagName, MyColorInfo);
|
|
75
|
-
}
|
|
76
|
-
break;
|
|
77
|
-
case "my-slider":
|
|
82
|
+
case "my-colorbox":
|
|
78
83
|
if (!customElements.get(tagName)) {
|
|
79
|
-
|
|
84
|
+
customElements.define(tagName, MyColorBox);
|
|
80
85
|
}
|
|
81
86
|
break;
|
|
82
87
|
} });
|
|
83
88
|
}
|
|
84
89
|
|
|
85
|
-
export {
|
|
90
|
+
export { MyColorBox as M, defineCustomElement as d };
|
|
86
91
|
|
|
87
92
|
//# sourceMappingURL=index8.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"index8.js","mappings":";;;;;
|
|
1
|
+
{"file":"index8.js","mappings":";;;;;AAAA,MAAM,QAAQ,GAAG,+gCAA+gC;;MCUnhC,UAAU;;;;IAWrB,eAAU,GAAG;MACX,IAAI,CAAC,YAAY,GAAG,UAAU,CAAC;QAC7B,YAAY,CAAC;UACX,KAAK,EAAE,YAAY;UACnB,IAAI,EAAE,IAAI,CAAC,IAAI;UACf,OAAO,EAAE,IAAI,CAAC,OAAO;UACrB,KAAK,EAAE,IAAI,CAAC,IAAI;SACj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EF,MAAM;;IACJ,QACE,WACE,YAAY,EAAE,MAAM,IAAI,CAAC,UAAU,EAAE,EACrC,YAAY,EAAE,MAAM,IAAI,CAAC,YAAY,EAAE,EACvC,KAAK,EAAE,gBAAgB,IAAI,CAAC,QAAQ,GAAG,QAAQ,GAAG,EAAE,IAAI,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,GAAG,EAAE,EAAE,EACvG,KAAK,EAAE;QACL,cAAc,EAAE,CAAA,MAAA,IAAI,CAAC,iBAAiB,0CAAE,iBAAiB,IAAG,OAAO,GAAG,EAAE;QACxE,eAAe,EAAE,CAAA,MAAA,IAAI,CAAC,iBAAiB,0CAAE,iBAAiB,IAAG,OAAO,MAAM,WAAW,IAAI,CAAC,iBAAiB,CAAC,QAAQ,iBAAiB,WAAW,GAAG,GAAG,EAAE;QACxJ,UAAU,EAAE,CAAA,MAAA,IAAI,CAAC,iBAAiB,0CAAE,iBAAiB,IAAG,IAAI,CAAC,iBAAiB,CAAC,QAAQ,GAAG,IAAI,CAAC,KAAK;QACpG,MAAM,EAAE,IAAI,CAAC,SAAS,EAAE;QACxB,SAAS,EAAE,IAAI,CAAC,YAAY,EAAE;OAC/B,IAED,WAAK,KAAK,EAAC,YAAY,IAAE,IAAI,CAAC,IAAI,CAAO,CACrC,EACN;GACH;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":[],"sources":["./src/components/colorbox/index.scss?tag=my-colorbox","./src/components/colorbox/index.tsx"],"sourcesContent":["@import '../../global/app.scss';\n\n.my-color-box {\n width: 125px;\n height: 125px;\n display: block;\n margin-bottom: 5px;\n cursor: pointer;\n display: flex;\n flex-direction: column;\n justify-content: flex-end;\n position: relative;\n\n @media (max-width: $medium) {\n width: 65px;\n height: 65px;\n }\n .color-name {\n width: 100%;\n background-color: $white;\n padding: 15px 0px 10px;\n border-top-left-radius: 15px;\n border-top-right-radius: 15px;\n opacity: 0;\n transition: 0.3s opacity ease-in-out;\n font-size: 10px;\n color: $black;\n text-transform: lowercase;\n }\n &.active {\n .color-name {\n opacity: 1;\n }\n }\n\n &.categoryactive {\n width: 120px;\n height: 115px;\n .color-name {\n opacity: 1;\n }\n\n @media (max-width: $medium) {\n width: 72px;\n height: 72px;\n }\n }\n &:hover {\n .color-name {\n opacity: 1;\n }\n }\n}\n","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"],"version":3}
|