@classic-homes/maps-core 0.7.4 → 0.7.5

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/styles/popup.css +142 -122
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@classic-homes/maps-core",
3
- "version": "0.7.4",
3
+ "version": "0.7.5",
4
4
  "description": "Core utilities and theme for Classic Theme maps",
5
5
  "keywords": [
6
6
  "maps",
@@ -91,181 +91,201 @@
91
91
  position: absolute;
92
92
  inset: -8px;
93
93
  }
94
+ /* PopupContent placed first (no PopupHeader) keeps clear of the close button */
95
+ .maplibregl-popup-content:has(> .maplibregl-popup-close-button)
96
+ [data-popup-card]
97
+ > [data-popup-content]:first-child {
98
+ padding-right: 2.75rem;
99
+ }
94
100
 
95
101
  /* ==========================================================================
96
- Popup Tip/Arrow Styling
97
-
98
- MapLibre creates a tip element with CSS borders to form a triangle.
99
- We color the border to match our popup border, then use ::after to
100
- create an inner triangle that fills with the background color.
101
-
102
- Note: The tip is outside the content container, so overflow:hidden
103
- on the content doesn't affect it.
102
+ Corner anchors: the tip meets the popup at a square corner
104
103
  ========================================================================== */
105
104
 
106
- /* Base tip styling - position: relative is required for ::after positioning */
107
- .maplibregl-popup-tip {
108
- z-index: 1 !important;
109
- position: relative !important;
105
+ .maplibregl-popup-anchor-top-left .maplibregl-popup-content {
106
+ border-top-left-radius: 0 !important;
110
107
  }
111
108
 
112
- /* --- Bottom Anchored (popup above point, arrow points down) --- */
113
-
114
- .maplibregl-popup-anchor-bottom .maplibregl-popup-tip {
115
- border-top-color: hsl(var(--border)) !important;
109
+ .maplibregl-popup-anchor-top-right .maplibregl-popup-content {
110
+ border-top-right-radius: 0 !important;
116
111
  }
117
112
 
118
- .dark .maplibregl-popup-anchor-bottom .maplibregl-popup-tip {
119
- border-top-color: rgb(156 163 175) !important;
113
+ .maplibregl-popup-anchor-bottom-left .maplibregl-popup-content {
114
+ border-bottom-left-radius: 0 !important;
120
115
  }
121
116
 
122
- /* Inner fill triangle */
123
- .maplibregl-popup-anchor-bottom .maplibregl-popup-tip::after {
124
- content: '' !important;
125
- position: absolute !important;
126
- left: -10px !important;
127
- top: -11px !important;
128
- border-left: 10px solid transparent !important;
129
- border-right: 10px solid transparent !important;
130
- border-top: 10px solid hsl(var(--popover)) !important;
117
+ .maplibregl-popup-anchor-bottom-right .maplibregl-popup-content {
118
+ border-bottom-right-radius: 0 !important;
131
119
  }
132
120
 
133
- /* --- Top Anchored (popup below point, arrow points up) --- */
121
+ [dir='rtl'] .maplibregl-popup-anchor-top-left .maplibregl-popup-content {
122
+ border-top-left-radius: 0.5rem !important;
123
+ border-top-right-radius: 0 !important;
124
+ }
134
125
 
135
- .maplibregl-popup-anchor-top .maplibregl-popup-tip {
136
- border-bottom-color: hsl(var(--border)) !important;
126
+ [dir='rtl'] .maplibregl-popup-anchor-top-right .maplibregl-popup-content {
127
+ border-top-right-radius: 0.5rem !important;
128
+ border-top-left-radius: 0 !important;
137
129
  }
138
130
 
139
- .dark .maplibregl-popup-anchor-top .maplibregl-popup-tip {
140
- border-bottom-color: rgb(156 163 175) !important;
131
+ [dir='rtl'] .maplibregl-popup-anchor-bottom-left .maplibregl-popup-content {
132
+ border-bottom-left-radius: 0.5rem !important;
133
+ border-bottom-right-radius: 0 !important;
141
134
  }
142
135
 
143
- .maplibregl-popup-anchor-top .maplibregl-popup-tip::after {
144
- content: '' !important;
145
- position: absolute !important;
146
- left: -10px !important;
147
- bottom: -11px !important;
148
- border-left: 10px solid transparent !important;
149
- border-right: 10px solid transparent !important;
150
- border-bottom: 10px solid hsl(var(--popover)) !important;
136
+ [dir='rtl'] .maplibregl-popup-anchor-bottom-right .maplibregl-popup-content {
137
+ border-bottom-right-radius: 0.5rem !important;
138
+ border-bottom-left-radius: 0 !important;
151
139
  }
152
140
 
153
- /* --- Left Anchored (popup to right of point, arrow points left) --- */
141
+ /* ==========================================================================
142
+ Popup Tip/Arrow
143
+
144
+ MapLibre draws the tip as a CSS border triangle. We drop that and paint
145
+ two clip-path triangles instead: ::before in the border colour, ::after
146
+ in the fill colour, inset 1px (1.414px along the 45° edges). The tip
147
+ overlaps the popup by 1px, so the fill covers the popup's own border
148
+ across the tip's mouth: the outline runs round the tip, not through it.
149
+
150
+ The fill matches the part of the popup the tip touches: PopupHeader
151
+ (when it comes first) for tips above, PopupFooter (when it comes last)
152
+ for tips below, the popover colour otherwise. A header or footer with a
153
+ custom background sets --popup-tip-fill on the popup to match.
154
+ ========================================================================== */
154
155
 
155
- .maplibregl-popup-anchor-left .maplibregl-popup-tip {
156
- border-right-color: hsl(var(--border)) !important;
156
+ .maplibregl-popup {
157
+ --ct-popup-tip-border: hsl(var(--border));
158
+ --ct-popup-tip-fill: var(--popup-tip-fill, hsl(var(--popover)));
157
159
  }
158
160
 
159
- .dark .maplibregl-popup-anchor-left .maplibregl-popup-tip {
160
- border-right-color: rgb(156 163 175) !important;
161
+ .dark .maplibregl-popup {
162
+ --ct-popup-tip-border: rgb(156 163 175); /* gray-400, as the popup border */
161
163
  }
162
164
 
163
- .maplibregl-popup-anchor-left .maplibregl-popup-tip::after {
164
- content: '' !important;
165
- position: absolute !important;
166
- top: -10px !important;
167
- left: -10px !important;
168
- border-top: 10px solid transparent !important;
169
- border-bottom: 10px solid transparent !important;
170
- border-right: 10px solid hsl(var(--popover)) !important;
165
+ .maplibregl-popup:is(
166
+ .maplibregl-popup-anchor-top,
167
+ .maplibregl-popup-anchor-top-left,
168
+ .maplibregl-popup-anchor-top-right
169
+ ):has([data-popup-card] > [data-popup-header]:first-child),
170
+ .maplibregl-popup:is(
171
+ .maplibregl-popup-anchor-bottom,
172
+ .maplibregl-popup-anchor-bottom-left,
173
+ .maplibregl-popup-anchor-bottom-right
174
+ ):has([data-popup-card] > [data-popup-footer]:last-child) {
175
+ --ct-popup-tip-fill: var(--popup-tip-fill, hsl(var(--muted)));
171
176
  }
172
177
 
173
- /* --- Right Anchored (popup to left of point, arrow points right) --- */
174
-
175
- .maplibregl-popup-anchor-right .maplibregl-popup-tip {
176
- border-left-color: hsl(var(--border)) !important;
178
+ .maplibregl-popup-tip {
179
+ position: relative !important;
180
+ z-index: 1 !important; /* above the popup's border */
181
+ width: 22px !important;
182
+ height: 11px !important;
183
+ border: none !important;
177
184
  }
178
185
 
179
- .dark .maplibregl-popup-anchor-right .maplibregl-popup-tip {
180
- border-left-color: rgb(156 163 175) !important;
186
+ .maplibregl-popup-tip::before,
187
+ .maplibregl-popup-tip::after {
188
+ content: '';
189
+ position: absolute;
190
+ inset: 0;
191
+ clip-path: var(--ct-tip-outer);
192
+ background: var(--ct-popup-tip-border);
181
193
  }
182
194
 
183
- .maplibregl-popup-anchor-right .maplibregl-popup-tip::after {
184
- content: '' !important;
185
- position: absolute !important;
186
- top: -10px !important;
187
- right: -10px !important;
188
- border-top: 10px solid transparent !important;
189
- border-bottom: 10px solid transparent !important;
190
- border-left: 10px solid hsl(var(--popover)) !important;
195
+ .maplibregl-popup-tip::after {
196
+ clip-path: var(--ct-tip-inner);
197
+ background: var(--ct-popup-tip-fill);
191
198
  }
192
199
 
193
- /* --- Top-Left Anchored (popup below-right of point, arrow points up-left) --- */
194
-
195
- .maplibregl-popup-anchor-top-left .maplibregl-popup-tip {
196
- border-bottom-color: hsl(var(--border)) !important;
200
+ /* Popup above the point: tip hangs below, mouth on top */
201
+ .maplibregl-popup-anchor-bottom .maplibregl-popup-tip {
202
+ margin-top: -1px !important;
203
+ --ct-tip-outer: polygon(0 0, 100% 0, 50% 100%);
204
+ --ct-tip-inner: polygon(1.414px 0, calc(100% - 1.414px) 0, 50% calc(100% - 1.414px));
197
205
  }
198
206
 
199
- .dark .maplibregl-popup-anchor-top-left .maplibregl-popup-tip {
200
- border-bottom-color: rgb(156 163 175) !important;
207
+ /* Popup below the point: tip sits on top, mouth at the bottom */
208
+ .maplibregl-popup-anchor-top .maplibregl-popup-tip {
209
+ margin-bottom: -1px !important;
210
+ --ct-tip-outer: polygon(50% 0, 100% 100%, 0 100%);
211
+ --ct-tip-inner: polygon(50% 1.414px, calc(100% - 1.414px) 100%, 1.414px 100%);
201
212
  }
202
213
 
203
- .maplibregl-popup-anchor-top-left .maplibregl-popup-tip::after {
204
- content: '' !important;
205
- position: absolute !important;
206
- left: -10px !important;
207
- bottom: -11px !important;
208
- border-left: 10px solid transparent !important;
209
- border-right: 10px solid transparent !important;
210
- border-bottom: 10px solid hsl(var(--popover)) !important;
214
+ /* Popup right of the point: tip on its left, mouth on the right */
215
+ .maplibregl-popup-anchor-left .maplibregl-popup-tip {
216
+ width: 11px !important;
217
+ height: 22px !important;
218
+ margin-right: -1px !important;
219
+ --ct-tip-outer: polygon(100% 0, 100% 100%, 0 50%);
220
+ --ct-tip-inner: polygon(100% 1.414px, 100% calc(100% - 1.414px), 1.414px 50%);
211
221
  }
212
222
 
213
- /* --- Top-Right Anchored (popup below-left of point, arrow points up-right) --- */
214
-
215
- .maplibregl-popup-anchor-top-right .maplibregl-popup-tip {
216
- border-bottom-color: hsl(var(--border)) !important;
223
+ /* Popup left of the point: tip on its right, mouth on the left */
224
+ .maplibregl-popup-anchor-right .maplibregl-popup-tip {
225
+ width: 11px !important;
226
+ height: 22px !important;
227
+ margin-left: -1px !important;
228
+ --ct-tip-outer: polygon(0 0, 100% 50%, 0 100%);
229
+ --ct-tip-inner: polygon(0 1.414px, calc(100% - 1.414px) 50%, 0 calc(100% - 1.414px));
217
230
  }
218
231
 
219
- .dark .maplibregl-popup-anchor-top-right .maplibregl-popup-tip {
220
- border-bottom-color: rgb(156 163 175) !important;
232
+ [dir='rtl'] .maplibregl-popup-anchor-left .maplibregl-popup-tip {
233
+ margin-right: 0 !important;
234
+ margin-left: -1px !important;
235
+ --ct-tip-outer: polygon(0 0, 100% 50%, 0 100%);
236
+ --ct-tip-inner: polygon(0 1.414px, calc(100% - 1.414px) 50%, 0 calc(100% - 1.414px));
221
237
  }
222
238
 
223
- .maplibregl-popup-anchor-top-right .maplibregl-popup-tip::after {
224
- content: '' !important;
225
- position: absolute !important;
226
- left: -10px !important;
227
- bottom: -11px !important;
228
- border-left: 10px solid transparent !important;
229
- border-right: 10px solid transparent !important;
230
- border-bottom: 10px solid hsl(var(--popover)) !important;
239
+ [dir='rtl'] .maplibregl-popup-anchor-right .maplibregl-popup-tip {
240
+ margin-left: 0 !important;
241
+ margin-right: -1px !important;
242
+ --ct-tip-outer: polygon(100% 0, 100% 100%, 0 50%);
243
+ --ct-tip-inner: polygon(100% 1.414px, 100% calc(100% - 1.414px), 1.414px 50%);
231
244
  }
232
245
 
233
- /* --- Bottom-Left Anchored (popup above-right of point, arrow points down-left) --- */
234
-
235
- .maplibregl-popup-anchor-bottom-left .maplibregl-popup-tip {
236
- border-top-color: hsl(var(--border)) !important;
246
+ /* Corner anchors: a right-angled tip whose straight side continues the
247
+ popup's side border down (or up) to the point */
248
+ .maplibregl-popup-anchor-top-left .maplibregl-popup-tip,
249
+ .maplibregl-popup-anchor-top-right .maplibregl-popup-tip,
250
+ .maplibregl-popup-anchor-bottom-left .maplibregl-popup-tip,
251
+ .maplibregl-popup-anchor-bottom-right .maplibregl-popup-tip {
252
+ width: 11px !important;
237
253
  }
238
254
 
239
- .dark .maplibregl-popup-anchor-bottom-left .maplibregl-popup-tip {
240
- border-top-color: rgb(156 163 175) !important;
255
+ .maplibregl-popup-anchor-top-left .maplibregl-popup-tip,
256
+ .maplibregl-popup-anchor-top-right .maplibregl-popup-tip {
257
+ margin-bottom: -1px !important;
241
258
  }
242
259
 
243
- .maplibregl-popup-anchor-bottom-left .maplibregl-popup-tip::after {
244
- content: '' !important;
245
- position: absolute !important;
246
- left: -10px !important;
247
- top: -11px !important;
248
- border-left: 10px solid transparent !important;
249
- border-right: 10px solid transparent !important;
250
- border-top: 10px solid hsl(var(--popover)) !important;
260
+ .maplibregl-popup-anchor-bottom-left .maplibregl-popup-tip,
261
+ .maplibregl-popup-anchor-bottom-right .maplibregl-popup-tip {
262
+ margin-top: -1px !important;
251
263
  }
252
264
 
253
- /* --- Bottom-Right Anchored (popup above-left of point, arrow points down-right) --- */
265
+ /* Point at the top-left corner */
266
+ .maplibregl-popup-anchor-top-left .maplibregl-popup-tip,
267
+ [dir='rtl'] .maplibregl-popup-anchor-top-right .maplibregl-popup-tip {
268
+ --ct-tip-outer: polygon(0 0, 100% 100%, 0 100%);
269
+ --ct-tip-inner: polygon(1px 2.414px, calc(100% - 1.414px) 100%, 1px 100%);
270
+ }
254
271
 
255
- .maplibregl-popup-anchor-bottom-right .maplibregl-popup-tip {
256
- border-top-color: hsl(var(--border)) !important;
272
+ /* Point at the top-right corner */
273
+ .maplibregl-popup-anchor-top-right .maplibregl-popup-tip,
274
+ [dir='rtl'] .maplibregl-popup-anchor-top-left .maplibregl-popup-tip {
275
+ --ct-tip-outer: polygon(100% 0, 100% 100%, 0 100%);
276
+ --ct-tip-inner: polygon(calc(100% - 1px) 2.414px, calc(100% - 1px) 100%, 1.414px 100%);
257
277
  }
258
278
 
259
- .dark .maplibregl-popup-anchor-bottom-right .maplibregl-popup-tip {
260
- border-top-color: rgb(156 163 175) !important;
279
+ /* Point at the bottom-left corner */
280
+ .maplibregl-popup-anchor-bottom-left .maplibregl-popup-tip,
281
+ [dir='rtl'] .maplibregl-popup-anchor-bottom-right .maplibregl-popup-tip {
282
+ --ct-tip-outer: polygon(0 0, 100% 0, 0 100%);
283
+ --ct-tip-inner: polygon(1px 0, calc(100% - 1.414px) 0, 1px calc(100% - 2.414px));
261
284
  }
262
285
 
263
- .maplibregl-popup-anchor-bottom-right .maplibregl-popup-tip::after {
264
- content: '' !important;
265
- position: absolute !important;
266
- left: -10px !important;
267
- top: -11px !important;
268
- border-left: 10px solid transparent !important;
269
- border-right: 10px solid transparent !important;
270
- border-top: 10px solid hsl(var(--popover)) !important;
286
+ /* Point at the bottom-right corner */
287
+ .maplibregl-popup-anchor-bottom-right .maplibregl-popup-tip,
288
+ [dir='rtl'] .maplibregl-popup-anchor-bottom-left .maplibregl-popup-tip {
289
+ --ct-tip-outer: polygon(0 0, 100% 0, 100% 100%);
290
+ --ct-tip-inner: polygon(1.414px 0, calc(100% - 1px) 0, calc(100% - 1px) calc(100% - 2.414px));
271
291
  }