@abi-software/map-utilities 0.0.0-beta.6 → 1.0.0

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.
@@ -1,394 +1,394 @@
1
- <template>
2
- <div class="help-mode-dialog" :class="{ finish: lastItem }">
3
- <h4>Help Mode</h4>
4
-
5
- <template v-if="lastItem">
6
- <p>
7
- All caught up! <br />
8
- Click 'Help' to restart.
9
- </p>
10
- <div>
11
- <el-button class="button" @click="finishHelpMode"> Finish </el-button>
12
- </div>
13
- </template>
14
- <template v-else>
15
- <p>Click "Next" to see the next item.</p>
16
- <div>
17
- <el-button class="button" @click="showNext"> Next </el-button>
18
- <el-button class="button secondary" @click="finishHelpMode">
19
- Exit Help Mode
20
- </el-button>
21
- </div>
22
- </template>
23
- </div>
24
- </template>
25
-
26
- <script>
27
- export default {
28
- name: "HelpModeDialog",
29
- props: {
30
- /**
31
- * MultiFlatmapRef from multiflatmapvuer. Provide this when using with MultiFlatmap.
32
- */
33
- multiflatmapRef: {
34
- type: Object,
35
- default: null,
36
- },
37
- /**
38
- * FlatmapRef from flatmapvuer. Provide this when using with Flatmap.
39
- */
40
- flatmapRef: {
41
- type: Object,
42
- default: null,
43
- },
44
- /**
45
- * ScaffoldRef from scaffoldvuer. Provide this when using with Scaffold.
46
- */
47
- scaffoldRef: {
48
- type: Object,
49
- default: null,
50
- },
51
- /**
52
- * The flag for last tooltip item.
53
- */
54
- lastItem: {
55
- type: Boolean,
56
- default: false,
57
- required: false,
58
- },
59
- },
60
- mounted: function () {
61
- this.toggleHelpModeHighlight(true);
62
- // For tooltips outside of Flatmap
63
- this.toggleTooltipHighlight();
64
- },
65
- unmounted: function () {
66
- this.toggleHelpModeHighlight(false);
67
- },
68
- watch: {
69
- lastItem: function (isLastItem) {
70
- if (isLastItem) {
71
- this.toggleTooltipHighlight();
72
- }
73
- },
74
- },
75
- methods: {
76
- /**
77
- * This function will be called on clicking Next button.
78
- *
79
- * @public
80
- */
81
- showNext: function () {
82
- /**
83
- * This event is emitted after clicking Next button.
84
- */
85
- this.$emit("show-next");
86
- },
87
- /**
88
- * This function will be called on clicking Finish button.
89
- *
90
- * @public
91
- */
92
- finishHelpMode: function () {
93
- /**
94
- * This event is emitted after clicking Finish button.
95
- */
96
- this.$emit("finish-help-mode");
97
- },
98
- /**
99
- * This function must be called on 'shown-map-tooltip' event.
100
- *
101
- * @public
102
- */
103
- toggleTooltipPinHighlight: function () {
104
- const currentFlatmapEl = this.getCurrentFlatmap();
105
- this.resetHighlightedItems();
106
-
107
- this.$nextTick(() => {
108
- // Temporary solution to find the position of map marker from popover
109
- const mapPins = currentFlatmapEl.querySelectorAll(".maplibregl-marker");
110
- const mapPinPopover = currentFlatmapEl.querySelector(
111
- ".flatmap-popup-popper"
112
- );
113
- const styleVal = mapPinPopover?.style?.transform || "";
114
- const mapPopoverPosition = this.extractMarkerPosition(styleVal);
115
-
116
- mapPins.forEach((mapPin) => {
117
- const mapPinStyleVal = mapPin.style.transform;
118
- const mapPinPosition = this.extractMarkerPosition(mapPinStyleVal);
119
-
120
- if (mapPinPosition === mapPopoverPosition) {
121
- mapPin.classList.add("in-help-highlight");
122
- }
123
- });
124
- });
125
- },
126
- /**
127
- * This function must be called on 'shown-tooltip' event.
128
- *
129
- * @public
130
- */
131
- toggleTooltipHighlight: function () {
132
- this.resetHighlightedItems();
133
-
134
- this.$nextTick(() => {
135
- const activePoppers = document.querySelectorAll(
136
- '.el-popper:not([style*="none"])'
137
- );
138
-
139
- activePoppers.forEach((activePopper) => {
140
- const multiFlatmapTooltip =
141
- activePopper.classList.contains("flatmap-popper");
142
- const flatmapTooltip = activePopper.classList.contains(
143
- "el-fade-in-linear-enter-active"
144
- );
145
-
146
- if (multiFlatmapTooltip || flatmapTooltip) {
147
- this.toggleHighlight(activePopper);
148
- }
149
- });
150
- });
151
- },
152
- toggleHighlight: function (activePopper) {
153
- const popperId = activePopper?.id || "";
154
- const popperTrigger = document.querySelector(
155
- `[aria-describedby="${popperId}"]`
156
- );
157
-
158
- if (popperTrigger) {
159
- popperTrigger.classList.add("in-help-highlight");
160
- }
161
- },
162
- resetHighlightedItems: function () {
163
- const allHighlightedItems =
164
- document.querySelectorAll(".in-help-highlight");
165
- allHighlightedItems.forEach((el) => {
166
- el.classList.remove("in-help-highlight");
167
- });
168
- },
169
- getCurrentScaffold: function () {
170
- const scaffoldEl = this.scaffoldRef?.$el || null;
171
- return scaffoldEl;
172
- },
173
- getCurrentMultiflatmap: function () {
174
- const multiflatmapEl = this.multiflatmapRef?.$el || null;
175
- return multiflatmapEl;
176
- },
177
- getCurrentFlatmap: function () {
178
- const flatmap =
179
- this.flatmapRef || this.multiflatmapRef?.getCurrentFlatmap();
180
- const flatmapEl = flatmap?.$el || null;
181
- return flatmapEl;
182
- },
183
- toggleHelpModeHighlight: function (option) {
184
- const currentMultiflatmapEl = this.getCurrentMultiflatmap();
185
- const currentFlatmapEl = this.getCurrentFlatmap();
186
- const currentScaffoldEl = this.getCurrentScaffold();
187
- const allHighlightedItems =
188
- document.querySelectorAll(".in-help-highlight");
189
-
190
- if (currentMultiflatmapEl) {
191
- if (option) {
192
- currentMultiflatmapEl.classList.add("in-help");
193
- } else {
194
- currentMultiflatmapEl.classList.remove("in-help");
195
- }
196
- }
197
-
198
- if (currentFlatmapEl) {
199
- if (option) {
200
- currentFlatmapEl.classList.add("in-help");
201
- } else {
202
- currentFlatmapEl.classList.remove("in-help");
203
- }
204
- }
205
-
206
- if (currentScaffoldEl) {
207
- if (option) {
208
- currentScaffoldEl.classList.add("in-help");
209
- } else {
210
- currentScaffoldEl.classList.remove("in-help");
211
- }
212
- }
213
-
214
- if (!option) {
215
- allHighlightedItems.forEach((el) => {
216
- el.classList.remove("in-help-highlight");
217
- });
218
- }
219
- },
220
- /**
221
- * Temporary solution to find the position of map marker from popover
222
- */
223
- extractMarkerPosition: function (str) {
224
- const translateRegex = /translate\((.*?)\)/g;
225
- const matches = str.match(translateRegex);
226
- if (!matches) {
227
- return "";
228
- }
229
- const lastMatch = matches[matches.length - 1];
230
- const values = lastMatch.slice(10, -1);
231
- return values;
232
- },
233
- },
234
- };
235
- </script>
236
-
237
- <style lang="scss" scoped>
238
- .help-mode-dialog {
239
- display: flex;
240
- flex-direction: column;
241
- align-items: center;
242
- justify-content: center;
243
- gap: 1rem;
244
- width: 300px;
245
- padding: 1rem;
246
- font-family: inherit;
247
- font-size: 14px;
248
- background: white;
249
- border-radius: 4px 4px;
250
- border: 1px solid $app-primary-color;
251
- box-shadow: 0px 0px 160px 80px rgba(0, 0, 0, 0.5);
252
- position: absolute;
253
- top: 0;
254
- left: 50%;
255
- transform: translateX(-50%);
256
- z-index: 2;
257
-
258
- &.finish {
259
- animation: shake 0.35s;
260
- animation-delay: 0.7s;
261
- }
262
-
263
- h4 {
264
- color: $app-primary-color;
265
- }
266
-
267
- h4,
268
- p {
269
- margin: 0;
270
- }
271
-
272
- p {
273
- line-height: 1.5;
274
- }
275
-
276
- .button {
277
- color: #fff;
278
- background-color: $app-primary-color;
279
- transform: scale(1);
280
- transform-origin: 50% 50%;
281
- transition: all var(--el-transition-duration);
282
-
283
- &:hover {
284
- color: #fff !important;
285
- background: #ac76c5 !important;
286
- border: 1px solid #ac76c5 !important;
287
- }
288
-
289
- &:active {
290
- transform: scale(0.95);
291
- }
292
-
293
- &.secondary {
294
- background: #f3e6f9;
295
- border-color: $app-primary-color;
296
- color: $app-primary-color;
297
-
298
- &:hover {
299
- color: $app-primary-color !important;
300
- background: #fff !important;
301
- }
302
- }
303
- }
304
- }
305
-
306
- @keyframes shake {
307
- 0% {
308
- transform: translateX(-50%) rotate(2deg);
309
- }
310
- 25% {
311
- transform: translateX(-50%) rotate(-2deg);
312
- }
313
- 50% {
314
- transform: translateX(-50%) rotate(2deg);
315
- }
316
- 75% {
317
- transform: translateX(-50%) rotate(-2deg);
318
- }
319
- 100% {
320
- transform: translateX(-50%) rotate(2deg);
321
- }
322
- }
323
-
324
- // Just for App.vue with options popover on top
325
- .help-mode-dialog {
326
- .options-popover + .multi-container + & {
327
- margin-top: 40px;
328
- }
329
- .options-popover:not([style*="display: none"]) + .multi-container + & {
330
- margin-top: 175px;
331
- }
332
- }
333
- </style>
334
-
335
- <style lang="scss">
336
- .scaffold-container.in-help,
337
- .flatmap-container.in-help {
338
- background: rgba(0, 0, 0, 0.3);
339
- }
340
-
341
- .scaffold-container.in-help {
342
- canvas {
343
- opacity: 0.3;
344
- }
345
- }
346
-
347
- .scaffold-container.in-help,
348
- .flatmap-container.in-help {
349
- .el-tooltip__trigger,
350
- .el-popover {
351
- opacity: 0.3;
352
- }
353
-
354
- .pathway-location:has(.in-help-highlight) {
355
- opacity: 1;
356
-
357
- .pathway-container {
358
- background: transparent;
359
- }
360
-
361
- .container,
362
- .legends-container,
363
- .selections-container {
364
- opacity: 0.3;
365
- }
366
- }
367
-
368
- .maplibregl-canvas,
369
- .maplibregl-ctrl-minimap {
370
- opacity: 0.3;
371
- }
372
-
373
- .maplibregl-map,
374
- .maplibregl-canvas {
375
- pointer-events: none;
376
- }
377
- }
378
-
379
- .in-help .el-popper:not([style*="none"]) {
380
- opacity: 1 !important;
381
- }
382
-
383
- .in-help-highlight {
384
- opacity: 1 !important;
385
- background: white !important;
386
- box-shadow: 0px 0px 128px 128px white !important;
387
- animation: highlight-area 0.1s;
388
-
389
- &.maplibregl-marker {
390
- background: none !important;
391
- box-shadow: 0px 0px 128px 128px rgba(255, 255, 255, 0.5) !important;
392
- }
393
- }
394
- </style>
1
+ <template>
2
+ <div class="help-mode-dialog" :class="{ finish: lastItem }">
3
+ <h4>Help Mode</h4>
4
+
5
+ <template v-if="lastItem">
6
+ <p>
7
+ All caught up! <br />
8
+ Click 'Help' to restart.
9
+ </p>
10
+ <div>
11
+ <el-button class="button" @click="finishHelpMode"> Finish </el-button>
12
+ </div>
13
+ </template>
14
+ <template v-else>
15
+ <p>Click "Next" to see the next item.</p>
16
+ <div>
17
+ <el-button class="button" @click="showNext"> Next </el-button>
18
+ <el-button class="button secondary" @click="finishHelpMode">
19
+ Exit Help Mode
20
+ </el-button>
21
+ </div>
22
+ </template>
23
+ </div>
24
+ </template>
25
+
26
+ <script>
27
+ export default {
28
+ name: "HelpModeDialog",
29
+ props: {
30
+ /**
31
+ * MultiFlatmapRef from multiflatmapvuer. Provide this when using with MultiFlatmap.
32
+ */
33
+ multiflatmapRef: {
34
+ type: Object,
35
+ default: null,
36
+ },
37
+ /**
38
+ * FlatmapRef from flatmapvuer. Provide this when using with Flatmap.
39
+ */
40
+ flatmapRef: {
41
+ type: Object,
42
+ default: null,
43
+ },
44
+ /**
45
+ * ScaffoldRef from scaffoldvuer. Provide this when using with Scaffold.
46
+ */
47
+ scaffoldRef: {
48
+ type: Object,
49
+ default: null,
50
+ },
51
+ /**
52
+ * The flag for last tooltip item.
53
+ */
54
+ lastItem: {
55
+ type: Boolean,
56
+ default: false,
57
+ required: false,
58
+ },
59
+ },
60
+ mounted: function () {
61
+ this.toggleHelpModeHighlight(true);
62
+ // For tooltips outside of Flatmap
63
+ this.toggleTooltipHighlight();
64
+ },
65
+ unmounted: function () {
66
+ this.toggleHelpModeHighlight(false);
67
+ },
68
+ watch: {
69
+ lastItem: function (isLastItem) {
70
+ if (isLastItem) {
71
+ this.toggleTooltipHighlight();
72
+ }
73
+ },
74
+ },
75
+ methods: {
76
+ /**
77
+ * This function will be called on clicking Next button.
78
+ *
79
+ * @public
80
+ */
81
+ showNext: function () {
82
+ /**
83
+ * This event is emitted after clicking Next button.
84
+ */
85
+ this.$emit("show-next");
86
+ },
87
+ /**
88
+ * This function will be called on clicking Finish button.
89
+ *
90
+ * @public
91
+ */
92
+ finishHelpMode: function () {
93
+ /**
94
+ * This event is emitted after clicking Finish button.
95
+ */
96
+ this.$emit("finish-help-mode");
97
+ },
98
+ /**
99
+ * This function must be called on 'shown-map-tooltip' event.
100
+ *
101
+ * @public
102
+ */
103
+ toggleTooltipPinHighlight: function () {
104
+ const currentFlatmapEl = this.getCurrentFlatmap();
105
+ this.resetHighlightedItems();
106
+
107
+ this.$nextTick(() => {
108
+ // Temporary solution to find the position of map marker from popover
109
+ const mapPins = currentFlatmapEl.querySelectorAll(".maplibregl-marker");
110
+ const mapPinPopover = currentFlatmapEl.querySelector(
111
+ ".flatmap-popup-popper"
112
+ );
113
+ const styleVal = mapPinPopover?.style?.transform || "";
114
+ const mapPopoverPosition = this.extractMarkerPosition(styleVal);
115
+
116
+ mapPins.forEach((mapPin) => {
117
+ const mapPinStyleVal = mapPin.style.transform;
118
+ const mapPinPosition = this.extractMarkerPosition(mapPinStyleVal);
119
+
120
+ if (mapPinPosition === mapPopoverPosition) {
121
+ mapPin.classList.add("in-help-highlight");
122
+ }
123
+ });
124
+ });
125
+ },
126
+ /**
127
+ * This function must be called on 'shown-tooltip' event.
128
+ *
129
+ * @public
130
+ */
131
+ toggleTooltipHighlight: function () {
132
+ this.resetHighlightedItems();
133
+
134
+ this.$nextTick(() => {
135
+ const activePoppers = document.querySelectorAll(
136
+ '.el-popper:not([style*="none"])'
137
+ );
138
+
139
+ activePoppers.forEach((activePopper) => {
140
+ const multiFlatmapTooltip =
141
+ activePopper.classList.contains("flatmap-popper");
142
+ const flatmapTooltip = activePopper.classList.contains(
143
+ "el-fade-in-linear-enter-active"
144
+ );
145
+
146
+ if (multiFlatmapTooltip || flatmapTooltip) {
147
+ this.toggleHighlight(activePopper);
148
+ }
149
+ });
150
+ });
151
+ },
152
+ toggleHighlight: function (activePopper) {
153
+ const popperId = activePopper?.id || "";
154
+ const popperTrigger = document.querySelector(
155
+ `[aria-describedby="${popperId}"]`
156
+ );
157
+
158
+ if (popperTrigger) {
159
+ popperTrigger.classList.add("in-help-highlight");
160
+ }
161
+ },
162
+ resetHighlightedItems: function () {
163
+ const allHighlightedItems =
164
+ document.querySelectorAll(".in-help-highlight");
165
+ allHighlightedItems.forEach((el) => {
166
+ el.classList.remove("in-help-highlight");
167
+ });
168
+ },
169
+ getCurrentScaffold: function () {
170
+ const scaffoldEl = this.scaffoldRef?.$el || null;
171
+ return scaffoldEl;
172
+ },
173
+ getCurrentMultiflatmap: function () {
174
+ const multiflatmapEl = this.multiflatmapRef?.$el || null;
175
+ return multiflatmapEl;
176
+ },
177
+ getCurrentFlatmap: function () {
178
+ const flatmap =
179
+ this.flatmapRef || this.multiflatmapRef?.getCurrentFlatmap();
180
+ const flatmapEl = flatmap?.$el || null;
181
+ return flatmapEl;
182
+ },
183
+ toggleHelpModeHighlight: function (option) {
184
+ const currentMultiflatmapEl = this.getCurrentMultiflatmap();
185
+ const currentFlatmapEl = this.getCurrentFlatmap();
186
+ const currentScaffoldEl = this.getCurrentScaffold();
187
+ const allHighlightedItems =
188
+ document.querySelectorAll(".in-help-highlight");
189
+
190
+ if (currentMultiflatmapEl) {
191
+ if (option) {
192
+ currentMultiflatmapEl.classList.add("in-help");
193
+ } else {
194
+ currentMultiflatmapEl.classList.remove("in-help");
195
+ }
196
+ }
197
+
198
+ if (currentFlatmapEl) {
199
+ if (option) {
200
+ currentFlatmapEl.classList.add("in-help");
201
+ } else {
202
+ currentFlatmapEl.classList.remove("in-help");
203
+ }
204
+ }
205
+
206
+ if (currentScaffoldEl) {
207
+ if (option) {
208
+ currentScaffoldEl.classList.add("in-help");
209
+ } else {
210
+ currentScaffoldEl.classList.remove("in-help");
211
+ }
212
+ }
213
+
214
+ if (!option) {
215
+ allHighlightedItems.forEach((el) => {
216
+ el.classList.remove("in-help-highlight");
217
+ });
218
+ }
219
+ },
220
+ /**
221
+ * Temporary solution to find the position of map marker from popover
222
+ */
223
+ extractMarkerPosition: function (str) {
224
+ const translateRegex = /translate\((.*?)\)/g;
225
+ const matches = str.match(translateRegex);
226
+ if (!matches) {
227
+ return "";
228
+ }
229
+ const lastMatch = matches[matches.length - 1];
230
+ const values = lastMatch.slice(10, -1);
231
+ return values;
232
+ },
233
+ },
234
+ };
235
+ </script>
236
+
237
+ <style lang="scss" scoped>
238
+ .help-mode-dialog {
239
+ display: flex;
240
+ flex-direction: column;
241
+ align-items: center;
242
+ justify-content: center;
243
+ gap: 1rem;
244
+ width: 300px;
245
+ padding: 1rem;
246
+ font-family: inherit;
247
+ font-size: 14px;
248
+ background: white;
249
+ border-radius: 4px 4px;
250
+ border: 1px solid $app-primary-color;
251
+ box-shadow: 0px 0px 160px 80px rgba(0, 0, 0, 0.5);
252
+ position: absolute;
253
+ top: 0;
254
+ left: 50%;
255
+ transform: translateX(-50%);
256
+ z-index: 2;
257
+
258
+ &.finish {
259
+ animation: shake 0.35s;
260
+ animation-delay: 0.7s;
261
+ }
262
+
263
+ h4 {
264
+ color: $app-primary-color;
265
+ }
266
+
267
+ h4,
268
+ p {
269
+ margin: 0;
270
+ }
271
+
272
+ p {
273
+ line-height: 1.5;
274
+ }
275
+
276
+ .button {
277
+ color: #fff;
278
+ background-color: $app-primary-color;
279
+ transform: scale(1);
280
+ transform-origin: 50% 50%;
281
+ transition: all var(--el-transition-duration);
282
+
283
+ &:hover {
284
+ color: #fff !important;
285
+ background: #ac76c5 !important;
286
+ border: 1px solid #ac76c5 !important;
287
+ }
288
+
289
+ &:active {
290
+ transform: scale(0.95);
291
+ }
292
+
293
+ &.secondary {
294
+ background: #f3e6f9;
295
+ border-color: $app-primary-color;
296
+ color: $app-primary-color;
297
+
298
+ &:hover {
299
+ color: $app-primary-color !important;
300
+ background: #fff !important;
301
+ }
302
+ }
303
+ }
304
+ }
305
+
306
+ @keyframes shake {
307
+ 0% {
308
+ transform: translateX(-50%) rotate(2deg);
309
+ }
310
+ 25% {
311
+ transform: translateX(-50%) rotate(-2deg);
312
+ }
313
+ 50% {
314
+ transform: translateX(-50%) rotate(2deg);
315
+ }
316
+ 75% {
317
+ transform: translateX(-50%) rotate(-2deg);
318
+ }
319
+ 100% {
320
+ transform: translateX(-50%) rotate(2deg);
321
+ }
322
+ }
323
+
324
+ // Just for App.vue with options popover on top
325
+ .help-mode-dialog {
326
+ .options-popover + .multi-container + & {
327
+ margin-top: 40px;
328
+ }
329
+ .options-popover:not([style*="display: none"]) + .multi-container + & {
330
+ margin-top: 175px;
331
+ }
332
+ }
333
+ </style>
334
+
335
+ <style lang="scss">
336
+ .scaffold-container.in-help,
337
+ .flatmap-container.in-help {
338
+ background: rgba(0, 0, 0, 0.3);
339
+ }
340
+
341
+ .scaffold-container.in-help {
342
+ canvas {
343
+ opacity: 0.3;
344
+ }
345
+ }
346
+
347
+ .scaffold-container.in-help,
348
+ .flatmap-container.in-help {
349
+ .el-tooltip__trigger,
350
+ .el-popover {
351
+ opacity: 0.3;
352
+ }
353
+
354
+ .pathway-location:has(.in-help-highlight) {
355
+ opacity: 1;
356
+
357
+ .pathway-container {
358
+ background: transparent;
359
+ }
360
+
361
+ .container,
362
+ .legends-container,
363
+ .selections-container {
364
+ opacity: 0.3;
365
+ }
366
+ }
367
+
368
+ .maplibregl-canvas,
369
+ .maplibregl-ctrl-minimap {
370
+ opacity: 0.3;
371
+ }
372
+
373
+ .maplibregl-map,
374
+ .maplibregl-canvas {
375
+ pointer-events: none;
376
+ }
377
+ }
378
+
379
+ .in-help .el-popper:not([style*="none"]) {
380
+ opacity: 1 !important;
381
+ }
382
+
383
+ .in-help-highlight {
384
+ opacity: 1 !important;
385
+ background: white !important;
386
+ box-shadow: 0px 0px 128px 128px white !important;
387
+ animation: highlight-area 0.1s;
388
+
389
+ &.maplibregl-marker {
390
+ background: none !important;
391
+ box-shadow: 0px 0px 128px 128px rgba(255, 255, 255, 0.5) !important;
392
+ }
393
+ }
394
+ </style>