Skip to content

Commit beb93a6

Browse files
committed
Redesigned room marker + added room building name to map
1 parent 8faaec1 commit beb93a6

2 files changed

Lines changed: 190 additions & 187 deletions

File tree

frontend/components/RoomMapMarker.tsx

Lines changed: 58 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,77 @@
11
"use client";
2-
import useRoom from "hooks/useRoom";
3-
import Image from "next/image";
4-
import { useEffect } from "react";
2+
3+
import React, { useEffect, useRef } from "react";
54
import { Marker } from "react-map-gl/mapbox";
5+
import { alpha } from "@mui/material";
6+
import { Typography } from "@mui/material";
7+
import Box from "@mui/material/Box";
8+
import { useTheme } from "@mui/material/styles";
9+
import useRoom from "hooks/useRoom";
610

7-
const RoomMapMarker = ({
8-
roomId,
9-
roomLocation,
10-
}: {
11+
interface RoomMapMarkerProps {
1112
roomId: string;
1213
roomLocation?: (lat: number, long: number) => void;
14+
}
15+
16+
const RoomMapMarker: React.FC<RoomMapMarkerProps> = ({
17+
roomId,
18+
roomLocation,
1319
}) => {
1420
const { room } = useRoom(roomId);
21+
const hasFocusedRef = useRef(false);
22+
const theme = useTheme();
1523

1624
useEffect(() => {
17-
if (room && roomLocation) {
25+
if (!hasFocusedRef.current && room && roomLocation) {
1826
roomLocation(room.lat, room.long);
27+
hasFocusedRef.current = true;
1928
}
2029
}, [room, roomLocation]);
2130

2231
if (!room) return null;
32+
const blue = "#1976d2";
2333

2434
return (
25-
<Marker
26-
key={roomId}
27-
latitude={room.lat}
28-
longitude={room.long}
29-
anchor="bottom"
30-
>
31-
<Image src="/MapPin.png" alt="Room pin" width={30} height={30} />
35+
<Marker latitude={room.lat} longitude={room.long} anchor="bottom">
36+
<div
37+
style={{
38+
display: "flex",
39+
flexDirection: "column",
40+
alignItems: "center",
41+
position: "relative",
42+
}}
43+
>
44+
<Typography
45+
sx={{
46+
fontSize: 11,
47+
fontWeight: 500,
48+
textShadow:
49+
theme.palette.mode === "light"
50+
? "-.5px -.5px 1px #f2f2f2, .5px -.5px 1px #f2f2f2, -.5px .5px 1px #f2f2f2, .5px .5px 1px #f2f2f2"
51+
: "",
52+
color: theme.palette.text.primary,
53+
marginBottom: 1,
54+
userSelect: "none",
55+
}}
56+
>
57+
{room.name}
58+
</Typography>
59+
60+
<Box
61+
sx={(theme) => ({
62+
width: 18,
63+
height: 18,
64+
borderRadius: "50%",
65+
border: `5px solid ${blue}`,
66+
backgroundColor: "white",
67+
boxShadow: `0px 0px 6px 4px ${alpha(blue, 0.5)}`,
68+
position: "relative",
69+
"&:hover": {
70+
cursor: "pointer",
71+
},
72+
})}
73+
/>
74+
</div>
3275
</Marker>
3376
);
3477
};

0 commit comments

Comments
 (0)