@geotrekce/geotrek-rando-widget 0.0.1 → 0.0.2

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 (53) hide show
  1. package/dist/cjs/geotrek-rando-widget.cjs.js +2 -2
  2. package/dist/cjs/grw-app_7.cjs.entry.js +137 -55
  3. package/dist/cjs/{index-31255e29.js → index-c6f73e30.js} +36 -0
  4. package/dist/cjs/loader.cjs.js +2 -2
  5. package/dist/collection/assets/departure-arrival.svg +1 -1
  6. package/dist/collection/components/grw-app/grw-app.css +60 -37
  7. package/dist/collection/components/grw-app/grw-app.js +277 -15
  8. package/dist/collection/components/grw-map/grw-map.css +36 -0
  9. package/dist/collection/components/grw-map/grw-map.js +157 -18
  10. package/dist/collection/components/grw-trek-card/grw-trek-card.js +87 -32
  11. package/dist/collection/components/grw-trek-detail/grw-trek-detail.css +1 -1
  12. package/dist/collection/components/grw-trek-detail/grw-trek-detail.js +87 -32
  13. package/dist/collection/components/grw-treks-list/grw-treks-list.css +3 -12
  14. package/dist/collection/components/grw-treks-list/grw-treks-list.js +46 -4
  15. package/dist/collection/store/grw-trek-provider.js +28 -6
  16. package/dist/collection/store/grw-treks-provider.js +155 -9
  17. package/dist/collection/stories/App.js +31 -1
  18. package/dist/collection/stories/App.stories.js +21 -1
  19. package/dist/collection/stories/TrekCard.js +8 -3
  20. package/dist/collection/stories/TrekCard.stories.js +2 -0
  21. package/dist/collection/stories/TrekDetail.js +8 -3
  22. package/dist/collection/stories/TrekDetail.stories.js +2 -0
  23. package/dist/collection/stories/TrekMap.js +10 -3
  24. package/dist/collection/stories/TrekMap.stories.js +13 -1
  25. package/dist/collection/stories/TreksList.js +16 -3
  26. package/dist/collection/stories/TreksList.stories.js +10 -0
  27. package/dist/collection/stories/TreksMap.js +12 -3
  28. package/dist/collection/stories/TreksMap.stories.js +15 -1
  29. package/dist/components/grw-app.js +39 -6
  30. package/dist/components/grw-map2.js +56 -20
  31. package/dist/components/grw-trek-card2.js +25 -7
  32. package/dist/components/grw-trek-detail2.js +26 -8
  33. package/dist/components/grw-trek-provider2.js +10 -7
  34. package/dist/components/grw-treks-list2.js +10 -4
  35. package/dist/components/grw-treks-provider2.js +26 -11
  36. package/dist/esm/geotrek-rando-widget.js +2 -2
  37. package/dist/esm/grw-app_7.entry.js +137 -55
  38. package/dist/esm/{index-b36f38f5.js → index-7aa9e822.js} +36 -0
  39. package/dist/esm/loader.js +2 -2
  40. package/dist/geotrek-rando-widget/geotrek-rando-widget.esm.js +1 -1
  41. package/dist/geotrek-rando-widget/p-332ba9ab.js +2 -0
  42. package/dist/geotrek-rando-widget/p-b7c66d2d.entry.js +1 -0
  43. package/dist/types/components/grw-app/grw-app.d.ts +21 -2
  44. package/dist/types/components/grw-map/grw-map.d.ts +8 -0
  45. package/dist/types/components/grw-trek-card/grw-trek-card.d.ts +3 -1
  46. package/dist/types/components/grw-trek-detail/grw-trek-detail.d.ts +2 -0
  47. package/dist/types/components/grw-treks-list/grw-treks-list.d.ts +2 -0
  48. package/dist/types/components.d.ts +70 -0
  49. package/dist/types/store/grw-trek-provider.d.ts +1 -0
  50. package/dist/types/store/grw-treks-provider.d.ts +8 -0
  51. package/package.json +1 -1
  52. package/dist/geotrek-rando-widget/p-f721481d.js +0 -2
  53. package/dist/geotrek-rando-widget/p-fe788eaa.entry.js +0 -1
@@ -1,28 +1,41 @@
1
- import { Component, Host, h, Element, Prop } from '@stencil/core';
1
+ import { Component, Host, h, Element, Prop, State } from '@stencil/core';
2
2
  import L from 'leaflet';
3
3
  import state, { onChange } from 'store/store';
4
4
  import departureArrivalImage from '../../assets/departure-arrival.svg';
5
5
  export class GrwMap {
6
6
  constructor() {
7
+ this.mapIsReady = false;
8
+ this.center = '1, 1';
9
+ this.zoom = 10;
7
10
  this.colorTrekLine = '#6b0030';
8
11
  this.colorDepartureIcon = '#006b3b';
9
12
  this.colorArrivalIcon = '#85003b';
13
+ this.colorPrimary = '#6b0030';
14
+ this.colorPrimaryTint = '#d2b2c0';
10
15
  }
11
16
  componentDidLoad() {
12
17
  this.map = L.map(this.element, {
13
- center: [1, 1],
14
- zoom: 10,
18
+ center: this.center.split(',').map(Number),
19
+ zoom: this.zoom,
15
20
  });
16
- L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
21
+ L.tileLayer(this.urlLayer, {
17
22
  maxZoom: 19,
18
- attribution: '© OpenStreetMap',
23
+ attribution: this.attribution,
19
24
  }).addTo(this.map);
20
25
  if (state.currentTrek) {
21
26
  this.addTrek();
22
27
  }
23
- else {
28
+ else if (state.currentTrek) {
24
29
  this.addTreks();
25
30
  }
31
+ onChange('treks', () => {
32
+ if (state.currentTrek) {
33
+ this.addTrek();
34
+ }
35
+ else if (state.treks) {
36
+ this.addTreks();
37
+ }
38
+ });
26
39
  onChange('currentTrek', () => {
27
40
  if (state.currentTrek) {
28
41
  this.removeTreks();
@@ -35,6 +48,7 @@ export class GrwMap {
35
48
  });
36
49
  }
37
50
  addTreks() {
51
+ var _a;
38
52
  const treksDepartureCoordinates = [];
39
53
  const treksFeatureCollection = {
40
54
  type: 'FeatureCollection',
@@ -44,28 +58,32 @@ export class GrwMap {
44
58
  treksDepartureCoordinates.push(trek.departure_geom);
45
59
  treksFeatureCollection.features.push({
46
60
  type: 'Feature',
47
- properties: {},
61
+ properties: { practice: (_a = state.practices.find(practice => practice.id === trek.practice)) === null || _a === void 0 ? void 0 : _a.pictogram },
48
62
  geometry: { type: 'Point', coordinates: trek.departure_geom },
49
63
  });
50
64
  }
51
65
  if (treksDepartureCoordinates.length > 0) {
52
66
  const bounds = L.latLngBounds(treksDepartureCoordinates.map(coordinate => [coordinate[1], coordinate[0]]));
53
- this.map.fitBounds(bounds);
67
+ this.currentBounds = bounds;
68
+ this.map.fitBounds(this.currentBounds);
54
69
  }
55
70
  this.treksLayer = L.geoJSON(treksFeatureCollection, {
56
- pointToLayer: (_geoJsonPoint, latlng) => L.marker(latlng, {
71
+ pointToLayer: (geoJsonPoint, latlng) => L.marker(latlng, {
57
72
  icon: L.divIcon({
58
73
  className: 'trek-marker',
59
74
  iconSize: 48,
60
- iconAnchor: [0, 48],
75
+ html: geoJsonPoint.properties.practice ? `<img src=${geoJsonPoint.properties.practice} />` : '',
61
76
  }),
62
77
  autoPanOnFocus: false,
63
78
  }),
64
79
  }).addTo(this.map);
80
+ !this.mapIsReady && (this.mapIsReady = !this.mapIsReady);
65
81
  }
66
82
  removeTreks() {
67
- this.map.removeLayer(this.treksLayer);
68
- this.treksLayer = null;
83
+ if (this.treksLayer) {
84
+ this.map.removeLayer(this.treksLayer);
85
+ this.treksLayer = null;
86
+ }
69
87
  }
70
88
  addTrek() {
71
89
  const trekFeature = {
@@ -79,7 +97,8 @@ export class GrwMap {
79
97
  }),
80
98
  }).addTo(this.map);
81
99
  const bounds = L.latLngBounds(state.currentTrek.geometry.coordinates.map(coordinate => [coordinate[1], coordinate[0]]));
82
- this.map.fitBounds(bounds);
100
+ this.currentBounds = bounds;
101
+ this.map.fitBounds(this.currentBounds);
83
102
  const departureCoordinates = [state.currentTrek.geometry.coordinates.at(0)[0], state.currentTrek.geometry.coordinates.at(0)[1]];
84
103
  const arrivalCoordinates = [state.currentTrek.geometry.coordinates.at(-1)[0], state.currentTrek.geometry.coordinates.at(-1)[1]];
85
104
  const departureArrivalFeatureCollection = {
@@ -110,15 +129,26 @@ export class GrwMap {
110
129
  autoPanOnFocus: false,
111
130
  }),
112
131
  }).addTo(this.map);
132
+ !this.mapIsReady && (this.mapIsReady = !this.mapIsReady);
113
133
  }
114
134
  removeTrek() {
115
- this.map.removeLayer(this.trekLayer);
116
- this.map.removeLayer(this.departureArrivalLayer);
117
- this.trekLayer = null;
118
- this.departureArrivalLayer = null;
135
+ if (this.trekLayer) {
136
+ this.map.removeLayer(this.trekLayer);
137
+ this.trekLayer = null;
138
+ }
139
+ if (this.departureArrivalLayer) {
140
+ this.map.removeLayer(this.departureArrivalLayer);
141
+ this.departureArrivalLayer = null;
142
+ }
119
143
  }
120
144
  render() {
121
- return h(Host, { style: { '--color-departure-icon': this.colorDepartureIcon, '--color-arrival-icon': this.colorArrivalIcon } });
145
+ return (h(Host, { style: {
146
+ '--color-primary': this.colorPrimary,
147
+ '--color-primary-tint': this.colorPrimaryTint,
148
+ '--color-departure-icon': this.colorDepartureIcon,
149
+ '--color-arrival-icon': this.colorArrivalIcon,
150
+ } }, !this.mapIsReady && (h("div", { class: "map-loader-container" },
151
+ h("span", { class: "loader" })))));
122
152
  }
123
153
  static get is() { return "grw-map"; }
124
154
  static get originalStyleUrls() { return {
@@ -128,6 +158,76 @@ export class GrwMap {
128
158
  "$": ["grw-map.css"]
129
159
  }; }
130
160
  static get properties() { return {
161
+ "urlLayer": {
162
+ "type": "string",
163
+ "mutable": false,
164
+ "complexType": {
165
+ "original": "string",
166
+ "resolved": "string",
167
+ "references": {}
168
+ },
169
+ "required": false,
170
+ "optional": false,
171
+ "docs": {
172
+ "tags": [],
173
+ "text": ""
174
+ },
175
+ "attribute": "url-layer",
176
+ "reflect": false
177
+ },
178
+ "attribution": {
179
+ "type": "string",
180
+ "mutable": false,
181
+ "complexType": {
182
+ "original": "string",
183
+ "resolved": "string",
184
+ "references": {}
185
+ },
186
+ "required": false,
187
+ "optional": false,
188
+ "docs": {
189
+ "tags": [],
190
+ "text": ""
191
+ },
192
+ "attribute": "attribution",
193
+ "reflect": false
194
+ },
195
+ "center": {
196
+ "type": "string",
197
+ "mutable": false,
198
+ "complexType": {
199
+ "original": "string",
200
+ "resolved": "string",
201
+ "references": {}
202
+ },
203
+ "required": false,
204
+ "optional": false,
205
+ "docs": {
206
+ "tags": [],
207
+ "text": ""
208
+ },
209
+ "attribute": "center",
210
+ "reflect": false,
211
+ "defaultValue": "'1, 1'"
212
+ },
213
+ "zoom": {
214
+ "type": "number",
215
+ "mutable": false,
216
+ "complexType": {
217
+ "original": "number",
218
+ "resolved": "number",
219
+ "references": {}
220
+ },
221
+ "required": false,
222
+ "optional": false,
223
+ "docs": {
224
+ "tags": [],
225
+ "text": ""
226
+ },
227
+ "attribute": "zoom",
228
+ "reflect": false,
229
+ "defaultValue": "10"
230
+ },
131
231
  "colorTrekLine": {
132
232
  "type": "string",
133
233
  "mutable": false,
@@ -181,7 +281,46 @@ export class GrwMap {
181
281
  "attribute": "color-arrival-icon",
182
282
  "reflect": false,
183
283
  "defaultValue": "'#85003b'"
284
+ },
285
+ "colorPrimary": {
286
+ "type": "string",
287
+ "mutable": false,
288
+ "complexType": {
289
+ "original": "string",
290
+ "resolved": "string",
291
+ "references": {}
292
+ },
293
+ "required": false,
294
+ "optional": false,
295
+ "docs": {
296
+ "tags": [],
297
+ "text": ""
298
+ },
299
+ "attribute": "color-primary",
300
+ "reflect": false,
301
+ "defaultValue": "'#6b0030'"
302
+ },
303
+ "colorPrimaryTint": {
304
+ "type": "string",
305
+ "mutable": false,
306
+ "complexType": {
307
+ "original": "string",
308
+ "resolved": "string",
309
+ "references": {}
310
+ },
311
+ "required": false,
312
+ "optional": false,
313
+ "docs": {
314
+ "tags": [],
315
+ "text": ""
316
+ },
317
+ "attribute": "color-primary-tint",
318
+ "reflect": false,
319
+ "defaultValue": "'#d2b2c0'"
184
320
  }
185
321
  }; }
322
+ static get states() { return {
323
+ "mapIsReady": {}
324
+ }; }
186
325
  static get elementRef() { return "element"; }
187
326
  }
@@ -1,45 +1,58 @@
1
- import { Component, Host, h, Prop, Event } from '@stencil/core';
2
- import state from 'store/store';
1
+ import { Component, Host, h, Prop, Event, State } from '@stencil/core';
2
+ import state, { onChange } from 'store/store';
3
3
  import { formatDuration, formatLength, formatAscent } from 'utils/utils';
4
4
  import ascentImage from '../../assets/ascent.svg';
5
5
  import durationImage from '../../assets/duration.svg';
6
6
  import lengthImage from '../../assets/length.svg';
7
7
  export class GrwTrekCard {
8
+ constructor() {
9
+ this.colorPrimary = '#6b0030';
10
+ this.colorPrimaryTint = '#d2b2c0';
11
+ }
8
12
  componentWillLoad() {
9
13
  this.currentTrek = this.trek ? this.trek : state.currentTrek;
10
- this.difficulty = state.difficulties.find(difficulty => difficulty.id === this.currentTrek.difficulty);
11
- this.route = state.routes.find(route => route.id === this.currentTrek.route);
12
- this.practice = state.practices.find(practice => practice.id === this.currentTrek.practice);
14
+ if (this.currentTrek) {
15
+ this.difficulty = state.difficulties.find(difficulty => difficulty.id === this.currentTrek.difficulty);
16
+ this.route = state.routes.find(route => route.id === this.currentTrek.route);
17
+ this.practice = state.practices.find(practice => practice.id === this.currentTrek.practice);
18
+ }
19
+ onChange('currentTrek', () => {
20
+ this.currentTrek = this.trek ? this.trek : state.currentTrek;
21
+ if (this.currentTrek) {
22
+ this.difficulty = state.difficulties.find(difficulty => difficulty.id === this.currentTrek.difficulty);
23
+ this.route = state.routes.find(route => route.id === this.currentTrek.route);
24
+ this.practice = state.practices.find(practice => practice.id === this.currentTrek.practice);
25
+ }
26
+ });
13
27
  }
14
28
  render() {
15
29
  var _a, _b, _c, _d, _e, _f, _g, _h;
16
- return (h(Host, { onClick: () => this.trekCardPress.emit(this.currentTrek.id) },
17
- h("div", { class: "trek-card-container" },
18
- this.currentTrek.attachments[0] && h("img", { class: "image", src: this.currentTrek.attachments[0].url, loading: "lazy" }),
19
- h("div", { class: "sub-container" },
20
- h("div", { class: "name" }, (_a = this.currentTrek) === null || _a === void 0 ? void 0 : _a.name),
21
- h("div", { class: "description", innerHTML: (_b = this.currentTrek) === null || _b === void 0 ? void 0 : _b.description_teaser }),
22
- h("div", { class: "icons-labels-container" },
23
- h("div", { class: "row" },
24
- h("div", { class: "icon-label difficulty" },
25
- ((_c = this.difficulty) === null || _c === void 0 ? void 0 : _c.pictogram) && h("img", { src: this.difficulty.pictogram }), (_d = this.difficulty) === null || _d === void 0 ? void 0 :
26
- _d.label),
27
- h("div", { class: "icon-label duration" },
28
- h("div", { class: "svg-icon", innerHTML: durationImage }),
29
- formatDuration(this.currentTrek.duration)),
30
- h("div", { class: "icon-label route" },
31
- ((_e = this.route) === null || _e === void 0 ? void 0 : _e.pictogram) && h("img", { src: this.route.pictogram }), (_f = this.route) === null || _f === void 0 ? void 0 :
32
- _f.route)),
33
- h("div", { class: "row" },
34
- h("div", { class: "icon-label length" },
35
- h("div", { class: "svg-icon", innerHTML: lengthImage }),
36
- formatLength(this.currentTrek.length_2d)),
37
- h("div", { class: "icon-label ascent" },
38
- h("div", { class: "svg-icon", innerHTML: ascentImage }),
39
- formatAscent(this.currentTrek.ascent)),
40
- h("div", { class: "icon-label practice" },
41
- ((_g = this.practice) === null || _g === void 0 ? void 0 : _g.pictogram) && h("img", { src: this.practice.pictogram }), (_h = this.practice) === null || _h === void 0 ? void 0 :
42
- _h.name)))))));
30
+ return (h(Host, { onClick: () => this.trekCardPress.emit(this.currentTrek.id), style: { '--color-primary': this.colorPrimary, '--color-primary-tint': this.colorPrimaryTint } }, this.currentTrek && (h("div", { class: "trek-card-container" },
31
+ this.currentTrek.attachments && this.currentTrek.attachments[0] && this.currentTrek.attachments[0].url && (h("img", { class: "image", src: `${this.currentTrek.attachments[0].url}.400x0_q85.${this.currentTrek.attachments[0].url.slice(-3).toLowerCase()}`, loading: "lazy" })),
32
+ h("div", { class: "sub-container" },
33
+ h("div", { class: "name" }, (_a = this.currentTrek) === null || _a === void 0 ? void 0 : _a.name),
34
+ h("div", { class: "description", innerHTML: (_b = this.currentTrek) === null || _b === void 0 ? void 0 : _b.description_teaser }),
35
+ h("div", { class: "icons-labels-container" },
36
+ h("div", { class: "row" },
37
+ h("div", { class: "icon-label difficulty" },
38
+ ((_c = this.difficulty) === null || _c === void 0 ? void 0 : _c.pictogram) && h("img", { src: this.difficulty.pictogram }), (_d = this.difficulty) === null || _d === void 0 ? void 0 :
39
+ _d.label),
40
+ h("div", { class: "icon-label duration" },
41
+ h("div", { class: "svg-icon", innerHTML: durationImage }),
42
+ formatDuration(this.currentTrek.duration)),
43
+ h("div", { class: "icon-label route" },
44
+ ((_e = this.route) === null || _e === void 0 ? void 0 : _e.pictogram) && h("img", { src: this.route.pictogram }), (_f = this.route) === null || _f === void 0 ? void 0 :
45
+ _f.route)),
46
+ h("div", { class: "row" },
47
+ h("div", { class: "icon-label length" },
48
+ h("div", { class: "svg-icon", innerHTML: lengthImage }),
49
+ formatLength(this.currentTrek.length_2d)),
50
+ h("div", { class: "icon-label ascent" },
51
+ h("div", { class: "svg-icon", innerHTML: ascentImage }),
52
+ formatAscent(this.currentTrek.ascent)),
53
+ h("div", { class: "icon-label practice" },
54
+ ((_g = this.practice) === null || _g === void 0 ? void 0 : _g.pictogram) && h("img", { src: this.practice.pictogram }), (_h = this.practice) === null || _h === void 0 ? void 0 :
55
+ _h.name))))))));
43
56
  }
44
57
  static get is() { return "grw-trek-card"; }
45
58
  static get encapsulation() { return "shadow"; }
@@ -69,8 +82,50 @@ export class GrwTrekCard {
69
82
  "tags": [],
70
83
  "text": ""
71
84
  }
85
+ },
86
+ "colorPrimary": {
87
+ "type": "string",
88
+ "mutable": false,
89
+ "complexType": {
90
+ "original": "string",
91
+ "resolved": "string",
92
+ "references": {}
93
+ },
94
+ "required": false,
95
+ "optional": false,
96
+ "docs": {
97
+ "tags": [],
98
+ "text": ""
99
+ },
100
+ "attribute": "color-primary",
101
+ "reflect": false,
102
+ "defaultValue": "'#6b0030'"
103
+ },
104
+ "colorPrimaryTint": {
105
+ "type": "string",
106
+ "mutable": false,
107
+ "complexType": {
108
+ "original": "string",
109
+ "resolved": "string",
110
+ "references": {}
111
+ },
112
+ "required": false,
113
+ "optional": false,
114
+ "docs": {
115
+ "tags": [],
116
+ "text": ""
117
+ },
118
+ "attribute": "color-primary-tint",
119
+ "reflect": false,
120
+ "defaultValue": "'#d2b2c0'"
72
121
  }
73
122
  }; }
123
+ static get states() { return {
124
+ "currentTrek": {},
125
+ "difficulty": {},
126
+ "route": {},
127
+ "practice": {}
128
+ }; }
74
129
  static get events() { return [{
75
130
  "method": "trekCardPress",
76
131
  "name": "trekCardPress",
@@ -1,7 +1,7 @@
1
1
  .trek-detail-container {
2
2
  display: flex;
3
3
  flex-direction: column;
4
- max-height: calc(100vh - 64px);
4
+ height: 100%;
5
5
  overflow-y: auto;
6
6
  }
7
7
  .trek-detail-container .name {
@@ -1,45 +1,58 @@
1
- import { Component, Host, h, Prop } from '@stencil/core';
2
- import state from 'store/store';
1
+ import { Component, Host, h, Prop, State } from '@stencil/core';
2
+ import state, { onChange } from 'store/store';
3
3
  import { formatDuration, formatLength, formatAscent } from 'utils/utils';
4
4
  import ascentImage from '../../assets/ascent.svg';
5
5
  import durationImage from '../../assets/duration.svg';
6
6
  import lengthImage from '../../assets/length.svg';
7
7
  export class GrwTrekDetail {
8
+ constructor() {
9
+ this.colorPrimary = '#6b0030';
10
+ this.colorPrimaryTint = '#d2b2c0';
11
+ }
8
12
  componentWillLoad() {
9
13
  this.currentTrek = this.trek ? this.trek : state.currentTrek;
10
- this.difficulty = state.difficulties.find(difficulty => difficulty.id === this.currentTrek.difficulty);
11
- this.route = state.routes.find(route => route.id === this.currentTrek.route);
12
- this.practice = state.practices.find(practice => practice.id === this.currentTrek.practice);
14
+ if (this.currentTrek) {
15
+ this.difficulty = state.difficulties.find(difficulty => difficulty.id === this.currentTrek.difficulty);
16
+ this.route = state.routes.find(route => route.id === this.currentTrek.route);
17
+ this.practice = state.practices.find(practice => practice.id === this.currentTrek.practice);
18
+ }
19
+ onChange('currentTrek', () => {
20
+ this.currentTrek = this.trek ? this.trek : state.currentTrek;
21
+ if (this.currentTrek) {
22
+ this.difficulty = state.difficulties.find(difficulty => difficulty.id === this.currentTrek.difficulty);
23
+ this.route = state.routes.find(route => route.id === this.currentTrek.route);
24
+ this.practice = state.practices.find(practice => practice.id === this.currentTrek.practice);
25
+ }
26
+ });
13
27
  }
14
28
  render() {
15
29
  var _a, _b, _c, _d, _e, _f, _g;
16
- return (h(Host, null,
17
- h("div", { class: "trek-detail-container" },
18
- h("div", { class: "name" }, this.currentTrek.name),
19
- this.currentTrek.attachments[0] && h("img", { class: "image", src: this.currentTrek.attachments[0].url, loading: "lazy" }),
20
- h("div", { class: "sub-container" },
21
- h("div", { class: "icons-labels-container" },
22
- h("div", { class: "row" },
23
- h("div", { class: "icon-label difficulty" },
24
- ((_a = this.difficulty) === null || _a === void 0 ? void 0 : _a.pictogram) && h("img", { src: this.difficulty.pictogram }), (_b = this.difficulty) === null || _b === void 0 ? void 0 :
25
- _b.label),
26
- h("div", { class: "icon-label duration" },
27
- h("div", { class: "svg-icon", innerHTML: durationImage }),
28
- formatDuration((_c = this.currentTrek) === null || _c === void 0 ? void 0 : _c.duration)),
29
- h("div", { class: "icon-label route" },
30
- ((_d = this.route) === null || _d === void 0 ? void 0 : _d.pictogram) && h("img", { src: this.route.pictogram }), (_e = this.route) === null || _e === void 0 ? void 0 :
31
- _e.route)),
32
- h("div", { class: "row" },
33
- h("div", { class: "icon-label length" },
34
- h("div", { class: "svg-icon", innerHTML: lengthImage }),
35
- formatLength(this.currentTrek.length_2d)),
36
- h("div", { class: "icon-label ascent" },
37
- h("div", { class: "svg-icon", innerHTML: ascentImage }),
38
- formatAscent(this.currentTrek.ascent)),
39
- h("div", { class: "icon-label practice" },
40
- ((_f = this.practice) === null || _f === void 0 ? void 0 : _f.pictogram) && h("img", { src: this.practice.pictogram }), (_g = this.practice) === null || _g === void 0 ? void 0 :
41
- _g.name)))),
42
- h("div", { class: "description", innerHTML: this.currentTrek.description ? this.currentTrek.description : this.currentTrek.description_teaser }))));
30
+ return (h(Host, { style: { '--color-primary': this.colorPrimary, '--color-primary-tint': this.colorPrimaryTint } }, this.currentTrek && (h("div", { class: "trek-detail-container" },
31
+ h("div", { class: "name" }, this.currentTrek.name),
32
+ this.currentTrek.attachments && this.currentTrek.attachments[0] && h("img", { class: "image", src: this.currentTrek.attachments[0].url, loading: "lazy" }),
33
+ h("div", { class: "sub-container" },
34
+ h("div", { class: "icons-labels-container" },
35
+ h("div", { class: "row" },
36
+ h("div", { class: "icon-label difficulty" },
37
+ ((_a = this.difficulty) === null || _a === void 0 ? void 0 : _a.pictogram) && h("img", { src: this.difficulty.pictogram }), (_b = this.difficulty) === null || _b === void 0 ? void 0 :
38
+ _b.label),
39
+ h("div", { class: "icon-label duration" },
40
+ h("div", { class: "svg-icon", innerHTML: durationImage }),
41
+ formatDuration((_c = this.currentTrek) === null || _c === void 0 ? void 0 : _c.duration)),
42
+ h("div", { class: "icon-label route" },
43
+ ((_d = this.route) === null || _d === void 0 ? void 0 : _d.pictogram) && h("img", { src: this.route.pictogram }), (_e = this.route) === null || _e === void 0 ? void 0 :
44
+ _e.route)),
45
+ h("div", { class: "row" },
46
+ h("div", { class: "icon-label length" },
47
+ h("div", { class: "svg-icon", innerHTML: lengthImage }),
48
+ formatLength(this.currentTrek.length_2d)),
49
+ h("div", { class: "icon-label ascent" },
50
+ h("div", { class: "svg-icon", innerHTML: ascentImage }),
51
+ formatAscent(this.currentTrek.ascent)),
52
+ h("div", { class: "icon-label practice" },
53
+ ((_f = this.practice) === null || _f === void 0 ? void 0 : _f.pictogram) && h("img", { src: this.practice.pictogram }), (_g = this.practice) === null || _g === void 0 ? void 0 :
54
+ _g.name)))),
55
+ h("div", { class: "description", innerHTML: this.currentTrek.description ? this.currentTrek.description : this.currentTrek.description_teaser })))));
43
56
  }
44
57
  static get is() { return "grw-trek-detail"; }
45
58
  static get encapsulation() { return "shadow"; }
@@ -69,6 +82,48 @@ export class GrwTrekDetail {
69
82
  "tags": [],
70
83
  "text": ""
71
84
  }
85
+ },
86
+ "colorPrimary": {
87
+ "type": "string",
88
+ "mutable": false,
89
+ "complexType": {
90
+ "original": "string",
91
+ "resolved": "string",
92
+ "references": {}
93
+ },
94
+ "required": false,
95
+ "optional": false,
96
+ "docs": {
97
+ "tags": [],
98
+ "text": ""
99
+ },
100
+ "attribute": "color-primary",
101
+ "reflect": false,
102
+ "defaultValue": "'#6b0030'"
103
+ },
104
+ "colorPrimaryTint": {
105
+ "type": "string",
106
+ "mutable": false,
107
+ "complexType": {
108
+ "original": "string",
109
+ "resolved": "string",
110
+ "references": {}
111
+ },
112
+ "required": false,
113
+ "optional": false,
114
+ "docs": {
115
+ "tags": [],
116
+ "text": ""
117
+ },
118
+ "attribute": "color-primary-tint",
119
+ "reflect": false,
120
+ "defaultValue": "'#d2b2c0'"
72
121
  }
73
122
  }; }
123
+ static get states() { return {
124
+ "currentTrek": {},
125
+ "difficulty": {},
126
+ "route": {},
127
+ "practice": {}
128
+ }; }
74
129
  }
@@ -1,20 +1,11 @@
1
1
  :host {
2
2
  display: flex;
3
3
  flex-wrap: wrap;
4
- justify-content: center;
5
- max-height: calc(100vh - 64px);
4
+ justify-content: space-around;
5
+ height: 100%;
6
+ max-height: 100vh;
6
7
  overflow-y: auto;
7
8
  }
8
- @media (min-width: 664px) {
9
- :host {
10
- justify-content: space-between;
11
- }
12
- }
13
- @media (min-width: 996px) {
14
- :host {
15
- justify-content: flex-start;
16
- }
17
- }
18
9
 
19
10
  grw-trek-card {
20
11
  margin: 6px;
@@ -1,14 +1,18 @@
1
- import { Component, Host, h, Element, State } from '@stencil/core';
2
- import state from 'store/store';
1
+ import { Component, Host, h, Element, State, Prop } from '@stencil/core';
2
+ import state, { onChange } from 'store/store';
3
3
  export class GrwTreksList {
4
4
  constructor() {
5
5
  this.treksToDisplay = [];
6
+ this.colorPrimary = '#6b0030';
7
+ this.colorPrimaryTint = '#d2b2c0';
6
8
  this.handleInfiniteScrollBind = this.handleInfiniteScroll.bind(this);
7
9
  this.step = 10;
8
10
  }
9
11
  componentWillLoad() {
10
- this.treksToDisplay = state.treks.slice(0, this.step);
11
12
  this.element.addEventListener('scroll', this.handleInfiniteScrollBind);
13
+ onChange('treks', () => {
14
+ this.treksToDisplay = state.treks.slice(0, this.step);
15
+ });
12
16
  }
13
17
  handleInfiniteScroll(event) {
14
18
  if (event.composedPath()[0].scrollTop + event.composedPath()[0].scrollHeight / 2 >= event.composedPath()[0].scrollHeight) {
@@ -21,7 +25,7 @@ export class GrwTreksList {
21
25
  }
22
26
  }
23
27
  render() {
24
- return (h(Host, { class: "treks-list-container" }, this.treksToDisplay.map(trek => (h("grw-trek-card", { trek: trek })))));
28
+ return (h(Host, { style: { '--color-primary': this.colorPrimary, '--color-primary-tint': this.colorPrimaryTint } }, this.treksToDisplay.map(trek => (h("grw-trek-card", { trek: trek, "color-primary": this.colorPrimary, "color-primary-tint": this.colorPrimaryTint })))));
25
29
  }
26
30
  static get is() { return "grw-treks-list"; }
27
31
  static get encapsulation() { return "shadow"; }
@@ -31,6 +35,44 @@ export class GrwTreksList {
31
35
  static get styleUrls() { return {
32
36
  "$": ["grw-treks-list.css"]
33
37
  }; }
38
+ static get properties() { return {
39
+ "colorPrimary": {
40
+ "type": "string",
41
+ "mutable": false,
42
+ "complexType": {
43
+ "original": "string",
44
+ "resolved": "string",
45
+ "references": {}
46
+ },
47
+ "required": false,
48
+ "optional": false,
49
+ "docs": {
50
+ "tags": [],
51
+ "text": ""
52
+ },
53
+ "attribute": "color-primary",
54
+ "reflect": false,
55
+ "defaultValue": "'#6b0030'"
56
+ },
57
+ "colorPrimaryTint": {
58
+ "type": "string",
59
+ "mutable": false,
60
+ "complexType": {
61
+ "original": "string",
62
+ "resolved": "string",
63
+ "references": {}
64
+ },
65
+ "required": false,
66
+ "optional": false,
67
+ "docs": {
68
+ "tags": [],
69
+ "text": ""
70
+ },
71
+ "attribute": "color-primary-tint",
72
+ "reflect": false,
73
+ "defaultValue": "'#d2b2c0'"
74
+ }
75
+ }; }
34
76
  static get states() { return {
35
77
  "treksToDisplay": {}
36
78
  }; }