Skip to content

Commit

Permalink
Merge pull request #805 from ibi-group/set-viewed-stop-from-endpoint
Browse files Browse the repository at this point in the history
Set viewed stop from endpoint
  • Loading branch information
amy-corson-ibigroup authored Jan 15, 2025
2 parents 779128e + 3bc4a90 commit 123ffa3
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/endpoints-overlay/i18n/en-US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ otpUi:
saveAsHome: Save as home
saveAsWork: Save as work
swapLocation: Change to {locationType} location
viewNearby: View nearby
1 change: 1 addition & 0 deletions packages/endpoints-overlay/i18n/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ otpUi:
swapLocation: >-
En faire {locationType, select, from {le point de départ} to {la
destination} other {{locationType}}}
viewNearby: À proximité
3 changes: 3 additions & 0 deletions packages/endpoints-overlay/src/EndpointsOverlay.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const clearLocation = action("clearLocation");
const forgetPlace = action("forgetPlace");
const rememberPlace = action("rememberPlace");
const setLocation = action("setLocation");
const setViewNearby = action("setViewNearby");
const unnamedFromLocation = {
lat: 45.522497,
lon: -122.676029,
Expand Down Expand Up @@ -57,6 +58,7 @@ export const EndpointsOverlayWithUserSettings: ComponentStory<typeof EndpointsOv
locations={locations}
rememberPlace={rememberPlace}
setLocation={setLocation}
setViewNearby={setViewNearby}
showUserSettings
toLocation={toLocation}
/>
Expand Down Expand Up @@ -91,6 +93,7 @@ export const EndpointsOverlayWithUnnamedPlace: ComponentStory<typeof EndpointsOv
<EndpointsOverlay
fromLocation={unnamedFromLocation}
setLocation={setLocation}
setViewNearby={setViewNearby}
showUserSettings
toLocation={unnamedToLocation}
/>
Expand Down
25 changes: 24 additions & 1 deletion packages/endpoints-overlay/src/endpoint.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Briefcase } from "@styled-icons/fa-solid/Briefcase";
import { Popup } from "@opentripplanner/base-map";
import { Search } from "@styled-icons/fa-solid/Search";
import {
ClearLocationArg,
Location,
Expand Down Expand Up @@ -30,6 +31,7 @@ interface Props {
MapMarkerIcon: ComponentType<UserLocationAndType>;
rememberPlace: (arg: UserLocationAndType) => void;
setLocation: (arg: MapLocationActionArg) => void;
setViewNearby?: (arg: Location) => void;
showUserSettings: boolean;
type: string;
}
Expand Down Expand Up @@ -60,6 +62,8 @@ function UserLocationInnerIcon({ type }: IconProps) {
return <Sync size={12} />;
case "times":
return <Times size={12} />;
case "nearby":
return <Search size={12} />;
default:
return null;
}
Expand Down Expand Up @@ -150,7 +154,14 @@ const Endpoint = (props: Props): JSX.Element => {
};

const [showPopup, setShowPopup] = useState(false);
const { location, locations, MapMarkerIcon, showUserSettings, type } = props;
const {
location,
locations,
MapMarkerIcon,
setViewNearby,
showUserSettings,
type
} = props;
if (!(location && location.lat && location.lon)) return null;
const match = locations.find(l => coreUtils.map.matchLatLon(l, location));
const isWork = match && match.type === "work";
Expand Down Expand Up @@ -273,6 +284,18 @@ const Endpoint = (props: Props): JSX.Element => {
/>
</S.Button>
</div>
<div>
<S.Button onClick={() => setViewNearby(location)}>
<UserLocationIcon type="nearby" />
<FormattedMessage
defaultMessage={
defaultMessages["otpUi.EndpointsOverlay.viewStop"]
}
description="Button text to view the coordinates in the nearby view"
id="otpUi.EndpointsOverlay.viewNearby"
/>
</S.Button>
</div>
</FocusTrapWrapper>
</Popup>
)}
Expand Down
7 changes: 7 additions & 0 deletions packages/endpoints-overlay/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ interface Props {
* { location: {...location}, reverseGeocode: true, type: "from/to" }
*/
setLocation?: (arg: MapLocationActionArg) => void;
/**
* Opens the nearby view from the location coordinates
*/
setViewNearby?: (arg: Location) => void;
/**
* Whether or not to show the user settings popup when an endpoint is clicked.
*/
Expand Down Expand Up @@ -121,6 +125,7 @@ const EndpointsOverlay = ({
MapMarkerIcon = DefaultMapMarkerIcon,
rememberPlace = noop,
setLocation = noop,
setViewNearby = noop,
showUserSettings,
toLocation
}: Props): ReactElement => (
Expand All @@ -133,6 +138,7 @@ const EndpointsOverlay = ({
MapMarkerIcon={MapMarkerIcon}
rememberPlace={rememberPlace}
setLocation={setLocation}
setViewNearby={setViewNearby}
showUserSettings={showUserSettings}
type="from"
/>
Expand Down Expand Up @@ -161,6 +167,7 @@ const EndpointsOverlay = ({
rememberPlace={rememberPlace}
setLocation={setLocation}
showUserSettings={showUserSettings}
setViewNearby={setViewNearby}
type="to"
/>
</div>
Expand Down

0 comments on commit 123ffa3

Please sign in to comment.