@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.
- package/dist/cjs/geotrek-rando-widget.cjs.js +2 -2
- package/dist/cjs/grw-app_7.cjs.entry.js +137 -55
- package/dist/cjs/{index-31255e29.js → index-c6f73e30.js} +36 -0
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/collection/assets/departure-arrival.svg +1 -1
- package/dist/collection/components/grw-app/grw-app.css +60 -37
- package/dist/collection/components/grw-app/grw-app.js +277 -15
- package/dist/collection/components/grw-map/grw-map.css +36 -0
- package/dist/collection/components/grw-map/grw-map.js +157 -18
- package/dist/collection/components/grw-trek-card/grw-trek-card.js +87 -32
- package/dist/collection/components/grw-trek-detail/grw-trek-detail.css +1 -1
- package/dist/collection/components/grw-trek-detail/grw-trek-detail.js +87 -32
- package/dist/collection/components/grw-treks-list/grw-treks-list.css +3 -12
- package/dist/collection/components/grw-treks-list/grw-treks-list.js +46 -4
- package/dist/collection/store/grw-trek-provider.js +28 -6
- package/dist/collection/store/grw-treks-provider.js +155 -9
- package/dist/collection/stories/App.js +31 -1
- package/dist/collection/stories/App.stories.js +21 -1
- package/dist/collection/stories/TrekCard.js +8 -3
- package/dist/collection/stories/TrekCard.stories.js +2 -0
- package/dist/collection/stories/TrekDetail.js +8 -3
- package/dist/collection/stories/TrekDetail.stories.js +2 -0
- package/dist/collection/stories/TrekMap.js +10 -3
- package/dist/collection/stories/TrekMap.stories.js +13 -1
- package/dist/collection/stories/TreksList.js +16 -3
- package/dist/collection/stories/TreksList.stories.js +10 -0
- package/dist/collection/stories/TreksMap.js +12 -3
- package/dist/collection/stories/TreksMap.stories.js +15 -1
- package/dist/components/grw-app.js +39 -6
- package/dist/components/grw-map2.js +56 -20
- package/dist/components/grw-trek-card2.js +25 -7
- package/dist/components/grw-trek-detail2.js +26 -8
- package/dist/components/grw-trek-provider2.js +10 -7
- package/dist/components/grw-treks-list2.js +10 -4
- package/dist/components/grw-treks-provider2.js +26 -11
- package/dist/esm/geotrek-rando-widget.js +2 -2
- package/dist/esm/grw-app_7.entry.js +137 -55
- package/dist/esm/{index-b36f38f5.js → index-7aa9e822.js} +36 -0
- package/dist/esm/loader.js +2 -2
- package/dist/geotrek-rando-widget/geotrek-rando-widget.esm.js +1 -1
- package/dist/geotrek-rando-widget/p-332ba9ab.js +2 -0
- package/dist/geotrek-rando-widget/p-b7c66d2d.entry.js +1 -0
- package/dist/types/components/grw-app/grw-app.d.ts +21 -2
- package/dist/types/components/grw-map/grw-map.d.ts +8 -0
- package/dist/types/components/grw-trek-card/grw-trek-card.d.ts +3 -1
- package/dist/types/components/grw-trek-detail/grw-trek-detail.d.ts +2 -0
- package/dist/types/components/grw-treks-list/grw-treks-list.d.ts +2 -0
- package/dist/types/components.d.ts +70 -0
- package/dist/types/store/grw-trek-provider.d.ts +1 -0
- package/dist/types/store/grw-treks-provider.d.ts +8 -0
- package/package.json +1 -1
- package/dist/geotrek-rando-widget/p-f721481d.js +0 -2
- 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:
|
|
14
|
-
zoom:
|
|
18
|
+
center: this.center.split(',').map(Number),
|
|
19
|
+
zoom: this.zoom,
|
|
15
20
|
});
|
|
16
|
-
L.tileLayer(
|
|
21
|
+
L.tileLayer(this.urlLayer, {
|
|
17
22
|
maxZoom: 19,
|
|
18
|
-
attribution:
|
|
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.
|
|
67
|
+
this.currentBounds = bounds;
|
|
68
|
+
this.map.fitBounds(this.currentBounds);
|
|
54
69
|
}
|
|
55
70
|
this.treksLayer = L.geoJSON(treksFeatureCollection, {
|
|
56
|
-
pointToLayer: (
|
|
71
|
+
pointToLayer: (geoJsonPoint, latlng) => L.marker(latlng, {
|
|
57
72
|
icon: L.divIcon({
|
|
58
73
|
className: 'trek-marker',
|
|
59
74
|
iconSize: 48,
|
|
60
|
-
|
|
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
|
-
|
|
68
|
-
|
|
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.
|
|
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
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
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: {
|
|
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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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("
|
|
18
|
-
|
|
19
|
-
h("div", { class: "
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
h("div", { class: "
|
|
23
|
-
h("div", { class: "
|
|
24
|
-
h("
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
h("div", { class: "icon
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
h("
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
h("div", { class: "
|
|
34
|
-
h("div", { class: "icon
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
h("div", { class: "icon
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
h("
|
|
41
|
-
|
|
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,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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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,
|
|
17
|
-
h("div", { class: "
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
h("div", { class: "
|
|
21
|
-
h("div", { class: "
|
|
22
|
-
h("div", { class: "
|
|
23
|
-
h("
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
h("div", { class: "icon
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
h("
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
h("div", { class: "
|
|
33
|
-
h("div", { class: "icon
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
h("div", { class: "icon
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
h("
|
|
40
|
-
|
|
41
|
-
|
|
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:
|
|
5
|
-
|
|
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, {
|
|
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
|
}; }
|