Skip to content

Commit ee1cbc6

Browse files
committed
feat(islands): improve island popup
1 parent 1c19554 commit ee1cbc6

File tree

1 file changed

+38
-18
lines changed

1 file changed

+38
-18
lines changed

modules/MapDashboard/IslandMarkers.tsx

Lines changed: 38 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import { MapIcon } from 'lucide-react'
44
import dynamic from 'next/dynamic'
55
import Link from 'next/link'
6+
import { toast } from 'sonner'
67
import { Area } from '@/lib/const'
78
import { useMapDashboard } from './hooks/useDashboard'
89
import { useIslands } from './hooks/useIslands'
@@ -33,38 +34,57 @@ export default function IslandMarkers() {
3334
position={[island.latitude, island.longitude]}
3435
title={island.name}
3536
>
36-
<div className="flex flex-col gap-2">
37-
<b className="font-bold block">{island.name}</b>
37+
<div className="flex flex-col">
38+
<span className="font-bold block text-sm">{island.name}</span>
39+
<span className="text-sm">{island.code}</span>
3840

39-
<span className="text-xs text-gray-500 block">
40-
{island.coordinate}
41-
</span>
42-
43-
<Link
44-
href={`https://www.google.com/maps/search/${island.coordinate}`}
45-
passHref
46-
target="_blank"
47-
rel="noopener noreferrer"
48-
className="text-xs inline-flex items-center gap-2"
41+
<button
42+
type="button"
43+
onClick={() => {
44+
try {
45+
navigator.clipboard.writeText(island.coordinate)
46+
toast.success('Coordinate copied to clipboard', {
47+
duration: 3_000, // 3 seconds
48+
})
49+
} catch (_error) {
50+
toast.error('Failed to copy coordinate to clipboard', {
51+
closeButton: true,
52+
})
53+
}
54+
}}
55+
className="mt-1 flex flex-col items-start gap-0"
56+
title="Copy Coordinate"
4957
>
50-
<MapIcon className="size-4" />
51-
See on Google Maps
52-
</Link>
58+
<span className="text-xs text-gray-500 block">Coordinate :</span>
59+
<br />
60+
<span className="text-xs">{island.coordinate}</span>
61+
</button>
5362

5463
{(island.isPopulated || island.isOutermostSmall) && (
55-
<div className="flex gap-1 mt-1">
64+
<div className="flex gap-1 mt-2">
5665
{island.isPopulated && (
57-
<span className="bg-green-500 text-popover font-semibold rounded-full px-2 py-1">
66+
<span className="bg-green-500 text-xs text-popover font-semibold rounded px-2 py-0.5">
5867
Populated
5968
</span>
6069
)}
6170
{island.isOutermostSmall && (
62-
<span className="bg-red-500 text-popover font-semibold rounded-full px-2 py-1">
71+
<span className="bg-red-500 text-xs text-popover font-semibold rounded px-2 py-0.5">
6372
Outermost Small Island
6473
</span>
6574
)}
6675
</div>
6776
)}
77+
78+
<Link
79+
href={`https://www.google.com/maps/search/${island.coordinate}`}
80+
passHref
81+
target="_blank"
82+
rel="noopener noreferrer"
83+
className="text-xs inline-flex items-center gap-2 mt-4"
84+
>
85+
<MapIcon className="size-4" />
86+
See on Google Maps
87+
</Link>
6888
</div>
6989
</MapMarker>
7090
))}

0 commit comments

Comments
 (0)