@abi-software/flatmapvuer 1.11.4 → 1.12.0-beta.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.
@@ -0,0 +1,194 @@
1
+ <template>
2
+ <div class="legend-item" v-if="legendStyleValue">
3
+ <template v-if="clipPathLegends.includes(legendStyleValue)">
4
+ <div
5
+ :class="legendStyleValue"
6
+ :style="customClipPathStyle(true)"
7
+ >
8
+ <div
9
+ :class="legendStyleValue"
10
+ :style="customClipPathStyle(false)"
11
+ >
12
+ </div>
13
+ </div>
14
+ </template>
15
+ <template v-else>
16
+ <div
17
+ :class="legendStyleValue"
18
+ :style="customStyle"
19
+ >
20
+ </div>
21
+ </template>
22
+ <div class="label">{{ capitalise(item[identifierKey]) }}</div>
23
+ </div>
24
+ </template>
25
+
26
+ <script>
27
+ const starTemplate = '<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path fill="<fillColor>" stroke="<borderColor>" stroke-width="<borderWidth>" d="M11.0748 3.25583C11.4141 2.42845 12.5859 2.42845 12.9252 3.25583L14.6493 7.45955C14.793 7.80979 15.1221 8.04889 15.4995 8.07727L20.0303 8.41798C20.922 8.48504 21.2841 9.59942 20.6021 10.1778L17.1369 13.1166C16.8482 13.3614 16.7225 13.7483 16.8122 14.1161L17.8882 18.5304C18.1 19.3992 17.152 20.0879 16.3912 19.618L12.5255 17.2305C12.2034 17.0316 11.7966 17.0316 11.4745 17.2305L7.60881 19.618C6.84796 20.0879 5.90001 19.3992 6.1118 18.5304L7.18785 14.1161C7.2775 13.7483 7.1518 13.3614 6.86309 13.1166L3.3979 10.1778C2.71588 9.59942 3.07796 8.48504 3.96971 8.41798L8.50046 8.07727C8.87794 8.04889 9.20704 7.80979 9.35068 7.45955L11.0748 3.25583Z"/></svg>'
28
+
29
+ /* eslint-disable no-alert, no-console */
30
+ export default {
31
+ name: "LegendItem",
32
+ props: {
33
+ item: {
34
+ type: Object,
35
+ required: true,
36
+ },
37
+ identifierKey: {
38
+ type: String,
39
+ default: "id",
40
+ },
41
+ styleKey: {
42
+ type: String,
43
+ default: "style",
44
+ },
45
+ showStarInLegend: {
46
+ type: Boolean,
47
+ default: false,
48
+ },
49
+ },
50
+ computed: {
51
+ clipPathLegends: function () {
52
+ return ['exoid', 'hexagon'];
53
+ },
54
+ legendStyleValue: function () {
55
+ if (this.item[this.styleKey] === "star") {
56
+ if (this.item[this.identifierKey] === "Featured dataset marker") {
57
+ if (!this.showStarInLegend) {
58
+ return;
59
+ }
60
+ }
61
+ return 'star';
62
+ } else if (this.clipPathLegends.includes(this.item[this.styleKey])) {
63
+ return this.item[this.styleKey];
64
+ } else if (this.item[this.styleKey] === 'line') {
65
+ return [this.item[this.styleKey], this.item.dashed ? 'dashed' : '', this.item.arrow ? 'arrow' : ''];
66
+ }
67
+ return [this.item[this.styleKey], 'shape'];
68
+ },
69
+ customStyle: function() {
70
+ const specifiedColour = this.item["color"] ? this.item["color"] : this.item["colour"];
71
+ let colour = specifiedColour ? specifiedColour : "transparent";
72
+ let borderColour = this.item.border ? this.item.border : "black";
73
+ if (specifiedColour && !this.item.border) {
74
+ borderColour = colour;
75
+ }
76
+ if (this.item[this.styleKey] === 'star') {
77
+ let star = starTemplate.replace('<fillColor>', colour);
78
+ star = star.replace('<borderColor>', borderColour);
79
+ star = star.replace('<borderWidth>', borderColour ? '2' : '0');
80
+ star = 'data:image/svg+xml,' + encodeURIComponent(star);
81
+ return { 'color': colour, 'background-image': `url(${star})` };
82
+ } else if (this.item[this.styleKey] === 'line') {
83
+ return {'color': colour};
84
+ } else {
85
+ return { 'background-color': colour, 'border-color': borderColour};
86
+ }
87
+ },
88
+ },
89
+ methods: {
90
+ capitalise: function (label) {
91
+ return label.charAt(0).toUpperCase() + label.slice(1).toLowerCase();
92
+ },
93
+ customClipPathStyle: function(isBorder) {
94
+ const style = {...this.customStyle};
95
+ if (isBorder) {
96
+ style['background-color'] = style['border-color'];
97
+ } else {
98
+ style.scale = 0.7;
99
+ }
100
+ return style;
101
+ },
102
+ },
103
+ };
104
+ </script>
105
+
106
+ <style lang="scss" scoped>
107
+ .legend-item {
108
+ display: flex;
109
+ align-items: center;
110
+ margin: 8px 12.5px;
111
+ }
112
+
113
+ .line {
114
+ position: relative;
115
+ width: 20px;
116
+ border-top: 2px solid currentColor;
117
+ }
118
+
119
+ .line.dashed {
120
+ border-top: 2px dashed currentColor;
121
+ }
122
+
123
+ .line::after {
124
+ content: "";
125
+ position: absolute;
126
+ right: -2px;
127
+ top: -5px;
128
+ width: 0;
129
+ height: 0;
130
+ border-left: 7px solid currentColor;
131
+ border-top: 4px solid transparent;
132
+ border-bottom: 4px solid transparent;
133
+ display: none;
134
+ }
135
+
136
+ .line.arrow::after {
137
+ display: block;
138
+ }
139
+
140
+ .shape {
141
+ height: 16px;
142
+ width: 16px;
143
+ border-color: black;
144
+ border-style: solid;
145
+ border-width: 2px;
146
+ background-color: transparent;
147
+ display: inline-block;
148
+ }
149
+
150
+ .circle {
151
+ border-radius: 50%;
152
+ }
153
+
154
+ .rounded-square {
155
+ border-radius: 30%;
156
+ }
157
+
158
+ .hexagon {
159
+ width: 20px;
160
+ height: calc(20px * 0.866);
161
+ background-color: transparent;
162
+ clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
163
+ -webkit-clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
164
+ }
165
+
166
+ .exoid {
167
+ width: 20px;
168
+ height: 25px;
169
+ background-color: transparent;
170
+ clip-path: path(
171
+ "M9.96 0.72 c-2.01 3.53 -5.81 5.74 -9.92 5.74 l-0.15 0.23 c1.94 3.42 1.94 7.6 0 11.02 l0.15 0.23 c4.07 0 7.9 2.2 9.92 5.74 c2.01 -3.53 5.81 -5.74 9.92 -5.74 c-2.01 -3.53 -2.01 -7.94 0 -11.55 C15.81 6.5 12.04 4.29 9.96 0.72z"
172
+ );
173
+ -webkit-clip-path: path(
174
+ "M9.96 0.72 c-2.01 3.53 -5.81 5.74 -9.92 5.74 l-0.15 0.23 c1.94 3.42 1.94 7.6 0 11.02 l0.15 0.23 c4.07 0 7.9 2.2 9.92 5.74 c2.01 -3.53 5.81 -5.74 9.92 -5.74 c-2.01 -3.53 -2.01 -7.94 0 -11.55 C15.81 6.5 12.04 4.29 9.96 0.72z"
175
+ );
176
+ }
177
+
178
+ .star {
179
+ width: 25px;
180
+ height: 25px;
181
+ background-color: transparent !important;
182
+ background-repeat: no-repeat;
183
+ background-size: contain;
184
+ display: inline-block;
185
+ margin: -3px;
186
+ padding-right: 2px;
187
+ }
188
+
189
+ .label {
190
+ margin-left: 14px;
191
+ font-size: 12px;
192
+ color: rgb(48, 49, 51);
193
+ }
194
+ </style>
@@ -26,6 +26,7 @@ declare module 'vue' {
26
26
  ElSelect: typeof import('element-plus/es')['ElSelect']
27
27
  FlatmapError: typeof import('./components/FlatmapError.vue')['default']
28
28
  FlatmapVuer: typeof import('./components/FlatmapVuer.vue')['default']
29
+ LegendItem: typeof import('./components/legends/LegendItem.vue')['default']
29
30
  MultiFlatmapVuer: typeof import('./components/MultiFlatmapVuer.vue')['default']
30
31
  SelectionsGroup: typeof import('./components/SelectionsGroup.vue')['default']
31
32
  SvgLegends: typeof import('./components/legends/SvgLegends.vue')['default']
@@ -0,0 +1,6 @@
1
+ /**
2
+ * a single source for the flatmap-viewer library import
3
+ */
4
+ import * as flatmap from 'https://cdn.jsdelivr.net/npm/@abi-software/flatmap-viewer@4.4.0/+esm';
5
+
6
+ export default flatmap;