@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,20 +1,23 @@
1
1
  import { Component, h, Host, Prop } from '@stencil/core';
2
2
  import state from 'store/store';
3
3
  export class GrwTrekProvider {
4
+ constructor() {
5
+ this.language = 'fr';
6
+ }
4
7
  componentWillLoad() {
5
8
  state.api = this.api;
6
9
  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`),
10
+ fetch(`${this.api}trek_difficulty/?language=${this.language}`),
11
+ fetch(`${this.api}trek_route/?language=${this.language}`),
12
+ fetch(`${this.api}trek_practice/?language=${this.language}`),
13
+ fetch(`${this.api}trek/${this.trekId}/?language=${this.language}&fields=id,name,attachments,description,description_teaser,difficulty,duration,ascent,length_2d,practice,route,geometry`),
11
14
  ])
12
15
  .then(responses => Promise.all(responses.map(response => response.json())))
13
- .then(([trek, difficulties, routes, practices]) => {
14
- state.currentTrek = trek;
16
+ .then(([difficulties, routes, practices, trek]) => {
15
17
  state.difficulties = difficulties.results;
16
18
  state.routes = routes.results;
17
19
  state.practices = practices.results;
20
+ state.currentTrek = trek;
18
21
  });
19
22
  }
20
23
  disconnectedCallback() {
@@ -24,7 +27,26 @@ export class GrwTrekProvider {
24
27
  return h(Host, null);
25
28
  }
26
29
  static get is() { return "grw-trek-provider"; }
30
+ static get encapsulation() { return "shadow"; }
27
31
  static get properties() { return {
32
+ "language": {
33
+ "type": "string",
34
+ "mutable": false,
35
+ "complexType": {
36
+ "original": "string",
37
+ "resolved": "string",
38
+ "references": {}
39
+ },
40
+ "required": false,
41
+ "optional": false,
42
+ "docs": {
43
+ "tags": [],
44
+ "text": ""
45
+ },
46
+ "attribute": "language",
47
+ "reflect": false,
48
+ "defaultValue": "'fr'"
49
+ },
28
50
  "api": {
29
51
  "type": "string",
30
52
  "mutable": false,
@@ -1,32 +1,59 @@
1
1
  import { Component, h, Host, Prop } from '@stencil/core';
2
2
  import state from 'store/store';
3
3
  export class GrwTreksProvider {
4
+ constructor() {
5
+ this.language = 'fr';
6
+ }
4
7
  componentWillLoad() {
5
8
  state.api = this.api;
6
- let treksRequest = `${this.api}trek/?language=fr`;
7
- if (this.portals) {
8
- treksRequest += `&portals=${this.portals}`;
9
- }
9
+ let treksRequest = `${this.api}trek/?language=${this.language}`;
10
+ this.inBbox && (treksRequest += `&in_bbox=${this.inBbox}`);
11
+ this.cities && (treksRequest += `&cities=${this.cities}`);
12
+ this.districts && (treksRequest += `&districts=${this.districts}`);
13
+ this.structures && (treksRequest += `&structures=${this.structures}`);
14
+ this.themes && (treksRequest += `&themes=${this.themes}`);
15
+ this.portals && (treksRequest += `&portals=${this.portals}`);
16
+ this.routes && (treksRequest += `&routes=${this.routes}`);
17
+ this.practices && (treksRequest += `&practices=${this.practices}`);
10
18
  treksRequest += `&fields=id,name,attachments,description_teaser,difficulty,duration,ascent,length_2d,practice,route,departure_geom&page_size=999`;
11
19
  return Promise.all([
20
+ fetch(`${this.api}trek_difficulty/?language=${this.language}`),
21
+ fetch(`${this.api}trek_route/?language=${this.language}`),
22
+ fetch(`${this.api}trek_practice/?language=${this.language}`),
12
23
  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
24
  ])
17
25
  .then(responses => Promise.all(responses.map(response => response.json())))
18
- .then(([treks, difficulties, routes, practices]) => {
19
- state.treks = treks.results;
26
+ .then(([difficulties, routes, practices, treks]) => {
20
27
  state.difficulties = difficulties.results;
21
28
  state.routes = routes.results;
22
29
  state.practices = practices.results;
30
+ state.treks = treks.results;
23
31
  });
24
32
  }
25
33
  render() {
26
34
  return h(Host, null);
27
35
  }
28
36
  static get is() { return "grw-treks-provider"; }
37
+ static get encapsulation() { return "shadow"; }
29
38
  static get properties() { return {
39
+ "language": {
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": "language",
54
+ "reflect": false,
55
+ "defaultValue": "'fr'"
56
+ },
30
57
  "api": {
31
58
  "type": "string",
32
59
  "mutable": false,
@@ -44,6 +71,91 @@ export class GrwTreksProvider {
44
71
  "attribute": "api",
45
72
  "reflect": false
46
73
  },
74
+ "inBbox": {
75
+ "type": "string",
76
+ "mutable": false,
77
+ "complexType": {
78
+ "original": "string",
79
+ "resolved": "string",
80
+ "references": {}
81
+ },
82
+ "required": false,
83
+ "optional": false,
84
+ "docs": {
85
+ "tags": [],
86
+ "text": ""
87
+ },
88
+ "attribute": "in-bbox",
89
+ "reflect": false
90
+ },
91
+ "cities": {
92
+ "type": "string",
93
+ "mutable": false,
94
+ "complexType": {
95
+ "original": "string",
96
+ "resolved": "string",
97
+ "references": {}
98
+ },
99
+ "required": false,
100
+ "optional": false,
101
+ "docs": {
102
+ "tags": [],
103
+ "text": ""
104
+ },
105
+ "attribute": "cities",
106
+ "reflect": false
107
+ },
108
+ "districts": {
109
+ "type": "string",
110
+ "mutable": false,
111
+ "complexType": {
112
+ "original": "string",
113
+ "resolved": "string",
114
+ "references": {}
115
+ },
116
+ "required": false,
117
+ "optional": false,
118
+ "docs": {
119
+ "tags": [],
120
+ "text": ""
121
+ },
122
+ "attribute": "districts",
123
+ "reflect": false
124
+ },
125
+ "structures": {
126
+ "type": "string",
127
+ "mutable": false,
128
+ "complexType": {
129
+ "original": "string",
130
+ "resolved": "string",
131
+ "references": {}
132
+ },
133
+ "required": false,
134
+ "optional": false,
135
+ "docs": {
136
+ "tags": [],
137
+ "text": ""
138
+ },
139
+ "attribute": "structures",
140
+ "reflect": false
141
+ },
142
+ "themes": {
143
+ "type": "string",
144
+ "mutable": false,
145
+ "complexType": {
146
+ "original": "string",
147
+ "resolved": "string",
148
+ "references": {}
149
+ },
150
+ "required": false,
151
+ "optional": false,
152
+ "docs": {
153
+ "tags": [],
154
+ "text": ""
155
+ },
156
+ "attribute": "themes",
157
+ "reflect": false
158
+ },
47
159
  "portals": {
48
160
  "type": "string",
49
161
  "mutable": false,
@@ -60,6 +172,40 @@ export class GrwTreksProvider {
60
172
  },
61
173
  "attribute": "portals",
62
174
  "reflect": false
175
+ },
176
+ "routes": {
177
+ "type": "string",
178
+ "mutable": false,
179
+ "complexType": {
180
+ "original": "string",
181
+ "resolved": "string",
182
+ "references": {}
183
+ },
184
+ "required": false,
185
+ "optional": false,
186
+ "docs": {
187
+ "tags": [],
188
+ "text": ""
189
+ },
190
+ "attribute": "routes",
191
+ "reflect": false
192
+ },
193
+ "practices": {
194
+ "type": "string",
195
+ "mutable": false,
196
+ "complexType": {
197
+ "original": "string",
198
+ "resolved": "string",
199
+ "references": {}
200
+ },
201
+ "required": false,
202
+ "optional": false,
203
+ "docs": {
204
+ "tags": [],
205
+ "text": ""
206
+ },
207
+ "attribute": "practices",
208
+ "reflect": false
63
209
  }
64
210
  }; }
65
211
  }
@@ -1,9 +1,39 @@
1
- export const createApp = ({ api, portals, appName, colorPrimary, colorPrimaryTint }) => {
1
+ export const createApp = ({
2
+ api,
3
+ inBbox,
4
+ cities,
5
+ districts,
6
+ structures,
7
+ themes,
8
+ portals,
9
+ routes,
10
+ practices,
11
+ appName,
12
+ urlLayer,
13
+ attribution,
14
+ colorPrimary,
15
+ colorPrimaryTint,
16
+ trekLineColor,
17
+ departureIconColor,
18
+ arrivalIconColor,
19
+ }) => {
2
20
  const app = document.createElement('grw-app');
3
21
  app.setAttribute('api', api);
22
+ app.setAttribute('in-bbox', inBbox);
23
+ app.setAttribute('cities', cities);
24
+ app.setAttribute('districts', districts);
25
+ app.setAttribute('structures', structures);
26
+ app.setAttribute('themes', themes);
4
27
  app.setAttribute('portals', portals);
28
+ app.setAttribute('routes', routes);
29
+ app.setAttribute('practices', practices);
5
30
  app.setAttribute('app-name', appName);
31
+ app.setAttribute('url-layer', urlLayer);
32
+ app.setAttribute('attribution', attribution);
6
33
  app.setAttribute('color-primary', colorPrimary);
7
34
  app.setAttribute('color-primary-tint', colorPrimaryTint);
35
+ app.setAttribute('trek-line-color', trekLineColor);
36
+ app.setAttribute('departure-icon-color', departureIconColor);
37
+ app.setAttribute('arrival-icon-color', arrivalIconColor);
8
38
  return app;
9
39
  };
@@ -2,7 +2,15 @@ import { createApp } from './App';
2
2
 
3
3
  export default {
4
4
  title: 'Geotrek Rando Widget',
5
- argTypes: {},
5
+ argTypes: {
6
+ urlLayer: {
7
+ control: 'select',
8
+ options: ['openstreetmap'],
9
+ mapping: {
10
+ openstreetmap: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
11
+ },
12
+ },
13
+ },
6
14
  };
7
15
 
8
16
  const Template = ({ label, ...args }) => {
@@ -13,9 +21,21 @@ export const App = Template.bind({});
13
21
 
14
22
  App.args = {
15
23
  api: 'https://randoadmin.parc-haut-jura.fr/api/v2/',
24
+ inBbox: '',
25
+ cities: '',
26
+ districts: '',
27
+ structures: '',
28
+ themes: '',
16
29
  portals: '',
30
+ routes: '',
31
+ practices: '',
17
32
  appName: 'Geotrek Rando Widget',
33
+ urlLayer: 'openstreetmap',
34
+ attribution: '© OpenStreetMap',
18
35
  colorPrimary: '#6b0030',
19
36
  colorPrimaryTint: '#d2b2c0',
37
+ trekLineColor: '#6b0030',
38
+ departureIconColor: '#006b3b',
39
+ arrivalIconColor: '#85003b',
20
40
  };
21
41
  App.storyName = 'App';
@@ -1,7 +1,12 @@
1
- export const createTrekCard = ({ api, trekId }) => {
1
+ export const createTrekCard = ({ api, trekId, colorPrimary, colorPrimaryTint }) => {
2
+ const container = document.createElement('div');
2
3
  const trek = document.createElement('grw-trek-provider');
3
4
  trek.setAttribute('api', api);
4
5
  trek.setAttribute('trek-id', trekId);
5
- trek.appendChild(document.createElement('grw-trek-card'));
6
- return trek;
6
+ container.appendChild(trek);
7
+ const card = document.createElement('grw-trek-card');
8
+ card.setAttribute('color-primary', colorPrimary);
9
+ card.setAttribute('color-primary-tint', colorPrimaryTint);
10
+ container.appendChild(card);
11
+ return container;
7
12
  };
@@ -14,5 +14,7 @@ export const TrekCard = Template.bind({});
14
14
  TrekCard.args = {
15
15
  api: 'https://randoadmin.parc-haut-jura.fr/api/v2/',
16
16
  trekId: 242872,
17
+ colorPrimary: '#6b0030',
18
+ colorPrimaryTint: '#d2b2c0',
17
19
  };
18
20
  TrekCard.storyName = 'Trek card';
@@ -1,7 +1,12 @@
1
- export const createTrekDetail = ({ api, trekId }) => {
1
+ export const createTrekDetail = ({ api, trekId, colorPrimary, colorPrimaryTint }) => {
2
+ const container = document.createElement('div');
2
3
  const trek = document.createElement('grw-trek-provider');
3
4
  trek.setAttribute('api', api);
4
5
  trek.setAttribute('trek-id', trekId);
5
- trek.appendChild(document.createElement('grw-trek-detail'));
6
- return trek;
6
+ container.appendChild(trek);
7
+ const detail = document.createElement('grw-trek-detail');
8
+ detail.setAttribute('color-primary', colorPrimary);
9
+ detail.setAttribute('color-primary-tint', colorPrimaryTint);
10
+ container.appendChild(detail);
11
+ return container;
7
12
  };
@@ -14,5 +14,7 @@ export const TrekDetail = Template.bind({});
14
14
  TrekDetail.args = {
15
15
  api: 'https://randoadmin.parc-haut-jura.fr/api/v2/',
16
16
  trekId: 242872,
17
+ colorPrimary: '#6b0030',
18
+ colorPrimaryTint: '#d2b2c0',
17
19
  };
18
20
  TrekDetail.storyName = 'Trek detail';
@@ -1,11 +1,18 @@
1
- export const createTrekMap = ({ api, trekId, trekLineColor, departureIconColor, arrivalIconColor }) => {
1
+ export const createTrekMap = ({ api, trekId, urlLayer, center, zoom, attribution, trekLineColor, departureIconColor, arrivalIconColor }) => {
2
+ const container = document.createElement('div');
3
+ container.style = 'height: 100%';
2
4
  const trek = document.createElement('grw-trek-provider');
3
5
  trek.setAttribute('api', api);
4
6
  trek.setAttribute('trek-id', trekId);
7
+ container.appendChild(trek);
5
8
  const trekMap = document.createElement('grw-map');
9
+ trekMap.setAttribute('url-layer', urlLayer);
10
+ trekMap.setAttribute('center', center);
11
+ trekMap.setAttribute('zoom', zoom);
12
+ trekMap.setAttribute('attribution', attribution);
6
13
  trekMap.setAttribute('trek-line-color', trekLineColor);
7
14
  trekMap.setAttribute('departure-icon-color', departureIconColor);
8
15
  trekMap.setAttribute('arrival-icon-color', arrivalIconColor);
9
- trek.appendChild(trekMap);
10
- return trek;
16
+ container.appendChild(trekMap);
17
+ return container;
11
18
  };
@@ -2,7 +2,15 @@ import { createTrekMap } from './TrekMap';
2
2
 
3
3
  export default {
4
4
  title: 'Geotrek Rando Widget',
5
- argTypes: {},
5
+ argTypes: {
6
+ urlLayer: {
7
+ control: 'select',
8
+ options: ['openstreetmap'],
9
+ mapping: {
10
+ openstreetmap: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
11
+ },
12
+ },
13
+ },
6
14
  };
7
15
 
8
16
  const Template = ({ label, ...args }) => {
@@ -14,6 +22,10 @@ export const TrekMap = Template.bind({});
14
22
  TrekMap.args = {
15
23
  api: 'https://randoadmin.parc-haut-jura.fr/api/v2/',
16
24
  trekId: 242872,
25
+ urlLayer: 'openstreetmap',
26
+ center: '46.50761080179829, 5.927117067721017',
27
+ zoom: 8,
28
+ attribution: '© OpenStreetMap',
17
29
  trekLineColor: '#6b0030',
18
30
  departureIconColor: '#006b3b',
19
31
  arrivalIconColor: '#85003b',
@@ -1,6 +1,19 @@
1
- export const createTreksList = ({ api }) => {
1
+ export const createTreksList = ({ api, inBbox, cities, districts, structures, themes, portals, routes, practices, colorPrimary, colorPrimaryTint }) => {
2
+ const container = document.createElement('div');
2
3
  const treks = document.createElement('grw-treks-provider');
3
4
  treks.setAttribute('api', api);
4
- treks.appendChild(document.createElement('grw-treks-list'));
5
- return treks;
5
+ treks.setAttribute('in-bbox', inBbox);
6
+ treks.setAttribute('cities', cities);
7
+ treks.setAttribute('districts', districts);
8
+ treks.setAttribute('structures', structures);
9
+ treks.setAttribute('themes', themes);
10
+ treks.setAttribute('portals', portals);
11
+ treks.setAttribute('routes', routes);
12
+ treks.setAttribute('practices', practices);
13
+ container.appendChild(treks);
14
+ const list = document.createElement('grw-treks-list');
15
+ list.setAttribute('color-primary', colorPrimary);
16
+ list.setAttribute('color-primary-tint', colorPrimaryTint);
17
+ container.appendChild(list);
18
+ return container;
6
19
  };
@@ -13,5 +13,15 @@ export const TreksList = Template.bind({});
13
13
 
14
14
  TreksList.args = {
15
15
  api: 'https://randoadmin.parc-haut-jura.fr/api/v2/',
16
+ inBbox: '',
17
+ cities: '',
18
+ districts: '',
19
+ structures: '',
20
+ themes: '',
21
+ portals: '',
22
+ routes: '',
23
+ practices: '',
24
+ colorPrimary: '#6b0030',
25
+ colorPrimaryTint: '#d2b2c0',
16
26
  };
17
27
  TreksList.storyName = 'Treks list';
@@ -1,7 +1,16 @@
1
- export const createTreksMap = ({ api }) => {
1
+ export const createTreksMap = ({ api, urlLayer, center, zoom, attribution, colorPrimary, colorPrimaryTint }) => {
2
+ const container = document.createElement('div');
3
+ container.style = 'height: 100%';
2
4
  const treks = document.createElement('grw-treks-provider');
3
5
  treks.setAttribute('api', api);
6
+ container.appendChild(treks);
4
7
  const treksMap = document.createElement('grw-map');
5
- treks.appendChild(treksMap);
6
- return treks;
8
+ treksMap.setAttribute('url-layer', urlLayer);
9
+ treksMap.setAttribute('center', center);
10
+ treksMap.setAttribute('zoom', zoom);
11
+ treksMap.setAttribute('attribution', attribution);
12
+ treksMap.setAttribute('color-primary', colorPrimary);
13
+ treksMap.setAttribute('color-primary-tint', colorPrimaryTint);
14
+ container.appendChild(treksMap);
15
+ return container;
7
16
  };
@@ -2,7 +2,15 @@ import { createTreksMap } from './TreksMap';
2
2
 
3
3
  export default {
4
4
  title: 'Geotrek Rando Widget',
5
- argTypes: {},
5
+ argTypes: {
6
+ urlLayer: {
7
+ control: 'select',
8
+ options: ['openstreetmap'],
9
+ mapping: {
10
+ openstreetmap: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
11
+ },
12
+ },
13
+ },
6
14
  };
7
15
 
8
16
  const Template = ({ label, ...args }) => {
@@ -13,5 +21,11 @@ export const TreksMap = Template.bind({});
13
21
 
14
22
  TreksMap.args = {
15
23
  api: 'https://randoadmin.parc-haut-jura.fr/api/v2/',
24
+ urlLayer: 'openstreetmap',
25
+ center: '46.50761080179829, 5.927117067721017',
26
+ zoom: 8,
27
+ attribution: '© OpenStreetMap',
28
+ colorPrimary: '#6b0030',
29
+ colorPrimaryTint: '#d2b2c0',
16
30
  };
17
31
  TreksMap.storyName = 'Treks map';
@@ -9,43 +9,76 @@ import { d as defineCustomElement$2 } from './grw-treks-provider2.js';
9
9
 
10
10
  const arrowBackImage = `<svg xmlns="http://www.w3.org/2000/svg" width="512" height="512" viewBox="0 0 512 512"><polyline points="244 400 100 256 244 112" style="fill:none;stroke:#ffffff;stroke-linecap:round;stroke-linejoin:round;stroke-width:48px"/><line x1="120" y1="256" x2="412" y2="256" style="fill:none;stroke:#ffffff;stroke-linecap:round;stroke-linejoin:round;stroke-width:48px"/></svg>`;
11
11
 
12
- const grwAppCss = ".header-container{display:flex;align-items:center;background-color:var(--color-primary);height:64px}.header-container .title{color:#ffffff;font-size:24px;margin-left:24px}.header-container .arrow-back-icon{width:48px;height:auto;margin-left:24px}.header-container .arrow-back-icon svg{cursor:pointer;width:48px;height:auto}.loader-container{position:absolute;display:flex;justify-content:center;align-items:center;width:100vw;height:100%}.loader-container .loader{width:48px;height:48px;border:5px solid var(--color-primary-tint);border-bottom-color:var(--color-primary);border-radius:50%;display:inline-block;box-sizing:border-box;animation:rotation 1s linear infinite}@keyframes rotation{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}.content-container{display:flex;height:calc(100vh - 64px)}.app-treks-list-container,.app-trek-detail-container{width:100vw;height:100%}.app-map-container{position:absolute;width:100vw;height:calc(100vh - 64px)}.map-visibility-button{cursor:pointer;display:flex;justify-content:center;align-items:center;position:absolute;bottom:24px;width:100%;z-index:400;user-select:none}.map-visibility-button div{background-color:var(--color-primary);color:#ffffff;padding:12px;border-radius:24px;width:120px;text-align:center}@media (min-width: 664px){.map-visibility-button{display:none}.header-container .title{font-size:32px}.loader-container{position:relative;width:50vw}.app-treks-list-container,.app-trek-detail-container{width:50vw;height:100%}.app-map-container{position:relative;width:50vw;height:100%}}";
12
+ const grwAppCss = ".app-container{position:relative;height:100%;max-height:100vh}.header-container,.large-view-header-container{display:flex;align-items:center;background-color:var(--color-primary);height:64px}.header-container .title,.large-view-header-container .title{color:#ffffff;margin-left:24px}.header-container .arrow-back-icon,.large-view-header-container .arrow-back-icon{width:48px;height:auto;margin-left:24px}.header-container .arrow-back-icon svg,.large-view-header-container .arrow-back-icon svg{cursor:pointer;width:48px;height:auto}.loader-container,.large-view-loader-container{display:flex;justify-content:center;align-items:center;height:100%}.loader-container .loader,.large-view-loader-container .loader{width:48px;height:48px;border:5px solid var(--color-primary-tint);border-bottom-color:var(--color-primary);border-radius:50%;display:inline-block;box-sizing:border-box;animation:rotation 1s linear infinite}@keyframes rotation{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}.content-container{position:relative;display:flex;height:calc(100% - 64px)}.app-treks-list-container,.app-trek-detail-container,.large-view-app-treks-list-container,.large-view-app-trek-detail-container{height:100%}.app-map-container,.large-view-app-map-container{width:100%;height:100%}.map-visibility-button{cursor:pointer;display:flex;justify-content:center;align-items:center;position:absolute;bottom:24px;width:100%;z-index:400;user-select:none}.map-visibility-button div{background-color:var(--color-primary);color:#ffffff;padding:12px;border-radius:24px;width:120px;text-align:center}.header-container .title{font-size:24px}.loader-container{position:absolute;width:100%}.app-treks-list-container,.app-trek-detail-container{width:100%}.app-map-container{position:relative;width:100%;position:absolute}.large-view-header-container .title{font-size:32px}.large-view-loader-container{position:relative;width:50%}.large-view-app-treks-list-container,.large-view-app-trek-detail-container{width:50%}.large-view-app-map-container{position:relative;width:50%}";
13
13
 
14
14
  const GrwApp$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
15
15
  constructor() {
16
16
  super();
17
17
  this.__registerHost();
18
18
  this.__attachShadow();
19
+ this.showTrek = false;
20
+ this.showMap = false;
21
+ this.isLargeView = false;
19
22
  this.appName = 'Geotrek Rando Widget';
20
23
  this.colorPrimary = '#6b0030';
21
24
  this.colorPrimaryTint = '#d2b2c0';
25
+ this.colorTrekLine = '#6b0030';
26
+ this.colorDepartureIcon = '#006b3b';
27
+ this.colorArrivalIcon = '#85003b';
28
+ this.largeViewSize = 664;
22
29
  }
23
30
  onTrekCardPress(event) {
24
31
  this.currentTrekId = event.detail;
25
32
  this.showTrek = !this.showTrek;
26
33
  }
27
- onWindowResize(event) {
28
- this.showMap = !(event.composedPath()[0].innerWidth < 664);
34
+ onWindowResize() {
35
+ this.handleView();
36
+ }
37
+ watchPropHandler() {
38
+ window.dispatchEvent(new window.Event('resize'));
39
+ }
40
+ componentDidLoad() {
41
+ this.handleView();
29
42
  }
30
43
  onTrekDetailsClose() {
31
44
  this.currentTrekId = null;
32
45
  this.showTrek = !this.showTrek;
33
46
  }
34
- componentWillLoad() {
35
- this.showMap = !(window.innerWidth < 664);
47
+ handleView() {
48
+ this.isLargeView = this.element.getBoundingClientRect().width >= this.largeViewSize;
49
+ this.showMap = this.isLargeView;
36
50
  }
37
51
  render() {
38
- return (h(Host, { style: { '--color-primary': this.colorPrimary, '--color-primary-tint': this.colorPrimaryTint } }, h("grw-treks-provider", { api: this.api, portals: this.portals }, h("div", { class: "header-container" }, this.showTrek ? h("div", { onClick: () => this.onTrekDetailsClose(), class: "arrow-back-icon", innerHTML: arrowBackImage }) : h("div", { class: "title" }, this.appName)), h("div", { class: "content-container" }, h("div", { class: "app-treks-list-container", style: { visibility: this.showTrek ? 'hidden' : 'visible', position: this.showTrek ? 'absolute' : 'relative' } }, h("grw-treks-list", null)), this.showTrek && !state.currentTrek && (h("div", { class: "loader-container" }, h("span", { class: "loader" }))), this.showTrek && this.currentTrekId && (h("grw-trek-provider", { api: state.api, "trek-id": this.currentTrekId }, state.currentTrek && (h("div", { class: "app-trek-detail-container" }, h("grw-trek-detail", null))))), h("div", { class: "app-map-container", style: { visibility: this.showMap ? 'visible' : 'hidden' } }, h("grw-map", null))), h("div", { class: "map-visibility-button" }, h("div", { onClick: () => (this.showMap = !this.showMap) }, this.showMap ? (this.showTrek ? 'Voir la fiche' : 'Voir la liste') : 'Voir la carte')))));
52
+ return (h(Host, { style: { '--color-primary': this.colorPrimary, '--color-primary-tint': this.colorPrimaryTint } }, h("grw-treks-provider", { api: this.api, "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 }), this.showTrek && this.currentTrekId && h("grw-trek-provider", { api: state.api, "trek-id": this.currentTrekId }), h("div", { class: "app-container" }, h("div", { class: this.isLargeView ? 'large-view-header-container' : 'header-container' }, this.showTrek ? h("div", { onClick: () => this.onTrekDetailsClose(), class: "arrow-back-icon", innerHTML: arrowBackImage }) : h("div", { class: "title" }, this.appName)), h("div", { class: "content-container" }, 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' } }, h("grw-treks-list", { "color-primary": this.colorPrimary, "color-primary-tint": this.colorPrimaryTint })), this.showTrek && !state.currentTrek && (h("div", { class: this.isLargeView ? 'large-view-loader-container' : 'loader-container' }, h("span", { class: "loader" }))), state.currentTrek && (h("div", { class: this.isLargeView ? 'large-view-app-trek-detail-container' : 'app-trek-detail-container' }, h("grw-trek-detail", { "color-primary": this.colorPrimary, "color-primary-tint": this.colorPrimaryTint }))), 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-trek-line": this.colorTrekLine, "color-departure-icon": this.colorDepartureIcon, "color-arrival-icon": this.colorArrivalIcon })), h("div", { class: "map-visibility-button", style: { display: this.isLargeView ? 'none' : 'flex' } }, h("div", { onClick: () => (this.showMap = !this.showMap) }, this.showMap ? (this.showTrek ? 'Voir la fiche' : 'Voir la liste') : 'Voir la carte')))));
39
53
  }
54
+ get element() { return this; }
55
+ static get watchers() { return {
56
+ "isLargeView": ["watchPropHandler"]
57
+ }; }
40
58
  static get style() { return grwAppCss; }
41
59
  }, [1, "grw-app", {
42
60
  "api": [1],
61
+ "inBbox": [1, "in-bbox"],
62
+ "cities": [1],
63
+ "districts": [1],
64
+ "structures": [1],
65
+ "themes": [1],
43
66
  "portals": [1],
67
+ "routes": [1],
68
+ "practices": [1],
44
69
  "appName": [1, "app-name"],
70
+ "urlLayer": [1, "url-layer"],
71
+ "center": [1],
72
+ "zoom": [8],
73
+ "attribution": [1],
45
74
  "colorPrimary": [1, "color-primary"],
46
75
  "colorPrimaryTint": [1, "color-primary-tint"],
76
+ "colorTrekLine": [1, "color-trek-line"],
77
+ "colorDepartureIcon": [1, "color-departure-icon"],
78
+ "colorArrivalIcon": [1, "color-arrival-icon"],
47
79
  "showTrek": [32],
48
80
  "showMap": [32],
81
+ "isLargeView": [32],
49
82
  "currentTrekId": [32]
50
83
  }, [[0, "trekCardPress", "onTrekCardPress"], [9, "resize", "onWindowResize"]]]);
51
84
  function defineCustomElement$1() {