forked from HSLdevcom/OpenTripPlanner
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
55 additions
and
61 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
client-next/src/components/SearchBar/LocationInputField.tsx
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,24 @@ | ||
import { Form } from 'react-bootstrap'; | ||
import { COORDINATE_PRECISION } from './constants.ts'; | ||
import { Location } from '../../gql/graphql.ts'; | ||
|
||
export function LocationInputField({ location, id, label }: { location?: Location; id: string; label: string }) { | ||
return ( | ||
<Form.Group> | ||
<Form.Label htmlFor={id}>{label}</Form.Label> | ||
<Form.Control | ||
type="text" | ||
id={id} | ||
size="sm" | ||
placeholder="[Click in map]" | ||
value={ | ||
location | ||
? `${location.coordinates?.latitude.toPrecision( | ||
COORDINATE_PRECISION, | ||
)} ${location.coordinates?.longitude.toPrecision(COORDINATE_PRECISION)}` | ||
: undefined | ||
} | ||
/> | ||
</Form.Group> | ||
); | ||
} |
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,28 @@ | ||
import { Button, Stack } from 'react-bootstrap'; | ||
import { TripQueryVariables } from '../../gql/graphql.ts'; | ||
import { LocationInputField } from './LocationInputField.tsx'; | ||
|
||
export function SearchBar({ | ||
onRoute, | ||
tripQueryVariables, | ||
}: { | ||
onRoute: () => void; | ||
tripQueryVariables?: TripQueryVariables; | ||
}) { | ||
return ( | ||
<section | ||
style={{ | ||
height: '5rem', | ||
paddingLeft: '1rem', | ||
}} | ||
> | ||
<Stack direction="horizontal" gap={2}> | ||
<LocationInputField location={tripQueryVariables?.from} label="From" id="fromInputField" /> | ||
<LocationInputField location={tripQueryVariables?.to} label="To" id="toInputField" /> | ||
<Button variant="primary" onClick={onRoute}> | ||
Route | ||
</Button> | ||
</Stack> | ||
</section> | ||
); | ||
} |
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 @@ | ||
export const COORDINATE_PRECISION = 7; |
This file was deleted.
Oops, something went wrong.
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