Skip to content

Commit 3e3e3f2

Browse files
Merge pull request #1921 from appwrite/map-marker-fixes
Map marker fixes
2 parents a3aa07f + 5348f68 commit 3e3e3f2

File tree

11 files changed

+171
-157
lines changed

11 files changed

+171
-157
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"optimize": "node ./scripts/optimize-assets.js",
2525
"optimize:all": "node ./scripts/optimize-all.js"
2626
},
27-
"packageManager": "pnpm@10.6.2",
27+
"packageManager": "pnpm@10.8.1",
2828
"dependencies": {
2929
"@number-flow/svelte": "^0.3.3",
3030
"h3": "^1.14.0",

src/lib/actions/mouse-position.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export const useMousePosition = () => {
2020
() => {
2121
node.addEventListener('mousemove', handleMouseMove);
2222
},
23-
{ amount: 'all' }
23+
{ amount: 'any' }
2424
);
2525

2626
return {

src/lib/components/FooterNav.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@
3737
{ label: 'Functions', href: '/products/functions' },
3838
{ label: 'Messaging', href: '/products/messaging' },
3939
{ label: 'Storage', href: '/products/storage' },
40-
{ label: 'Realtime', href: '/docs/apis/realtime' }
40+
{ label: 'Realtime', href: '/docs/apis/realtime' },
41+
{ label: 'The Appwrite Network', href: '/docs/products/network' }
4142
],
4243
Learn: [
4344
{ label: 'Docs', href: '/docs' },

src/lib/components/appwrite-network/data/pins.ts

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ export const pins = {
55
lng: -77.49,
66
city: 'Ashburn',
77
code: 'ASH',
8-
available: true
8+
available: true,
9+
offsetX: 10,
10+
offsetY: -10
911
},
1012
{
1113
lat: 33.75,
@@ -64,8 +66,8 @@ export const pins = {
6466
available: true
6567
},
6668
{
67-
lat: 21.31,
68-
lng: -157.86,
69+
lat: 28.31,
70+
lng: -125.86,
6971
city: 'Honolulu',
7072
code: 'HNL',
7173
available: true
@@ -180,8 +182,7 @@ export const pins = {
180182
lng: -74.07,
181183
city: 'Bogota',
182184
code: 'BOG',
183-
available: true,
184-
x: -0.5
185+
available: true
185186
},
186187
{
187188
lat: -34.61,
@@ -198,7 +199,7 @@ export const pins = {
198199
available: true
199200
},
200201
{
201-
lat: -3.73,
202+
lat: -8.73,
202203
lng: -38.52,
203204
city: 'Fortaleza',
204205
code: 'FOR',
@@ -254,8 +255,8 @@ export const pins = {
254255
available: true
255256
},
256257
{
257-
lat: 53.35,
258-
lng: -6.26,
258+
lat: 55.35,
259+
lng: -10.26,
259260
city: 'Dublin',
260261
code: 'DUB',
261262
available: true
@@ -275,8 +276,8 @@ export const pins = {
275276
available: true
276277
},
277278
{
278-
lat: 38.72,
279-
lng: -9.14,
279+
lat: 40.72,
280+
lng: -12.14,
280281
city: 'Lisbon',
281282
code: 'LIS',
282283
available: true
@@ -289,7 +290,7 @@ export const pins = {
289290
available: true
290291
},
291292
{
292-
lat: 40.42,
293+
lat: 46.42,
293294
lng: -3.7,
294295
city: 'Madrid',
295296
code: 'MAD',
@@ -324,8 +325,8 @@ export const pins = {
324325
available: true
325326
},
326327
{
327-
lat: 59.91,
328-
lng: 10.75,
328+
lat: 62.91,
329+
lng: 8.75,
329330
city: 'Oslo',
330331
code: 'OSL',
331332
available: true
@@ -506,7 +507,7 @@ export const pins = {
506507
available: true
507508
},
508509
{
509-
lat: -36.85,
510+
lat: -39.85,
510511
lng: 174.76,
511512
city: 'Auckland',
512513
code: 'AKL',
@@ -520,8 +521,8 @@ export const pins = {
520521
available: true
521522
},
522523
{
523-
lat: -43.53,
524-
lng: 172.64,
524+
lat: -48.53,
525+
lng: 150.64,
525526
city: 'Christchurch',
526527
code: 'CHC',
527528
available: true
@@ -548,8 +549,8 @@ export const pins = {
548549
available: true
549550
},
550551
{
551-
lat: -41.29,
552-
lng: 174.78,
552+
lat: -45.29,
553+
lng: 158.78,
553554
city: 'Wellington',
554555
code: 'WLG',
555556
available: true
@@ -561,7 +562,9 @@ export const pins = {
561562
lng: -74.01,
562563
city: 'New York',
563564
code: 'NYC',
564-
available: true
565+
available: true,
566+
offsetX: 10,
567+
offsetY: -10
565568
},
566569
{
567570
lat: 50.11,
@@ -584,7 +587,9 @@ export const pins = {
584587
lng: -74.01,
585588
city: 'New York',
586589
code: 'NYC',
587-
available: true
590+
available: true,
591+
offsetX: 10,
592+
offsetY: -10
588593
},
589594
{
590595
lat: 50.11,
Lines changed: 40 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,90 +1,64 @@
11
<script lang="ts">
22
import { classNames } from '$lib/utils/classnames';
33
import { slugify } from '$lib/utils/slugify';
4-
import { Tooltip } from 'bits-ui';
4+
import { latLongToSvgPosition } from './utils/projections';
5+
import { tooltipData } from './map-tooltip.svelte';
56
67
interface Props {
78
city: string;
89
code: string;
910
index: number;
1011
lat: number;
1112
lng: number;
12-
position: {
13-
x: number;
14-
y: number;
15-
};
1613
bounds: {
1714
north: number;
1815
south: number;
1916
west: number;
2017
east: number;
2118
};
22-
available?: boolean;
19+
available: boolean;
2320
class?: string;
2421
animate?: boolean;
25-
isOpen: boolean;
2622
}
2723
28-
const {
29-
city,
30-
code,
31-
index = 0,
32-
position,
33-
available = false,
34-
class: className = '',
35-
animate = false,
36-
isOpen = false
37-
}: Props = $props();
24+
const { city, code, index = 0, lat, lng, available, animate = false }: Props = $props();
3825
39-
let open = $state(isOpen);
26+
const position = $derived(latLongToSvgPosition({ latitude: lat, longitude: lng }));
4027
41-
$effect(() => {
42-
open = isOpen;
43-
});
44-
</script>
28+
const handleSetActiveMarker = () => {
29+
tooltipData.set({
30+
city,
31+
code,
32+
available
33+
});
34+
};
4535
46-
<Tooltip.Root bind:open>
47-
<Tooltip.Trigger
48-
class={classNames(
49-
'group absolute flex size-3 cursor-pointer items-center justify-center opacity-0 [animation-delay:var(--delay)]',
50-
{ 'animate-fade-in': animate }
51-
)}
52-
style="left:{position.x}%; top:{position.y}%; --delay:{index * 10}ms;"
53-
data-region={slugify(city)}
54-
data-active={isOpen}
55-
>
56-
<span
57-
class="from-accent/20 to-accent/10 border-gradient ease-spring absolute inline-flex h-5 w-5 rounded-full bg-gradient-to-b opacity-0 transition-opacity group-hover:animate-ping group-hover:opacity-75 before:rounded-full"
58-
style:animation-duration="1.5s"
59-
></span>
60-
<span class="bg-accent absolute inline-flex h-full w-full rounded-full"></span>
61-
<span class="absolute size-1/2 rounded-full bg-white/80 transition-all"></span>
62-
</Tooltip.Trigger>
36+
const handleResetActiveMarker = () => {
37+
tooltipData.set({
38+
city: null,
39+
code: null,
40+
available: null
41+
});
42+
};
43+
</script>
6344

64-
<Tooltip.Content
65-
sideOffset={12}
66-
class={classNames(
67-
'bg-card/90 border-gradient relative z-100 flex w-[190px] flex-col gap-2 rounded-[10px] p-2 backdrop-blur-lg before:rounded-[10px] after:rounded-[10px]',
68-
'data-[state="closed"]:animate-menu-out data-[state="instant-open"]:animate-menu-in data-[state="delayed-open"]:animate-menu-in',
69-
className
70-
)}
71-
>
72-
<span class="text-primary text-caption w-fit"
73-
>{city}
74-
({code})</span
75-
>
76-
{#if available}
77-
<div
78-
class="text-caption flex h-5 items-center justify-center place-self-start rounded-md bg-[#10B981]/24 p-1 text-center text-[#B4F8E2]"
79-
>
80-
<span class="text-micro -tracking-tight">Available now</span>
81-
</div>
82-
{:else}
83-
<div
84-
class="text-caption flex h-5 items-center justify-center place-self-start rounded-md bg-white/6 p-1 text-center text-white/60"
85-
>
86-
<span class="text-micro -tracking-tight">Planned</span>
87-
</div>
88-
{/if}
89-
</Tooltip.Content>
90-
</Tooltip.Root>
45+
<button
46+
class={classNames(
47+
'group absolute z-10 flex size-2 cursor-pointer items-center justify-center opacity-0 [animation-delay:var(--delay)]',
48+
{ 'animate-fade-in': animate }
49+
)}
50+
style="left: {position.x}%; top: {position.y}%;--delay: {index * 10}ms;"
51+
data-region={slugify(city)}
52+
onmouseenter={handleSetActiveMarker}
53+
onfocus={handleSetActiveMarker}
54+
onmouseleave={handleResetActiveMarker}
55+
onblur={handleResetActiveMarker}
56+
aria-label={city}
57+
>
58+
<span
59+
class="from-accent/20 to-accent/10 border-gradient ease-spring pointer-events-none absolute inline-flex h-5 w-5 rounded-full bg-gradient-to-b opacity-0 transition-opacity group-hover:animate-ping group-hover:opacity-75 before:rounded-full"
60+
style:animation-duration="1.5s"
61+
></span>
62+
<span class="bg-accent absolute inline-flex h-full w-full rounded-full"></span>
63+
<span class="absolute size-1/2 rounded-full bg-white/80 transition-all"></span>
64+
</button>

src/lib/components/appwrite-network/map-nav.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
<Tabs.Root
3434
value={navItems[0].value}
3535
{onValueChange}
36-
class="flex flex-col items-center justify-center gap-12"
36+
class="flex flex-col items-center justify-center gap-12 md:-mt-8"
3737
>
3838
<Tabs.List
3939
class="border-smooth animate-fade-in bg-card relative grid w-full max-w-xl grid-cols-1 place-content-center gap-3 p-1 px-8 drop-shadow-md md:grid-cols-3 md:rounded-full md:border md:px-1"
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<script lang="ts" module>
2+
import { classNames } from '$lib/utils/classnames';
3+
import { writable } from 'svelte/store';
4+
5+
export const tooltipData = writable<{
6+
city: string | null;
7+
code: string | null;
8+
available: boolean | null;
9+
}>({
10+
city: null,
11+
code: null,
12+
available: null
13+
});
14+
</script>
15+
16+
<script lang="ts">
17+
type Props = {
18+
coords: {
19+
x: number;
20+
y: number;
21+
};
22+
};
23+
24+
const { coords }: Props = $props();
25+
</script>
26+
27+
{#if $tooltipData.city}
28+
<div
29+
class="pointer-events-none absolute"
30+
style:left="{coords.x - 50}px"
31+
style:top="{coords.y - 50}px"
32+
>
33+
<div
34+
class={classNames(
35+
'bg-card/90 border-gradient relative z-100 flex w-[190px] flex-col gap-2 rounded-[10px] p-2 backdrop-blur-lg before:rounded-[10px] after:rounded-[10px]',
36+
'data-[state="closed"]:animate-menu-out data-[state="instant-open"]:animate-menu-in data-[state="delayed-open"]:animate-menu-in'
37+
)}
38+
>
39+
<span class="text-primary text-caption w-fit">
40+
{$tooltipData.city}
41+
({$tooltipData.code})
42+
</span>
43+
{#if $tooltipData.available}
44+
<div
45+
class="text-caption flex h-5 items-center justify-center place-self-start rounded-md bg-[#10B981]/24 p-1 text-center text-[#B4F8E2]"
46+
>
47+
<span class="text-micro -tracking-tight">Available now</span>
48+
</div>
49+
{:else}
50+
<div
51+
class="text-caption flex h-5 items-center justify-center place-self-start rounded-md bg-white/6 p-1 text-center text-white/60"
52+
>
53+
<span class="text-micro -tracking-tight">Planned</span>
54+
</div>
55+
{/if}
56+
</div>
57+
</div>
58+
{/if}

0 commit comments

Comments
 (0)