@geotrekce/geotrek-rando-widget 0.0.1 → 0.0.4

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 (87) hide show
  1. package/dist/cjs/geotrek-rando-widget.cjs.js +2 -2
  2. package/dist/cjs/{grw-app_7.cjs.entry.js → grw-app_11.cjs.entry.js} +513 -89
  3. package/dist/cjs/{index-31255e29.js → index-c2c4531d.js} +82 -1
  4. package/dist/cjs/loader.cjs.js +2 -2
  5. package/dist/collection/assets/departure-arrival.svg +1 -1
  6. package/dist/collection/collection-manifest.json +4 -0
  7. package/dist/collection/components/grw-app/grw-app.css +127 -39
  8. package/dist/collection/components/grw-app/grw-app.js +375 -18
  9. package/dist/collection/components/grw-filter/grw-filter.css +29 -0
  10. package/dist/collection/components/grw-filter/grw-filter.js +132 -0
  11. package/dist/collection/components/grw-information-desk-detail/grw-information-desk-detail.css +30 -0
  12. package/dist/collection/components/grw-information-desk-detail/grw-information-desk-detail.js +53 -0
  13. package/dist/collection/components/grw-map/grw-map.css +117 -0
  14. package/dist/collection/components/grw-map/grw-map.js +409 -40
  15. package/dist/collection/components/grw-poi-detail/grw-poi-detail.css +30 -0
  16. package/dist/collection/components/grw-poi-detail/grw-poi-detail.js +41 -0
  17. package/dist/collection/components/grw-sensitive-area-detail/grw-sensitive-area-detail.css +16 -0
  18. package/dist/collection/components/grw-sensitive-area-detail/grw-sensitive-area-detail.js +38 -0
  19. package/dist/collection/components/grw-trek-card/grw-trek-card.css +67 -30
  20. package/dist/collection/components/grw-trek-card/grw-trek-card.js +112 -33
  21. package/dist/collection/components/grw-trek-detail/grw-trek-detail.css +36 -1
  22. package/dist/collection/components/grw-trek-detail/grw-trek-detail.js +122 -33
  23. package/dist/collection/components/grw-treks-list/grw-treks-list.css +17 -12
  24. package/dist/collection/components/grw-treks-list/grw-treks-list.js +70 -6
  25. package/dist/collection/store/grw-trek-provider.js +50 -8
  26. package/dist/collection/store/grw-treks-provider.js +166 -11
  27. package/dist/collection/store/store.js +6 -0
  28. package/dist/collection/stories/App.js +39 -3
  29. package/dist/collection/stories/App.stories.js +30 -5
  30. package/dist/collection/stories/TrekCard.js +9 -3
  31. package/dist/collection/stories/TrekCard.stories.js +5 -2
  32. package/dist/collection/stories/TrekDetail.js +10 -3
  33. package/dist/collection/stories/TrekDetail.stories.js +6 -2
  34. package/dist/collection/stories/TrekMap.js +15 -6
  35. package/dist/collection/stories/TrekMap.stories.js +21 -6
  36. package/dist/collection/stories/TreksList.js +17 -3
  37. package/dist/collection/stories/TreksList.stories.js +13 -2
  38. package/dist/collection/stories/TreksMap.js +12 -3
  39. package/dist/collection/stories/TreksMap.stories.js +18 -3
  40. package/dist/collection/utils/utils.js +2 -2
  41. package/dist/components/grw-app.js +79 -9
  42. package/dist/components/grw-filter.d.ts +11 -0
  43. package/dist/components/grw-filter.js +6 -0
  44. package/dist/components/grw-filter2.js +95 -0
  45. package/dist/components/grw-information-desk-detail.d.ts +11 -0
  46. package/dist/components/grw-information-desk-detail.js +6 -0
  47. package/dist/components/grw-information-desk-detail2.js +34 -0
  48. package/dist/components/grw-map2.js +260 -43
  49. package/dist/components/grw-poi-detail.d.ts +11 -0
  50. package/dist/components/grw-poi-detail.js +6 -0
  51. package/dist/components/grw-poi-detail2.js +32 -0
  52. package/dist/components/grw-sensitive-area-detail.d.ts +11 -0
  53. package/dist/components/grw-sensitive-area-detail.js +6 -0
  54. package/dist/components/grw-sensitive-area-detail2.js +32 -0
  55. package/dist/components/grw-trek-card2.js +33 -10
  56. package/dist/components/grw-trek-detail2.js +47 -9
  57. package/dist/components/grw-trek-provider2.js +32 -9
  58. package/dist/components/grw-treks-list2.js +15 -6
  59. package/dist/components/grw-treks-provider2.js +37 -13
  60. package/dist/components/length.js +2 -2
  61. package/dist/components/store.js +6 -0
  62. package/dist/esm/geotrek-rando-widget.js +2 -2
  63. package/dist/esm/{grw-app_7.entry.js → grw-app_11.entry.js} +510 -90
  64. package/dist/esm/{index-b36f38f5.js → index-fe16e7b6.js} +82 -1
  65. package/dist/esm/loader.js +2 -2
  66. package/dist/geotrek-rando-widget/geotrek-rando-widget.css +1 -1
  67. package/dist/geotrek-rando-widget/geotrek-rando-widget.esm.js +1 -1
  68. package/dist/geotrek-rando-widget/p-8c206aec.js +2 -0
  69. package/dist/geotrek-rando-widget/p-ed8706fb.entry.js +1 -0
  70. package/dist/types/components/grw-app/grw-app.d.ts +27 -2
  71. package/dist/types/components/grw-filter/grw-filter.d.ts +9 -0
  72. package/dist/types/components/grw-information-desk-detail/grw-information-desk-detail.d.ts +5 -0
  73. package/dist/types/components/grw-map/grw-map.d.ts +19 -2
  74. package/dist/types/components/grw-poi-detail/grw-poi-detail.d.ts +5 -0
  75. package/dist/types/components/grw-sensitive-area-detail/grw-sensitive-area-detail.d.ts +5 -0
  76. package/dist/types/components/grw-trek-card/grw-trek-card.d.ts +6 -2
  77. package/dist/types/components/grw-trek-detail/grw-trek-detail.d.ts +3 -0
  78. package/dist/types/components/grw-treks-list/grw-treks-list.d.ts +3 -0
  79. package/dist/types/components.d.ts +158 -1
  80. package/dist/types/store/grw-trek-provider.d.ts +1 -0
  81. package/dist/types/store/grw-treks-provider.d.ts +8 -0
  82. package/dist/types/store/store.d.ts +13 -1
  83. package/dist/types/types/types.d.ts +69 -3
  84. package/package.json +5 -7
  85. package/readme.md +19 -1
  86. package/dist/geotrek-rando-widget/p-f721481d.js +0 -2
  87. package/dist/geotrek-rando-widget/p-fe788eaa.entry.js +0 -1
@@ -1,40 +1,77 @@
1
- import { Component, Host, h, Listen, State, Prop } from '@stencil/core';
1
+ import { Component, Host, h, Listen, State, Prop, Element, Watch } from '@stencil/core';
2
2
  import state from 'store/store';
3
3
  import arrowBackImage from '../../assets/arrow-back.svg';
4
4
  export class GrwApp {
5
5
  constructor() {
6
+ this.showTrek = false;
7
+ this.showMap = false;
8
+ this.showFilters = false;
9
+ this.isLargeView = false;
10
+ this.language = 'fr';
6
11
  this.appName = 'Geotrek Rando Widget';
7
12
  this.colorPrimary = '#6b0030';
8
- this.colorPrimaryTint = '#d2b2c0';
13
+ this.colorPrimaryShade = '#4a0021';
14
+ this.colorPrimaryTint = '#974c6e';
15
+ this.colorTrekLine = '#6b0030';
16
+ this.colorDepartureIcon = '#006b3b';
17
+ this.colorArrivalIcon = '#85003b';
18
+ this.colorSensitiveArea = '#4974a5';
19
+ this.colorPoiIcon = '#974c6e';
20
+ this.largeViewSize = 1024;
9
21
  }
10
22
  onTrekCardPress(event) {
11
23
  this.currentTrekId = event.detail;
12
24
  this.showTrek = !this.showTrek;
13
25
  }
14
- onWindowResize(event) {
15
- this.showMap = !(event.composedPath()[0].innerWidth < 664);
26
+ onWindowResize() {
27
+ this.handleView();
28
+ }
29
+ watchPropHandler() {
30
+ window.dispatchEvent(new window.Event('resize'));
31
+ }
32
+ componentDidLoad() {
33
+ this.handleView();
16
34
  }
17
35
  onTrekDetailsClose() {
18
36
  this.currentTrekId = null;
19
37
  this.showTrek = !this.showTrek;
20
38
  }
21
- componentWillLoad() {
22
- this.showMap = !(window.innerWidth < 664);
39
+ handleView() {
40
+ this.isLargeView = this.element.getBoundingClientRect().width >= this.largeViewSize;
41
+ this.showMap = this.isLargeView;
42
+ }
43
+ handleFilters() {
44
+ this.showFilters = !this.showFilters;
23
45
  }
24
46
  render() {
25
- return (h(Host, { style: { '--color-primary': this.colorPrimary, '--color-primary-tint': this.colorPrimaryTint } },
26
- h("grw-treks-provider", { api: this.api, portals: this.portals },
27
- h("div", { class: "header-container" }, this.showTrek ? h("div", { onClick: () => this.onTrekDetailsClose(), class: "arrow-back-icon", innerHTML: arrowBackImage }) : h("div", { class: "title" }, this.appName)),
47
+ return (h(Host, { style: { '--color-primary': this.colorPrimary, '--color-primary-tint': this.colorPrimaryTint, '--color-primary-shade': this.colorPrimaryShade } },
48
+ h("grw-treks-provider", { api: this.api, language: this.language, "in-bbox": this.inBbox, cities: this.cities, districts: this.districts, structures: this.structures, themes: this.themes, portals: this.portals, routes: this.routes, practices: this.practices }),
49
+ this.showTrek && this.currentTrekId && h("grw-trek-provider", { api: state.api, language: this.language, "trek-id": this.currentTrekId }),
50
+ h("div", { class: "app-container" },
51
+ h("div", { class: this.isLargeView ? 'large-view-header-container' : 'header-container' },
52
+ this.showTrek ? (h("div", { onClick: () => this.onTrekDetailsClose(), class: "arrow-back-icon", innerHTML: arrowBackImage })) : (h("div", { onClick: () => this.handleFilters(), class: "handle-filters-button" }, "FILTRER")),
53
+ !this.showTrek && this.showFilters && (h("div", { class: "options-container" },
54
+ h("div", { class: "filters-container" },
55
+ h("div", { class: "current-treks-length" }, `${state.currentTreks.length} résultat${state.currentTreks.length > 1 ? 's' : ''}`),
56
+ h("div", { onClick: () => this.handleFilters(), class: "close-filters-button" }, "X"),
57
+ h("div", null,
58
+ h("grw-filter", { filterName: "Pratique", filterType: "practices", filterNameProperty: "name" })),
59
+ h("div", { class: "filter-margin-top" },
60
+ h("grw-filter", { filterName: "Difficult\u00E9", filterType: "difficulties", filterNameProperty: "label" })),
61
+ h("div", { class: "filter-margin-top" },
62
+ h("grw-filter", { filterName: "Dur\u00E9e", filterType: "durations", filterNameProperty: "name" }))),
63
+ h("div", { onClick: () => this.handleFilters(), class: "back-filters-container" }))),
64
+ h("div", { class: "attribution-container" },
65
+ h("a", { target: "_blank", href: "https://geotrek.fr" }, "GEOTREK"))),
28
66
  h("div", { class: "content-container" },
29
- h("div", { class: "app-treks-list-container", style: { visibility: this.showTrek ? 'hidden' : 'visible', position: this.showTrek ? 'absolute' : 'relative' } },
30
- h("grw-treks-list", null)),
31
- this.showTrek && !state.currentTrek && (h("div", { class: "loader-container" },
67
+ h("div", { class: this.isLargeView ? 'large-view-app-treks-list-container' : 'app-treks-list-container', style: { display: this.showTrek ? 'none' : 'flex', position: this.showTrek ? 'absolute' : 'relative' } },
68
+ h("grw-treks-list", { "is-large-view": this.isLargeView, "color-primary": this.colorPrimary, "color-primary-tint": this.colorPrimaryTint })),
69
+ this.showTrek && !state.currentTrek && (h("div", { class: this.isLargeView ? 'large-view-loader-container' : 'loader-container' },
32
70
  h("span", { class: "loader" }))),
33
- this.showTrek && this.currentTrekId && (h("grw-trek-provider", { api: state.api, "trek-id": this.currentTrekId }, state.currentTrek && (h("div", { class: "app-trek-detail-container" },
34
- h("grw-trek-detail", null))))),
35
- h("div", { class: "app-map-container", style: { visibility: this.showMap ? 'visible' : 'hidden' } },
36
- h("grw-map", null))),
37
- h("div", { class: "map-visibility-button" },
71
+ state.currentTrek && (h("div", { class: this.isLargeView ? 'large-view-app-trek-detail-container' : 'app-trek-detail-container' },
72
+ h("grw-trek-detail", { "color-primary": this.colorPrimary, "color-primary-shade": this.colorPrimaryShade, "color-primary-tint": this.colorPrimaryTint }))),
73
+ h("grw-map", { class: this.isLargeView ? 'large-view-app-map-container' : 'app-map-container', style: { visibility: this.showMap ? 'visible' : 'hidden' }, "url-layer": this.urlLayer, center: this.center, zoom: this.zoom, attribution: this.attribution, "color-primary": this.colorPrimary, "color-primary-tint": this.colorPrimaryTint, "color-trek-line": this.colorTrekLine, "color-departure-icon": this.colorDepartureIcon, "color-arrival-icon": this.colorArrivalIcon, "color-sensitive-area": this.colorSensitiveArea, "color-poi-icon": this.colorPoiIcon })),
74
+ h("div", { class: "map-visibility-button", style: { display: this.isLargeView ? 'none' : 'flex' } },
38
75
  h("div", { onClick: () => (this.showMap = !this.showMap) }, this.showMap ? (this.showTrek ? 'Voir la fiche' : 'Voir la liste') : 'Voir la carte')))));
39
76
  }
40
77
  static get is() { return "grw-app"; }
@@ -63,6 +100,109 @@ export class GrwApp {
63
100
  "attribute": "api",
64
101
  "reflect": false
65
102
  },
103
+ "language": {
104
+ "type": "string",
105
+ "mutable": false,
106
+ "complexType": {
107
+ "original": "string",
108
+ "resolved": "string",
109
+ "references": {}
110
+ },
111
+ "required": false,
112
+ "optional": false,
113
+ "docs": {
114
+ "tags": [],
115
+ "text": ""
116
+ },
117
+ "attribute": "language",
118
+ "reflect": false,
119
+ "defaultValue": "'fr'"
120
+ },
121
+ "inBbox": {
122
+ "type": "string",
123
+ "mutable": false,
124
+ "complexType": {
125
+ "original": "string",
126
+ "resolved": "string",
127
+ "references": {}
128
+ },
129
+ "required": false,
130
+ "optional": false,
131
+ "docs": {
132
+ "tags": [],
133
+ "text": ""
134
+ },
135
+ "attribute": "in-bbox",
136
+ "reflect": false
137
+ },
138
+ "cities": {
139
+ "type": "string",
140
+ "mutable": false,
141
+ "complexType": {
142
+ "original": "string",
143
+ "resolved": "string",
144
+ "references": {}
145
+ },
146
+ "required": false,
147
+ "optional": false,
148
+ "docs": {
149
+ "tags": [],
150
+ "text": ""
151
+ },
152
+ "attribute": "cities",
153
+ "reflect": false
154
+ },
155
+ "districts": {
156
+ "type": "string",
157
+ "mutable": false,
158
+ "complexType": {
159
+ "original": "string",
160
+ "resolved": "string",
161
+ "references": {}
162
+ },
163
+ "required": false,
164
+ "optional": false,
165
+ "docs": {
166
+ "tags": [],
167
+ "text": ""
168
+ },
169
+ "attribute": "districts",
170
+ "reflect": false
171
+ },
172
+ "structures": {
173
+ "type": "string",
174
+ "mutable": false,
175
+ "complexType": {
176
+ "original": "string",
177
+ "resolved": "string",
178
+ "references": {}
179
+ },
180
+ "required": false,
181
+ "optional": false,
182
+ "docs": {
183
+ "tags": [],
184
+ "text": ""
185
+ },
186
+ "attribute": "structures",
187
+ "reflect": false
188
+ },
189
+ "themes": {
190
+ "type": "string",
191
+ "mutable": false,
192
+ "complexType": {
193
+ "original": "string",
194
+ "resolved": "string",
195
+ "references": {}
196
+ },
197
+ "required": false,
198
+ "optional": false,
199
+ "docs": {
200
+ "tags": [],
201
+ "text": ""
202
+ },
203
+ "attribute": "themes",
204
+ "reflect": false
205
+ },
66
206
  "portals": {
67
207
  "type": "string",
68
208
  "mutable": false,
@@ -80,6 +220,40 @@ export class GrwApp {
80
220
  "attribute": "portals",
81
221
  "reflect": false
82
222
  },
223
+ "routes": {
224
+ "type": "string",
225
+ "mutable": false,
226
+ "complexType": {
227
+ "original": "string",
228
+ "resolved": "string",
229
+ "references": {}
230
+ },
231
+ "required": false,
232
+ "optional": false,
233
+ "docs": {
234
+ "tags": [],
235
+ "text": ""
236
+ },
237
+ "attribute": "routes",
238
+ "reflect": false
239
+ },
240
+ "practices": {
241
+ "type": "string",
242
+ "mutable": false,
243
+ "complexType": {
244
+ "original": "string",
245
+ "resolved": "string",
246
+ "references": {}
247
+ },
248
+ "required": false,
249
+ "optional": false,
250
+ "docs": {
251
+ "tags": [],
252
+ "text": ""
253
+ },
254
+ "attribute": "practices",
255
+ "reflect": false
256
+ },
83
257
  "appName": {
84
258
  "type": "string",
85
259
  "mutable": false,
@@ -98,6 +272,74 @@ export class GrwApp {
98
272
  "reflect": false,
99
273
  "defaultValue": "'Geotrek Rando Widget'"
100
274
  },
275
+ "urlLayer": {
276
+ "type": "string",
277
+ "mutable": false,
278
+ "complexType": {
279
+ "original": "string",
280
+ "resolved": "string",
281
+ "references": {}
282
+ },
283
+ "required": false,
284
+ "optional": false,
285
+ "docs": {
286
+ "tags": [],
287
+ "text": ""
288
+ },
289
+ "attribute": "url-layer",
290
+ "reflect": false
291
+ },
292
+ "center": {
293
+ "type": "string",
294
+ "mutable": false,
295
+ "complexType": {
296
+ "original": "string",
297
+ "resolved": "string",
298
+ "references": {}
299
+ },
300
+ "required": false,
301
+ "optional": false,
302
+ "docs": {
303
+ "tags": [],
304
+ "text": ""
305
+ },
306
+ "attribute": "center",
307
+ "reflect": false
308
+ },
309
+ "zoom": {
310
+ "type": "any",
311
+ "mutable": false,
312
+ "complexType": {
313
+ "original": "any",
314
+ "resolved": "any",
315
+ "references": {}
316
+ },
317
+ "required": false,
318
+ "optional": false,
319
+ "docs": {
320
+ "tags": [],
321
+ "text": ""
322
+ },
323
+ "attribute": "zoom",
324
+ "reflect": false
325
+ },
326
+ "attribution": {
327
+ "type": "string",
328
+ "mutable": false,
329
+ "complexType": {
330
+ "original": "string",
331
+ "resolved": "string",
332
+ "references": {}
333
+ },
334
+ "required": false,
335
+ "optional": false,
336
+ "docs": {
337
+ "tags": [],
338
+ "text": ""
339
+ },
340
+ "attribute": "attribution",
341
+ "reflect": false
342
+ },
101
343
  "colorPrimary": {
102
344
  "type": "string",
103
345
  "mutable": false,
@@ -116,6 +358,24 @@ export class GrwApp {
116
358
  "reflect": false,
117
359
  "defaultValue": "'#6b0030'"
118
360
  },
361
+ "colorPrimaryShade": {
362
+ "type": "string",
363
+ "mutable": false,
364
+ "complexType": {
365
+ "original": "string",
366
+ "resolved": "string",
367
+ "references": {}
368
+ },
369
+ "required": false,
370
+ "optional": false,
371
+ "docs": {
372
+ "tags": [],
373
+ "text": ""
374
+ },
375
+ "attribute": "color-primary-shade",
376
+ "reflect": false,
377
+ "defaultValue": "'#4a0021'"
378
+ },
119
379
  "colorPrimaryTint": {
120
380
  "type": "string",
121
381
  "mutable": false,
@@ -132,14 +392,111 @@ export class GrwApp {
132
392
  },
133
393
  "attribute": "color-primary-tint",
134
394
  "reflect": false,
135
- "defaultValue": "'#d2b2c0'"
395
+ "defaultValue": "'#974c6e'"
396
+ },
397
+ "colorTrekLine": {
398
+ "type": "string",
399
+ "mutable": false,
400
+ "complexType": {
401
+ "original": "string",
402
+ "resolved": "string",
403
+ "references": {}
404
+ },
405
+ "required": false,
406
+ "optional": false,
407
+ "docs": {
408
+ "tags": [],
409
+ "text": ""
410
+ },
411
+ "attribute": "color-trek-line",
412
+ "reflect": false,
413
+ "defaultValue": "'#6b0030'"
414
+ },
415
+ "colorDepartureIcon": {
416
+ "type": "string",
417
+ "mutable": false,
418
+ "complexType": {
419
+ "original": "string",
420
+ "resolved": "string",
421
+ "references": {}
422
+ },
423
+ "required": false,
424
+ "optional": false,
425
+ "docs": {
426
+ "tags": [],
427
+ "text": ""
428
+ },
429
+ "attribute": "color-departure-icon",
430
+ "reflect": false,
431
+ "defaultValue": "'#006b3b'"
432
+ },
433
+ "colorArrivalIcon": {
434
+ "type": "string",
435
+ "mutable": false,
436
+ "complexType": {
437
+ "original": "string",
438
+ "resolved": "string",
439
+ "references": {}
440
+ },
441
+ "required": false,
442
+ "optional": false,
443
+ "docs": {
444
+ "tags": [],
445
+ "text": ""
446
+ },
447
+ "attribute": "color-arrival-icon",
448
+ "reflect": false,
449
+ "defaultValue": "'#85003b'"
450
+ },
451
+ "colorSensitiveArea": {
452
+ "type": "string",
453
+ "mutable": false,
454
+ "complexType": {
455
+ "original": "string",
456
+ "resolved": "string",
457
+ "references": {}
458
+ },
459
+ "required": false,
460
+ "optional": false,
461
+ "docs": {
462
+ "tags": [],
463
+ "text": ""
464
+ },
465
+ "attribute": "color-sensitive-area",
466
+ "reflect": false,
467
+ "defaultValue": "'#4974a5'"
468
+ },
469
+ "colorPoiIcon": {
470
+ "type": "string",
471
+ "mutable": false,
472
+ "complexType": {
473
+ "original": "string",
474
+ "resolved": "string",
475
+ "references": {}
476
+ },
477
+ "required": false,
478
+ "optional": false,
479
+ "docs": {
480
+ "tags": [],
481
+ "text": ""
482
+ },
483
+ "attribute": "color-poi-icon",
484
+ "reflect": false,
485
+ "defaultValue": "'#974c6e'"
136
486
  }
137
487
  }; }
138
488
  static get states() { return {
139
489
  "showTrek": {},
140
490
  "showMap": {},
491
+ "showFilters": {},
492
+ "isLargeView": {},
141
493
  "currentTrekId": {}
142
494
  }; }
495
+ static get elementRef() { return "element"; }
496
+ static get watchers() { return [{
497
+ "propName": "isLargeView",
498
+ "methodName": "watchPropHandler"
499
+ }]; }
143
500
  static get listeners() { return [{
144
501
  "name": "trekCardPress",
145
502
  "method": "onTrekCardPress",
@@ -0,0 +1,29 @@
1
+ .filter-name {
2
+ margin-left: 8px;
3
+ color: var(--color-primary);
4
+ font-size: 24px;
5
+ font-weight: bold;
6
+ }
7
+
8
+ .filter-button-container {
9
+ display: flex;
10
+ flex-direction: row;
11
+ flex-wrap: wrap;
12
+ }
13
+ .filter-button-container .filter-button,
14
+ .filter-button-container .selected-filter-button {
15
+ user-select: none;
16
+ cursor: pointer;
17
+ border: 1px var(--color-primary) solid;
18
+ border-radius: 8px;
19
+ margin: 8px 0px 0px 8px;
20
+ padding: 8px;
21
+ }
22
+ .filter-button-container .filter-button {
23
+ color: var(--color-primary);
24
+ background-color: #ffffff;
25
+ }
26
+ .filter-button-container .selected-filter-button {
27
+ color: #ffffff;
28
+ background-color: var(--color-primary);
29
+ }
@@ -0,0 +1,132 @@
1
+ import { Component, Host, h, Prop } from '@stencil/core';
2
+ import state from 'store/store';
3
+ export class GrwFilter {
4
+ constructor() {
5
+ this.filters = [
6
+ { property: 'practices', trekProperty: 'practice', type: 'include' },
7
+ { property: 'difficulties', trekProperty: 'difficulty', type: 'include' },
8
+ { property: 'durations', trekProperty: 'duration', type: 'interval' },
9
+ ];
10
+ }
11
+ handleFilter(_event, filterToHandle) {
12
+ const filterFromState = [...state[this.filterType]];
13
+ filterFromState.find(currentFilter => currentFilter.id === filterToHandle.id).selected = !filterFromState.find(currentFilter => currentFilter.id === filterToHandle.id)
14
+ .selected;
15
+ state[this.filterType] = filterFromState;
16
+ let isUsingFilter = false;
17
+ let filtersTreks = [];
18
+ for (const filter of this.filters) {
19
+ const currentFiltersId = state[filter.property].filter(currentFilter => currentFilter.selected).map(currentFilter => currentFilter.id);
20
+ if (currentFiltersId.length > 0) {
21
+ if (filtersTreks.length > 0) {
22
+ if (filter.type === 'include') {
23
+ filtersTreks = [...filtersTreks.filter(trek => currentFiltersId.includes(trek[filter.trekProperty]))];
24
+ }
25
+ else if (filter.type === 'interval') {
26
+ let minValue;
27
+ let maxValue;
28
+ for (const currentFilterId of currentFiltersId) {
29
+ const currentFilter = state[filter.property].find(property => property.id === currentFilterId);
30
+ if (isNaN(minValue) || currentFilter.minValue < minValue) {
31
+ minValue = currentFilter.minValue;
32
+ }
33
+ if (isNaN(maxValue) || currentFilter.maxValue > maxValue) {
34
+ maxValue = currentFilter.maxValue;
35
+ }
36
+ }
37
+ filtersTreks = [...filtersTreks.filter(trek => trek[filter.trekProperty] >= minValue && trek[filter.trekProperty] <= maxValue)];
38
+ }
39
+ }
40
+ else {
41
+ if (!isUsingFilter) {
42
+ isUsingFilter = true;
43
+ }
44
+ if (filter.type === 'include') {
45
+ filtersTreks = [...state.treks.filter(trek => currentFiltersId.includes(trek[filter.trekProperty]))];
46
+ }
47
+ else if (filter.type === 'interval') {
48
+ let minValue;
49
+ let maxValue;
50
+ for (const currentFilterId of currentFiltersId) {
51
+ const currentFilter = state[filter.property].find(property => property.id === currentFilterId);
52
+ if (isNaN(minValue) || currentFilter.minValue < minValue) {
53
+ minValue = currentFilter.minValue;
54
+ }
55
+ if (isNaN(maxValue) || currentFilter.maxValue > maxValue) {
56
+ maxValue = currentFilter.maxValue;
57
+ }
58
+ }
59
+ filtersTreks = [...state.treks.filter(trek => trek[filter.trekProperty] >= minValue && trek[filter.trekProperty] <= maxValue)];
60
+ }
61
+ }
62
+ }
63
+ }
64
+ state.currentTreks = isUsingFilter ? filtersTreks : state.treks;
65
+ }
66
+ render() {
67
+ return (h(Host, null,
68
+ h("div", { class: "filter-name" }, this.filterName),
69
+ h("div", { class: "filter-button-container" }, state[this.filterType].map(currentFilter => (h("div", { onClick: event => this.handleFilter(event, currentFilter), class: currentFilter.selected ? 'selected-filter-button' : 'filter-button' }, currentFilter[this.filterNameProperty]))))));
70
+ }
71
+ static get is() { return "grw-filter"; }
72
+ static get encapsulation() { return "shadow"; }
73
+ static get originalStyleUrls() { return {
74
+ "$": ["grw-filter.scss"]
75
+ }; }
76
+ static get styleUrls() { return {
77
+ "$": ["grw-filter.css"]
78
+ }; }
79
+ static get properties() { return {
80
+ "filterType": {
81
+ "type": "string",
82
+ "mutable": false,
83
+ "complexType": {
84
+ "original": "string",
85
+ "resolved": "string",
86
+ "references": {}
87
+ },
88
+ "required": false,
89
+ "optional": false,
90
+ "docs": {
91
+ "tags": [],
92
+ "text": ""
93
+ },
94
+ "attribute": "filter-type",
95
+ "reflect": false
96
+ },
97
+ "filterName": {
98
+ "type": "string",
99
+ "mutable": false,
100
+ "complexType": {
101
+ "original": "string",
102
+ "resolved": "string",
103
+ "references": {}
104
+ },
105
+ "required": false,
106
+ "optional": false,
107
+ "docs": {
108
+ "tags": [],
109
+ "text": ""
110
+ },
111
+ "attribute": "filter-name",
112
+ "reflect": false
113
+ },
114
+ "filterNameProperty": {
115
+ "type": "string",
116
+ "mutable": false,
117
+ "complexType": {
118
+ "original": "string",
119
+ "resolved": "string",
120
+ "references": {}
121
+ },
122
+ "required": false,
123
+ "optional": false,
124
+ "docs": {
125
+ "tags": [],
126
+ "text": ""
127
+ },
128
+ "attribute": "filter-name-property",
129
+ "reflect": false
130
+ }
131
+ }; }
132
+ }
@@ -0,0 +1,30 @@
1
+ :host {
2
+ display: flex;
3
+ flex-direction: column;
4
+ padding: 0px 8px 8px 8px;
5
+ }
6
+
7
+ .information-desk-img {
8
+ width: 180px;
9
+ }
10
+ .information-desk-img img {
11
+ width: 180px;
12
+ border-radius: 8px;
13
+ }
14
+
15
+ .information-desk-right-container {
16
+ display: flex;
17
+ flex-direction: column;
18
+ padding: 8px;
19
+ }
20
+
21
+ .information-desk-name {
22
+ color: var(--color-primary);
23
+ font-size: 24px;
24
+ font-weight: bold;
25
+ padding: 0px 0px 8px 0px;
26
+ }
27
+
28
+ .information-desk-description {
29
+ font-size: 16px;
30
+ }