@geotrekce/geotrek-rando-widget 0.0.1 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/dist/cjs/geotrek-rando-widget.cjs.js +2 -2
  2. package/dist/cjs/{grw-app_7.cjs.entry.js → grw-app_11.cjs.entry.js} +513 -89
  3. package/dist/cjs/{index-31255e29.js → index-c2c4531d.js} +82 -1
  4. package/dist/cjs/loader.cjs.js +2 -2
  5. package/dist/collection/assets/departure-arrival.svg +1 -1
  6. package/dist/collection/collection-manifest.json +4 -0
  7. package/dist/collection/components/grw-app/grw-app.css +127 -39
  8. package/dist/collection/components/grw-app/grw-app.js +375 -18
  9. package/dist/collection/components/grw-filter/grw-filter.css +29 -0
  10. package/dist/collection/components/grw-filter/grw-filter.js +132 -0
  11. package/dist/collection/components/grw-information-desk-detail/grw-information-desk-detail.css +30 -0
  12. package/dist/collection/components/grw-information-desk-detail/grw-information-desk-detail.js +53 -0
  13. package/dist/collection/components/grw-map/grw-map.css +117 -0
  14. package/dist/collection/components/grw-map/grw-map.js +409 -40
  15. package/dist/collection/components/grw-poi-detail/grw-poi-detail.css +30 -0
  16. package/dist/collection/components/grw-poi-detail/grw-poi-detail.js +41 -0
  17. package/dist/collection/components/grw-sensitive-area-detail/grw-sensitive-area-detail.css +16 -0
  18. package/dist/collection/components/grw-sensitive-area-detail/grw-sensitive-area-detail.js +38 -0
  19. package/dist/collection/components/grw-trek-card/grw-trek-card.css +67 -30
  20. package/dist/collection/components/grw-trek-card/grw-trek-card.js +112 -33
  21. package/dist/collection/components/grw-trek-detail/grw-trek-detail.css +36 -1
  22. package/dist/collection/components/grw-trek-detail/grw-trek-detail.js +122 -33
  23. package/dist/collection/components/grw-treks-list/grw-treks-list.css +17 -12
  24. package/dist/collection/components/grw-treks-list/grw-treks-list.js +70 -6
  25. package/dist/collection/store/grw-trek-provider.js +50 -8
  26. package/dist/collection/store/grw-treks-provider.js +166 -11
  27. package/dist/collection/store/store.js +6 -0
  28. package/dist/collection/stories/App.js +39 -3
  29. package/dist/collection/stories/App.stories.js +30 -5
  30. package/dist/collection/stories/TrekCard.js +9 -3
  31. package/dist/collection/stories/TrekCard.stories.js +5 -2
  32. package/dist/collection/stories/TrekDetail.js +10 -3
  33. package/dist/collection/stories/TrekDetail.stories.js +6 -2
  34. package/dist/collection/stories/TrekMap.js +15 -6
  35. package/dist/collection/stories/TrekMap.stories.js +21 -6
  36. package/dist/collection/stories/TreksList.js +17 -3
  37. package/dist/collection/stories/TreksList.stories.js +13 -2
  38. package/dist/collection/stories/TreksMap.js +12 -3
  39. package/dist/collection/stories/TreksMap.stories.js +18 -3
  40. package/dist/collection/utils/utils.js +2 -2
  41. package/dist/components/grw-app.js +79 -9
  42. package/dist/components/grw-filter.d.ts +11 -0
  43. package/dist/components/grw-filter.js +6 -0
  44. package/dist/components/grw-filter2.js +95 -0
  45. package/dist/components/grw-information-desk-detail.d.ts +11 -0
  46. package/dist/components/grw-information-desk-detail.js +6 -0
  47. package/dist/components/grw-information-desk-detail2.js +34 -0
  48. package/dist/components/grw-map2.js +260 -43
  49. package/dist/components/grw-poi-detail.d.ts +11 -0
  50. package/dist/components/grw-poi-detail.js +6 -0
  51. package/dist/components/grw-poi-detail2.js +32 -0
  52. package/dist/components/grw-sensitive-area-detail.d.ts +11 -0
  53. package/dist/components/grw-sensitive-area-detail.js +6 -0
  54. package/dist/components/grw-sensitive-area-detail2.js +32 -0
  55. package/dist/components/grw-trek-card2.js +33 -10
  56. package/dist/components/grw-trek-detail2.js +47 -9
  57. package/dist/components/grw-trek-provider2.js +32 -9
  58. package/dist/components/grw-treks-list2.js +15 -6
  59. package/dist/components/grw-treks-provider2.js +37 -13
  60. package/dist/components/length.js +2 -2
  61. package/dist/components/store.js +6 -0
  62. package/dist/esm/geotrek-rando-widget.js +2 -2
  63. package/dist/esm/{grw-app_7.entry.js → grw-app_11.entry.js} +510 -90
  64. package/dist/esm/{index-b36f38f5.js → index-fe16e7b6.js} +82 -1
  65. package/dist/esm/loader.js +2 -2
  66. package/dist/geotrek-rando-widget/geotrek-rando-widget.css +1 -1
  67. package/dist/geotrek-rando-widget/geotrek-rando-widget.esm.js +1 -1
  68. package/dist/geotrek-rando-widget/p-8c206aec.js +2 -0
  69. package/dist/geotrek-rando-widget/p-ed8706fb.entry.js +1 -0
  70. package/dist/types/components/grw-app/grw-app.d.ts +27 -2
  71. package/dist/types/components/grw-filter/grw-filter.d.ts +9 -0
  72. package/dist/types/components/grw-information-desk-detail/grw-information-desk-detail.d.ts +5 -0
  73. package/dist/types/components/grw-map/grw-map.d.ts +19 -2
  74. package/dist/types/components/grw-poi-detail/grw-poi-detail.d.ts +5 -0
  75. package/dist/types/components/grw-sensitive-area-detail/grw-sensitive-area-detail.d.ts +5 -0
  76. package/dist/types/components/grw-trek-card/grw-trek-card.d.ts +6 -2
  77. package/dist/types/components/grw-trek-detail/grw-trek-detail.d.ts +3 -0
  78. package/dist/types/components/grw-treks-list/grw-treks-list.d.ts +3 -0
  79. package/dist/types/components.d.ts +158 -1
  80. package/dist/types/store/grw-trek-provider.d.ts +1 -0
  81. package/dist/types/store/grw-treks-provider.d.ts +8 -0
  82. package/dist/types/store/store.d.ts +13 -1
  83. package/dist/types/types/types.d.ts +69 -3
  84. package/package.json +5 -7
  85. package/readme.md +19 -1
  86. package/dist/geotrek-rando-widget/p-f721481d.js +0 -2
  87. package/dist/geotrek-rando-widget/p-fe788eaa.entry.js +0 -1
@@ -1,19 +1,25 @@
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 = '#974c6e';
8
+ this.isLargeView = false;
6
9
  this.handleInfiniteScrollBind = this.handleInfiniteScroll.bind(this);
7
10
  this.step = 10;
8
11
  }
9
12
  componentWillLoad() {
10
- this.treksToDisplay = state.treks.slice(0, this.step);
11
- this.element.addEventListener('scroll', this.handleInfiniteScrollBind);
13
+ onChange('currentTreks', () => {
14
+ this.element.addEventListener('scroll', this.handleInfiniteScrollBind);
15
+ this.element.scroll({ top: 0 });
16
+ this.treksToDisplay = [...state.currentTreks.slice(0, this.step)];
17
+ });
12
18
  }
13
19
  handleInfiniteScroll(event) {
14
20
  if (event.composedPath()[0].scrollTop + event.composedPath()[0].scrollHeight / 2 >= event.composedPath()[0].scrollHeight) {
15
21
  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);
22
+ this.treksToDisplay = state.currentTreks.slice(0, this.treksToDisplay.length + this.step >= state.currentTreks.length ? state.currentTreks.length : this.treksToDisplay.length + this.step);
17
23
  }
18
24
  else {
19
25
  this.element.removeEventListener('scroll', this.handleInfiniteScrollBind);
@@ -21,7 +27,9 @@ export class GrwTreksList {
21
27
  }
22
28
  }
23
29
  render() {
24
- return (h(Host, { class: "treks-list-container" }, this.treksToDisplay.map(trek => (h("grw-trek-card", { trek: trek })))));
30
+ return (h(Host, { style: { '--color-primary': this.colorPrimary, '--color-primary-tint': this.colorPrimaryTint } },
31
+ h("div", { class: "current-treks-length" }, `${state.currentTreks.length} résultat${state.currentTreks.length > 1 ? 's' : ''}`),
32
+ h("div", { class: "current-treks-container" }, this.treksToDisplay.map(trek => (h("grw-trek-card", { key: `trek-${trek.id}`, trek: trek, "is-large-view": this.isLargeView, "color-primary": this.colorPrimary, "color-primary-tint": this.colorPrimaryTint }))))));
25
33
  }
26
34
  static get is() { return "grw-treks-list"; }
27
35
  static get encapsulation() { return "shadow"; }
@@ -31,6 +39,62 @@ export class GrwTreksList {
31
39
  static get styleUrls() { return {
32
40
  "$": ["grw-treks-list.css"]
33
41
  }; }
42
+ static get properties() { return {
43
+ "colorPrimary": {
44
+ "type": "string",
45
+ "mutable": false,
46
+ "complexType": {
47
+ "original": "string",
48
+ "resolved": "string",
49
+ "references": {}
50
+ },
51
+ "required": false,
52
+ "optional": false,
53
+ "docs": {
54
+ "tags": [],
55
+ "text": ""
56
+ },
57
+ "attribute": "color-primary",
58
+ "reflect": false,
59
+ "defaultValue": "'#6b0030'"
60
+ },
61
+ "colorPrimaryTint": {
62
+ "type": "string",
63
+ "mutable": false,
64
+ "complexType": {
65
+ "original": "string",
66
+ "resolved": "string",
67
+ "references": {}
68
+ },
69
+ "required": false,
70
+ "optional": false,
71
+ "docs": {
72
+ "tags": [],
73
+ "text": ""
74
+ },
75
+ "attribute": "color-primary-tint",
76
+ "reflect": false,
77
+ "defaultValue": "'#974c6e'"
78
+ },
79
+ "isLargeView": {
80
+ "type": "boolean",
81
+ "mutable": false,
82
+ "complexType": {
83
+ "original": "boolean",
84
+ "resolved": "boolean",
85
+ "references": {}
86
+ },
87
+ "required": false,
88
+ "optional": false,
89
+ "docs": {
90
+ "tags": [],
91
+ "text": ""
92
+ },
93
+ "attribute": "is-large-view",
94
+ "reflect": false,
95
+ "defaultValue": "false"
96
+ }
97
+ }; }
34
98
  static get states() { return {
35
99
  "treksToDisplay": {}
36
100
  }; }
@@ -1,20 +1,43 @@
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;
9
+ const requests = [];
10
+ requests.push(!state.difficulties ? fetch(`${this.api}trek_difficulty/?language=${this.language}&fields=id,label,pictogram`) : new Response('null'));
11
+ requests.push(!state.routes ? fetch(`${this.api}trek_route/?language=${this.language}&fields=id,route,pictogram`) : new Response('null'));
12
+ requests.push(!state.practices ? fetch(`${this.api}trek_practice/?language=${this.language}&fields=id,name,pictogram`) : new Response('null'));
13
+ requests.push(!state.themes ? fetch(`${this.api}theme/?language=${this.language}&fields=id,label,pictogram`) : new Response('null'));
6
14
  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`),
15
+ ...requests,
16
+ fetch(`${this.api}sensitivearea/?language=${this.language}&trek=${this.trekId}&fields=id,geometry,name,description`).catch(() => new Response('null')),
17
+ fetch(`${this.api}poi/?language=${this.language}&trek=${this.trekId}&published=true&fields=id,name,description,attachments,type,type_label,type_pictogram,url,published,geometry&page_size=999`),
18
+ fetch(`${this.api}informationdesk/?language=${this.language}&near_trek=${this.trekId}&fields=id,name,description,type,phone,email,website,municipality,postal_code,street,photo_url,latitude,longitude&page_size=999`),
19
+ fetch(`${this.api}trek/${this.trekId}/?language=${this.language}&published=true&fields=id,name,attachments,description,description_teaser,difficulty,duration,ascent,length_2d,practice,themes,route,geometry,gpx,kml,pdf,parking_location,departure`),
11
20
  ])
12
21
  .then(responses => Promise.all(responses.map(response => response.json())))
13
- .then(([trek, difficulties, routes, practices]) => {
22
+ .then(([difficulties, routes, practices, themes, sensitiveAreas, pois, informationDesks, trek]) => {
23
+ if (difficulties) {
24
+ state.difficulties = difficulties.results;
25
+ }
26
+ if (routes) {
27
+ state.routes = routes.results;
28
+ }
29
+ if (practices) {
30
+ state.practices = practices.results.map(practice => (Object.assign(Object.assign({}, practice), { selected: false })));
31
+ }
32
+ if (themes) {
33
+ state.themes = themes.results;
34
+ }
35
+ if (sensitiveAreas) {
36
+ state.currentSensitiveAreas = sensitiveAreas.results;
37
+ }
38
+ state.currentPois = pois.results;
39
+ state.currentInformationDesks = informationDesks.results;
14
40
  state.currentTrek = trek;
15
- state.difficulties = difficulties.results;
16
- state.routes = routes.results;
17
- state.practices = practices.results;
18
41
  });
19
42
  }
20
43
  disconnectedCallback() {
@@ -24,7 +47,26 @@ export class GrwTrekProvider {
24
47
  return h(Host, null);
25
48
  }
26
49
  static get is() { return "grw-trek-provider"; }
50
+ static get encapsulation() { return "shadow"; }
27
51
  static get properties() { return {
52
+ "language": {
53
+ "type": "string",
54
+ "mutable": false,
55
+ "complexType": {
56
+ "original": "string",
57
+ "resolved": "string",
58
+ "references": {}
59
+ },
60
+ "required": false,
61
+ "optional": false,
62
+ "docs": {
63
+ "tags": [],
64
+ "text": ""
65
+ },
66
+ "attribute": "language",
67
+ "reflect": false,
68
+ "defaultValue": "'fr'"
69
+ },
28
70
  "api": {
29
71
  "type": "string",
30
72
  "mutable": false,
@@ -1,32 +1,68 @@
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
- }
10
- treksRequest += `&fields=id,name,attachments,description_teaser,difficulty,duration,ascent,length_2d,practice,route,departure_geom&page_size=999`;
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}`);
18
+ treksRequest += `&fields=id,name,attachments,description_teaser,difficulty,duration,ascent,length_2d,practice,themes,route,departure,departure_geom&page_size=999`;
11
19
  return Promise.all([
20
+ fetch(`${this.api}trek_difficulty/?language=${this.language}&fields=id,label,pictogram`),
21
+ fetch(`${this.api}trek_route/?language=${this.language}&fields=id,route,pictogram`),
22
+ fetch(`${this.api}trek_practice/?language=${this.language}&fields=id,name,pictogram`),
23
+ fetch(`${this.api}theme/?language=${this.language}&fields=id,label,pictogram`),
12
24
  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
25
  ])
17
26
  .then(responses => Promise.all(responses.map(response => response.json())))
18
- .then(([treks, difficulties, routes, practices]) => {
19
- state.treks = treks.results;
27
+ .then(([difficulties, routes, practices, themes, treks]) => {
20
28
  state.difficulties = difficulties.results;
21
29
  state.routes = routes.results;
22
- state.practices = practices.results;
30
+ state.practices = practices.results.map(practice => (Object.assign(Object.assign({}, practice), { selected: false })));
31
+ state.themes = themes.results;
32
+ state.durations = [
33
+ { id: 1, name: '0 - 1h', minValue: 0, maxValue: 1, selected: false },
34
+ { id: 2, name: '1 - 2h', minValue: 1, maxValue: 2, selected: false },
35
+ { id: 3, name: '2 - 5h', minValue: 2, maxValue: 5, selected: false },
36
+ { id: 4, name: '5 - 10h', minValue: 5, maxValue: 10, selected: false },
37
+ ];
38
+ state.treks = treks.results;
39
+ state.currentTreks = treks.results;
23
40
  });
24
41
  }
25
42
  render() {
26
43
  return h(Host, null);
27
44
  }
28
45
  static get is() { return "grw-treks-provider"; }
46
+ static get encapsulation() { return "shadow"; }
29
47
  static get properties() { return {
48
+ "language": {
49
+ "type": "string",
50
+ "mutable": false,
51
+ "complexType": {
52
+ "original": "string",
53
+ "resolved": "string",
54
+ "references": {}
55
+ },
56
+ "required": false,
57
+ "optional": false,
58
+ "docs": {
59
+ "tags": [],
60
+ "text": ""
61
+ },
62
+ "attribute": "language",
63
+ "reflect": false,
64
+ "defaultValue": "'fr'"
65
+ },
30
66
  "api": {
31
67
  "type": "string",
32
68
  "mutable": false,
@@ -44,6 +80,91 @@ export class GrwTreksProvider {
44
80
  "attribute": "api",
45
81
  "reflect": false
46
82
  },
83
+ "inBbox": {
84
+ "type": "string",
85
+ "mutable": false,
86
+ "complexType": {
87
+ "original": "string",
88
+ "resolved": "string",
89
+ "references": {}
90
+ },
91
+ "required": false,
92
+ "optional": false,
93
+ "docs": {
94
+ "tags": [],
95
+ "text": ""
96
+ },
97
+ "attribute": "in-bbox",
98
+ "reflect": false
99
+ },
100
+ "cities": {
101
+ "type": "string",
102
+ "mutable": false,
103
+ "complexType": {
104
+ "original": "string",
105
+ "resolved": "string",
106
+ "references": {}
107
+ },
108
+ "required": false,
109
+ "optional": false,
110
+ "docs": {
111
+ "tags": [],
112
+ "text": ""
113
+ },
114
+ "attribute": "cities",
115
+ "reflect": false
116
+ },
117
+ "districts": {
118
+ "type": "string",
119
+ "mutable": false,
120
+ "complexType": {
121
+ "original": "string",
122
+ "resolved": "string",
123
+ "references": {}
124
+ },
125
+ "required": false,
126
+ "optional": false,
127
+ "docs": {
128
+ "tags": [],
129
+ "text": ""
130
+ },
131
+ "attribute": "districts",
132
+ "reflect": false
133
+ },
134
+ "structures": {
135
+ "type": "string",
136
+ "mutable": false,
137
+ "complexType": {
138
+ "original": "string",
139
+ "resolved": "string",
140
+ "references": {}
141
+ },
142
+ "required": false,
143
+ "optional": false,
144
+ "docs": {
145
+ "tags": [],
146
+ "text": ""
147
+ },
148
+ "attribute": "structures",
149
+ "reflect": false
150
+ },
151
+ "themes": {
152
+ "type": "string",
153
+ "mutable": false,
154
+ "complexType": {
155
+ "original": "string",
156
+ "resolved": "string",
157
+ "references": {}
158
+ },
159
+ "required": false,
160
+ "optional": false,
161
+ "docs": {
162
+ "tags": [],
163
+ "text": ""
164
+ },
165
+ "attribute": "themes",
166
+ "reflect": false
167
+ },
47
168
  "portals": {
48
169
  "type": "string",
49
170
  "mutable": false,
@@ -60,6 +181,40 @@ export class GrwTreksProvider {
60
181
  },
61
182
  "attribute": "portals",
62
183
  "reflect": false
184
+ },
185
+ "routes": {
186
+ "type": "string",
187
+ "mutable": false,
188
+ "complexType": {
189
+ "original": "string",
190
+ "resolved": "string",
191
+ "references": {}
192
+ },
193
+ "required": false,
194
+ "optional": false,
195
+ "docs": {
196
+ "tags": [],
197
+ "text": ""
198
+ },
199
+ "attribute": "routes",
200
+ "reflect": false
201
+ },
202
+ "practices": {
203
+ "type": "string",
204
+ "mutable": false,
205
+ "complexType": {
206
+ "original": "string",
207
+ "resolved": "string",
208
+ "references": {}
209
+ },
210
+ "required": false,
211
+ "optional": false,
212
+ "docs": {
213
+ "tags": [],
214
+ "text": ""
215
+ },
216
+ "attribute": "practices",
217
+ "reflect": false
63
218
  }
64
219
  }; }
65
220
  }
@@ -2,10 +2,16 @@ import { createStore } from '@stencil/store';
2
2
  const { state, onChange } = createStore({
3
3
  api: '',
4
4
  treks: [],
5
+ currentTreks: [],
5
6
  difficulties: [],
6
7
  routes: [],
7
8
  practices: [],
9
+ themes: [],
10
+ durations: [],
11
+ currentSensitiveAreas: null,
12
+ currentPois: null,
8
13
  currentTrek: null,
14
+ currentInformationDesks: null,
9
15
  });
10
16
  export { onChange };
11
17
  export default state;
@@ -1,9 +1,45 @@
1
- export const createApp = ({ api, portals, appName, colorPrimary, colorPrimaryTint }) => {
1
+ export const createApp = ({
2
+ api,
3
+ language,
4
+ inBbox,
5
+ cities,
6
+ districts,
7
+ structures,
8
+ themes,
9
+ portals,
10
+ routes,
11
+ practices,
12
+ urlLayer,
13
+ attribution,
14
+ colorPrimary,
15
+ colorPrimaryShade,
16
+ colorPrimaryTint,
17
+ colorTrekLine,
18
+ colorDepartureIcon,
19
+ colorArrivalIcon,
20
+ colorSensitiveArea,
21
+ colorPoiIcon,
22
+ }) => {
2
23
  const app = document.createElement('grw-app');
3
24
  app.setAttribute('api', api);
4
- app.setAttribute('portals', portals);
5
- app.setAttribute('app-name', appName);
25
+ app.setAttribute('language', language);
26
+ inBbox && app.setAttribute('in-bbox', inBbox);
27
+ cities && app.setAttribute('cities', cities);
28
+ districts && app.setAttribute('districts', districts);
29
+ structures && app.setAttribute('structures', structures);
30
+ themes && app.setAttribute('themes', themes);
31
+ portals && app.setAttribute('portals', portals);
32
+ routes && app.setAttribute('routes', routes);
33
+ practices && app.setAttribute('practices', practices);
34
+ app.setAttribute('url-layer', urlLayer);
35
+ app.setAttribute('attribution', attribution);
6
36
  app.setAttribute('color-primary', colorPrimary);
37
+ app.setAttribute('color-primary-shade', colorPrimaryShade);
7
38
  app.setAttribute('color-primary-tint', colorPrimaryTint);
39
+ app.setAttribute('color-trek-line', colorTrekLine);
40
+ app.setAttribute('color-departure-icon', colorDepartureIcon);
41
+ app.setAttribute('color-arrival-icon', colorArrivalIcon);
42
+ app.setAttribute('color-sensitive-area', colorSensitiveArea);
43
+ app.setAttribute('color-poi-icon', colorPoiIcon);
8
44
  return app;
9
45
  };
@@ -2,20 +2,45 @@ 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', 'planignv2'],
9
+ mapping: {
10
+ openstreetmap: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
11
+ planignv2:
12
+ 'https://wxs.ign.fr/cartes/geoportail/wmts?&REQUEST=GetTile&SERVICE=WMTS&VERSION=1.0.0&STYLE=normal&TILEMATRIXSET=PM&FORMAT=image/png&LAYER=GEOGRAPHICALGRIDSYSTEMS.PLANIGNV2&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}',
13
+ },
14
+ },
15
+ },
6
16
  };
7
17
 
8
- const Template = ({ label, ...args }) => {
9
- return createApp({ label, ...args });
18
+ const Template = ({ ...args }) => {
19
+ return createApp({ ...args });
10
20
  };
11
21
 
12
22
  export const App = Template.bind({});
13
23
 
14
24
  App.args = {
15
25
  api: 'https://randoadmin.parc-haut-jura.fr/api/v2/',
26
+ language: 'fr',
27
+ inBbox: '',
28
+ cities: '',
29
+ districts: '',
30
+ structures: '',
31
+ themes: '',
16
32
  portals: '',
17
- appName: 'Geotrek Rando Widget',
33
+ routes: '',
34
+ practices: '',
35
+ urlLayer: 'openstreetmap',
36
+ attribution: '© <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a> contributors',
18
37
  colorPrimary: '#6b0030',
19
- colorPrimaryTint: '#d2b2c0',
38
+ colorPrimaryShade: '4a0021',
39
+ colorPrimaryTint: '#974c6e',
40
+ colorTrekLine: '#6b0030',
41
+ colorDepartureIcon: '#006b3b',
42
+ colorArrivalIcon: '#85003b',
43
+ colorSensitiveArea: '#4974a5',
44
+ colorPoiIcon: '#974c6e',
20
45
  };
21
46
  App.storyName = 'App';
@@ -1,7 +1,13 @@
1
- export const createTrekCard = ({ api, trekId }) => {
1
+ export const createTrekCard = ({ api, language, trekId, colorPrimary, colorPrimaryTint }) => {
2
+ const container = document.createElement('div');
2
3
  const trek = document.createElement('grw-trek-provider');
3
4
  trek.setAttribute('api', api);
5
+ trek.setAttribute('language', language);
4
6
  trek.setAttribute('trek-id', trekId);
5
- trek.appendChild(document.createElement('grw-trek-card'));
6
- return trek;
7
+ container.appendChild(trek);
8
+ const card = document.createElement('grw-trek-card');
9
+ card.setAttribute('color-primary', colorPrimary);
10
+ card.setAttribute('color-primary-tint', colorPrimaryTint);
11
+ container.appendChild(card);
12
+ return container;
7
13
  };
@@ -5,14 +5,17 @@ export default {
5
5
  argTypes: {},
6
6
  };
7
7
 
8
- const Template = ({ label, ...args }) => {
9
- return createTrekCard({ label, ...args });
8
+ const Template = ({ ...args }) => {
9
+ return createTrekCard({ ...args });
10
10
  };
11
11
 
12
12
  export const TrekCard = Template.bind({});
13
13
 
14
14
  TrekCard.args = {
15
15
  api: 'https://randoadmin.parc-haut-jura.fr/api/v2/',
16
+ language: 'fr',
16
17
  trekId: 242872,
18
+ colorPrimary: '#6b0030',
19
+ colorPrimaryTint: '#974c6e',
17
20
  };
18
21
  TrekCard.storyName = 'Trek card';
@@ -1,7 +1,14 @@
1
- export const createTrekDetail = ({ api, trekId }) => {
1
+ export const createTrekDetail = ({ api, language, trekId, colorPrimary, colorPrimaryShade, colorPrimaryTint }) => {
2
+ const container = document.createElement('div');
2
3
  const trek = document.createElement('grw-trek-provider');
3
4
  trek.setAttribute('api', api);
5
+ trek.setAttribute('language', language);
4
6
  trek.setAttribute('trek-id', trekId);
5
- trek.appendChild(document.createElement('grw-trek-detail'));
6
- return trek;
7
+ container.appendChild(trek);
8
+ const detail = document.createElement('grw-trek-detail');
9
+ detail.setAttribute('color-primary', colorPrimary);
10
+ detail.setAttribute('color-primary-shade', colorPrimaryShade);
11
+ detail.setAttribute('color-primary-tint', colorPrimaryTint);
12
+ container.appendChild(detail);
13
+ return container;
7
14
  };
@@ -5,14 +5,18 @@ export default {
5
5
  argTypes: {},
6
6
  };
7
7
 
8
- const Template = ({ label, ...args }) => {
9
- return createTrekDetail({ label, ...args });
8
+ const Template = ({ ...args }) => {
9
+ return createTrekDetail({ ...args });
10
10
  };
11
11
 
12
12
  export const TrekDetail = Template.bind({});
13
13
 
14
14
  TrekDetail.args = {
15
15
  api: 'https://randoadmin.parc-haut-jura.fr/api/v2/',
16
+ language: 'fr',
16
17
  trekId: 242872,
18
+ colorPrimary: '#6b0030',
19
+ colorPrimaryShade: '4a0021',
20
+ colorPrimaryTint: '#974c6e',
17
21
  };
18
22
  TrekDetail.storyName = 'Trek detail';
@@ -1,11 +1,20 @@
1
- export const createTrekMap = ({ api, trekId, trekLineColor, departureIconColor, arrivalIconColor }) => {
1
+ export const createTrekMap = ({ api, trekId, urlLayer, center, zoom, attribution, colorTrekLine, colorDepartureIcon, colorArrivalIcon, colorSensitiveArea, colorPoiIcon }) => {
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');
6
- trekMap.setAttribute('trek-line-color', trekLineColor);
7
- trekMap.setAttribute('departure-icon-color', departureIconColor);
8
- trekMap.setAttribute('arrival-icon-color', arrivalIconColor);
9
- trek.appendChild(trekMap);
10
- return trek;
9
+ trekMap.setAttribute('url-layer', urlLayer);
10
+ trekMap.setAttribute('center', center);
11
+ trekMap.setAttribute('zoom', zoom);
12
+ trekMap.setAttribute('attribution', attribution);
13
+ trekMap.setAttribute('color-trek-line', colorTrekLine);
14
+ trekMap.setAttribute('color-departure-icon', colorDepartureIcon);
15
+ trekMap.setAttribute('color-arrival-icon', colorArrivalIcon);
16
+ trekMap.setAttribute('color-sensitive-area', colorSensitiveArea);
17
+ trekMap.setAttribute('color-poi-icon', colorPoiIcon);
18
+ container.appendChild(trekMap);
19
+ return container;
11
20
  };
@@ -2,11 +2,20 @@ 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', 'planignv2'],
9
+ mapping: {
10
+ openstreetmap: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
11
+ planignv2: 'https://wxs.ign.fr/cartes/geoportail/wmts?&REQUEST=GetTile&SERVICE=WMTS&VERSION=1.0.0&STYLE=normal&TILEMATRIXSET=PM&FORMAT=image/png&LAYER=GEOGRAPHICALGRIDSYSTEMS.PLANIGNV2&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}',
12
+ },
13
+ },
14
+ },
6
15
  };
7
16
 
8
- const Template = ({ label, ...args }) => {
9
- return createTrekMap({ label, ...args });
17
+ const Template = ({ ...args }) => {
18
+ return createTrekMap({ ...args });
10
19
  };
11
20
 
12
21
  export const TrekMap = Template.bind({});
@@ -14,8 +23,14 @@ export const TrekMap = Template.bind({});
14
23
  TrekMap.args = {
15
24
  api: 'https://randoadmin.parc-haut-jura.fr/api/v2/',
16
25
  trekId: 242872,
17
- trekLineColor: '#6b0030',
18
- departureIconColor: '#006b3b',
19
- arrivalIconColor: '#85003b',
26
+ urlLayer: 'openstreetmap',
27
+ center: '46.50761080179829, 5.927117067721017',
28
+ zoom: 8,
29
+ attribution: '© <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a> contributors',
30
+ colorTrekLine: '#6b0030',
31
+ colorDepartureIcon: '#006b3b',
32
+ colorArrivalIcon: '#85003b',
33
+ colorSensitiveArea: '#4974a5',
34
+ colorPoiIcon: '#974c6e',
20
35
  };
21
36
  TrekMap.storyName = 'Trek map';