@ppg_pl/pallete 0.0.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.
Files changed (117) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +51 -0
  3. package/dist/cjs/index-f418fc60.js +1340 -0
  4. package/dist/cjs/index.cjs.js +2 -0
  5. package/dist/cjs/loader.cjs.js +21 -0
  6. package/dist/cjs/my-backdrop_8.cjs.entry.js +8109 -0
  7. package/dist/cjs/pallete.cjs.js +19 -0
  8. package/dist/collection/collection-manifest.json +19 -0
  9. package/dist/collection/components/api/index.js +19 -0
  10. package/dist/collection/components/api/services.js +81 -0
  11. package/dist/collection/components/my-backdrop/my-backdrop.css +21 -0
  12. package/dist/collection/components/my-backdrop/my-backdrop.js +13 -0
  13. package/dist/collection/components/my-colorbox/my-colorbox.css +60 -0
  14. package/dist/collection/components/my-colorbox/my-colorbox.js +145 -0
  15. package/dist/collection/components/my-colorinfo/my-colorinfo.js +197 -0
  16. package/dist/collection/components/my-component/my-component.css +18 -0
  17. package/dist/collection/components/my-component/my-component.js +106 -0
  18. package/dist/collection/components/my-loader/my-loader.css +85 -0
  19. package/dist/collection/components/my-loader/my-loader.js +18 -0
  20. package/dist/collection/components/my-modal/assets/arrow_down.png +0 -0
  21. package/dist/collection/components/my-modal/assets/close.png +0 -0
  22. package/dist/collection/components/my-modal/my-modal.css +323 -0
  23. package/dist/collection/components/my-modal/my-modal.js +430 -0
  24. package/dist/collection/components/my-search/assets/search.svg +15 -0
  25. package/dist/collection/components/my-search/my-search.css +43 -0
  26. package/dist/collection/components/my-search/my-search.js +112 -0
  27. package/dist/collection/components/my-slider/index.js +145 -0
  28. package/dist/collection/components/my-slider/my-slider.css +96 -0
  29. package/dist/collection/gtmUtils.js +3 -0
  30. package/dist/collection/index.js +1 -0
  31. package/dist/collection/types.js +1 -0
  32. package/dist/components/gtmUtils.js +5 -0
  33. package/dist/components/index.d.ts +29 -0
  34. package/dist/components/index.js +9 -0
  35. package/dist/components/index2.js +5458 -0
  36. package/dist/components/my-backdrop.d.ts +11 -0
  37. package/dist/components/my-backdrop.js +6 -0
  38. package/dist/components/my-backdrop2.js +29 -0
  39. package/dist/components/my-colorbox.d.ts +11 -0
  40. package/dist/components/my-colorbox.js +6 -0
  41. package/dist/components/my-colorbox2.js +61 -0
  42. package/dist/components/my-colorinfo.d.ts +11 -0
  43. package/dist/components/my-colorinfo.js +6 -0
  44. package/dist/components/my-colorinfo2.js +64 -0
  45. package/dist/components/my-component.d.ts +11 -0
  46. package/dist/components/my-component.js +216 -0
  47. package/dist/components/my-loader.d.ts +11 -0
  48. package/dist/components/my-loader.js +6 -0
  49. package/dist/components/my-loader2.js +29 -0
  50. package/dist/components/my-modal.d.ts +11 -0
  51. package/dist/components/my-modal.js +6 -0
  52. package/dist/components/my-modal2.js +2451 -0
  53. package/dist/components/my-search.d.ts +11 -0
  54. package/dist/components/my-search.js +6 -0
  55. package/dist/components/my-search2.js +55 -0
  56. package/dist/components/my-slider.d.ts +11 -0
  57. package/dist/components/my-slider.js +6 -0
  58. package/dist/esm/index-367ea408.js +1312 -0
  59. package/dist/esm/index.js +1 -0
  60. package/dist/esm/loader.js +17 -0
  61. package/dist/esm/my-backdrop_8.entry.js +8098 -0
  62. package/dist/esm/pallete.js +17 -0
  63. package/dist/esm/polyfills/core-js.js +11 -0
  64. package/dist/esm/polyfills/css-shim.js +1 -0
  65. package/dist/esm/polyfills/dom.js +79 -0
  66. package/dist/esm/polyfills/es5-html-element.js +1 -0
  67. package/dist/esm/polyfills/index.js +34 -0
  68. package/dist/esm/polyfills/system.js +6 -0
  69. package/dist/index.cjs.js +1 -0
  70. package/dist/index.js +1 -0
  71. package/dist/pallete/assets/arrow_down.png +0 -0
  72. package/dist/pallete/assets/close.png +0 -0
  73. package/dist/pallete/assets/search.svg +15 -0
  74. package/dist/pallete/index.esm.js +0 -0
  75. package/dist/pallete/p-02fc334c.js +2 -0
  76. package/dist/pallete/p-9f47a4e8.entry.js +1 -0
  77. package/dist/pallete/pallete.css +1 -0
  78. package/dist/pallete/pallete.esm.js +1 -0
  79. package/dist/types/components/api/index.d.ts +6 -0
  80. package/dist/types/components/api/services.d.ts +4 -0
  81. package/dist/types/components/my-backdrop/my-backdrop.d.ts +3 -0
  82. package/dist/types/components/my-colorbox/my-colorbox.d.ts +13 -0
  83. package/dist/types/components/my-colorinfo/my-colorinfo.d.ts +15 -0
  84. package/dist/types/components/my-component/my-component.d.ts +9 -0
  85. package/dist/types/components/my-loader/my-loader.d.ts +3 -0
  86. package/dist/types/components/my-modal/my-modal.d.ts +56 -0
  87. package/dist/types/components/my-search/my-search.d.ts +12 -0
  88. package/dist/types/components/my-slider/index.d.ts +15 -0
  89. package/dist/types/components.d.ts +198 -0
  90. package/dist/types/gtmUtils.d.ts +1 -0
  91. package/dist/types/index.d.ts +1 -0
  92. package/dist/types/stencil-public-runtime.d.ts +1565 -0
  93. package/dist/types/types.d.ts +56 -0
  94. package/loader/cdn.js +3 -0
  95. package/loader/index.cjs.js +3 -0
  96. package/loader/index.d.ts +12 -0
  97. package/loader/index.es2017.js +3 -0
  98. package/loader/index.js +4 -0
  99. package/loader/package.json +10 -0
  100. package/package.json +49 -0
  101. package/www/build/assets/arrow_down.png +0 -0
  102. package/www/build/assets/close.png +0 -0
  103. package/www/build/assets/fonts/Galatea-Regular.eot +0 -0
  104. package/www/build/assets/fonts/Galatea-Regular.ttf +0 -0
  105. package/www/build/assets/fonts/Galatea-Regular.woff +0 -0
  106. package/www/build/assets/fonts/Galatea-Regular.woff2 +0 -0
  107. package/www/build/assets/search.svg +15 -0
  108. package/www/build/index.esm.js +0 -0
  109. package/www/build/p-02fc334c.js +2 -0
  110. package/www/build/p-95e95ceb.css +1 -0
  111. package/www/build/p-9f47a4e8.entry.js +1 -0
  112. package/www/build/p-b0b8b976.js +1 -0
  113. package/www/build/pallete.css +1 -0
  114. package/www/build/pallete.esm.js +1 -0
  115. package/www/build/pallete.js +33 -0
  116. package/www/host.config.json +15 -0
  117. package/www/index.html +22 -0
@@ -0,0 +1,430 @@
1
+ import { Component, Method, Element, Prop, Event, h, State, getAssetPath, Listen, Watch } from '@stencil/core';
2
+ import { ApiService } from '../api';
3
+ import { setDataLayer } from '../../gtmUtils';
4
+ import { fetchCategoryColorsQuery, fetchColorByNumber, fetchProductColorsQuery } from '../api/services';
5
+ export class MyModal {
6
+ constructor() {
7
+ this.boxDesktopWidth = 130;
8
+ this.boxMobileWidth = 85;
9
+ this.desktopPadding = 75;
10
+ this.mobilePadding = 35;
11
+ this.mediumBreakpoint = 1024;
12
+ this.closeImage = 'close.png';
13
+ this.arrowDown = 'arrow_down.png';
14
+ this.chunksNum = 12;
15
+ this.data = null;
16
+ this.preloader = false;
17
+ this.loading = false;
18
+ this.colors = null;
19
+ this.currentColor = null;
20
+ this.currentIndex = null;
21
+ this.infoBoxWidth = null;
22
+ this.boxWidth = this.boxDesktopWidth; // box width with gap
23
+ this.padding = this.desktopPadding;
24
+ this.isMobile = false;
25
+ this.showRange = false;
26
+ this.colorCategories = null;
27
+ this.selectedCategory = null;
28
+ this.page = 1;
29
+ this.clearInterval = () => {
30
+ this.colorTimerInterval && clearInterval(this.colorTimerInterval);
31
+ this.colorTimerInterval = undefined;
32
+ };
33
+ this.colorTimer = () => {
34
+ if (this.currentColor && this.currentColor.id) {
35
+ this.colorTimerInterval = setInterval(() => {
36
+ var _a, _b;
37
+ ((_a = this.currentColor) === null || _a === void 0 ? void 0 : _a.name) &&
38
+ setDataLayer({
39
+ event: 'ColorTimer',
40
+ shop: this.shop,
41
+ product: this.product,
42
+ color: (_b = this.currentColor) === null || _b === void 0 ? void 0 : _b.name,
43
+ timer: '10',
44
+ });
45
+ }, 10000);
46
+ }
47
+ else {
48
+ this.clearInterval();
49
+ }
50
+ };
51
+ this.chunks = (xs, y = []) => {
52
+ return xs.length === 0 ? y : this.chunks(xs.slice(this.chunksNum), y.concat([xs.slice(0, this.chunksNum)]));
53
+ };
54
+ this.calculateBoxCount = () => {
55
+ var _a;
56
+ const modalWidth = this.modalEl.children && this.modalEl.children[0] && ((_a = this.modalEl.children[0]) === null || _a === void 0 ? void 0 : _a.clientWidth) - this.padding;
57
+ const boxWidth = this.boxWidth;
58
+ const calc = Math.floor(modalWidth / boxWidth);
59
+ const boxesCount = calc;
60
+ if (!this.preloader)
61
+ this.chunksNum = boxesCount;
62
+ };
63
+ this.displayForMobile = () => {
64
+ if (window.innerWidth < this.mediumBreakpoint) {
65
+ this.boxWidth = this.boxMobileWidth;
66
+ this.padding = this.mobilePadding;
67
+ this.isMobile = true;
68
+ }
69
+ else {
70
+ this.isMobile = false;
71
+ this.boxWidth = this.boxDesktopWidth;
72
+ this.padding = this.desktopPadding;
73
+ }
74
+ };
75
+ this.fetchProductData = async () => {
76
+ try {
77
+ const response = await ApiService.getData(`products?populate[0]=modalLogo&populate[1]=images&populate[2]=shops&populate[3]=categories&filters[name][$contains]=${this.product}`);
78
+ if (response) {
79
+ if (response.data[0].attributes.shops.data.find((shop) => shop.attributes.name === this.shop).id) {
80
+ this.data = Object.assign(Object.assign({}, response.data[0].attributes), { id: response.data[0].id });
81
+ }
82
+ }
83
+ }
84
+ catch (error) {
85
+ console.error(error);
86
+ }
87
+ finally {
88
+ this.preloader = false;
89
+ }
90
+ };
91
+ // TODO:
92
+ this.fetchProductColors = async (id, page) => {
93
+ this.loading = true;
94
+ try {
95
+ const response = await ApiService.getData(`colors?${fetchProductColorsQuery(id, page)}`);
96
+ if (response) {
97
+ this.colors = {
98
+ list: response &&
99
+ response.data &&
100
+ response.data.map((item) => (Object.assign({ id: item.id }, item.attributes))),
101
+ pagination: response.meta.pagination,
102
+ };
103
+ }
104
+ }
105
+ catch (error) {
106
+ console.error(error);
107
+ }
108
+ finally {
109
+ this.loading = false;
110
+ }
111
+ };
112
+ this.fetchCategoryColors = async (color) => {
113
+ this.loading = true;
114
+ try {
115
+ const response = await ApiService.getData(`colors?${fetchCategoryColorsQuery(color)}`);
116
+ if (response) {
117
+ this.colors = {
118
+ list: response &&
119
+ response.data &&
120
+ response.data.map((item) => (Object.assign({ id: item.id }, item.attributes))),
121
+ pagination: response.meta.pagination,
122
+ };
123
+ }
124
+ }
125
+ catch (error) {
126
+ console.error(error);
127
+ }
128
+ finally {
129
+ this.loading = false;
130
+ }
131
+ };
132
+ // private onIntersection = async (entries: any) => {
133
+ // console.log(entries[0]);
134
+ // if (entries[0].intersectionRatio === 0) {
135
+ // console.log('d');
136
+ // }
137
+ // };
138
+ // private handleObserve = () => {
139
+ // console.log(this.modalEl.shadowRoot);
140
+ // const boxesList: any = (this.modalEl as any).querySelector('.my-modal__wrapper');
141
+ // console.log(boxesList);
142
+ // if (boxesList) {
143
+ // this.observer = new IntersectionObserver(this.onIntersection);
144
+ // this.observer.observe(boxesList);
145
+ // }
146
+ // };
147
+ this.onPage = (page) => {
148
+ this.data && this.fetchProductColors(String(this.data.id), page);
149
+ this.page = page;
150
+ this.currentColor = null;
151
+ this.currentIndex = null;
152
+ };
153
+ this.handleCategoryClick = (color) => {
154
+ if (this.selectedCategory && color && this.selectedCategory.id === color.id && !this.showRange) {
155
+ this.data && this.fetchProductColors(String(this.data.id));
156
+ this.selectedCategory = null;
157
+ }
158
+ else {
159
+ color && this.fetchCategoryColors(color);
160
+ this.selectedCategory = color;
161
+ }
162
+ this.currentColor = null;
163
+ };
164
+ }
165
+ setInfoBoxWidth(newValue) {
166
+ this.infoBoxWidth = newValue * this.boxWidth;
167
+ }
168
+ watchPropHandler(newValue) {
169
+ if (newValue.categories.data.length > 0) {
170
+ this.showRange = true;
171
+ this.handleCategoryClick(newValue.categories.data[0]);
172
+ }
173
+ else {
174
+ this.fetchProductColors(String(newValue.id));
175
+ }
176
+ }
177
+ async open() {
178
+ this.modalEl.style.display = 'block';
179
+ }
180
+ closeModalHandler() {
181
+ this.close.emit();
182
+ }
183
+ closeInfoBoxHandler() {
184
+ this.currentColor = null;
185
+ this.currentIndex = null;
186
+ }
187
+ handleResize() {
188
+ this.calculateBoxCount();
189
+ this.displayForMobile();
190
+ }
191
+ async searchColorsHandler(event) {
192
+ var _a;
193
+ // if search is empty set to first category to not showing whole product colors
194
+ if (event.detail === '') {
195
+ this.handleCategoryClick((_a = this.data) === null || _a === void 0 ? void 0 : _a.categories.data[0]);
196
+ }
197
+ try {
198
+ if (this.data && this.data.id && event.detail !== '') {
199
+ this.selectedCategory = null;
200
+ const response = await ApiService.getData(`colors?${fetchColorByNumber(Number(this.data.id), event.detail)}`);
201
+ if (response) {
202
+ this.colors = {
203
+ list: response &&
204
+ response.data &&
205
+ response.data.map((item) => (Object.assign({ id: item.id }, item.attributes))),
206
+ pagination: response.meta.pagination,
207
+ };
208
+ }
209
+ }
210
+ }
211
+ catch (error) {
212
+ console.error(error);
213
+ }
214
+ }
215
+ componentWillLoad() {
216
+ this.preloader = true;
217
+ this.fetchProductData();
218
+ }
219
+ componentWillRender() {
220
+ this.displayForMobile();
221
+ this.calculateBoxCount();
222
+ this.colorTimer();
223
+ }
224
+ render() {
225
+ var _a, _b, _c, _d, _e, _f, _g;
226
+ return (h("div", { class: `my-modal` },
227
+ this.preloader && (h("div", { class: 'loader' },
228
+ h("my-loader", null))),
229
+ !this.preloader && (h("button", { class: "my-modal__close", onClick: () => this.closeModalHandler() },
230
+ h("img", { src: getAssetPath(`./assets/${this.closeImage}`), alt: "closebtn" }))),
231
+ !this.preloader && this.data && this.data.modalLogo && h("img", { src: `${(_d = (_c = (_b = (_a = this.data) === null || _a === void 0 ? void 0 : _a.modalLogo) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.attributes) === null || _d === void 0 ? void 0 : _d.url}`, alt: "modal-logo" }),
232
+ !this.preloader && (h("p", { class: "my-modal__see-more" }, (_e = this.data) === null || _e === void 0 ? void 0 : _e.modalDescription)),
233
+ this.showRange && (h("div", { class: 'categories' },
234
+ this.data && h("my-search", { productId: Number((_f = this.data) === null || _f === void 0 ? void 0 : _f.id), isMobile: this.isMobile }),
235
+ h("div", { class: 'categories__container', style: { maxWidth: `${this.infoBoxWidth}px` } }, (_g = this.data) === null || _g === void 0 ? void 0 : _g.categories.data.map((c) => {
236
+ var _a;
237
+ return (h("my-colorbox", { key: c.id, onClick: () => this.handleCategoryClick(c), color: c.attributes.hex, name: c.attributes.name, shop: this.shop, product: this.product, isCategoryActive: ((_a = this.selectedCategory) === null || _a === void 0 ? void 0 : _a.id) === c.id }));
238
+ })),
239
+ this.isMobile && (h("div", { class: 'categories__slide-information', style: { width: `${this.infoBoxWidth}px` } },
240
+ h("span", null, "Przewi\u0144 w lewo"),
241
+ h("span", null, "Przewi\u0144 w prawo"))))),
242
+ h("div", { class: 'my-modal__wrapper' },
243
+ this.loading && h("my-loader", null),
244
+ !this.loading && this.colors && (h("div", { class: 'container_boxes' },
245
+ this.colors.list.length > 0 ? (this.chunks(this.colors.list).map((color, index) => {
246
+ var _a;
247
+ return (h("div", { key: index, class: "boxes" },
248
+ h("div", { class: "boxes__list" }, color.map((c) => {
249
+ var _a;
250
+ return (h("my-colorbox", { key: c.id, onClick: () => {
251
+ var _a, _b, _c;
252
+ return [
253
+ ((_a = this.currentColor) === null || _a === void 0 ? void 0 : _a.id) ? (((_b = this.currentColor) === null || _b === void 0 ? void 0 : _b.id) === c.id ? (this.currentColor = null) : (this.currentColor = c)) : (this.currentColor = c),
254
+ (this.currentIndex = index),
255
+ setDataLayer({
256
+ event: 'ColorClick',
257
+ shop: this.shop,
258
+ product: this.product,
259
+ color: c.name,
260
+ }),
261
+ ((_c = this.currentColor) === null || _c === void 0 ? void 0 : _c.id) && this.clearInterval(),
262
+ ];
263
+ }, color: c.hex, name: c.name, isActive: ((_a = this.currentColor) === null || _a === void 0 ? void 0 : _a.id) === c.id, shop: this.shop, product: this.product }));
264
+ })),
265
+ ((_a = this.currentColor) === null || _a === void 0 ? void 0 : _a.id) && index === this.currentIndex && (h("my-colorinfo", { currentColor: this.currentColor, shop: this.shop, product: this.product, data: this.data, isMobile: this.isMobile, infoBoxWidth: this.infoBoxWidth }))));
266
+ })) : (h("p", null, "Brak wynik\u00F3w")),
267
+ this.colors.pagination.pageCount > 1 && (h("div", { class: 'pagination' }, Array.from({ length: this.colors.pagination.pageCount }).map((page, i) => (h("span", { class: i + 1 === this.page ? 'current' : '', onClick: e => {
268
+ e.preventDefault();
269
+ this.onPage(i + 1);
270
+ }, key: `#${i + 1 + page}` }, i + 1))))))))));
271
+ }
272
+ static get is() { return "my-modal"; }
273
+ static get originalStyleUrls() { return {
274
+ "$": ["my-modal.scss"]
275
+ }; }
276
+ static get styleUrls() { return {
277
+ "$": ["my-modal.css"]
278
+ }; }
279
+ static get assetsDirs() { return ["assets"]; }
280
+ static get properties() { return {
281
+ "shop": {
282
+ "type": "string",
283
+ "mutable": false,
284
+ "complexType": {
285
+ "original": "string",
286
+ "resolved": "string",
287
+ "references": {}
288
+ },
289
+ "required": false,
290
+ "optional": false,
291
+ "docs": {
292
+ "tags": [],
293
+ "text": ""
294
+ },
295
+ "attribute": "shop",
296
+ "reflect": false
297
+ },
298
+ "product": {
299
+ "type": "string",
300
+ "mutable": false,
301
+ "complexType": {
302
+ "original": "string",
303
+ "resolved": "string",
304
+ "references": {}
305
+ },
306
+ "required": false,
307
+ "optional": false,
308
+ "docs": {
309
+ "tags": [],
310
+ "text": ""
311
+ },
312
+ "attribute": "product",
313
+ "reflect": false
314
+ },
315
+ "closeImage": {
316
+ "type": "string",
317
+ "mutable": false,
318
+ "complexType": {
319
+ "original": "string",
320
+ "resolved": "string",
321
+ "references": {}
322
+ },
323
+ "required": false,
324
+ "optional": false,
325
+ "docs": {
326
+ "tags": [],
327
+ "text": ""
328
+ },
329
+ "attribute": "close-image",
330
+ "reflect": false,
331
+ "defaultValue": "'close.png'"
332
+ },
333
+ "arrowDown": {
334
+ "type": "string",
335
+ "mutable": false,
336
+ "complexType": {
337
+ "original": "string",
338
+ "resolved": "string",
339
+ "references": {}
340
+ },
341
+ "required": false,
342
+ "optional": false,
343
+ "docs": {
344
+ "tags": [],
345
+ "text": ""
346
+ },
347
+ "attribute": "arrow-down",
348
+ "reflect": false,
349
+ "defaultValue": "'arrow_down.png'"
350
+ }
351
+ }; }
352
+ static get states() { return {
353
+ "chunksNum": {},
354
+ "data": {},
355
+ "preloader": {},
356
+ "loading": {},
357
+ "colors": {},
358
+ "currentColor": {},
359
+ "currentIndex": {},
360
+ "infoBoxWidth": {},
361
+ "boxWidth": {},
362
+ "padding": {},
363
+ "isMobile": {},
364
+ "showRange": {},
365
+ "colorCategories": {},
366
+ "selectedCategory": {},
367
+ "page": {}
368
+ }; }
369
+ static get events() { return [{
370
+ "method": "close",
371
+ "name": "close",
372
+ "bubbles": true,
373
+ "cancelable": true,
374
+ "composed": true,
375
+ "docs": {
376
+ "tags": [],
377
+ "text": ""
378
+ },
379
+ "complexType": {
380
+ "original": "any",
381
+ "resolved": "any",
382
+ "references": {}
383
+ }
384
+ }]; }
385
+ static get methods() { return {
386
+ "open": {
387
+ "complexType": {
388
+ "signature": "() => Promise<void>",
389
+ "parameters": [],
390
+ "references": {
391
+ "Promise": {
392
+ "location": "global"
393
+ }
394
+ },
395
+ "return": "Promise<void>"
396
+ },
397
+ "docs": {
398
+ "text": "",
399
+ "tags": []
400
+ }
401
+ }
402
+ }; }
403
+ static get elementRef() { return "modalEl"; }
404
+ static get watchers() { return [{
405
+ "propName": "chunksNum",
406
+ "methodName": "setInfoBoxWidth"
407
+ }, {
408
+ "propName": "data",
409
+ "methodName": "watchPropHandler"
410
+ }]; }
411
+ static get listeners() { return [{
412
+ "name": "closeInfoBox",
413
+ "method": "closeInfoBoxHandler",
414
+ "target": undefined,
415
+ "capture": false,
416
+ "passive": false
417
+ }, {
418
+ "name": "resize",
419
+ "method": "handleResize",
420
+ "target": "window",
421
+ "capture": false,
422
+ "passive": true
423
+ }, {
424
+ "name": "searchColors",
425
+ "method": "searchColorsHandler",
426
+ "target": undefined,
427
+ "capture": false,
428
+ "passive": false
429
+ }]; }
430
+ }
@@ -0,0 +1,15 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <svg width="21px" height="21px" viewBox="0 0 21 21" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
3
+ <title>search (1)</title>
4
+ <g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
5
+ <g id="E_TT-Copy" transform="translate(-670.000000, -275.000000)" fill="#000000" fill-rule="nonzero">
6
+ <g id="Group-11" transform="translate(240.477268, 115.000000)">
7
+ <g id="Group-18" transform="translate(38.010142, 143.000000)">
8
+ <g id="search-(1)" transform="translate(392.266523, 17.349138)">
9
+ <path d="M8.04938507,16.0918365 C9.8370154,16.0918798 11.5735099,15.4954541 12.9838185,14.3969873 L18.3044575,19.7176263 C18.7019302,20.1014916 19.3352777,20.0904844 19.719143,19.6930117 C20.0936046,19.3052895 20.0936046,18.6906196 19.719143,18.3029407 L14.3985041,12.9823018 C17.12426,9.47351771 16.4895258,4.41943508 12.9807417,1.69367909 C9.47195764,-1.03207689 4.41791834,-0.397342671 1.69216235,3.11144142 C-1.03359363,6.62022552 -0.398859411,11.6743081 3.10992468,14.4000641 C4.5225301,15.4974475 6.26058468,16.0927465 8.04938507,16.0918365 Z M3.77430035,3.77274027 C6.13538859,1.4116087 9.96346822,1.41156536 12.3245998,3.7726536 C14.6857314,6.13374184 14.6857747,9.96182148 12.3246865,12.3229531 C9.96359823,14.6840846 6.1355186,14.684128 3.77438702,12.3230397 C3.77434368,12.3229964 3.77434368,12.3229964 3.77430035,12.3229531 C1.41321211,9.97906898 1.39930143,6.16494336 3.7431855,3.80385512 C3.75354267,3.79345461 3.76389984,3.78309744 3.77430035,3.77274027 Z" id="Shape"></path>
10
+ </g>
11
+ </g>
12
+ </g>
13
+ </g>
14
+ </g>
15
+ </svg>
@@ -0,0 +1,43 @@
1
+ html {
2
+ font-size: 62.5%;
3
+ }
4
+
5
+ body {
6
+ font-size: 1.5rem;
7
+ }
8
+
9
+ * {
10
+ font-family: "Galatea", sans-serif;
11
+ }
12
+
13
+ .search {
14
+ position: relative;
15
+ width: 400px;
16
+ }
17
+ @media (max-width: 768px) {
18
+ .search {
19
+ width: 100%;
20
+ }
21
+ }
22
+ .search input {
23
+ margin-bottom: 12px;
24
+ font-size: 1.6rem;
25
+ padding: 19px;
26
+ border-radius: 27.35px;
27
+ border: 1px solid #dfdfdf;
28
+ width: 100%;
29
+ }
30
+ .search button {
31
+ position: absolute;
32
+ border: none;
33
+ background-color: transparent;
34
+ right: -20px;
35
+ top: 0;
36
+ width: 50px;
37
+ height: calc(100% - 12px);
38
+ display: flex;
39
+ flex-direction: column;
40
+ align-items: center;
41
+ justify-content: center;
42
+ cursor: pointer;
43
+ }
@@ -0,0 +1,112 @@
1
+ import { Component, Prop, h, State, getAssetPath, Event, Watch } from '@stencil/core';
2
+ export class MySearch {
3
+ constructor() {
4
+ this.searchIcon = 'search.svg';
5
+ this.searchText = null;
6
+ this.fetchColorsByName = (text) => {
7
+ this.searchColors.emit(text);
8
+ };
9
+ }
10
+ onInputChangeValue(event) {
11
+ const value = event.target.value;
12
+ this.searchColors.emit(value);
13
+ this.searchText = value;
14
+ }
15
+ fetchColorsByNameHandle(newValue) {
16
+ this.fetchColorsByName(newValue);
17
+ }
18
+ render() {
19
+ return (h("div", { class: 'search' },
20
+ h("input", { placeholder: this.isMobile ? 'Wyszukaj kolor' : 'Wyszukaj kolor po nazwie bądź numerze', value: this.searchText || '', type: "text", onInput: this.onInputChangeValue.bind(this) }),
21
+ h("button", { onClick: () => {
22
+ this.searchText && this.fetchColorsByName(this.searchText);
23
+ this.searchText = '';
24
+ } },
25
+ h("img", { src: getAssetPath(`./assets/${this.searchIcon}`), alt: "arrow_down" }))));
26
+ }
27
+ static get is() { return "my-search"; }
28
+ static get originalStyleUrls() { return {
29
+ "$": ["my-search.scss"]
30
+ }; }
31
+ static get styleUrls() { return {
32
+ "$": ["my-search.css"]
33
+ }; }
34
+ static get assetsDirs() { return ["assets"]; }
35
+ static get properties() { return {
36
+ "productId": {
37
+ "type": "number",
38
+ "mutable": false,
39
+ "complexType": {
40
+ "original": "number",
41
+ "resolved": "number",
42
+ "references": {}
43
+ },
44
+ "required": false,
45
+ "optional": false,
46
+ "docs": {
47
+ "tags": [],
48
+ "text": ""
49
+ },
50
+ "attribute": "product-id",
51
+ "reflect": false
52
+ },
53
+ "isMobile": {
54
+ "type": "boolean",
55
+ "mutable": false,
56
+ "complexType": {
57
+ "original": "boolean",
58
+ "resolved": "boolean",
59
+ "references": {}
60
+ },
61
+ "required": false,
62
+ "optional": false,
63
+ "docs": {
64
+ "tags": [],
65
+ "text": ""
66
+ },
67
+ "attribute": "is-mobile",
68
+ "reflect": false
69
+ },
70
+ "searchIcon": {
71
+ "type": "string",
72
+ "mutable": false,
73
+ "complexType": {
74
+ "original": "string",
75
+ "resolved": "string",
76
+ "references": {}
77
+ },
78
+ "required": false,
79
+ "optional": false,
80
+ "docs": {
81
+ "tags": [],
82
+ "text": ""
83
+ },
84
+ "attribute": "search-icon",
85
+ "reflect": false,
86
+ "defaultValue": "'search.svg'"
87
+ }
88
+ }; }
89
+ static get states() { return {
90
+ "searchText": {}
91
+ }; }
92
+ static get events() { return [{
93
+ "method": "searchColors",
94
+ "name": "searchColors",
95
+ "bubbles": true,
96
+ "cancelable": true,
97
+ "composed": true,
98
+ "docs": {
99
+ "tags": [],
100
+ "text": ""
101
+ },
102
+ "complexType": {
103
+ "original": "any",
104
+ "resolved": "any",
105
+ "references": {}
106
+ }
107
+ }]; }
108
+ static get watchers() { return [{
109
+ "propName": "searchText",
110
+ "methodName": "fetchColorsByNameHandle"
111
+ }]; }
112
+ }