-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #99 from DartExplore/issue#algo
Issue#88
- Loading branch information
Showing
8 changed files
with
178 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
.modal-overlay { | ||
position: fixed; | ||
top: 0; | ||
left: 0; | ||
width: 100%; | ||
height: 100%; | ||
background-color: rgb(0 0 0 / 50%); | ||
display: flex; | ||
justify-content: center; | ||
align-items: flex-start; | ||
padding-top: 10%; | ||
} | ||
|
||
.modal-content { | ||
background-color: #fff; | ||
border: solid; | ||
padding: 2em; | ||
width: 25em; | ||
max-width: 90%; | ||
box-shadow: 0 0 20px rgb(0 0 0 / 20%); | ||
border-radius: 8px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import React from "react"; | ||
|
||
import "./DirectionsModal.css"; | ||
|
||
interface DirectionsModalProps { | ||
show: boolean; | ||
onClose: () => void; | ||
placeName: string; | ||
stationName: string; | ||
currentStationName?: string; | ||
} | ||
|
||
const DirectionsModal: React.FC<DirectionsModalProps> = ({ | ||
show, | ||
onClose, | ||
placeName, | ||
stationName, | ||
currentStationName, | ||
}) => { | ||
const handleOverlayClick = (e: React.MouseEvent<HTMLDivElement>) => { | ||
if (e.target === e.currentTarget) { | ||
onClose(); | ||
} | ||
}; | ||
|
||
const buildGoogleMapsUrl = (station: string, place: string) => { | ||
const encodedStation = encodeURIComponent(station); | ||
const encodedPlace = encodeURIComponent(place); | ||
return `https://www.google.com/maps/dir/${encodedStation}/${encodedPlace}`; | ||
}; | ||
|
||
if (!show) return null; | ||
|
||
const googleMapsUrl = buildGoogleMapsUrl(stationName, placeName); | ||
const currentGoogleMapsUrl = currentStationName | ||
? buildGoogleMapsUrl(currentStationName, placeName) | ||
: null; | ||
|
||
return ( | ||
<div className="modal-overlay" onClick={handleOverlayClick}> | ||
<div className="modal-content"> | ||
<h2>Directions to {placeName}</h2> | ||
{currentGoogleMapsUrl && ( | ||
<div> | ||
<a | ||
href={currentGoogleMapsUrl} | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
> | ||
Google maps from current station | ||
</a> | ||
</div> | ||
)} | ||
<div> | ||
<a href={googleMapsUrl} target="_blank" rel="noopener noreferrer"> | ||
Google maps from final station | ||
</a> | ||
</div> | ||
<div> | ||
<p> | ||
Information about | ||
<a | ||
href="https://www.dart.org/fare/general-fares-and-overview/fares#fareoptions" | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
> | ||
purchasing station tickets | ||
</a> | ||
</p> | ||
</div> | ||
<div> | ||
<button onClick={onClose}>Close</button> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default DirectionsModal; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
flex-direction: column; | ||
gap: 0.5em; | ||
padding: 0.25em; | ||
cursor: pointer; | ||
} | ||
|
||
.place-card .name { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters