Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add tooltip and direction to footer #6

Merged
merged 2 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
);
const totalLength = decodedPolyline.length;

return decodedPolyline.map(([lat, lng]: any, index: number) => ({

Check warning on line 36 in src/App.tsx

View workflow job for this annotation

GitHub Actions / frontend (20, 3.12)

Unexpected any. Specify a different type
lat,
lng,
// Map the percentage progress to the range [1, 11]
Expand Down Expand Up @@ -84,6 +84,12 @@
busData?.data.attributes.latitude,
busData?.data.attributes.longitude,
]}
destination={
routeData?.data.attributes.direction_destinations[
busData?.data.attributes.direction_id
]
}
routeId={routeId}
/>
)}
</Element>
Expand All @@ -93,6 +99,11 @@
busStatus={busStatus}
status={status}
stopName={stopName}
direction={
routeData?.data.attributes.direction_names[
busData?.data.attributes.direction_id
]
}
/>
</div>
</>
Expand Down
40 changes: 19 additions & 21 deletions src/MapLayers.tsx
Original file line number Diff line number Diff line change
@@ -1,50 +1,48 @@
import { LatLngTuple } from "leaflet";
import { useEffect } from "react";
import { useMap, useMapEvent } from "react-leaflet";
import { Marker, useMapEvent, Tooltip } from "react-leaflet";
import { Hotline } from "react-leaflet-hotline";
import { MarkerLayer, Marker } from "react-leaflet-marker";
import * as L from "leaflet";
import { ArrowRightIcon } from "@heroicons/react/20/solid";

interface MapLayersProps {
formattedPolyline: [{ lat: string; lng: string; value: number }];
position: LatLngTuple;
setZoom: (zoom: number) => void;
destination: string;
routeId: string;
}

export const MapLayers = ({
formattedPolyline,
position,
setZoom,
destination,
routeId,
}: MapLayersProps) => {
const map = useMap();

useMapEvent("zoom", (event) => {
setZoom(event.target.getZoom());
});

useEffect(() => {
// Create a custom pane with a high zIndex
const pane = map.createPane("markerPane");
pane.style.zIndex = "650";
}, [map]);

const icon = L.icon({ iconUrl: "../pride-logo.png", iconSize: [24, 24] });
return (
<>
<MarkerLayer
pane="markerPane"
attribution={
'&copy; <a href="https://transitmatters.org">TransitMatters</a>'
}
>
<Marker position={position} size={[24, 24]}>
<img className="h-6" src={"pride-logo.png"} alt="MBTA Pride Logo" />
</Marker>
</MarkerLayer>
<Marker position={position} icon={icon}>
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@devinmatte leaflet-marker-layer was making hover/etc odd so I just removed it

<Tooltip
direction="top"
offset={[0, -13]}
className="flex flex-row justify-between items-center"
>
{routeId} <ArrowRightIcon className="mx-1 h-3 w-3" />
{destination}
</Tooltip>
</Marker>

{formattedPolyline && (
<Hotline
data={formattedPolyline}
getLat={(t: any) => t.lat}

Check warning on line 43 in src/MapLayers.tsx

View workflow job for this annotation

GitHub Actions / frontend (20, 3.12)

Unexpected any. Specify a different type
getLng={(t: any) => t.lng}

Check warning on line 44 in src/MapLayers.tsx

View workflow job for this annotation

GitHub Actions / frontend (20, 3.12)

Unexpected any. Specify a different type
getVal={(t: any) => t.value}

Check warning on line 45 in src/MapLayers.tsx

View workflow job for this annotation

GitHub Actions / frontend (20, 3.12)

Unexpected any. Specify a different type
options={{
outlineWidth: 8,
outlineColor: "black",
Expand Down
10 changes: 8 additions & 2 deletions src/components/Footer.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import { ArrowRightIcon, HeartIcon } from "@heroicons/react/20/solid";
import { STATUSES, STATUS_TO_BG, useScreenDetector } from "../utils";

export const Footer = ({ busStatus, stopName, status, routeId }: any) => {
export const Footer = ({
busStatus,
stopName,
status,
routeId,
direction,
}: any) => {

Check warning on line 10 in src/components/Footer.tsx

View workflow job for this annotation

GitHub Actions / frontend (20, 3.12)

Unexpected any. Specify a different type
const { isMobile } = useScreenDetector();

return (
Expand Down Expand Up @@ -57,7 +63,7 @@
</span>
<ArrowRightIcon className="mx-2 h-5 w-5" />
<span className="inline-flex items-center rounded-md bg-yellow-300 px-2 py-1 text-xs font-medium ">
Route {routeId}
{direction} Route {routeId}
</span>
</p>
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ export const getInfo = (busData: any, routeData: any, stopData: any) => ({

export const STATUSES: any = {
INCOMING_AT: "Approaching",
STOPPED_AT: "Stopped at",
IN_TRANSIT_TO: "In transit to",
STOPPED_AT: "Stopped",
IN_TRANSIT_TO: "In transit",
};

export const STATUS_TO_BG: any = {
Expand Down
Loading