@classic-homes/maps-svelte 0.7.3 → 0.7.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.
@@ -14,7 +14,7 @@
14
14
 
15
15
  <div
16
16
  class={cn(
17
- 'flex flex-col items-center justify-center rounded-lg border border-border bg-muted/50',
17
+ 'flex flex-col items-center justify-center rounded-lg border border-border bg-muted',
18
18
  className
19
19
  )}
20
20
  style:height={heightStyle}
@@ -15,7 +15,7 @@
15
15
 
16
16
  <div
17
17
  class={cn(
18
- 'flex flex-col items-center justify-center rounded-lg border border-destructive/50 bg-destructive/5',
18
+ 'flex flex-col items-center justify-center rounded-lg border border-destructive bg-background',
19
19
  className
20
20
  )}
21
21
  style:height={heightStyle}
@@ -47,7 +47,7 @@
47
47
  {#if onRetry}
48
48
  <button
49
49
  onclick={onRetry}
50
- class="mt-2 rounded-md border border-input bg-background px-4 py-2 text-sm font-medium shadow-sm hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"
50
+ class="mt-2 rounded-md border border-input bg-background px-4 py-2 text-sm font-medium shadow-sm hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"
51
51
  >
52
52
  Retry
53
53
  </button>
@@ -226,7 +226,7 @@
226
226
  <div
227
227
  class={cn(
228
228
  'absolute classic-basemap-panel-enter',
229
- 'bg-card rounded-lg shadow-lg border border-black dark:border-gray-400',
229
+ 'bg-card rounded-lg shadow-lg border border-border',
230
230
  'p-2'
231
231
  )}
232
232
  style={panelStyle}
@@ -250,8 +250,9 @@
250
250
  tabindex={index === tabStopIndex ? 0 : -1}
251
251
  class={cn(
252
252
  'flex min-h-[44px] min-w-0 flex-col items-center gap-1 p-1 rounded cursor-pointer',
253
- 'hover:bg-muted',
254
- isActive && 'ring-2 ring-primary'
253
+ // Selected: Linen, a check and a bold label. The ring is the focus
254
+ // indicator only, so arrowing onto an option never looks selected
255
+ isActive ? 'bg-accent' : 'hover:bg-muted'
255
256
  )}
256
257
  onfocus={() => (tabStopIndex = index)}
257
258
  onclick={() => handleSelect(basemap)}
@@ -266,7 +267,27 @@
266
267
  style="width: {thumbnailSize}px; height: {thumbnailSize}px;"
267
268
  />
268
269
  {/if}
269
- <span class="text-xs text-foreground truncate w-full text-center leading-tight">
270
+ <span
271
+ class={cn(
272
+ 'text-xs text-foreground truncate w-full text-center leading-tight',
273
+ isActive && 'font-semibold'
274
+ )}
275
+ >
276
+ {#if isActive}
277
+ <svg
278
+ aria-hidden="true"
279
+ width="10"
280
+ height="10"
281
+ viewBox="0 0 24 24"
282
+ fill="none"
283
+ stroke="currentColor"
284
+ stroke-width="3"
285
+ stroke-linecap="round"
286
+ stroke-linejoin="round"
287
+ style="display: inline; vertical-align: -1px; margin-right: 2px;"
288
+ ><path d="M20 6 9 17l-5-5" /></svg
289
+ >
290
+ {/if}
270
291
  {basemap.label ?? basemap.name}
271
292
  </span>
272
293
  </button>
@@ -281,7 +302,7 @@
281
302
  type="button"
282
303
  class={cn(
283
304
  'w-[44px] h-[44px] flex items-center justify-center',
284
- 'bg-card rounded shadow-lg border border-black dark:border-gray-400',
305
+ 'bg-card rounded shadow-lg border border-border',
285
306
  'hover:bg-muted cursor-pointer',
286
307
  'text-foreground'
287
308
  )}
@@ -129,7 +129,7 @@
129
129
  class={cn(
130
130
  'absolute bg-card rounded px-2 py-1',
131
131
  'text-xs font-mono text-muted-foreground',
132
- 'border border-black dark:border-gray-400 shadow-sm',
132
+ 'border border-border shadow-sm',
133
133
  'flex items-center gap-3',
134
134
  !controlPosition.visible && 'invisible',
135
135
  className
@@ -139,7 +139,7 @@
139
139
  {#if cursorLngLat}
140
140
  <span title="Cursor coordinates">{formatCoord(cursorLngLat)}</span>
141
141
  {:else}
142
- <span class="text-muted-foreground/60">Move cursor over map</span>
142
+ <span class="text-muted-foreground">Move cursor over map</span>
143
143
  {/if}
144
144
 
145
145
  {#if showZoom}
@@ -86,7 +86,7 @@
86
86
  ```svelte
87
87
  <Map>
88
88
  <CustomControl position="top-right">
89
- <div class="bg-white p-2 rounded shadow">
89
+ <div class="bg-card p-2 rounded shadow">
90
90
  Custom widget content
91
91
  </div>
92
92
  </CustomControl>
@@ -9,6 +9,8 @@
9
9
  import {
10
10
  CATEGORY_META,
11
11
  getLayerStyleForTheme,
12
+ getOutlineStyleForTheme,
13
+ OUTLINE_LAYER_SUFFIX,
12
14
  searchLayers,
13
15
  getLayerCategories,
14
16
  groupLayersByCategory,
@@ -143,6 +145,8 @@
143
145
  let lastKnownStyleVersion = -1;
144
146
  let addedSources = new Set<string>();
145
147
  let addedLayers = new Set<string>();
148
+ // Outline line layers (`style.outline`), also listed in addedLayers
149
+ const addedOutlines = new Set<string>();
146
150
 
147
151
  // Detect theme from document
148
152
  let isDark = $state(false);
@@ -219,6 +223,7 @@
219
223
  lastKnownStyleVersion = sv;
220
224
  addedSources.clear();
221
225
  addedLayers.clear();
226
+ addedOutlines.clear();
222
227
  layerThemes.clear();
223
228
  }
224
229
  });
@@ -254,6 +259,8 @@
254
259
  if (!map || !loaded) return;
255
260
 
256
261
  const currentVisibleIds = new Set(states.map((s) => s.id));
262
+ // Outline layers with paint for the current theme
263
+ const shownOutlines = new Set<string>();
257
264
 
258
265
  // Add/update visible layers
259
266
  // Use untrack to read layers without creating a dependency
@@ -361,12 +368,55 @@
361
368
  // Ignore
362
369
  }
363
370
  }
371
+
372
+ // Full-strength outline of a fill layer, as its own line layer above it
373
+ const outlinePaint = getOutlineStyleForTheme(layer, theme);
374
+ const outlineId = `${layerId}${OUTLINE_LAYER_SUFFIX}`;
375
+ if (outlinePaint && map.getLayer(layerId)) {
376
+ shownOutlines.add(outlineId);
377
+ const linePaint = {
378
+ ...outlinePaint,
379
+ 'line-opacity':
380
+ ((outlinePaint['line-opacity'] as number | undefined) ?? 1) * state.opacity,
381
+ };
382
+ try {
383
+ if (!map.getLayer(outlineId)) {
384
+ const outlineConfig: maplibregl.LineLayerSpecification = {
385
+ id: outlineId,
386
+ type: 'line',
387
+ source: sourceId,
388
+ paint: linePaint as maplibregl.LineLayerSpecification['paint'],
389
+ layout: { visibility: 'visible' },
390
+ };
391
+ if (layer.source.sourceLayer)
392
+ outlineConfig['source-layer'] = layer.source.sourceLayer;
393
+ if (layer.style.minZoom !== undefined) outlineConfig.minzoom = layer.style.minZoom;
394
+ if (layer.style.maxZoom !== undefined) outlineConfig.maxzoom = layer.style.maxZoom;
395
+ map.addLayer(outlineConfig);
396
+ addedLayers.add(outlineId);
397
+ addedOutlines.add(outlineId);
398
+ } else {
399
+ for (const [prop, value] of Object.entries(linePaint)) {
400
+ map.setPaintProperty(
401
+ outlineId,
402
+ prop as Parameters<maplibregl.Map['setPaintProperty']>[1],
403
+ value as Parameters<maplibregl.Map['setPaintProperty']>[2]
404
+ );
405
+ }
406
+ }
407
+ } catch (err) {
408
+ console.error(`[maps-svelte] LayerManager: Failed to add layer "${outlineId}":`, err);
409
+ }
410
+ }
364
411
  }
365
412
 
366
413
  // Hide layers that are no longer visible
367
414
  for (const layerId of addedLayers) {
368
415
  const originalId = layerId.replace('lm-layer-', '');
369
- if (!currentVisibleIds.has(originalId)) {
416
+ const shown = addedOutlines.has(layerId)
417
+ ? shownOutlines.has(layerId)
418
+ : currentVisibleIds.has(originalId);
419
+ if (!shown) {
370
420
  try {
371
421
  if (map.getLayer(layerId)) {
372
422
  map.setLayoutProperty(layerId, 'visibility', 'none');
@@ -629,7 +679,7 @@
629
679
  <div
630
680
  class={cn(
631
681
  'absolute classic-layer-panel-enter',
632
- 'bg-card rounded-lg shadow-lg border border-black dark:border-gray-400',
682
+ 'bg-card rounded-lg shadow-lg border border-border',
633
683
  'w-64',
634
684
  isTop ? 'top-full mt-1' : 'bottom-full mb-1',
635
685
  position.includes('right') ? 'right-0' : 'left-0'
@@ -679,6 +729,7 @@
679
729
  type="button"
680
730
  class="classic-layer-tab"
681
731
  data-active={activeCategory === 'all'}
732
+ aria-pressed={activeCategory === 'all'}
682
733
  onclick={() => (activeCategory = 'all')}
683
734
  >
684
735
  All
@@ -688,6 +739,7 @@
688
739
  type="button"
689
740
  class="classic-layer-tab"
690
741
  data-active={activeCategory === cat}
742
+ aria-pressed={activeCategory === cat}
691
743
  onclick={() => (activeCategory = cat)}
692
744
  >
693
745
  {CATEGORY_META[cat].label}
@@ -963,7 +1015,7 @@
963
1015
  type="button"
964
1016
  class={cn(
965
1017
  'w-[40px] h-[40px] flex items-center justify-center',
966
- 'bg-card rounded shadow-lg border border-black dark:border-gray-400',
1018
+ 'bg-card rounded shadow-lg border border-border',
967
1019
  'hover:bg-muted cursor-pointer',
968
1020
  'text-foreground'
969
1021
  )}
@@ -71,7 +71,7 @@
71
71
  <div
72
72
  bind:this={legendElement}
73
73
  class={cn(
74
- 'absolute bg-card rounded-lg shadow-lg border border-black dark:border-gray-400',
74
+ 'absolute bg-card rounded-lg shadow-lg border border-border',
75
75
  'text-sm min-w-[140px]',
76
76
  !controlPosition.visible && 'invisible',
77
77
  className
@@ -120,19 +120,22 @@
120
120
  class={cn(
121
121
  'flex items-center gap-2 w-full text-left rounded px-1 -mx-1',
122
122
  onItemClick && 'hover:bg-muted cursor-pointer',
123
- !onItemClick && 'cursor-default',
124
- item.active === false && 'opacity-50'
123
+ !onItemClick && 'cursor-default'
125
124
  )}
126
125
  onclick={() => handleItemClick(item, index)}
127
126
  disabled={!onItemClick}
128
127
  >
129
- <!-- border ring: light swatches (e.g. #22c55e, #f59e0b) fall
130
- under 3:1 against the panel (WCAG 1.4.11) without it -->
128
+ <!-- Grey 01 edge: light swatches (Pike's Gold, Shallows) fall under 3:1
129
+ against the panel without it. A hidden item shows a hollow swatch -->
131
130
  <span
132
- class="w-4 h-4 rounded flex-shrink-0 border border-foreground/40"
133
- style="background-color: {item.color};"
131
+ class="w-4 h-4 rounded flex-shrink-0 border border-foreground"
132
+ style="background-color: {item.active === false ? 'transparent' : item.color};"
134
133
  ></span>
135
- <span class="text-foreground">{item.label}</span>
134
+ <span
135
+ class={item.active === false
136
+ ? 'text-muted-foreground line-through'
137
+ : 'text-foreground'}>{item.label}</span
138
+ >
136
139
  {#if item.value !== undefined}
137
140
  <span class="text-muted-foreground text-xs">{item.value}</span>
138
141
  {/if}
@@ -82,7 +82,7 @@
82
82
  <div
83
83
  bind:this={containerElement}
84
84
  class={cn(
85
- 'absolute bg-card rounded-lg shadow-lg border border-black dark:border-gray-400',
85
+ 'absolute bg-card rounded-lg shadow-lg border border-border',
86
86
  'text-sm min-w-[160px] max-w-[280px]',
87
87
  !controlPosition.visible && 'invisible',
88
88
  className
@@ -140,17 +140,25 @@
140
140
  class={cn(
141
141
  'flex items-center gap-2 w-full text-left rounded px-1 -mx-1',
142
142
  legend.onItemClick && 'hover:bg-muted cursor-pointer',
143
- !legend.onItemClick && 'cursor-default',
144
- item.active === false && 'opacity-50'
143
+ !legend.onItemClick && 'cursor-default'
145
144
  )}
146
145
  onclick={() => handleItemClick(legend, item, index)}
147
146
  disabled={!legend.onItemClick}
148
147
  >
148
+ <!-- Grey 01 edge: light swatches (Pike's Gold, Shallows) fall under 3:1
149
+ against the panel without it. A hidden item shows a hollow swatch -->
149
150
  <span
150
- class="w-4 h-4 rounded flex-shrink-0"
151
- style="background-color: {item.color};"
151
+ class="w-4 h-4 rounded flex-shrink-0 border border-foreground"
152
+ style="background-color: {item.active === false ? 'transparent' : item.color};"
152
153
  ></span>
153
- <span class="text-foreground truncate flex-1">{item.label}</span>
154
+ <span
155
+ class={cn(
156
+ 'truncate flex-1',
157
+ item.active === false
158
+ ? 'text-muted-foreground line-through'
159
+ : 'text-foreground'
160
+ )}>{item.label}</span
161
+ >
154
162
  {#if item.value !== undefined}
155
163
  <span class="text-muted-foreground text-xs">{item.value}</span>
156
164
  {/if}
@@ -7,9 +7,9 @@
7
7
  applyMarkerProtection,
8
8
  applyMarkerChildProtection,
9
9
  removeMarkerProtection,
10
+ markerColor,
10
11
  } from '@classic-homes/maps-core';
11
12
  import type { MapContextValue } from '../../composables/useMapContext.svelte';
12
- import { colors } from '@classic-homes/theme-tokens';
13
13
 
14
14
  type Anchor =
15
15
  | 'center'
@@ -30,7 +30,7 @@
30
30
  let {
31
31
  id,
32
32
  coordinates,
33
- color = colors.teal[500],
33
+ color = markerColor,
34
34
  anchor = 'bottom',
35
35
  offset,
36
36
  rotation,
@@ -12,11 +12,6 @@
12
12
  let { class: className, children }: Props = $props();
13
13
  </script>
14
14
 
15
- <div
16
- class={cn(
17
- 'flex justify-end gap-2 border-t border-black dark:border-gray-400 bg-muted/30 px-4 py-3',
18
- className
19
- )}
20
- >
15
+ <div class={cn('flex justify-end gap-2 border-t border-border bg-muted px-4 py-3', className)}>
21
16
  {@render children()}
22
17
  </div>
@@ -27,7 +27,7 @@
27
27
 
28
28
  <div
29
29
  class={cn(
30
- 'flex items-start justify-between gap-2 border-b border-black dark:border-gray-400 bg-muted/30 px-4 py-3 pr-12',
30
+ 'flex items-start justify-between gap-2 border-b border-border bg-muted px-4 py-3 pr-12',
31
31
  className
32
32
  )}
33
33
  >
@@ -1,6 +1,7 @@
1
1
  <script lang="ts">
2
2
  import { getContext, onDestroy } from 'svelte';
3
3
  import type * as maplibregl from 'maplibre-gl';
4
+ import { resolveDeckInterleaved } from '@classic-homes/maps-core';
4
5
 
5
6
  /**
6
7
  * Props for the DeckOverlay component
@@ -14,7 +15,11 @@
14
15
  onClick?: (info: unknown) => void;
15
16
  /** Callback to get cursor style based on picking state */
16
17
  getCursor?: (state: { isHovering: boolean; isDragging: boolean }) => string;
17
- /** Whether to enable interleaved rendering (default: true) */
18
+ /**
19
+ * Whether to enable interleaved rendering (default: true). Ignored on
20
+ * MapLibre 6, which deck.gl cannot interleave into yet: the overlay is
21
+ * drawn on its own canvas above the map instead.
22
+ */
18
23
  interleaved?: boolean;
19
24
  /** Deck.gl effects */
20
25
  effects?: unknown[];
@@ -77,7 +82,9 @@
77
82
  MapboxOverlayClass = deckMapbox.MapboxOverlay as unknown as MapboxOverlayClass;
78
83
 
79
84
  const overlay = new MapboxOverlayClass({
80
- interleaved,
85
+ // deck.gl reads map.transform, which MapLibre 6 no longer has: every
86
+ // interleaved frame would throw, so fall back to overlaid rendering
87
+ interleaved: resolveDeckInterleaved(map, interleaved),
81
88
  layers,
82
89
  onHover,
83
90
  onClick,
@@ -13,7 +13,11 @@ interface Props {
13
13
  isHovering: boolean;
14
14
  isDragging: boolean;
15
15
  }) => string;
16
- /** Whether to enable interleaved rendering (default: true) */
16
+ /**
17
+ * Whether to enable interleaved rendering (default: true). Ignored on
18
+ * MapLibre 6, which deck.gl cannot interleave into yet: the overlay is
19
+ * drawn on its own canvas above the map instead.
20
+ */
17
21
  interleaved?: boolean;
18
22
  /** Deck.gl effects */
19
23
  effects?: unknown[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@classic-homes/maps-svelte",
3
- "version": "0.7.3",
3
+ "version": "0.7.4",
4
4
  "description": "Svelte MapLibre components for Classic Theme",
5
5
  "keywords": [
6
6
  "maps",
@@ -37,7 +37,7 @@
37
37
  "test": "vitest run"
38
38
  },
39
39
  "dependencies": {
40
- "@classic-homes/maps-core": "*",
40
+ "@classic-homes/maps-core": "^0.7.4",
41
41
  "@classic-homes/theme-svelte": "*",
42
42
  "@classic-homes/theme-tokens": "*",
43
43
  "clsx": "^2.1.0",