@geotrekce/geotrek-rando-widget 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.
- package/LICENSE +21 -0
- package/dist/cjs/geotrek-rando-widget.cjs.js +19 -0
- package/dist/cjs/grw-app_7.cjs.entry.js +14662 -0
- package/dist/cjs/index-31255e29.js +1262 -0
- package/dist/cjs/index.cjs.js +2 -0
- package/dist/cjs/loader.cjs.js +21 -0
- package/dist/collection/assets/arrow-back.svg +1 -0
- package/dist/collection/assets/ascent.svg +1 -0
- package/dist/collection/assets/departure-arrival.svg +1 -0
- package/dist/collection/assets/duration.svg +1 -0
- package/dist/collection/assets/length.svg +1 -0
- package/dist/collection/collection-manifest.json +18 -0
- package/dist/collection/components/grw-app/grw-app.css +112 -0
- package/dist/collection/components/grw-app/grw-app.js +156 -0
- package/dist/collection/components/grw-map/grw-map.css +686 -0
- package/dist/collection/components/grw-map/grw-map.js +187 -0
- package/dist/collection/components/grw-trek-card/grw-trek-card.css +66 -0
- package/dist/collection/components/grw-trek-card/grw-trek-card.js +90 -0
- package/dist/collection/components/grw-trek-detail/grw-trek-detail.css +58 -0
- package/dist/collection/components/grw-trek-detail/grw-trek-detail.js +74 -0
- package/dist/collection/components/grw-treks-list/grw-treks-list.css +21 -0
- package/dist/collection/components/grw-treks-list/grw-treks-list.js +38 -0
- package/dist/collection/index.js +1 -0
- package/dist/collection/store/grw-trek-provider.js +63 -0
- package/dist/collection/store/grw-treks-provider.js +65 -0
- package/dist/collection/store/store.js +11 -0
- package/dist/collection/stories/App.js +9 -0
- package/dist/collection/stories/App.stories.js +21 -0
- package/dist/collection/stories/TrekCard.js +7 -0
- package/dist/collection/stories/TrekCard.stories.js +18 -0
- package/dist/collection/stories/TrekDetail.js +7 -0
- package/dist/collection/stories/TrekDetail.stories.js +18 -0
- package/dist/collection/stories/TrekMap.js +11 -0
- package/dist/collection/stories/TrekMap.stories.js +21 -0
- package/dist/collection/stories/TreksList.js +6 -0
- package/dist/collection/stories/TreksList.stories.js +17 -0
- package/dist/collection/stories/TreksMap.js +7 -0
- package/dist/collection/stories/TreksMap.stories.js +17 -0
- package/dist/collection/types/types.js +1 -0
- package/dist/collection/utils/utils.js +19 -0
- package/dist/components/grw-app.d.ts +11 -0
- package/dist/components/grw-app.js +98 -0
- package/dist/components/grw-map.d.ts +11 -0
- package/dist/components/grw-map.js +6 -0
- package/dist/components/grw-map2.js +14288 -0
- package/dist/components/grw-trek-card.d.ts +11 -0
- package/dist/components/grw-trek-card.js +6 -0
- package/dist/components/grw-trek-card2.js +45 -0
- package/dist/components/grw-trek-detail.d.ts +11 -0
- package/dist/components/grw-trek-detail.js +6 -0
- package/dist/components/grw-trek-detail2.js +44 -0
- package/dist/components/grw-trek-provider.d.ts +11 -0
- package/dist/components/grw-trek-provider.js +6 -0
- package/dist/components/grw-trek-provider2.js +49 -0
- package/dist/components/grw-treks-list.d.ts +11 -0
- package/dist/components/grw-treks-list.js +6 -0
- package/dist/components/grw-treks-list2.js +57 -0
- package/dist/components/grw-treks-provider.d.ts +11 -0
- package/dist/components/grw-treks-provider.js +6 -0
- package/dist/components/grw-treks-provider2.js +51 -0
- package/dist/components/index.d.ts +26 -0
- package/dist/components/index.js +1 -0
- package/dist/components/length.js +27 -0
- package/dist/components/store.js +196 -0
- package/dist/esm/geotrek-rando-widget.js +17 -0
- package/dist/esm/grw-app_7.entry.js +14652 -0
- package/dist/esm/index-b36f38f5.js +1232 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/loader.js +17 -0
- package/dist/esm/polyfills/core-js.js +11 -0
- package/dist/esm/polyfills/css-shim.js +1 -0
- package/dist/esm/polyfills/dom.js +79 -0
- package/dist/esm/polyfills/es5-html-element.js +1 -0
- package/dist/esm/polyfills/index.js +34 -0
- package/dist/esm/polyfills/system.js +6 -0
- package/dist/geotrek-rando-widget/geotrek-rando-widget.css +1 -0
- package/dist/geotrek-rando-widget/geotrek-rando-widget.esm.js +1 -0
- package/dist/geotrek-rando-widget/index.esm.js +0 -0
- package/dist/geotrek-rando-widget/p-f721481d.js +2 -0
- package/dist/geotrek-rando-widget/p-fe788eaa.entry.js +1 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/types/components/grw-app/grw-app.d.ts +15 -0
- package/dist/types/components/grw-map/grw-map.d.ts +17 -0
- package/dist/types/components/grw-trek-card/grw-trek-card.d.ts +12 -0
- package/dist/types/components/grw-trek-detail/grw-trek-detail.d.ts +10 -0
- package/dist/types/components/grw-treks-list/grw-treks-list.d.ts +10 -0
- package/dist/types/components.d.ts +149 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/stencil-public-runtime.d.ts +1565 -0
- package/dist/types/store/grw-trek-provider.d.ts +7 -0
- package/dist/types/store/grw-treks-provider.d.ts +6 -0
- package/dist/types/store/store.d.ts +18 -0
- package/dist/types/types/types.d.ts +48 -0
- package/dist/types/utils/utils.d.ts +3 -0
- package/loader/cdn.js +3 -0
- package/loader/index.cjs.js +3 -0
- package/loader/index.d.ts +12 -0
- package/loader/index.es2017.js +3 -0
- package/loader/index.js +4 -0
- package/loader/package.json +10 -0
- package/package.json +57 -0
- package/readme.md +3 -0
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { Component, Host, h, Element, Prop } from '@stencil/core';
|
|
2
|
+
import L from 'leaflet';
|
|
3
|
+
import state, { onChange } from 'store/store';
|
|
4
|
+
import departureArrivalImage from '../../assets/departure-arrival.svg';
|
|
5
|
+
export class GrwMap {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.colorTrekLine = '#6b0030';
|
|
8
|
+
this.colorDepartureIcon = '#006b3b';
|
|
9
|
+
this.colorArrivalIcon = '#85003b';
|
|
10
|
+
}
|
|
11
|
+
componentDidLoad() {
|
|
12
|
+
this.map = L.map(this.element, {
|
|
13
|
+
center: [1, 1],
|
|
14
|
+
zoom: 10,
|
|
15
|
+
});
|
|
16
|
+
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
|
17
|
+
maxZoom: 19,
|
|
18
|
+
attribution: '© OpenStreetMap',
|
|
19
|
+
}).addTo(this.map);
|
|
20
|
+
if (state.currentTrek) {
|
|
21
|
+
this.addTrek();
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
this.addTreks();
|
|
25
|
+
}
|
|
26
|
+
onChange('currentTrek', () => {
|
|
27
|
+
if (state.currentTrek) {
|
|
28
|
+
this.removeTreks();
|
|
29
|
+
this.addTrek();
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
this.addTreks();
|
|
33
|
+
this.removeTrek();
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
addTreks() {
|
|
38
|
+
const treksDepartureCoordinates = [];
|
|
39
|
+
const treksFeatureCollection = {
|
|
40
|
+
type: 'FeatureCollection',
|
|
41
|
+
features: [],
|
|
42
|
+
};
|
|
43
|
+
for (const trek of state.treks) {
|
|
44
|
+
treksDepartureCoordinates.push(trek.departure_geom);
|
|
45
|
+
treksFeatureCollection.features.push({
|
|
46
|
+
type: 'Feature',
|
|
47
|
+
properties: {},
|
|
48
|
+
geometry: { type: 'Point', coordinates: trek.departure_geom },
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
if (treksDepartureCoordinates.length > 0) {
|
|
52
|
+
const bounds = L.latLngBounds(treksDepartureCoordinates.map(coordinate => [coordinate[1], coordinate[0]]));
|
|
53
|
+
this.map.fitBounds(bounds);
|
|
54
|
+
}
|
|
55
|
+
this.treksLayer = L.geoJSON(treksFeatureCollection, {
|
|
56
|
+
pointToLayer: (_geoJsonPoint, latlng) => L.marker(latlng, {
|
|
57
|
+
icon: L.divIcon({
|
|
58
|
+
className: 'trek-marker',
|
|
59
|
+
iconSize: 48,
|
|
60
|
+
iconAnchor: [0, 48],
|
|
61
|
+
}),
|
|
62
|
+
autoPanOnFocus: false,
|
|
63
|
+
}),
|
|
64
|
+
}).addTo(this.map);
|
|
65
|
+
}
|
|
66
|
+
removeTreks() {
|
|
67
|
+
this.map.removeLayer(this.treksLayer);
|
|
68
|
+
this.treksLayer = null;
|
|
69
|
+
}
|
|
70
|
+
addTrek() {
|
|
71
|
+
const trekFeature = {
|
|
72
|
+
type: 'Feature',
|
|
73
|
+
geometry: state.currentTrek.geometry,
|
|
74
|
+
properties: {},
|
|
75
|
+
};
|
|
76
|
+
this.trekLayer = L.geoJSON(trekFeature, {
|
|
77
|
+
style: () => ({
|
|
78
|
+
color: this.colorTrekLine,
|
|
79
|
+
}),
|
|
80
|
+
}).addTo(this.map);
|
|
81
|
+
const bounds = L.latLngBounds(state.currentTrek.geometry.coordinates.map(coordinate => [coordinate[1], coordinate[0]]));
|
|
82
|
+
this.map.fitBounds(bounds);
|
|
83
|
+
const departureCoordinates = [state.currentTrek.geometry.coordinates.at(0)[0], state.currentTrek.geometry.coordinates.at(0)[1]];
|
|
84
|
+
const arrivalCoordinates = [state.currentTrek.geometry.coordinates.at(-1)[0], state.currentTrek.geometry.coordinates.at(-1)[1]];
|
|
85
|
+
const departureArrivalFeatureCollection = {
|
|
86
|
+
type: 'FeatureCollection',
|
|
87
|
+
features: [
|
|
88
|
+
{
|
|
89
|
+
type: 'Feature',
|
|
90
|
+
properties: { type: 'departure' },
|
|
91
|
+
geometry: { type: 'Point', coordinates: departureCoordinates },
|
|
92
|
+
},
|
|
93
|
+
],
|
|
94
|
+
};
|
|
95
|
+
if (departureCoordinates[0] !== arrivalCoordinates[0] || departureCoordinates[1] !== arrivalCoordinates[1]) {
|
|
96
|
+
departureArrivalFeatureCollection.features.push({
|
|
97
|
+
type: 'Feature',
|
|
98
|
+
properties: { type: 'arrival' },
|
|
99
|
+
geometry: { type: 'Point', coordinates: arrivalCoordinates },
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
this.departureArrivalLayer = L.geoJSON(departureArrivalFeatureCollection, {
|
|
103
|
+
pointToLayer: (geoJsonPoint, latlng) => L.marker(latlng, {
|
|
104
|
+
icon: L.divIcon({
|
|
105
|
+
html: departureArrivalImage,
|
|
106
|
+
className: geoJsonPoint.properties.type === 'departure' ? 'departure-icon' : 'arrival-icon',
|
|
107
|
+
iconSize: 48,
|
|
108
|
+
iconAnchor: [0, 48],
|
|
109
|
+
}),
|
|
110
|
+
autoPanOnFocus: false,
|
|
111
|
+
}),
|
|
112
|
+
}).addTo(this.map);
|
|
113
|
+
}
|
|
114
|
+
removeTrek() {
|
|
115
|
+
this.map.removeLayer(this.trekLayer);
|
|
116
|
+
this.map.removeLayer(this.departureArrivalLayer);
|
|
117
|
+
this.trekLayer = null;
|
|
118
|
+
this.departureArrivalLayer = null;
|
|
119
|
+
}
|
|
120
|
+
render() {
|
|
121
|
+
return h(Host, { style: { '--color-departure-icon': this.colorDepartureIcon, '--color-arrival-icon': this.colorArrivalIcon } });
|
|
122
|
+
}
|
|
123
|
+
static get is() { return "grw-map"; }
|
|
124
|
+
static get originalStyleUrls() { return {
|
|
125
|
+
"$": ["grw-map.scss"]
|
|
126
|
+
}; }
|
|
127
|
+
static get styleUrls() { return {
|
|
128
|
+
"$": ["grw-map.css"]
|
|
129
|
+
}; }
|
|
130
|
+
static get properties() { return {
|
|
131
|
+
"colorTrekLine": {
|
|
132
|
+
"type": "string",
|
|
133
|
+
"mutable": false,
|
|
134
|
+
"complexType": {
|
|
135
|
+
"original": "string",
|
|
136
|
+
"resolved": "string",
|
|
137
|
+
"references": {}
|
|
138
|
+
},
|
|
139
|
+
"required": false,
|
|
140
|
+
"optional": false,
|
|
141
|
+
"docs": {
|
|
142
|
+
"tags": [],
|
|
143
|
+
"text": ""
|
|
144
|
+
},
|
|
145
|
+
"attribute": "color-trek-line",
|
|
146
|
+
"reflect": false,
|
|
147
|
+
"defaultValue": "'#6b0030'"
|
|
148
|
+
},
|
|
149
|
+
"colorDepartureIcon": {
|
|
150
|
+
"type": "string",
|
|
151
|
+
"mutable": false,
|
|
152
|
+
"complexType": {
|
|
153
|
+
"original": "string",
|
|
154
|
+
"resolved": "string",
|
|
155
|
+
"references": {}
|
|
156
|
+
},
|
|
157
|
+
"required": false,
|
|
158
|
+
"optional": false,
|
|
159
|
+
"docs": {
|
|
160
|
+
"tags": [],
|
|
161
|
+
"text": ""
|
|
162
|
+
},
|
|
163
|
+
"attribute": "color-departure-icon",
|
|
164
|
+
"reflect": false,
|
|
165
|
+
"defaultValue": "'#006b3b'"
|
|
166
|
+
},
|
|
167
|
+
"colorArrivalIcon": {
|
|
168
|
+
"type": "string",
|
|
169
|
+
"mutable": false,
|
|
170
|
+
"complexType": {
|
|
171
|
+
"original": "string",
|
|
172
|
+
"resolved": "string",
|
|
173
|
+
"references": {}
|
|
174
|
+
},
|
|
175
|
+
"required": false,
|
|
176
|
+
"optional": false,
|
|
177
|
+
"docs": {
|
|
178
|
+
"tags": [],
|
|
179
|
+
"text": ""
|
|
180
|
+
},
|
|
181
|
+
"attribute": "color-arrival-icon",
|
|
182
|
+
"reflect": false,
|
|
183
|
+
"defaultValue": "'#85003b'"
|
|
184
|
+
}
|
|
185
|
+
}; }
|
|
186
|
+
static get elementRef() { return "element"; }
|
|
187
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
.trek-card-container {
|
|
2
|
+
width: 350px;
|
|
3
|
+
height: auto;
|
|
4
|
+
border-radius: 8px;
|
|
5
|
+
box-shadow: 4px 8px 24px rgba(0, 0, 0, 0.25);
|
|
6
|
+
cursor: pointer;
|
|
7
|
+
}
|
|
8
|
+
.trek-card-container .image {
|
|
9
|
+
width: 100%;
|
|
10
|
+
height: auto;
|
|
11
|
+
}
|
|
12
|
+
.trek-card-container .sub-container {
|
|
13
|
+
padding: 12px;
|
|
14
|
+
}
|
|
15
|
+
.trek-card-container .sub-container .name {
|
|
16
|
+
color: var(--color-primary);
|
|
17
|
+
font-size: 24px;
|
|
18
|
+
font-weight: bold;
|
|
19
|
+
margin-bottom: 12px;
|
|
20
|
+
}
|
|
21
|
+
.trek-card-container .sub-container .description {
|
|
22
|
+
max-height: 24px;
|
|
23
|
+
white-space: nowrap;
|
|
24
|
+
overflow: hidden;
|
|
25
|
+
text-overflow: ellipsis;
|
|
26
|
+
margin-bottom: 12px;
|
|
27
|
+
}
|
|
28
|
+
.trek-card-container .sub-container .description p {
|
|
29
|
+
white-space: nowrap;
|
|
30
|
+
overflow: hidden;
|
|
31
|
+
text-overflow: ellipsis;
|
|
32
|
+
margin: 0;
|
|
33
|
+
}
|
|
34
|
+
.trek-card-container .sub-container .icons-labels-container {
|
|
35
|
+
display: flex;
|
|
36
|
+
justify-content: flex-start;
|
|
37
|
+
align-items: center;
|
|
38
|
+
flex-wrap: wrap;
|
|
39
|
+
}
|
|
40
|
+
.trek-card-container .sub-container .icons-labels-container .row {
|
|
41
|
+
display: flex;
|
|
42
|
+
justify-content: space-between;
|
|
43
|
+
align-items: center;
|
|
44
|
+
width: 100%;
|
|
45
|
+
}
|
|
46
|
+
.trek-card-container .sub-container .icons-labels-container .row:not(:last-child) {
|
|
47
|
+
margin-bottom: 12px;
|
|
48
|
+
}
|
|
49
|
+
.trek-card-container .sub-container .icons-labels-container .row .icon-label {
|
|
50
|
+
display: flex;
|
|
51
|
+
justify-content: center;
|
|
52
|
+
align-items: center;
|
|
53
|
+
width: 33.3333333333%;
|
|
54
|
+
}
|
|
55
|
+
.trek-card-container .sub-container .icons-labels-container .row .icon-label:nth-child(2) {
|
|
56
|
+
margin: 0px 4px;
|
|
57
|
+
}
|
|
58
|
+
.trek-card-container .sub-container .icons-labels-container .row .icon-label img,
|
|
59
|
+
.trek-card-container .sub-container .icons-labels-container .row .icon-label .svg-icon svg {
|
|
60
|
+
width: 24px;
|
|
61
|
+
height: auto;
|
|
62
|
+
margin-right: 24px;
|
|
63
|
+
}
|
|
64
|
+
.trek-card-container .sub-container .icons-labels-container .row .practice img {
|
|
65
|
+
background-color: var(--color-primary);
|
|
66
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { Component, Host, h, Prop, Event } from '@stencil/core';
|
|
2
|
+
import state from 'store/store';
|
|
3
|
+
import { formatDuration, formatLength, formatAscent } from 'utils/utils';
|
|
4
|
+
import ascentImage from '../../assets/ascent.svg';
|
|
5
|
+
import durationImage from '../../assets/duration.svg';
|
|
6
|
+
import lengthImage from '../../assets/length.svg';
|
|
7
|
+
export class GrwTrekCard {
|
|
8
|
+
componentWillLoad() {
|
|
9
|
+
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);
|
|
13
|
+
}
|
|
14
|
+
render() {
|
|
15
|
+
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)))))));
|
|
43
|
+
}
|
|
44
|
+
static get is() { return "grw-trek-card"; }
|
|
45
|
+
static get encapsulation() { return "shadow"; }
|
|
46
|
+
static get originalStyleUrls() { return {
|
|
47
|
+
"$": ["grw-trek-card.scss"]
|
|
48
|
+
}; }
|
|
49
|
+
static get styleUrls() { return {
|
|
50
|
+
"$": ["grw-trek-card.css"]
|
|
51
|
+
}; }
|
|
52
|
+
static get properties() { return {
|
|
53
|
+
"trek": {
|
|
54
|
+
"type": "unknown",
|
|
55
|
+
"mutable": false,
|
|
56
|
+
"complexType": {
|
|
57
|
+
"original": "Trek",
|
|
58
|
+
"resolved": "{ id: number; name: string; attachments: Attachments; description?: string; description_teaser: string; difficulty: number; route: number; practice: number; duration: number; length_2d: number; ascent: number; geometry?: LineString; departure_geom?: Position; }",
|
|
59
|
+
"references": {
|
|
60
|
+
"Trek": {
|
|
61
|
+
"location": "import",
|
|
62
|
+
"path": "types/types"
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
"required": false,
|
|
67
|
+
"optional": false,
|
|
68
|
+
"docs": {
|
|
69
|
+
"tags": [],
|
|
70
|
+
"text": ""
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}; }
|
|
74
|
+
static get events() { return [{
|
|
75
|
+
"method": "trekCardPress",
|
|
76
|
+
"name": "trekCardPress",
|
|
77
|
+
"bubbles": true,
|
|
78
|
+
"cancelable": true,
|
|
79
|
+
"composed": true,
|
|
80
|
+
"docs": {
|
|
81
|
+
"tags": [],
|
|
82
|
+
"text": ""
|
|
83
|
+
},
|
|
84
|
+
"complexType": {
|
|
85
|
+
"original": "number",
|
|
86
|
+
"resolved": "number",
|
|
87
|
+
"references": {}
|
|
88
|
+
}
|
|
89
|
+
}]; }
|
|
90
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
.trek-detail-container {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
max-height: calc(100vh - 64px);
|
|
5
|
+
overflow-y: auto;
|
|
6
|
+
}
|
|
7
|
+
.trek-detail-container .name {
|
|
8
|
+
color: var(--color-primary);
|
|
9
|
+
font-size: 48px;
|
|
10
|
+
font-weight: bold;
|
|
11
|
+
padding: 24px;
|
|
12
|
+
}
|
|
13
|
+
.trek-detail-container .image {
|
|
14
|
+
align-self: center;
|
|
15
|
+
width: 100%;
|
|
16
|
+
max-width: 700px;
|
|
17
|
+
height: auto;
|
|
18
|
+
box-shadow: 4px 8px 24px rgba(0, 0, 0, 0.25);
|
|
19
|
+
}
|
|
20
|
+
.trek-detail-container .sub-container {
|
|
21
|
+
padding: 24px;
|
|
22
|
+
}
|
|
23
|
+
.trek-detail-container .sub-container .icons-labels-container {
|
|
24
|
+
display: flex;
|
|
25
|
+
justify-content: flex-start;
|
|
26
|
+
align-items: center;
|
|
27
|
+
flex-wrap: wrap;
|
|
28
|
+
}
|
|
29
|
+
.trek-detail-container .sub-container .icons-labels-container .row {
|
|
30
|
+
display: flex;
|
|
31
|
+
justify-content: space-between;
|
|
32
|
+
align-items: center;
|
|
33
|
+
width: 100%;
|
|
34
|
+
}
|
|
35
|
+
.trek-detail-container .sub-container .icons-labels-container .row:not(:last-child) {
|
|
36
|
+
margin-bottom: 24px;
|
|
37
|
+
}
|
|
38
|
+
.trek-detail-container .sub-container .icons-labels-container .row .icon-label {
|
|
39
|
+
display: flex;
|
|
40
|
+
justify-content: center;
|
|
41
|
+
align-items: center;
|
|
42
|
+
width: 33.3333333333%;
|
|
43
|
+
}
|
|
44
|
+
.trek-detail-container .sub-container .icons-labels-container .row .icon-label:nth-child(2) {
|
|
45
|
+
margin: 0px 8px;
|
|
46
|
+
}
|
|
47
|
+
.trek-detail-container .sub-container .icons-labels-container .row .icon-label img,
|
|
48
|
+
.trek-detail-container .sub-container .icons-labels-container .row .icon-label .svg-icon svg {
|
|
49
|
+
width: 24px;
|
|
50
|
+
height: auto;
|
|
51
|
+
margin-right: 24px;
|
|
52
|
+
}
|
|
53
|
+
.trek-detail-container .sub-container .icons-labels-container .row .practice img {
|
|
54
|
+
background-color: var(--color-primary);
|
|
55
|
+
}
|
|
56
|
+
.trek-detail-container .description {
|
|
57
|
+
padding: 0px 24px 24px 24px;
|
|
58
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { Component, Host, h, Prop } from '@stencil/core';
|
|
2
|
+
import state from 'store/store';
|
|
3
|
+
import { formatDuration, formatLength, formatAscent } from 'utils/utils';
|
|
4
|
+
import ascentImage from '../../assets/ascent.svg';
|
|
5
|
+
import durationImage from '../../assets/duration.svg';
|
|
6
|
+
import lengthImage from '../../assets/length.svg';
|
|
7
|
+
export class GrwTrekDetail {
|
|
8
|
+
componentWillLoad() {
|
|
9
|
+
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);
|
|
13
|
+
}
|
|
14
|
+
render() {
|
|
15
|
+
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 }))));
|
|
43
|
+
}
|
|
44
|
+
static get is() { return "grw-trek-detail"; }
|
|
45
|
+
static get encapsulation() { return "shadow"; }
|
|
46
|
+
static get originalStyleUrls() { return {
|
|
47
|
+
"$": ["grw-trek-detail.scss"]
|
|
48
|
+
}; }
|
|
49
|
+
static get styleUrls() { return {
|
|
50
|
+
"$": ["grw-trek-detail.css"]
|
|
51
|
+
}; }
|
|
52
|
+
static get properties() { return {
|
|
53
|
+
"trek": {
|
|
54
|
+
"type": "unknown",
|
|
55
|
+
"mutable": false,
|
|
56
|
+
"complexType": {
|
|
57
|
+
"original": "Trek",
|
|
58
|
+
"resolved": "{ id: number; name: string; attachments: Attachments; description?: string; description_teaser: string; difficulty: number; route: number; practice: number; duration: number; length_2d: number; ascent: number; geometry?: LineString; departure_geom?: Position; }",
|
|
59
|
+
"references": {
|
|
60
|
+
"Trek": {
|
|
61
|
+
"location": "import",
|
|
62
|
+
"path": "types/types"
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
"required": false,
|
|
67
|
+
"optional": false,
|
|
68
|
+
"docs": {
|
|
69
|
+
"tags": [],
|
|
70
|
+
"text": ""
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}; }
|
|
74
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-wrap: wrap;
|
|
4
|
+
justify-content: center;
|
|
5
|
+
max-height: calc(100vh - 64px);
|
|
6
|
+
overflow-y: auto;
|
|
7
|
+
}
|
|
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
|
+
|
|
19
|
+
grw-trek-card {
|
|
20
|
+
margin: 6px;
|
|
21
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Component, Host, h, Element, State } from '@stencil/core';
|
|
2
|
+
import state from 'store/store';
|
|
3
|
+
export class GrwTreksList {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.treksToDisplay = [];
|
|
6
|
+
this.handleInfiniteScrollBind = this.handleInfiniteScroll.bind(this);
|
|
7
|
+
this.step = 10;
|
|
8
|
+
}
|
|
9
|
+
componentWillLoad() {
|
|
10
|
+
this.treksToDisplay = state.treks.slice(0, this.step);
|
|
11
|
+
this.element.addEventListener('scroll', this.handleInfiniteScrollBind);
|
|
12
|
+
}
|
|
13
|
+
handleInfiniteScroll(event) {
|
|
14
|
+
if (event.composedPath()[0].scrollTop + event.composedPath()[0].scrollHeight / 2 >= event.composedPath()[0].scrollHeight) {
|
|
15
|
+
if (this.treksToDisplay.length < state.treks.length) {
|
|
16
|
+
this.treksToDisplay = state.treks.slice(0, this.treksToDisplay.length + this.step >= state.treks.length ? state.treks.length : this.treksToDisplay.length + this.step);
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
this.element.removeEventListener('scroll', this.handleInfiniteScrollBind);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
render() {
|
|
24
|
+
return (h(Host, { class: "treks-list-container" }, this.treksToDisplay.map(trek => (h("grw-trek-card", { trek: trek })))));
|
|
25
|
+
}
|
|
26
|
+
static get is() { return "grw-treks-list"; }
|
|
27
|
+
static get encapsulation() { return "shadow"; }
|
|
28
|
+
static get originalStyleUrls() { return {
|
|
29
|
+
"$": ["grw-treks-list.scss"]
|
|
30
|
+
}; }
|
|
31
|
+
static get styleUrls() { return {
|
|
32
|
+
"$": ["grw-treks-list.css"]
|
|
33
|
+
}; }
|
|
34
|
+
static get states() { return {
|
|
35
|
+
"treksToDisplay": {}
|
|
36
|
+
}; }
|
|
37
|
+
static get elementRef() { return "element"; }
|
|
38
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { Component, h, Host, Prop } from '@stencil/core';
|
|
2
|
+
import state from 'store/store';
|
|
3
|
+
export class GrwTrekProvider {
|
|
4
|
+
componentWillLoad() {
|
|
5
|
+
state.api = this.api;
|
|
6
|
+
return Promise.all([
|
|
7
|
+
fetch(`${this.api}trek/${this.trekId}/?language=fr&fields=id,name,attachments,description,description_teaser,difficulty,duration,ascent,length_2d,practice,route,geometry`),
|
|
8
|
+
fetch(`${this.api}trek_difficulty/?language=fr`),
|
|
9
|
+
fetch(`${this.api}trek_route/?language=fr`),
|
|
10
|
+
fetch(`${this.api}trek_practice/?language=fr`),
|
|
11
|
+
])
|
|
12
|
+
.then(responses => Promise.all(responses.map(response => response.json())))
|
|
13
|
+
.then(([trek, difficulties, routes, practices]) => {
|
|
14
|
+
state.currentTrek = trek;
|
|
15
|
+
state.difficulties = difficulties.results;
|
|
16
|
+
state.routes = routes.results;
|
|
17
|
+
state.practices = practices.results;
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
disconnectedCallback() {
|
|
21
|
+
state.currentTrek = null;
|
|
22
|
+
}
|
|
23
|
+
render() {
|
|
24
|
+
return h(Host, null);
|
|
25
|
+
}
|
|
26
|
+
static get is() { return "grw-trek-provider"; }
|
|
27
|
+
static get properties() { return {
|
|
28
|
+
"api": {
|
|
29
|
+
"type": "string",
|
|
30
|
+
"mutable": false,
|
|
31
|
+
"complexType": {
|
|
32
|
+
"original": "string",
|
|
33
|
+
"resolved": "string",
|
|
34
|
+
"references": {}
|
|
35
|
+
},
|
|
36
|
+
"required": false,
|
|
37
|
+
"optional": false,
|
|
38
|
+
"docs": {
|
|
39
|
+
"tags": [],
|
|
40
|
+
"text": ""
|
|
41
|
+
},
|
|
42
|
+
"attribute": "api",
|
|
43
|
+
"reflect": false
|
|
44
|
+
},
|
|
45
|
+
"trekId": {
|
|
46
|
+
"type": "string",
|
|
47
|
+
"mutable": false,
|
|
48
|
+
"complexType": {
|
|
49
|
+
"original": "string",
|
|
50
|
+
"resolved": "string",
|
|
51
|
+
"references": {}
|
|
52
|
+
},
|
|
53
|
+
"required": false,
|
|
54
|
+
"optional": false,
|
|
55
|
+
"docs": {
|
|
56
|
+
"tags": [],
|
|
57
|
+
"text": ""
|
|
58
|
+
},
|
|
59
|
+
"attribute": "trek-id",
|
|
60
|
+
"reflect": false
|
|
61
|
+
}
|
|
62
|
+
}; }
|
|
63
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { Component, h, Host, Prop } from '@stencil/core';
|
|
2
|
+
import state from 'store/store';
|
|
3
|
+
export class GrwTreksProvider {
|
|
4
|
+
componentWillLoad() {
|
|
5
|
+
state.api = this.api;
|
|
6
|
+
let treksRequest = `${this.api}trek/?language=fr`;
|
|
7
|
+
if (this.portals) {
|
|
8
|
+
treksRequest += `&portals=${this.portals}`;
|
|
9
|
+
}
|
|
10
|
+
treksRequest += `&fields=id,name,attachments,description_teaser,difficulty,duration,ascent,length_2d,practice,route,departure_geom&page_size=999`;
|
|
11
|
+
return Promise.all([
|
|
12
|
+
fetch(treksRequest),
|
|
13
|
+
fetch(`${this.api}trek_difficulty/?language=fr`),
|
|
14
|
+
fetch(`${this.api}trek_route/?language=fr`),
|
|
15
|
+
fetch(`${this.api}trek_practice/?language=fr`),
|
|
16
|
+
])
|
|
17
|
+
.then(responses => Promise.all(responses.map(response => response.json())))
|
|
18
|
+
.then(([treks, difficulties, routes, practices]) => {
|
|
19
|
+
state.treks = treks.results;
|
|
20
|
+
state.difficulties = difficulties.results;
|
|
21
|
+
state.routes = routes.results;
|
|
22
|
+
state.practices = practices.results;
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
render() {
|
|
26
|
+
return h(Host, null);
|
|
27
|
+
}
|
|
28
|
+
static get is() { return "grw-treks-provider"; }
|
|
29
|
+
static get properties() { return {
|
|
30
|
+
"api": {
|
|
31
|
+
"type": "string",
|
|
32
|
+
"mutable": false,
|
|
33
|
+
"complexType": {
|
|
34
|
+
"original": "string",
|
|
35
|
+
"resolved": "string",
|
|
36
|
+
"references": {}
|
|
37
|
+
},
|
|
38
|
+
"required": false,
|
|
39
|
+
"optional": false,
|
|
40
|
+
"docs": {
|
|
41
|
+
"tags": [],
|
|
42
|
+
"text": ""
|
|
43
|
+
},
|
|
44
|
+
"attribute": "api",
|
|
45
|
+
"reflect": false
|
|
46
|
+
},
|
|
47
|
+
"portals": {
|
|
48
|
+
"type": "string",
|
|
49
|
+
"mutable": false,
|
|
50
|
+
"complexType": {
|
|
51
|
+
"original": "string",
|
|
52
|
+
"resolved": "string",
|
|
53
|
+
"references": {}
|
|
54
|
+
},
|
|
55
|
+
"required": false,
|
|
56
|
+
"optional": false,
|
|
57
|
+
"docs": {
|
|
58
|
+
"tags": [],
|
|
59
|
+
"text": ""
|
|
60
|
+
},
|
|
61
|
+
"attribute": "portals",
|
|
62
|
+
"reflect": false
|
|
63
|
+
}
|
|
64
|
+
}; }
|
|
65
|
+
}
|